rdxz2-utill 0.0.2__py3-none-any.whl → 0.0.4__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 rdxz2-utill might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rdxz2-utill
3
- Version: 0.0.2
3
+ Version: 0.0.4
4
4
  Summary: Your daily Python utility
5
5
  Author-email: Richard Dharmawan <richard.dharmawan@gmail.com>
6
6
  License: MIT License
@@ -1,18 +1,19 @@
1
- rdxz2_utill-0.0.2.dist-info/licenses/LICENSE,sha256=PF9CUvzP8XFYopEAzrMzSCovF7RdBdscPqJCDC6KjPc,1073
1
+ rdxz2_utill-0.0.4.dist-info/licenses/LICENSE,sha256=PF9CUvzP8XFYopEAzrMzSCovF7RdBdscPqJCDC6KjPc,1073
2
2
  utill/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
- utill/my_bq.py,sha256=ZsjRbrbczGQ70CavXfyeAPaWT1OW5LyRFBxyusNZ0cc,14701
3
+ utill/my_bq.py,sha256=o3foe_sbYKJ_lfiW4e6oPfNIUIxyKmsrwa6TbYF5bDA,14611
4
+ utill/my_compare.py,sha256=oGK4fEAQYZqy2FH-jqRSvxANL9SsEoEaq5GOCMGoNXI,918
4
5
  utill/my_const.py,sha256=88dOqn6NPQ5-hfRqdkew5POoAIyO91XXOGvN76oNsdo,251
5
- utill/my_csv.py,sha256=76Q7IM7T_WYF5SybObN_MbkPqycirX4FnLd0DX3Kdyg,2742
6
+ utill/my_csv.py,sha256=svgu93R0pP7UW0B58eJMi0vuJnYhqMtafzCsTIk4yUU,2781
6
7
  utill/my_datetime.py,sha256=KEZTplLk3tgVqqC3wClXFcsF_zo40fma_rtPg4kSJHc,2125
7
8
  utill/my_dict.py,sha256=jPaPfdn4WYpm0uIBPiYFinpHhx1jXpFVDJ9npmvxGZQ,391
8
9
  utill/my_encryption.py,sha256=SCF7PPur39cW4RHidsRhw-9BZP-ymUH-6LZ9nAHJDsY,2105
9
10
  utill/my_env.py,sha256=mREys72Ybg2p9p2s7ApOt0s_6F5-qxR8FyYEcSJ8pmU,2093
10
11
  utill/my_file.py,sha256=H3QmIOwubQCUMoOuk7jwf6AnqsljWZIuM7OjelyZby4,1865
11
- utill/my_gcs.py,sha256=VY2CXQbzBUhX-HunvAZ_y4E19eiuZ1b3TF33bUkJfp4,3953
12
+ utill/my_gcs.py,sha256=u9rZr4e6XLLFK1QC9JknMwBeNX5MWOnVq1W50U5Jt14,4032
12
13
  utill/my_input.py,sha256=OyKLoutXpwISReltuL_Gw2oojv16tYWJqQpqabBOQx4,350
13
14
  utill/my_json.py,sha256=WgW6mavGhfs4h1N5XbhsDnRk2dbh_ttJWdJUj4iWDN4,1473
14
15
  utill/my_mb.py,sha256=3_A5kXHgnkxGbd38vK5t5MfFcj84lohjS7C2OtlSo30,14841
15
- utill/my_pg.py,sha256=2Q6NhWnWWVi7rfv4eMgE8v98WPXj4PZFkO_RrQnK-Zg,6550
16
+ utill/my_pg.py,sha256=udsqNok7dOFz1rO-hQhqnEj8PpH9oMdkyyjGAdLRS-w,6554
16
17
  utill/my_queue.py,sha256=hINP4_yjmboSjHgo1J3CtPm2X9SE3HfczyED3ip7nfk,1930
17
18
  utill/my_string.py,sha256=pINYFR1ligTyVZYzV8P_FolCsZQwYE1jaFNTuQ3XS_8,833
18
19
  utill/my_style.py,sha256=Wy6j4WL9RgGeX6cS9hhlOrufc9UC4UPTQ5UJa0ZJ3Yo,900
@@ -25,10 +26,10 @@ utill/cmd/_enc.py,sha256=DBy3Iwa5DTtww7lgHPRLEilrYPrWDG1vRv5PO-YzNO8,997
25
26
  utill/cmd/_main.py,sha256=UJ_XTIGDO9XPIypgHhS81SJQ_8qy8JOyw98Or0Nb2x8,273
26
27
  utill/cmd/_pg.py,sha256=RVxEiSifyIwMDYDM69vt6WSLdVDr1cMzY6r4T2PzNRA,492
27
28
  utill/cmd/utill.py,sha256=TlHfiwOUcK1m58PrRCjX9sARiPYZUsoTk-KOTCOz1vM,3558
28
- utill/templates/mb.json,sha256=BPnVhMG2FgcxnThYp04Vn5zSQI0G-yQv99qTPNvmSok,44
29
- utill/templates/pg.json,sha256=49c8AoGznP-omKGEgWlIWFpj7qIjeOC5Nf5k0DxlbHE,256
30
- rdxz2_utill-0.0.2.dist-info/METADATA,sha256=wNe5vDTD-cDgQmUOlXQLJTFdsFTNG75TxF5EHij6b2A,4489
31
- rdxz2_utill-0.0.2.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
32
- rdxz2_utill-0.0.2.dist-info/entry_points.txt,sha256=9n5NWz5Wi9jDvYhB_81_4icgT5xABZ-QivHD8ibcafg,47
33
- rdxz2_utill-0.0.2.dist-info/top_level.txt,sha256=tuAYZoCsr02JYbpZj7I6fl1IIo53v3GG0uoj-_fINVk,6
34
- rdxz2_utill-0.0.2.dist-info/RECORD,,
29
+ utill/templates/mb.json,sha256=M46ZHSaSh4rbD_KGUViGr2B2ZV8_PC-O5Evqi35JK5g,59
30
+ utill/templates/pg.json,sha256=LkJt0VV3zcyt7Tpn6gulsoVQgUc-9uImXOStvzu8cdU,271
31
+ rdxz2_utill-0.0.4.dist-info/METADATA,sha256=nZ2GUHgCjt5YG-zsuFN8SJzh7oF35MPdFRqtHTkhT5s,4489
32
+ rdxz2_utill-0.0.4.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
33
+ rdxz2_utill-0.0.4.dist-info/entry_points.txt,sha256=9n5NWz5Wi9jDvYhB_81_4icgT5xABZ-QivHD8ibcafg,47
34
+ rdxz2_utill-0.0.4.dist-info/top_level.txt,sha256=tuAYZoCsr02JYbpZj7I6fl1IIo53v3GG0uoj-_fINVk,6
35
+ rdxz2_utill-0.0.4.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (78.1.0)
2
+ Generator: setuptools (79.0.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
utill/my_bq.py CHANGED
@@ -12,7 +12,6 @@ from .my_const import ByteSize
12
12
  from .my_csv import read_header, combine as csv_combine, compress
13
13
  from .my_datetime import current_datetime_str
14
14
  from .my_env import envs
15
- from .my_file import make_sure_path_is_directory
16
15
  from .my_gcs import GCS
17
16
  from .my_queue import ThreadingQ
18
17
  from .my_string import replace_nonnumeric
@@ -249,8 +248,7 @@ class BQ():
249
248
  if not dst_filename.endswith('.csv'):
250
249
  raise ValueError('Destination filename must ends with .csv!')
251
250
 
252
- dirname = os.path.dirname(dst_filename)
253
- make_sure_path_is_directory(dirname)
251
+ dirname = dst_filename.removesuffix('.csv')
254
252
 
255
253
  # Remove & recreate existing folder
256
254
  if os.path.exists(dirname):
utill/my_compare.py ADDED
@@ -0,0 +1,34 @@
1
+ import math
2
+
3
+
4
+ def try_float(value) -> float:
5
+ try:
6
+ return float(value)
7
+ except:
8
+ return value
9
+
10
+
11
+ def same(a, b, float_precision=None) -> tuple[bool, float]:
12
+ if a is None and b is None:
13
+ return True, None
14
+
15
+ if a is None or b is None:
16
+ return False, None
17
+
18
+ # Compare float
19
+ a_float = try_float(a)
20
+ b_float = try_float(b)
21
+ if isinstance(a_float, float) or isinstance(b_float, float):
22
+ try:
23
+ if math.isnan(a_float) and math.isnan(b_float):
24
+ return True, None
25
+
26
+ if float_precision:
27
+ a_float_rounded = round(a_float, float_precision)
28
+ b_float_rounded = round(b_float, float_precision)
29
+
30
+ return a_float_rounded == b_float_rounded, abs(a_float - b_float)
31
+ except (ValueError, TypeError):
32
+ raise Exception(f'Can\'t compare {a} to {b}')
33
+
34
+ return str(a) == str(b), None
utill/my_csv.py CHANGED
@@ -81,6 +81,7 @@ def combine(src_filenames: list[str], dst_filename: str) -> None:
81
81
  # Copy the header if this is the first file
82
82
  if first_file:
83
83
  csvwriter.writerow(next(csvreader))
84
+ first_file = False
84
85
  # Else, skip the header
85
86
  else:
86
87
  next(csvreader)
utill/my_gcs.py CHANGED
@@ -30,6 +30,8 @@ class GCS:
30
30
  return f'{self.base_path}/{path}' if self.base_path else path
31
31
 
32
32
  def change_bucket(self, bucket_name: str):
33
+ if not bucket_name:
34
+ raise ValueError('Bucket name needed')
33
35
  self.bucket = self.client.bucket(bucket_name)
34
36
  logger.debug(f'Change bucket to {self.bucket.name}')
35
37
 
utill/my_pg.py CHANGED
@@ -24,7 +24,7 @@ class PG:
24
24
  ) -> None:
25
25
  # Evaluate config source
26
26
  if isinstance(config_source, str):
27
- if os.path.exists(config_source):
27
+ if not os.path.exists(config_source):
28
28
  raise ValueError(f'Config source file not found: {config_source}, create one with \'utill init\'')
29
29
  if connection is None:
30
30
  raise ValueError('Connection name must be provided when using file source!')
utill/templates/mb.json CHANGED
@@ -1,4 +1,5 @@
1
1
  {
2
2
  "base_url": "xxx",
3
- "api_key": "xxx"
3
+ "api_key": "xxx",
4
+ "end": true
4
5
  }
utill/templates/pg.json CHANGED
@@ -9,5 +9,6 @@
9
9
  "db": "xxx",
10
10
  "username": "xxx",
11
11
  "password": "xxx"
12
- }
12
+ },
13
+ "end": true
13
14
  }