当前位置: 首页>>代码示例>>Python>>正文


Python sublime.expand_variables函数代码示例

本文整理汇总了Python中sublime.expand_variables函数的典型用法代码示例。如果您正苦于以下问题:Python expand_variables函数的具体用法?Python expand_variables怎么用?Python expand_variables使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了expand_variables函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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("<","&lt;").replace(">","&gt;")
	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("<","&lt;").replace(">","&gt;").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("<","&lt;").replace(">","&gt;")
	variables["description"] = data["description"].replace("<","&lt;").replace(">","&gt;").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


注:本文中的sublime.expand_variables函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。