我正在尝试为 Sublimetext2 程序构建一个插件。
它使用用 Python 编码的插件。我根本没有 Python 知识,但通过查看现有插件和我的 PHP 知识,我需要帮助...
到目前为止,这是 Python 文件的开始
import sublime, sublime_plugin
import webbrowser
settings = sublime.load_settings('openonserver.sublime-settings')
settings.get('file_path_prefix')
settings.get('server_url')
class OpenonServerCommand(sublime_plugin.TextCommand):
def run(self,edit):
file_path = self.view.file_name()
我需要做的虽然取设置的值
file_path
将是我正在运行它的文件的路径,所以可以说......
E:\Server\htdocs\mytest_project_\some\folder_\test.php
设置
file_path_prefix
将是E:\Server\htdocs\
和
server_url
将会http://localhost/
我需要看看是否file_path_prefix
存在,如果存在file_path
,
我需要E:\Server\htdocs\
用 thehttp://localhost/
替换并全部替换\
为/
,然后将这个新路径存储在一个变量中
所以……
E:\Server\htdocs\mytest_project_\some\folder_\test.php
会变成
http://localhost/mytest_project_/some/folder_/test.php
然后我需要将其发送到浏览器。
任何帮助是极大的赞赏