From 3780c37c2bb4973adb40d5ef4784a1b006595a29 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sun, 3 Dec 2023 15:54:57 +0100 Subject: [PATCH] Add support for dependencies.json in hidden packages This commit includes hidden sublime packages into lookup paths for required libraries. --- package_control/package_io.py | 7 +++++-- package_control/package_manager.py | 20 +++++++++++++++----- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/package_control/package_io.py b/package_control/package_io.py index 1ef88287..2063e239 100644 --- a/package_control/package_io.py +++ b/package_control/package_io.py @@ -30,7 +30,7 @@ def create_empty_file(filename): return True -def list_sublime_package_dirs(path): +def list_sublime_package_dirs(path, include_hidden=False): """ Return a set of directories in the folder specified that are not hidden and are not marked to be removed @@ -38,6 +38,9 @@ def list_sublime_package_dirs(path): :param path: The folder to list the directories inside of + :param include_hidden: + If True, also return hidden packages + :return: A generator of directory names """ @@ -51,7 +54,7 @@ def list_sublime_package_dirs(path): if not os.path.isdir(file_path): continue # Don't include hidden packages - if os.path.exists(os.path.join(file_path, '.hidden-sublime-package')): + if not include_hidden and os.path.exists(os.path.join(file_path, '.hidden-sublime-package')): continue # Don't include a dir if it is going to be cleaned up if os.path.exists(os.path.join(file_path, 'package-control.cleanup')): diff --git a/package_control/package_manager.py b/package_control/package_manager.py index e9c01ece..7507937a 100644 --- a/package_control/package_manager.py +++ b/package_control/package_manager.py @@ -762,18 +762,25 @@ def list_libraries(self): return library.list_all() - def list_packages(self, ignored_packages=None, unpacked_only=False): + def list_packages(self, ignored_packages=None, unpacked_only=False, include_hidden=False): """ List installed packages on the machine + :param ignored_packages: + A list of packages to ignore in returned result. + The default value ``None`` or an empty list disables filtering. + :param unpacked_only: Only list packages that are not inside of .sublime-package files + :param include_hidden: + If True, also return hidden packages + :return: A set of all installed or overridden default package names """ - packages = set(list_sublime_package_dirs(sys_path.packages_path())) + packages = set(list_sublime_package_dirs(sys_path.packages_path(), include_hidden)) if unpacked_only is False: packages |= set(list_sublime_package_files(sys_path.installed_packages_path())) if ignored_packages: @@ -793,15 +800,18 @@ def list_default_packages(self): packages -= {'User'} return packages - def list_all_packages(self): + def list_all_packages(self, include_hidden=False): """ Lists all packages on the machine + :param include_hidden: + If True, also return hidden packages + :return: A set of all package names, including default packages """ - packages = set(list_sublime_package_dirs(sys_path.packages_path())) + packages = set(list_sublime_package_dirs(sys_path.packages_path(), include_hidden)) packages |= set(list_sublime_package_files(sys_path.installed_packages_path())) packages |= set(list_sublime_package_files(sys_path.default_packages_path())) packages -= {'User'} @@ -914,7 +924,7 @@ def find_required_libraries(self): """ output = set() - for package in self.list_packages(): + for package in self.list_packages(include_hidden=True): output |= self.get_libraries(package) output |= self.get_libraries('User')