python-sdk-remote 0.0.180b126__tar.gz → 0.0.180b127__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. {python_sdk_remote-0.0.180b126 → python_sdk_remote-0.0.180b127}/PKG-INFO +2 -2
  2. {python_sdk_remote-0.0.180b126 → python_sdk_remote-0.0.180b127}/pyproject.toml +1 -1
  3. python_sdk_remote-0.0.180b126/python_sdk_remote/src/exceptions.py → python_sdk_remote-0.0.180b127/python_sdk_remote/src/environment_variable_exception.py +0 -1
  4. python_sdk_remote-0.0.180b127/python_sdk_remote/src/filename.py +82 -0
  5. {python_sdk_remote-0.0.180b126 → python_sdk_remote-0.0.180b127}/python_sdk_remote/src/utilities.py +1 -1
  6. {python_sdk_remote-0.0.180b126 → python_sdk_remote-0.0.180b127}/python_sdk_remote.egg-info/PKG-INFO +2 -2
  7. {python_sdk_remote-0.0.180b126 → python_sdk_remote-0.0.180b127}/python_sdk_remote.egg-info/SOURCES.txt +2 -1
  8. {python_sdk_remote-0.0.180b126 → python_sdk_remote-0.0.180b127}/setup.py +3 -3
  9. {python_sdk_remote-0.0.180b126 → python_sdk_remote-0.0.180b127}/README.md +0 -0
  10. {python_sdk_remote-0.0.180b126 → python_sdk_remote-0.0.180b127}/python_sdk_remote/src/__init__.py +0 -0
  11. {python_sdk_remote-0.0.180b126 → python_sdk_remote-0.0.180b127}/python_sdk_remote/src/constants.py +0 -0
  12. {python_sdk_remote-0.0.180b126 → python_sdk_remote-0.0.180b127}/python_sdk_remote/src/constants_src_mini_logger_and_logger.py +0 -0
  13. {python_sdk_remote-0.0.180b126 → python_sdk_remote-0.0.180b127}/python_sdk_remote/src/datetime_range.py +0 -0
  14. {python_sdk_remote-0.0.180b126 → python_sdk_remote-0.0.180b127}/python_sdk_remote/src/generic_crud.py +0 -0
  15. {python_sdk_remote-0.0.180b126 → python_sdk_remote-0.0.180b127}/python_sdk_remote/src/http_response.py +0 -0
  16. {python_sdk_remote-0.0.180b126 → python_sdk_remote-0.0.180b127}/python_sdk_remote/src/is_test_data.py +0 -0
  17. {python_sdk_remote-0.0.180b126 → python_sdk_remote-0.0.180b127}/python_sdk_remote/src/item.py +0 -0
  18. {python_sdk_remote-0.0.180b126 → python_sdk_remote-0.0.180b127}/python_sdk_remote/src/mini_logger.py +0 -0
  19. {python_sdk_remote-0.0.180b126 → python_sdk_remote-0.0.180b127}/python_sdk_remote/src/our_obfuscation.py +0 -0
  20. {python_sdk_remote-0.0.180b126 → python_sdk_remote-0.0.180b127}/python_sdk_remote/src/our_object.py +0 -0
  21. {python_sdk_remote-0.0.180b126 → python_sdk_remote-0.0.180b127}/python_sdk_remote/src/our_objects.py +0 -0
  22. {python_sdk_remote-0.0.180b126 → python_sdk_remote-0.0.180b127}/python_sdk_remote/src/our_objects_local.py +0 -0
  23. {python_sdk_remote-0.0.180b126 → python_sdk_remote-0.0.180b127}/python_sdk_remote/src/our_objects_remote.py +0 -0
  24. {python_sdk_remote-0.0.180b126 → python_sdk_remote-0.0.180b127}/python_sdk_remote/src/our_request.py +0 -0
  25. {python_sdk_remote-0.0.180b126 → python_sdk_remote-0.0.180b127}/python_sdk_remote/src/our_request_old.py +0 -0
  26. {python_sdk_remote-0.0.180b126 → python_sdk_remote-0.0.180b127}/python_sdk_remote/src/unified_json.py +0 -0
  27. {python_sdk_remote-0.0.180b126 → python_sdk_remote-0.0.180b127}/python_sdk_remote/src/valid_json_versions.py +0 -0
  28. {python_sdk_remote-0.0.180b126 → python_sdk_remote-0.0.180b127}/python_sdk_remote/src/validate_environment.py +0 -0
  29. {python_sdk_remote-0.0.180b126 → python_sdk_remote-0.0.180b127}/python_sdk_remote/src/version.py +0 -0
  30. {python_sdk_remote-0.0.180b126 → python_sdk_remote-0.0.180b127}/python_sdk_remote.egg-info/dependency_links.txt +0 -0
  31. {python_sdk_remote-0.0.180b126 → python_sdk_remote-0.0.180b127}/python_sdk_remote.egg-info/requires.txt +0 -0
  32. {python_sdk_remote-0.0.180b126 → python_sdk_remote-0.0.180b127}/python_sdk_remote.egg-info/top_level.txt +0 -0
  33. {python_sdk_remote-0.0.180b126 → python_sdk_remote-0.0.180b127}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-sdk-remote
3
- Version: 0.0.180b126
3
+ Version: 0.0.180b127
4
4
  Summary: PyPI Package for Circles Python SDK Local Python
5
5
  Home-page: https://github.com/circles-zone/python-sdk-remote-python-package
6
6
  Author: Circles
@@ -22,4 +22,4 @@ Dynamic: home-page
22
22
  Dynamic: requires-dist
23
23
  Dynamic: summary
24
24
 
25
- This is a package for sharing common functions used in different repositories
25
+ This is a package for sharing common functions used in different repositories.
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [tool.poetry]
6
6
  name = "python-sdk-local"
7
- version = "0.0.75" # https://pypi.org/project/python-sdk-local
7
+ version = "0.0.76" # https://pypi.org/project/python-sdk-local
8
8
  description = "python-sdk-local Python Package"
9
9
  readme = "README.md"
10
10
  authors = [
@@ -1,4 +1,3 @@
1
- # TODO Rename the file to environment_variable_exception.py
2
1
  class EnvironmentVariableException(Exception):
3
2
  """Raised when a required environment variable is missing or empty.
4
3
 
@@ -0,0 +1,82 @@
1
+ import re
2
+ import unicodedata
3
+
4
+ # Characters that are illegal in filenames on Windows / most filesystems,
5
+ # plus the ASCII control characters (0x00-0x1F).
6
+ _INVALID_CHARS_PATTERN = re.compile(r'[<>:"/\\|?*\x00-\x1f]')
7
+ _WHITESPACE_PATTERN = re.compile(r'\s+')
8
+
9
+ # Names reserved by Windows (case-insensitive), with or without an extension.
10
+ _RESERVED_NAMES = {
11
+ "CON", "PRN", "AUX", "NUL",
12
+ *(f"COM{i}" for i in range(1, 10)),
13
+ *(f"LPT{i}" for i in range(1, 10)),
14
+ }
15
+
16
+ MAX_FILENAME_LENGTH = 255
17
+
18
+
19
+ def convert_to_valid_filename(
20
+ string: str,
21
+ replacement: str = "_",
22
+ max_length: int = MAX_FILENAME_LENGTH,
23
+ fallback: str = "file",
24
+ ) -> str:
25
+ """Convert an arbitrary string into a filename that is safe to use across
26
+ Windows, macOS and Linux.
27
+
28
+ - Normalises unicode and collapses runs of whitespace into ``replacement``.
29
+ - Replaces characters that are illegal on common filesystems.
30
+ - Strips leading/trailing dots, spaces and ``replacement`` characters.
31
+ - Avoids Windows reserved device names (CON, NUL, COM1, ...).
32
+ - Truncates to ``max_length`` characters while keeping the extension.
33
+ - Returns ``fallback`` when nothing usable remains.
34
+ """
35
+ if not isinstance(string, str):
36
+ string = str(string)
37
+
38
+ filename = unicodedata.normalize("NFKC", string)
39
+ filename = _INVALID_CHARS_PATTERN.sub(replacement, filename)
40
+ filename = _WHITESPACE_PATTERN.sub(replacement, filename)
41
+
42
+ # Trim characters that are problematic at the edges of a filename,
43
+ # repeating until stable so e.g. "_.._" collapses fully.
44
+ edge_chars = " .\t\n\r\f\v" + (replacement or "")
45
+ previous = None
46
+ while filename != previous:
47
+ previous = filename
48
+ filename = filename.strip(edge_chars)
49
+
50
+ if not filename:
51
+ return fallback
52
+
53
+ root, dot, extension = filename.partition(".")
54
+ if root.upper() in _RESERVED_NAMES:
55
+ root = f"{root}{replacement}"
56
+ filename = root + dot + extension
57
+
58
+ if len(filename) > max_length:
59
+ root, dot, extension = filename.rpartition(".")
60
+ if dot and len(extension) < max_length:
61
+ keep = max_length - len(dot) - len(extension)
62
+ filename = root[:keep] + dot + extension
63
+ else:
64
+ filename = filename[:max_length]
65
+ filename = filename.strip(" .")
66
+
67
+ return filename or fallback
68
+
69
+ # def convert_to_valid_filename(name: str) -> str:
70
+ # """Reduce ``name`` to characters that are safe for a single path component.
71
+
72
+ # Every run of characters outside ``[A-Za-z0-9._-]`` (path separators,
73
+ # whitespace, shell metacharacters, ...) collapses to a single underscore and
74
+ # leading / trailing ``.``, ``-`` and ``_`` are trimmed. A falsy input or one
75
+ # that is left empty after sanitising yields ``"unnamed"`` so a usable name is
76
+ # always returned.
77
+ # """
78
+ # if not name:
79
+ # return _FALLBACK_FILENAME
80
+ # sanitized = _INVALID_FILENAME_CHARACTERS_PATTERN.sub("_", str(name))
81
+ # sanitized = sanitized.strip("._-")
82
+ # return sanitized or _FALLBACK_FILENAME
@@ -17,7 +17,7 @@ from .version import PACKAGE_VERSION
17
17
 
18
18
  from .mini_logger import MiniLogger as logger
19
19
 
20
- from .exceptions import EnvironmentVariableException
20
+ from .environment_variable_exception import EnvironmentVariableException
21
21
 
22
22
  load_dotenv()
23
23
  # Load environment variables from .env file
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-sdk-remote
3
- Version: 0.0.180b126
3
+ Version: 0.0.180b127
4
4
  Summary: PyPI Package for Circles Python SDK Local Python
5
5
  Home-page: https://github.com/circles-zone/python-sdk-remote-python-package
6
6
  Author: Circles
@@ -22,4 +22,4 @@ Dynamic: home-page
22
22
  Dynamic: requires-dist
23
23
  Dynamic: summary
24
24
 
25
- This is a package for sharing common functions used in different repositories
25
+ This is a package for sharing common functions used in different repositories.
@@ -10,7 +10,8 @@ python_sdk_remote/src/__init__.py
10
10
  python_sdk_remote/src/constants.py
11
11
  python_sdk_remote/src/constants_src_mini_logger_and_logger.py
12
12
  python_sdk_remote/src/datetime_range.py
13
- python_sdk_remote/src/exceptions.py
13
+ python_sdk_remote/src/environment_variable_exception.py
14
+ python_sdk_remote/src/filename.py
14
15
  python_sdk_remote/src/generic_crud.py
15
16
  python_sdk_remote/src/http_response.py
16
17
  python_sdk_remote/src/is_test_data.py
@@ -7,11 +7,11 @@ package_dir = PACKAGE_NAME.replace("-", "_")
7
7
  # python -m build needs pyproject.toml or setup.py
8
8
  setuptools.setup(
9
9
  name=PACKAGE_NAME,
10
- version='0.0.180b126', # https://pypi.org/project/python-sdk-remote#history
10
+ version='0.0.180b127', # https://pypi.org/project/python-sdk-remote#history
11
11
  author="Circles",
12
12
  author_email="info@circlez.ai",
13
13
  description="PyPI Package for Circles Python SDK Local Python",
14
- long_description="This is a package for sharing common functions used in different repositories",
14
+ long_description="This is a package for sharing common functions used in different repositories.",
15
15
  long_description_content_type="text/markdown",
16
16
  url=f"https://github.com/circles-zone/{PACKAGE_NAME}-python-package",
17
17
  packages=[package_dir],
@@ -30,7 +30,7 @@ setuptools.setup(
30
30
  "pyjwt",
31
31
  # OurObject lives here now. item.py and __init__.py import it from this
32
32
  # package directly; our_object.py is a temporary deprecated re-export kept
33
- # for consumers still on `from python_sdk_remote.our_object import OurObject`.
33
+ # for consumers still on `from python_sdk_remote.our_object import OurObject.
34
34
  "our-object-local",
35
35
  ]
36
36
  )