garf-core 0.1.0__py3-none-any.whl → 0.1.1__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 +1 -1
- garf_core/fetchers/fake.py +15 -9
- garf_core/fetchers/rest.py +15 -2
- {garf_core-0.1.0.dist-info → garf_core-0.1.1.dist-info}/METADATA +1 -1
- {garf_core-0.1.0.dist-info → garf_core-0.1.1.dist-info}/RECORD +8 -8
- {garf_core-0.1.0.dist-info → garf_core-0.1.1.dist-info}/WHEEL +0 -0
- {garf_core-0.1.0.dist-info → garf_core-0.1.1.dist-info}/entry_points.txt +0 -0
- {garf_core-0.1.0.dist-info → garf_core-0.1.1.dist-info}/top_level.txt +0 -0
garf_core/__init__.py
CHANGED
garf_core/fetchers/fake.py
CHANGED
@@ -20,6 +20,8 @@ from __future__ import annotations
|
|
20
20
|
|
21
21
|
import logging
|
22
22
|
import os
|
23
|
+
from collections.abc import Sequence
|
24
|
+
from typing import Any
|
23
25
|
|
24
26
|
from garf_core import (
|
25
27
|
api_clients,
|
@@ -36,7 +38,7 @@ class FakeApiReportFetcher(report_fetcher.ApiReportFetcher):
|
|
36
38
|
|
37
39
|
def __init__(
|
38
40
|
self,
|
39
|
-
|
41
|
+
api_client: api_clients.FakeApiClient | None = None,
|
40
42
|
parser: parsers.BaseParser = parsers.DictParser,
|
41
43
|
query_specification_builder: query_editor.QuerySpecification = (
|
42
44
|
query_editor.QuerySpecification
|
@@ -46,29 +48,33 @@ class FakeApiReportFetcher(report_fetcher.ApiReportFetcher):
|
|
46
48
|
json_location: str | os.PathLike[str] | None = None,
|
47
49
|
**kwargs: str,
|
48
50
|
) -> None:
|
49
|
-
if not
|
51
|
+
if not api_client and not (
|
50
52
|
data_location := json_location or csv_location or data_location
|
51
53
|
):
|
52
54
|
raise report_fetcher.ApiReportFetcherError(
|
53
55
|
'Missing fake data for the fetcher.'
|
54
56
|
)
|
55
|
-
|
56
|
-
api_clients.FakeApiClient(
|
57
|
-
if data
|
58
|
-
else api_clients.FakeApiClient.from_file(data_location)
|
59
|
-
)
|
57
|
+
if not api_client:
|
58
|
+
api_client = api_clients.FakeApiClient.from_file(data_location)
|
60
59
|
super().__init__(api_client, parser, query_specification_builder, **kwargs)
|
61
60
|
|
61
|
+
@classmethod
|
62
|
+
def from_data(cls, data: Sequence[dict[str, Any]]) -> FakeApiReportFetcher:
|
63
|
+
"""Initializes FakeApiReportFetcher from a sequence of data."""
|
64
|
+
return FakeApiReportFetcher(
|
65
|
+
api_client=api_clients.FakeApiClient(results=data)
|
66
|
+
)
|
67
|
+
|
62
68
|
@classmethod
|
63
69
|
def from_csv(
|
64
70
|
cls, file_location: str | os.PathLike[str]
|
65
71
|
) -> FakeApiReportFetcher:
|
66
|
-
"""
|
72
|
+
"""Initializes FakeApiReportFetcher from a csv file."""
|
67
73
|
return FakeApiReportFetcher(csv_location=file_location)
|
68
74
|
|
69
75
|
@classmethod
|
70
76
|
def from_json(
|
71
77
|
cls, file_location: str | os.PathLike[str]
|
72
78
|
) -> FakeApiReportFetcher:
|
73
|
-
"""
|
79
|
+
"""Initializes FakeApiReportFetcher from a json file."""
|
74
80
|
return FakeApiReportFetcher(json_location=file_location)
|
garf_core/fetchers/rest.py
CHANGED
@@ -40,11 +40,12 @@ class RestApiReportFetcher(report_fetcher.ApiReportFetcher):
|
|
40
40
|
|
41
41
|
def __init__(
|
42
42
|
self,
|
43
|
-
|
43
|
+
api_client: api_clients.RestApiClient | None = None,
|
44
44
|
parser: parsers.BaseParser = parsers.DictParser,
|
45
45
|
query_specification_builder: query_editor.QuerySpecification = (
|
46
46
|
query_editor.QuerySpecification
|
47
47
|
),
|
48
|
+
endpoint: str | None = None,
|
48
49
|
**kwargs: str,
|
49
50
|
) -> None:
|
50
51
|
"""Instantiates RestApiReportFetcher.
|
@@ -54,5 +55,17 @@ class RestApiReportFetcher(report_fetcher.ApiReportFetcher):
|
|
54
55
|
parser: Type of parser to convert API response.
|
55
56
|
query_specification_builder: Class to perform query parsing.
|
56
57
|
"""
|
57
|
-
api_client
|
58
|
+
if not api_client and not endpoint:
|
59
|
+
raise report_fetcher.ApiReportFetcherError(
|
60
|
+
'Missing api_client or endpoint for the fetcher.'
|
61
|
+
)
|
62
|
+
if not api_client:
|
63
|
+
api_client = api_clients.RestApiClient(endpoint)
|
58
64
|
super().__init__(api_client, parser, query_specification_builder, **kwargs)
|
65
|
+
|
66
|
+
@classmethod
|
67
|
+
def from_endpoint(cls, endpoint: str) -> RestApiReportFetcher:
|
68
|
+
"""Initializes RestApiReportFetcher: from an API endpoint."""
|
69
|
+
return RestApiReportFetcher(
|
70
|
+
api_client=api_clients.RestApiClient(endpoint=endpoint)
|
71
|
+
)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: garf-core
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.1
|
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>, Andrei Markin <andrey.markin.ppc@gmail.com>
|
6
6
|
License: Apache 2.0
|
@@ -1,4 +1,4 @@
|
|
1
|
-
garf_core/__init__.py,sha256=
|
1
|
+
garf_core/__init__.py,sha256=5D5GNZp_18xDdFHuq7q1jn0HbR0-HD0s4vn0qzAAGKo,598
|
2
2
|
garf_core/api_clients.py,sha256=k4vjFsA3JOx7Hp_pXIQNwzMXqq4u4dDcz-ddkJC0JhI,4651
|
3
3
|
garf_core/base_query.py,sha256=ZDAw2ojmismXRO0HXEvKDukpS7OAc7390LnM8kvCSCY,1201
|
4
4
|
garf_core/exceptions.py,sha256=Gzvkl2M-rA_XQRAMd3CC62KHeFQE_b6uby0fD0pouw4,1269
|
@@ -7,10 +7,10 @@ garf_core/query_editor.py,sha256=lA1aMFc_1wo6e2CyVISarnZxtH2jnKkuZfJecQqslDg,171
|
|
7
7
|
garf_core/report.py,sha256=2z4tUR5mg29CkwodGaFIXs8Vpo2DCyyzwJWXhBrT0R4,19910
|
8
8
|
garf_core/report_fetcher.py,sha256=o6YT_o0t9EPutiJk9R637lQabkHSaOrzoF2ciOmpQPA,4560
|
9
9
|
garf_core/fetchers/__init__.py,sha256=_cSjg1D5RhUKxaVeVbaDdb8AAoI9glKJXgN5H4qXFkw,783
|
10
|
-
garf_core/fetchers/fake.py,sha256=
|
11
|
-
garf_core/fetchers/rest.py,sha256
|
12
|
-
garf_core-0.1.
|
13
|
-
garf_core-0.1.
|
14
|
-
garf_core-0.1.
|
15
|
-
garf_core-0.1.
|
16
|
-
garf_core-0.1.
|
10
|
+
garf_core/fetchers/fake.py,sha256=fgJjxuHyd6EIUflUtj8r_HfaMS1YTDrOqDlaj6Kvbjs,2584
|
11
|
+
garf_core/fetchers/rest.py,sha256=-5B2-Ck_t3hG99ym59AKwlzctiDxRFI2Nnc8STBxRDo,2201
|
12
|
+
garf_core-0.1.1.dist-info/METADATA,sha256=OY4D0XX-hTCKypRrrea9bBYuqpR87Z58Y5WK35X31zo,2443
|
13
|
+
garf_core-0.1.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
14
|
+
garf_core-0.1.1.dist-info/entry_points.txt,sha256=u4h-ujHO1hbxVXRQzwcC4ftju9_KBYtq5mCLKEBHMj0,69
|
15
|
+
garf_core-0.1.1.dist-info/top_level.txt,sha256=Gj-Zp7fM2turGut5vTJuo5xEcKfow7cTLX3y3WFfNgA,10
|
16
|
+
garf_core-0.1.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|