diff --git a/src/python/jw/pkg/App.py b/src/python/jw/pkg/App.py index e10c0681..6e5d2844 100644 --- a/src/python/jw/pkg/App.py +++ b/src/python/jw/pkg/App.py @@ -55,7 +55,7 @@ class ResultCache(object): return r d = d[k] = {} #d = d[k] - raise Exception("cache algorithm failed for function", func.__name__, "in depth", depth) + raise Exception('cache algorithm failed for function', func.__name__, 'in depth', depth) class Scope(Enum): Self = auto() @@ -142,7 +142,7 @@ class App(Base): return visited.add(spec) deps = self.get_value(name, section, key) - log(DEBUG, "name = ", name, "section = ", section, "key = ", key, "deps = ", deps, "scope = ", scope.name, "visited = ", visited) + log(DEBUG, 'name = ', name, 'section = ', section, 'key = ', key, 'deps = ', deps, 'scope = ', scope.name, 'visited = ', visited) if deps and scope != Scope.Self: if scope == Scope.One: subscope = Scope.Self @@ -213,7 +213,7 @@ class App(Base): def __init__(self, distro: Distro|None=None) -> None: - super().__init__("jw-pkg swiss army knife", modules=["jw.pkg.cmds"]) + super().__init__('jw-pkg swiss army knife', modules=['jw.pkg.cmds']) # -- Members without default values self.__opt_interactive: bool|None = None @@ -227,7 +227,7 @@ class App(Base): # -- Members with default values self.__topdir_fmt = 'absolute' - self.__projs_root = pwd.getpwuid(os.getuid()).pw_dir + "/local/src/jw.dev/proj" + self.__projs_root = pwd.getpwuid(os.getuid()).pw_dir + '/local/src/jw.dev/proj' self.__pretty_projs_root = None async def __init_async(self) -> None: @@ -248,9 +248,9 @@ class App(Base): parser.add_argument('-p', '--prefix', default = None, help='Parent directory of project source directories') parser.add_argument('--distro-id', default=None, help='Distribution ID (default is taken from /etc/os-release)') - parser.add_argument('--interactive', choices=['true', 'false', 'auto'], default='true', help="Wait for user input or try to proceed unattended") - parser.add_argument('--verbose', action='store_true', default=False, help="Be verbose on stderr about what's being done on the distro level") - parser.add_argument('--uri', default='local', help="Run commands on this host") + parser.add_argument('--interactive', choices=['true', 'false', 'auto'], default='true', help='Wait for user input or try to proceed unattended') + parser.add_argument('--verbose', action='store_true', default=False, help='Be verbose on stderr about what\'s being done on the distro level') + parser.add_argument('--uri', default='local', help='Run commands on this host') async def _run(self, args: argparse.Namespace) -> None: self.__topdir = args.topdir @@ -311,12 +311,12 @@ class App(Base): # TODO: add support for customizing this in project.conf def htdocs_dir(self, project: str) -> str: - return self.find_dir(project, ["/src/html/htdocs", "/tools/html/htdocs", "/htdocs"], - ["/srv/www/proj/" + project]) + return self.find_dir(project, ['/src/html/htdocs', '/tools/html/htdocs', '/htdocs'], + ['/srv/www/proj/' + project]) # TODO: add support for customizing this in project.conf def tmpl_dir(self, name: str) -> str: - return self.find_dir(name, ["/tmpl"], ["/opt/" + name + "/share/tmpl"]) + return self.find_dir(name, ['/tmpl'], ['/opt/' + name + '/share/tmpl']) def strip_module_from_spec(self, mod): return re.sub(r'-dev$|-devel$|-run$', '', re.split('([=><]+)', mod)[0].strip()) @@ -362,7 +362,7 @@ class App(Base): cont_line = '' rx = re.compile(r'^\s*' + key + r'\s*=\s*(.*)\s*$') for line in lines: - #log(DEBUG, " looking for >%s< in line=>%s<" % (key, line)) + #log(DEBUG, ' looking for "%s" in line="%s"' % (key, line)) m = re.search(rx, line) if m is not None: return m.group(1) @@ -370,11 +370,11 @@ class App(Base): def scan_section_debug(f, key: str) -> str|None: ret = scan_section(f, key) - #log(DEBUG, " returning", rr) + #log(DEBUG, ' returning', rr) return ret try: - #log(DEBUG, "looking for {}::[{}].{}".format(path, section, key)) + #log(DEBUG, 'looking for {}::[{}].{}'.format(path, section, key)) with open(path, 'r') as f: if not len(section): rr = scan_section(f, key) @@ -384,7 +384,7 @@ class App(Base): return scan_section(f, key) return None except: - log(DEBUG, path, "not found") + log(DEBUG, path, 'not found') # TODO: handle this special case cleaner somewhere up the stack if section == 'build' and key == 'libname': return 'none' @@ -408,12 +408,12 @@ class App(Base): fd.close() return ret except EnvironmentError: - log(DEBUG, f'"Ignoring unreadable file "{version_path}"') + log(DEBUG, f'Ignoring unreadable file "{version_path}"') continue raise Exception(f'No version file found for project "{project}"') path = proj_root + '/make/project.conf' ret = self.read_value(path, section, key) - log(DEBUG, "Lookup %s -> %s / [%s%s] -> \"%s\"" % + log(DEBUG, 'Lookup %s -> %s / [%s%s] -> "%s"' % (self.__top_name, project, section, '.' + key if key else '', ret)) return ret @@ -428,7 +428,7 @@ class App(Base): for key in keys: vals = self.get_value(p, section, key) if vals: - ret += [val.strip() for val in vals.split(",")] + ret += [val.strip() for val in vals.split(',')] return list(dict.fromkeys(ret)) # Remove duplicates, keep ordering def get_project_refs(self, projects: list[str], sections: list[str], @@ -458,7 +458,7 @@ class App(Base): return ' '.join(reversed(vals)) def is_excluded_from_build(self, project: str) -> str|None: - log(DEBUG, "checking if project " + project + " is excluded from build") + log(DEBUG, 'checking if project ' + project + ' is excluded from build') exclude = self.get_project_refs([ project ], ['build'], 'exclude', scope = Scope.One, add_self=False, names_only=True) cascade = self.distro.os_cascade + [ 'all' ]