qbraid-core 0.1.0.dev1__tar.gz → 0.1.0.dev3__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.
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/PKG-INFO +2 -1
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/pyproject.toml +2 -2
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/qbraid_core/__init__.py +5 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/qbraid_core/_version.py +2 -2
- qbraid-core-0.1.0.dev3/qbraid_core/_warnings.py +45 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/qbraid_core/services/quantum/proxy.py +14 -9
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/qbraid_core.egg-info/PKG-INFO +2 -1
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/qbraid_core.egg-info/SOURCES.txt +2 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/qbraid_core.egg-info/requires.txt +1 -0
- qbraid-core-0.1.0.dev3/tests/test_warnings.py +31 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/tools/verify_headers.py +56 -13
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/.github/ISSUE_TEMPLATE/bug_report.yml +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/.github/ISSUE_TEMPLATE/feature_request.yml +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/.github/PULL_REQUEST_TEMPLATE.md +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/.github/workflows/docs.yml +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/.github/workflows/format.yml +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/.github/workflows/main.yml +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/.github/workflows/publish.yml +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/.github/workflows/test-publish.yml +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/.gitignore +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/.readthedocs.yaml +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/LICENSE +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/MANIFEST.in +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/README.md +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/docs/Makefile +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/docs/_static/cards/jupyter.png +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/docs/_static/cards/python.png +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/docs/_static/cards/terminal.png +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/docs/_static/css/custom.css +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/docs/_static/css/s4defs-roles.css +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/docs/_static/favicon.ico +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/docs/_static/logo.png +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/docs/api/qbraid_core.rst +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/docs/api/qbraid_core.services.rst +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/docs/api/qbraid_core.system.rst +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/docs/conf.py +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/docs/index.rst +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/docs/make.bat +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/qbraid_core/client.py +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/qbraid_core/exceptions.py +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/qbraid_core/registry.py +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/qbraid_core/retry.py +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/qbraid_core/services/__init__.py +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/qbraid_core/services/environments/__init__.py +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/qbraid_core/services/environments/client.py +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/qbraid_core/services/environments/create.py +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/qbraid_core/services/environments/exceptions.py +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/qbraid_core/services/environments/paths.py +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/qbraid_core/services/environments/state.py +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/qbraid_core/services/environments/validate.py +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/qbraid_core/services/quantum/__init__.py +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/qbraid_core/services/quantum/adapter.py +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/qbraid_core/services/quantum/client.py +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/qbraid_core/services/quantum/exceptions.py +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/qbraid_core/session.py +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/qbraid_core/system/__init__.py +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/qbraid_core/system/exceptions.py +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/qbraid_core/system/executables.py +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/qbraid_core/system/generic.py +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/qbraid_core/system/packages.py +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/qbraid_core/system/threader.py +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/qbraid_core.egg-info/dependency_links.txt +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/qbraid_core.egg-info/top_level.txt +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/setup.cfg +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/tests/__init__.py +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/tests/conftest.py +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/tests/fixtures/__init__.py +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/tests/fixtures/environments.py +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/tests/test_client.py +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/tests/test_environments.py +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/tests/test_session.py +0 -0
- {qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/tests/test_system.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: qbraid-core
|
|
3
|
-
Version: 0.1.0.
|
|
3
|
+
Version: 0.1.0.dev3
|
|
4
4
|
Summary: Python library with core abstractions for software development in the qBraid ecosystem.
|
|
5
5
|
Author-email: qBraid Development Team <contact@qbraid.com>
|
|
6
6
|
License: Proprietary
|
|
@@ -25,6 +25,7 @@ Requires-Python: >=3.8
|
|
|
25
25
|
Description-Content-Type: text/markdown
|
|
26
26
|
License-File: LICENSE
|
|
27
27
|
Requires-Dist: requests
|
|
28
|
+
Requires-Dist: urllib3
|
|
28
29
|
Provides-Extra: dev
|
|
29
30
|
Requires-Dist: black; extra == "dev"
|
|
30
31
|
Requires-Dist: isort; extra == "dev"
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "qbraid-core"
|
|
7
|
-
version = "0.1.0.
|
|
7
|
+
version = "0.1.0.dev3"
|
|
8
8
|
authors = [
|
|
9
9
|
{name = "qBraid Development Team", email = "contact@qbraid.com"},
|
|
10
10
|
]
|
|
@@ -26,7 +26,7 @@ classifiers = [
|
|
|
26
26
|
"Programming Language :: Python :: 3.11",
|
|
27
27
|
"Programming Language :: Python :: 3.12",
|
|
28
28
|
]
|
|
29
|
-
dependencies = ["requests"]
|
|
29
|
+
dependencies = ["requests", "urllib3"]
|
|
30
30
|
|
|
31
31
|
[project.urls]
|
|
32
32
|
Homepage = "https://www.qbraid.com/"
|
|
@@ -40,6 +40,7 @@ Exceptions
|
|
|
40
40
|
RequestsApiError
|
|
41
41
|
|
|
42
42
|
"""
|
|
43
|
+
from ._warnings import _check_version, _disable_urllib3
|
|
43
44
|
from .client import QbraidClient
|
|
44
45
|
from .exceptions import (
|
|
45
46
|
AuthError,
|
|
@@ -104,3 +105,7 @@ def client(*args, **kwargs):
|
|
|
104
105
|
A service client instance.
|
|
105
106
|
"""
|
|
106
107
|
return _get_default_session().client(*args, **kwargs)
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
_disable_urllib3()
|
|
111
|
+
_check_version("qbraid-core")
|
|
@@ -12,5 +12,5 @@ __version__: str
|
|
|
12
12
|
__version_tuple__: VERSION_TUPLE
|
|
13
13
|
version_tuple: VERSION_TUPLE
|
|
14
14
|
|
|
15
|
-
__version__ = version = '0.1.dev1+
|
|
16
|
-
__version_tuple__ = version_tuple = (0, 1, 'dev1', '
|
|
15
|
+
__version__ = version = '0.1.dev1+g3175d41'
|
|
16
|
+
__version_tuple__ = version_tuple = (0, 1, 'dev1', 'g3175d41')
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Copyright (c) 2024, qBraid Development Team
|
|
2
|
+
# All rights reserved.
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
Module for emitting and disabling warnings at top level.
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
import warnings
|
|
9
|
+
|
|
10
|
+
import urllib3
|
|
11
|
+
|
|
12
|
+
from .exceptions import QbraidException
|
|
13
|
+
from .system import get_latest_package_version, get_local_package_version
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def _warn_new_version(local: str, latest: str) -> bool:
|
|
17
|
+
"""Returns True if you should warn user about updated package version,
|
|
18
|
+
False otherwise."""
|
|
19
|
+
installed_major, installed_minor = map(int, local.split(".")[:2])
|
|
20
|
+
latest_major, latest_minor = map(int, latest.split(".")[:2])
|
|
21
|
+
|
|
22
|
+
return (installed_major, installed_minor) < (latest_major, latest_minor)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def _check_version(package: str) -> None:
|
|
26
|
+
"""Emits UserWarning if updated package version exists."""
|
|
27
|
+
try:
|
|
28
|
+
latest_version = get_latest_package_version(package)
|
|
29
|
+
local_version = get_local_package_version(package)
|
|
30
|
+
|
|
31
|
+
if _warn_new_version(local_version, latest_version):
|
|
32
|
+
warnings.warn(
|
|
33
|
+
f"You are using {package} version {local_version}, however, version "
|
|
34
|
+
f"{latest_version} is available. To avoid compatibility issues, consider "
|
|
35
|
+
"upgrading.",
|
|
36
|
+
UserWarning,
|
|
37
|
+
)
|
|
38
|
+
except QbraidException:
|
|
39
|
+
pass
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
# coverage: ignore
|
|
43
|
+
def _disable_urllib3() -> None:
|
|
44
|
+
"""Disables urllib3 InsecureRequestWarning warning."""
|
|
45
|
+
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
|
@@ -22,7 +22,7 @@ SUPPORTED_QJOB_LIBS = ["braket"]
|
|
|
22
22
|
|
|
23
23
|
def _check_proxy(
|
|
24
24
|
proxy_spec: Tuple[str, ...], slug_path: Optional[Path] = None
|
|
25
|
-
) -> Tuple[bool, bool]:
|
|
25
|
+
) -> Tuple[bool, bool, Path]:
|
|
26
26
|
"""
|
|
27
27
|
Checks if the specified proxy file exists and contains the string 'qbraid'.
|
|
28
28
|
|
|
@@ -32,9 +32,13 @@ def _check_proxy(
|
|
|
32
32
|
slug_path (optional, Path): The base path to prepend to the 'pyenv' directory.
|
|
33
33
|
|
|
34
34
|
Returns:
|
|
35
|
-
A tuple of two booleans: The first indicates whether the
|
|
36
|
-
the second, if the file exists, is True if it contains
|
|
35
|
+
A tuple of two booleans and sitepackages path: The first bool indicates whether the
|
|
36
|
+
specified proxy file exists; the second bool, if the file exists, is True if it contains
|
|
37
|
+
'qbraid', False otherwise. The sitepackages path gives the location of the site-packages
|
|
38
|
+
directory where the proxy file is located.
|
|
37
39
|
"""
|
|
40
|
+
site_packages_path = None
|
|
41
|
+
|
|
38
42
|
try:
|
|
39
43
|
if slug_path is None:
|
|
40
44
|
site_packages: str = get_active_site_packages_path()
|
|
@@ -43,26 +47,26 @@ def _check_proxy(
|
|
|
43
47
|
site_packages_path = get_venv_site_packages_path(slug_path / "pyenv")
|
|
44
48
|
except QbraidException as err:
|
|
45
49
|
logger.debug(err)
|
|
46
|
-
return False, False
|
|
50
|
+
return False, False, site_packages_path
|
|
47
51
|
|
|
48
52
|
target_file_path = site_packages_path.joinpath(*proxy_spec)
|
|
49
53
|
|
|
50
54
|
if not target_file_path.exists():
|
|
51
|
-
return False, False
|
|
55
|
+
return False, False, site_packages_path
|
|
52
56
|
|
|
53
57
|
try:
|
|
54
58
|
with target_file_path.open("r", encoding="utf-8") as file:
|
|
55
59
|
for line in file:
|
|
56
60
|
if "qbraid" in line:
|
|
57
61
|
return True, True, site_packages_path
|
|
58
|
-
return True, False
|
|
62
|
+
return True, False, site_packages_path
|
|
59
63
|
except Exception as err: # pylint: disable=broad-exception-caught
|
|
60
64
|
logger.debug("Unexpected error checking qBraid proxy: %s", err)
|
|
61
65
|
|
|
62
|
-
return True, False
|
|
66
|
+
return True, False, site_packages_path
|
|
63
67
|
|
|
64
68
|
|
|
65
|
-
def quantum_lib_proxy_state(device_lib: str) -> Dict[str, Union[str, bool]]:
|
|
69
|
+
def quantum_lib_proxy_state(device_lib: str, **kwargs) -> Dict[str, Union[str, bool]]:
|
|
66
70
|
"""Checks if qBraid Quantum Jobs are supported and if so, checks whether they are enabled.
|
|
67
71
|
Returns dictionary providing information about the state of qBraid Quantum Jobs support
|
|
68
72
|
and configuration for the given quantum device library.
|
|
@@ -91,11 +95,12 @@ def quantum_lib_proxy_state(device_lib: str) -> Dict[str, Union[str, bool]]:
|
|
|
91
95
|
if device_lib == "braket":
|
|
92
96
|
proxy_lib = "botocore"
|
|
93
97
|
proxy_spec = (proxy_lib, "httpsession.py")
|
|
94
|
-
supported, enabled = _check_proxy(proxy_spec)
|
|
98
|
+
supported, enabled, path = _check_proxy(proxy_spec, **kwargs)
|
|
95
99
|
|
|
96
100
|
# add more device libraries here as needed
|
|
97
101
|
|
|
98
102
|
state["proxy_lib"] = proxy_lib
|
|
99
103
|
state["supported"] = supported
|
|
100
104
|
state["enabled"] = enabled
|
|
105
|
+
state["path"] = str(path)
|
|
101
106
|
return state
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: qbraid-core
|
|
3
|
-
Version: 0.1.0.
|
|
3
|
+
Version: 0.1.0.dev3
|
|
4
4
|
Summary: Python library with core abstractions for software development in the qBraid ecosystem.
|
|
5
5
|
Author-email: qBraid Development Team <contact@qbraid.com>
|
|
6
6
|
License: Proprietary
|
|
@@ -25,6 +25,7 @@ Requires-Python: >=3.8
|
|
|
25
25
|
Description-Content-Type: text/markdown
|
|
26
26
|
License-File: LICENSE
|
|
27
27
|
Requires-Dist: requests
|
|
28
|
+
Requires-Dist: urllib3
|
|
28
29
|
Provides-Extra: dev
|
|
29
30
|
Requires-Dist: black; extra == "dev"
|
|
30
31
|
Requires-Dist: isort; extra == "dev"
|
|
@@ -28,6 +28,7 @@ docs/api/qbraid_core.services.rst
|
|
|
28
28
|
docs/api/qbraid_core.system.rst
|
|
29
29
|
qbraid_core/__init__.py
|
|
30
30
|
qbraid_core/_version.py
|
|
31
|
+
qbraid_core/_warnings.py
|
|
31
32
|
qbraid_core/client.py
|
|
32
33
|
qbraid_core/exceptions.py
|
|
33
34
|
qbraid_core/registry.py
|
|
@@ -63,6 +64,7 @@ tests/test_client.py
|
|
|
63
64
|
tests/test_environments.py
|
|
64
65
|
tests/test_session.py
|
|
65
66
|
tests/test_system.py
|
|
67
|
+
tests/test_warnings.py
|
|
66
68
|
tests/fixtures/__init__.py
|
|
67
69
|
tests/fixtures/environments.py
|
|
68
70
|
tools/verify_headers.py
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Copyright (c) 2024, qBraid Development Team
|
|
2
|
+
# All rights reserved.
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
Unit tests related to qBraid core functionality and system configurations.
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
import pytest
|
|
9
|
+
|
|
10
|
+
from qbraid_core._warnings import _warn_new_version
|
|
11
|
+
|
|
12
|
+
check_version_data = [
|
|
13
|
+
# local, API, warn
|
|
14
|
+
("0.1.0", "0.1.1", False),
|
|
15
|
+
("1.0.7", "1.0.8", False),
|
|
16
|
+
("1.3.2", "2.0.6", True),
|
|
17
|
+
("0.1.0", "0.3.0", True),
|
|
18
|
+
("0.2.4.dev1", "0.2.4", False),
|
|
19
|
+
("0.1.0", "0.1.0.dev0", False),
|
|
20
|
+
("0.1.6.dev2", "0.1.6.dev5", False),
|
|
21
|
+
("0.1.6.dev5", "0.1.6.dev2", False),
|
|
22
|
+
("0.2.0", "0.1.4", False),
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@pytest.mark.parametrize("test_data", check_version_data)
|
|
27
|
+
def test_check_version(test_data):
|
|
28
|
+
"""Test function that compares local/api package versions to determine if
|
|
29
|
+
update is needed."""
|
|
30
|
+
local, api, warn_bool = test_data
|
|
31
|
+
assert warn_bool == _warn_new_version(local, api)
|
|
@@ -19,13 +19,27 @@ header = """# Copyright (c) 2024, qBraid Development Team
|
|
|
19
19
|
# All rights reserved.
|
|
20
20
|
"""
|
|
21
21
|
|
|
22
|
+
header_gpl = """# Copyright (C) 2024 qBraid
|
|
23
|
+
#
|
|
24
|
+
# This file is part of the qBraid-SDK
|
|
25
|
+
#
|
|
26
|
+
# The qBraid-SDK is free software released under the GNU General Public License v3
|
|
27
|
+
# or later. You can redistribute and/or modify it under the terms of the GPL v3.
|
|
28
|
+
# See the LICENSE file in the project root or <https://www.gnu.org/licenses/gpl-3.0.html>.
|
|
29
|
+
#
|
|
30
|
+
# THERE IS NO WARRANTY for the qBraid-SDK, as per Section 15 of the GPL v3.
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
header_2023 = header.replace("2024", "2023")
|
|
34
|
+
header_gpl_2023 = header_gpl.replace("2024", "2023")
|
|
35
|
+
|
|
22
36
|
skip_files = ["qbraid_core/_version.py"]
|
|
23
37
|
|
|
24
38
|
failed_headers = []
|
|
25
39
|
fixed_headers = []
|
|
26
40
|
|
|
27
41
|
|
|
28
|
-
def should_skip(file_path, content):
|
|
42
|
+
def should_skip(file_path: str, content: str) -> bool:
|
|
29
43
|
if file_path in skip_files:
|
|
30
44
|
return True
|
|
31
45
|
|
|
@@ -45,11 +59,17 @@ def should_skip(file_path, content):
|
|
|
45
59
|
return False
|
|
46
60
|
|
|
47
61
|
|
|
48
|
-
def replace_or_add_header(file_path, fix=False):
|
|
62
|
+
def replace_or_add_header(file_path: str, fix: bool = False) -> None:
|
|
49
63
|
with open(file_path, "r", encoding="ISO-8859-1") as f:
|
|
50
64
|
content = f.read()
|
|
51
65
|
|
|
52
|
-
if
|
|
66
|
+
if (
|
|
67
|
+
content.startswith(header)
|
|
68
|
+
or content.startswith(header_2023)
|
|
69
|
+
or content.startswith(header_gpl)
|
|
70
|
+
or content.startswith(header_gpl_2023)
|
|
71
|
+
or should_skip(file_path, content)
|
|
72
|
+
):
|
|
53
73
|
return
|
|
54
74
|
|
|
55
75
|
if not fix:
|
|
@@ -76,7 +96,7 @@ def replace_or_add_header(file_path, fix=False):
|
|
|
76
96
|
fixed_headers.append(file_path)
|
|
77
97
|
|
|
78
98
|
|
|
79
|
-
def process_files_in_directory(directory, fix=False):
|
|
99
|
+
def process_files_in_directory(directory: str, fix: bool = False) -> int:
|
|
80
100
|
count = 0
|
|
81
101
|
for root, _, files in os.walk(directory):
|
|
82
102
|
for file in files:
|
|
@@ -87,9 +107,29 @@ def process_files_in_directory(directory, fix=False):
|
|
|
87
107
|
return count
|
|
88
108
|
|
|
89
109
|
|
|
110
|
+
def display_help() -> None:
|
|
111
|
+
help_message = """
|
|
112
|
+
Usage: python verify_headers.py SRC [OPTIONS] ...
|
|
113
|
+
|
|
114
|
+
This script checks for copyright headers at the specified path.
|
|
115
|
+
If no flags are passed, it will indicate which files would be
|
|
116
|
+
modified without actually making any changes.
|
|
117
|
+
|
|
118
|
+
Options:
|
|
119
|
+
--help Display this help message and exit.
|
|
120
|
+
--fix Adds/modifies file headers as necessary.
|
|
121
|
+
"""
|
|
122
|
+
print(help_message)
|
|
123
|
+
sys.exit(0)
|
|
124
|
+
|
|
125
|
+
|
|
90
126
|
if __name__ == "__main__":
|
|
91
|
-
if
|
|
92
|
-
|
|
127
|
+
if "--help" in sys.argv:
|
|
128
|
+
display_help()
|
|
129
|
+
|
|
130
|
+
# Check if at least two arguments are provided and the first argument is not a flag
|
|
131
|
+
if len(sys.argv) < 2 or sys.argv[1].startswith("--"):
|
|
132
|
+
print("Usage: python verify_headers.py SRC [OPTIONS] ...")
|
|
93
133
|
sys.exit(1)
|
|
94
134
|
|
|
95
135
|
script_directory = os.path.dirname(os.path.abspath(__file__))
|
|
@@ -97,16 +137,19 @@ if __name__ == "__main__":
|
|
|
97
137
|
skip_files = [os.path.join(project_directory, file_path) for file_path in skip_files]
|
|
98
138
|
|
|
99
139
|
fix = "--fix" in sys.argv
|
|
100
|
-
|
|
140
|
+
files_and_dirs = [arg for arg in sys.argv[1:] if arg != "--fix"]
|
|
101
141
|
|
|
102
142
|
checked = 0
|
|
103
|
-
for
|
|
104
|
-
|
|
105
|
-
if os.path.isdir(
|
|
106
|
-
checked += process_files_in_directory(
|
|
143
|
+
for item in files_and_dirs:
|
|
144
|
+
full_path = os.path.join(project_directory, item)
|
|
145
|
+
if os.path.isdir(full_path):
|
|
146
|
+
checked += process_files_in_directory(full_path, fix)
|
|
147
|
+
elif os.path.isfile(full_path) and full_path.endswith(".py"):
|
|
148
|
+
replace_or_add_header(full_path, fix)
|
|
149
|
+
checked += 1
|
|
107
150
|
else:
|
|
108
|
-
failed_headers.append(
|
|
109
|
-
print(f"Directory not found: {
|
|
151
|
+
failed_headers.append(full_path)
|
|
152
|
+
print(f"Directory not found: {full_path}")
|
|
110
153
|
|
|
111
154
|
if not fix:
|
|
112
155
|
if failed_headers:
|
|
File without changes
|
{qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/.github/ISSUE_TEMPLATE/feature_request.yml
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
|
|
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
|
{qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/qbraid_core/services/environments/__init__.py
RENAMED
|
File without changes
|
{qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/qbraid_core/services/environments/client.py
RENAMED
|
File without changes
|
{qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/qbraid_core/services/environments/create.py
RENAMED
|
File without changes
|
{qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/qbraid_core/services/environments/exceptions.py
RENAMED
|
File without changes
|
{qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/qbraid_core/services/environments/paths.py
RENAMED
|
File without changes
|
{qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/qbraid_core/services/environments/state.py
RENAMED
|
File without changes
|
{qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/qbraid_core/services/environments/validate.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{qbraid-core-0.1.0.dev1 → qbraid-core-0.1.0.dev3}/qbraid_core/services/quantum/exceptions.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
|