jwutils: Move to jwutils -> jw.util

Move all implementation source code from the jwutils module to jw.util. For compatibility with existing Python modules, keep a thin, autogenerated compatibility shim under jwutils.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-06-10 07:22:46 +02:00 committed by janware DevOps
commit a2684dd601
Signed by: DevOps
SSH key fingerprint: SHA256:cZiw7ExG5q3KAVm7Jse3rGITowu0VjgUgNMPbifmY8g
129 changed files with 678 additions and 52 deletions

4
src/python/jw/Makefile Normal file
View file

@ -0,0 +1,4 @@
TOPDIR = ../../..
include $(TOPDIR)/make/proj.mk
include $(JWBDIR)/make/py-ns-dir.mk

View file

@ -0,0 +1,3 @@
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__)

View file

@ -4,7 +4,7 @@ import argparse
from collections import OrderedDict
from jwutils.log import *
from .log import slog
class ArgsContainer: # export

View file

@ -4,7 +4,7 @@ from __future__ import annotations
import inspect, sys, re, abc, argparse
from argparse import ArgumentParser, _SubParsersAction
from jwutils import log
from . import log
# full blown example of one level of nested subcommands
# git -C project remote -v show -n myremote

View file

@ -4,9 +4,8 @@ import os, sys, argcomplete, argparse, importlib, inspect, re, pickle, asyncio,
from argparse import ArgumentParser
from pathlib import Path, PurePath
import jwutils
from jwutils.log import *
from jwutils.stree import serdes
from .log import *
from .stree import serdes
class Cmds: # export

View file

@ -4,7 +4,7 @@ from typing import Optional, Dict, cast
import os, re, glob, sys
from pathlib import Path, PosixPath
from jwutils import stree
from . import stree
from .stree.StringTree import StringTree
from .log import *

View file

@ -0,0 +1,6 @@
TOPDIR = ../../../..
PY_UPDATE_INIT_PY ?= false
include $(TOPDIR)/make/proj.mk
include $(JWBDIR)/make/py-mod.mk

View file

@ -2,16 +2,16 @@
from __future__ import print_function
import jwutils.log
from . import log
class Object(object): # export
def __init__(self):
self.log_level = jwutils.log.level
self.log_level = log.level
def log(self, prio, *args):
if self.log_level == jwutils.log.level:
jwutils.log.slog(prio, args)
if self.log_level == log.level:
log.slog(prio, args)
return
if prio <= self.log_level:
msg = ""
@ -21,4 +21,4 @@ class Object(object): # export
print(msg[1:])
def debug(self, *args):
jwutils.log.slog(jwutils.log.DEBUG, args)
log.slog(log.DEBUG, args)

View file

@ -0,0 +1,3 @@
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__)

View file

@ -1,5 +1,5 @@
import asyncio
from jwutils.log import *
from ..log import *
# FIXME: Derive this from Process, or merge the classes entirely
@ -98,8 +98,8 @@ class ShellCmd: # export
await self.cleanup()
if __name__ == '__main__':
import jwutils.log
jwutils.log.set_level('info')
from .. import log
log.set_level('info')
async def run():
sp = ShellCmd([ 'echo', 'hello world!' ])
await sp.run()

View file

@ -6,8 +6,9 @@ import abc
from enum import Flag, Enum, auto
from jwutils.log import *
from jwutils import Config, load_object
from ..log import *
from ..Config import Config
from ..misc import load_object
class Access(Enum): # export
Read = auto()

View file

@ -0,0 +1,4 @@
TOPDIR = ../../../../../..
include $(TOPDIR)/make/proj.mk
include $(JWBDIR)/make/py-mod.mk

View file

@ -0,0 +1,4 @@
TOPDIR = ../../../../../..
include $(TOPDIR)/make/proj.mk
include $(JWBDIR)/make/py-mod.mk

View file

@ -5,9 +5,9 @@ from typing import Any
import abc
from contextlib import contextmanager
from jwutils.Config import Config
from jwutils.db.schema.Schema import Schema
from jwutils import Cmds
from ..Config import Config
from .schema.Schema import Schema
from ..Cmds import Cmds
from .Session import Session
from ..log import *

View file

@ -0,0 +1,4 @@
TOPDIR = ../../../../../..
include $(TOPDIR)/make/proj.mk
include $(JWBDIR)/make/py-mod.mk

View file

@ -4,13 +4,13 @@ from typing import Any
import abc
from jwutils.log import *
from jwutils.misc import load_classes
from jwutils.Cmds import Cmds
from jwutils.db.DataBase import DataBase
from jwutils.db.query.Query import Query as QueryBase
from jwutils.db.query.QueryResult import QueryResult
from jwutils.db.schema.Schema import Schema
from ...log import *
from ...misc import load_classes
from ...Cmds import Cmds
from ..DataBase import DataBase
from ..schema.Schema import Schema
from .Query import Query as QueryBase
from .QueryResult import QueryResult
class Queries(abc.ABC): # export

View file

@ -4,13 +4,13 @@ from typing import Any
import abc
from jwutils.log import *
from jwutils.misc import load_classes
from jwutils.Cmds import Cmds
from jwutils.db.DataBase import DataBase
from jwutils.db.Session import Session
from jwutils.db.query.QueryResult import QueryResult
#from jwutils.db.query.Queries import Queries
from ...log import *
from ...misc import load_classes
from ...Cmds import Cmds
from ..DataBase import DataBase
from ..Session import Session
from .QueryResult import QueryResult
#from .Queries import Queries
class Query(abc.ABC): # export

View file

@ -5,10 +5,10 @@ from typing import Any, Union
import abc
from enum import Enum, auto
from jwutils.log import *
from jwutils.Cmds import Cmds
from jwutils.db.DataBase import DataBase
from jwutils.db.Session import Session
from ...log import *
from ...Cmds import Cmds
from ..DataBase import DataBase
from ..Session import Session
class ResType(Enum): # export
Statement = auto()

View file

@ -3,7 +3,7 @@
import io, os, re, textwrap, json, csv
from tabulate import tabulate # type: ignore
from jwutils.log import *
from ..log import *
def rows_pretty(rows): # export
if type(rows) == dict:

View file

@ -2,7 +2,7 @@
from typing import Optional, Any
from jwutils.log import *
from ...log import *
from .ColumnSet import ColumnSet
from .SingleForeignKey import SingleForeignKey

View file

@ -0,0 +1,4 @@
TOPDIR = ../../../../../..
include $(TOPDIR)/make/proj.mk
include $(JWBDIR)/make/py-mod.mk

View file

@ -2,7 +2,7 @@
from .Schema import Schema
from jwutils.log import *
from ...log import *
def check_schema(schema: Schema): # export
slog(NOTICE, f'There are {len(schema)} tables in the database')

View file

@ -0,0 +1,4 @@
TOPDIR = ../../../../../..
include $(TOPDIR)/make/proj.mk
include $(JWBDIR)/make/py-mod.mk

View file

@ -4,7 +4,7 @@ from collections.abc import Callable
import xml.etree.ElementTree as ET
from jwutils.log import *
from ...log import *
class MapAttr2Shape: # export

View file

View file

@ -0,0 +1,4 @@
TOPDIR = ../../../../..
include $(TOPDIR)/make/proj.mk
include $(JWBDIR)/make/py-mod.mk

View file

@ -8,7 +8,7 @@ import re, fnmatch
from collections import OrderedDict
from enum import Enum, auto
from jwutils.log import *
from ..log import *
def quote(s):
if is_quoted(s):

View file

@ -2,8 +2,8 @@
import os, glob
from jwutils.stree.StringTree import *
from jwutils.log import *
from .StringTree import *
from ..log import *
def _cleanup_line(line: str) -> str:
line = line.strip()

View file

@ -0,0 +1,8 @@
# ruff: noqa: E501
from jw.util.ArgsContainer import ArgsContainer as ArgsContainer
from jw.util.ArgsContainer import add_argument as add_argument
__all__ = [
"ArgsContainer",
"add_argument",
]

View file

@ -0,0 +1,6 @@
# ruff: noqa: E501
from jw.util.Bunch import Bunch as Bunch
__all__ = [
"Bunch",
]

View file

@ -0,0 +1,6 @@
# ruff: noqa: E501
from jw.util.Cmd import Cmd as Cmd
__all__ = [
"Cmd",
]

View file

@ -0,0 +1,8 @@
# ruff: noqa: E501
from jw.util.Cmds import Cmds as Cmds
from jw.util.Cmds import run_sub_commands as run_sub_commands
__all__ = [
"Cmds",
"run_sub_commands",
]

View file

@ -0,0 +1,6 @@
# ruff: noqa: E501
from jw.util.Config import Config as Config
__all__ = [
"Config",
]

View file

@ -0,0 +1,6 @@
# ruff: noqa: E501
from jw.util.CppState import CppState as CppState
__all__ = [
"CppState",
]

View file

@ -1,4 +1,5 @@
TOPDIR = ../../..
PY_UPDATE_INIT_PY = false
include $(TOPDIR)/make/proj.mk
include $(JWBDIR)/make/py-mod.mk

View file

@ -0,0 +1,6 @@
# ruff: noqa: E501
from jw.util.Object import Object as Object
__all__ = [
"Object",
]

View file

@ -0,0 +1,6 @@
# ruff: noqa: E501
from jw.util.Options import Options as Options
__all__ = [
"Options",
]

View file

@ -0,0 +1,6 @@
# ruff: noqa: E501
from jw.util.Process import Process as Process
__all__ = [
"Process",
]

View file

@ -0,0 +1,6 @@
# ruff: noqa: E501
from jw.util.RedirectStdIO import RedirectStdIO as RedirectStdIO
__all__ = [
"RedirectStdIO",
]

View file

@ -0,0 +1,3 @@
# ruff: noqa: E501
__all__ = []

View file

@ -0,0 +1,6 @@
# ruff: noqa: E501
from jw.util.StopWatch import StopWatch as StopWatch
__all__ = [
"StopWatch",
]

View file

@ -0,0 +1,51 @@
# >> -------------------------- generated by python-tools.sh >>
# ruff: noqa: E501
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__)
from .ArgsContainer import ArgsContainer as ArgsContainer
from .ArgsContainer import add_argument as add_argument
from .Bunch import Bunch as Bunch
from .cast import cast_str_to_timedelta as cast_str_to_timedelta
from .cast import cast_str_to_int as cast_str_to_int
from .cast import cast_str_to_bool as cast_str_to_bool
from .cast import guess_type as guess_type
from .cast import from_str as from_str
from .cast import from_env as from_env
from .Cmds import Cmds as Cmds
from .Cmds import run_sub_commands as run_sub_commands
from .Config import Config as Config
from .CppState import CppState as CppState
from .ldap import Connection as Connection
from .ldap import default_config as default_config
from .log import prio_gets_logged as prio_gets_logged
from .log import log_level as log_level
from .log import slog_m as slog_m
from .log import slog as slog
from .log import parse_log_prio_str as parse_log_prio_str
from .log import console_color_chars as console_color_chars
from .log import set_level as set_level
from .log import set_flags as set_flags
from .log import append_to_prefix as append_to_prefix
from .log import remove_from_prefix as remove_from_prefix
from .log import set_filename_length as set_filename_length
from .log import set_module_name_length as set_module_name_length
from .log import add_log_file as add_log_file
from .misc import silentremove as silentremove
from .misc import atomic_store as atomic_store
from .misc import object_builtin_name as object_builtin_name
from .misc import get_derived_classes as get_derived_classes
from .misc import load_classes as load_classes
from .misc import load_class as load_class
from .misc import load_class_names as load_class_names
from .misc import load_object as load_object
from .misc import load_function as load_function
from .misc import commit_tmpfile as commit_tmpfile
from .misc import multi_regex_edit as multi_regex_edit
from .misc import dump as dump
from .Object import Object as Object
from .Options import Options as Options
from .Process import Process as Process
from .RedirectStdIO import RedirectStdIO as RedirectStdIO
from .StopWatch import StopWatch as StopWatch
# << -------------------------- generated by python-tools.sh <<

View file

@ -1,4 +1,5 @@
TOPDIR = ../../../..
PY_UPDATE_INIT_PY = false
include $(TOPDIR)/make/proj.mk
include $(JWBDIR)/make/py-mod.mk

View file

@ -0,0 +1,12 @@
# ruff: noqa: E501
from jw.util.algo.ShuntingYard import L as L
from jw.util.algo.ShuntingYard import R as R
from jw.util.algo.ShuntingYard import Operator as Operator
from jw.util.algo.ShuntingYard import ShuntingYard as ShuntingYard
__all__ = [
"L",
"R",
"Operator",
"ShuntingYard",
]

View file

@ -0,0 +1,8 @@
# >> -------------------------- generated by python-tools.sh >>
# ruff: noqa: E501
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__)
from .ShuntingYard import Operator as Operator
from .ShuntingYard import ShuntingYard as ShuntingYard
# << -------------------------- generated by python-tools.sh <<

View file

@ -1,4 +1,5 @@
TOPDIR = ../../../..
PY_UPDATE_INIT_PY = false
include $(TOPDIR)/make/proj.mk
include $(JWBDIR)/make/py-mod.mk

View file

@ -0,0 +1,6 @@
# ruff: noqa: E501
from jw.util.asyncio.Process import Process as Process
__all__ = [
"Process",
]

View file

@ -0,0 +1,6 @@
# ruff: noqa: E501
from jw.util.asyncio.ShellCmd import ShellCmd as ShellCmd
__all__ = [
"ShellCmd",
]

View file

@ -0,0 +1,3 @@
# ruff: noqa: E501
__all__ = []

View file

@ -0,0 +1,8 @@
# >> -------------------------- generated by python-tools.sh >>
# ruff: noqa: E501
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__)
from .Process import Process as Process
from .ShellCmd import ShellCmd as ShellCmd
# << -------------------------- generated by python-tools.sh <<

View file

@ -0,0 +1,14 @@
# ruff: noqa: E501
from jw.util.auth.Auth import Access as Access
from jw.util.auth.Auth import ProjectFlags as ProjectFlags
from jw.util.auth.Auth import Group as Group
from jw.util.auth.Auth import User as User
from jw.util.auth.Auth import Auth as Auth
__all__ = [
"Access",
"ProjectFlags",
"Group",
"User",
"Auth",
]

View file

@ -1,4 +1,5 @@
TOPDIR = ../../../..
PY_UPDATE_INIT_PY = false
include $(TOPDIR)/make/proj.mk
include $(JWBDIR)/make/py-mod.mk

View file

@ -0,0 +1,11 @@
# >> -------------------------- generated by python-tools.sh >>
# ruff: noqa: E501
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__)
from .Auth import Access as Access
from .Auth import ProjectFlags as ProjectFlags
from .Auth import Group as Group
from .Auth import User as User
from .Auth import Auth as Auth
# << -------------------------- generated by python-tools.sh <<

View file

@ -0,0 +1,10 @@
# ruff: noqa: E501
from jw.util.auth.dummy.Auth import Group as Group
from jw.util.auth.dummy.Auth import User as User
from jw.util.auth.dummy.Auth import Auth as Auth
__all__ = [
"Group",
"User",
"Auth",
]

View file

@ -0,0 +1,5 @@
TOPDIR = ../../../../..
PY_UPDATE_INIT_PY = false
include $(TOPDIR)/make/proj.mk
include $(JWBDIR)/make/py-mod.mk

View file

@ -0,0 +1,9 @@
# >> -------------------------- generated by python-tools.sh >>
# ruff: noqa: E501
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__)
from .Auth import Group as Group
from .Auth import User as User
from .Auth import Auth as Auth
# << -------------------------- generated by python-tools.sh <<

View file

@ -0,0 +1,8 @@
# ruff: noqa: E501
from jw.util.auth.ldap.Auth import Group as Group
from jw.util.auth.ldap.Auth import Auth as Auth
__all__ = [
"Group",
"Auth",
]

View file

@ -0,0 +1,5 @@
TOPDIR = ../../../../..
PY_UPDATE_INIT_PY = false
include $(TOPDIR)/make/proj.mk
include $(JWBDIR)/make/py-mod.mk

View file

@ -0,0 +1,8 @@
# >> -------------------------- generated by python-tools.sh >>
# ruff: noqa: E501
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__)
from .Auth import Group as Group
from .Auth import Auth as Auth
# << -------------------------- generated by python-tools.sh <<

View file

@ -0,0 +1,18 @@
# ruff: noqa: E501
from jw.util.cast import cast_str_to_timedelta as cast_str_to_timedelta
from jw.util.cast import cast_str_to_int as cast_str_to_int
from jw.util.cast import cast_str_to_bool as cast_str_to_bool
from jw.util.cast import guess_type as guess_type
from jw.util.cast import from_str as from_str
from jw.util.cast import from_env as from_env
from jw.util.cast import cast_str as cast_str
__all__ = [
"cast_str_to_timedelta",
"cast_str_to_int",
"cast_str_to_bool",
"guess_type",
"from_str",
"from_env",
"cast_str",
]

View file

@ -0,0 +1,7 @@
# ruff: noqa: E501
from jw.util.db.DataBase import DataBase as DataBase
__all__ = [
"DataBase",
]

View file

@ -1,4 +1,5 @@
TOPDIR = ../../../..
PY_UPDATE_INIT_PY = false
include $(TOPDIR)/make/proj.mk
include $(JWBDIR)/make/py-mod.mk

View file

@ -0,0 +1,6 @@
# ruff: noqa: E501
from jw.util.db.Session import Session as Session
__all__ = [
"Session",
]

View file

@ -0,0 +1,6 @@
# ruff: noqa: E501
from jw.util.db.TableIoHandler import TableIoHandler as TableIoHandler
__all__ = [
"TableIoHandler",
]

View file

@ -0,0 +1,17 @@
# >> -------------------------- generated by python-tools.sh >>
# ruff: noqa: E501
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__)
from .rows import rows_pretty as rows_pretty
from .rows import rows_duplicates as rows_duplicates
from .rows import rows_remove as rows_remove
from .rows import rows_select as rows_select
from .rows import rows_rewrite_regex as rows_rewrite_regex
from .rows import rows_check_not_null as rows_check_not_null
from .rows import rows_dumps as rows_dumps
from .rows import rows_dump as rows_dump
from .rows import rows_to_csv as rows_to_csv
from .Session import Session as Session
from .TableIoHandler import TableIoHandler as TableIoHandler
# << -------------------------- generated by python-tools.sh <<

View file

@ -0,0 +1,5 @@
TOPDIR = ../../../../..
PY_UPDATE_INIT_PY = false
include $(TOPDIR)/make/proj.mk
include $(JWBDIR)/make/py-mod.mk

View file

@ -0,0 +1,6 @@
# ruff: noqa: E501
from jw.util.db.query.Queries import Queries as Queries
__all__ = [
"Queries",
]

View file

@ -0,0 +1,6 @@
# ruff: noqa: E501
from jw.util.db.query.Query import Query as Query
__all__ = [
"Query",
]

Some files were not shown because too many files have changed in this diff Show more