zrb 0.15.0__py3-none-any.whl → 0.15.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. zrb/__main__.py +0 -3
  2. zrb/action/runner.py +6 -2
  3. zrb/advertisement.py +4 -0
  4. zrb/builtin/devtool/install/_input.py +2 -4
  5. zrb/builtin/project/create/template/project.sh +1 -0
  6. zrb/config/config.py +21 -14
  7. zrb/helper/accessories/color.py +5 -2
  8. zrb/helper/accessories/icon.py +4 -0
  9. zrb/helper/accessories/name.py +4 -0
  10. zrb/helper/accessories/untyped_color.py +10 -0
  11. zrb/helper/advertisement.py +3 -0
  12. zrb/helper/callable.py +5 -0
  13. zrb/helper/cli.py +2 -0
  14. zrb/helper/codemod/add_argument_to_function.py +6 -0
  15. zrb/helper/codemod/add_argument_to_function_call.py +6 -0
  16. zrb/helper/codemod/add_assert_resource.py +4 -0
  17. zrb/helper/codemod/add_function_call.py +4 -0
  18. zrb/helper/codemod/add_import_module.py +4 -0
  19. zrb/helper/codemod/add_key_value_to_dict.py +6 -0
  20. zrb/helper/codemod/add_property_to_class.py +6 -0
  21. zrb/helper/codemod/add_upstream_to_task.py +4 -0
  22. zrb/helper/codemod/append_code_to_function.py +6 -0
  23. zrb/helper/codemod/format_code.py +4 -0
  24. zrb/helper/default_env.py +2 -0
  25. zrb/helper/docker_compose/fetch_external_env.py +6 -0
  26. zrb/helper/docker_compose/file.py +4 -0
  27. zrb/helper/docstring.py +5 -0
  28. zrb/helper/env_map/fetch.py +4 -0
  29. zrb/helper/file/copy_tree.py +3 -0
  30. zrb/helper/file/match.py +4 -0
  31. zrb/helper/file/text.py +4 -0
  32. zrb/helper/git/detect_changes.py +4 -0
  33. zrb/helper/loader/load_module.py +2 -0
  34. zrb/helper/log.py +1 -1
  35. zrb/helper/map/conversion.py +4 -0
  36. zrb/helper/python_task.py +3 -0
  37. zrb/helper/render_data.py +4 -0
  38. zrb/helper/string/conversion.py +13 -36
  39. zrb/helper/string/jinja.py +4 -0
  40. zrb/helper/string/modification.py +4 -0
  41. zrb/helper/string/parse_replacement.py +4 -0
  42. zrb/helper/string/untyped_conversion.py +49 -0
  43. zrb/helper/task.py +4 -0
  44. zrb/helper/typecheck.py +6 -7
  45. zrb/helper/typing.py +32 -12
  46. zrb/helper/util.py +4 -0
  47. zrb/runner.py +3 -0
  48. zrb/task/any_task.py +4 -0
  49. zrb/task/any_task_event_handler.py +4 -0
  50. zrb/task/base_remote_cmd_task.py +4 -0
  51. zrb/task/checker.py +4 -0
  52. zrb/task/cmd_task.py +4 -1
  53. zrb/task/decorator.py +4 -0
  54. zrb/task/docker_compose_task.py +4 -0
  55. zrb/task/flow_task.py +4 -0
  56. zrb/task/http_checker.py +4 -0
  57. zrb/task/notifier.py +4 -0
  58. zrb/task/parallel.py +4 -0
  59. zrb/task/path_checker.py +4 -0
  60. zrb/task/path_watcher.py +4 -0
  61. zrb/task/port_checker.py +4 -0
  62. zrb/task/recurring_task.py +4 -0
  63. zrb/task/remote_cmd_task.py +4 -0
  64. zrb/task/resource_maker.py +4 -0
  65. zrb/task/rsync_task.py +4 -0
  66. zrb/task/task.py +4 -0
  67. zrb/task/time_watcher.py +4 -0
  68. zrb/task/wiki_task.py +4 -0
  69. zrb/task_env/constant.py +5 -0
  70. zrb/task_env/env.py +4 -0
  71. zrb/task_env/env_file.py +4 -0
  72. zrb/task_group/group.py +4 -0
  73. zrb/task_input/any_input.py +4 -0
  74. zrb/task_input/base_input.py +4 -0
  75. zrb/task_input/bool_input.py +4 -0
  76. zrb/task_input/choice_input.py +4 -0
  77. zrb/task_input/constant.py +5 -0
  78. zrb/task_input/float_input.py +4 -0
  79. zrb/task_input/int_input.py +4 -0
  80. zrb/task_input/password_input.py +4 -0
  81. zrb/task_input/str_input.py +4 -0
  82. zrb/task_input/task_input.py +4 -0
  83. {zrb-0.15.0.dist-info → zrb-0.15.1.dist-info}/METADATA +1 -1
  84. {zrb-0.15.0.dist-info → zrb-0.15.1.dist-info}/RECORD +87 -85
  85. {zrb-0.15.0.dist-info → zrb-0.15.1.dist-info}/LICENSE +0 -0
  86. {zrb-0.15.0.dist-info → zrb-0.15.1.dist-info}/WHEEL +0 -0
  87. {zrb-0.15.0.dist-info → zrb-0.15.1.dist-info}/entry_points.txt +0 -0
zrb/__main__.py CHANGED
@@ -1,10 +1,7 @@
1
- from zrb.helper.accessories.color import colored
2
1
  from zrb.helper.cli import create_cli
3
2
  from zrb.helper.default_env import inject_default_env
4
- from zrb.helper.log import logger
5
3
 
6
4
  inject_default_env()
7
- logger.info(colored("Create CLI instance", attrs=["dark"]))
8
5
  cli = create_cli()
9
6
 
10
7
  if __name__ == "__main__":
zrb/action/runner.py CHANGED
@@ -9,6 +9,8 @@ from zrb.helper.typing import Any, Callable, List, Mapping, Union
9
9
  from zrb.task.any_task import AnyTask
10
10
  from zrb.task_group.group import Group as TaskGroup
11
11
 
12
+ logger.debug(colored("Loading zrb.action.runner", attrs=["dark"]))
13
+
12
14
  CliSubcommand = Union[click.Group, click.Command]
13
15
 
14
16
 
@@ -88,7 +90,7 @@ class Runner:
88
90
  task_inputs = task._get_combined_inputs()
89
91
  task_cli_name = task.get_cli_name()
90
92
  task_description = task.get_description()
91
- callback = self.__wrap_task_function(task)
93
+ callback = self.__get_wrapped_task_function(task)
92
94
  command = click.Command(
93
95
  callback=callback, name=task_cli_name, help=task_description
94
96
  )
@@ -106,12 +108,14 @@ class Runner:
106
108
  command.params.append(click.Option(param_decl, **options))
107
109
  return command
108
110
 
109
- def __wrap_task_function(self, task: AnyTask) -> Callable[..., Any]:
111
+ def __get_wrapped_task_function(self, task: AnyTask) -> Callable[..., Any]:
110
112
  def wrapped_function(*args: Any, **kwargs: Any) -> Any:
111
113
  function = task.to_function(env_prefix=self.__env_prefix, raise_error=True)
112
114
  try:
113
115
  function(*args, **kwargs)
114
116
  except Exception:
115
117
  sys.exit(1)
118
+ finally:
119
+ task.clear_xcom()
116
120
 
117
121
  return wrapped_function
zrb/advertisement.py CHANGED
@@ -1,6 +1,10 @@
1
+ from zrb.helper.accessories.color import colored
1
2
  from zrb.helper.advertisement import Advertisement
3
+ from zrb.helper.log import logger
2
4
  from zrb.helper.typing import List
3
5
 
6
+ logger.debug(colored("Loading zrb.advertisement", attrs=["dark"]))
7
+
4
8
  # flake8: noqa E501
5
9
 
6
10
  advertisements: List[Advertisement] = [
@@ -1,11 +1,9 @@
1
- from zrb.config.config import get_current_shell
1
+ from zrb.config.config import default_shell
2
2
  from zrb.task_input.str_input import StrInput
3
3
 
4
- current_shell = get_current_shell()
5
-
6
4
  terminal_config_file_input = StrInput(
7
5
  name="config-file",
8
6
  shortcut="c",
9
7
  prompt="Config file",
10
- default="~/.zshrc" if current_shell == "zsh" else "~/.bashrc",
8
+ default="~/.zshrc" if default_shell == "zsh" else "~/.bashrc",
11
9
  )
@@ -56,6 +56,7 @@ reload() {
56
56
  fi
57
57
 
58
58
  log_info 'Install'
59
+ poetry lock --no-update
59
60
  poetry install
60
61
 
61
62
  if [ "$IS_TERMUX" = "1" ]
zrb/config/config.py CHANGED
@@ -1,17 +1,17 @@
1
1
  import importlib.metadata as metadata
2
2
  import os
3
3
 
4
- from zrb.helper.string.conversion import to_boolean, to_logging_level
5
- from zrb.helper.typecheck import typechecked
4
+ from zrb.helper.string.untyped_conversion import (
5
+ untyped_to_boolean,
6
+ untyped_to_logging_level,
7
+ )
6
8
 
7
9
 
8
- @typechecked
9
- def get_version() -> str:
10
+ def _get_version() -> str:
10
11
  return metadata.version("zrb")
11
12
 
12
13
 
13
- @typechecked
14
- def get_current_shell() -> str:
14
+ def _get_current_shell() -> str:
15
15
  current_shell = os.getenv("SHELL", "")
16
16
  if current_shell.endswith("zsh"):
17
17
  return "zsh"
@@ -24,17 +24,24 @@ def _get_valid_container_backend(container_backend: str) -> str:
24
24
  return "docker"
25
25
 
26
26
 
27
- tmp_dir = os.getenv("ZRB_TMP_DIR", "/tmp")
28
- default_shell = os.getenv("ZRB_SHELL", get_current_shell())
27
+ def _get_default_tmp_dir() -> str:
28
+ if os.path.isdir("/tmp"):
29
+ return "/tmp"
30
+ return os.path.expanduser(os.path.join("~", ".tmp"))
31
+
32
+
33
+ tmp_dir = os.getenv("ZRB_TMP_DIR", _get_default_tmp_dir())
34
+ default_shell = os.getenv("ZRB_SHELL", _get_current_shell())
29
35
  init_script_str = os.getenv("ZRB_INIT_SCRIPTS", "")
30
36
  init_scripts = init_script_str.split(":") if init_script_str != "" else []
31
- logging_level = to_logging_level(os.getenv("ZRB_LOGGING_LEVEL", "WARNING"))
32
- should_load_builtin = to_boolean(os.getenv("ZRB_SHOULD_LOAD_BUILTIN", "1"))
37
+ logging_level = untyped_to_logging_level(os.getenv("ZRB_LOGGING_LEVEL", "WARNING"))
38
+ should_load_builtin = untyped_to_boolean(os.getenv("ZRB_SHOULD_LOAD_BUILTIN", "1"))
33
39
  env_prefix = os.getenv("ZRB_ENV", "")
34
- show_advertisement = to_boolean(os.getenv("ZRB_SHOW_ADVERTISEMENT", "1"))
35
- show_prompt = to_boolean(os.getenv("ZRB_SHOW_PROMPT", "1"))
36
- show_time = to_boolean(os.getenv("ZRB_SHOW_TIME", "1"))
37
- version = get_version()
40
+ show_advertisement = untyped_to_boolean(os.getenv("ZRB_SHOW_ADVERTISEMENT", "1"))
41
+ show_prompt = untyped_to_boolean(os.getenv("ZRB_SHOW_PROMPT", "1"))
42
+ show_time = untyped_to_boolean(os.getenv("ZRB_SHOW_TIME", "1"))
43
+ version = _get_version()
38
44
  container_backend = _get_valid_container_backend(
39
45
  os.getenv("ZRB_CONTAINER_BACKEND", "docker")
40
46
  )
47
+ enable_type_checking = untyped_to_boolean(os.getenv("ZRB_ENABLE_TYPE_CHECKING", "1"))
@@ -1,11 +1,14 @@
1
1
  import random
2
2
 
3
3
  from termcolor import COLORS
4
- from termcolor import colored as term_colored
5
4
 
5
+ from zrb.helper.accessories.untyped_color import untyped_colored
6
+ from zrb.helper.log import logger
6
7
  from zrb.helper.typecheck import typechecked
7
8
  from zrb.helper.typing import Iterable, Optional
8
9
 
10
+ logger.debug(untyped_colored("Loading zrb.helper.accessories.color", attrs=["dark"]))
11
+
9
12
 
10
13
  @typechecked
11
14
  def get_random_color() -> str:
@@ -37,4 +40,4 @@ def colored(
37
40
  on_color: Optional[str] = None,
38
41
  attrs: Optional[Iterable[str]] = None,
39
42
  ) -> str:
40
- return term_colored(text, color, on_color, attrs)
43
+ return untyped_colored(text, color, on_color, attrs)
@@ -1,7 +1,11 @@
1
1
  import random
2
2
 
3
+ from zrb.helper.accessories.color import colored
4
+ from zrb.helper.log import logger
3
5
  from zrb.helper.typecheck import typechecked
4
6
 
7
+ logger.debug(colored("Loading zrb.helper.accessories.icon", attrs=["dark"]))
8
+
5
9
 
6
10
  @typechecked
7
11
  def get_random_icon() -> str:
@@ -1,8 +1,12 @@
1
1
  import random
2
2
  import string
3
3
 
4
+ from zrb.helper.accessories.color import colored
5
+ from zrb.helper.log import logger
4
6
  from zrb.helper.typecheck import typechecked
5
7
 
8
+ logger.debug(colored("Loading zrb.helper.accessories.name", attrs=["dark"]))
9
+
6
10
 
7
11
  @typechecked
8
12
  def get_random_name(
@@ -0,0 +1,10 @@
1
+ from termcolor import colored as term_colored
2
+
3
+
4
+ def untyped_colored(
5
+ text,
6
+ color=None,
7
+ on_color=None,
8
+ attrs=None,
9
+ ) -> str:
10
+ return term_colored(text, color, on_color, attrs)
@@ -4,9 +4,12 @@ import re
4
4
  import sys
5
5
 
6
6
  from zrb.helper.accessories.color import colored
7
+ from zrb.helper.log import logger
7
8
  from zrb.helper.typecheck import typechecked
8
9
  from zrb.helper.typing import Iterable, Optional
9
10
 
11
+ logger.debug(colored("Loading zrb.helper.advertisement", attrs=["dark"]))
12
+
10
13
 
11
14
  @typechecked
12
15
  class Advertisement:
zrb/helper/callable.py CHANGED
@@ -1,6 +1,11 @@
1
1
  import inspect
2
2
  from typing import Any, Callable
3
3
 
4
+ from zrb.helper.accessories.color import colored
5
+ from zrb.helper.log import logger
6
+
7
+ logger.debug(colored("Loading zrb.helper.callable", attrs=["dark"]))
8
+
4
9
 
5
10
  async def run_async(fn: Callable, *args: Any, **kwargs: Any) -> Any:
6
11
  if inspect.iscoroutinefunction(fn):
zrb/helper/cli.py CHANGED
@@ -11,6 +11,8 @@ from zrb.helper.log import logger
11
11
  from zrb.helper.typecheck import typechecked
12
12
  from zrb.runner import runner
13
13
 
14
+ logger.debug(colored("Loading zrb.helper.cli", attrs=["dark"]))
15
+
14
16
  HELP = f"""
15
17
  bb
16
18
  zzzzz rr rr bb
@@ -1,7 +1,13 @@
1
1
  import libcst as cst
2
2
 
3
+ from zrb.helper.accessories.color import colored
4
+ from zrb.helper.log import logger
3
5
  from zrb.helper.typecheck import typechecked
4
6
 
7
+ logger.debug(
8
+ colored("Loading zrb.helper.codemod.add_argument_to_function", attrs=["dark"])
9
+ )
10
+
5
11
 
6
12
  @typechecked
7
13
  class AddArgumentTransformer(cst.CSTTransformer):
@@ -1,7 +1,13 @@
1
1
  import libcst as cst
2
2
 
3
+ from zrb.helper.accessories.color import colored
4
+ from zrb.helper.log import logger
3
5
  from zrb.helper.typecheck import typechecked
4
6
 
7
+ logger.debug(
8
+ colored("Loading zrb.helper.codemod.add_argument_to_function_call", attrs=["dark"])
9
+ )
10
+
5
11
 
6
12
  @typechecked
7
13
  class AddArgumentTransformer(cst.CSTTransformer):
@@ -1,7 +1,11 @@
1
1
  import libcst as cst
2
2
 
3
+ from zrb.helper.accessories.color import colored
4
+ from zrb.helper.log import logger
3
5
  from zrb.helper.typecheck import typechecked
4
6
 
7
+ logger.debug(colored("Loading zrb.helper.codemod.add_assert_resource", attrs=["dark"]))
8
+
5
9
 
6
10
  @typechecked
7
11
  def add_assert_resource(code: str, resource: str) -> str:
@@ -1,7 +1,11 @@
1
1
  import libcst as cst
2
2
 
3
+ from zrb.helper.accessories.color import colored
4
+ from zrb.helper.log import logger
3
5
  from zrb.helper.typecheck import typechecked
4
6
 
7
+ logger.debug(colored("Loading zrb.helper.codemod.add_function_call", attrs=["dark"]))
8
+
5
9
 
6
10
  @typechecked
7
11
  def add_function_call(code: str, function_name: str, parameters: list) -> str:
@@ -1,8 +1,12 @@
1
1
  import libcst as cst
2
2
 
3
+ from zrb.helper.accessories.color import colored
4
+ from zrb.helper.log import logger
3
5
  from zrb.helper.typecheck import typechecked
4
6
  from zrb.helper.typing import Optional, Tuple, Union
5
7
 
8
+ logger.debug(colored("Loading zrb.helper.codemod.add_import_module", attrs=["dark"]))
9
+
6
10
 
7
11
  @typechecked
8
12
  def add_import_module(
@@ -1,7 +1,13 @@
1
1
  import libcst as cst
2
2
 
3
+ from zrb.helper.accessories.color import colored
4
+ from zrb.helper.log import logger
3
5
  from zrb.helper.typecheck import typechecked
4
6
 
7
+ logger.debug(
8
+ colored("Loading zrb.helper.codemod.add_key_value_to_dict", attrs=["dark"])
9
+ )
10
+
5
11
 
6
12
  @typechecked
7
13
  class AddKeyValuePairTransformer(cst.CSTTransformer):
@@ -1,8 +1,14 @@
1
1
  import libcst as cst
2
2
 
3
+ from zrb.helper.accessories.color import colored
4
+ from zrb.helper.log import logger
3
5
  from zrb.helper.typecheck import typechecked
4
6
  from zrb.helper.typing import Optional
5
7
 
8
+ logger.debug(
9
+ colored("Loading zrb.helper.codemod.add_property_to_class", attrs=["dark"])
10
+ )
11
+
6
12
 
7
13
  @typechecked
8
14
  class AddPropertyTransformer(cst.CSTTransformer):
@@ -1,7 +1,11 @@
1
1
  import libcst as cst
2
2
 
3
+ from zrb.helper.accessories.color import colored
4
+ from zrb.helper.log import logger
3
5
  from zrb.helper.typecheck import typechecked
4
6
 
7
+ logger.debug(colored("Loading zrb.helper.codemod.add_upstream_to_task", attrs=["dark"]))
8
+
5
9
 
6
10
  @typechecked
7
11
  class TaskTransformer(cst.CSTTransformer):
@@ -1,7 +1,13 @@
1
1
  import libcst as cst
2
2
 
3
+ from zrb.helper.accessories.color import colored
4
+ from zrb.helper.log import logger
3
5
  from zrb.helper.typecheck import typechecked
4
6
 
7
+ logger.debug(
8
+ colored("Loading zrb.helper.codemod.append_code_to_function", attrs=["dark"])
9
+ )
10
+
5
11
 
6
12
  @typechecked
7
13
  class AppendCodeTransformer(cst.CSTTransformer):
@@ -1,7 +1,11 @@
1
1
  import autopep8
2
2
 
3
+ from zrb.helper.accessories.color import colored
4
+ from zrb.helper.log import logger
3
5
  from zrb.helper.typecheck import typechecked
4
6
 
7
+ logger.debug(colored("Loading zrb.helper.codemod.format_code", attrs=["dark"]))
8
+
5
9
 
6
10
  @typechecked
7
11
  def format_code(code: str) -> str:
zrb/helper/default_env.py CHANGED
@@ -6,9 +6,11 @@ from zrb.helper.log import logger
6
6
  from zrb.helper.typecheck import typechecked
7
7
  from zrb.helper.typing import Mapping, Optional
8
8
 
9
+ logger.debug(colored("Loading zrb.helper.default_env", attrs=["dark"]))
9
10
  _PROJECT_DIR_MAP: Mapping[str, str] = {}
10
11
 
11
12
 
13
+ @lru_cache
12
14
  def inject_default_env():
13
15
  # Inject PYTHONUNBUFFERED
14
16
  if "PYTHONUNBUFFERED" not in os.environ:
@@ -1,6 +1,12 @@
1
+ from zrb.helper.accessories.color import colored
2
+ from zrb.helper.log import logger
1
3
  from zrb.helper.typecheck import typechecked
2
4
  from zrb.helper.typing import Any, List, Mapping
3
5
 
6
+ logger.debug(
7
+ colored("Loading zrb.helper.docker_compose.fetch_external_env", attrs=["dark"])
8
+ )
9
+
4
10
 
5
11
  @typechecked
6
12
  def fetch_compose_file_env_map(data: Any) -> Mapping[str, str]:
@@ -1,8 +1,12 @@
1
1
  from ruamel.yaml import YAML, CommentedMap
2
2
 
3
+ from zrb.helper.accessories.color import colored
4
+ from zrb.helper.log import logger
3
5
  from zrb.helper.typecheck import typechecked
4
6
  from zrb.helper.typing import Any, Mapping
5
7
 
8
+ logger.debug(colored("Loading zrb.helper.docker_compose.file", attrs=["dark"]))
9
+
6
10
 
7
11
  @typechecked
8
12
  def read_compose_file(file_name: str) -> Any:
zrb/helper/docstring.py CHANGED
@@ -1,6 +1,11 @@
1
1
  import inspect
2
2
  import re
3
3
 
4
+ from zrb.helper.accessories.color import colored
5
+ from zrb.helper.log import logger
6
+
7
+ logger.debug(colored("Loading zrb.helper.docstring", attrs=["dark"]))
8
+
4
9
 
5
10
  def get_markdown_from_docstring(cls) -> str:
6
11
  """
@@ -1,3 +1,5 @@
1
+ from zrb.helper.accessories.color import colored
2
+ from zrb.helper.log import logger
1
3
  from zrb.helper.string.jinja import is_probably_jinja
2
4
  from zrb.helper.typecheck import typechecked
3
5
  from zrb.helper.typing import List, Mapping
@@ -5,6 +7,8 @@ from zrb.task.any_task import AnyTask
5
7
  from zrb.task_env.env import Env
6
8
  from zrb.task_group.group import Group
7
9
 
10
+ logger.debug(colored("Loading zrb.helper.env_map.fetch", attrs=["dark"]))
11
+
8
12
 
9
13
  @typechecked
10
14
  def fetch_env_map_from_group(
@@ -2,12 +2,15 @@ import fnmatch
2
2
  import os
3
3
  import shutil
4
4
 
5
+ from zrb.helper.accessories.color import colored
5
6
  from zrb.helper.file.text import read_text_file_async, write_text_file_async
6
7
  from zrb.helper.log import logger
7
8
  from zrb.helper.string.parse_replacement import parse_replacement
8
9
  from zrb.helper.typecheck import typechecked
9
10
  from zrb.helper.typing import Iterable, Mapping, Optional
10
11
 
12
+ logger.debug(colored("Loading zrb.helper.file.copy_tree", attrs=["dark"]))
13
+
11
14
 
12
15
  @typechecked
13
16
  async def copy_tree(
zrb/helper/file/match.py CHANGED
@@ -1,9 +1,13 @@
1
1
  import fnmatch
2
2
  import glob
3
3
 
4
+ from zrb.helper.accessories.color import colored
5
+ from zrb.helper.log import logger
4
6
  from zrb.helper.typecheck import typechecked
5
7
  from zrb.helper.typing import Iterable, List
6
8
 
9
+ logger.debug(colored("Loading zrb.helper.file.match", attrs=["dark"]))
10
+
7
11
 
8
12
  @typechecked
9
13
  def get_file_names(glob_path: str, glob_ignored_paths: Iterable[str]) -> List[str]:
zrb/helper/file/text.py CHANGED
@@ -2,8 +2,12 @@ import os
2
2
 
3
3
  import aiofiles
4
4
 
5
+ from zrb.helper.accessories.color import colored
6
+ from zrb.helper.log import logger
5
7
  from zrb.helper.typecheck import typechecked
6
8
 
9
+ logger.debug(colored("Loading zrb.helper.file.text", attrs=["dark"]))
10
+
7
11
 
8
12
  @typechecked
9
13
  async def read_text_file_async(file_name: str) -> str:
@@ -1,8 +1,12 @@
1
1
  import subprocess
2
2
 
3
+ from zrb.helper.accessories.color import colored
4
+ from zrb.helper.log import logger
3
5
  from zrb.helper.typecheck import typechecked
4
6
  from zrb.helper.typing import Mapping
5
7
 
8
+ logger.debug(colored("Loading zrb.helper.git.detect_changes", attrs=["dark"]))
9
+
6
10
 
7
11
  @typechecked
8
12
  class ModificationState:
@@ -8,6 +8,8 @@ from zrb.helper.accessories.color import colored
8
8
  from zrb.helper.log import logger
9
9
  from zrb.helper.typecheck import typechecked
10
10
 
11
+ logger.debug(colored("Loading zrb.helper.loader.load_module", attrs=["dark"]))
12
+
11
13
  pattern = re.compile("[^a-zA-Z0-9]")
12
14
 
13
15
 
zrb/helper/log.py CHANGED
@@ -1,7 +1,7 @@
1
1
  import logging
2
2
 
3
3
  from zrb.config.config import logging_level
4
- from zrb.helper.accessories.color import colored
4
+ from zrb.helper.accessories.untyped_color import untyped_colored as colored
5
5
 
6
6
  # create logger
7
7
  logger = logging.getLogger("zrb")
@@ -1,6 +1,10 @@
1
+ from zrb.helper.accessories.color import colored
2
+ from zrb.helper.log import logger
1
3
  from zrb.helper.typecheck import typechecked
2
4
  from zrb.helper.typing import Any, Mapping
3
5
 
6
+ logger.debug(colored("Loading zrb.helper.map.conversion", attrs=["dark"]))
7
+
4
8
 
5
9
  @typechecked
6
10
  def to_str(
zrb/helper/python_task.py CHANGED
@@ -1,10 +1,13 @@
1
1
  import sys
2
2
 
3
3
  from zrb.helper.accessories.color import colored
4
+ from zrb.helper.log import logger
4
5
  from zrb.helper.task import show_lines as task_show_lines
5
6
  from zrb.helper.typecheck import typechecked
6
7
  from zrb.task.task import Task
7
8
 
9
+ logger.debug(colored("Loading zrb.helper.python_task", attrs=["dark"]))
10
+
8
11
  _DEPRECATION_WARNING = """
9
12
  DEPRECATED: zrb.helper.python_task
10
13
  Use zrb.helper.task instead
zrb/helper/render_data.py CHANGED
@@ -3,6 +3,8 @@ import os
3
3
  import platform
4
4
  import time
5
5
 
6
+ from zrb.helper.accessories.color import colored
7
+ from zrb.helper.log import logger
6
8
  from zrb.helper.util import (
7
9
  coalesce,
8
10
  coalesce_str,
@@ -14,6 +16,8 @@ from zrb.helper.util import (
14
16
  to_snake_case,
15
17
  )
16
18
 
19
+ logger.debug(colored("Loading zrb.helper.render_data", attrs=["dark"]))
20
+
17
21
  DEFAULT_RENDER_DATA = {
18
22
  "datetime": datetime,
19
23
  "os": os,
@@ -1,54 +1,31 @@
1
- import keyword
2
- import logging
3
- import re
4
-
5
- from zrb.helper.string.constant import FALSE_STRS, TRUE_STRS
1
+ from zrb.helper.accessories.color import colored
2
+ from zrb.helper.log import logger
3
+ from zrb.helper.string.untyped_conversion import (
4
+ untyped_to_boolean,
5
+ untyped_to_cli_name,
6
+ untyped_to_logging_level,
7
+ untyped_to_variable_name,
8
+ )
6
9
  from zrb.helper.typecheck import typechecked
7
10
 
8
- NON_WORD = re.compile(r"[\W]+")
9
- LEADING_NUM = re.compile(r"^\d+")
10
- LOGGING_LEVEL_MAP = {
11
- "critical": logging.CRITICAL,
12
- "fatal": logging.FATAL,
13
- "error": logging.ERROR,
14
- "warning": logging.WARNING,
15
- "warn": logging.WARN,
16
- "info": logging.INFO,
17
- "debug": logging.DEBUG,
18
- "notset": logging.NOTSET,
19
- }
11
+ logger.debug(colored("Loading zrb.helper.string.conversion", attrs=["dark"]))
20
12
 
21
13
 
22
14
  @typechecked
23
15
  def to_cli_name(name: str) -> str:
24
- return NON_WORD.sub("-", name).strip("-").lower()
16
+ return untyped_to_cli_name((name))
25
17
 
26
18
 
27
19
  @typechecked
28
20
  def to_variable_name(string: str) -> str:
29
- # Replace any non-word characters with underscore
30
- string = NON_WORD.sub("_", string).strip()
31
- # Remove leading digits
32
- string = LEADING_NUM.sub("", string)
33
- # Convert to lowercase
34
- string = string.lower()
35
- if keyword.iskeyword(string):
36
- return string + "_"
37
- return string
21
+ return untyped_to_variable_name(string)
38
22
 
39
23
 
40
24
  @typechecked
41
25
  def to_boolean(string: str) -> bool:
42
- if string.lower() in TRUE_STRS:
43
- return True
44
- if string.lower() in FALSE_STRS:
45
- return False
46
- raise Exception(f'Cannot infer boolean value from "{string}"')
26
+ return untyped_to_boolean(string)
47
27
 
48
28
 
49
29
  @typechecked
50
30
  def to_logging_level(logging_level_str: str) -> int:
51
- lower_logging_level_str = logging_level_str.lower()
52
- if lower_logging_level_str in LOGGING_LEVEL_MAP:
53
- return LOGGING_LEVEL_MAP[lower_logging_level_str]
54
- return logging.WARNING
31
+ return untyped_to_logging_level(logging_level_str)
@@ -1,6 +1,10 @@
1
+ from zrb.helper.accessories.color import colored
2
+ from zrb.helper.log import logger
1
3
  from zrb.helper.typecheck import typechecked
2
4
  from zrb.helper.typing import Any
3
5
 
6
+ logger.debug(colored("Loading zrb.helper.string.jinja", attrs=["dark"]))
7
+
4
8
 
5
9
  @typechecked
6
10
  def is_probably_jinja(value: Any) -> bool:
@@ -1,5 +1,9 @@
1
+ from zrb.helper.accessories.color import colored
2
+ from zrb.helper.log import logger
1
3
  from zrb.helper.typecheck import typechecked
2
4
 
5
+ logger.debug(colored("Loading zrb.helper.string.modification", attrs=["dark"]))
6
+
3
7
 
4
8
  @typechecked
5
9
  def double_quote(text: str) -> str: