python类packages_path()的实例源码

ConvertToUTF8.py 文件源码 项目:macos-st-packages 作者: zce 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def __init__(self):
        self.file = os.path.join(sublime.packages_path(), 'User', 'encoding_cache.json')
        self.cache = []
        self.max_size = -1
        self.dirty = False
        self.load()
ConvertToUTF8.py 文件源码 项目:macos-st-packages 作者: zce 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def init_settings():
    global encoding_cache, TMP_DIR
    encoding_cache = EncodingCache()
    get_settings()
    sublime.load_settings('ConvertToUTF8.sublime-settings').add_on_change('get_settings', get_settings)
    TMP_DIR = os.path.join(sublime.packages_path(), 'User', 'c2u_tmp')
    if not os.path.exists(TMP_DIR):
        os.mkdir(TMP_DIR)
helpers.py 文件源码 项目:sublime-atomizr 作者: idleberg 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def get_coffee(this):
        import os

        # package locations
        locations = [sublime.installed_packages_path(), sublime.packages_path()]

        # supported packages
        packages = ["Better CoffeeScript", "CoffeeScript", "IcedCoffeeScript", "Mongoose CoffeeScript"]

        # iterate over packages locations
        for location in locations:
            # iterate over packages installed with Package Control
            for package in packages:
                # is "ignored_package"?
                settings = sublime.load_settings('Preferences.sublime-settings').get("ignored_packages")
                if package in settings:
                    continue

                if os.path.isfile(location + "/" + package + ".sublime-package") is True:
                    if package is "IcedCoffeeScript":
                        this.view.set_syntax_file("Packages/IcedCoffeeScript/Syntaxes/IcedCoffeeScript.tmLanguage")
                        return True
                    elif package is "Mongoose CoffeeScript":
                        this.view.set_syntax_file("Packages/Mongoose CoffeeScript/CoffeeScript.tmLanguage")
                        return True
                    else:
                        this.view.set_syntax_file("Packages/" + package + "/CoffeeScript.tmLanguage")
                        return True

        sublime.message_dialog("Atomizr\n\nAutomatic conversion requires a supported CoffeeScript package to be installed")
        return False
__init__.py 文件源码 项目:Requester 作者: kylebebak 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def get_env(self):
        """Computes an env from various settings: `requester.env_string`,
        `requester.file`, `requester.env_file` settings. Returns a tuple
        containing an env dictionary and a combined env string.

        http://stackoverflow.com/questions/67631/how-to-import-a-module-given-the-full-path
        """
        env_strings = []
        packages_path = self.config.get('packages_path', '')
        if packages_path and packages_path not in sys.path:  # makes it possible to import any Python package in env
            sys.path.append(packages_path)

        env_strings.append(self.view.settings().get('requester.env_string', None))

        if not self.view.settings().get('requester.env_block_parsed', None):
            # if env block was already parsed don't parse it again
            file = self.view.settings().get('requester.file', None)
            if file:
                try:
                    with open(file, 'r', encoding='utf-8') as f:
                        text = f.read()
                except Exception as e:
                    self.add_error_status_bar(str(e))
                else:
                    env_strings.append(self.parse_env_block(text))

        env_file = self.view.settings().get('requester.env_file', None)
        if env_file:
            try:
                with open(env_file, 'r') as f:
                    env_strings.append(f.read())
            except Exception as e:
                self.add_error_status_bar(str(e))

        env_string = '\n\n'.join(s for s in env_strings if s)
        return self.get_env_dict_from_string(env_string), env_string
test_integration.py 文件源码 项目:Requester 作者: kylebebak 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def test_single_request_with_env_file(self):
        """From env file.
        """
        view = self.window.open_file(
            path.join(sublime.packages_path(), 'Requester', 'tests', 'requester_env_file.py')
        )
        yield 1000  # not waiting here causes a strange bug to happen
        select_line_beginnings(view, 4)
        view.run_command('requester')
        yield self.WAIT_MS
        view.close()
        self._test_url_in_view(self.window.active_view(), 'http://127.0.0.1:8000/get')
        self._test_name_in_view(self.window.active_view(), 'GET: /get')
request_history.py 文件源码 项目:Requester 作者: kylebebak 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def delete_request(view, history_path=None):
    """Delete request in this staging `view` from request history.
    """
    if not view.settings().get('requester.response_view') or not view.settings().get('requester.history_view'):
        return

    reqs = load_history(rev=False)
    index = view.settings().get('requester.request_history_index', None)
    if index is None:
        sublime.error_message("History Error: request index doesn't exist")
        return

    try:
        params_dict = reqs[index][1]
    except IndexError as e:
        sublime.error_message('RequestHistory Error: {}'.format(e))
        return

    request = params_dict['request']
    file = params_dict['file']
    key = '{};;{}'.format(request, file) if file else request
    rh = load_history(as_dict=True)
    try:
        del rh[key]
    except KeyError:
        pass
    try:
        del rh[request]  # also delete identical requests not sent from any file
    except KeyError:
        pass

    config = sublime.load_settings('Requester.sublime-settings')
    history_file = config.get('history_file', None)
    if not history_path:
        history_path = os.path.join(sublime.packages_path(), 'User', history_file)
    write_json_file(rh, history_path)
sublimefunctions.py 文件源码 项目:FileManager 作者: math2001 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def plugin_loaded():
    global TEMPLATE_FOLDER
    TEMPLATE_FOLDER = os.path.join(sublime.packages_path(), 'User', '.FileManager')
    if not os.path.exists(TEMPLATE_FOLDER):
        makedirs(TEMPLATE_FOLDER)
Assembly RGBDS.py 文件源码 项目:Assembly-RGBDS 作者: michalisb 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def plugin_loaded():
    sublime.load_settings("Preferences.sublime-settings").add_on_change('color_scheme', ColorSchemeManager.adjustScheme)

    packages_path = sublime.packages_path()
    if not os.path.exists(packages_path+"/RGBDSThemes"):
        os.makedirs(packages_path+"/RGBDSThemes")

    ColorSchemeManager.adjustScheme()
spanish.py 文件源码 项目:sublimetext_spanish 作者: igece 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def init():
    PACKAGES_PATH = sublime.packages_path()
    DEFAULT_PATH = os.path.join(PACKAGES_PATH, "Default")
    #SUBLIME_PACKAGE_PATH = get_builtin_pkg_path()
    #DEFAULT_SRC = os.path.join(SUBLIME_PACKAGE_PATH, "Default.sublime-package")
    from 'Default.zip' import ZipFile
    with ZipFile('Default.zip', "r") as f:
        f.extractall(DEFAULT_PATH)
spanish.py 文件源码 项目:sublimetext_spanish 作者: igece 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def plugin_unloaded():
    PACKAGE_NAME = __name__.split('.')[0]
    from package_control import events
    if events.remove(PACKAGE_NAME):
        PACKAGES_PATH = sublime.packages_path()
        DEFAULT_PATH = os.path.join(PACKAGES_PATH, "Default")
        import shutil
        shutil.rmtree(DEFAULT_PATH)
        print('Removing %s!' % events.remove(PACKAGE_NAME))
Localize.py 文件源码 项目:LocalizedMenu 作者: zam1024t 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def init():
    if v == '3' and (sublime.installed_packages_path() in pDir):
        pkgDir = os.path.join(sublime.packages_path(), pName);
        if not os.path.isdir(pkgDir):
            pkgFile = os.path.dirname(os.path.abspath(__file__))
            unpackSelf(pkgFile, pkgDir)
            return
    locale = ''
    firstRun = False
    fFile = os.path.join(pDir, '.firstRun')
    if not os.path.isfile(fFile):
        firstRun = True
        backupMenu()
        open(fFile, 'wt').write('')
        locale = getSetting('locale', '')
    eDir = os.path.join(mDir, version, 'en');
    if v == '3' and not os.path.isdir(eDir):
        eFile = sublime.executable_path();
        dFile = os.path.join(os.path.dirname(eFile), 'Packages', 'Default.sublime-package');
        unpackMenu(dFile, eDir);
    makeMenu(locale, firstRun)
    makeCommand(locale, firstRun)
    setLocale(locale, firstRun)

    s = sublime.load_settings(sFile)
    s.add_on_change('locale', updateLocale)
ToolTipHelper.py 文件源码 项目:ToolTip-Helper 作者: AvitanI 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def get_tooltip_files(self, current_scope):
        """ get all files paths which have the current scope"""
        files = self.get_immediate_files()
        relative_path = sublime.packages_path() + '\\ToolTipHelper\\'
        tooltip_files = []

        if files:
            for file in files:  
                if file['source'] in current_scope:
                    full_path = relative_path + file['file_name']
                    # replace the file name with full path
                    file['file_name'] = full_path
                    tooltip_files.append(file)
        # print("tooltip_files: " + str(tooltip_files))      
        return tooltip_files
ToolTipHelper.py 文件源码 项目:ToolTip-Helper 作者: AvitanI 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def __init__(self):
        self.theme_file_path = os.path.join(sublime.packages_path(), "User", "scheme_styles.json")
        self.resource_path = "/".join(["Packages", "User", "scheme_styles.json"])
        self.style_sheets = {}
        settings = sublime.load_settings("Preferences.sublime-settings")
        self.cache_limit = settings.get("popup_style_cache_limit", 5)
Layout.py 文件源码 项目:SppLayout 作者: mg979 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def plugin_path():
    return os.path.join(sublime.packages_path(), PLUGIN_NAME)
Layout.py 文件源码 项目:SppLayout 作者: mg979 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def plugin_loaded():
    if not os.path.isdir(layouts_path()):
        os.makedirs(layouts_path())
    user = os.path.join(sublime.packages_path(), 'User', PLUGIN_NAME)
    if not os.path.isdir(user):
        os.mkdir(user)
        src = plugin_path() + os.sep + "Default.sublime-keymap"
        dst = user + os.sep + "Default.sublime-keymap"
        shutil.copyfile(src, dst)
save.py 文件源码 项目:SppLayout 作者: mg979 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def user_preferences():
    path = os.path.join(sublime.packages_path(
        ), 'User', 'Preferences.sublime-settings')
    return json.loads(open(path).read())
SpandocCreateConfig.py 文件源码 项目:Spandoc 作者: geniusupgrader 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def run(self):
        if self.window.active_view().file_name():
            configFile = os.path.join(os.path.dirname(self.window.active_view().file_name()), 'spandoc.json')
        else:
            sublime.status_message("Cannot create project configuration for unsaved files.")
            return

        if os.path.exists(configFile):
            self.window.open_file(configFile)
            return

        defaultConfigFile = os.path.join(sublime.packages_path(), 'Spandoc', 'Spandoc.sublime-settings')
        userConfigFile = os.path.join(sublime.packages_path(), 'User', 'Spandoc.sublime-settings')

        if not os.path.exists(defaultConfigFile) and not os.path.exists(userConfigFile):
            try:
                s = sublime.load_resource("Packages/Spandoc/Spandoc.sublime-settings")
            except OSError as e:
                sublime.status_message("Could not load default Pandoc configuration.")
                print("[Spandoc could not find a default configuration file in Packages/Spandoc/Spandoc.sublime-settings]")
                print("[Loading from the binary package resource file also failed.]")
                print("[e: {0}]".format(e))
                return
            with codecs.open(configFile, "w", "utf-8") as f:
                f.write(s)
            self.window.open_file(configFile)

        else:
            try:
                toCopy = defaultConfigFile if not os.path.exists(userConfigFile) else userConfigFile
                shutil.copy(toCopy, configFile)
            except Exception as e:
                sublime.status_message("Could not write {0}".format(configFile))
                print("[Spandoc encountered an exception:]")
                print("[e: {0}]".format(e))
            else:
                self.window.open_file(configFile)
code_map.py 文件源码 项目:sublime-codemap 作者: oleg-shilo 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def is_compressed_package():
    plugin_dir = path.dirname(__file__)
    return not plugin_dir.startswith(sublime.packages_path())
code_map.py 文件源码 项目:sublime-codemap 作者: oleg-shilo 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def mapper_path(syntax):
    return path.join(sublime.packages_path(), 'User', 'CodeMap', 'custom_mappers', 'code_map.'+syntax+'.py')
code_map.py 文件源码 项目:sublime-codemap 作者: oleg-shilo 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def syntax_path(syntax):
    return path.join(sublime.packages_path(), 'User', 'CodeMap', 'custom_languages', syntax+'.sublime-syntax')


问题


面经


文章

微信
公众号

扫码关注公众号