From aa60c002734c61425180c90ef51008084ca19a16 Mon Sep 17 00:00:00 2001 From: github-actions Date: Mon, 14 Aug 2023 18:12:56 +0000 Subject: [PATCH] pre-commit auto fixes --- Code/autopkglib/StopProcessingIf.py | 3 +-- Code/autopkglib/URLDownloader.py | 2 +- Code/autopkglib/__init__.py | 6 ++++-- Code/autopkglib/common.py | 25 ++++++++++++++++++------- Code/tests/test_preferences.py | 8 ++++++-- 5 files changed, 30 insertions(+), 14 deletions(-) diff --git a/Code/autopkglib/StopProcessingIf.py b/Code/autopkglib/StopProcessingIf.py index cf7b4cd3..35134dd9 100644 --- a/Code/autopkglib/StopProcessingIf.py +++ b/Code/autopkglib/StopProcessingIf.py @@ -15,8 +15,7 @@ # limitations under the License. """See docstring for StopProcessingIf class""" -from autopkglib import Processor, ProcessorError -from autopkglib import log +from autopkglib import Processor, ProcessorError, log try: from Foundation import NSPredicate diff --git a/Code/autopkglib/URLDownloader.py b/Code/autopkglib/URLDownloader.py index 0e94100c..39dbb991 100755 --- a/Code/autopkglib/URLDownloader.py +++ b/Code/autopkglib/URLDownloader.py @@ -20,8 +20,8 @@ import platform import tempfile -from autopkglib.common import BUNDLE_ID from autopkglib import ProcessorError, xattr +from autopkglib.common import BUNDLE_ID from autopkglib.URLGetter import URLGetter __all__ = ["URLDownloader"] diff --git a/Code/autopkglib/__init__.py b/Code/autopkglib/__init__.py index 2e152169..1d4133dd 100755 --- a/Code/autopkglib/__init__.py +++ b/Code/autopkglib/__init__.py @@ -30,9 +30,9 @@ import pkg_resources import yaml from autopkglib.common import ( + DEFAULT_RECIPE_MAP, DEFAULT_SEARCH_DIRS, DEFAULT_USER_OVERRIDES_DIR, - DEFAULT_RECIPE_MAP, RE_KEYREF, RECIPE_EXTS, FileOrPath, @@ -1007,7 +1007,9 @@ def import_processors() -> None: # # from Bar.Foo import Foo # - for name in filter(lambda f: f not in ("__init__", "xattr", "prefs", "common"), processor_files): + for name in filter( + lambda f: f not in ("__init__", "xattr", "prefs", "common"), processor_files + ): globals()[name] = getattr( __import__(__name__ + "." + name, fromlist=[name]), name ) diff --git a/Code/autopkglib/common.py b/Code/autopkglib/common.py index 2f4b752f..06cc4e59 100644 --- a/Code/autopkglib/common.py +++ b/Code/autopkglib/common.py @@ -19,17 +19,28 @@ import sys from typing import IO, Any, Dict, Union - APP_NAME = "Autopkg" BUNDLE_ID = "com.github.autopkg" DEFAULT_USER_LIBRARY_DIR = "~/Library/AutoPkg" DEFAULT_LIBRARY_DIR = "/Library/AutoPkg" -DEFAULT_USER_OVERRIDES_DIR = os.path.expanduser(os.path.join(DEFAULT_USER_LIBRARY_DIR, "RecipeOverrides")) -DEFAULT_USER_RECIPES_DIR = os.path.expanduser(os.path.join(DEFAULT_USER_LIBRARY_DIR, "Recipes")) -DEFAULT_USER_CACHE_DIR = os.path.expanduser(os.path.join(DEFAULT_USER_LIBRARY_DIR, "Cache")) -DEFAULT_USER_REPOS_DIR = os.path.expanduser(os.path.join(DEFAULT_USER_LIBRARY_DIR, "RecipeRepos")) -DEFAULT_RECIPE_MAP = os.path.expanduser(os.path.join(DEFAULT_USER_LIBRARY_DIR, "recipe_map.json")) -DEFAULT_GH_TOKEN = os.path.expanduser(os.path.join(DEFAULT_USER_LIBRARY_DIR, "gh_token")) +DEFAULT_USER_OVERRIDES_DIR = os.path.expanduser( + os.path.join(DEFAULT_USER_LIBRARY_DIR, "RecipeOverrides") +) +DEFAULT_USER_RECIPES_DIR = os.path.expanduser( + os.path.join(DEFAULT_USER_LIBRARY_DIR, "Recipes") +) +DEFAULT_USER_CACHE_DIR = os.path.expanduser( + os.path.join(DEFAULT_USER_LIBRARY_DIR, "Cache") +) +DEFAULT_USER_REPOS_DIR = os.path.expanduser( + os.path.join(DEFAULT_USER_LIBRARY_DIR, "RecipeRepos") +) +DEFAULT_RECIPE_MAP = os.path.expanduser( + os.path.join(DEFAULT_USER_LIBRARY_DIR, "recipe_map.json") +) +DEFAULT_GH_TOKEN = os.path.expanduser( + os.path.join(DEFAULT_USER_LIBRARY_DIR, "gh_token") +) DEFAULT_SEARCH_DIRS = [".", DEFAULT_USER_LIBRARY_DIR, DEFAULT_LIBRARY_DIR] RE_KEYREF = re.compile(r"%(?P[a-zA-Z_][a-zA-Z_0-9]*)%") diff --git a/Code/tests/test_preferences.py b/Code/tests/test_preferences.py index 321fba34..2c0bc7b3 100644 --- a/Code/tests/test_preferences.py +++ b/Code/tests/test_preferences.py @@ -55,8 +55,12 @@ def setUp(self): # Return an empty list of preference keys by default. Makes a new list on # every call to ensure no false sharing. self.mock_copykeylist.side_effect = lambda *_, **_kw: list() - self.mock_copyappvalue = patch("autopkglib.prefs.CFPreferencesCopyAppValue").start() - self.mock_setappvalue = patch("autopkglib.prefs.CFPreferencesSetAppValue").start() + self.mock_copyappvalue = patch( + "autopkglib.prefs.CFPreferencesCopyAppValue" + ).start() + self.mock_setappvalue = patch( + "autopkglib.prefs.CFPreferencesSetAppValue" + ).start() self.mock_appsynchronize = patch( "autopkglib.prefs.CFPreferencesAppSynchronize" ).start()