rdxz2-utill 0.0.7__tar.gz → 0.0.9__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.
Files changed (40) hide show
  1. {rdxz2_utill-0.0.7/src/rdxz2_utill.egg-info → rdxz2_utill-0.0.9}/PKG-INFO +1 -1
  2. {rdxz2_utill-0.0.7 → rdxz2_utill-0.0.9}/pyproject.toml +1 -1
  3. {rdxz2_utill-0.0.7 → rdxz2_utill-0.0.9/src/rdxz2_utill.egg-info}/PKG-INFO +1 -1
  4. {rdxz2_utill-0.0.7 → rdxz2_utill-0.0.9}/src/utill/my_bq.py +8 -4
  5. {rdxz2_utill-0.0.7 → rdxz2_utill-0.0.9}/src/utill/my_gcs.py +7 -3
  6. {rdxz2_utill-0.0.7 → rdxz2_utill-0.0.9}/src/utill/my_mb.py +3 -3
  7. {rdxz2_utill-0.0.7 → rdxz2_utill-0.0.9}/src/utill/my_pg.py +1 -1
  8. {rdxz2_utill-0.0.7 → rdxz2_utill-0.0.9}/LICENSE +0 -0
  9. {rdxz2_utill-0.0.7 → rdxz2_utill-0.0.9}/README.md +0 -0
  10. {rdxz2_utill-0.0.7 → rdxz2_utill-0.0.9}/setup.cfg +0 -0
  11. {rdxz2_utill-0.0.7 → rdxz2_utill-0.0.9}/src/rdxz2_utill.egg-info/SOURCES.txt +0 -0
  12. {rdxz2_utill-0.0.7 → rdxz2_utill-0.0.9}/src/rdxz2_utill.egg-info/dependency_links.txt +0 -0
  13. {rdxz2_utill-0.0.7 → rdxz2_utill-0.0.9}/src/rdxz2_utill.egg-info/entry_points.txt +0 -0
  14. {rdxz2_utill-0.0.7 → rdxz2_utill-0.0.9}/src/rdxz2_utill.egg-info/requires.txt +0 -0
  15. {rdxz2_utill-0.0.7 → rdxz2_utill-0.0.9}/src/rdxz2_utill.egg-info/top_level.txt +0 -0
  16. {rdxz2_utill-0.0.7 → rdxz2_utill-0.0.9}/src/utill/__init__.py +0 -0
  17. {rdxz2_utill-0.0.7 → rdxz2_utill-0.0.9}/src/utill/cmd/__init__.py +0 -0
  18. {rdxz2_utill-0.0.7 → rdxz2_utill-0.0.9}/src/utill/cmd/_bq.py +0 -0
  19. {rdxz2_utill-0.0.7 → rdxz2_utill-0.0.9}/src/utill/cmd/_conf.py +0 -0
  20. {rdxz2_utill-0.0.7 → rdxz2_utill-0.0.9}/src/utill/cmd/_enc.py +0 -0
  21. {rdxz2_utill-0.0.7 → rdxz2_utill-0.0.9}/src/utill/cmd/_main.py +0 -0
  22. {rdxz2_utill-0.0.7 → rdxz2_utill-0.0.9}/src/utill/cmd/_pg.py +0 -0
  23. {rdxz2_utill-0.0.7 → rdxz2_utill-0.0.9}/src/utill/cmd/utill.py +0 -0
  24. {rdxz2_utill-0.0.7 → rdxz2_utill-0.0.9}/src/utill/my_compare.py +0 -0
  25. {rdxz2_utill-0.0.7 → rdxz2_utill-0.0.9}/src/utill/my_const.py +0 -0
  26. {rdxz2_utill-0.0.7 → rdxz2_utill-0.0.9}/src/utill/my_csv.py +0 -0
  27. {rdxz2_utill-0.0.7 → rdxz2_utill-0.0.9}/src/utill/my_datetime.py +0 -0
  28. {rdxz2_utill-0.0.7 → rdxz2_utill-0.0.9}/src/utill/my_dict.py +0 -0
  29. {rdxz2_utill-0.0.7 → rdxz2_utill-0.0.9}/src/utill/my_encryption.py +0 -0
  30. {rdxz2_utill-0.0.7 → rdxz2_utill-0.0.9}/src/utill/my_env.py +0 -0
  31. {rdxz2_utill-0.0.7 → rdxz2_utill-0.0.9}/src/utill/my_file.py +0 -0
  32. {rdxz2_utill-0.0.7 → rdxz2_utill-0.0.9}/src/utill/my_input.py +0 -0
  33. {rdxz2_utill-0.0.7 → rdxz2_utill-0.0.9}/src/utill/my_json.py +0 -0
  34. {rdxz2_utill-0.0.7 → rdxz2_utill-0.0.9}/src/utill/my_queue.py +0 -0
  35. {rdxz2_utill-0.0.7 → rdxz2_utill-0.0.9}/src/utill/my_string.py +0 -0
  36. {rdxz2_utill-0.0.7 → rdxz2_utill-0.0.9}/src/utill/my_style.py +0 -0
  37. {rdxz2_utill-0.0.7 → rdxz2_utill-0.0.9}/src/utill/my_tunnel.py +0 -0
  38. {rdxz2_utill-0.0.7 → rdxz2_utill-0.0.9}/src/utill/my_xlsx.py +0 -0
  39. {rdxz2_utill-0.0.7 → rdxz2_utill-0.0.9}/src/utill/templates/mb.json +0 -0
  40. {rdxz2_utill-0.0.7 → rdxz2_utill-0.0.9}/src/utill/templates/pg.json +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rdxz2-utill
3
- Version: 0.0.7
3
+ Version: 0.0.9
4
4
  Summary: Your daily Python utility
5
5
  Author-email: Richard Dharmawan <richard.dharmawan@gmail.com>
6
6
  License: MIT License
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "rdxz2-utill"
7
- version = "0.0.7"
7
+ version = "0.0.9"
8
8
  authors = [
9
9
  { name="Richard Dharmawan", email="richard.dharmawan@gmail.com" },
10
10
  ]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rdxz2-utill
3
- Version: 0.0.7
3
+ Version: 0.0.9
4
4
  Summary: Your daily Python utility
5
5
  Author-email: Richard Dharmawan <richard.dharmawan@gmail.com>
6
6
  License: MIT License
@@ -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
- self.client = bigquery.Client(project=self.project)
65
- logger.debug(f'BQ client open, project: {self.project or "<application-default>"}')
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
- self.client = storage.Client(project=self.project)
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 or "<application-default>"}')
25
+ logger.debug(f'GCS client open, project: {self.client.project}')
22
26
 
23
27
  def __enter__(self):
24
28
  return self
@@ -21,10 +21,10 @@ def _translate_user_group_ids(user: dict) -> set:
21
21
 
22
22
 
23
23
  class MB:
24
- def __init__(self, base_url: str = None) -> None:
25
- config = json.loads(open(MB_FILENAME, 'r').read())
24
+ def __init__(self, config_source: str = MB_FILENAME) -> None:
25
+ config = json.loads(open(config_source, 'r').read())
26
26
 
27
- self.base_url = base_url or config['base_url']
27
+ self.base_url = config['base_url']
28
28
  self.api_key = config['api_key']
29
29
 
30
30
  self._is_user_initialized = False
@@ -74,7 +74,7 @@ class PG:
74
74
 
75
75
  self.conn.autocommit = autocommit
76
76
 
77
- def execute_query(self, query: str, params: tuple):
77
+ def execute_query(self, query: str, params: tuple = None):
78
78
  # Make sure connection alive
79
79
  if self.conn.closed:
80
80
  self.establish_connection(self.conn.autocommit, self.row_factory)
File without changes
File without changes
File without changes