dyngle 0.4.3__tar.gz → 0.5.0__tar.gz

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.

Potentially problematic release.


This version of dyngle might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: dyngle
3
- Version: 0.4.3
3
+ Version: 0.5.0
4
4
  Summary: Run lightweight local workflows
5
5
  License: MIT
6
6
  Author: Steampunk Wizard
@@ -0,0 +1,58 @@
1
+ from functools import cached_property
2
+ from pathlib import Path
3
+ from wizlib.app import WizApp
4
+ from wizlib.stream_handler import StreamHandler
5
+ from wizlib.config_handler import ConfigHandler
6
+ from wizlib.ui_handler import UIHandler
7
+
8
+ from dyngle.command import DyngleCommand
9
+ from dyngle.error import DyngleError
10
+ from dyngle.expression import expression
11
+
12
+
13
+ class DyngleApp(WizApp):
14
+
15
+ base = DyngleCommand
16
+ name = 'dyngle'
17
+ handlers = [StreamHandler, ConfigHandler, UIHandler]
18
+
19
+ # For possible upstreaming to WizLib, a mechanism to "import" configuration
20
+ # settings from external files.
21
+
22
+ @property
23
+ def _imported_configrations(self):
24
+ if not hasattr(self, '__imported_configurations'):
25
+ imports = self.config.get('dyngle-imports')
26
+ confs = []
27
+ if imports:
28
+ for filename in imports:
29
+ full_filename = Path(filename).expanduser()
30
+ confs.append(ConfigHandler(full_filename))
31
+ self.__imported_configurations = confs
32
+ return self.__imported_configurations
33
+
34
+ def _get_configuration_details(self, type: str):
35
+ label = f'dyngle-{type}'
36
+ details = {}
37
+ for conf in self._imported_configrations:
38
+ if (imported_details := conf.get(label)):
39
+ details |= imported_details
40
+ configured_details = self.config.get(label)
41
+ if configured_details:
42
+ details |= configured_details
43
+ return details
44
+
45
+ @cached_property
46
+ def operations(self):
47
+ operations = self._get_configuration_details('operations')
48
+ if not operations:
49
+ raise DyngleError("No operations defined")
50
+ return operations
51
+
52
+ @cached_property
53
+ def expressions(self):
54
+ expr_texts = self._get_configuration_details('expressions')
55
+ if expr_texts:
56
+ return {k: expression(t) for k, t in expr_texts.items()}
57
+ else:
58
+ return {}
@@ -29,13 +29,13 @@ class RunCommand(DyngleCommand):
29
29
  if self.operation not in operations:
30
30
  available_operations = ', '.join(operations.keys())
31
31
  raise DyngleError(
32
- f'Operation "{self.operation}" not found. " + \
33
- f"Available operations: {available_operations}')
32
+ f"Operation '{self.operation}' not found. " +
33
+ f"Available operations: {available_operations}")
34
34
 
35
35
  @DyngleCommand.wrap
36
36
  def execute(self):
37
37
  expressions = self.app.expressions
38
- operations = self.app.config.get('dyngle-operations')
38
+ operations = self.app.operations
39
39
  self._validate_operation_exists(operations)
40
40
  steps = operations[self.operation]
41
41
  data_string = self.app.stream.text
@@ -8,7 +8,7 @@ description = "Run lightweight local workflows"
8
8
  authors = ["Steampunk Wizard <dyngle@steamwiz.io>"]
9
9
  license = "MIT"
10
10
  readme = "PACKAGE.md"
11
- version = "0.4.3"
11
+ version = "0.5.0"
12
12
 
13
13
  [tool.poetry.dependencies]
14
14
  python = "~3.11"
@@ -1,23 +0,0 @@
1
- from functools import cached_property
2
- from wizlib.app import WizApp
3
- from wizlib.stream_handler import StreamHandler
4
- from wizlib.config_handler import ConfigHandler
5
- from wizlib.ui_handler import UIHandler
6
-
7
- from dyngle.command import DyngleCommand
8
- from dyngle.expression import expression
9
-
10
-
11
- class DyngleApp(WizApp):
12
-
13
- base = DyngleCommand
14
- name = 'dyngle'
15
- handlers = [StreamHandler, ConfigHandler, UIHandler]
16
-
17
- @cached_property
18
- def expressions(self):
19
- expr_texts = self.config.get('dyngle-expressions')
20
- if expr_texts:
21
- return {k: expression(t) for k, t in expr_texts.items()}
22
- else:
23
- return {}
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes