garf-core 0.0.3__py3-none-any.whl → 0.0.5__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.
garf_core/__init__.py CHANGED
@@ -0,0 +1,15 @@
1
+ # Copyright 2025 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ __version__ = '0.0.5'
garf_core/parsers.py CHANGED
@@ -20,9 +20,10 @@ strategies to each element of the row.
20
20
  from __future__ import annotations
21
21
 
22
22
  import abc
23
+ import contextlib
23
24
  import functools
24
25
  import operator
25
- from collections.abc import Mapping
26
+ from collections.abc import Mapping, MutableSequence
26
27
  from typing import Union
27
28
 
28
29
  from typing_extensions import TypeAlias, override
@@ -78,5 +79,23 @@ class DictParser(BaseParser):
78
79
  return None
79
80
 
80
81
 
82
+ class NumericConverterDictParser(DictParser):
83
+ def get_nested_field(self, dictionary, key):
84
+ def convert_field(value):
85
+ for type_ in (int, float):
86
+ with contextlib.suppress(ValueError):
87
+ return type_(value)
88
+ return value
89
+
90
+ key = key.split('.')
91
+ try:
92
+ field = functools.reduce(operator.getitem, key, dictionary)
93
+ if isinstance(field, MutableSequence) or field in (True, False):
94
+ return field
95
+ return convert_field(field)
96
+ except KeyError:
97
+ return None
98
+
99
+
81
100
  class GarfParserError(exceptions.GarfError):
82
101
  """Incorrect data format for parser."""
garf_core/report.py CHANGED
@@ -176,9 +176,9 @@ class GarfReport:
176
176
  if value_column_output == 'list':
177
177
  output[key].append(value)
178
178
  else:
179
- if key in output:
179
+ if output.get(key) and output.get(key) != value:
180
180
  raise GarfReportError(
181
- f'Non unique values found for key_column: {key}'
181
+ f'Non unique values found for key_column: {key_column}'
182
182
  )
183
183
  output[key] = value
184
184
  return output
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: garf-core
3
- Version: 0.0.3
3
+ Version: 0.0.5
4
4
  Summary: Abstracts fetching data from API based on provided SQL-like query.
5
5
  Author-email: "Google Inc. (gTech gPS CSE team)" <no-reply@google.com>
6
6
  License: Apache 2.0
@@ -0,0 +1,12 @@
1
+ garf_core/__init__.py,sha256=Te0VIlL1MdNgrZ3wJdVePlSHb4Q-0-2KtcuhQp10jOQ,598
2
+ garf_core/api_clients.py,sha256=sBiOfPllrSewV6Ul4uaHhdmgTHQ_l5M7sZHW1z4kNik,1568
3
+ garf_core/base_query.py,sha256=uEhKP56wcFtMiSwYOxoZ0q7OEvURGVOeRdpSYjxWLho,1201
4
+ garf_core/exceptions.py,sha256=4qvNN-8GqbbVsrLKxJwBeX1FUtWpKbhUWyvm7anD3iE,1916
5
+ garf_core/parsers.py,sha256=Y4wwpDXRZky7LBTBklvzk-aDNxgRL5RJg52rSdH5t9Q,2928
6
+ garf_core/query_editor.py,sha256=EzwjFnbje-RcP9VwWQwzCpy8lipt4tph3Kv6q5Lly5o,15994
7
+ garf_core/report.py,sha256=-wz3c4k6Gtxs1jdqC0aSK61ziulxV1cGTl55E8o26bs,16980
8
+ garf_core/report_fetcher.py,sha256=RazwzI8n3e4oVhFUEGshzwaGG0EHIYJgHOleuAeNEto,3231
9
+ garf_core-0.0.5.dist-info/METADATA,sha256=_stbiUxOKv99mdf9EHHw8r5T-QeFKj9wpfAji2SRwQ0,1115
10
+ garf_core-0.0.5.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
11
+ garf_core-0.0.5.dist-info/top_level.txt,sha256=Gj-Zp7fM2turGut5vTJuo5xEcKfow7cTLX3y3WFfNgA,10
12
+ garf_core-0.0.5.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.6.0)
2
+ Generator: setuptools (75.8.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,12 +0,0 @@
1
- garf_core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- garf_core/api_clients.py,sha256=sBiOfPllrSewV6Ul4uaHhdmgTHQ_l5M7sZHW1z4kNik,1568
3
- garf_core/base_query.py,sha256=uEhKP56wcFtMiSwYOxoZ0q7OEvURGVOeRdpSYjxWLho,1201
4
- garf_core/exceptions.py,sha256=4qvNN-8GqbbVsrLKxJwBeX1FUtWpKbhUWyvm7anD3iE,1916
5
- garf_core/parsers.py,sha256=aIiv2SgEhrsRUE86PsOroYGC8DyIl2JAFlybwzzt0r0,2374
6
- garf_core/query_editor.py,sha256=EzwjFnbje-RcP9VwWQwzCpy8lipt4tph3Kv6q5Lly5o,15994
7
- garf_core/report.py,sha256=rWL4wqgfAMKgMq5GxATLd-gWTl1PgmUWYzYfCuCV7Q4,16942
8
- garf_core/report_fetcher.py,sha256=RazwzI8n3e4oVhFUEGshzwaGG0EHIYJgHOleuAeNEto,3231
9
- garf_core-0.0.3.dist-info/METADATA,sha256=iFpFCTwRC51b9p9G-WRTKykj-1GWzp9Fr0zYDSMNdWw,1115
10
- garf_core-0.0.3.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
11
- garf_core-0.0.3.dist-info/top_level.txt,sha256=Gj-Zp7fM2turGut5vTJuo5xEcKfow7cTLX3y3WFfNgA,10
12
- garf_core-0.0.3.dist-info/RECORD,,