sharedkernel 1.7.1__tar.gz → 1.7.3__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 (33) hide show
  1. {sharedkernel-1.7.1 → sharedkernel-1.7.3}/PKG-INFO +5 -1
  2. {sharedkernel-1.7.1 → sharedkernel-1.7.3}/README.md +4 -0
  3. {sharedkernel-1.7.1 → sharedkernel-1.7.3}/setup.py +1 -1
  4. {sharedkernel-1.7.1 → sharedkernel-1.7.3}/sharedkernel/date_converter.py +5 -5
  5. {sharedkernel-1.7.1 → sharedkernel-1.7.3}/sharedkernel/s3_uploader.py +11 -5
  6. {sharedkernel-1.7.1 → sharedkernel-1.7.3}/sharedkernel.egg-info/PKG-INFO +5 -1
  7. {sharedkernel-1.7.1 → sharedkernel-1.7.3}/setup.cfg +0 -0
  8. {sharedkernel-1.7.1 → sharedkernel-1.7.3}/sharedkernel/common.py +0 -0
  9. {sharedkernel-1.7.1 → sharedkernel-1.7.3}/sharedkernel/database/__init__.py +0 -0
  10. {sharedkernel-1.7.1 → sharedkernel-1.7.3}/sharedkernel/database/mongo_generic_repository.py +0 -0
  11. {sharedkernel-1.7.1 → sharedkernel-1.7.3}/sharedkernel/database/vector_database_repository/__init__.py +0 -0
  12. {sharedkernel-1.7.1 → sharedkernel-1.7.3}/sharedkernel/database/vector_database_repository/chroma_startegy.py +0 -0
  13. {sharedkernel-1.7.1 → sharedkernel-1.7.3}/sharedkernel/database/vector_database_repository/vector_database_repository.py +0 -0
  14. {sharedkernel-1.7.1 → sharedkernel-1.7.3}/sharedkernel/database/vector_database_repository/vector_database_strategy.py +0 -0
  15. {sharedkernel-1.7.1 → sharedkernel-1.7.3}/sharedkernel/enum/__init__.py +0 -0
  16. {sharedkernel-1.7.1 → sharedkernel-1.7.3}/sharedkernel/enum/error_code.py +0 -0
  17. {sharedkernel-1.7.1 → sharedkernel-1.7.3}/sharedkernel/enum/vector_database_type.py +0 -0
  18. {sharedkernel-1.7.1 → sharedkernel-1.7.3}/sharedkernel/exception/__init__.py +0 -0
  19. {sharedkernel-1.7.1 → sharedkernel-1.7.3}/sharedkernel/exception/exception.py +0 -0
  20. {sharedkernel-1.7.1 → sharedkernel-1.7.3}/sharedkernel/exception/exception_handlers.py +0 -0
  21. {sharedkernel-1.7.1 → sharedkernel-1.7.3}/sharedkernel/jwt_service.py +0 -0
  22. {sharedkernel-1.7.1 → sharedkernel-1.7.3}/sharedkernel/normalizer/__init__.py +0 -0
  23. {sharedkernel-1.7.1 → sharedkernel-1.7.3}/sharedkernel/normalizer/phone_number_normalizer.py +0 -0
  24. {sharedkernel-1.7.1 → sharedkernel-1.7.3}/sharedkernel/objects/__init__.py +0 -0
  25. {sharedkernel-1.7.1 → sharedkernel-1.7.3}/sharedkernel/objects/base_document.py +0 -0
  26. {sharedkernel-1.7.1 → sharedkernel-1.7.3}/sharedkernel/objects/jwt_model.py +0 -0
  27. {sharedkernel-1.7.1 → sharedkernel-1.7.3}/sharedkernel/objects/result.py +0 -0
  28. {sharedkernel-1.7.1 → sharedkernel-1.7.3}/sharedkernel/regex_masking.py +0 -0
  29. {sharedkernel-1.7.1 → sharedkernel-1.7.3}/sharedkernel/string_extentions.py +0 -0
  30. {sharedkernel-1.7.1 → sharedkernel-1.7.3}/sharedkernel.egg-info/SOURCES.txt +0 -0
  31. {sharedkernel-1.7.1 → sharedkernel-1.7.3}/sharedkernel.egg-info/dependency_links.txt +0 -0
  32. {sharedkernel-1.7.1 → sharedkernel-1.7.3}/sharedkernel.egg-info/requires.txt +0 -0
  33. {sharedkernel-1.7.1 → sharedkernel-1.7.3}/sharedkernel.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sharedkernel
3
- Version: 1.7.1
3
+ Version: 1.7.3
4
4
  Summary: sharekernel is a shared package between all python projects
5
5
  Author: Smilinno
6
6
  Description-Content-Type: text/markdown
@@ -20,6 +20,10 @@ Requires-Dist: boto3
20
20
  this a shared kernel package
21
21
 
22
22
  # Change Log
23
+ ### Version 1.7.3
24
+ - Add optional folder name for s3 uploader to save the file in
25
+ ### Version 1.7.2
26
+ - Fix bug of to_diff_persian_date_time_string
23
27
  ### Version 1.7.1
24
28
  - Update BaseDocument initial values
25
29
  ### Version 1.7.0
@@ -2,6 +2,10 @@
2
2
  this a shared kernel package
3
3
 
4
4
  # Change Log
5
+ ### Version 1.7.3
6
+ - Add optional folder name for s3 uploader to save the file in
7
+ ### Version 1.7.2
8
+ - Fix bug of to_diff_persian_date_time_string
5
9
  ### Version 1.7.1
6
10
  - Update BaseDocument initial values
7
11
  ### Version 1.7.0
@@ -35,7 +35,7 @@ setup(
35
35
  "boto3"
36
36
  ],
37
37
  # *strongly* suggested for sharing
38
- version="1.7.1",
38
+ version="1.7.3",
39
39
  description="sharekernel is a shared package between all python projects",
40
40
  long_description=long_description,
41
41
  long_description_content_type="text/markdown",
@@ -76,7 +76,7 @@ class DateConverter:
76
76
  total_days = abs(total_days)
77
77
  total_months = abs(total_months)
78
78
 
79
- date_time_today = comparison_base.date()
79
+ date_time_today = JalaliDateTime.to_jalali(comparison_base)
80
80
  yesterday = date_time_today - timedelta(days=1)
81
81
  tomorrow = date_time_today + timedelta(days=1)
82
82
 
@@ -95,10 +95,10 @@ class DateConverter:
95
95
  if total_seconds < 86400:
96
96
  return f"{floor(total_seconds / 3600)} ساعت{suffix}{hh_mm}"
97
97
 
98
- if yesterday == date.date():
99
- return f"دیروز {get_persian_day_name(JalaliDate(yesterday.year, yesterday.month, yesterday.day -1))}"
98
+ if yesterday.date() == date.date():
99
+ return f"دیروز {get_persian_day_name(JalaliDate(yesterday.year, yesterday.month, yesterday.day))}"
100
100
  if tomorrow == date.date():
101
- return f"فردا {get_persian_day_name(JalaliDate(tomorrow.year, tomorrow.month, tomorrow.day -1))}"
101
+ return f"فردا {get_persian_day_name(JalaliDate(tomorrow.year, tomorrow.month, tomorrow.day))}"
102
102
 
103
103
  if total_days < MONTH: # 30 days
104
104
  return f"{int(total_days)} روز{suffix}"
@@ -106,7 +106,7 @@ class DateConverter:
106
106
  total_months = int(total_days / MONTH)
107
107
  total_days = total_days - total_months * MONTH
108
108
 
109
- if total_months < 12 * MONTH:
109
+ if total_months < 12:
110
110
  if total_days == 0:
111
111
  return f"{total_months} ماه {suffix}"
112
112
  else:
@@ -27,13 +27,14 @@ class S3Uploader:
27
27
  aws_secret_access_key=self.secret_key,
28
28
  )
29
29
 
30
- def upload_file_object(self, file_obj, object_name=None, file_extension=None):
30
+ def upload_file_object(self, file_obj, object_name=None, file_extension=None, folder_name=None):
31
31
  """
32
32
  Uploads a file object to an S3 bucket and returns its URL.
33
33
 
34
34
  :param file_obj: File object to upload
35
35
  :param object_name: S3 file name to save as (optional)
36
36
  :param file_extension: File extension to append to object name (optional)
37
+ :param folder_name: Optional folder name to save the file in
37
38
  :return: URL of the uploaded file if successful, else False
38
39
  """
39
40
  # Use uuid4 to generate a unique object_name if not provided
@@ -44,6 +45,10 @@ class S3Uploader:
44
45
  if file_extension:
45
46
  object_name += file_extension
46
47
 
48
+ # Prefix the object name with the folder if provided
49
+ if folder_name:
50
+ object_name = f"{folder_name}/{object_name}"
51
+
47
52
  # Upload the file object
48
53
  self.s3.upload_fileobj(file_obj, self.bucket, object_name, ExtraArgs={'ACL':'public-read'})
49
54
  print(f"File object uploaded to {self.bucket} as {object_name}.")
@@ -53,20 +58,21 @@ class S3Uploader:
53
58
 
54
59
  return file_url
55
60
 
56
- def upload_file_from_url(self, file_url, object_name=None):
61
+ def upload_file_from_url(self, file_url, object_name=None, folder_name=None):
57
62
  """
58
63
  Downloads a file from a URL and uploads it to an S3 bucket, returning its URL.
59
64
 
60
65
  :param file_url: URL of the file to download
61
66
  :param object_name: S3 file name to save as (optional)
67
+ :param folder_name: Optional folder name to save the file in
62
68
  :return: URL of the uploaded file if successful, else False
63
69
  """
64
70
  # Step 1: Download the file from the provided URL
65
71
  response = requests.get(file_url)
66
72
  response.raise_for_status() # Check if the request was successful
67
73
 
68
- # Extract file extension from the URL if available
69
- file_extension = os.path.splitext(file_url)[1] # Get extension from URL (e.g., .jpg, .png, etc.)
74
+ # Extract file extension from the URL if available
75
+ file_extension = os.path.splitext(file_url)[1] # Get extension from URL (e.g., .jpg, .mp3, etc.)
70
76
 
71
77
  # Use the filename from the URL if no object_name is provided, otherwise use uuid4
72
78
  if object_name is None:
@@ -74,4 +80,4 @@ class S3Uploader:
74
80
 
75
81
  # Step 2: Upload the file to S3
76
82
  file_obj = BytesIO(response.content)
77
- return self.upload_file_object(file_obj, object_name, file_extension)
83
+ return self.upload_file_object(file_obj=file_obj, object_name=object_name, file_extension=file_extension, folder_name=folder_name)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sharedkernel
3
- Version: 1.7.1
3
+ Version: 1.7.3
4
4
  Summary: sharekernel is a shared package between all python projects
5
5
  Author: Smilinno
6
6
  Description-Content-Type: text/markdown
@@ -20,6 +20,10 @@ Requires-Dist: boto3
20
20
  this a shared kernel package
21
21
 
22
22
  # Change Log
23
+ ### Version 1.7.3
24
+ - Add optional folder name for s3 uploader to save the file in
25
+ ### Version 1.7.2
26
+ - Fix bug of to_diff_persian_date_time_string
23
27
  ### Version 1.7.1
24
28
  - Update BaseDocument initial values
25
29
  ### Version 1.7.0
File without changes