commonlib-reader 1.1.2__tar.gz → 1.2.0__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.
@@ -0,0 +1,39 @@
1
+ Metadata-Version: 2.3
2
+ Name: commonlib-reader
3
+ Version: 1.2.0
4
+ Summary: Reader for Equinor commonlib api.
5
+ Author: Åsmund Våge Fannemel
6
+ Author-email: Åsmund Våge Fannemel <asmf@equinor.com>
7
+ License: MIT
8
+ Requires-Dist: pandas>=2.1.4
9
+ Requires-Dist: eq-api-connector>=1.1.0,<2.0.0
10
+ Requires-Python: >=3.10, <4.0.0
11
+ Project-URL: Repository, https://github.com/equinor/commonlib-reader.git
12
+ Description-Content-Type: text/markdown
13
+
14
+ # commonlib-reader
15
+ Connector package for Equinor [Commonlib](https://commonlib.equinor.com/) [api](https://commonlibapi.equinor.com/swagger/index.html).
16
+
17
+ Current features:
18
+ - Reading code tables
19
+ - Getting facility data using the [Facility](commonlib_reader/facility.py) class
20
+ - [IMS source ](commonlib_reader/ims.py) lookup tables for facilities
21
+ - Getting Tag category, Tag type, Tag format, and Tag format element data. See [tag.py](commonlib_reader/tag.py)
22
+ - Getting [units of measure](commonlib_reader/ims.py) definitions.
23
+
24
+
25
+ ## Use
26
+ Try it out by running the [demo](examples/demo.py).
27
+
28
+ ## Installing
29
+
30
+ Install package from pypi using `pip install commonlib_reader`
31
+
32
+
33
+ ## Developing / testing
34
+
35
+ uv is preferred for developers. Clone and install with required packages for testing and coverage:
36
+ `uv sync`
37
+
38
+ For testing with coverage run:
39
+ `uv run pytest --cov --cov-report=html`
@@ -1,4 +1,4 @@
1
- # commonlib-reader [![SNYK dependency check](https://github.com/equinor/commonlib-reader/actions/workflows/snyk.yml/badge.svg)](https://github.com/equinor/commonlib-reader/actions/workflows/snyk.yml)
1
+ # commonlib-reader
2
2
  Connector package for Equinor [Commonlib](https://commonlib.equinor.com/) [api](https://commonlibapi.equinor.com/swagger/index.html).
3
3
 
4
4
  Current features:
@@ -19,8 +19,8 @@ Install package from pypi using `pip install commonlib_reader`
19
19
 
20
20
  ## Developing / testing
21
21
 
22
- Poetry is preferred for developers. Clone and install with required packages for testing and coverage:
23
- `poetry install`
22
+ uv is preferred for developers. Clone and install with required packages for testing and coverage:
23
+ `uv sync`
24
24
 
25
- For testing with coverage run:
26
- `poetry run pytest --cov --cov-report=html`
25
+ For testing with coverage run:
26
+ `uv run pytest --cov --cov-report=html`
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "commonlib-reader"
3
- version = "1.1.2"
3
+ version = "1.2.0"
4
4
  description = "Reader for Equinor commonlib api."
5
5
  authors = [
6
6
  { name = "Åsmund Våge Fannemel", email = "asmf@equinor.com" }
@@ -11,18 +11,16 @@ urls = {"Repository" = "https://github.com/equinor/commonlib-reader.git"}
11
11
  requires-python = ">=3.10,<4.0.0"
12
12
  dependencies = [
13
13
  "pandas>=2.1.4",
14
- "requests>=2.32.4",
15
- "urllib3>=2.5.0", # Pinned to avoid security issues in some older versions
16
- "eq-api-connector (>=1.0.0,<2.0.0)"
14
+ "eq-api-connector (>=1.1.0,<2.0.0)"
17
15
  ]
18
16
 
19
- [tool.poetry.group.test.dependencies]
20
- pytest = "^7.4.4"
21
- pytest-cov = "^6.0.0"
22
-
23
- [tool.poetry.group.dev.dependencies]
24
- black = "^24.1.1"
17
+ [dependency-groups]
18
+ dev = [
19
+ "pytest>=7.4.4,<10.0.0",
20
+ "pytest-cov>=7.0.0,<8.0.0",
21
+ "black>=24.1.1,<27.0.0"
22
+ ]
25
23
 
26
24
  [build-system]
27
- requires = ["poetry-core"]
28
- build-backend = "poetry.core.masonry.api"
25
+ requires = ["uv_build>=0.11.16,<0.12"]
26
+ build-backend = "uv_build"
@@ -1,6 +1,6 @@
1
1
  from eq_api_connector import APIConnector
2
2
 
3
- _connector = None
3
+ _connector: APIConnector | None = None
4
4
 
5
5
 
6
6
  def get_connector() -> APIConnector:
@@ -13,17 +13,23 @@ def get_connector() -> APIConnector:
13
13
  if _connector is None:
14
14
  clientID = "728cfddd-b8e9-4ed7-b9a3-8f2fd5b8e79a"
15
15
  scopes = ["37d598fc-da0f-46bd-949f-7107918d47a5/user_impersonation"]
16
- _connector = APIConnector(client_id=clientID, scope=scopes)
17
- _connector.set_url_prod("https://commonlibapi.equinor.com/")
16
+ connector = APIConnector(client_id=clientID, scope=scopes)
17
+ connector.set_url_prod("https://commonlibapi.equinor.com/")
18
+ _connector = connector
18
19
 
19
20
  return _connector
20
21
 
21
22
 
22
- def set_connector(connector: APIConnector):
23
+ def set_connector(connector: APIConnector) -> None:
23
24
  """Set the singleton instance of the APIConnector.
24
25
 
25
26
  Args:
26
27
  connector (APIConnector): An instance of the APIConnector class.
27
28
  """
28
29
  global _connector
30
+
31
+ if not isinstance(connector, APIConnector):
32
+ raise TypeError(
33
+ f"Connector must be an instance of APIConnector, got {type(connector).__name__}."
34
+ )
29
35
  _connector = connector
@@ -60,7 +60,7 @@ def post_sql(sql: str, take: int = 100, skip: int = 0) -> list:
60
60
  list: List of response from api
61
61
  """
62
62
 
63
- url = urljoin(get_connector().get_url(), "api/sql")
63
+ url = urljoin(get_connector().url, "api/sql")
64
64
  response = requests.post(
65
65
  url=url,
66
66
  json={"query": sql, "take": take, "skip": skip},
@@ -1,49 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: commonlib-reader
3
- Version: 1.1.2
4
- Summary: Reader for Equinor commonlib api.
5
- License: MIT
6
- Author: Åsmund Våge Fannemel
7
- Author-email: asmf@equinor.com
8
- Requires-Python: >=3.10,<4.0.0
9
- Classifier: License :: OSI Approved :: MIT License
10
- Classifier: Programming Language :: Python :: 3
11
- Classifier: Programming Language :: Python :: 3.10
12
- Classifier: Programming Language :: Python :: 3.11
13
- Classifier: Programming Language :: Python :: 3.12
14
- Classifier: Programming Language :: Python :: 3.13
15
- Classifier: Programming Language :: Python :: 3.14
16
- Requires-Dist: eq-api-connector (>=1.0.0,<2.0.0)
17
- Requires-Dist: pandas (>=2.1.4)
18
- Requires-Dist: requests (>=2.32.4)
19
- Requires-Dist: urllib3 (>=2.5.0)
20
- Project-URL: Repository, https://github.com/equinor/commonlib-reader.git
21
- Description-Content-Type: text/markdown
22
-
23
- # commonlib-reader [![SNYK dependency check](https://github.com/equinor/commonlib-reader/actions/workflows/snyk.yml/badge.svg)](https://github.com/equinor/commonlib-reader/actions/workflows/snyk.yml)
24
- Connector package for Equinor [Commonlib](https://commonlib.equinor.com/) [api](https://commonlibapi.equinor.com/swagger/index.html).
25
-
26
- Current features:
27
- - Reading code tables
28
- - Getting facility data using the [Facility](commonlib_reader/facility.py) class
29
- - [IMS source ](commonlib_reader/ims.py) lookup tables for facilities
30
- - Getting Tag category, Tag type, Tag format, and Tag format element data. See [tag.py](commonlib_reader/tag.py)
31
- - Getting [units of measure](commonlib_reader/ims.py) definitions.
32
-
33
-
34
- ## Use
35
- Try it out by running the [demo](examples/demo.py).
36
-
37
- ## Installing
38
-
39
- Install package from pypi using `pip install commonlib_reader`
40
-
41
-
42
- ## Developing / testing
43
-
44
- Poetry is preferred for developers. Clone and install with required packages for testing and coverage:
45
- `poetry install`
46
-
47
- For testing with coverage run:
48
- `poetry run pytest --cov --cov-report=html`
49
-