jw.pkg.App: Remove .debug() and friends

Replace the jw.pkg.App.debug(), .warn() and .err() methods by the
global log() function. There's no obvious benefit in having App know
what's logged.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-01-25 15:18:27 +01:00
commit 95fa2f0d06
8 changed files with 39 additions and 41 deletions

View file

@ -31,7 +31,7 @@ class ResultCache(object):
else:
k = str(k)
depth += 1
#self.projects.debug('depth = ', depth, 'key = ', k, 'd = ', str(d))
#log(DEBUG, 'depth = ', depth, 'key = ', k, 'd = ', str(d))
if k in d:
if l == depth:
return d[k]
@ -160,15 +160,6 @@ class App(Base):
def find_dir(self, name: str, search_subdirs: list[str]=[], search_absdirs: list[str]=[], pretty: bool=True):
return self.__find_dir(name, search_subdirs, search_absdirs, pretty)
def debug(self, *objs):
log(DEBUG, *objs)
def warn(self, *objs):
log(WARNING, *objs)
def err(self, *objs):
log(ERR, *objs)
def re_section(self, name):
return re.compile('[' + name + ']'
'.*?'
@ -191,7 +182,7 @@ class App(Base):
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
(out, rr) = p.communicate()
if rr:
self.err("failed to run ", cmd)
log(ERR, "failed to run ", cmd)
continue
out = re.sub('\n', '', out.decode('utf-8'))
return out
@ -270,7 +261,7 @@ class App(Base):
lines.append(cont_line)
cont_line = ''
for line in lines:
#self.debug(" looking for >%s< in line=>%s<" % (key, line))
#log(DEBUG, " looking for >%s< in line=>%s<" % (key, line))
rr = re.findall('^ *' + key + ' *= *(.*)', line)
if len(rr) > 0:
return rr[0]
@ -278,11 +269,11 @@ class App(Base):
def scan_section_debug(f, key):
rr = scan_section(f, key)
#self.debug(" returning", rr)
#log(DEBUG, " returning", rr)
return rr
try:
#self.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)
@ -292,19 +283,19 @@ class App(Base):
return scan_section(f, key)
return None
except:
self.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'
return None
def get_value(self, name, section, key):
self.debug("getting value [%s].%s for project %s (%s)" %(section, key, name, self.top_name))
log(DEBUG, "getting value [%s].%s for project %s (%s)" %(section, key, name, self.top_name))
if self.top_name and name == self.top_name:
proj_root = self.topdir
else:
proj_root = self.projs_root + '/' + name
self.debug("proj_root = " + proj_root)
log(DEBUG, "proj_root = " + proj_root)
if section == 'version':
proj_version_dirs = [ proj_root ]
@ -318,7 +309,7 @@ class App(Base):
fd.close()
return r
except EnvironmentError:
self.debug("ignoring unreadable file " + version_path)
log(DEBUG, "ignoring unreadable file " + version_path)
continue
raise Exception("No version file found for project \"" + name + "\"")
@ -356,7 +347,7 @@ class App(Base):
return
visited.add(spec)
deps = self.get_value(name, section, key)
self.debug("name = ", name, "section = ", section, "key = ", key, "deps = ", deps, "scope = ", scope, "visited = ", visited)
log(DEBUG, "name = ", name, "section = ", section, "key = ", key, "deps = ", deps, "scope = ", scope, "visited = ", visited)
if deps and scope > 0:
if scope == 1:
subscope = 0
@ -402,7 +393,7 @@ class App(Base):
return ' '.join(reversed(vals))
def is_excluded_from_build(self, module):
self.debug("checking if module " + module + " is excluded from build")
log(DEBUG, "checking if module " + module + " is excluded from build")
exclude = self.get_modules_from_project_txt([ module ], ['build'], 'exclude',
scope = 1, add_self=False, names_only=True)
cascade = self.os_cascade() + [ 'all' ]
@ -443,7 +434,7 @@ class App(Base):
def check_circular_deps(self, module, section, graph, unvisited, temp, path):
if module in temp:
self.debug('found circular dependency at module', module)
log(DEBUG, 'found circular dependency at module', module)
return module
if not module in unvisited:
return None