Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ about: Create a report to help us improve
title: ''
labels: bug
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

Expand Down
2 changes: 0 additions & 2 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Expand Down
16 changes: 8 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v6.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files

- repo: https://github.com/psf/black
rev: 23.3.0
rev: 25.1.0
hooks:
- id: black

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.5.1
rev: v1.17.1
hooks:
- id: mypy
additional_dependencies:
Expand All @@ -24,29 +24,29 @@ repos:


- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.0.289"
rev: "v0.12.8"
hooks:
- id: ruff

- repo: https://github.com/python-poetry/poetry
rev: "1.6.1" # Keep this version synced with POETRY_VERSION in check_code.yml
rev: "2.1.3" # Keep this version synced with POETRY_VERSION in check_code.yml
hooks:
- id: poetry-check

- repo: https://github.com/Lucas-C/pre-commit-hooks-nodejs
rev: v1.1.0
rev: v1.1.2
hooks:
- id: markdown-toc

- repo: https://github.com/compilerla/conventional-pre-commit
rev: "v2.3.0"
rev: "v4.2.0"
hooks:
- id: conventional-pre-commit
stages: [commit-msg]
args: []

- repo: https://github.com/PyCQA/bandit
rev: '1.7.4'
rev: '1.8.6'
hooks:
- id: bandit
args: ["-c", "pyproject.toml"]
Expand Down
754 changes: 16 additions & 738 deletions poetry.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions pyartifactory/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Import all object definitions here.
"""

from __future__ import annotations

import contextlib
Expand Down
1 change: 1 addition & 0 deletions pyartifactory/exception.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Definition of all exceptions.
"""

from __future__ import annotations


Expand Down
1 change: 1 addition & 0 deletions pyartifactory/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Import all models here.
"""

from __future__ import annotations

from typing import Union
Expand Down
1 change: 1 addition & 0 deletions pyartifactory/models/artifact.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Definition of all artifact models.
"""

from __future__ import annotations

import hashlib
Expand Down
1 change: 1 addition & 0 deletions pyartifactory/models/auth.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Definition of all auth models.
"""

from __future__ import annotations

from typing import Optional, Tuple, Union
Expand Down
1 change: 1 addition & 0 deletions pyartifactory/models/build.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Definition of all build models.
"""

from __future__ import annotations

from typing import Dict, List, Optional
Expand Down
1 change: 1 addition & 0 deletions pyartifactory/models/group.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Definition of all group models.
"""

from __future__ import annotations

from typing import List, Optional
Expand Down
1 change: 1 addition & 0 deletions pyartifactory/models/permission.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Definition of all permission models.
"""

from __future__ import annotations

from enum import Enum
Expand Down
1 change: 1 addition & 0 deletions pyartifactory/models/repository.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Definition of all repository models.
"""

from __future__ import annotations

from enum import Enum
Expand Down
1 change: 1 addition & 0 deletions pyartifactory/models/user.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Definition of all user related models.
"""

from __future__ import annotations

from datetime import datetime
Expand Down
25 changes: 19 additions & 6 deletions pyartifactory/objects/artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ def _download(self, artifact_path: str, local_directory_path: Optional[Path] = N
:param local_directory_path: Local path to where the artifact will be downloaded
:return: File name
"""
artifact_path = artifact_path.lstrip("/")
local_filename = artifact_path.split("/")[-1]

if local_directory_path:
Expand All @@ -160,14 +159,28 @@ def _download(self, artifact_path: str, local_directory_path: Optional[Path] = N
else:
local_file_full_path = Path(local_filename)

artifact_path_url = urllib.parse.quote(artifact_path)
with self._get(f"{artifact_path_url}", stream=True) as response, local_file_full_path.open("wb") as file:
for chunk in response.iter_content(chunk_size=8192):
if chunk: # filter out keep-alive new chunks
file.write(chunk)
with local_file_full_path.open("wb") as file:
for chunk in self.stream(artifact_path):
file.write(chunk)
logger.debug("Artifact %s successfully downloaded", local_filename)
return local_file_full_path

def stream(self, artifact_path: str, chunk_size: int = 8192) -> Iterator[bytes]:
"""
Open an Iterator stream of an artifact (file).
:param artifact_path: Path to file in Artifactory
:param chunk_size: Size of bytes in a chunk
:return: Iterator of byte chunks
"""
artifact_path = artifact_path.lstrip("/")

artifact_path_url = urllib.parse.quote(artifact_path)
# Filter out keep-alive new chunks with a filter function
return filter(
lambda chunk: chunk,
self._get(f"{artifact_path_url}", stream=True).iter_content(chunk_size=chunk_size),
)

def download(self, artifact_path: str, local_directory_path: str = ".") -> Path:
"""
Download artifact (file or directory) into local directory.
Expand Down
1 change: 1 addition & 0 deletions pyartifactory/objects/object.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Definition of artifactory base object.
"""

from __future__ import annotations

from typing import Optional, Tuple
Expand Down
12 changes: 4 additions & 8 deletions pyartifactory/objects/permission.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,13 @@ def __init__(self, artifactory: AuthModel) -> None:
def create(
self,
permission: Permission,
) -> Permission:
...
) -> Permission: ...

@overload
def create(
self,
permission: PermissionV2,
) -> PermissionV2:
...
) -> PermissionV2: ...

def create(self, permission: AnyPermission) -> AnyPermission:
"""
Expand Down Expand Up @@ -87,12 +85,10 @@ def list(self) -> List[SimplePermission]:
return [SimplePermission(**permission) for permission in response.json()]

@overload
def update(self, permission: Permission) -> Permission:
...
def update(self, permission: Permission) -> Permission: ...

@overload
def update(self, permission: PermissionV2) -> PermissionV2:
...
def update(self, permission: PermissionV2) -> PermissionV2: ...

def update(self, permission: AnyPermission) -> AnyPermission:
"""
Expand Down
24 changes: 8 additions & 16 deletions pyartifactory/objects/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,16 @@ def get_repo(self, repo_name: str) -> AnyRepositoryResponse:
raise ArtifactoryError from error

@overload
def create_repo(self, repo: LocalRepository) -> LocalRepositoryResponse:
...
def create_repo(self, repo: LocalRepository) -> LocalRepositoryResponse: ...

@overload
def create_repo(self, repo: VirtualRepository) -> VirtualRepositoryResponse:
...
def create_repo(self, repo: VirtualRepository) -> VirtualRepositoryResponse: ...

@overload
def create_repo(self, repo: RemoteRepository) -> RemoteRepositoryResponse:
...
def create_repo(self, repo: RemoteRepository) -> RemoteRepositoryResponse: ...

@overload
def create_repo(self, repo: FederatedRepository) -> FederatedRepositoryResponse:
...
def create_repo(self, repo: FederatedRepository) -> FederatedRepositoryResponse: ...

def create_repo(
self,
Expand Down Expand Up @@ -112,20 +108,16 @@ def create_repo(
return self.get_repo(repo_name)

@overload
def update_repo(self, repo: LocalRepository) -> LocalRepositoryResponse:
...
def update_repo(self, repo: LocalRepository) -> LocalRepositoryResponse: ...

@overload
def update_repo(self, repo: VirtualRepository) -> VirtualRepositoryResponse:
...
def update_repo(self, repo: VirtualRepository) -> VirtualRepositoryResponse: ...

@overload
def update_repo(self, repo: RemoteRepository) -> RemoteRepositoryResponse:
...
def update_repo(self, repo: RemoteRepository) -> RemoteRepositoryResponse: ...

@overload
def update_repo(self, repo: FederatedRepository) -> FederatedRepositoryResponse:
...
def update_repo(self, repo: FederatedRepository) -> FederatedRepositoryResponse: ...

def update_repo(
self,
Expand Down
1 change: 1 addition & 0 deletions pyartifactory/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Definition of all utils.
"""

from __future__ import annotations

from typing import Any
Expand Down
66 changes: 34 additions & 32 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
[tool.poetry]
[project]
name = "PyArtifactory"
version = "2.10.0"
description = "Typed interactions with the Jfrog Artifactory REST API"
authors = [
"Ananias CARVALHO <carvalhoananias@hotmail.com>",
"Thomas GAUDIN <thomas.gaudin@centraliens-lille.org>",
"Helio Chissini de Castro <heliocastro@gmail.com"
{ name = "Ananias CARVALHO", email = "carvalhoananias@hotmail.com" },
{ name = "Thomas GAUDIN", email = "thomas.gaudin@centraliens-lille.org" },
{ name = "Helio Chissini de Castro", email = "heliocastro@gmail.com" },
]
license = "MIT"
requires-python = "~=3.8"
readme = "README.md"
repository = "https://github.com/anancarv/python-artifactory"
documentation = "https://github.com/anancarv/python-artifactory"
license = "MIT"
keywords = ["artifactory"]
classifiers = [
"Development Status :: 5 - Production/Stable",
Expand All @@ -23,37 +22,40 @@ classifiers = [
"Programming Language :: Python :: 3.11",
"Topic :: Software Development :: Libraries",
"Topic :: System :: Filesystems",
"Operating System :: OS Independent"
"Operating System :: OS Independent",
]
dependencies = [
"requests~=2.31",
"typing_extensions>=4.7.1,<5",
"pydantic[email]>=2.4.0,<3",
]

[tool.poetry.urls]
[project.urls]
Repository = "https://github.com/anancarv/python-artifactory"
Documentation = "https://github.com/anancarv/python-artifactory"
"Bug Tracker" = "https://github.com/anancarv/python-artifactory/issues"

[tool.poetry.dependencies]
python = "^3.8"
requests = "^2.31"
typing_extensions = "^4.7.1"
pydantic = {extras = ["email"], version = "^2.4.0"}

[tool.poetry.group.dev.dependencies]
ruff = "^0.0.289"
pytest = "^7.4.2"
black = "^23.3.0"
pre-commit = "^2.9.2"
responses = "^0.23.3"
pytest-mock = "^2.0.0"
detect-secrets = "^1.2.0"
pytest-cov = "^4.1.0"
mypy = "^1.5.1"
typed-ast = "^1.5.5"
types-urllib3 = "^1.26.25.14"
types-requests = "^2.31.0.2"
pytest-md = "^0.2.0"
pytest-emoji = "^0.2.0"
[dependency-groups]
dev = [
"ruff>=0.0.289,<0.0.290",
"pytest>=7.4.2,<8",
"black>=23.3.0,<24",
"pre-commit>=2.9.2,<3",
"responses>=0.23.3,<0.24",
"pytest-mock>=2.0.0,<3",
"detect-secrets>=1.2.0,<2",
"pytest-cov>=4.1.0,<5",
"mypy>=1.5.1,<2",
"typed-ast>=1.5.5,<2",
"types-urllib3>=1.26.25.14,<2",
"types-requests>=2.31.0.2,<3",
"pytest-md>=0.2.0,<0.3",
"pytest-emoji>=0.2.0,<0.3",
]

[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.isort]
multi_line_output = 3
Expand Down
Loading
Loading