pxwebpy 0.3.0__tar.gz → 0.3.1__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.
- {pxwebpy-0.3.0 → pxwebpy-0.3.1}/.github/workflows/ci.yml +1 -1
- {pxwebpy-0.3.0 → pxwebpy-0.3.1}/.github/workflows/release.yml +1 -1
- {pxwebpy-0.3.0 → pxwebpy-0.3.1}/PKG-INFO +1 -1
- {pxwebpy-0.3.0 → pxwebpy-0.3.1}/pyproject.toml +1 -1
- {pxwebpy-0.3.0 → pxwebpy-0.3.1}/requirements-dev.lock +18 -17
- {pxwebpy-0.3.0 → pxwebpy-0.3.1}/requirements.lock +4 -3
- {pxwebpy-0.3.0 → pxwebpy-0.3.1}/src/pxwebpy/table.py +53 -11
- {pxwebpy-0.3.0 → pxwebpy-0.3.1}/.gitignore +0 -0
- {pxwebpy-0.3.0 → pxwebpy-0.3.1}/.python-version +0 -0
- {pxwebpy-0.3.0 → pxwebpy-0.3.1}/LICENSE +0 -0
- {pxwebpy-0.3.0 → pxwebpy-0.3.1}/README.md +0 -0
- {pxwebpy-0.3.0 → pxwebpy-0.3.1}/examples/example.py +0 -0
- {pxwebpy-0.3.0 → pxwebpy-0.3.1}/examples/example_query.json +0 -0
- {pxwebpy-0.3.0 → pxwebpy-0.3.1}/src/pxwebpy/__init__.py +0 -0
- {pxwebpy-0.3.0 → pxwebpy-0.3.1}/tests/invalid_query.json +0 -0
- {pxwebpy-0.3.0 → pxwebpy-0.3.1}/tests/mock/response_fi.json +0 -0
- {pxwebpy-0.3.0 → pxwebpy-0.3.1}/tests/mock/response_gl.json +0 -0
- {pxwebpy-0.3.0 → pxwebpy-0.3.1}/tests/mock/response_no.json +0 -0
- {pxwebpy-0.3.0 → pxwebpy-0.3.1}/tests/mock/response_table_variables.json +0 -0
- {pxwebpy-0.3.0 → pxwebpy-0.3.1}/tests/mock/result_fi.json +0 -0
- {pxwebpy-0.3.0 → pxwebpy-0.3.1}/tests/mock/result_gl.json +0 -0
- {pxwebpy-0.3.0 → pxwebpy-0.3.1}/tests/mock/result_no.json +0 -0
- {pxwebpy-0.3.0 → pxwebpy-0.3.1}/tests/queries.json +0 -0
- {pxwebpy-0.3.0 → pxwebpy-0.3.1}/tests/test_table.py +0 -0
- {pxwebpy-0.3.0 → pxwebpy-0.3.1}/tests/valid_query.json +0 -0
|
@@ -20,7 +20,7 @@ jobs:
|
|
|
20
20
|
|
|
21
21
|
- name: Install and setup rye
|
|
22
22
|
run: |
|
|
23
|
-
curl -sSf https://rye.astral.sh/get | RYE_VERSION="0.
|
|
23
|
+
curl -sSf https://rye.astral.sh/get | RYE_VERSION="0.37.0" RYE_TOOLCHAIN_VERSION="${{ matrix.python-version }}" RYE_INSTALL_OPTION="--yes" bash
|
|
24
24
|
echo "$HOME/.rye/shims" >> $GITHUB_PATH
|
|
25
25
|
|
|
26
26
|
- name: Pin ${{ matrix.python-version }}
|
|
@@ -16,7 +16,7 @@ jobs:
|
|
|
16
16
|
- name: Install and setup rye
|
|
17
17
|
run: |
|
|
18
18
|
python_version=$(cat .python-version)
|
|
19
|
-
curl -sSf https://rye.astral.sh/get | RYE_VERSION="0.
|
|
19
|
+
curl -sSf https://rye.astral.sh/get | RYE_VERSION="0.37.0" RYE_TOOLCHAIN_VERSION="$python_version" RYE_INSTALL_OPTION="--yes" bash
|
|
20
20
|
echo "$HOME/.rye/shims" >> $GITHUB_PATH
|
|
21
21
|
|
|
22
22
|
- name: Build for distribution
|
|
@@ -7,17 +7,18 @@
|
|
|
7
7
|
# all-features: false
|
|
8
8
|
# with-sources: false
|
|
9
9
|
# generate-hashes: false
|
|
10
|
+
# universal: false
|
|
10
11
|
|
|
11
12
|
-e file:.
|
|
12
13
|
asttokens==2.4.1
|
|
13
14
|
# via stack-data
|
|
14
|
-
certifi==2024.
|
|
15
|
+
certifi==2024.7.4
|
|
15
16
|
# via requests
|
|
16
17
|
charset-normalizer==3.3.2
|
|
17
18
|
# via requests
|
|
18
19
|
comm==0.2.2
|
|
19
20
|
# via ipykernel
|
|
20
|
-
debugpy==1.8.
|
|
21
|
+
debugpy==1.8.2
|
|
21
22
|
# via ipykernel
|
|
22
23
|
decorator==5.1.1
|
|
23
24
|
# via ipython
|
|
@@ -27,12 +28,12 @@ idna==3.7
|
|
|
27
28
|
# via requests
|
|
28
29
|
iniconfig==2.0.0
|
|
29
30
|
# via pytest
|
|
30
|
-
ipykernel==6.29.
|
|
31
|
-
ipython==8.
|
|
31
|
+
ipykernel==6.29.5
|
|
32
|
+
ipython==8.26.0
|
|
32
33
|
# via ipykernel
|
|
33
34
|
jedi==0.19.1
|
|
34
35
|
# via ipython
|
|
35
|
-
jupyter-client==8.6.
|
|
36
|
+
jupyter-client==8.6.2
|
|
36
37
|
# via ipykernel
|
|
37
38
|
jupyter-core==5.7.2
|
|
38
39
|
# via ipykernel
|
|
@@ -42,14 +43,14 @@ matplotlib-inline==0.1.7
|
|
|
42
43
|
# via ipython
|
|
43
44
|
nest-asyncio==1.6.0
|
|
44
45
|
# via ipykernel
|
|
45
|
-
numpy==
|
|
46
|
+
numpy==2.0.1
|
|
46
47
|
# via pandas
|
|
47
48
|
# via pandas-stubs
|
|
48
|
-
packaging==24.
|
|
49
|
+
packaging==24.1
|
|
49
50
|
# via ipykernel
|
|
50
51
|
# via pytest
|
|
51
52
|
pandas==2.2.2
|
|
52
|
-
pandas-stubs==2.2.
|
|
53
|
+
pandas-stubs==2.2.2.240603
|
|
53
54
|
parso==0.8.4
|
|
54
55
|
# via jedi
|
|
55
56
|
pexpect==4.9.0
|
|
@@ -58,18 +59,18 @@ platformdirs==4.2.2
|
|
|
58
59
|
# via jupyter-core
|
|
59
60
|
pluggy==1.5.0
|
|
60
61
|
# via pytest
|
|
61
|
-
polars==
|
|
62
|
-
prompt-toolkit==3.0.
|
|
62
|
+
polars==1.3.0
|
|
63
|
+
prompt-toolkit==3.0.47
|
|
63
64
|
# via ipython
|
|
64
|
-
psutil==
|
|
65
|
+
psutil==6.0.0
|
|
65
66
|
# via ipykernel
|
|
66
67
|
ptyprocess==0.7.0
|
|
67
68
|
# via pexpect
|
|
68
|
-
pure-eval==0.2.
|
|
69
|
+
pure-eval==0.2.3
|
|
69
70
|
# via stack-data
|
|
70
71
|
pygments==2.18.0
|
|
71
72
|
# via ipython
|
|
72
|
-
pytest==8.2
|
|
73
|
+
pytest==8.3.2
|
|
73
74
|
python-dateutil==2.9.0.post0
|
|
74
75
|
# via jupyter-client
|
|
75
76
|
# via pandas
|
|
@@ -78,14 +79,14 @@ pytz==2024.1
|
|
|
78
79
|
pyzmq==26.0.3
|
|
79
80
|
# via ipykernel
|
|
80
81
|
# via jupyter-client
|
|
81
|
-
requests==2.
|
|
82
|
+
requests==2.32.3
|
|
82
83
|
# via pxwebpy
|
|
83
84
|
six==1.16.0
|
|
84
85
|
# via asttokens
|
|
85
86
|
# via python-dateutil
|
|
86
87
|
stack-data==0.6.3
|
|
87
88
|
# via ipython
|
|
88
|
-
tornado==6.4
|
|
89
|
+
tornado==6.4.1
|
|
89
90
|
# via ipykernel
|
|
90
91
|
# via jupyter-client
|
|
91
92
|
traitlets==5.14.3
|
|
@@ -97,10 +98,10 @@ traitlets==5.14.3
|
|
|
97
98
|
# via matplotlib-inline
|
|
98
99
|
types-pytz==2024.1.0.20240417
|
|
99
100
|
# via pandas-stubs
|
|
100
|
-
types-requests==2.32.0.
|
|
101
|
+
types-requests==2.32.0.20240712
|
|
101
102
|
tzdata==2024.1
|
|
102
103
|
# via pandas
|
|
103
|
-
urllib3==2.2.
|
|
104
|
+
urllib3==2.2.2
|
|
104
105
|
# via requests
|
|
105
106
|
# via types-requests
|
|
106
107
|
wcwidth==0.2.13
|
|
@@ -7,15 +7,16 @@
|
|
|
7
7
|
# all-features: false
|
|
8
8
|
# with-sources: false
|
|
9
9
|
# generate-hashes: false
|
|
10
|
+
# universal: false
|
|
10
11
|
|
|
11
12
|
-e file:.
|
|
12
|
-
certifi==2024.
|
|
13
|
+
certifi==2024.7.4
|
|
13
14
|
# via requests
|
|
14
15
|
charset-normalizer==3.3.2
|
|
15
16
|
# via requests
|
|
16
17
|
idna==3.7
|
|
17
18
|
# via requests
|
|
18
|
-
requests==2.
|
|
19
|
+
requests==2.32.3
|
|
19
20
|
# via pxwebpy
|
|
20
|
-
urllib3==2.2.
|
|
21
|
+
urllib3==2.2.2
|
|
21
22
|
# via requests
|
|
@@ -112,25 +112,67 @@ class PxTable:
|
|
|
112
112
|
|
|
113
113
|
self.fetched = datetime.now()
|
|
114
114
|
|
|
115
|
-
def __unpack_data(self,
|
|
115
|
+
def __unpack_data(self, json_data: dict) -> list[dict]:
|
|
116
116
|
"""
|
|
117
|
-
Takes the
|
|
117
|
+
Takes the json-stat2 and turns it into a list of dicts that can
|
|
118
118
|
be used to convert into a dataframe, using either pandas or polars.
|
|
119
119
|
"""
|
|
120
120
|
|
|
121
|
-
|
|
122
|
-
response["dimension"][dim]["label"]: response["dimension"][dim]["category"][
|
|
123
|
-
"label"
|
|
124
|
-
].values()
|
|
125
|
-
for dim in response["dimension"]
|
|
126
|
-
}
|
|
121
|
+
dimension_categories = {}
|
|
127
122
|
|
|
123
|
+
# Go over each dimension
|
|
124
|
+
for dim in json_data["dimension"]:
|
|
125
|
+
# If the dimension has extension data along with a key for show, use
|
|
126
|
+
# that to determine the values shown in the output
|
|
127
|
+
try:
|
|
128
|
+
match json_data["dimension"][dim]["extension"]["show"]:
|
|
129
|
+
case "code_value":
|
|
130
|
+
values = [
|
|
131
|
+
str(k) + " " + str(v)
|
|
132
|
+
for k, v in json_data["dimension"][dim]["category"][
|
|
133
|
+
"label"
|
|
134
|
+
].items()
|
|
135
|
+
]
|
|
136
|
+
|
|
137
|
+
case "code":
|
|
138
|
+
values = [
|
|
139
|
+
str(k)
|
|
140
|
+
for k in json_data["dimension"][dim]["category"][
|
|
141
|
+
"label"
|
|
142
|
+
].keys()
|
|
143
|
+
]
|
|
144
|
+
|
|
145
|
+
case "value":
|
|
146
|
+
values = [
|
|
147
|
+
str(v)
|
|
148
|
+
for v in json_data["dimension"][dim]["category"][
|
|
149
|
+
"label"
|
|
150
|
+
].values()
|
|
151
|
+
]
|
|
152
|
+
|
|
153
|
+
# Raise an error if we hit some value in the show key that we don't know how to handle
|
|
154
|
+
case _:
|
|
155
|
+
raise ValueError(
|
|
156
|
+
f"""Unexpected show value. Expected "code", "value" or "code_value", got: {json_data["dimension"][dim]["extension"]["show"]}"""
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
# If there's no show key at all we default to using the label values
|
|
160
|
+
except KeyError:
|
|
161
|
+
values = [
|
|
162
|
+
str(v)
|
|
163
|
+
for v in json_data["dimension"][dim]["category"]["label"].values()
|
|
164
|
+
]
|
|
165
|
+
|
|
166
|
+
dimension_categories.update({json_data["dimension"][dim]["label"]: values})
|
|
167
|
+
|
|
168
|
+
# The result is a list of dicts with the dimension as key and product of the category labels for values
|
|
128
169
|
result = [
|
|
129
|
-
dict(zip(
|
|
130
|
-
for x in itertools.product(*
|
|
170
|
+
dict(zip(dimension_categories.keys(), x))
|
|
171
|
+
for x in itertools.product(*dimension_categories.values())
|
|
131
172
|
]
|
|
132
173
|
|
|
133
|
-
|
|
174
|
+
# Finally add the value for each dict representing a row
|
|
175
|
+
for value, dict_row in zip(json_data["value"], result):
|
|
134
176
|
dict_row["value"] = value
|
|
135
177
|
|
|
136
178
|
return result
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|