holado 0.2.3__py3-none-any.whl → 0.2.4__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.

Potentially problematic release.


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

@@ -1,128 +1,128 @@
1
-
2
- #################################################
3
- # HolAdo (Holistic Automation do)
4
- #
5
- # (C) Copyright 2021-2025 by Eric Klumpp
6
- #
7
- # Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8
- #
9
- # The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10
-
11
- # The Software is provided “as is”, without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the Software.
12
- #################################################
13
-
14
- import logging
15
-
16
-
17
- # logger = logging.getLogger(__name__)
18
-
19
-
20
- class LogConfig(object):
21
- TLogger = None
22
- TManager = None
23
- default_level = logging.INFO
24
-
25
- @classmethod
26
- def configure(cls, initialize_logging=True, log_level=None):
27
- # HolAdo needs at least to add logging level TRACE and PRINT
28
- cls.add_logging_level_trace()
29
- cls.add_logging_level_print()
30
-
31
- if log_level:
32
- if isinstance(log_level, str):
33
- cls.default_level = logging._nameToLevel[log_level]
34
- else:
35
- cls.default_level = log_level
36
-
37
- if initialize_logging:
38
- from holado_logging.common.logging.holado_logger import HALogger
39
-
40
- HALogger.default_message_size_limit = 10000
41
- cls.TLogger = HALogger
42
- cls.TManager = logging.Manager
43
-
44
- # Configure logging
45
- cls.configure_logging()
46
-
47
- @classmethod
48
- def configure_logging(cls):
49
- #TODO EKL: make loggers configuration optional
50
- # Configure loggers
51
- from holado_logging.common.logging.holado_logger import TestRootLogger
52
- logging.root = TestRootLogger(cls.default_level)
53
- logging.Logger.root = logging.root
54
- logging.Logger.manager = cls.TManager(cls.TLogger.root)
55
-
56
- logging.setLoggerClass(cls.TLogger)
57
-
58
-
59
- @classmethod
60
- def add_logging_level_print(cls):
61
- if not cls.has_logging_level("PRINT"):
62
- cls.add_logging_level("PRINT", 45, None)
63
-
64
- @classmethod
65
- def add_logging_level_trace(cls):
66
- if not cls.has_logging_level("TRACE"):
67
- cls.add_logging_level("TRACE", 5, None)
68
-
69
-
70
- @classmethod
71
- def has_logging_level(cls, levelName):
72
- return hasattr(logging, levelName)
73
-
74
- @classmethod
75
- def add_logging_level(cls, levelName, levelNum, methodName=None):
76
- """
77
- This method was implemented and shared by the author of library haggis (https://haggis.readthedocs.io).
78
-
79
- Comprehensively adds a new logging level to the `logging` module and the
80
- currently configured logging class.
81
-
82
- `levelName` becomes an attribute of the `logging` module with the value
83
- `levelNum`. `methodName` becomes a convenience method for both `logging`
84
- itself and the class returned by `logging.getLoggerClass()` (usually just
85
- `logging.Logger`). If `methodName` is not specified, `levelName.lower()` is
86
- used.
87
-
88
- To avoid accidental clobberings of existing attributes, this method will
89
- raise an `AttributeError` if the level name is already an attribute of the
90
- `logging` module or if the method name is already present
91
-
92
- Example
93
- -------
94
- >>> addLoggingLevel('TRACE', logging.DEBUG - 5)
95
- >>> logging.getLogger(__name__).setLevel("TRACE")
96
- >>> logging.getLogger(__name__).trace('that worked')
97
- >>> logging.trace('so did this')
98
- >>> logging.TRACE
99
- 5
100
-
101
- """
102
- if not methodName:
103
- methodName = levelName.lower()
104
-
105
- if hasattr(logging, levelName):
106
- raise AttributeError('{} already defined in logging module'.format(levelName))
107
- if hasattr(logging, methodName):
108
- raise AttributeError('{} already defined in logging module'.format(methodName))
109
- if hasattr(logging.getLoggerClass(), methodName):
110
- raise AttributeError('{} already defined in logger class'.format(methodName))
111
-
112
- # This method was inspired by the answers to Stack Overflow post
113
- # http://stackoverflow.com/q/2183233/2988730, especially
114
- # http://stackoverflow.com/a/13638084/2988730
115
- def logForLevel(self, message, *args, **kwargs):
116
- if self.isEnabledFor(levelNum):
117
- self._log(levelNum, message, args, **kwargs)
118
- def logToRoot(message, *args, **kwargs):
119
- logging.log(levelNum, message, *args, **kwargs)
120
-
121
- logging.addLevelName(levelNum, levelName)
122
- setattr(logging, levelName, levelNum)
123
- setattr(logging.getLoggerClass(), methodName, logForLevel)
124
- setattr(logging, methodName, logToRoot)
125
-
126
-
127
-
1
+
2
+ #################################################
3
+ # HolAdo (Holistic Automation do)
4
+ #
5
+ # (C) Copyright 2021-2025 by Eric Klumpp
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8
+ #
9
+ # The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10
+
11
+ # The Software is provided “as is”, without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the Software.
12
+ #################################################
13
+
14
+ import logging
15
+
16
+
17
+ # logger = logging.getLogger(__name__)
18
+
19
+
20
+ class LogConfig(object):
21
+ TLogger = None
22
+ TManager = None
23
+ default_level = logging.INFO
24
+
25
+ @classmethod
26
+ def configure(cls, initialize_logging=True, log_level=None):
27
+ # HolAdo needs at least to add logging level TRACE and PRINT
28
+ cls.add_logging_level_trace()
29
+ cls.add_logging_level_print()
30
+
31
+ if log_level:
32
+ if isinstance(log_level, str):
33
+ cls.default_level = logging._nameToLevel[log_level]
34
+ else:
35
+ cls.default_level = log_level
36
+
37
+ if initialize_logging:
38
+ from holado_logging.common.logging.holado_logger import HALogger
39
+
40
+ HALogger.default_message_size_limit = 10000
41
+ cls.TLogger = HALogger
42
+ cls.TManager = logging.Manager
43
+
44
+ # Configure logging
45
+ cls.configure_logging()
46
+
47
+ @classmethod
48
+ def configure_logging(cls):
49
+ #TODO EKL: make loggers configuration optional
50
+ # Configure loggers
51
+ from holado_logging.common.logging.holado_logger import TestRootLogger
52
+ logging.root = TestRootLogger(cls.default_level)
53
+ logging.Logger.root = logging.root
54
+ logging.Logger.manager = cls.TManager(cls.TLogger.root)
55
+
56
+ logging.setLoggerClass(cls.TLogger)
57
+
58
+
59
+ @classmethod
60
+ def add_logging_level_print(cls):
61
+ if not cls.has_logging_level("PRINT"):
62
+ cls.add_logging_level("PRINT", 45, None)
63
+
64
+ @classmethod
65
+ def add_logging_level_trace(cls):
66
+ if not cls.has_logging_level("TRACE"):
67
+ cls.add_logging_level("TRACE", 5, None)
68
+
69
+
70
+ @classmethod
71
+ def has_logging_level(cls, levelName):
72
+ return hasattr(logging, levelName)
73
+
74
+ @classmethod
75
+ def add_logging_level(cls, levelName, levelNum, methodName=None):
76
+ """
77
+ This method was implemented and shared by the author of library haggis (https://haggis.readthedocs.io).
78
+
79
+ Comprehensively adds a new logging level to the `logging` module and the
80
+ currently configured logging class.
81
+
82
+ `levelName` becomes an attribute of the `logging` module with the value
83
+ `levelNum`. `methodName` becomes a convenience method for both `logging`
84
+ itself and the class returned by `logging.getLoggerClass()` (usually just
85
+ `logging.Logger`). If `methodName` is not specified, `levelName.lower()` is
86
+ used.
87
+
88
+ To avoid accidental clobberings of existing attributes, this method will
89
+ raise an `AttributeError` if the level name is already an attribute of the
90
+ `logging` module or if the method name is already present
91
+
92
+ Example
93
+ -------
94
+ >>> addLoggingLevel('TRACE', logging.DEBUG - 5)
95
+ >>> logging.getLogger(__name__).setLevel("TRACE")
96
+ >>> logging.getLogger(__name__).trace('that worked')
97
+ >>> logging.trace('so did this')
98
+ >>> logging.TRACE
99
+ 5
100
+
101
+ """
102
+ if not methodName:
103
+ methodName = levelName.lower()
104
+
105
+ if hasattr(logging, levelName):
106
+ raise AttributeError('{} already defined in logging module'.format(levelName))
107
+ if hasattr(logging, methodName):
108
+ raise AttributeError('{} already defined in logging module'.format(methodName))
109
+ if hasattr(logging.getLoggerClass(), methodName):
110
+ raise AttributeError('{} already defined in logger class'.format(methodName))
111
+
112
+ # This method was inspired by the answers to Stack Overflow post
113
+ # http://stackoverflow.com/q/2183233/2988730, especially
114
+ # http://stackoverflow.com/a/13638084/2988730
115
+ def logForLevel(self, message, *args, **kwargs):
116
+ if self.isEnabledFor(levelNum):
117
+ self._log(levelNum, message, args, **kwargs)
118
+ def logToRoot(message, *args, **kwargs):
119
+ logging.log(levelNum, message, *args, **kwargs)
120
+
121
+ logging.addLevelName(levelNum, levelName)
122
+ setattr(logging, levelName, levelNum)
123
+ setattr(logging.getLoggerClass(), methodName, logForLevel)
124
+ setattr(logging, methodName, logToRoot)
125
+
126
+
127
+
128
128
 
@@ -19,7 +19,6 @@ def dependencies():
19
19
 
20
20
  def register():
21
21
  from holado.common.context.session_context import SessionContext
22
- from holado_protobuf.ipc.protobuf.types.google.protobuf import Timestamp
23
22
  from holado_python.common.tools.comparators.datetime_comparator import DatetimeComparator
24
23
  from holado_python.common.tools.datetime import DateTime
25
24
 
@@ -51,6 +50,7 @@ def register():
51
50
 
52
51
  # Register datetime conversion
53
52
 
53
+ from holado_protobuf.ipc.protobuf.types.google.protobuf import Timestamp
54
54
  DatetimeComparator.register_resource_for_type_in_class('protobuf.Timestamp', None,
55
55
  lambda o: isinstance(o, Timestamp.protobuf_class()),
56
56
  lambda o: DateTime.seconds_nanos_to_datetime(o.seconds, o.nanos),