Python sublime 模块,packages_path() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用sublime.packages_path()

项目:sublime-text-3-packages    作者:nickjj    | 项目源码 | 文件源码
def is_scratch(self, view):
        """
        Return whether a view is effectively scratch.

        There is a bug (or feature) in the current ST3 where the Find panel
        is not marked scratch but has no window.

        There is also a bug where settings files opened from within .sublime-package
        files are not marked scratch during the initial on_modified event, so we have
        to check that a view with a filename actually exists on disk if the file
        being opened is in the Sublime Text packages directory.

        """

        if view.is_scratch() or view.is_read_only() or view.window() is None or view.settings().get("repl") is not None:
            return True
        elif (
            view.file_name() and
            view.file_name().startswith(sublime.packages_path() + os.path.sep) and
            not os.path.exists(view.file_name())
        ):
            return True
        else:
            return False
项目:sublime-text-3-packages    作者:nickjj    | 项目源码 | 文件源码
def change_mark_colors(error_color, warning_color):
    """Change SublimeLinter error/warning colors in user color schemes."""

    error_color = error_color.lstrip('#')
    warning_color = warning_color.lstrip('#')

    base_path = os.path.join(sublime.packages_path(), 'User', '*.tmTheme')
    sublime_path = os.path.join(sublime.packages_path(), 'User', 'SublimeLinter', '*.tmTheme')
    themes = glob(sublime_path) + glob(base_path)

    for theme in themes:
        with open(theme, encoding='utf8') as f:
            text = f.read()

        if re.search(MARK_COLOR_RE.format(r'mark\.error'), text):
            text = re.sub(MARK_COLOR_RE.format(r'mark\.error'), r'\1#{}\2'.format(error_color), text)
            text = re.sub(MARK_COLOR_RE.format(r'mark\.warning'), r'\1#{}\2'.format(warning_color), text)

            with open(theme, encoding='utf8', mode='w') as f:
                f.write(text)
项目:sublime-text-3-packages    作者:nickjj    | 项目源码 | 文件源码
def generate_menu(name, menu_text):
    """Generate and return a sublime-menu from a template."""

    from . import persist
    plugin_dir = os.path.join(sublime.packages_path(), persist.PLUGIN_DIRECTORY)
    path = os.path.join(plugin_dir, '{}.sublime-menu.template'.format(name))

    with open(path, encoding='utf8') as f:
        template = f.read()

    # Get the indent for the menus within the template,
    # indent the chooser menus except for the first line.
    indent = MENU_INDENT_RE.search(template).group(1)
    menu_text = indent_lines(menu_text, indent)

    text = Template(template).safe_substitute({'menus': menu_text})
    path = os.path.join(plugin_dir, '{}.sublime-menu'.format(name))

    with open(path, mode='w', encoding='utf8') as f:
        f.write(text)

    return text
项目:sublime-text-3-packages    作者:nickjj    | 项目源码 | 文件源码
def fix_scheme_in_settings(settings_file,current_scheme, new_scheme, regenerate=False):
  """Change the color scheme in the given Settings to a background-corrected one"""
  from os.path import join, normpath, isfile

  settings = load_settings(settings_file)
  settings_scheme = settings.get("color_scheme")
  if current_scheme == settings_scheme:
    new_scheme_path =  join(packages_path(), normpath(new_scheme[len("Packages/"):]))
    if isfile(new_scheme_path) and not regenerate:
      settings.set("color_scheme", new_scheme)
    else:
      generate_scheme_fix(current_scheme, new_scheme_path)
      settings.set("color_scheme", new_scheme)
    save_settings(settings_file)
    return True
  return False
项目:sublime-text-3-packages    作者:nickjj    | 项目源码 | 文件源码
def generate_scheme_fix(old_scheme, new_scheme_path):
  """Appends background-correction XML to a color scheme file"""
  from os.path import join
  from re import sub
  UUID_REGEX = '[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}'

  with open(join(packages_path(),current_directory(),'background_fix.xml')) as f:
    xml = f.read()
  scheme_data = load_resource(old_scheme) # only valid for ST3 API!

  insertion_point = scheme_data.rfind("</array>")
  new_scheme_data = scheme_data[:insertion_point] + xml + scheme_data[insertion_point:]

  def uuid_gen(args):
    from uuid import uuid4
    return str(uuid4())
  new_scheme_data = sub(UUID_REGEX, uuid_gen, new_scheme_data)

  with open(new_scheme_path, "wb") as f:
    f.write(new_scheme_data.encode("utf-8"))
项目:sublime-simple-import    作者:vinpac    | 项目源码 | 文件源码
def on_post_save(self, view):
    file_name = view.file_name()
    if not ReloadPlugin.PACKAGE_NAME in file_name: return
    if ReloadPlugin.PLUGIN_PYTHON_FILE in file_name: return

    original_file_name = view.file_name()
    plugin_python_file = os.path.join(sublime.packages_path(), ReloadPlugin.PLUGIN_PYTHON_FILE)
    if not os.path.isfile(plugin_python_file): return

    def _open_original_file():
      view.window().open_file(original_file_name)

    plugin_view = view.window().open_file(plugin_python_file)
    print("save", plugin_view.file_name())
    plugin_view.run_command("save")
    sublime.set_timeout_async(_open_original_file, self.PLUGIN_RELOAD_TIME_MS)
项目:Requester    作者:kylebebak    | 项目源码 | 文件源码
def load_history(rev=True, as_dict=False):
    """Returns list of past requests. Raises exception if history file doesn't
    exist.
    """
    history_file = sublime.load_settings('Requester.sublime-settings').get('history_file', None)
    if not history_file:
        raise KeyError

    history_path = os.path.join(sublime.packages_path(), 'User', history_file)
    with open(history_path, 'r') as f:
        rh = json.loads(f.read() or '{}', object_pairs_hook=OrderedDict)
    if as_dict:
        return rh
    requests = list(rh.items())
    if rev:
        requests.reverse()
    return requests
项目:sublimeTextConfig    作者:luoye-fe    | 项目源码 | 文件源码
def is_scratch(self, view):
        """
        Return whether a view is effectively scratch.

        There is a bug (or feature) in the current ST3 where the Find panel
        is not marked scratch but has no window.

        There is also a bug where settings files opened from within .sublime-package
        files are not marked scratch during the initial on_modified event, so we have
        to check that a view with a filename actually exists on disk if the file
        being opened is in the Sublime Text packages directory.

        """

        if view.is_scratch() or view.is_read_only() or view.window() is None or view.settings().get("repl") is not None:
            return True
        elif (
            view.file_name() and
            view.file_name().startswith(sublime.packages_path() + os.path.sep) and
            not os.path.exists(view.file_name())
        ):
            return True
        else:
            return False
项目:sublimeTextConfig    作者:luoye-fe    | 项目源码 | 文件源码
def is_settings_file(self, view, user_only=False):
        """Return True if view is a SublimeLinter settings file."""

        filename = view.file_name()

        if not filename:
            return False

        if not filename.startswith(sublime.packages_path()):
            return False

        dirname, filename = os.path.split(filename)
        dirname = os.path.basename(dirname)

        if self.LINTER_SETTINGS_RE.match(filename):
            if user_only:
                return dirname == 'User'
            else:
                return dirname in (persist.PLUGIN_DIRECTORY, 'User')
项目:sublimeTextConfig    作者:luoye-fe    | 项目源码 | 文件源码
def change_mark_colors(error_color, warning_color):
    """Change SublimeLinter error/warning colors in user color schemes."""

    error_color = error_color.lstrip('#')
    warning_color = warning_color.lstrip('#')

    base_path = os.path.join(sublime.packages_path(), 'User', '*.tmTheme')
    sublime_path = os.path.join(sublime.packages_path(), 'User', 'SublimeLinter', '*.tmTheme')
    themes = glob(sublime_path) + glob(base_path)

    for theme in themes:
        with open(theme, encoding='utf8') as f:
            text = f.read()

        if re.search(MARK_COLOR_RE.format(r'mark\.error'), text):
            text = re.sub(MARK_COLOR_RE.format(r'mark\.error'), r'\1#{}\2'.format(error_color), text)
            text = re.sub(MARK_COLOR_RE.format(r'mark\.warning'), r'\1#{}\2'.format(warning_color), text)

            with open(theme, encoding='utf8', mode='w') as f:
                f.write(text)
项目:sublimeTextConfig    作者:luoye-fe    | 项目源码 | 文件源码
def generate_menu(name, menu_text):
    """Generate and return a sublime-menu from a template."""

    from . import persist
    plugin_dir = os.path.join(sublime.packages_path(), persist.PLUGIN_DIRECTORY)
    path = os.path.join(plugin_dir, '{}.sublime-menu.template'.format(name))

    with open(path, encoding='utf8') as f:
        template = f.read()

    # Get the indent for the menus within the template,
    # indent the chooser menus except for the first line.
    indent = MENU_INDENT_RE.search(template).group(1)
    menu_text = indent_lines(menu_text, indent)

    text = Template(template).safe_substitute({'menus': menu_text})
    path = os.path.join(plugin_dir, '{}.sublime-menu'.format(name))

    with open(path, mode='w', encoding='utf8') as f:
        f.write(text)

    return text
项目:ElectricImp-Sublime    作者:electricimp    | 项目源码 | 文件源码
def find_resource(resource_pattern, package=None):
    file_set = set()
    if package == None:
        for package in get_packages_list():
            file_set.update(find_resource(resource_pattern, package))

        ret_list = list(file_set)
    else:
        file_set.update(_find_directory_resource(os.path.join(sublime.packages_path(), package), resource_pattern))

        if VERSION >= 3006:
            zip_location = os.path.join(sublime.installed_packages_path(), package + ".sublime-package")
            file_set.update(_find_zip_resource(zip_location, resource_pattern))
            zip_location = os.path.join(os.path.dirname(sublime.executable_path()), "Packages", package + ".sublime-package")
            file_set.update(_find_zip_resource(zip_location, resource_pattern))
        ret_list = map(lambda e: package + "/" + e, file_set)

    return sorted(ret_list)
项目:sublime-troubleshooting    作者:guillermooo    | 项目源码 | 文件源码
def collect_package_data(self):
        block = DataBlock('Package data')

        _, packages, _ = next(os.walk(sublime.packages_path()))
        packages = list(packages)

        _, _, files = next(os.walk(sublime.installed_packages_path()))
        suffix = '.sublime-package'
        files = [f[:-len(suffix)] for f in files if f.endswith(suffix)]

        ignored_packages = sublime.load_settings('Preferences.sublime-settings').get('ignored_packages', [])

        block.items.append(DataItem('installed packages', json.dumps(files)))
        block.items.append(DataItem('packages', json.dumps(packages)))
        block.items.append(DataItem('ignored packages', json.dumps(ignored_packages)))
        if sublime.find_resources('Package Control.sublime-settings'):
            pc_packages = sublime.load_settings('Package Control.sublime-settings').get('installed_packages', [])
            block.items.append(DataItem('packages managed by Package Control', json.dumps(pc_packages)))

        self.elements.append(block)
项目:sublime-favorites    作者:oleg-shilo    | 项目源码 | 文件源码
def favorites_data_path(per_project):
    file = None

    if per_project:
        project = sublime.active_window().project_file_name()
        if project:
            file = project + '.favorites'
    else:
        file = os.path.join(sublime.packages_path(), 'User', 'favorites.txt')

    if file and not path.exists(file):
        with open(file, "w") as f:
            f.write('')

    return file
# -------------------------
项目:sublime-favorites    作者:oleg-shilo    | 项目源码 | 文件源码
def get_favorite_files_data():
    """ 
        Integration with Favorit_Files plugin
        It goes only as far as reading its data file, flattening it and allowing to 
        open files on double-click on the item in the Favorites panel  
    """
    import json

    file_name = os.path.join(sublime.packages_path(), 'User', 'favorite_files_list.json')

    with open(file_name) as data_file:    
        data = json.load(data_file)

    result = []    
    for f in data["files"]:
        result.append(f)

    for name in data["groups"].keys():
        for f in data["groups"][name]:
            result.append(f)

    return result
# -------------------------
项目:AutomaticPackageReloader    作者:randy3k    | 项目源码 | 文件源码
def current_package_name(self):
        view = self.window.active_view()
        spp = os.path.realpath(sublime.packages_path())
        if view and view.file_name():
            file_path = os.path.realpath(view.file_name())
            if file_path.endswith(".py") and file_path.startswith(spp):
                # path on Windows may not be properly cased
                # https://github.com/randy3k/AutomaticPackageReloader/issues/10
                file_path = casedpath(file_path)
                return file_path[len(spp):].split(os.sep)[1]

        folders = self.window.folders()
        if folders and len(folders) > 0:
            first_folder = os.path.realpath(folders[0])
            if first_folder.startswith(spp):
                return os.path.basename(casedpath(first_folder))

        return None
项目:OverrideAudit    作者:OdatNurd    | 项目源码 | 文件源码
def __init__(self, name_list=None):
        self._list = dict()
        self._disabled = 0
        self._dependencies = 0

        # Maps lower cased package names to listed packages on case insensitive
        # systems.
        self._case_list = dict() if _wrap("ABC") == _wrap("abc") else None

        if name_list is not None:
            if isinstance(name_list, str):
                name_list = [name_list]

            if _wrap("Abc") == _wrap("abc"):
                name_list = [_wrap(name) for name in name_list]

        self._shipped = self.__find_pkgs(PackageInfo.shipped_packages_path, name_list, shipped=True)
        self._installed = self.__find_pkgs(sublime.installed_packages_path(), name_list)
        self._unpacked = self.__find_pkgs(sublime.packages_path(), name_list, packed=False)
项目:st-user-package    作者:math2001    | 项目源码 | 文件源码
def load_session(self):
        """
        Returns dict or None if no session exists
        """

        local_session_path = os.path.join(os.path.dirname(sublime.packages_path()), 'Local')
        local_auto_save_session_file = os.path.join(local_session_path, 'Auto Save Session.sublime_session')
        local_session_file = os.path.join(local_session_path, 'Session.sublime_session')

        if os.path.isfile(local_auto_save_session_file):
            session_file_to_use = local_auto_save_session_file
        elif os.path.isfile(local_session_file):
            session_file_to_use = local_session_file
        else:
            return None

        with open(session_file_to_use) as f:
            local_session_content = f.read()

        session = json.loads(local_session_content, strict=False)

        return session
项目:NeoVintageous    作者:NeoVintageous    | 项目源码 | 文件源码
def file_name():
    return os.path.join(sublime.packages_path(), 'User', '.vintageousrc')
项目:NeoVintageous    作者:NeoVintageous    | 项目源码 | 文件源码
def abbrevs_path():
    return os.path.normpath(
        os.path.join(
            sublime.packages_path(),
            'User/_vintageous_abbrev.sublime-completions'
        )
    )
项目:Chinese-Localization    作者:rexdf    | 项目源码 | 文件源码
def cleanup():
    PACKAGES_PATH = sublime.packages_path()
    DEFAULT_PATH = os.path.join(PACKAGES_PATH, "Default")
    ZZZZ_LOCALE = os.path.join(PACKAGES_PATH, "ZZZZZZZZ-Localization")
    import shutil
    shutil.rmtree(DEFAULT_PATH)
    shutil.rmtree(ZZZZ_LOCALE)
项目:sublime-text-3-packages    作者:nickjj    | 项目源码 | 文件源码
def get_dest_path():
    return os.path.join(sublime.packages_path(), PKG, DIST, PATCHES)
项目:sublime-text-3-packages    作者:nickjj    | 项目源码 | 文件源码
def get_aliases_path():
    return os.path.join(sublime.packages_path(), PKG, DIST, ALIASES)
项目:sublime-text-3-packages    作者:nickjj    | 项目源码 | 文件源码
def copy_linter(self, name):
        """Copy the template linter to a new linter with the given name."""

        self.name = name
        self.fullname = 'SublimeLinter-contrib-{}'.format(name)
        self.dest = os.path.join(sublime.packages_path(), self.fullname)

        if os.path.exists(self.dest):
            sublime.error_message('The plugin “{}” already exists.'.format(self.fullname))
            return

        src = os.path.join(sublime.packages_path(), persist.PLUGIN_DIRECTORY, 'linter-plugin-template')
        self.temp_dir = None

        try:
            self.temp_dir = tempfile.mkdtemp()
            self.temp_dest = os.path.join(self.temp_dir, self.fullname)
            shutil.copytree(src, self.temp_dest)

            self.get_linter_language(name, self.configure_linter)

        except Exception as ex:
            if self.temp_dir and os.path.exists(self.temp_dir):
                shutil.rmtree(self.temp_dir)

            sublime.error_message('An error occurred while copying the template plugin: {}'.format(str(ex)))
项目:sublime-text-3-packages    作者:nickjj    | 项目源码 | 文件源码
def run(self):
        """Run the command."""
        base_path = os.path.join(sublime.packages_path(), 'User', '*.tmTheme')
        sublime_path = os.path.join(sublime.packages_path(), 'User', 'SublimeLinter', '*.tmTheme')
        themes = glob(base_path) + glob(sublime_path)
        prefs = sublime.load_settings('Preferences.sublime-settings')
        scheme = prefs.get('color_scheme')

        for theme in themes:
            # Ensure it is a (SL) theme and it is not current current scheme
            if re.search(r'\(SL\)', theme) and os.path.normpath(scheme) not in theme:
                persist.debug('deleting {}'.format(os.path.split(theme)[1]))
                os.remove(theme)
项目:SublimeRSS    作者:JaredMHall    | 项目源码 | 文件源码
def openFeedList(self):
        packagePath = sublime.packages_path()

        matches = []
        #self.window.open_file("/feedlist.txt")
        for root, dirnames, filenames in os.walk(packagePath):
            for filename in fnmatch.filter(filenames, "sublimerss.py"):
                matches.append(root)

        self.window.open_file(matches[0] + "/feedlist.txt")
项目:KodiDevKit    作者:phil65    | 项目源码 | 文件源码
def on_done(self, index):
        """
        callback for menu items, gets called with *index of selected items
        """
        if index == -1:
            return None
        elif index == 0:
            self.window.show_input_panel("Set remote IP",
                                         self.settings.get("remote_ip", "192.168.0.1"),
                                         self.set_ip,
                                         None,
                                         None)
        elif index == 1:
            REMOTE.adb_reconnect_async()
            self.window.run_command("remote_actions")
        elif index == 2:
            variables = self.window.active_view().extract_variables()
            if "folder" in variables:
                REMOTE.push_to_box(variables["folder"])
        elif index == 3:
            plugin_path = os.path.join(sublime.packages_path(), "KodiDevKit")
            REMOTE.get_log(self.open_file, plugin_path)
        elif index == 4:
            plugin_path = os.path.join(sublime.packages_path(), "KodiDevKit")
            REMOTE.get_screenshot(self.open_file, plugin_path)
        elif index == 5:
            REMOTE.clear_cache()
        elif index == 6:
            REMOTE.reboot()
项目:Bethesda_SublimeFO4    作者:Scrivener07    | 项目源码 | 文件源码
def processRecentUpgrade():
    if (VERSION in UPGRADE_KILL_FILES):
        print("Performing kill for version %1.1f" % (VERSION))
        for killed in UPGRADE_KILL_FILES[VERSION]:
            killPath = os.path.join(sublime.packages_path(), "PapyrusF4", killed)
            if os.path.exists(killPath):
                if killed[-1] == "/":
                    shutil.rmtree(killPath)
                else:
                    os.remove(killPath)
项目:Bethesda_SublimeFO4    作者:Scrivener07    | 项目源码 | 文件源码
def Init():
    global VERSION
    try:
        with open(os.path.join(sublime.packages_path(), "PapyrusF4", "VERSION"), "r") as version_file:
            VERSION = float(version_file.read())
    except:
        pass # VERSION remains 0.0

    autoUpdateCheck()
    processRecentUpgrade()
项目:DXMate    作者:jtowers    | 项目源码 | 文件源码
def get_plugin_folder(self):
        packages_path = os.path.join(sublime.packages_path(), self.plugin_name())
        return packages_path
项目:macos-st-packages    作者:zce    | 项目源码 | 文件源码
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()
项目:macos-st-packages    作者:zce    | 项目源码 | 文件源码
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)
项目:sublime-atomizr    作者:idleberg    | 项目源码 | 文件源码
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
项目:Requester    作者:kylebebak    | 项目源码 | 文件源码
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
项目:Requester    作者:kylebebak    | 项目源码 | 文件源码
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')
项目:Requester    作者:kylebebak    | 项目源码 | 文件源码
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)
项目:FileManager    作者:math2001    | 项目源码 | 文件源码
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    作者:michalisb    | 项目源码 | 文件源码
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()
项目:sublimetext_spanish    作者:igece    | 项目源码 | 文件源码
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)
项目:sublimetext_spanish    作者:igece    | 项目源码 | 文件源码
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))
项目:LocalizedMenu    作者:zam1024t    | 项目源码 | 文件源码
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)
项目:ToolTip-Helper    作者:AvitanI    | 项目源码 | 文件源码
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
项目:ToolTip-Helper    作者:AvitanI    | 项目源码 | 文件源码
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)
项目:SppLayout    作者:mg979    | 项目源码 | 文件源码
def plugin_path():
    return os.path.join(sublime.packages_path(), PLUGIN_NAME)
项目:SppLayout    作者:mg979    | 项目源码 | 文件源码
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)
项目:SppLayout    作者:mg979    | 项目源码 | 文件源码
def user_preferences():
    path = os.path.join(sublime.packages_path(
        ), 'User', 'Preferences.sublime-settings')
    return json.loads(open(path).read())
项目:Spandoc    作者:geniusupgrader    | 项目源码 | 文件源码
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)
项目:sublime-codemap    作者:oleg-shilo    | 项目源码 | 文件源码
def is_compressed_package():
    plugin_dir = path.dirname(__file__)
    return not plugin_dir.startswith(sublime.packages_path())
项目:sublime-codemap    作者:oleg-shilo    | 项目源码 | 文件源码
def mapper_path(syntax):
    return path.join(sublime.packages_path(), 'User', 'CodeMap', 'custom_mappers', 'code_map.'+syntax+'.py')
项目:sublime-codemap    作者:oleg-shilo    | 项目源码 | 文件源码
def syntax_path(syntax):
    return path.join(sublime.packages_path(), 'User', 'CodeMap', 'custom_languages', syntax+'.sublime-syntax')