rb-commons 0.5.13__py3-none-any.whl → 0.5.15__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.
@@ -1,5 +1,6 @@
1
1
  from typing import Optional, Any
2
2
 
3
+ from pydantic import field_validator
3
4
  from pydantic_settings import BaseSettings
4
5
 
5
6
  class CommonConfigs(BaseSettings):
@@ -24,7 +25,6 @@ class CommonConfigs(BaseSettings):
24
25
  DIGITALOCEAN_STORAGE_BUCKET_NAME: Optional[str] = None
25
26
  DIGITALOCEAN_S3_ENDPOINT_URL: Optional[str] = None
26
27
 
27
-
28
28
  @property
29
29
  def database_url(self) -> Optional[str]:
30
30
  """Construct the database URL if all required fields are present."""
File without changes
@@ -0,0 +1,52 @@
1
+ from typing import Optional, Any
2
+
3
+ from pydantic import field_validator
4
+ from pydantic_settings import BaseSettings
5
+
6
+ class CommonConfigs(BaseSettings):
7
+ service_name: Optional[str] = None
8
+ service_port: Optional[int] = None
9
+ service_id: Optional[str] = None
10
+ service_hostname: Optional[Any] = '127.0.0.1'
11
+ service_host: Optional[str] = None
12
+
13
+ # db
14
+ POSTGRES_HOST: Optional[str] = None
15
+ POSTGRES_USER: Optional[str] = None
16
+ POSTGRES_PORT: Optional[int] = None
17
+ POSTGRES_PASSWORD: Optional[str] = None
18
+ POSTGRES_DB: Optional[str] = None
19
+ DB_ALEMBIC_URL: Optional[str] = None
20
+
21
+ # Broker
22
+
23
+ RABBITMQ_URL: Optional[str] = None
24
+
25
+ DIGITALOCEAN_STORAGE_BUCKET_NAME: Optional[str] = None
26
+ DIGITALOCEAN_S3_ENDPOINT_URL: Optional[str] = None
27
+
28
+ @property
29
+ def database_url(self) -> Optional[str]:
30
+ """Construct the database URL if all required fields are present."""
31
+ required_fields = [
32
+ self.POSTGRES_USER,
33
+ self.POSTGRES_PASSWORD,
34
+ self.POSTGRES_HOST,
35
+ self.POSTGRES_PORT,
36
+ self.POSTGRES_DB
37
+ ]
38
+ if all(required_fields):
39
+ return (
40
+ f"postgresql+asyncpg://{self.POSTGRES_USER}:"
41
+ f"{self.POSTGRES_PASSWORD}@{self.POSTGRES_HOST}:"
42
+ f"{self.POSTGRES_PORT}/{self.POSTGRES_DB}"
43
+ )
44
+ return None
45
+
46
+ class Config:
47
+ env_file = "/robosell/.env"
48
+ env_file_encoding = "utf-8"
49
+ extra = "ignore"
50
+
51
+
52
+ configs = CommonConfigs()
rb_commons/utils/media.py CHANGED
@@ -1,9 +1,18 @@
1
- from rb_commons.configs.config import configs
1
+ from pydantic import ValidationError
2
2
 
3
3
  class MediaUtils:
4
4
 
5
5
  @staticmethod
6
6
  def url_builder(key: str):
7
+ try:
8
+ from rb_commons.configs.config import configs
9
+ DIGITALOCEAN_S3_ENDPOINT_URL = configs.DIGITALOCEAN_S3_ENDPOINT_URL
10
+ DIGITALOCEAN_STORAGE_BUCKET_NAME = configs.DIGITALOCEAN_STORAGE_BUCKET_NAME
11
+ except ValidationError as e:
12
+ from rb_commons.configs.v2.config import configs
13
+ DIGITALOCEAN_S3_ENDPOINT_URL = configs.DIGITALOCEAN_S3_ENDPOINT_URL
14
+ DIGITALOCEAN_STORAGE_BUCKET_NAME = configs.DIGITALOCEAN_STORAGE_BUCKET_NAME
15
+
7
16
  return "{endpoint_url}/{bucket_name}/{key}" \
8
- .format(endpoint_url=configs.DIGITALOCEAN_S3_ENDPOINT_URL,
9
- bucket_name=configs.DIGITALOCEAN_STORAGE_BUCKET_NAME, key=key)
17
+ .format(endpoint_url=DIGITALOCEAN_S3_ENDPOINT_URL,
18
+ bucket_name=DIGITALOCEAN_STORAGE_BUCKET_NAME, key=key)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rb-commons
3
- Version: 0.5.13
3
+ Version: 0.5.15
4
4
  Summary: Commons of project and simplified orm based on sqlalchemy.
5
5
  Home-page: https://github.com/RoboSell-organization/rb-commons
6
6
  Author: Abdulvoris
@@ -2,9 +2,11 @@ rb_commons/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  rb_commons/broker/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  rb_commons/broker/consumer.py,sha256=84yLq8kJIGNYAH9_ySSTDpOMNL54NSs3cA8lNG8CTGY,1264
4
4
  rb_commons/configs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
- rb_commons/configs/config.py,sha256=UB-gGq26nkt_L2XSM0RpV58C64T8oaZofdo7-PbwPWc,1535
5
+ rb_commons/configs/config.py,sha256=1XVqxb9QY0E3P3n7vRJF_w238WgRpArfPVcpeT3geUE,1571
6
6
  rb_commons/configs/injections.py,sha256=6B1EOgIGnkWv3UrFaV9PRgG0-CJAbLu1UZ3kq-SjPVU,273
7
7
  rb_commons/configs/rabbitmq.py,sha256=vUqa_PcZkPp1lX0B6HLSAXVMUcPR2_8-8cN-C7xFxRI,741
8
+ rb_commons/configs/v2/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
+ rb_commons/configs/v2/config.py,sha256=kZ02y_HIMD-SXqA990yR1r9qrkpvzwn4Nda6fhVMcmo,1581
8
10
  rb_commons/http/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
11
  rb_commons/http/base_api.py,sha256=Kpr8qSbRtoAqB9oBzXJvZjspJpMoCmq8EDGSrItPFSA,5169
10
12
  rb_commons/http/consul.py,sha256=Ioq72VD1jGwoC96set7n2SgxN40olzI-myA2lwKkYi4,1864
@@ -19,8 +21,8 @@ rb_commons/schemes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuF
19
21
  rb_commons/schemes/jwt.py,sha256=4MLw3J1-LiU2CXIgm0kP1mlGoDmNfMXmj9iav2s-1Iw,2056
20
22
  rb_commons/schemes/pagination.py,sha256=8VZW1wZGJIPR9jEBUgppZUoB4uqP8ORudHkMwvEJSxg,1866
21
23
  rb_commons/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
- rb_commons/utils/media.py,sha256=KNY_9SdRa3Rp7d3B1tZaXkhmzVa65RcS62BYwZP1bVM,332
23
- rb_commons-0.5.13.dist-info/METADATA,sha256=S12_XY8LrZBsTJSD_mkfOCdlH0nWlWLXXQc7Ufu1VwQ,6571
24
- rb_commons-0.5.13.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
25
- rb_commons-0.5.13.dist-info/top_level.txt,sha256=HPx_WAYo3_fbg1WCeGHsz3wPGio1ucbnrlm2lmqlJog,11
26
- rb_commons-0.5.13.dist-info/RECORD,,
24
+ rb_commons/utils/media.py,sha256=J2Zi0J28DhcVQVzt-myNNVuzj9Msaetul53VjZtdDdc,820
25
+ rb_commons-0.5.15.dist-info/METADATA,sha256=SpqJikfOad52mTulqsU3-1xfNDnzz_cekxNyV_w-fH0,6571
26
+ rb_commons-0.5.15.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
27
+ rb_commons-0.5.15.dist-info/top_level.txt,sha256=HPx_WAYo3_fbg1WCeGHsz3wPGio1ucbnrlm2lmqlJog,11
28
+ rb_commons-0.5.15.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.4.0)
2
+ Generator: setuptools (80.7.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5