Compare commits

..

2 commits

3 changed files with 15 additions and 16 deletions

View file

@ -1,6 +1,6 @@
"""Elytra PIM Client - A Pythonic client for the Elytra PIM API""" """Elytra PIM Client - A Pythonic client for the Elytra PIM API"""
__version__ = "0.3.0" __version__ = "0.5.0"
__author__ = "Your Name" __author__ = "Your Name"
from . import rest_api from . import rest_api

View file

@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project] [project]
name = "elytra-pim-client" name = "elytra-pim-client"
version = "0.3.0" version = "0.5.0"
description = "A Pythonic client for the Elytra PIM API" description = "A Pythonic client for the Elytra PIM API"
readme = "README.md" readme = "README.md"
requires-python = ">=3.9" requires-python = ">=3.9"
@ -44,8 +44,8 @@ Repository = "https://git.him-tools.de/HIM-public/elytra_client.git"
Documentation = "https://www.elytra.ch/" Documentation = "https://www.elytra.ch/"
Issues = "https://git.him-tools.de/HIM-public/elytra_client/issues" Issues = "https://git.him-tools.de/HIM-public/elytra_client/issues"
[tool.setuptools] [tool.setuptools.packages.find]
packages = ["elytra_client"] include = ["elytra_client*"]
[tool.black] [tool.black]
line-length = 100 line-length = 100

View file

@ -27,24 +27,28 @@ def validate_version(version: str) -> bool:
Returns: Returns:
True if valid, False otherwise True if valid, False otherwise
""" """
pattern = r'^\d+\.\d+\.\d+(?:-[a-zA-Z0-9]+)?$' pattern = r"^\d+\.\d+\.\d+(?:-[a-zA-Z0-9]+)?$"
return bool(re.match(pattern, version)) return bool(re.match(pattern, version))
def update_file(file_path: Path, old_pattern: str, new_version: str) -> bool: def update_file(
file_path: Path, old_pattern: str, new_version: str, multiline: bool = False
) -> bool:
"""Update version in a file. """Update version in a file.
Args: Args:
file_path: Path to file to update file_path: Path to file to update
old_pattern: Regex pattern to find version old_pattern: Regex pattern to find version
new_version: New version string new_version: New version string
multiline: Whether to use multiline mode for regex
Returns: Returns:
True if successful, False otherwise True if successful, False otherwise
""" """
try: try:
content = file_path.read_text() content = file_path.read_text()
updated_content = re.sub(old_pattern, new_version, content) flags = re.MULTILINE if multiline else 0
updated_content = re.sub(old_pattern, new_version, content, flags=flags)
if content == updated_content: if content == updated_content:
print(f"{file_path.name} already up-to-date") print(f"{file_path.name} already up-to-date")
@ -89,11 +93,10 @@ def main() -> int:
# Update pyproject.toml # Update pyproject.toml
if pyproject_path.exists(): if pyproject_path.exists():
pattern = r'version = "[^"]+"' # Use word boundary to match 'version' but not 'python_version'
pattern = r'^version = "[^"]+"'
success &= update_file( success &= update_file(
pyproject_path, pyproject_path, pattern, f'version = "{new_version}"', multiline=True
pattern,
f'version = "{new_version}"'
) )
else: else:
print(f"{pyproject_path} not found") print(f"{pyproject_path} not found")
@ -102,11 +105,7 @@ def main() -> int:
# Update __init__.py # Update __init__.py
if init_path.exists(): if init_path.exists():
pattern = r'__version__ = "[^"]+"' pattern = r'__version__ = "[^"]+"'
success &= update_file( success &= update_file(init_path, pattern, f'__version__ = "{new_version}"')
init_path,
pattern,
f'__version__ = "{new_version}"'
)
else: else:
print(f"{init_path} not found") print(f"{init_path} not found")
success = False success = False