datamarket 0.9.19__py3-none-any.whl → 0.9.20__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/utils/main.py +84 -69
- {datamarket-0.9.19.dist-info → datamarket-0.9.20.dist-info}/METADATA +1 -1
- {datamarket-0.9.19.dist-info → datamarket-0.9.20.dist-info}/RECORD +5 -5
- {datamarket-0.9.19.dist-info → datamarket-0.9.20.dist-info}/LICENSE +0 -0
- {datamarket-0.9.19.dist-info → datamarket-0.9.20.dist-info}/WHEEL +0 -0
datamarket/utils/main.py
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
# IMPORTS
|
|
3
3
|
|
|
4
4
|
import asyncio
|
|
5
|
-
from dataclasses import dataclass
|
|
6
|
-
import inspect
|
|
7
5
|
import logging
|
|
8
6
|
import random
|
|
9
7
|
import re
|
|
@@ -12,26 +10,25 @@ import shutil
|
|
|
12
10
|
import subprocess
|
|
13
11
|
import time
|
|
14
12
|
from pathlib import Path
|
|
15
|
-
from typing import Literal,
|
|
13
|
+
from typing import Any, Literal, Self, Union
|
|
16
14
|
|
|
17
15
|
import pendulum
|
|
18
16
|
from croniter import croniter
|
|
19
|
-
from configparser import RawConfigParser
|
|
20
17
|
from dynaconf import Dynaconf, add_converter
|
|
21
18
|
|
|
22
19
|
logger = logging.getLogger(__name__)
|
|
23
20
|
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
|
|
22
|
+
class NoProjectFoundError(Exception):
|
|
23
|
+
def __init__(self):
|
|
24
|
+
super().__init__("Could not detect project. Did you add the config file?")
|
|
26
25
|
|
|
27
26
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
path: Path
|
|
34
|
-
config_path: Path
|
|
27
|
+
class NoPackageFoundError(Exception):
|
|
28
|
+
def __init__(self):
|
|
29
|
+
super().__init__(
|
|
30
|
+
"A project was detected but it has no packages inside the 'src' directory"
|
|
31
|
+
)
|
|
35
32
|
|
|
36
33
|
|
|
37
34
|
########################################################################################################################
|
|
@@ -79,62 +76,80 @@ def read_converter(path_str: str):
|
|
|
79
76
|
return f.read()
|
|
80
77
|
|
|
81
78
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
79
|
+
class Project:
|
|
80
|
+
CONFIG_FILE_NAME = "config.toml"
|
|
81
|
+
|
|
82
|
+
def __init__(self, path: Path):
|
|
83
|
+
self.path = path
|
|
84
|
+
|
|
85
|
+
try:
|
|
86
|
+
self.pkg_name = next((self.path / "src").glob("*")).name
|
|
87
|
+
except StopIteration:
|
|
88
|
+
raise NoPackageFoundError()
|
|
89
|
+
|
|
90
|
+
self.env_name = f"{self.pkg_name}_env"
|
|
91
|
+
self.config_path = self.path / self.CONFIG_FILE_NAME
|
|
92
|
+
self.tests_path = self.path / "tests"
|
|
93
|
+
self.cmd_prefix = "dix vnc run --" if shutil.which("dix") else ""
|
|
94
|
+
|
|
95
|
+
@classmethod
|
|
96
|
+
def from_file(cls, file: Path | str) -> Self:
|
|
97
|
+
file_path = Path(file).resolve()
|
|
98
|
+
|
|
99
|
+
while file_path != file_path.parent:
|
|
100
|
+
config_file = file_path / cls.CONFIG_FILE_NAME
|
|
101
|
+
|
|
102
|
+
if not config_file.is_file():
|
|
103
|
+
file_path = file_path.parent
|
|
104
|
+
continue
|
|
105
|
+
|
|
106
|
+
if file_path.parent == Path("/home"):
|
|
107
|
+
raise NoProjectFoundError()
|
|
108
|
+
|
|
109
|
+
return cls(file_path)
|
|
110
|
+
|
|
111
|
+
raise NoProjectFoundError()
|
|
112
|
+
|
|
113
|
+
def to_dict(self) -> dict[str, Any]:
|
|
114
|
+
return {
|
|
115
|
+
"project_path": self.path,
|
|
116
|
+
"cmd_prefix": self.cmd_prefix,
|
|
117
|
+
"env_name": self.env_name,
|
|
118
|
+
"pkg_name": self.pkg_name,
|
|
119
|
+
"config_path": self.config_path,
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
def get_config(self, tz: str = "Europe/Madrid") -> Dynaconf:
|
|
123
|
+
add_converter("read", read_converter)
|
|
124
|
+
|
|
125
|
+
dt_now = get_granular_date("now", tz)
|
|
126
|
+
dt_weekly = get_granular_date("weekly", tz)
|
|
127
|
+
dt_biweekly = get_granular_date("biweekly", tz)
|
|
128
|
+
|
|
129
|
+
config = Dynaconf(
|
|
130
|
+
environments=True,
|
|
131
|
+
env_switcher="SYSTYPE",
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
config.load_file(path=self.config_path)
|
|
135
|
+
config.load_file(path=Path.home() / self.config_path.name)
|
|
136
|
+
|
|
137
|
+
config.vars = {
|
|
138
|
+
"year": dt_now.strftime("%Y"),
|
|
139
|
+
"month": dt_now.strftime("%m"),
|
|
140
|
+
"day": dt_now.strftime("%d"),
|
|
141
|
+
"now": dt_now.strftime("%Y-%m-%d %H:%M:%S"),
|
|
142
|
+
"now_stripped": dt_now.strftime("%Y%m%d%H%M%S"),
|
|
143
|
+
"today": dt_now.strftime("%Y-%m-%d"),
|
|
144
|
+
"today_stripped": dt_now.strftime("%Y%m%d"),
|
|
145
|
+
"weekly_date": dt_weekly.strftime("%Y-%m-%d"),
|
|
146
|
+
"weekly_date_stripped": dt_weekly.strftime("%Y%m%d"),
|
|
147
|
+
"biweekly_date": dt_biweekly.strftime("%Y-%m-%d"),
|
|
148
|
+
"biweekly_date_stripped": dt_biweekly.strftime("%Y%m%d"),
|
|
149
|
+
"dynaconf_merge": True,
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return config
|
|
138
153
|
|
|
139
154
|
|
|
140
155
|
def set_logger(level):
|
|
@@ -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=j8wnAxeLvijdRU9M4V6HunWH7vgWWHP4u4xamzkWcUU,7009
|
|
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.20.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
21
|
+
datamarket-0.9.20.dist-info/METADATA,sha256=2BsxMukyGFYw-lk455Ksf7NJ_M-mjNB7-_vl3nOdxQ4,6459
|
|
22
|
+
datamarket-0.9.20.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
|
|
23
|
+
datamarket-0.9.20.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|