talentro-commons 0.19.9__tar.gz → 0.19.11__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.
- {talentro_commons-0.19.9 → talentro_commons-0.19.11}/PKG-INFO +1 -1
- {talentro_commons-0.19.9 → talentro_commons-0.19.11}/pyproject.toml +1 -1
- {talentro_commons-0.19.9 → talentro_commons-0.19.11}/src/talentro/services/google_storage.py +23 -10
- {talentro_commons-0.19.9 → talentro_commons-0.19.11}/src/talentro/util/string.py +7 -1
- {talentro_commons-0.19.9 → talentro_commons-0.19.11}/README.md +0 -0
- {talentro_commons-0.19.9 → talentro_commons-0.19.11}/src/talentro/__init__.py +0 -0
- {talentro_commons-0.19.9 → talentro_commons-0.19.11}/src/talentro/acquisition/__init__.py +0 -0
- {talentro_commons-0.19.9 → talentro_commons-0.19.11}/src/talentro/acquisition/dataclasses.py +0 -0
- {talentro_commons-0.19.9 → talentro_commons-0.19.11}/src/talentro/acquisition/models.py +0 -0
- {talentro_commons-0.19.9 → talentro_commons-0.19.11}/src/talentro/billing/__init__.py +0 -0
- {talentro_commons-0.19.9 → talentro_commons-0.19.11}/src/talentro/billing/dataclasses.py +0 -0
- {talentro_commons-0.19.9 → talentro_commons-0.19.11}/src/talentro/billing/models.py +0 -0
- {talentro_commons-0.19.9 → talentro_commons-0.19.11}/src/talentro/candidates/__init__.py +0 -0
- {talentro_commons-0.19.9 → talentro_commons-0.19.11}/src/talentro/candidates/dataclasses.py +0 -0
- {talentro_commons-0.19.9 → talentro_commons-0.19.11}/src/talentro/candidates/models.py +0 -0
- {talentro_commons-0.19.9 → talentro_commons-0.19.11}/src/talentro/constants.py +0 -0
- {talentro_commons-0.19.9 → talentro_commons-0.19.11}/src/talentro/event.py +0 -0
- {talentro_commons-0.19.9 → talentro_commons-0.19.11}/src/talentro/exceptions.py +0 -0
- {talentro_commons-0.19.9 → talentro_commons-0.19.11}/src/talentro/general/__init__.py +0 -0
- {talentro_commons-0.19.9 → talentro_commons-0.19.11}/src/talentro/general/dataclasses.py +0 -0
- {talentro_commons-0.19.9 → talentro_commons-0.19.11}/src/talentro/general/models.py +0 -0
- {talentro_commons-0.19.9 → talentro_commons-0.19.11}/src/talentro/iam/__init__.py +0 -0
- {talentro_commons-0.19.9 → talentro_commons-0.19.11}/src/talentro/iam/dataclasses.py +0 -0
- {talentro_commons-0.19.9 → talentro_commons-0.19.11}/src/talentro/iam/models.py +0 -0
- {talentro_commons-0.19.9 → talentro_commons-0.19.11}/src/talentro/iam/types.py +0 -0
- {talentro_commons-0.19.9 → talentro_commons-0.19.11}/src/talentro/integrations/__init__.py +0 -0
- {talentro_commons-0.19.9 → talentro_commons-0.19.11}/src/talentro/integrations/dataclasses.py +0 -0
- {talentro_commons-0.19.9 → talentro_commons-0.19.11}/src/talentro/integrations/models.py +0 -0
- {talentro_commons-0.19.9 → talentro_commons-0.19.11}/src/talentro/services/__init__.py +0 -0
- {talentro_commons-0.19.9 → talentro_commons-0.19.11}/src/talentro/services/billing.py +0 -0
- {talentro_commons-0.19.9 → talentro_commons-0.19.11}/src/talentro/services/caching.py +0 -0
- {talentro_commons-0.19.9 → talentro_commons-0.19.11}/src/talentro/services/clients.py +0 -0
- {talentro_commons-0.19.9 → talentro_commons-0.19.11}/src/talentro/services/db.py +0 -0
- {talentro_commons-0.19.9 → talentro_commons-0.19.11}/src/talentro/services/rabbitmq.py +0 -0
- {talentro_commons-0.19.9 → talentro_commons-0.19.11}/src/talentro/util/__init__.py +0 -0
- {talentro_commons-0.19.9 → talentro_commons-0.19.11}/src/talentro/util/attributes.py +0 -0
- {talentro_commons-0.19.9 → talentro_commons-0.19.11}/src/talentro/util/enum.py +0 -0
- {talentro_commons-0.19.9 → talentro_commons-0.19.11}/src/talentro/util/files.py +0 -0
- {talentro_commons-0.19.9 → talentro_commons-0.19.11}/src/talentro/util/singleton.py +0 -0
- {talentro_commons-0.19.9 → talentro_commons-0.19.11}/src/talentro/util/vacancy.py +0 -0
- {talentro_commons-0.19.9 → talentro_commons-0.19.11}/src/talentro/vacancies/__init__.py +0 -0
- {talentro_commons-0.19.9 → talentro_commons-0.19.11}/src/talentro/vacancies/dataclasses.py +0 -0
- {talentro_commons-0.19.9 → talentro_commons-0.19.11}/src/talentro/vacancies/models.py +0 -0
- {talentro_commons-0.19.9 → talentro_commons-0.19.11}/src/talentro/vacancies/taxanomy.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "talentro-commons"
|
|
3
|
-
version = "0.19.
|
|
3
|
+
version = "0.19.11"
|
|
4
4
|
description = "This package contains all globally used code, services, models and data structures for Talentro"
|
|
5
5
|
authors = ["Emiel van Essen <emiel@marksmen.nl>"]
|
|
6
6
|
license = "Proprietary"
|
{talentro_commons-0.19.9 → talentro_commons-0.19.11}/src/talentro/services/google_storage.py
RENAMED
|
@@ -6,8 +6,8 @@ from enum import StrEnum
|
|
|
6
6
|
from http import HTTPStatus
|
|
7
7
|
|
|
8
8
|
from fastapi import UploadFile
|
|
9
|
-
from google.api_core.exceptions import NotFound
|
|
10
9
|
from google.cloud import storage
|
|
10
|
+
from google.cloud.exceptions import NotFound
|
|
11
11
|
from google.cloud.storage import Bucket, Blob
|
|
12
12
|
from talentro.constants import ErrorCode, DisplayMessage
|
|
13
13
|
from talentro.exceptions import APIException
|
|
@@ -18,24 +18,35 @@ from ..util.string import render_template_path
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
class BucketEnum(StrEnum):
|
|
21
|
-
PUBLIC = "
|
|
22
|
-
BILLING = "
|
|
23
|
-
CANDIDATES = "
|
|
21
|
+
PUBLIC = "static"
|
|
22
|
+
BILLING = "billing"
|
|
23
|
+
CANDIDATES = "candidates"
|
|
24
|
+
SYSTEM = "system"
|
|
24
25
|
|
|
25
26
|
|
|
26
27
|
class FilePathEnum(StrEnum):
|
|
27
28
|
IAM_ORGANIZATION_LOGO = "iam/organizations/{organization_id}/details/logo.{extension}"
|
|
28
29
|
IAM_PROFILE_PICTURE = "iam/users/{user_id}/profile/profile_picture.{extension}"
|
|
30
|
+
|
|
31
|
+
# Candidates
|
|
29
32
|
CANDIDATES_CANDIDATE_CV_FILE = "organizations/{organization_id}/cand_{candidate_id}/cv/{file_name}"
|
|
30
33
|
CANDIDATES_CANDIDATE_CV_FOLDER = "organizations/{organization_id}/cand_{candidate_id}/cv/"
|
|
31
34
|
|
|
35
|
+
# DPG
|
|
36
|
+
SYSTEM_DPG_SYNC = "dpg/last_sync.txt"
|
|
37
|
+
|
|
32
38
|
|
|
33
39
|
class GoogleStorage(metaclass=SingletonMeta):
|
|
34
40
|
|
|
35
41
|
def __init__(self):
|
|
36
42
|
self._client = storage.Client()
|
|
43
|
+
self.env = os.getenv("ENVIRONMENT")
|
|
37
44
|
|
|
38
|
-
|
|
45
|
+
if not self.env:
|
|
46
|
+
raise Exception("Environment variable ENVIRONMENT is not set.")
|
|
47
|
+
|
|
48
|
+
def upload_base64_to_gcs(self, file: FileData, bucket: BucketEnum, destination: FilePathEnum,
|
|
49
|
+
path_definitions: dict | None = None) -> Blob:
|
|
39
50
|
file_bytes = base64.b64decode(file.data)
|
|
40
51
|
|
|
41
52
|
_, ext = os.path.splitext(file.file_name)
|
|
@@ -49,7 +60,7 @@ class GoogleStorage(metaclass=SingletonMeta):
|
|
|
49
60
|
|
|
50
61
|
blob.upload_from_filename(
|
|
51
62
|
tmp_path,
|
|
52
|
-
content_type=file.content_type #
|
|
63
|
+
content_type=file.content_type # Handig voor GCS metadata
|
|
53
64
|
)
|
|
54
65
|
|
|
55
66
|
if os.path.exists(tmp_path):
|
|
@@ -59,14 +70,15 @@ class GoogleStorage(metaclass=SingletonMeta):
|
|
|
59
70
|
|
|
60
71
|
def _get_bucket(self, bucket: BucketEnum) -> Bucket:
|
|
61
72
|
try:
|
|
62
|
-
bucket = self._client.get_bucket(bucket.value)
|
|
73
|
+
bucket = self._client.get_bucket(f"talentro-{self.env}-{bucket.value}")
|
|
63
74
|
except NotFound:
|
|
64
|
-
print("Bucket not found
|
|
75
|
+
print(f"Bucket {bucket.value} not found, creating...")
|
|
65
76
|
bucket = self._client.create_bucket(bucket.value)
|
|
66
77
|
|
|
67
78
|
return bucket
|
|
68
79
|
|
|
69
|
-
def _get_blob(self, bucket: BucketEnum, destination: FilePathEnum, path_definitions: dict):
|
|
80
|
+
def _get_blob(self, bucket: BucketEnum, destination: FilePathEnum, path_definitions: dict | None = None):
|
|
81
|
+
|
|
70
82
|
bucket = self._get_bucket(bucket)
|
|
71
83
|
|
|
72
84
|
try:
|
|
@@ -118,7 +130,8 @@ class GoogleStorage(metaclass=SingletonMeta):
|
|
|
118
130
|
traceback.print_exc()
|
|
119
131
|
return False
|
|
120
132
|
|
|
121
|
-
def upload_file(self, file: UploadFile, bucket: BucketEnum, destination: FilePathEnum,
|
|
133
|
+
def upload_file(self, file: UploadFile, bucket: BucketEnum, destination: FilePathEnum,
|
|
134
|
+
path_definitions: dict) -> Blob:
|
|
122
135
|
"""
|
|
123
136
|
Uploads a file to Google Storage
|
|
124
137
|
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import string
|
|
2
2
|
|
|
3
|
-
def render_template_path(template: str, values: dict) -> str:
|
|
3
|
+
def render_template_path(template: str, values: dict | None) -> str:
|
|
4
4
|
formatter = string.Formatter()
|
|
5
5
|
|
|
6
6
|
required_fields = [field for _, field, _, _ in formatter.parse(template) if field]
|
|
7
7
|
|
|
8
|
+
if required_fields is None or required_fields is []:
|
|
9
|
+
return template
|
|
10
|
+
|
|
11
|
+
if not values:
|
|
12
|
+
raise ValueError(f"Values are expected but not set")
|
|
13
|
+
|
|
8
14
|
missing = [field for field in required_fields if field not in values]
|
|
9
15
|
|
|
10
16
|
if missing:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{talentro_commons-0.19.9 → talentro_commons-0.19.11}/src/talentro/acquisition/dataclasses.py
RENAMED
|
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
|
{talentro_commons-0.19.9 → talentro_commons-0.19.11}/src/talentro/integrations/dataclasses.py
RENAMED
|
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
|