本文整理汇总了Python中sublime.expand_variables函数的典型用法代码示例。如果您正苦于以下问题:Python expand_variables函数的具体用法?Python expand_variables怎么用?Python expand_variables使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了expand_variables函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: render_result
def render_result(result_data, test_bundle, reporter):
# lowercase all the keys since we can't guarantee the casing coming from CFML
# also convert floats to ints, since CFML might serialize ints to floats
result_data = preprocess(result_data)
padToLen = 7 if reporter == "compacttext" else 0
result_string = sublime.expand_variables(
RESULT_TEMPLATES[reporter]["results"], filter_stats_dict(result_data, padToLen)
)
for bundle in result_data["bundlestats"]:
if len(test_bundle) and bundle["path"] != test_bundle:
continue
result_string += sublime.expand_variables(
RESULT_TEMPLATES[reporter]["bundle"], filter_stats_dict(bundle)
)
if isinstance(bundle["globalexception"], dict):
result_string += (
sublime.expand_variables(
RESULT_TEMPLATES[reporter]["global_exception"],
filter_exception_dict(bundle["globalexception"]),
)
+ "\n"
)
for suite in bundle["suitestats"]:
result_string += gen_suite_report(bundle, suite, reporter)
result_string += "\n" + RESULT_TEMPLATES[reporter]["legend"]
return result_string
开发者ID:thomasrotter,项目名称:sublimetext-cfml,代码行数:31,代码来源:test_runner.py
示例2: convert
def convert(m):
quote = m.group("quote")
if quote:
var = sublime.expand_variables(m.group("quoted_var"), extracted_variables)
if quote == "'":
return "'" + escape_squote(var) + "'"
else:
return '"' + escape_dquote(var) + '"'
else:
return sublime.expand_variables(m.group("var"), extracted_variables)
开发者ID:randy3k,项目名称:SendREPL,代码行数:10,代码来源:send_code.py
示例3: generate_previews
def generate_previews(docs, current_index):
preview_html_variables = dict(docs[current_index].preview_html_variables["html"])
preview_html_variables["pagination"] = (
build_pagination(current_index, len(docs)) if len(docs) > 1 else ""
)
html = sublime.expand_variables(PREVIEW_TEMPLATE, preview_html_variables)
return html, docs[current_index].preview_regions
开发者ID:thomasrotter,项目名称:sublimetext-cfml,代码行数:7,代码来源:method_preview.py
示例4: build_cfdoc
def build_cfdoc(function_or_tag, data):
cfdoc = dict(CFDOCS_STYLES)
cfdoc["links"] = [{"href": "http://cfdocs.org" + "/" + function_or_tag, "text": "cfdocs.org" + "/" + function_or_tag}]
cfdoc["header"] = data["syntax"].replace("<","<").replace(">",">")
if len(data["returns"]) > 0:
cfdoc["header"] += ":" + data["returns"]
cfdoc["description"] = "<div class=\"engines\">"
for engine in sorted(CFDOCS_ENGINES):
if engine not in data["engines"]:
continue
cfdoc["description"] += build_engine_span(engine, data["engines"][engine]["minimum_version"])
cfdoc["description"] += "</div>"
cfdoc["description"] += data["description"].replace("<","<").replace(">",">").replace("\n","<br>")
cfdoc["body"] = ""
if len(data["params"]) > 0:
cfdoc["body"] = "<ul>"
for param in data["params"]:
param_variables = {"name": param["name"], "description": param["description"].replace("\n","<br>"), "values": ""}
if "values" in param and len(param["values"]):
param_variables["values"] = "<em>values:</em> " + ", ".join([str(value) for value in param["values"]])
cfdoc["body"] += "<li>" + sublime.expand_variables(CFDOCS_PARAM_TEMPLATE, param_variables) + "</li>"
cfdoc["body"] += "</ul>"
return cfdoc
开发者ID:Ortus-Solutions,项目名称:sublimetext-cfml,代码行数:27,代码来源:cfdocs.py
示例5: build_completion_doc
def build_completion_doc(function_call_params, data):
cfdoc = dict(CFDOCS_STYLES)
cfdoc["header"] = data["syntax"].split('(')[0] + "(...)"
if len(data["returns"]) > 0:
cfdoc["header"] += ":" + data["returns"]
cfdoc["description"] = ""
cfdoc["body"] = ""
description_params = []
if len(data["params"]) > 0:
for index, param in enumerate(data["params"]):
if function_call_params.named_params:
active_name = function_call_params.params[function_call_params.current_index][0] or ""
is_active = active_name.lower() == param["name"].lower()
else:
is_active = index == function_call_params.current_index
if is_active:
param_variables = {"name": param["name"], "description": param["description"].replace("\n", "<br>"), "values": ""}
if "values" in param and len(param["values"]):
param_variables["values"] = "<em>values:</em> " + ", ".join([str(value) for value in param["values"]])
if len(param_variables["description"]) > 0 or len(param_variables["values"]) > 0:
cfdoc["body"] = sublime.expand_variables("<p>${description}</p><p>${values}</p>", param_variables)
description_params.append("<span class=\"active\">" + param["name"] + "</span>")
elif param["required"]:
description_params.append("<span class=\"required\">" + param["name"] + "</span>")
else:
description_params.append("<span class=\"optional\">" + param["name"] + "</span>")
cfdoc["description"] = "(" + ", ".join(description_params) + ")"
return cfdoc
开发者ID:jcberquist,项目名称:sublimetext-cfml,代码行数:33,代码来源:cfdocs.py
示例6: run
def run(self, args = []):
# 替换参数中的环境变量
env = self.window.extract_variables()
args = [sublime.expand_variables(x, env) for x in args]
# 获取【sublime】执行路径
executable_path = sublime.executable_path()
# 获取【OSX】下的【subl】目录
if sublime.platform() == 'osx':
app_path = executable_path[:executable_path.rfind(".app/") + 5]
executable_path = app_path + "Contents/SharedSupport/bin/subl"
# 运行【subl】命令
subprocess.Popen([executable_path] + args)
# 修复在【Windows】下窗口推动焦点
if sublime.platform() == "windows":
def fix_focus():
window = sublime.active_window()
view = window.active_view()
window.run_command('focus_neighboring_group')
window.focus_view(view)
sublime.set_timeout(fix_focus, 300)
开发者ID:edonet,项目名称:package,代码行数:26,代码来源:subl_command.py
示例7: createExecDict
def createExecDict(self, sourceDict):
global custom_var_list
print("hello")
project_data = self.window.project_data()
project_settings = (project_data or {}).get("settings", {})
# Get the view specific settings
view_settings = self.window.active_view().settings()
# Variables to expnd; start with defaults, then add ours
variables = self.window.extract_variables()
print(type(variables))
for custom_var in custom_var_list:
setting = project_settings.get(custom_var, "")
variables[custom_var] = view_settings.get(custom_var,
project_settings.get(custom_var, ""))
# Create arguments to return by expading variables in the arguments given
args = sublime.expand_variables(sourceDict, variables)
# Rename the command parameter to what exec expects
args["cmd"] = args.pop("command", [])
return args
开发者ID:Zouch,项目名称:Utils,代码行数:28,代码来源:custom_build.py
示例8: get_working_dir
def get_working_dir(self):
build_systems = self.project_data()["build_systems"]
for build_system in build_systems:
if "working_dir" in build_system:
return sublime.expand_variables(build_system["working_dir"], self.extract_variables())
return None
开发者ID:ciechowoj,项目名称:minion,代码行数:8,代码来源:minion.py
示例9: build_cfdoc_html
def build_cfdoc_html(function_or_tag, data):
variables = { "function_or_tag": function_or_tag, "href": "http://cfdocs.org/" + function_or_tag, "params": "" }
variables["syntax"] = data["syntax"].replace("<","<").replace(">",">")
variables["description"] = data["description"].replace("<","<").replace(">",">").replace("\n","<br>")
if len(data["returns"]) > 0:
variables["syntax"] += ":" + data["returns"]
if len(data["params"]) > 0:
variables["params"] = "<ul>"
for param in data["params"]:
param_variables = {"name": param["name"], "description": param["description"].replace("\n","<br>"), "values": ""}
if len(param["values"]):
param_variables["values"] = "<em>values:</em> " + ", ".join([str(value) for value in param["values"]])
variables["params"] += "<li>" + sublime.expand_variables(CFDOCS_PARAM_TEMPLATE, param_variables) + "</li>"
variables["params"] += "</ul>"
return sublime.expand_variables(CFDOCS_TEMPLATE, variables)
开发者ID:Ortus-Solutions,项目名称:sublimetext-lucee,代码行数:18,代码来源:cfdocs.py
示例10: get_window_env
def get_window_env(window: sublime.Window, config: ClientConfig):
# Create a dictionary of Sublime Text variables
variables = window.extract_variables()
# Expand language server command line environment variables
expanded_args = list(
sublime.expand_variables(os.path.expanduser(arg), variables)
for arg in config.binary_args
)
# Override OS environment variables
env = os.environ.copy()
for var, value in config.env.items():
# Expand both ST and OS environment variables
env[var] = os.path.expandvars(sublime.expand_variables(value, variables))
return expanded_args, env
开发者ID:Kronuz,项目名称:SublimeCodeIntel,代码行数:18,代码来源:clients.py
示例11: render_result
def render_result(result_data, test_bundle):
# lowercase all the keys since we can't guarantee the casing coming from CFML
result_data = lcase_keys(result_data)
result_string = sublime.expand_variables(RESULTS_TEMPLATES["results"], filter_stats_dict(result_data)) + "\n"
for bundle in result_data["bundlestats"]:
if len(test_bundle) and bundle["path"] != test_bundle:
continue
result_string += "\n" + sublime.expand_variables(RESULTS_TEMPLATES["bundle"], filter_stats_dict(bundle)) + "\n"
if isinstance(bundle["globalexception"], dict):
result_string += "\n" + sublime.expand_variables(RESULTS_TEMPLATES["global_exception"], filter_exception_dict(bundle["globalexception"])) + "\n"
for suite in bundle["suitestats"]:
result_string += "\n" + gen_suite_report(suite)
result_string += "\n" + RESULTS_TEMPLATES["legend"]
return result_string
开发者ID:Ortus-Solutions,项目名称:sublimetext-cfml,代码行数:19,代码来源:test_runner.py
示例12: start_client
def start_client(window: sublime.Window, project_path: str, config: ClientConfig):
if config.name in client_start_listeners:
handler_startup_hook = client_start_listeners[config.name]
if not handler_startup_hook(window):
return
if settings.show_status_messages:
window.status_message("Starting " + config.name + "...")
debug("starting in", project_path)
# Create a dictionary of Sublime Text variables
variables = window.extract_variables()
# Expand language server command line environment variables
expanded_args = list(
sublime.expand_variables(os.path.expanduser(arg), variables)
for arg in config.binary_args
)
# Override OS environment variables
env = os.environ.copy()
for var, value in config.env.items():
# Expand both ST and OS environment variables
env[var] = os.path.expandvars(sublime.expand_variables(value, variables))
# TODO: don't start process if tcp already up or command empty?
process = start_server(expanded_args, project_path, env)
if not process:
window.status_message("Could not start " + config.name + ", disabling")
debug("Could not start", config.binary_args, ", disabling")
return None
if config.tcp_port is not None:
client = attach_tcp_client(config.tcp_port, process, settings)
else:
client = attach_stdio_client(process, settings)
if not client:
window.status_message("Could not connect to " + config.name + ", disabling")
return None
return client
开发者ID:Kronuz,项目名称:SublimeCodeIntel,代码行数:43,代码来源:main.py
示例13: build_pagination
def build_pagination(current_index, total_pages):
pagination_variables = {"current_page": str(current_index + 1), "total_pages": str(total_pages)}
previous_index = current_index - 1 if current_index > 0 else total_pages - 1
pagination_variables["prev"] = "page_" + str(previous_index)
next_index = current_index + 1 if current_index < total_pages - 1 else 0
pagination_variables["next"] = "page_" + str(next_index)
return sublime.expand_variables(PAGINATION_TEMPLATE, pagination_variables)
开发者ID:jcberquist,项目名称:sublimetext-cfml,代码行数:10,代码来源:inline_documentation.py
示例14: expandConfig
def expandConfig(path):
# get project name
project_name = sublime.active_window().project_file_name()
if project_name:
variables = {
'project_dir': os.path.dirname(project_name)
}
# permit '${project_dir}' to allow a configuration file
# relative to the project to be specified.
path = sublime.expand_variables(path, variables)
return os.path.expandvars(path)
开发者ID:obxyann,项目名称:Sublime-Uncrustify,代码行数:11,代码来源:Uncrustify.py
示例15: expand
def expand(view, path):
"""Expand the given path
"""
window = view.window()
if window is not None:
tmp = sublime.expand_variables(path, window.extract_variables())
tmp = os.path.expanduser(os.path.expandvars(tmp))
else:
return path
return tmp
开发者ID:cydib,项目名称:Sublime-Text-3,代码行数:12,代码来源:helpers.py
示例16: build_completion_doc
def build_completion_doc(function_call_params, data):
cfdoc = {"side_color": SIDE_COLOR, "html": {}}
cfdoc["html"]["header"] = build_cfdoc_header(data, False)
cfdoc["html"]["body"] = ""
description_params = []
if len(data["params"]) > 0:
for index, param in enumerate(data["params"]):
if function_call_params.named_params:
active_name = (
function_call_params.params[function_call_params.current_index][0]
or ""
)
is_active = active_name.lower() == param["name"].lower()
else:
is_active = index == function_call_params.current_index
if is_active:
param_variables = {
"name": param["name"],
"description": param["description"].replace("\n", "<br>"),
"values": "",
}
if "type" in param and len(param["type"]):
param_variables["name"] += ": " + param["type"]
if "values" in param and len(param["values"]):
param_variables["values"] = "<em>values:</em> " + ", ".join(
[str(value) for value in param["values"]]
)
if (
len(param_variables["description"]) > 0
or len(param_variables["values"]) > 0
):
cfdoc["html"]["body"] = sublime.expand_variables(
"<p>${description}</p><p>${values}</p>", param_variables
)
description_params.append(
'<span class="active">' + param["name"] + "</span>"
)
elif param["required"]:
description_params.append(
'<span class="required">' + param["name"] + "</span>"
)
else:
description_params.append(
'<span class="optional">' + param["name"] + "</span>"
)
cfdoc["html"]["arguments"] = "(" + ", ".join(description_params) + ")"
return cfdoc
开发者ID:thomasrotter,项目名称:sublimetext-cfml,代码行数:53,代码来源:cfdocs.py
示例17: recursive_replace
def recursive_replace(variables, value):
if isinstance(value, str):
value = sublime.expand_variables(value, variables)
return os.path.expanduser(value)
elif isinstance(value, Mapping):
return {key: recursive_replace(variables, val)
for key, val in value.items()}
elif isinstance(value, Sequence):
return [recursive_replace(variables, item)
for item in value]
else:
return value
开发者ID:mandx,项目名称:SublimeLinter,代码行数:12,代码来源:linter.py
示例18: start_server
def start_server():
global server_process
global client_path
out = call(client_path + " -q", shell=True, stdout=PIPE)
if out == 0:
print("Already running!")
return
global plugin_settings
plugin_settings = sublime.load_settings('DKit.sublime-settings')
global server_port
server_port = read_settings('dcd_port', 9166)
dcd_path = read_settings('dcd_path', '')
global server_path
server_path = os.path.join(dcd_path, 'dcd-server' + ('.exe' if sys.platform == 'win32' else ''))
client_path = os.path.join(dcd_path, 'dcd-client' + ('.exe' if sys.platform == 'win32' else ''))
server_path = sublime.expand_variables(server_path, sublime.active_window().extract_variables())
client_path = sublime.expand_variables(client_path, sublime.active_window().extract_variables())
if not os.path.exists(server_path):
sublime.error_message('DCD server doesn\'t exist in the path specified:\n' + server_path + '\n\nSetup the path in DCD package settings and then restart sublime to get things working.')
return False
if not os.path.exists(client_path):
sublime.error_message('DCD client doesn\'t exist in the path specified:\n' + client_path + '\n\nSetup the path in DCD package settings and then restart sublime to get things working.')
return False
include_paths = read_all_settings('include_paths')
include_paths = ['-I"' + p + '"' for p in include_paths]
args = ['"%s"' % server_path]
args.extend(include_paths)
args.extend(['-p' + str(server_port)])
print('Restarting DCD server...')
server_process = Popen(get_shell_args(args), shell=True)
return True
开发者ID:yazd,项目名称:DKit,代码行数:40,代码来源:DKit.py
示例19: run
def run(self, edit, saving=False):
view = self.view
global_settings = sublime.load_settings(__name__ + '.sublime-settings')
build_on_save = view.settings().get('build_on_save', global_settings.get('build_on_save', False))
filter_execute = view.settings().get('filter_execute', global_settings.get('filter_execute', []))
if saving and not build_on_save:
return
for filter, execute in filter_execute:
if re.search(filter, view.file_name()):
view.window().run_command("exec", {"cmd": sublime.expand_variables(execute,view.window().extract_variables())})
开发者ID:bisk8s,项目名称:ExecuteOnSave,代码行数:13,代码来源:ExecuteOnSave.py
示例20: pep8_params
def pep8_params():
"""Return params for the autopep8 module."""
user_settings = get_user_settings()
env_vars = sublime.active_window().extract_variables()
params = ['-d'] # args for preview
# read settings
for opt in AUTOPEP8_OPTIONS:
opt_value = user_settings.get(opt, '')
if opt_value == '' or opt_value is None:
continue
if opt_value and opt in ('exclude', 'global-config'):
opt_value = sublime.expand_variables(opt_value, env_vars)
if opt in ('exclude', 'global-config'):
if opt_value:
opt_value = sublime.expand_variables(opt_value, env_vars)
params.append('--{0}={1}'.format(opt, opt_value))
elif opt in ('ignore', 'select'):
# remove white spaces as autopep8 does not trim them
opt_value = ','.join(param.strip()
for param in opt_value.split(','))
params.append('--{0}={1}'.format(opt, opt_value))
elif opt in ('ignore-local-config', 'hang-closing'):
if opt_value:
params.append('--{0}'.format(opt))
else:
params.append('--{0}={1}'.format(opt, opt_value))
# use verbose==2 to catch non-fixed issues
params.extend(['--verbose'] * 2)
# autopep8.parse_args required at least one positional argument,
# fake-file parent folder is used as location for local configs.
params.append(sublime.expand_variables('${folder}/fake-file', env_vars))
logger.info('pep8_params: %s', params)
args = autopep8.parse_args(params, apply_config=True)
return args
开发者ID:wistful,项目名称:SublimeAutoPEP8,代码行数:39,代码来源:sublautopep8.py
注:本文中的sublime.expand_variables函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论