tesorotools-python 0.0.0__py2.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 (38) hide show
  1. tesorotools/__init__.py +0 -0
  2. tesorotools/artists/__init__.py +5 -0
  3. tesorotools/artists/barh_plot.py +310 -0
  4. tesorotools/artists/line_plot.py +114 -0
  5. tesorotools/artists/table.py +199 -0
  6. tesorotools/artists/type_curve.py +216 -0
  7. tesorotools/convert.py +93 -0
  8. tesorotools/data_sources/__init__.py +0 -0
  9. tesorotools/data_sources/debug.py +26 -0
  10. tesorotools/data_sources/eikon.py +117 -0
  11. tesorotools/database/__init__.py +0 -0
  12. tesorotools/database/push.py +70 -0
  13. tesorotools/dependencies/__init__.py +0 -0
  14. tesorotools/dependencies/functions.py +11 -0
  15. tesorotools/dependencies/node.py +34 -0
  16. tesorotools/dependencies/resolution.py +118 -0
  17. tesorotools/main.py +37 -0
  18. tesorotools/offsets/__init__.py +0 -0
  19. tesorotools/offsets/offsets.py +439 -0
  20. tesorotools/offsets/outliers.py +15 -0
  21. tesorotools/render/__init__.py +11 -0
  22. tesorotools/render/content/__init__.py +0 -0
  23. tesorotools/render/content/content.py +17 -0
  24. tesorotools/render/content/images.py +147 -0
  25. tesorotools/render/content/section.py +53 -0
  26. tesorotools/render/content/table.py +283 -0
  27. tesorotools/render/headline.py +40 -0
  28. tesorotools/render/introduction.py +49 -0
  29. tesorotools/render/report.py +29 -0
  30. tesorotools/utils/__init__.py +0 -0
  31. tesorotools/utils/config.py +35 -0
  32. tesorotools/utils/globals.py +12 -0
  33. tesorotools/utils/matplotlib.py +38 -0
  34. tesorotools/utils/series.py +40 -0
  35. tesorotools/utils/template.py +126 -0
  36. tesorotools_python-0.0.0.dist-info/METADATA +13 -0
  37. tesorotools_python-0.0.0.dist-info/RECORD +38 -0
  38. tesorotools_python-0.0.0.dist-info/WHEEL +5 -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,13 @@
1
+ Metadata-Version: 2.4
2
+ Name: tesorotools-python
3
+ Version: 0.0.0
4
+ Requires-Dist: babel
5
+ Requires-Dist: eikon
6
+ Requires-Dist: matplotlib
7
+ Requires-Dist: openpyxl
8
+ Requires-Dist: pandas
9
+ Requires-Dist: psycopg2
10
+ Requires-Dist: pyarrow
11
+ Requires-Dist: python-docx
12
+ Requires-Dist: pyyaml
13
+ Requires-Dist: sqlalchemy
@@ -0,0 +1,38 @@
1
+ tesorotools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ tesorotools/convert.py,sha256=qk4N-AZpKlmTD9L9SG0E43jqW27DJTHTu_Y1wehvETQ,3334
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=3KkoT0DLkctzYNMV3Pz1EcAT9i29YGYSkTLTFNb3dv8,9461
6
+ tesorotools/artists/line_plot.py,sha256=BqOHnmVB6fL0ElN_WDpvCzP0L7O2-mp6ULfHo3qwiCI,3405
7
+ tesorotools/artists/table.py,sha256=CjyjWivn5YrNP5m8_eWi-ZA7R1ts3aIhATrYMEgTuOU,7651
8
+ tesorotools/artists/type_curve.py,sha256=VGFCCyMVNwjliLK9usyw_nLC6emKcJYOSV1pmWJQNXk,6463
9
+ tesorotools/data_sources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
+ tesorotools/data_sources/debug.py,sha256=fmUHt7f3dAd6qUBo5D_kTn__MgGC0hisdaC6sFXHKNg,877
11
+ tesorotools/data_sources/eikon.py,sha256=YCAyT4152QFks9m1B0LktprQe7lu4DOjGLkeN0CWG5o,3724
12
+ tesorotools/database/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
+ tesorotools/database/push.py,sha256=Y1ToNupMIdNfXcg20P0sFijXza05FUCB1OK53cPXYtU,1960
14
+ tesorotools/dependencies/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
+ tesorotools/dependencies/functions.py,sha256=URpIB2jQoPG4f15wmTWH5f5x855bAjg6ts2O5cWljEg,248
16
+ tesorotools/dependencies/node.py,sha256=DSLbfagWc1KfYrUhIY5KTcFy7Q4nNF2B2qHfgihIKbo,879
17
+ tesorotools/dependencies/resolution.py,sha256=Ctzzsm37YaJoyJQrbo9UcR0Sw6gw4xBnJOhTtAhLAbw,3660
18
+ tesorotools/offsets/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
+ tesorotools/offsets/offsets.py,sha256=h8hEoQ6KEsANlMqbCmSImdymllsjFgrBseKcB9gyMLQ,14068
20
+ tesorotools/offsets/outliers.py,sha256=37enrVwungs7KrNE7FYiPd-Eo3-5d9OHFeNXy6X7URo,415
21
+ tesorotools/render/__init__.py,sha256=XiuKC7mwvsXMTpPcInPaVnVdv2BzWwM-dcVY8dXhkjA,575
22
+ tesorotools/render/headline.py,sha256=haKi1g2BvjrbLDMfsn6BaHJjGqPDmwlqH9e3pb9nzCE,1264
23
+ tesorotools/render/introduction.py,sha256=uSeuOWiauLiX_hZYULFUiyw7JQwMHBIexr15-sW1ayA,1802
24
+ tesorotools/render/report.py,sha256=rdbgeO1Ol6TM2mUkJeaAiJht_8Fcc9ZT5K_qbOXgj2Q,885
25
+ tesorotools/render/content/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
+ tesorotools/render/content/content.py,sha256=m3USJXle5NctlQJs-d0tgSCvb-aNoCy2v7sZFqHZ1B8,409
27
+ tesorotools/render/content/images.py,sha256=C0Tkrud17MqH_doenn5H-917kT6XCUdCmNek9CZkEXc,5040
28
+ tesorotools/render/content/section.py,sha256=EugPBsb5mAWKRONAHQU-qCbKFQ419XU2vDJHQ0s_i3U,1682
29
+ tesorotools/render/content/table.py,sha256=WFH1AdgS7mYdj4WAa3j9CNjisiHW6XGhJiqUnaX23a0,9420
30
+ tesorotools/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
31
+ tesorotools/utils/config.py,sha256=TMD_6OB2RS2sjM17tYwFnOtcXZgIxs-Ec8FYA3Qokuc,1056
32
+ tesorotools/utils/globals.py,sha256=gFhNjCjeih7NaNEb6yjgoJbkTSUuJu9Xw5-UDtCPAQA,287
33
+ tesorotools/utils/matplotlib.py,sha256=tKidZIcDLKWgawIOJggWwVoaTMsrjw1WEJQouydSYbI,1197
34
+ tesorotools/utils/series.py,sha256=eUEUOdzDfA7YbgO4o6KtxwJOL5cQYdqLjrdvuQ7Hqhc,1168
35
+ tesorotools/utils/template.py,sha256=xpBVad28gG9ZLVwd9e0dTWsGsbujjmVcCPEW2mIKEJo,4917
36
+ tesorotools_python-0.0.0.dist-info/METADATA,sha256=Ir3_5KhM8UiG1NuFYi39Qxg-KDj50jkzIXGraTv_L-0,298
37
+ tesorotools_python-0.0.0.dist-info/WHEEL,sha256=tkmg4JIqwd9H8mL30xA7crRmoStyCtGp0VWshokd1Jc,105
38
+ tesorotools_python-0.0.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.27.0
3
+ Root-Is-Purelib: true
4
+ Tag: py2-none-any
5
+ Tag: py3-none-any