8642b73ba1
misc: Add multi_regex_edit()
...
Signed-off-by: Jan Lindemann <jan@janware.com>
2022-12-04 12:34:52 +01:00
a52557570b
misc.py: from . import log
...
Do "from . import log" instead of "from jwutils import log". It works and looks cleaner than a module referencing itself. Not entirely sure if that's the way to go, I must admit.
Signed-off-by: Jan Lindemann <jan@janware.com>
2022-12-02 12:14:00 +01:00
428692ea3a
Streamline Python file headers somewhat
...
- Add coding statement
- Import all modules in one line where possible
- Order: __future__, typing, plain imports, from imports,
janware modules
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-07-10 05:14:06 +02:00
cc7aeeac31
misc: Add load_function()
...
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-01-29 16:54:10 +01:00
ce347772dd
misc: Add debug logging to load_class()
...
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-01-28 10:16:06 +01:00
381514ab2c
misc: Add load_class()
...
Add load_class() to complement load_object(), returning the class as opposed to instantiated object.
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-01-16 10:51:28 +01:00
c63d1a729e
misc: Add dump()
...
Add misc.dump(), which takes an iterable, assumes all elements have a dump() method, and calls it on all of them.
Signed-off-by: Jan Lindemann <jan@janware.com>
2020-04-23 10:34:28 +02:00
86e25a2dfb
misc: Add load_(classes|class_names|object)()
...
Add some functions to aid in dynamically loading objects.
Signed-off-by: Jan Lindemann <jan@janware.com>
2020-04-22 14:02:35 +02:00
77d43aebad
Add type annotations from monkeytype + jw-devops/test
...
Add type annotations as generated by monkeytype and jw-devops/test, plus some hand editing to satisfy both monkeytype and mypy.
Signed-off-by: Jan Lindemann <jan@janware.com>
2020-04-10 17:55:36 +02:00
952bf4a4e1
Fix Python errors reported by mypy
...
This commit fixes Python errors and warnings reported by static type checking with mypy.
Signed-off-by: Jan Lindemann <jan@janware.com>
2020-04-10 14:17:15 +02:00
47f4de938f
jwutils.misc: Add commit_tmpfile()
...
commit_tmpfile() is a better os.rename which doesn't do anything if source and target files are equal, and logs if does something.
Signed-off-by: Jan Lindemann <jan@janware.com>
2020-04-08 08:50:54 +02:00
6d6c48e6b8
jwutils.misc: Add get_derived_classes()
...
get_derived_classes(mod, baseclass) returns a list of class definitions from a module which are subclasses of baseclass.
Signed-off-by: Jan Lindemann <jan@janware.com>
2020-04-05 16:53:12 +02:00
ddfb500fa2
Add misc.object_builtin_name()
...
object_builtin_name() is meant to derive an object name from its class name. Doesn't work well, but adding the code nonetheless for improving it later.
Signed-off-by: Jan Lindemann <jan@janware.com>
2019-10-24 18:45:05 +02:00
ef79027b06
misc.py: Make process cleanup more robust
...
Eliminate a far chance of an exception thrown during process cleanup.
Signed-off-by: Jan Lindemann <jan@janware.com>
2017-11-22 09:52:22 +01:00
4a200c8851
misc.py: Add atomic_store()
...
Signed-off-by: Jan Lindemann <jan@janware.com>
2017-11-22 09:33:18 +01:00
8c5934725c
grammar.py: Add support for --irrelevant-symbols
...
Arguments to --irrelevant-symbols are not meant to be represented in the AST resulting from parsing.
Also, add pad() to misc.py.
Signed-off-by: Jan Lindemann <jan@janware.com>
2017-10-30 10:00:25 +01:00
f6e5d25df7
Add misc.py
...
Signed-off-by: Jan Lindemann <jan@janware.com>
2017-07-25 17:06:03 +02:00