sysnet-pyutils 1.2.3__py3-none-any.whl → 1.2.5__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,10 +1,13 @@
1
1
  from __future__ import annotations
2
2
 
3
+ import json
4
+ import pprint
3
5
  from datetime import datetime
4
6
  from enum import Enum
5
- from typing import Optional, List, Tuple, Any
7
+ from typing import Optional, List, Tuple, Any, ClassVar, Dict
6
8
 
7
- from pydantic import BaseModel, Field, EmailStr
9
+ from pydantic import BaseModel, Field, EmailStr, StrictStr
10
+ from typing_extensions import Self
8
11
 
9
12
  from sysnet_pyutils.utils import local_now, is_valid_unid, is_valid_pid, is_valid_uuid
10
13
 
@@ -58,6 +61,10 @@ class BaseEnum(str, Enum):
58
61
  def has_value(cls, value):
59
62
  return value in cls._value2member_map_
60
63
 
64
+ @classmethod
65
+ def from_json(cls, json_str: str) -> Self:
66
+ """Create an instance of PersonTypeType from a JSON string"""
67
+ return cls(json.loads(json_str))
61
68
 
62
69
 
63
70
  class AclLevelEnum(BaseEnum):
@@ -66,6 +73,26 @@ class AclLevelEnum(BaseEnum):
66
73
  MANAGE = 'M'
67
74
 
68
75
 
76
+ class PersonTypeEnum(BaseEnum):
77
+ """
78
+ Typ osoby (zdroj CRŽP):
79
+ - legalEntity: tuzemská právnická osoba
80
+ - legalEntityWithoutIco: tuzemská právnická osoba bez IČO
81
+ - foreignLegalEntity: zahraniční právnická osoba
82
+ - businessNaturalPerson: tuzemská fyzická osoba podnikající
83
+ - naturalPerson: tuzemská fyzická osoba nepodnikající
84
+ - foreignNaturalPerson: zahraniční fyzická osoba podnikající
85
+ """
86
+ LEGAL_ENTITY = 'legalEntity'
87
+ LEGAL_ENTITY_WO_ICO = 'legalEntityWithoutIco'
88
+ FOREIGN_LEGAL_ENTITY = 'foreignLegalEntity'
89
+ NATURAL_PERSON = 'naturalPerson'
90
+ BUSINESS_NATURAL_PERSON = 'businessNaturalPerson'
91
+ FOREIGN_NATURAL_PERSON = 'foreignNaturalPerson'
92
+ EMPTY = ''
93
+ NULL = None
94
+
95
+
69
96
  class CodeValueType(BaseModel):
70
97
  # kód/hodnota
71
98
  code: Optional[str] = Field(default=None, description='Kód položky', examples=['CZ'])
@@ -293,3 +320,157 @@ class WorkflowType(BaseModel):
293
320
  executor: Optional[UserType] = Field(default='SYSTEM', description='Uživatel, který provedl událost')
294
321
  status_from: Optional[str] = Field(default=None, description='Předchozí stav')
295
322
  status_to: Optional[str] = Field(default=None, description='Následný stav')
323
+
324
+
325
+ class PhoneNumberType(BaseModel):
326
+ """
327
+ Telefonní číslo
328
+ """ # noqa: E501
329
+ name: Optional[StrictStr] = Field(default=None, description="Název telefonního čísla (mobil, práce, domů)")
330
+ prefix: Optional[StrictStr] = Field(default=None, description="Národní prefix")
331
+ number: Optional[StrictStr] = Field(default=None, description="Vlastní telefonní číslo")
332
+ __properties: ClassVar[List[str]] = ["name", "prefix", "number"]
333
+
334
+ model_config = {
335
+ "populate_by_name": True,
336
+ "validate_assignment": True,
337
+ "protected_namespaces": (),
338
+ }
339
+
340
+
341
+ def to_str(self) -> str:
342
+ """Returns the string representation of the model using alias"""
343
+ return pprint.pformat(self.model_dump(by_alias=True))
344
+
345
+ def to_json(self) -> str:
346
+ """Returns the JSON representation of the model using alias"""
347
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
348
+ return json.dumps(self.to_dict())
349
+
350
+ @classmethod
351
+ def from_json(cls, json_str: str) -> Self:
352
+ """Create an instance of PhoneNumberType from a JSON string"""
353
+ return cls.from_dict(json.loads(json_str))
354
+
355
+ def to_dict(self) -> Dict[str, Any]:
356
+ """Return the dictionary representation of the model using alias.
357
+
358
+ This has the following differences from calling pydantic's
359
+ `self.model_dump(by_alias=True)`:
360
+
361
+ * `None` is only added to the output dict for nullable fields that
362
+ were set at model initialization. Other fields with value `None`
363
+ are ignored.
364
+ """
365
+ _dict = self.model_dump(
366
+ by_alias=True,
367
+ exclude={
368
+ },
369
+ exclude_none=True,
370
+ )
371
+ # set to None if name (nullable) is None
372
+ # and model_fields_set contains the field
373
+ if self.name is None and "name" in self.model_fields_set:
374
+ _dict['name'] = None
375
+
376
+ # set to None if prefix (nullable) is None
377
+ # and model_fields_set contains the field
378
+ if self.prefix is None and "prefix" in self.model_fields_set:
379
+ _dict['prefix'] = None
380
+
381
+ # set to None if number (nullable) is None
382
+ # and model_fields_set contains the field
383
+ if self.number is None and "number" in self.model_fields_set:
384
+ _dict['number'] = None
385
+
386
+ return _dict
387
+
388
+ @classmethod
389
+ def from_dict(cls, obj: Dict) -> Self:
390
+ """Create an instance of PhoneNumberType from a dict"""
391
+ if obj is None:
392
+ return None
393
+
394
+ if not isinstance(obj, dict):
395
+ return cls.model_validate(obj)
396
+
397
+ _obj = cls.model_validate({
398
+ "name": obj.get("name"),
399
+ "prefix": obj.get("prefix"),
400
+ "number": obj.get("number")
401
+ })
402
+ return _obj
403
+
404
+
405
+ class MailAddressType(BaseModel):
406
+ """
407
+ Adresa elektronické pošty
408
+ """ # noqa: E501
409
+ name: Optional[StrictStr] = Field(default=None, description="Název adresa elektronické pošty (práce, domů)")
410
+ email: Optional[StrictStr] = Field(default=None, description="Adresa elektronické pošty")
411
+ __properties: ClassVar[List[str]] = ["name", "email"]
412
+
413
+ model_config = {
414
+ "populate_by_name": True,
415
+ "validate_assignment": True,
416
+ "protected_namespaces": (),
417
+ }
418
+
419
+
420
+ def to_str(self) -> str:
421
+ """Returns the string representation of the model using alias"""
422
+ return pprint.pformat(self.model_dump(by_alias=True))
423
+
424
+ def to_json(self) -> str:
425
+ """Returns the JSON representation of the model using alias"""
426
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
427
+ return json.dumps(self.to_dict())
428
+
429
+ @classmethod
430
+ def from_json(cls, json_str: str) -> Self:
431
+ """Create an instance of MailAddressType from a JSON string"""
432
+ return cls.from_dict(json.loads(json_str))
433
+
434
+ def to_dict(self) -> Dict[str, Any]:
435
+ """Return the dictionary representation of the model using alias.
436
+
437
+ This has the following differences from calling pydantic's
438
+ `self.model_dump(by_alias=True)`:
439
+
440
+ * `None` is only added to the output dict for nullable fields that
441
+ were set at model initialization. Other fields with value `None`
442
+ are ignored.
443
+ """
444
+ _dict = self.model_dump(
445
+ by_alias=True,
446
+ exclude={
447
+ },
448
+ exclude_none=True,
449
+ )
450
+ # set to None if name (nullable) is None
451
+ # and model_fields_set contains the field
452
+ if self.name is None and "name" in self.model_fields_set:
453
+ _dict['name'] = None
454
+
455
+ # set to None if email (nullable) is None
456
+ # and model_fields_set contains the field
457
+ if self.email is None and "email" in self.model_fields_set:
458
+ _dict['email'] = None
459
+
460
+ return _dict
461
+
462
+ @classmethod
463
+ def from_dict(cls, obj: Dict) -> Self:
464
+ """Create an instance of MailAddressType from a dict"""
465
+ if obj is None:
466
+ return None
467
+
468
+ if not isinstance(obj, dict):
469
+ return cls.model_validate(obj)
470
+
471
+ _obj = cls.model_validate({
472
+ "name": obj.get("name"),
473
+ "email": obj.get("email")
474
+ })
475
+ return _obj
476
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sysnet-pyutils
3
- Version: 1.2.3
3
+ Version: 1.2.5
4
4
  Summary: Python Utilities
5
5
  Author-email: Data Developer <info@sysnet.cz>
6
6
  Project-URL: Homepage, https://github.com/SYSNET-CZ/pyutils
@@ -353,3 +353,15 @@ která naplní atribut **identifier** z unid, pid nebo uuid.
353
353
 
354
354
  1. Místo typu `UUID` se v modelu používá pouze `str`. Je tomu tak kvůli ukládání do **MongoDb**.
355
355
  2. Doplněn abstraktní typ `BaseEnum`, který obsahuje metodu `has_value`.
356
+
357
+
358
+ ### verze 1.2.4
359
+
360
+ Z modelu CITES přenesena třída **PersonTypeEnum**
361
+ Typ osoby (zdroj CRŽP):
362
+ - legalEntity: tuzemská právnická osoba
363
+ - legalEntityWithoutIco: tuzemská právnická osoba bez IČO
364
+ - foreignLegalEntity: zahraniční právnická osoba
365
+ - businessNaturalPerson: tuzemská fyzická osoba podnikající
366
+ - naturalPerson: tuzemská fyzická osoba nepodnikající
367
+ - foreignNaturalPerson: zahraniční fyzická osoba podnikající
@@ -9,9 +9,9 @@ sysnet_pyutils/ses.py,sha256=WJzs0y2QnF4XGDGjls_W0p0v6DJ4fZ4_97m3XbzpaFw,2713
9
9
  sysnet_pyutils/tools.py,sha256=ZioHvUIufrhuJyZLdPnuMUD8Li5LTljSMSCxqRnKIi4,377
10
10
  sysnet_pyutils/utils.py,sha256=4dOqlP8JhKaIzWlbYw4PLckBf1SigBJK-MzK1EWTgYk,23523
11
11
  sysnet_pyutils/models/__init__.py,sha256=oozOr_DKhenkM9BDaPOmtbLXhP5vtMUCjBPEjZDW4GQ,167
12
- sysnet_pyutils/models/general.py,sha256=Xe06pfmvcqNJ8AfVuMkF9h_Y81UXmcJYX8R9RrHs8MI,16273
13
- sysnet_pyutils-1.2.3.dist-info/licenses/LICENSE,sha256=bx5iLIKjgAdYQ7sISn7DsfHRKkoCUm1154sJJKhgqnU,35184
14
- sysnet_pyutils-1.2.3.dist-info/METADATA,sha256=OK2O7Ur_J69TJdpUqO9xOO2juCVFuMAnCAaiQzgmHls,15285
15
- sysnet_pyutils-1.2.3.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
16
- sysnet_pyutils-1.2.3.dist-info/top_level.txt,sha256=ZKTltQWbLlWBXw4oovo1w7ui-JQ1WoyECqMSWdBj6XE,15
17
- sysnet_pyutils-1.2.3.dist-info/RECORD,,
12
+ sysnet_pyutils/models/general.py,sha256=ZN7DUM_1Pnu--Rre22qqrygWnD_RAxR-gEn5a-hIs4k,22588
13
+ sysnet_pyutils-1.2.5.dist-info/licenses/LICENSE,sha256=bx5iLIKjgAdYQ7sISn7DsfHRKkoCUm1154sJJKhgqnU,35184
14
+ sysnet_pyutils-1.2.5.dist-info/METADATA,sha256=RPOygEMyUmGgzJiYkvzGuZu4C2pAUvumB6IkRH7KdnI,15747
15
+ sysnet_pyutils-1.2.5.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
16
+ sysnet_pyutils-1.2.5.dist-info/top_level.txt,sha256=ZKTltQWbLlWBXw4oovo1w7ui-JQ1WoyECqMSWdBj6XE,15
17
+ sysnet_pyutils-1.2.5.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (79.0.1)
2
+ Generator: setuptools (80.3.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5