Makefile: Include py-topdir.mk

Include py-topdir.mk, which entails loads of fallout from make check.
Fix it.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-06-10 13:28:35 +02:00
commit e9845b5a1f
Signed by: Jan Lindemann
GPG key ID: 3750640C9E25DD61

View file

@ -1,14 +1,16 @@
# -*- coding: utf-8 -*-
import glob
import os
import re
import sys
from typing import Optional, Dict, cast
import os, re, glob, sys
from pathlib import Path, PosixPath
from pathlib import Path
from typing import Dict, Optional, cast
from . import stree
from .stree import serdes
from .log import DEBUG, ERR, slog, get_caller_pos
from .stree.StringTree import StringTree
from .log import *
class Config(): # export
class Config(): # export
def __load(self, search_dirs, glob_paths, refuse_mode_mask):
@ -33,15 +35,15 @@ class Config(): # export
for path in glob_paths:
dirs = search_dirs
if dirs is None:
dirs = [''] if __is_abs(path) else [ str(Path.home()), str(Path.cwd()) ]
dirs = [''] if __is_abs(path) else [str(Path.home()), str(Path.cwd())]
for d in dirs:
g = d + '/' + path if len(d) else path
slog(DEBUG, 'Looking for config "{}"'.format(g))
for f in glob.glob(g):
slog(DEBUG, 'Reading config "{}"'.format(f))
paths_buf = []
tree = stree.read(f, paths_buf=paths_buf)
assert(len(paths_buf))
tree = serdes.read(f, paths_buf = paths_buf)
assert (len(paths_buf))
if refuse_mode_mask is not None:
for p in paths_buf:
st = os.stat(p)
@ -49,37 +51,44 @@ class Config(): # export
for item in tree.child_list():
if item.content is None:
continue
if not re.search('password|secret', cast(str, item.content), flags=re.IGNORECASE):
if not re.search('password|secret',
cast('str', item.content),
flags = re.IGNORECASE):
continue
msg = "Config files define secret, but at least one has file permissions open for world"
msg = (
'Config files define secret, but at least one '
'has file permissions open for world'
)
slog(ERR, f'{msg}:')
for pp in paths_buf:
slog(ERR, f' {((os.stat(pp).st_mode) & 0o7777):o} {pp}')
mode = (os.stat(pp).st_mode) & 0o7777
slog(ERR, f' {mode:o} {pp}')
raise Exception(msg)
tree.dump(DEBUG, f)
ret.add("", tree)
return ret
def __init__(self,
search_dirs: Optional[list[str]]=None,
glob_paths: Optional[list[str]]=None,
glob_paths_env_key: Optional[str]=None,
defaults: Optional[Dict[str, str]]=None,
tree: Optional[StringTree]=None,
parent=None,
root_section=None,
refuse_mode_mask=0o0027
) -> None:
def __init__(
self,
search_dirs: Optional[list[str]] = None,
glob_paths: Optional[list[str]] = None,
glob_paths_env_key: Optional[str] = None,
defaults: Optional[Dict[str, str]] = None,
tree: Optional[StringTree] = None,
parent = None,
root_section = None,
refuse_mode_mask = 0o0027
) -> None:
self.__parent = parent
if tree is not None:
assert(search_dirs is None)
assert(glob_paths is None)
assert(glob_paths_env_key is None)
assert (search_dirs is None)
assert (glob_paths is None)
assert (glob_paths_env_key is None)
self.__conf = tree
else:
assert(tree is None)
assert (tree is None)
if glob_paths_env_key is not None:
glob_paths_env = os.getenv(glob_paths_env_key)
if glob_paths_env is not None:
@ -87,8 +96,11 @@ class Config(): # export
glob_paths = []
glob_paths.extend(glob_paths_env.split(':'))
self.__conf = self.__load(search_dirs=search_dirs, glob_paths=glob_paths,
refuse_mode_mask=refuse_mode_mask)
self.__conf = self.__load(
search_dirs = search_dirs,
glob_paths = glob_paths,
refuse_mode_mask = refuse_mode_mask
)
if root_section is not None:
tmp = self.__conf.get(root_section)
@ -141,7 +153,11 @@ class Config(): # export
def value(self, key: str, default = None) -> Optional[str]:
return self.get(key, default)
def branch(self, path: str, throw: bool=True): # type: ignore # Optional[Config]: FIXME: Don't know how to get hold of this type here
def branch(
self,
path: str,
throw: bool = True
): # type: ignore # Optional[Config]: FIXME: Don't know how to get hold of this type here
if self.__conf:
tree = self.__conf.get(path)
if tree is None:
@ -151,19 +167,24 @@ class Config(): # export
return None
self.dump(ERR, msg)
raise Exception(msg)
return Config(tree=tree, parent=self) # type: ignore
return Config(tree = tree, parent = self) # type: ignore
return None
def dump(self, prio: int, *args, **kwargs) -> None:
caller = get_caller_pos(1, kwargs)
self.__conf.dump(prio, caller=caller, *args, **kwargs)
self.__conf.dump(prio, caller = caller, *args, **kwargs)
@property
def name(self):
return self.__conf.content
def find(self, key: str|None, val: str|None, match:StringTree.Match=StringTree.Match.Equal) -> list[str]:
return self.__conf.find(key, val, match=match)
def find(
self,
key: str | None,
val: str | None,
match: StringTree.Match = StringTree.Match.Equal
) -> list[str]:
return self.__conf.find(key, val, match = match)
#def __getattr__(self, name: str):
# return getattr(self.__conf, name)