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


Python sublime.encode_value方法代码示例

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


在下文中一共展示了sublime.encode_value方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run_command

# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import encode_value [as 别名]
def run_command(command, data=None, callback=None):
    debug("run_command", [NODE_BIN, command, data])
    json = sublime.encode_value({"command": command, "args": data})
    err = None
    out = None
    try:
        (err, out) = exec([NODE_BIN, "--no-warnings", RUN_PATH], json)
    except Exception as e:
        err = traceback.format_exc()
    if bool(err):
        if callback is not None:
            return callback(err, None)
        raise err
    # debug('run_command: trying to decode', out)
    result = sublime.decode_value(out)
    if callback is not None:
        return callback(None, result)
    return result 
开发者ID:unlight,项目名称:sublime-import-helper,代码行数:20,代码来源:exec_command.py

示例2: load

# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import encode_value [as 别名]
def load(self, default=[]):
        self.fdir = os.path.dirname(self.fpath)
        if not os.path.isdir(self.fdir):
            os.makedirs(self.fdir)
        if os.path.exists(self.fpath):
            with open(self.fpath, mode='r', encoding=self.encoding) as f:
                content = f.read()
                try:
                    data = sublime.decode_value(content)
                except Exception:
                    sublime.message_dialog('%s is bad!' % self.fpath)
                    raise
                if not data:
                    data = default
        else:
            with open(self.fpath, mode='w', encoding=self.encoding, newline='\n') as f:
                data = default
                f.write(sublime.encode_value(data, True))
        return data 
开发者ID:randy3k,项目名称:ProjectManager,代码行数:21,代码来源:json_file.py

示例3: getJsonOrGenerate

# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import encode_value [as 别名]
def getJsonOrGenerate(name, callback):
    filename = getI18nCachePath() + name + '.json'
    if os.path.exists(filename):
        with open(filename, 'r', encoding='utf8') as f:
            json = f.read(10485760)
        content = sublime.decode_value(json)

    else:
        content = callback()

        dirname = os.path.dirname(filename)
        if not os.path.isdir(dirname):
            os.makedirs(dirname)
        with open(filename, 'w', encoding="utf8") as f:
            f.write(sublime.encode_value(content))

    return content 
开发者ID:garveen,项目名称:docphp,代码行数:19,代码来源:docphp.py

示例4: save

# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import encode_value [as 别名]
def save(self, data, indent=4):
        self.fdir = os.path.dirname(self.fpath)
        if not os.path.isdir(self.fdir):
            os.makedirs(self.fdir)
        f = codecs.open(self.fpath, "w+", encoding=self.encoding)
        f.write(sublime.encode_value(data, True))
        f.close() 
开发者ID:SublimeText,项目名称:UnitTesting,代码行数:9,代码来源:json_file.py

示例5: save

# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import encode_value [as 别名]
def save(self, data, indent=4):
        self.fdir = os.path.dirname(self.fpath)
        if not os.path.isdir(self.fdir):
            os.makedirs(self.fdir)
        with open(self.fpath, mode='w', encoding=self.encoding, newline='\n') as f:
            f.write(sublime.encode_value(data, True)) 
开发者ID:randy3k,项目名称:ProjectManager,代码行数:8,代码来源:json_file.py

示例6: write_new_theme

# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import encode_value [as 别名]
def write_new_theme(self, name):
        full_path = os.path.join(sublime.packages_path(), self.get_theme_path(name))

        with util.file.safe_open(full_path, "wb", buffering=0) as out_f:
            out_f.write(sublime.encode_value(self.dict, pretty=True).encode("utf-8")) 
开发者ID:timbrel,项目名称:GitSavvy,代码行数:7,代码来源:theme_generator.py

示例7: toggle

# 需要导入模块: import sublime [as 别名]
# 或者: from sublime import encode_value [as 别名]
def toggle():
    preferences = sublime.load_settings("Preferences.sublime-settings")
    color_scheme = os.path.basename(preferences.get("color_scheme"))
    color_scheme_file = os.path.splitext(color_scheme)[0] + ".sublime-color-scheme"
    user_color_scheme = get_user_color_scheme("Packages/User/" + color_scheme_file)
    user_color_scheme_path = os.path.join(
        sublime.packages_path(), "User", color_scheme_file
    )

    non_cfml_rules = [
        row
        for row in user_color_scheme["rules"]
        if "scope" not in row or not row["scope"].endswith("cfml")
    ]
    has_cfml_rules = len(user_color_scheme["rules"]) > len(non_cfml_rules)

    if has_cfml_rules:
        user_color_scheme["rules"] = non_cfml_rules
    else:
        user_color_scheme["rules"].extend(get_cfml_rules())

    with open(user_color_scheme_path, "w") as f:
        f.write(sublime.encode_value(user_color_scheme, True))

    if len(user_color_scheme.keys()) == 1 and len(user_color_scheme["rules"]) == 0:
        print("CFML: Packages/User/{} is now empty.".format(color_scheme_file)) 
开发者ID:jcberquist,项目名称:sublimetext-cfml,代码行数:28,代码来源:color_scheme_styles.py


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