fixed syntax problems with previous python versions, added additional error messages

This commit is contained in:
Marcus Stoegbauer 2024-04-01 01:41:27 +02:00
parent 378ebcebf6
commit 3b747f56ba
2 changed files with 13 additions and 8 deletions

View File

@ -76,10 +76,8 @@ def main():
dest='file', action='store')
cmdline = parser.parse_args()
debug = Debug()
# debug.set_verbose(cmdline.verbose)
# cfg = Conf(filename=cmdline.file, debug=debug)
debug.set_verbose(3)
cfg = Conf(filename='/Users/lysis/userconfig2-test.conf', debug=debug)
debug.set_verbose(cmdline.verbose)
cfg = Conf(filename=cmdline.file, debug=debug)
uc = Userconfig(cfg)
cfg.debug.stdout(f'Verbose level: {cfg.debug.get_verbose()}', 1)
@ -117,6 +115,7 @@ def main():
continue
if package.name in ['.svn', '.git']:
cfg.debug.stdout(f'{package.path} is a svn or git data directory, skipping', 2, 'WARNING')
continue
if os.path.isfile(f'{package.path}/.ignore'):
cfg.debug.stdout(f'{package.path} contains .ignore, skipping', 2, 'WARNING')
continue
@ -124,9 +123,15 @@ def main():
cfg.debug.stdout(f'Start Package {cfg.debug.green(package.path)}', 1, 'NOTICE')
# Get all category directories for package
(category_dirs, dir_config) = uc.process_package_dir(package.path)
if not category_dirs:
cfg.debug.stdout(f'Could not get category_dirs for package {package.name}, skipping package.', 0, 'ERROR')
continue
if not dir_config:
cfg.debug.stdout(f'Could not get dir_config for package {package.name}, skipping package.', 0, 'ERROR')
continue
cfg.debug.stdout(f'Got categories: {category_dirs}', 2)
host_category_dirs = uc.filter_categories(category_dirs)
cfg.debug.stdout(f'Host uses categories: {", ".join([f'{v[1]}_{v[2]}' for v in host_category_dirs])}', 2)
cfg.debug.stdout('Host uses categories: %s' % ", ".join([f'{v[1]}_{v[2]}' for v in host_category_dirs]), 2)
file_list = dict()
for c in host_category_dirs:
file_list = uc.process_category_dir(c, file_list)
@ -136,7 +141,7 @@ def main():
subprocess.call([f'{package.path}/install.sh'])
for file in file_list:
dest = f'{dir_config.get(section="Main", option="dest")}/{file}'
cfg.debug.stdout(f'Generating {dest} from:\n {"\n ".join(file_list[file])}', 1)
cfg.debug.stdout('Generating %s from:\n %s' % (dest, "\n ".join(file_list[file])), 1)
try:
comment_string = dir_config.get(section="Main", option="commentstring")

View File

@ -28,11 +28,11 @@ class Userconfig:
if not os.path.isfile(package_config_file):
self._cfg.debug.stdout(f'No config file {self._cfg.get("configfile")} in {package_dir}, skipping',
0, 'ERROR')
return None
return None, None
dir_config = self.get_config(package_config_file)
if not dir_config:
self._cfg.debug.stdout(f'Cannot read config file {package_config_file}, skipping', 0, 'ERROR')
return None
return None, None
classes = []
for category in os.scandir(package_dir):
if category.path == package_config_file: