automizor 0.4.6__tar.gz → 0.4.8__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 (30) hide show
  1. {automizor-0.4.6/automizor.egg-info → automizor-0.4.8}/PKG-INFO +1 -1
  2. automizor-0.4.8/README.md +1 -0
  3. automizor-0.4.8/automizor/__init__.py +1 -0
  4. automizor-0.4.8/automizor/datastore/__init__.py +98 -0
  5. automizor-0.4.8/automizor/datastore/_container.py +28 -0
  6. {automizor-0.4.6 → automizor-0.4.8}/automizor/datastore/_datastore.py +25 -16
  7. {automizor-0.4.6 → automizor-0.4.8}/automizor/job/__init__.py +10 -9
  8. {automizor-0.4.6 → automizor-0.4.8}/automizor/job/_job.py +15 -6
  9. {automizor-0.4.6 → automizor-0.4.8}/automizor/storage/__init__.py +19 -17
  10. {automizor-0.4.6 → automizor-0.4.8}/automizor/storage/_storage.py +16 -6
  11. automizor-0.4.8/automizor/utils/__init__.py +34 -0
  12. {automizor-0.4.6 → automizor-0.4.8}/automizor/vault/__init__.py +10 -9
  13. {automizor-0.4.6 → automizor-0.4.8}/automizor/vault/_vault.py +14 -2
  14. {automizor-0.4.6 → automizor-0.4.8/automizor.egg-info}/PKG-INFO +1 -1
  15. {automizor-0.4.6 → automizor-0.4.8}/automizor.egg-info/SOURCES.txt +1 -0
  16. automizor-0.4.6/README.md +0 -1
  17. automizor-0.4.6/automizor/__init__.py +0 -1
  18. automizor-0.4.6/automizor/datastore/__init__.py +0 -107
  19. automizor-0.4.6/automizor/utils/__init__.py +0 -31
  20. {automizor-0.4.6 → automizor-0.4.8}/LICENSE +0 -0
  21. {automizor-0.4.6 → automizor-0.4.8}/MANIFEST.in +0 -0
  22. {automizor-0.4.6 → automizor-0.4.8}/automizor/exceptions.py +0 -0
  23. {automizor-0.4.6 → automizor-0.4.8}/automizor/log/__init__.py +0 -0
  24. {automizor-0.4.6 → automizor-0.4.8}/automizor/log/_log.py +0 -0
  25. {automizor-0.4.6 → automizor-0.4.8}/automizor/vault/_container.py +0 -0
  26. {automizor-0.4.6 → automizor-0.4.8}/automizor.egg-info/dependency_links.txt +0 -0
  27. {automizor-0.4.6 → automizor-0.4.8}/automizor.egg-info/requires.txt +0 -0
  28. {automizor-0.4.6 → automizor-0.4.8}/automizor.egg-info/top_level.txt +0 -0
  29. {automizor-0.4.6 → automizor-0.4.8}/setup.cfg +0 -0
  30. {automizor-0.4.6 → automizor-0.4.8}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: automizor
3
- Version: 0.4.6
3
+ Version: 0.4.8
4
4
  Summary: Python Automizor framework
5
5
  Home-page: https://github.com/automizor/automizor-python
6
6
  Author: Christian Fischer
@@ -0,0 +1 @@
1
+ # Automizor Python SDK
@@ -0,0 +1 @@
1
+ version = "0.4.8"
@@ -0,0 +1,98 @@
1
+ from ._container import DataStoreContainer
2
+ from ._datastore import DataStore
3
+
4
+
5
+ def configure(api_token: str):
6
+ """
7
+ Configures the DataStore instance with the provided API token.
8
+ """
9
+ DataStore.configure(api_token)
10
+
11
+
12
+ def get_store(name: str) -> "DataStoreContainer":
13
+ """
14
+ Get a store container by name. The `DataStoreContainer` is a wrapper
15
+ around the data store that provides a get and set method to interact
16
+ with the data store.
17
+
18
+ Example usage:
19
+
20
+ .. code-block:: python
21
+
22
+ from automizor import datastore
23
+
24
+ # Get a data store countries
25
+ countries = datastore.get_store("countries")
26
+
27
+ # Initialize or update json store
28
+ countries.set([
29
+ {
30
+ "name": "United States",
31
+ "code": "US",
32
+ },
33
+ {
34
+ "name": "Canada",
35
+ "code": "CA",
36
+ },
37
+ ])
38
+
39
+ # Get values from json store
40
+ result = countries.get()
41
+
42
+ # Get a data store movies
43
+ movies = datastore.get_store("movies")
44
+
45
+ # Initialize or update kkv store
46
+ movies.set({
47
+ "US": {
48
+ "action": {
49
+ "Die Hard": 1988,
50
+ "The Matrix": 1999
51
+ }
52
+ }
53
+ })
54
+
55
+ # Get values from kkv store
56
+ result = movies.get("US")
57
+ result = movies.get("US", "action")
58
+
59
+ # Insert or update values
60
+ movies.set({
61
+ "US": {
62
+ "action": {
63
+ "Die Hard": 1988,
64
+ "The Matrix": 1999,
65
+ "John Wick": 2014
66
+ },
67
+ "comedy": {
68
+ "The Hangover": 2009,
69
+ "Superbad": 2007
70
+ }
71
+ }
72
+ })
73
+
74
+ # Delete secondary key
75
+ movies.set({
76
+ "US": {
77
+ "action": None
78
+ }
79
+ })
80
+
81
+ # Delete primary key
82
+ movies.set({
83
+ "US": None
84
+ })
85
+
86
+ """
87
+
88
+ datastore = DataStore.get_instance()
89
+ return DataStoreContainer(
90
+ datastore=datastore,
91
+ name=name,
92
+ )
93
+
94
+
95
+ __all__ = [
96
+ "configure",
97
+ "get_store",
98
+ ]
@@ -0,0 +1,28 @@
1
+ from dataclasses import dataclass
2
+
3
+ from automizor.utils import JSON
4
+
5
+
6
+ @dataclass
7
+ class DataStoreContainer:
8
+ """
9
+ The `DataStoreContainer` is a wrapper around the data store that
10
+ provides a get and set method to interact with the data store.
11
+
12
+ Attributes:
13
+ datastore: The data store.
14
+ name: The name of the data store.
15
+ """
16
+
17
+ from ._datastore import DataStore
18
+
19
+ datastore: DataStore
20
+ name: str
21
+
22
+ def get(self, primary_key=None, secondary_key=None):
23
+ """Get values from the datastore."""
24
+ return self.datastore.get_values(self.name, primary_key, secondary_key)
25
+
26
+ def set(self, values: JSON):
27
+ """Set values in the datastore."""
28
+ self.datastore.set_values(self.name, values)
@@ -1,33 +1,42 @@
1
- from typing import Dict, List, Union
2
-
3
1
  import requests
4
2
 
5
3
  from automizor.exceptions import AutomizorError
6
- from automizor.utils import get_api_config, get_headers
7
-
8
- JSON = Union[str, int, float, bool, None, Dict[str, "JSON"], List["JSON"]]
4
+ from automizor.utils import JSON, get_api_config, get_headers
9
5
 
10
6
 
11
7
  class DataStore:
12
8
  """
13
- `DataStore` is a class designed to interface with the `Automizor Platform` to manage and
14
- manipulate data stored in various formats. It supports operations to retrieve and update
15
- data using a unified API.
9
+ `DataStore` is a class designed to interface with the `Automizor Platform`
10
+ to manage and manipulate data stored in various formats. It supports
11
+ operations to retrieve and update data using a unified API.
16
12
 
17
- The class initializes an HTTP session with the necessary headers for authentication, and
18
- provides methods to retrieve values, and set values in the store.
13
+ The class initializes an HTTP session with the necessary headers for
14
+ authentication, and provides methods to retrieve values, and set values in
15
+ the store.
19
16
 
20
17
  Attributes:
21
18
  url (str): The base URL for the API endpoint.
22
19
  token (str): The authentication token for API access.
23
- session (requests.Session): The HTTP session used for making API requests.
20
+ session (requests.Session): The HTTP session used to make API requests.
24
21
  """
25
22
 
26
- def __init__(self):
27
- self.url, self.token = get_api_config()
23
+ _instance = None
24
+
25
+ @classmethod
26
+ def configure(cls, api_token: str | None = None):
27
+ cls._instance = cls(api_token)
28
+
29
+ def __init__(self, api_token: str | None = None):
30
+ self.url, self.token = get_api_config(api_token)
28
31
  self.session = requests.Session()
29
32
  self.session.headers.update(get_headers(self.token))
30
33
 
34
+ @classmethod
35
+ def get_instance(cls):
36
+ if cls._instance is None:
37
+ cls.configure()
38
+ return cls._instance
39
+
31
40
  def get_values(
32
41
  self,
33
42
  name: str,
@@ -39,8 +48,8 @@ class DataStore:
39
48
 
40
49
  Parameters:
41
50
  name (str): The name of the data store.
42
- primary_key (str, optional): The primary key for the values. Defaults to None.
43
- secondary_key (str, optional): The secondary key for the values. Defaults to None.
51
+ primary_key (str, optional): The primary key for the values.
52
+ secondary_key (str, optional): The secondary key for the values.
44
53
 
45
54
  Returns:
46
55
  JSON: The values from the data store.
@@ -64,7 +73,7 @@ class DataStore:
64
73
  name: str,
65
74
  primary_key: str | None = None,
66
75
  secondary_key: str | None = None,
67
- ) -> dict:
76
+ ) -> JSON:
68
77
  params = (
69
78
  {"primary_key": primary_key, "secondary_key": secondary_key}
70
79
  if primary_key or secondary_key
@@ -1,13 +1,13 @@
1
- from functools import lru_cache
1
+ from automizor.utils import JSON
2
2
 
3
- from ._job import JSON
3
+ from ._job import Job
4
4
 
5
5
 
6
- @lru_cache
7
- def _get_job():
8
- from ._job import Job
9
-
10
- return Job()
6
+ def configure(api_token: str):
7
+ """
8
+ Configures the Job instance with the provided API token.
9
+ """
10
+ Job.configure(api_token)
11
11
 
12
12
 
13
13
  def get_context() -> dict:
@@ -22,7 +22,7 @@ def get_context() -> dict:
22
22
  AutomizorJobError: If retrieving the job context fails.
23
23
  """
24
24
 
25
- job = _get_job()
25
+ job = Job.get_instance()
26
26
  return job.get_context()
27
27
 
28
28
 
@@ -38,11 +38,12 @@ def set_result(name: str, value: JSON):
38
38
  Note: Errors during file operations will raise unhandled exceptions.
39
39
  """
40
40
 
41
- job = _get_job()
41
+ job = Job.get_instance()
42
42
  return job.set_result(name, value)
43
43
 
44
44
 
45
45
  __all__ = [
46
+ "configure",
46
47
  "get_context",
47
48
  "set_result",
48
49
  ]
@@ -1,13 +1,10 @@
1
1
  import json
2
2
  import os
3
- from typing import Dict, List, Union
4
3
 
5
4
  import requests
6
5
 
7
6
  from automizor.exceptions import AutomizorError
8
- from automizor.utils import get_api_config, get_headers
9
-
10
- JSON = Union[str, int, float, bool, None, Dict[str, "JSON"], List["JSON"]]
7
+ from automizor.utils import JSON, get_api_config, get_headers
11
8
 
12
9
 
13
10
  class Job:
@@ -49,14 +46,26 @@ class Job:
49
46
  job.set_result("result_name", {"key": "value"})
50
47
  """
51
48
 
52
- def __init__(self):
49
+ _instance = None
50
+
51
+ @classmethod
52
+ def configure(cls, api_token: str | None = None):
53
+ cls._instance = cls(api_token)
54
+
55
+ def __init__(self, api_token: str | None = None):
53
56
  self._context_file = os.getenv("AUTOMIZOR_CONTEXT_FILE", None)
54
57
  self._job_id = os.getenv("AUTOMIZOR_JOB_ID", None)
55
58
 
56
- self.url, self.token = get_api_config()
59
+ self.url, self.token = get_api_config(api_token)
57
60
  self.session = requests.Session()
58
61
  self.session.headers.update(get_headers(self.token))
59
62
 
63
+ @classmethod
64
+ def get_instance(cls):
65
+ if cls._instance is None:
66
+ cls.configure()
67
+ return cls._instance
68
+
60
69
  def get_context(self) -> dict:
61
70
  """
62
71
  Retrieves the context of the current job, which contains necessary information
@@ -1,17 +1,18 @@
1
1
  import json
2
2
  import mimetypes
3
- from functools import lru_cache
4
3
  from pathlib import Path
5
4
  from typing import List
6
5
 
7
- from ._storage import JSON
6
+ from automizor.utils import JSON
8
7
 
8
+ from ._storage import Storage
9
9
 
10
- @lru_cache
11
- def _get_storage():
12
- from ._storage import Storage
13
10
 
14
- return Storage()
11
+ def configure(api_token: str):
12
+ """
13
+ Configures the Storage instance with the provided API token.
14
+ """
15
+ Storage.configure(api_token)
15
16
 
16
17
 
17
18
  def list_assets() -> List[str]:
@@ -22,7 +23,7 @@ def list_assets() -> List[str]:
22
23
  A list of all asset names.
23
24
  """
24
25
 
25
- storage = _get_storage()
26
+ storage = Storage.get_instance()
26
27
  return storage.list_assets()
27
28
 
28
29
 
@@ -34,7 +35,7 @@ def delete_asset(name: str):
34
35
  name: The name identifier of the asset to delete.
35
36
  """
36
37
 
37
- storage = _get_storage()
38
+ storage = Storage.get_instance()
38
39
  storage.delete_asset(name)
39
40
 
40
41
 
@@ -49,7 +50,7 @@ def get_bytes(name: str) -> bytes:
49
50
  The raw byte content of the asset.
50
51
  """
51
52
 
52
- storage = _get_storage()
53
+ storage = Storage.get_instance()
53
54
  return storage.get_bytes(name)
54
55
 
55
56
 
@@ -65,7 +66,7 @@ def get_file(name: str, path: str) -> str:
65
66
  The path to the saved file, confirming the operation's success.
66
67
  """
67
68
 
68
- storage = _get_storage()
69
+ storage = Storage.get_instance()
69
70
  return storage.get_file(name, path)
70
71
 
71
72
 
@@ -80,7 +81,7 @@ def get_json(name: str) -> JSON:
80
81
  The parsed JSON data, which can be a dict, list, or primitive data type.
81
82
  """
82
83
 
83
- storage = _get_storage()
84
+ storage = Storage.get_instance()
84
85
  return storage.get_json(name)
85
86
 
86
87
 
@@ -95,7 +96,7 @@ def get_text(name: str) -> str:
95
96
  The content of the asset as a text string.
96
97
  """
97
98
 
98
- storage = _get_storage()
99
+ storage = Storage.get_instance()
99
100
  return storage.get_text(name)
100
101
 
101
102
 
@@ -109,7 +110,7 @@ def set_bytes(name: str, data: bytes, content_type="application/octet-stream"):
109
110
  content_type: The MIME type of the asset.
110
111
  """
111
112
 
112
- storage = _get_storage()
113
+ storage = Storage.get_instance()
113
114
  storage.set_bytes(name, data, content_type)
114
115
 
115
116
 
@@ -124,12 +125,12 @@ def set_file(name: str, path: str, content_type: str = None):
124
125
  """
125
126
 
126
127
  content = Path(path).read_bytes()
127
- if content_type is None:
128
+ if not content_type:
128
129
  content_type, _ = mimetypes.guess_type(path)
129
130
  if content_type is None:
130
131
  content_type = "application/octet-stream"
131
132
 
132
- storage = _get_storage()
133
+ storage = Storage.get_instance()
133
134
  storage.set_bytes(name, content, content_type)
134
135
 
135
136
 
@@ -146,7 +147,7 @@ def set_json(name: str, value: JSON, **kwargs):
146
147
  content = json.dumps(value, **kwargs).encode("utf-8")
147
148
  content_type = "application/json"
148
149
 
149
- storage = _get_storage()
150
+ storage = Storage.get_instance()
150
151
  storage.set_bytes(name, content, content_type)
151
152
 
152
153
 
@@ -162,11 +163,12 @@ def set_text(name: str, text: str):
162
163
  content = text.encode("utf-8")
163
164
  content_type = "text/plain"
164
165
 
165
- storage = _get_storage()
166
+ storage = Storage.get_instance()
166
167
  storage.set_bytes(name, content, content_type)
167
168
 
168
169
 
169
170
  __all__ = [
171
+ "configure",
170
172
  "list_assets",
171
173
  "delete_asset",
172
174
  "get_bytes",
@@ -1,11 +1,9 @@
1
- from typing import Dict, List, Union
1
+ from typing import List
2
2
 
3
3
  import requests
4
4
 
5
5
  from automizor.exceptions import AutomizorError, NotFound
6
- from automizor.utils import get_api_config, get_headers
7
-
8
- JSON = Union[str, int, float, bool, None, Dict[str, "JSON"], List["JSON"]]
6
+ from automizor.utils import JSON, get_api_config, get_headers
9
7
 
10
8
 
11
9
  class Storage:
@@ -50,11 +48,23 @@ class Storage:
50
48
  text_data = storage.get_text("AssetName")
51
49
  """
52
50
 
53
- def __init__(self):
54
- self.url, self.token = get_api_config()
51
+ _instance = None
52
+
53
+ @classmethod
54
+ def configure(cls, api_token: str | None = None):
55
+ cls._instance = cls(api_token)
56
+
57
+ def __init__(self, api_token: str | None = None):
58
+ self.url, self.token = get_api_config(api_token)
55
59
  self.session = requests.Session()
56
60
  self.session.headers.update(get_headers(self.token))
57
61
 
62
+ @classmethod
63
+ def get_instance(cls):
64
+ if cls._instance is None:
65
+ cls.configure()
66
+ return cls._instance
67
+
58
68
  def list_assets(self) -> List[str]:
59
69
  """
60
70
  Retrieves a list of all asset names.
@@ -0,0 +1,34 @@
1
+ import os
2
+ import platform
3
+ from typing import Dict, List, Union
4
+
5
+ from automizor import version
6
+ from automizor.exceptions import AutomizorError
7
+
8
+ JSON = Union[str, int, float, bool, None, Dict[str, "JSON"], List["JSON"]]
9
+
10
+
11
+ OS_SYSTEM, OS_RELEASE, _ = platform.system_alias(
12
+ platform.system(), platform.release(), platform.version()
13
+ )
14
+
15
+
16
+ def get_api_config(api_token: str | None = None) -> tuple[str, str]:
17
+ if api_token is None:
18
+ api_token = os.getenv("AUTOMIZOR_AGENT_TOKEN")
19
+
20
+ if not api_token:
21
+ raise AutomizorError("AUTOMIZOR_AGENT_TOKEN is not set.")
22
+
23
+ try:
24
+ token, url = api_token.strip().split("@")
25
+ except ValueError as exc:
26
+ raise AutomizorError("The API token is not in the correct format.") from exc
27
+ return url, token
28
+
29
+
30
+ def get_headers(token: str) -> dict:
31
+ return {
32
+ "Authorization": f"Token {token}",
33
+ "User-Agent": f"Automizor/{version} {OS_SYSTEM}/{OS_RELEASE}",
34
+ }
@@ -1,14 +1,14 @@
1
- from functools import lru_cache
2
1
  from typing import Any, Dict
3
2
 
4
3
  from ._container import SecretContainer
4
+ from ._vault import Vault
5
5
 
6
6
 
7
- @lru_cache
8
- def _get_vault():
9
- from ._vault import Vault
10
-
11
- return Vault()
7
+ def configure(api_token: str):
8
+ """
9
+ Configures the Vault instance with the provided API token.
10
+ """
11
+ Vault.configure(api_token)
12
12
 
13
13
 
14
14
  def create_secret(
@@ -38,7 +38,7 @@ def create_secret(
38
38
  value=value,
39
39
  )
40
40
 
41
- vault = _get_vault()
41
+ vault = Vault.get_instance()
42
42
  return vault.create_secret(secret)
43
43
 
44
44
 
@@ -56,7 +56,7 @@ def get_secret(name: str) -> SecretContainer:
56
56
  AutomizorVaultError: If retrieving the secret fails.
57
57
  """
58
58
 
59
- vault = _get_vault()
59
+ vault = Vault.get_instance()
60
60
  return vault.get_secret(name)
61
61
 
62
62
 
@@ -74,12 +74,13 @@ def set_secret(secret: SecretContainer) -> SecretContainer:
74
74
  AutomizorVaultError: If updating the secret fails.
75
75
  """
76
76
 
77
- vault = _get_vault()
77
+ vault = Vault.get_instance()
78
78
  return vault.set_secret(secret)
79
79
 
80
80
 
81
81
  __all__ = [
82
82
  "SecretContainer",
83
+ "configure",
83
84
  "create_secret",
84
85
  "get_secret",
85
86
  "set_secret",
@@ -42,11 +42,23 @@ class Vault:
42
42
  vault.set_secret(secret)
43
43
  """
44
44
 
45
- def __init__(self):
46
- self.url, self.token = get_api_config()
45
+ _instance = None
46
+
47
+ @classmethod
48
+ def configure(cls, api_token: str | None = None):
49
+ cls._instance = cls(api_token)
50
+
51
+ def __init__(self, api_token: str | None = None):
52
+ self.url, self.token = get_api_config(api_token)
47
53
  self.session = requests.Session()
48
54
  self.session.headers.update(get_headers(self.token))
49
55
 
56
+ @classmethod
57
+ def get_instance(cls):
58
+ if cls._instance is None:
59
+ cls.configure()
60
+ return cls._instance
61
+
50
62
  def create_secret(self, secret: SecretContainer) -> SecretContainer:
51
63
  """
52
64
  Creates a new secret. Stores the secret in the `Automizor API`.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: automizor
3
- Version: 0.4.6
3
+ Version: 0.4.8
4
4
  Summary: Python Automizor framework
5
5
  Home-page: https://github.com/automizor/automizor-python
6
6
  Author: Christian Fischer
@@ -11,6 +11,7 @@ automizor.egg-info/dependency_links.txt
11
11
  automizor.egg-info/requires.txt
12
12
  automizor.egg-info/top_level.txt
13
13
  automizor/datastore/__init__.py
14
+ automizor/datastore/_container.py
14
15
  automizor/datastore/_datastore.py
15
16
  automizor/job/__init__.py
16
17
  automizor/job/_job.py
automizor-0.4.6/README.md DELETED
@@ -1 +0,0 @@
1
- # Automizor Python automation framework
@@ -1 +0,0 @@
1
- version = "0.4.6"
@@ -1,107 +0,0 @@
1
- import sys
2
- import types
3
- from functools import lru_cache
4
-
5
- from ._datastore import JSON
6
-
7
-
8
- @lru_cache
9
- def _get_datastore():
10
- from ._datastore import DataStore
11
-
12
- return DataStore()
13
-
14
-
15
- class DataStoreProxy(types.ModuleType):
16
- """
17
- `DataStoreProxy` acts as a dynamic interface for interacting with various types of
18
- data stores within the `Automizor Platform`. It provides a convenient way to access
19
- and manipulate data stored in JSON and Key-Key-Value (KKV) formats.
20
-
21
- This class leverages the `Automizor DataStore` module to fetch and update data,
22
- utilizing a caching mechanism to enhance performance. The primary interaction is
23
- through attribute access and assignment, making it simple to work with different
24
- data structures.
25
-
26
- Example usage:
27
-
28
- .. code-block:: python
29
-
30
- from automizor import datastore
31
-
32
- # Initialize or update json store
33
- datastore.countries = {
34
- "US": {
35
- "name": "United States",
36
- "capital": "Washington, D.C.",
37
- "population": 331449281,
38
- "area": 9833520
39
- },
40
- "CA": {
41
- "name": "Canada",
42
- "capital": "Ottawa",
43
- "population": 38005238,
44
- "area": 9984670
45
- }
46
- }
47
-
48
- # Get values from json store
49
- countries = datastore.countries()
50
-
51
- # Initialize or update kkv store
52
- datastore.movies = {
53
- "US": {
54
- "action": {
55
- "Die Hard": 1988,
56
- "The Matrix": 1999
57
- }
58
- }
59
- }
60
-
61
- # Get values from kkv store
62
- movies = datastore.movies("US")
63
- movies_action = datastore.movies("US", "action")
64
-
65
- # Insert or update values
66
- datastore.movies = {
67
- "US": {
68
- "action": {
69
- "Die Hard": 1988,
70
- "The Matrix": 1999,
71
- "John Wick": 2014
72
- },
73
- "comedy": {
74
- "The Hangover": 2009,
75
- "Superbad": 2007
76
- }
77
- }
78
- }
79
-
80
- # Delete secondary key
81
- datastore.movies = {
82
- "US": {
83
- "action": None
84
- }
85
- }
86
-
87
- # Delete primary key
88
- datastore.movies = {
89
- "US": None
90
- }
91
-
92
- """
93
-
94
- def __getattr__(self, name):
95
- datastore = _get_datastore()
96
-
97
- def wrapper(primary_key=None, secondary_key=None):
98
- return datastore.get_values(name, primary_key, secondary_key)
99
-
100
- return wrapper
101
-
102
- def __setattr__(self, name, values: JSON):
103
- datastore = _get_datastore()
104
- datastore.set_values(name, values)
105
-
106
-
107
- sys.modules[__name__] = DataStoreProxy(__name__)
@@ -1,31 +0,0 @@
1
- import os
2
- import platform
3
-
4
- from automizor import version
5
- from automizor.exceptions import AutomizorError
6
-
7
- OS_SYSTEM, OS_RELEASE, _ = platform.system_alias(
8
- platform.system(), platform.release(), platform.version()
9
- )
10
-
11
-
12
- def get_api_config() -> tuple[str, str]:
13
- token_string = os.getenv("AUTOMIZOR_AGENT_TOKEN")
14
-
15
- if not token_string:
16
- raise AutomizorError("AUTOMIZOR_AGENT_TOKEN is not set.")
17
-
18
- try:
19
- token, url = token_string.strip().split("@")
20
- except ValueError as exc:
21
- raise AutomizorError(
22
- "AUTOMIZOR_AGENT_TOKEN is not in the correct format."
23
- ) from exc
24
- return url, token
25
-
26
-
27
- def get_headers(token: str) -> dict:
28
- return {
29
- "Authorization": f"Token {token}",
30
- "User-Agent": f"Automizor/{version} {OS_SYSTEM}/{OS_RELEASE}",
31
- }
File without changes
File without changes
File without changes
File without changes