tukan-python 0.1.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 tukan-python might be problematic. Click here for more details.

@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 TukanMx
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,2 @@
1
+ # Exclude the entire tests directory from the package distribution
2
+ prune tests
@@ -0,0 +1,120 @@
1
+ Metadata-Version: 2.4
2
+ Name: tukan_python
3
+ Version: 0.1.0
4
+ Summary: A package to utilize the tukan API.
5
+ Author-email: roberto <roberto@tukanmx.com>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2021 TukanMx
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://github.com/TukanMx/tukan_python
29
+ Classifier: Programming Language :: Python :: 3
30
+ Classifier: Programming Language :: Python :: 3.12
31
+ Classifier: License :: OSI Approved :: MIT License
32
+ Classifier: Operating System :: OS Independent
33
+ Requires-Python: >=3.7
34
+ Description-Content-Type: text/markdown
35
+ License-File: LICENSE
36
+ Requires-Dist: loguru==0.7.2
37
+ Requires-Dist: numpy==1.26.1
38
+ Requires-Dist: pandas==2.1.1
39
+ Requires-Dist: pytest==7.4.2
40
+ Requires-Dist: python-dotenv==1.0.0
41
+ Requires-Dist: requests==2.31.0
42
+ Requires-Dist: tqdm==4.66.1
43
+ Dynamic: license-file
44
+
45
+ # tukan_python
46
+
47
+ A Python package to interact with the TukanMX API, retrieve table metadata, and build and execute queries with flexible filters, groupings, and aggregations.
48
+
49
+ ## Installation
50
+
51
+ Once the package is published to PyPI, install it using:
52
+
53
+ ```bash
54
+ pip install tukan_python
55
+ ```
56
+
57
+ ## Usage
58
+
59
+ ### Authentication
60
+
61
+ You need an API token to use the TukanMX API. You can provide it directly to the `Tukan` or `Query` classes, or set it as an environment variable:
62
+
63
+ ```bash
64
+ export API_TUKAN=your_api_token
65
+ ```
66
+
67
+ ### Main Classes
68
+
69
+ #### Tukan
70
+ Handles authentication and requests to the TukanMX API. Provides methods for retrieving tables, indicators, and metadata, as well as sending and receiving data.
71
+
72
+ ```python
73
+ from tukan_python.tukan import Tukan
74
+
75
+ tukan = Tukan(token="your_api_token")
76
+
77
+ # Retrieve metadata for a table
78
+ metadata = tukan.get_table_metadata("table_name")
79
+
80
+ # Retrieve a list of tables
81
+ all_tables = tukan.get_tables()
82
+
83
+ # Retrieve a list of indicators
84
+ indicators = tukan.get_indicators()
85
+ ```
86
+
87
+ #### Query
88
+ Helper class for building and executing queries against the TukanMX API. Supports filters, groupings, aggregations, and execution.
89
+
90
+ ```python
91
+ from tukan_python.query import Query
92
+
93
+ # Create a Query instance
94
+ query = Query("table_name", token="your_api_token")
95
+
96
+ # Add filters, groupings, or aggregations as needed
97
+ query.set_where([{ "reference": "column", "eq": "value" }])
98
+ query.set_group_by([{ "reference": "column" }])
99
+ query.set_aggregate([{ "indicator": "indicator_name", "operation": "sum" }])
100
+
101
+ # Execute the query
102
+ result = query.execute_query()
103
+ print(result["df"]) # result is a dict with 'indicators' and a pandas DataFrame
104
+ ```
105
+
106
+ #### Utility Functions
107
+
108
+ - `create_identity_query_for_table(table_name, language)`
109
+ - `create_identity_query_for_table_with_date_filters(table_name, language, from_date, to_date)`
110
+ - `create_query_from_query_id_or_name(query_id_or_name)`
111
+ - `create_query_from_payload(payload)`
112
+
113
+ These functions help build queries quickly from table names, IDs, or payloads.
114
+
115
+ ## License
116
+ See the `LICENSE` file for license information.
117
+
118
+ ---
119
+
120
+ For more details, see the code in `tukan_python/tukan.py` and `tukan_python/query.py`.
@@ -0,0 +1,76 @@
1
+ # tukan_python
2
+
3
+ A Python package to interact with the TukanMX API, retrieve table metadata, and build and execute queries with flexible filters, groupings, and aggregations.
4
+
5
+ ## Installation
6
+
7
+ Once the package is published to PyPI, install it using:
8
+
9
+ ```bash
10
+ pip install tukan_python
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ### Authentication
16
+
17
+ You need an API token to use the TukanMX API. You can provide it directly to the `Tukan` or `Query` classes, or set it as an environment variable:
18
+
19
+ ```bash
20
+ export API_TUKAN=your_api_token
21
+ ```
22
+
23
+ ### Main Classes
24
+
25
+ #### Tukan
26
+ Handles authentication and requests to the TukanMX API. Provides methods for retrieving tables, indicators, and metadata, as well as sending and receiving data.
27
+
28
+ ```python
29
+ from tukan_python.tukan import Tukan
30
+
31
+ tukan = Tukan(token="your_api_token")
32
+
33
+ # Retrieve metadata for a table
34
+ metadata = tukan.get_table_metadata("table_name")
35
+
36
+ # Retrieve a list of tables
37
+ all_tables = tukan.get_tables()
38
+
39
+ # Retrieve a list of indicators
40
+ indicators = tukan.get_indicators()
41
+ ```
42
+
43
+ #### Query
44
+ Helper class for building and executing queries against the TukanMX API. Supports filters, groupings, aggregations, and execution.
45
+
46
+ ```python
47
+ from tukan_python.query import Query
48
+
49
+ # Create a Query instance
50
+ query = Query("table_name", token="your_api_token")
51
+
52
+ # Add filters, groupings, or aggregations as needed
53
+ query.set_where([{ "reference": "column", "eq": "value" }])
54
+ query.set_group_by([{ "reference": "column" }])
55
+ query.set_aggregate([{ "indicator": "indicator_name", "operation": "sum" }])
56
+
57
+ # Execute the query
58
+ result = query.execute_query()
59
+ print(result["df"]) # result is a dict with 'indicators' and a pandas DataFrame
60
+ ```
61
+
62
+ #### Utility Functions
63
+
64
+ - `create_identity_query_for_table(table_name, language)`
65
+ - `create_identity_query_for_table_with_date_filters(table_name, language, from_date, to_date)`
66
+ - `create_query_from_query_id_or_name(query_id_or_name)`
67
+ - `create_query_from_payload(payload)`
68
+
69
+ These functions help build queries quickly from table names, IDs, or payloads.
70
+
71
+ ## License
72
+ See the `LICENSE` file for license information.
73
+
74
+ ---
75
+
76
+ For more details, see the code in `tukan_python/tukan.py` and `tukan_python/query.py`.
@@ -0,0 +1,32 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "tukan_python"
7
+ version = "0.1.0"
8
+ description = "A package to utilize the tukan API."
9
+ authors = [
10
+ { name="roberto", email="roberto@tukanmx.com" }
11
+ ]
12
+ readme = "README.md"
13
+ license = { file = "LICENSE" }
14
+ requires-python = ">=3.7"
15
+ dependencies = [
16
+ "loguru==0.7.2",
17
+ "numpy==1.26.1",
18
+ "pandas==2.1.1",
19
+ "pytest==7.4.2",
20
+ "python-dotenv==1.0.0",
21
+ "requests==2.31.0",
22
+ "tqdm==4.66.1"
23
+ ]
24
+ classifiers = [
25
+ "Programming Language :: Python :: 3",
26
+ "Programming Language :: Python :: 3.12",
27
+ "License :: OSI Approved :: MIT License",
28
+ "Operating System :: OS Independent",
29
+ ]
30
+
31
+ [project.urls]
32
+ Homepage = "https://github.com/TukanMx/tukan_python"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
File without changes