rdxz2-utill 0.0.8__tar.gz → 0.0.10__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.
Potentially problematic release.
This version of rdxz2-utill might be problematic. Click here for more details.
- {rdxz2_utill-0.0.8/src/rdxz2_utill.egg-info → rdxz2_utill-0.0.10}/PKG-INFO +1 -1
- {rdxz2_utill-0.0.8 → rdxz2_utill-0.0.10}/pyproject.toml +1 -1
- {rdxz2_utill-0.0.8 → rdxz2_utill-0.0.10/src/rdxz2_utill.egg-info}/PKG-INFO +1 -1
- {rdxz2_utill-0.0.8 → rdxz2_utill-0.0.10}/src/utill/my_bq.py +8 -4
- {rdxz2_utill-0.0.8 → rdxz2_utill-0.0.10}/src/utill/my_gcs.py +7 -3
- {rdxz2_utill-0.0.8 → rdxz2_utill-0.0.10}/src/utill/my_mb.py +16 -7
- {rdxz2_utill-0.0.8 → rdxz2_utill-0.0.10}/LICENSE +0 -0
- {rdxz2_utill-0.0.8 → rdxz2_utill-0.0.10}/README.md +0 -0
- {rdxz2_utill-0.0.8 → rdxz2_utill-0.0.10}/setup.cfg +0 -0
- {rdxz2_utill-0.0.8 → rdxz2_utill-0.0.10}/src/rdxz2_utill.egg-info/SOURCES.txt +0 -0
- {rdxz2_utill-0.0.8 → rdxz2_utill-0.0.10}/src/rdxz2_utill.egg-info/dependency_links.txt +0 -0
- {rdxz2_utill-0.0.8 → rdxz2_utill-0.0.10}/src/rdxz2_utill.egg-info/entry_points.txt +0 -0
- {rdxz2_utill-0.0.8 → rdxz2_utill-0.0.10}/src/rdxz2_utill.egg-info/requires.txt +0 -0
- {rdxz2_utill-0.0.8 → rdxz2_utill-0.0.10}/src/rdxz2_utill.egg-info/top_level.txt +0 -0
- {rdxz2_utill-0.0.8 → rdxz2_utill-0.0.10}/src/utill/__init__.py +0 -0
- {rdxz2_utill-0.0.8 → rdxz2_utill-0.0.10}/src/utill/cmd/__init__.py +0 -0
- {rdxz2_utill-0.0.8 → rdxz2_utill-0.0.10}/src/utill/cmd/_bq.py +0 -0
- {rdxz2_utill-0.0.8 → rdxz2_utill-0.0.10}/src/utill/cmd/_conf.py +0 -0
- {rdxz2_utill-0.0.8 → rdxz2_utill-0.0.10}/src/utill/cmd/_enc.py +0 -0
- {rdxz2_utill-0.0.8 → rdxz2_utill-0.0.10}/src/utill/cmd/_main.py +0 -0
- {rdxz2_utill-0.0.8 → rdxz2_utill-0.0.10}/src/utill/cmd/_pg.py +0 -0
- {rdxz2_utill-0.0.8 → rdxz2_utill-0.0.10}/src/utill/cmd/utill.py +0 -0
- {rdxz2_utill-0.0.8 → rdxz2_utill-0.0.10}/src/utill/my_compare.py +0 -0
- {rdxz2_utill-0.0.8 → rdxz2_utill-0.0.10}/src/utill/my_const.py +0 -0
- {rdxz2_utill-0.0.8 → rdxz2_utill-0.0.10}/src/utill/my_csv.py +0 -0
- {rdxz2_utill-0.0.8 → rdxz2_utill-0.0.10}/src/utill/my_datetime.py +0 -0
- {rdxz2_utill-0.0.8 → rdxz2_utill-0.0.10}/src/utill/my_dict.py +0 -0
- {rdxz2_utill-0.0.8 → rdxz2_utill-0.0.10}/src/utill/my_encryption.py +0 -0
- {rdxz2_utill-0.0.8 → rdxz2_utill-0.0.10}/src/utill/my_env.py +0 -0
- {rdxz2_utill-0.0.8 → rdxz2_utill-0.0.10}/src/utill/my_file.py +0 -0
- {rdxz2_utill-0.0.8 → rdxz2_utill-0.0.10}/src/utill/my_input.py +0 -0
- {rdxz2_utill-0.0.8 → rdxz2_utill-0.0.10}/src/utill/my_json.py +0 -0
- {rdxz2_utill-0.0.8 → rdxz2_utill-0.0.10}/src/utill/my_pg.py +0 -0
- {rdxz2_utill-0.0.8 → rdxz2_utill-0.0.10}/src/utill/my_queue.py +0 -0
- {rdxz2_utill-0.0.8 → rdxz2_utill-0.0.10}/src/utill/my_string.py +0 -0
- {rdxz2_utill-0.0.8 → rdxz2_utill-0.0.10}/src/utill/my_style.py +0 -0
- {rdxz2_utill-0.0.8 → rdxz2_utill-0.0.10}/src/utill/my_tunnel.py +0 -0
- {rdxz2_utill-0.0.8 → rdxz2_utill-0.0.10}/src/utill/my_xlsx.py +0 -0
- {rdxz2_utill-0.0.8 → rdxz2_utill-0.0.10}/src/utill/templates/mb.json +0 -0
- {rdxz2_utill-0.0.8 → rdxz2_utill-0.0.10}/src/utill/templates/pg.json +0 -0
|
@@ -58,11 +58,15 @@ class Dtype:
|
|
|
58
58
|
|
|
59
59
|
|
|
60
60
|
class BQ():
|
|
61
|
-
def __init__(self, project: str = None):
|
|
61
|
+
def __init__(self, project: str = None, service_account_filename: str = None):
|
|
62
62
|
self.project = project or envs.GCP_PROJECT_ID
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
if service_account_filename is not None:
|
|
65
|
+
self.client = bigquery.Client.from_service_account_json(service_account_filename)
|
|
66
|
+
else:
|
|
67
|
+
self.client = bigquery.Client(project=self.project)
|
|
68
|
+
|
|
69
|
+
logger.debug(f'BQ client open, project: {self.client.project}')
|
|
66
70
|
|
|
67
71
|
def __enter__(self):
|
|
68
72
|
return self
|
|
@@ -247,7 +251,7 @@ class BQ():
|
|
|
247
251
|
def download_csv(self, query: str, dst_filename: str, combine: bool = True, pre_query: str = None):
|
|
248
252
|
if not dst_filename.endswith('.csv'):
|
|
249
253
|
raise ValueError('Destination filename must ends with .csv!')
|
|
250
|
-
|
|
254
|
+
|
|
251
255
|
dst_filename = os.path.expanduser(dst_filename)
|
|
252
256
|
|
|
253
257
|
dirname = dst_filename.removesuffix('.csv')
|
|
@@ -9,16 +9,20 @@ from .my_env import envs
|
|
|
9
9
|
|
|
10
10
|
class GCS:
|
|
11
11
|
|
|
12
|
-
def __init__(self, project: str = None, bucket_name: str = None):
|
|
12
|
+
def __init__(self, project: str = None, service_account_filename: str = None, bucket_name: str = None):
|
|
13
13
|
self.project = project if project is not None else envs.GCP_PROJECT_ID
|
|
14
|
-
|
|
14
|
+
|
|
15
|
+
if service_account_filename is not None:
|
|
16
|
+
self.client = storage.Client.from_service_account_json(service_account_filename)
|
|
17
|
+
else:
|
|
18
|
+
self.client = storage.Client(project=self.project)
|
|
15
19
|
|
|
16
20
|
bucket_name_parts = (bucket_name or envs.GCS_BUCKET).split('/')
|
|
17
21
|
self.change_bucket(bucket_name_parts[0])
|
|
18
22
|
self.base_path = '/'.join(bucket_name_parts[1:]) if len(bucket_name_parts) > 1 else None
|
|
19
23
|
not self.base_path or logger.debug(f'Base path: {self.base_path}')
|
|
20
24
|
|
|
21
|
-
logger.debug(f'GCS client open, project: {project
|
|
25
|
+
logger.debug(f'GCS client open, project: {self.client.project}')
|
|
22
26
|
|
|
23
27
|
def __enter__(self):
|
|
24
28
|
return self
|
|
@@ -12,6 +12,12 @@ from .my_dict import AutoPopulatingDict
|
|
|
12
12
|
from .my_env import MB_FILENAME
|
|
13
13
|
|
|
14
14
|
|
|
15
|
+
class UsersNotFoundException(Exception):
|
|
16
|
+
def __init__(self, username: list[str]):
|
|
17
|
+
self.message = f'User(s) {username} not exists'
|
|
18
|
+
super().__init__(self.message)
|
|
19
|
+
|
|
20
|
+
|
|
15
21
|
def _decode_collection_location_to_group(collections_dict: dict, location: str):
|
|
16
22
|
return ' > '.join(map(lambda x: collections_dict[x], map(int, location.strip('/').split('/'))))
|
|
17
23
|
|
|
@@ -21,10 +27,10 @@ def _translate_user_group_ids(user: dict) -> set:
|
|
|
21
27
|
|
|
22
28
|
|
|
23
29
|
class MB:
|
|
24
|
-
def __init__(self,
|
|
25
|
-
config = json.loads(open(
|
|
30
|
+
def __init__(self, config_source: str = MB_FILENAME) -> None:
|
|
31
|
+
config = json.loads(open(config_source, 'r').read())
|
|
26
32
|
|
|
27
|
-
self.base_url =
|
|
33
|
+
self.base_url = config['base_url']
|
|
28
34
|
self.api_key = config['api_key']
|
|
29
35
|
|
|
30
36
|
self._is_user_initialized = False
|
|
@@ -98,7 +104,7 @@ class MB:
|
|
|
98
104
|
not_exists.append(email)
|
|
99
105
|
|
|
100
106
|
if not_exists:
|
|
101
|
-
raise
|
|
107
|
+
raise UsersNotFoundException(not_exists)
|
|
102
108
|
|
|
103
109
|
def create_user(self, first_name: str, last_name: str, email: str, group_ids: list):
|
|
104
110
|
self.send_request(HttpMethod.POST, 'api/user', {
|
|
@@ -111,7 +117,11 @@ class MB:
|
|
|
111
117
|
logger.info(f'✅ Create user {email}')
|
|
112
118
|
|
|
113
119
|
def deactivate_user_by_email(self, email: str):
|
|
114
|
-
|
|
120
|
+
try:
|
|
121
|
+
user = self.dict__user_email__user[email]
|
|
122
|
+
except KeyError as e:
|
|
123
|
+
raise UsersNotFoundException([email])
|
|
124
|
+
|
|
115
125
|
self.send_request(HttpMethod.DELETE, f'api/user/{user["id"]}')
|
|
116
126
|
del self.dict__user_email__user[email]
|
|
117
127
|
logger.info(f'✅ Deactivate user [{user["id"]}] {email}')
|
|
@@ -120,8 +130,7 @@ class MB:
|
|
|
120
130
|
try:
|
|
121
131
|
self.dict__user_email__user[email]
|
|
122
132
|
except KeyError as e:
|
|
123
|
-
|
|
124
|
-
raise e
|
|
133
|
+
raise UsersNotFoundException([email])
|
|
125
134
|
self.send_request(HttpMethod.POST, 'api/session/forgot_password', {'email': email})
|
|
126
135
|
logger.info(f'✅ Reset password {email}')
|
|
127
136
|
|
|
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
|
|
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
|