tesorotools-python 0.0.18__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.
- tesorotools/__init__.py +6 -0
- tesorotools/artists/__init__.py +5 -0
- tesorotools/artists/barh_plot.py +310 -0
- tesorotools/artists/line_plot.py +245 -0
- tesorotools/artists/table.py +200 -0
- tesorotools/artists/type_curve.py +218 -0
- tesorotools/assets/README.md +5 -0
- tesorotools/assets/fonts/CabinetGrotesk-Black.otf +0 -0
- tesorotools/assets/fonts/CabinetGrotesk-Bold.otf +0 -0
- tesorotools/assets/fonts/CabinetGrotesk-Extrabold.otf +0 -0
- tesorotools/assets/fonts/CabinetGrotesk-Extralight.otf +0 -0
- tesorotools/assets/fonts/CabinetGrotesk-Light.otf +0 -0
- tesorotools/assets/fonts/CabinetGrotesk-Medium.otf +0 -0
- tesorotools/assets/fonts/CabinetGrotesk-Regular.otf +0 -0
- tesorotools/assets/fonts/CabinetGrotesk-Thin.otf +0 -0
- tesorotools/assets/fonts/README.md +1 -0
- tesorotools/assets/plots.yaml +43 -0
- tesorotools/assets/tesoro.mplstyle +21 -0
- tesorotools/convert.py +99 -0
- tesorotools/data_sources/README.md +14 -0
- tesorotools/data_sources/__init__.py +0 -0
- tesorotools/data_sources/debug.py +26 -0
- tesorotools/data_sources/lseg.py +117 -0
- tesorotools/database/__init__.py +0 -0
- tesorotools/database/push.py +70 -0
- tesorotools/dependencies/__init__.py +0 -0
- tesorotools/dependencies/functions.py +11 -0
- tesorotools/dependencies/node.py +34 -0
- tesorotools/dependencies/resolution.py +118 -0
- tesorotools/main.py +37 -0
- tesorotools/offsets/__init__.py +0 -0
- tesorotools/offsets/offsets.py +439 -0
- tesorotools/offsets/outliers.py +15 -0
- tesorotools/render/__init__.py +17 -0
- tesorotools/render/content/__init__.py +0 -0
- tesorotools/render/content/content.py +17 -0
- tesorotools/render/content/images.py +147 -0
- tesorotools/render/content/section.py +53 -0
- tesorotools/render/content/subtitle.py +53 -0
- tesorotools/render/content/table.py +308 -0
- tesorotools/render/content/text.py +23 -0
- tesorotools/render/content/title.py +40 -0
- tesorotools/render/report.py +31 -0
- tesorotools/utils/__init__.py +0 -0
- tesorotools/utils/config.py +35 -0
- tesorotools/utils/globals.py +14 -0
- tesorotools/utils/matplotlib.py +38 -0
- tesorotools/utils/series.py +40 -0
- tesorotools/utils/shortcuts.py +32 -0
- tesorotools/utils/template.py +126 -0
- tesorotools_python-0.0.18.dist-info/METADATA +16 -0
- tesorotools_python-0.0.18.dist-info/RECORD +53 -0
- tesorotools_python-0.0.18.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Please, read this to get used to (and understand) the jargon used in the code of this module.
|
|
3
|
+
|
|
4
|
+
Custom utilities for reading `.yaml` files, specifically, report templates
|
|
5
|
+
|
|
6
|
+
- A `.yaml` file is represented internally as a `MappingNode` *object*
|
|
7
|
+
- A `MappingNode` has a `value` *attribute*, that is a **list of 2-tuples**
|
|
8
|
+
- Each tuple on the list is composed by two `Node` *objects*.
|
|
9
|
+
- A `MappingNode` is a *subclass* of a `Node` by the way.
|
|
10
|
+
- Another subclass of of `Node` is `ScalarNode`, more about that later.
|
|
11
|
+
- The first `Node` of the tuple is called *key node*.
|
|
12
|
+
- The second `Node` of the tuple is called *value node*.
|
|
13
|
+
|
|
14
|
+
Example:
|
|
15
|
+
|
|
16
|
+
Given this yaml document snippet
|
|
17
|
+
|
|
18
|
+
```yaml
|
|
19
|
+
key1: "value1"
|
|
20
|
+
key2: !custom_tag
|
|
21
|
+
subkey: "subvalue"
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
It will be represented as a `MappingNode` whose `value` attribute will be a list of length 2 like the following
|
|
25
|
+
|
|
26
|
+
- (`key_node1`, `value_node1`)
|
|
27
|
+
- (`key_node2`, `value_node2`)
|
|
28
|
+
|
|
29
|
+
Let's analyze it:
|
|
30
|
+
|
|
31
|
+
- `key_node1` is a `ScalarNode` object, which has a `value` attribute of "key1" and and *implicit* `tag` attribute indicating it is a string. `value_node1` is similar, but with a `value` of "value1"
|
|
32
|
+
|
|
33
|
+
- `key_node2` is similar to the previously analyzed nodes, but `value_node2` is, instead of a `ScalarNode`, another `MappingNode`.
|
|
34
|
+
- This `MappingNode` object has an *explicit* and *custom* `tag` attribute called "!custom_tag". It is customary to name custom tags starting with "!".
|
|
35
|
+
- The `value` attribute is a list of length 1 containing a tuple of `ScalarNodes` as the previously analyzed.
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
from collections.abc import Hashable
|
|
39
|
+
from io import TextIOWrapper as _ReadStream
|
|
40
|
+
from pathlib import Path
|
|
41
|
+
from typing import Any
|
|
42
|
+
|
|
43
|
+
import yaml
|
|
44
|
+
from yaml.nodes import MappingNode, Node, ScalarNode
|
|
45
|
+
|
|
46
|
+
# implicit tag for string `ScalarNode`
|
|
47
|
+
STR_TAG = "tag:yaml.org,2002:str"
|
|
48
|
+
|
|
49
|
+
type NodeContents = list[tuple[Node, Node]]
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def _to_mapping_node(scalar_node: ScalarNode) -> MappingNode:
|
|
53
|
+
return MappingNode(tag=scalar_node.tag, value=[])
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class TemplateLoader(yaml.FullLoader):
|
|
57
|
+
"""This is a custom `.yaml` file loader to make our life easier when reading report templates."""
|
|
58
|
+
|
|
59
|
+
def __init__(self, stream: _ReadStream):
|
|
60
|
+
"""Remember the path of the file it is reading"""
|
|
61
|
+
super().__init__(stream)
|
|
62
|
+
self._path: Path = Path(stream.name).parent
|
|
63
|
+
|
|
64
|
+
def construct_mapping(
|
|
65
|
+
self, node: MappingNode, deep: bool = False
|
|
66
|
+
) -> dict[Hashable, Any]:
|
|
67
|
+
"""
|
|
68
|
+
This function it is not meant to be called directly by us, it will usually be called indirectly by code such as `yaml.load(file, Loader=loader)`.
|
|
69
|
+
|
|
70
|
+
For each `MappingNode` with a custom tag in the `.yaml` file, insert an additional tuple in its `value` attribute with an "id" string `ScalarNode` as *key node* and the same value as its associated *key node*.
|
|
71
|
+
|
|
72
|
+
For example, `.yaml` file
|
|
73
|
+
|
|
74
|
+
```yaml
|
|
75
|
+
key: !custom_tag
|
|
76
|
+
subkey: "subvalue"
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
will be transformed to:
|
|
80
|
+
|
|
81
|
+
```yaml
|
|
82
|
+
key: !custom_tag
|
|
83
|
+
id: key
|
|
84
|
+
subkey: "subvalue"
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Parameters
|
|
88
|
+
----------
|
|
89
|
+
node : MappingNode
|
|
90
|
+
Current `MappingNode` being parsed.
|
|
91
|
+
deep : bool, optional
|
|
92
|
+
Controls if all the child nodes should be built recursively or only shallowly, by default False
|
|
93
|
+
|
|
94
|
+
Returns
|
|
95
|
+
-------
|
|
96
|
+
dict[Hashable, Any]
|
|
97
|
+
Result dictionary
|
|
98
|
+
"""
|
|
99
|
+
mapping: dict[Hashable, Any] = {}
|
|
100
|
+
node_contents: NodeContents = node.value
|
|
101
|
+
|
|
102
|
+
for subkey_node, subvalue_node in node_contents:
|
|
103
|
+
subkey: str = self.construct_object(subkey_node, deep=deep)
|
|
104
|
+
if subvalue_node.tag.startswith("!"):
|
|
105
|
+
if isinstance(subvalue_node, ScalarNode):
|
|
106
|
+
subvalue_node = _to_mapping_node(subvalue_node)
|
|
107
|
+
id_name = ScalarNode(tag=STR_TAG, value="id")
|
|
108
|
+
id_value = ScalarNode(tag=STR_TAG, value=str(subkey))
|
|
109
|
+
subcontents: NodeContents = subvalue_node.value
|
|
110
|
+
subcontents.insert(0, (id_name, id_value))
|
|
111
|
+
value = self.construct_object(subvalue_node, deep=deep)
|
|
112
|
+
mapping[subkey] = value
|
|
113
|
+
|
|
114
|
+
# artificial imports of other `.yaml` files
|
|
115
|
+
if subkey == "imports":
|
|
116
|
+
imports: NodeContents = subvalue_node.value
|
|
117
|
+
self.imports = {}
|
|
118
|
+
for asset_key_node, asset_path_node in imports:
|
|
119
|
+
asset_key: str = self.construct_object(
|
|
120
|
+
asset_key_node, deep=deep
|
|
121
|
+
)
|
|
122
|
+
asset_path: Path = Path(
|
|
123
|
+
self.construct_object(asset_path_node, deep=deep)
|
|
124
|
+
)
|
|
125
|
+
self.imports[asset_key] = self._path / asset_path
|
|
126
|
+
return mapping
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tesorotools-python
|
|
3
|
+
Version: 0.0.18
|
|
4
|
+
Requires-Python: >=3.13
|
|
5
|
+
Requires-Dist: babel
|
|
6
|
+
Requires-Dist: eikon
|
|
7
|
+
Requires-Dist: lseg-data
|
|
8
|
+
Requires-Dist: matplotlib
|
|
9
|
+
Requires-Dist: openpyxl
|
|
10
|
+
Requires-Dist: pandas
|
|
11
|
+
Requires-Dist: psycopg2
|
|
12
|
+
Requires-Dist: pyarrow
|
|
13
|
+
Requires-Dist: python-docx
|
|
14
|
+
Requires-Dist: pywin32>=311; sys_platform != 'linux'
|
|
15
|
+
Requires-Dist: pyyaml
|
|
16
|
+
Requires-Dist: sqlalchemy
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
tesorotools/__init__.py,sha256=rkjAQCbiNmcFq9qlYUZFEOhPGXd5ISqS2PSfu1V1khQ,311
|
|
2
|
+
tesorotools/convert.py,sha256=b20V7xkcLcZIzNLTdWb9Y9jQe7byLmyZhVhr1S5mjqg,3489
|
|
3
|
+
tesorotools/main.py,sha256=ZxDyqBD_0zlfcdTZp84UPxlK3_O-9xfexDjLJVu4L5U,1357
|
|
4
|
+
tesorotools/artists/__init__.py,sha256=exObsPqXdP6IaRn4QPkLRXUN67iOPNXtDgDAOoMxJoA,105
|
|
5
|
+
tesorotools/artists/barh_plot.py,sha256=9B-A5KBkgCwL_9pOd_H-TgGQeOFH7A34CWKlifE-tLY,9465
|
|
6
|
+
tesorotools/artists/line_plot.py,sha256=nenvSACy56d1bq6SIiRx3iZquApkdr0hrUFd0jctKSI,7571
|
|
7
|
+
tesorotools/artists/table.py,sha256=tbPmpgn3Uo9UyYF4AsncItyglpRhC0TJInTOh8a712c,7672
|
|
8
|
+
tesorotools/artists/type_curve.py,sha256=klH90WayhQpVB3XqRYdBRSsjdf_q-0quXx_pfDsIiIg,6475
|
|
9
|
+
tesorotools/assets/README.md,sha256=pB77vD_MvE26ftVNcZuj3iS0y-6g-WzqHb5OScDkQ3I,289
|
|
10
|
+
tesorotools/assets/plots.yaml,sha256=O-6bFprWFNHJgMr-ehl_TPkDvr48XwK8V9k7CxL__ts,578
|
|
11
|
+
tesorotools/assets/tesoro.mplstyle,sha256=aDzJRln2EA7U-1yo_yHoAHikntEdpFSFTIvKJczN8To,477
|
|
12
|
+
tesorotools/assets/fonts/CabinetGrotesk-Black.otf,sha256=b7M_yFxz5IcGtmWWPMzLVkfx4RLhVALQDFeoq4T1YD0,37728
|
|
13
|
+
tesorotools/assets/fonts/CabinetGrotesk-Bold.otf,sha256=86oM6a9QVAjZoEIFFcbCbcIVEwtWrMBX0ks7_CzaKS4,38148
|
|
14
|
+
tesorotools/assets/fonts/CabinetGrotesk-Extrabold.otf,sha256=RmIwkz382lhAbMO72z4_u4jGIYghaBVlzYiO_Baxs4k,38392
|
|
15
|
+
tesorotools/assets/fonts/CabinetGrotesk-Extralight.otf,sha256=LCirXimxHxAnI5bKloiSXoFuQ8shqbX50fnx6QJ3AMo,38004
|
|
16
|
+
tesorotools/assets/fonts/CabinetGrotesk-Light.otf,sha256=MXsLPzs4QIYWWdUfxgtvgXBimlk9N_-z5P2HXB_chUw,37832
|
|
17
|
+
tesorotools/assets/fonts/CabinetGrotesk-Medium.otf,sha256=WfAWF9hgkNkk7xxl1545AsrZGa-zBAFzr_sxMUEYsPM,37812
|
|
18
|
+
tesorotools/assets/fonts/CabinetGrotesk-Regular.otf,sha256=iTJYvBNtfsdIczP6RRH3xXlPatfHfu4kN4gcbfmFwLE,37968
|
|
19
|
+
tesorotools/assets/fonts/CabinetGrotesk-Thin.otf,sha256=j_pm5xeEmBU3ikvKEQGPQY2FeN6Ee7DXeBuvlFOYmFw,37296
|
|
20
|
+
tesorotools/assets/fonts/README.md,sha256=o58YkAtgrA9fDmH6ZyYrBEDcwo78050N-yS7UdErN-A,71
|
|
21
|
+
tesorotools/data_sources/README.md,sha256=iMAeLsv9Xk3IogDh8nCt2pSeTqCHmXA66KPvV25Za7I,261
|
|
22
|
+
tesorotools/data_sources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
23
|
+
tesorotools/data_sources/debug.py,sha256=fmUHt7f3dAd6qUBo5D_kTn__MgGC0hisdaC6sFXHKNg,877
|
|
24
|
+
tesorotools/data_sources/lseg.py,sha256=-WEbtwkU6xSUrPjXXMvCjjCC28Wxqt5IOQ44_0fn6JI,3774
|
|
25
|
+
tesorotools/database/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
26
|
+
tesorotools/database/push.py,sha256=Y1ToNupMIdNfXcg20P0sFijXza05FUCB1OK53cPXYtU,1960
|
|
27
|
+
tesorotools/dependencies/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
28
|
+
tesorotools/dependencies/functions.py,sha256=URpIB2jQoPG4f15wmTWH5f5x855bAjg6ts2O5cWljEg,248
|
|
29
|
+
tesorotools/dependencies/node.py,sha256=DSLbfagWc1KfYrUhIY5KTcFy7Q4nNF2B2qHfgihIKbo,879
|
|
30
|
+
tesorotools/dependencies/resolution.py,sha256=Ctzzsm37YaJoyJQrbo9UcR0Sw6gw4xBnJOhTtAhLAbw,3660
|
|
31
|
+
tesorotools/offsets/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
32
|
+
tesorotools/offsets/offsets.py,sha256=h8hEoQ6KEsANlMqbCmSImdymllsjFgrBseKcB9gyMLQ,14068
|
|
33
|
+
tesorotools/offsets/outliers.py,sha256=37enrVwungs7KrNE7FYiPd-Eo3-5d9OHFeNXy6X7URo,415
|
|
34
|
+
tesorotools/render/__init__.py,sha256=ke90t_ZY49n8qVgKSnVjqQ02c29_8mUYt_SaPoX_U70,916
|
|
35
|
+
tesorotools/render/report.py,sha256=vRIzGMkkjjfnQIF7B62YZkoJJs49W3w1TNMaIuUQQy0,989
|
|
36
|
+
tesorotools/render/content/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
37
|
+
tesorotools/render/content/content.py,sha256=m3USJXle5NctlQJs-d0tgSCvb-aNoCy2v7sZFqHZ1B8,409
|
|
38
|
+
tesorotools/render/content/images.py,sha256=C0Tkrud17MqH_doenn5H-917kT6XCUdCmNek9CZkEXc,5040
|
|
39
|
+
tesorotools/render/content/section.py,sha256=EugPBsb5mAWKRONAHQU-qCbKFQ419XU2vDJHQ0s_i3U,1682
|
|
40
|
+
tesorotools/render/content/subtitle.py,sha256=OLWdq1yXG94bEKCoH4IwN9C9SaYyTesTOO34e6fWJ1c,1966
|
|
41
|
+
tesorotools/render/content/table.py,sha256=onBFo-7NceA-CdBtNs3BXst6a1msbAFkPsYFIQEmQ5U,10352
|
|
42
|
+
tesorotools/render/content/text.py,sha256=g3VdYxXe1GHF1IjmFrHdfjgC9CzWWMwWmgHxifToIqM,678
|
|
43
|
+
tesorotools/render/content/title.py,sha256=hu4b-o8iBXpsIA-nZjYaQNfUE2Sq5-QvHYPP19RXB3o,1345
|
|
44
|
+
tesorotools/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
45
|
+
tesorotools/utils/config.py,sha256=TMD_6OB2RS2sjM17tYwFnOtcXZgIxs-Ec8FYA3Qokuc,1056
|
|
46
|
+
tesorotools/utils/globals.py,sha256=c5PBpZwpVO_nOetxyIk8j32Vx3GFlsgdYbwwfSSlv1M,374
|
|
47
|
+
tesorotools/utils/matplotlib.py,sha256=tKidZIcDLKWgawIOJggWwVoaTMsrjw1WEJQouydSYbI,1197
|
|
48
|
+
tesorotools/utils/series.py,sha256=eUEUOdzDfA7YbgO4o6KtxwJOL5cQYdqLjrdvuQ7Hqhc,1168
|
|
49
|
+
tesorotools/utils/shortcuts.py,sha256=U4HMRae82h5A765mISIHbg3ewGaGr99HGN3Wf4KquTs,874
|
|
50
|
+
tesorotools/utils/template.py,sha256=xpBVad28gG9ZLVwd9e0dTWsGsbujjmVcCPEW2mIKEJo,4917
|
|
51
|
+
tesorotools_python-0.0.18.dist-info/METADATA,sha256=zk5gBOE_TysgcorrWMck1ZQvD27ZSv6xZbJCkQ1At4Q,401
|
|
52
|
+
tesorotools_python-0.0.18.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
53
|
+
tesorotools_python-0.0.18.dist-info/RECORD,,
|