datamarket 0.9.2__py3-none-any.whl → 0.9.3__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.
Potentially problematic release.
This version of datamarket might be problematic. Click here for more details.
- datamarket/interfaces/aws.py +9 -7
- datamarket/interfaces/ftp.py +3 -1
- datamarket/utils/main.py +16 -7
- {datamarket-0.9.2.dist-info → datamarket-0.9.3.dist-info}/METADATA +1 -1
- {datamarket-0.9.2.dist-info → datamarket-0.9.3.dist-info}/RECORD +7 -7
- {datamarket-0.9.2.dist-info → datamarket-0.9.3.dist-info}/LICENSE +0 -0
- {datamarket-0.9.2.dist-info → datamarket-0.9.3.dist-info}/WHEEL +0 -0
datamarket/interfaces/aws.py
CHANGED
|
@@ -5,6 +5,8 @@ import io
|
|
|
5
5
|
import logging
|
|
6
6
|
import boto3
|
|
7
7
|
|
|
8
|
+
from ..utils.main import Config
|
|
9
|
+
|
|
8
10
|
########################################################################################################################
|
|
9
11
|
# CLASSES
|
|
10
12
|
|
|
@@ -12,7 +14,7 @@ logger = logging.getLogger(__name__)
|
|
|
12
14
|
|
|
13
15
|
|
|
14
16
|
class AWSInterface:
|
|
15
|
-
def __init__(self, config):
|
|
17
|
+
def __init__(self, config: Config) -> None:
|
|
16
18
|
self.profiles = []
|
|
17
19
|
self.config = config
|
|
18
20
|
|
|
@@ -31,13 +33,13 @@ class AWSInterface:
|
|
|
31
33
|
self.current_profile = self.profiles[0] if self.profiles else None
|
|
32
34
|
self._update_resources()
|
|
33
35
|
|
|
34
|
-
def _update_resources(self):
|
|
36
|
+
def _update_resources(self) -> None:
|
|
35
37
|
if self.current_profile:
|
|
36
38
|
self.s3 = self.current_profile["session"].resource("s3")
|
|
37
39
|
self.s3_client = self.s3.meta.client
|
|
38
40
|
self.bucket = self.current_profile["buckets"][0]
|
|
39
41
|
|
|
40
|
-
def switch_profile(self, profile_name: str):
|
|
42
|
+
def switch_profile(self, profile_name: str) -> None:
|
|
41
43
|
for profile in self.profiles:
|
|
42
44
|
if profile["profile"] == profile_name:
|
|
43
45
|
self.current_profile = profile
|
|
@@ -45,7 +47,7 @@ class AWSInterface:
|
|
|
45
47
|
return
|
|
46
48
|
logger.warning(f"Profile {profile_name} not found")
|
|
47
49
|
|
|
48
|
-
def switch_bucket(self, bucket: str):
|
|
50
|
+
def switch_bucket(self, bucket: str) -> None:
|
|
49
51
|
if bucket not in self.current_profile["buckets"]:
|
|
50
52
|
logger.warning(
|
|
51
53
|
f"Bucket {bucket} not found in profile {self.current_profile['profile']}"
|
|
@@ -54,14 +56,14 @@ class AWSInterface:
|
|
|
54
56
|
|
|
55
57
|
self.bucket = bucket
|
|
56
58
|
|
|
57
|
-
def get_file(self, s3_path: str):
|
|
59
|
+
def get_file(self, s3_path: str) -> None:
|
|
58
60
|
try:
|
|
59
61
|
return self.s3.Object(self.bucket, s3_path).get()
|
|
60
62
|
except self.s3_client.exceptions.NoSuchKey:
|
|
61
63
|
logger.info(f"{s3_path} does not exist")
|
|
62
64
|
|
|
63
|
-
def read_file_as_bytes(self, s3_path: str):
|
|
65
|
+
def read_file_as_bytes(self, s3_path: str) -> io.BytesIO:
|
|
64
66
|
return io.BytesIO(self.get_file(s3_path)["Body"].read())
|
|
65
67
|
|
|
66
|
-
def upload_file(self, local_path: str, s3_path: str):
|
|
68
|
+
def upload_file(self, local_path: str, s3_path: str) -> None:
|
|
67
69
|
self.s3.Bucket(self.bucket).upload_file(local_path, s3_path)
|
datamarket/interfaces/ftp.py
CHANGED
|
@@ -5,6 +5,8 @@ import logging
|
|
|
5
5
|
from ftplib import FTP, FTP_TLS
|
|
6
6
|
from pathlib import Path
|
|
7
7
|
|
|
8
|
+
from ..utils.main import Config
|
|
9
|
+
|
|
8
10
|
########################################################################################################################
|
|
9
11
|
# CLASSES
|
|
10
12
|
|
|
@@ -12,7 +14,7 @@ logger = logging.getLogger(__name__)
|
|
|
12
14
|
|
|
13
15
|
|
|
14
16
|
class FTPInterface:
|
|
15
|
-
def __init__(self, config):
|
|
17
|
+
def __init__(self, config: Config):
|
|
16
18
|
if "ftp" in config:
|
|
17
19
|
self.config = config["ftp"]
|
|
18
20
|
|
datamarket/utils/main.py
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
# IMPORTS
|
|
3
3
|
|
|
4
4
|
import asyncio
|
|
5
|
-
import configparser
|
|
6
5
|
import inspect
|
|
7
6
|
import logging
|
|
8
7
|
import random
|
|
@@ -16,6 +15,7 @@ from typing import Literal, Union
|
|
|
16
15
|
|
|
17
16
|
import pendulum
|
|
18
17
|
from croniter import croniter
|
|
18
|
+
from configparser import RawConfigParser
|
|
19
19
|
from dynaconf import Dynaconf, add_converter
|
|
20
20
|
|
|
21
21
|
########################################################################################################################
|
|
@@ -23,6 +23,8 @@ from dynaconf import Dynaconf, add_converter
|
|
|
23
23
|
|
|
24
24
|
logger = logging.getLogger(__name__)
|
|
25
25
|
|
|
26
|
+
Config = Union[RawConfigParser, Dynaconf]
|
|
27
|
+
|
|
26
28
|
|
|
27
29
|
def get_granular_date(
|
|
28
30
|
granularity: Union[Literal["monthly", "biweekly", "weekly", "daily"], str], tz: str = "Europe/Madrid"
|
|
@@ -64,16 +66,20 @@ def read_converter(path_str: str):
|
|
|
64
66
|
return f.read()
|
|
65
67
|
|
|
66
68
|
|
|
67
|
-
def get_config(
|
|
69
|
+
def get_config(
|
|
70
|
+
config_file: Path, tz: str = "Europe/Madrid"
|
|
71
|
+
) -> Union[RawConfigParser, Dynaconf]:
|
|
68
72
|
if Path(config_file).suffix == ".ini":
|
|
69
73
|
logger.warning("Using legacy INI config reader. Please migrate to TOML")
|
|
70
|
-
cfg =
|
|
74
|
+
cfg = RawConfigParser()
|
|
71
75
|
cfg.read(config_file)
|
|
72
76
|
return cfg
|
|
73
77
|
|
|
74
78
|
add_converter("read", read_converter)
|
|
75
79
|
|
|
76
80
|
dt_now = get_granular_date("now", tz)
|
|
81
|
+
dt_weekly = get_granular_date("weekly", tz)
|
|
82
|
+
dt_biweekly = get_granular_date("biweekly", tz)
|
|
77
83
|
|
|
78
84
|
config = Dynaconf(
|
|
79
85
|
environments=True,
|
|
@@ -84,14 +90,17 @@ def get_config(config_file: Path, tz: str = "Europe/Madrid"):
|
|
|
84
90
|
config.load_file(path=Path.home() / config_file.name)
|
|
85
91
|
|
|
86
92
|
config.vars = {
|
|
87
|
-
"now": dt_now.strftime("%Y-%m-%d %H:%M:%S"),
|
|
88
|
-
"today": dt_now.strftime("%Y-%m-%d"),
|
|
89
93
|
"year": dt_now.strftime("%Y"),
|
|
90
94
|
"month": dt_now.strftime("%m"),
|
|
91
95
|
"day": dt_now.strftime("%d"),
|
|
92
|
-
"
|
|
93
|
-
"today_stripped": dt_now.strftime("%Y%m%d"),
|
|
96
|
+
"now": dt_now.strftime("%Y-%m-%d %H:%M:%S"),
|
|
94
97
|
"now_stripped": dt_now.strftime("%Y%m%d%H%M%S"),
|
|
98
|
+
"today": dt_now.strftime("%Y-%m-%d"),
|
|
99
|
+
"today_stripped": dt_now.strftime("%Y%m%d"),
|
|
100
|
+
"weekly_date": dt_weekly.strftime("%Y-%m-%d"),
|
|
101
|
+
"weekly_date_stripped": dt_weekly.strftime("%Y%m%d"),
|
|
102
|
+
"biweekly_date": dt_biweekly.strftime("%Y-%m-%d"),
|
|
103
|
+
"biweekly_date_stripped": dt_biweekly.strftime("%Y%m%d"),
|
|
95
104
|
"dynaconf_merge": True,
|
|
96
105
|
}
|
|
97
106
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
datamarket/__init__.py,sha256=FHS77P9qNewKMoN-p0FLEUEC60oWIYup1QkbJZP4ays,12
|
|
2
2
|
datamarket/interfaces/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
3
|
datamarket/interfaces/alchemy.py,sha256=V8E1GtokxUNmrUftKTFkIpNoXaqJME7ACES2BY0znQM,4214
|
|
4
|
-
datamarket/interfaces/aws.py,sha256=
|
|
4
|
+
datamarket/interfaces/aws.py,sha256=R6lYdSCD6a4g9l6aFMtNDt_EX3kroe2untDhgy7XG1k,2384
|
|
5
5
|
datamarket/interfaces/drive.py,sha256=shbV5jpQVe_KPE-8Idx6Z9te5Zu1SmVfrvSAyd9ZIgE,2915
|
|
6
|
-
datamarket/interfaces/ftp.py,sha256=
|
|
6
|
+
datamarket/interfaces/ftp.py,sha256=Owk3D7tiF47_ZFT3Dc9h4_BaPsWtcJUbhagjpQB19q8,1900
|
|
7
7
|
datamarket/interfaces/nominatim.py,sha256=_gFJ04D-ju5xn3wuaGT5Pj5jhf4F5eINpxOpuQL_dIQ,3664
|
|
8
8
|
datamarket/interfaces/peerdb.py,sha256=rNQ1-THcVvrej8BEPJs9zM4VfH5dlByafOIHYN9sB2A,21833
|
|
9
9
|
datamarket/interfaces/proxy.py,sha256=updoOStKd8-nQBbxWbnD9eOt6HksnYi-5dQ0rEySf5M,3152
|
|
@@ -13,11 +13,11 @@ datamarket/params/nominatim.py,sha256=pBYRfoBkkLBg2INbFymefmYSzaAVujQSpEro5c1hD_
|
|
|
13
13
|
datamarket/utils/__init__.py,sha256=8D5a8oKgqd6WA1RUkiKCn4l_PVemtyuckxQut0vDHXM,20
|
|
14
14
|
datamarket/utils/airflow.py,sha256=al0vc0YUikNu3Oy51VSn52I7pMU40akFBOl_UlHa2E4,795
|
|
15
15
|
datamarket/utils/alchemy.py,sha256=SRq6kgh1aANXVShBPgAuglmNhZssPWwWEY503gKSia8,635
|
|
16
|
-
datamarket/utils/main.py,sha256=
|
|
16
|
+
datamarket/utils/main.py,sha256=0Abt3ww1VSPnX4AVKDcYzqDLAOEV_54iUHMLJfre2bg,6129
|
|
17
17
|
datamarket/utils/selenium.py,sha256=IMKlbLzXABFhACnWzhHmB0l2hhVzNwHGZwbo14nEewQ,2499
|
|
18
18
|
datamarket/utils/soda.py,sha256=eZTXFbI1P3WoMd1MM-YjoVTpdjTcDSWuvBb7ViBMhSQ,941
|
|
19
19
|
datamarket/utils/typer.py,sha256=FDF3l6gh3UlAFPsHCtesnekvct2rKz0oFn3uKARBQvE,814
|
|
20
|
-
datamarket-0.9.
|
|
21
|
-
datamarket-0.9.
|
|
22
|
-
datamarket-0.9.
|
|
23
|
-
datamarket-0.9.
|
|
20
|
+
datamarket-0.9.3.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
21
|
+
datamarket-0.9.3.dist-info/METADATA,sha256=SY-94WLCqqxLVnPXVPzRQZ6SwP0I-HbqdCBp9Me9ySw,6329
|
|
22
|
+
datamarket-0.9.3.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
|
|
23
|
+
datamarket-0.9.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|