ansys-grantami-bomanalytics 2.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.
Files changed (27) hide show
  1. ansys_grantami_bomanalytics-2.2.0/AUTHORS +12 -0
  2. ansys_grantami_bomanalytics-2.2.0/LICENSE +21 -0
  3. ansys_grantami_bomanalytics-2.2.0/PKG-INFO +147 -0
  4. ansys_grantami_bomanalytics-2.2.0/README.rst +108 -0
  5. ansys_grantami_bomanalytics-2.2.0/pyproject.toml +179 -0
  6. ansys_grantami_bomanalytics-2.2.0/src/ansys/grantami/bomanalytics/__init__.py +29 -0
  7. ansys_grantami_bomanalytics-2.2.0/src/ansys/grantami/bomanalytics/_allowed_types.py +173 -0
  8. ansys_grantami_bomanalytics-2.2.0/src/ansys/grantami/bomanalytics/_bom_helper.py +140 -0
  9. ansys_grantami_bomanalytics-2.2.0/src/ansys/grantami/bomanalytics/_connection.py +533 -0
  10. ansys_grantami_bomanalytics-2.2.0/src/ansys/grantami/bomanalytics/_exceptions.py +35 -0
  11. ansys_grantami_bomanalytics-2.2.0/src/ansys/grantami/bomanalytics/_item_definitions.py +786 -0
  12. ansys_grantami_bomanalytics-2.2.0/src/ansys/grantami/bomanalytics/_item_results.py +2057 -0
  13. ansys_grantami_bomanalytics-2.2.0/src/ansys/grantami/bomanalytics/_logger.py +26 -0
  14. ansys_grantami_bomanalytics-2.2.0/src/ansys/grantami/bomanalytics/_query_results.py +991 -0
  15. ansys_grantami_bomanalytics-2.2.0/src/ansys/grantami/bomanalytics/_typing.py +71 -0
  16. ansys_grantami_bomanalytics-2.2.0/src/ansys/grantami/bomanalytics/bom_types/__init__.py +26 -0
  17. ansys_grantami_bomanalytics-2.2.0/src/ansys/grantami/bomanalytics/bom_types/_bom_reader.py +183 -0
  18. ansys_grantami_bomanalytics-2.2.0/src/ansys/grantami/bomanalytics/bom_types/_bom_types.py +1197 -0
  19. ansys_grantami_bomanalytics-2.2.0/src/ansys/grantami/bomanalytics/bom_types/_bom_writer.py +101 -0
  20. ansys_grantami_bomanalytics-2.2.0/src/ansys/grantami/bomanalytics/bom_types/_builders.py +299 -0
  21. ansys_grantami_bomanalytics-2.2.0/src/ansys/grantami/bomanalytics/indicators.py +580 -0
  22. ansys_grantami_bomanalytics-2.2.0/src/ansys/grantami/bomanalytics/py.typed +0 -0
  23. ansys_grantami_bomanalytics-2.2.0/src/ansys/grantami/bomanalytics/queries.py +1913 -0
  24. ansys_grantami_bomanalytics-2.2.0/src/ansys/grantami/bomanalytics/schemas/BillOfMaterialsEco1711.xsd +730 -0
  25. ansys_grantami_bomanalytics-2.2.0/src/ansys/grantami/bomanalytics/schemas/BillOfMaterialsEco2301.xsd +754 -0
  26. ansys_grantami_bomanalytics-2.2.0/src/ansys/grantami/bomanalytics/schemas/__init__.py +43 -0
  27. ansys_grantami_bomanalytics-2.2.0/src/ansys/grantami/bomanalytics/schemas/grantarecord1205.xsd +292 -0
@@ -0,0 +1,12 @@
1
+ # This is the list of PyGranta BoM Analytics' significant contributors.
2
+ #
3
+ # This file does not necessarily list everyone who has contributed code.
4
+ #
5
+ # For contributions made under a Corporate CLA, the organization is
6
+ # added to this file.
7
+ #
8
+ # If you have contributed to the repository and want to be added to this file,
9
+ # submit a request.
10
+ #
11
+ #
12
+ ANSYS, Inc.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 - 2024 ANSYS, Inc. and/or its affiliates.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
9
+ of the Software, and to permit persons to whom the Software is furnished to do
10
+ so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,147 @@
1
+ Metadata-Version: 2.1
2
+ Name: ansys-grantami-bomanalytics
3
+ Version: 2.2.0
4
+ Summary: Perform compliance and sustainability analysis on materials data stored in Granta MI.
5
+ Home-page: https://github.com/ansys/grantami-bomanalytics
6
+ License: MIT
7
+ Keywords: Ansys,Granta MI,Bill of Materials
8
+ Author: ANSYS, Inc.
9
+ Author-email: pyansys.core@ansys.com
10
+ Maintainer: ANSYS, Inc.
11
+ Maintainer-email: pyansys.core@ansys.com
12
+ Requires-Python: >=3.10.0,<4.0.0
13
+ Classifier: Development Status :: 5 - Production/Stable
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Operating System :: MacOS
17
+ Classifier: Operating System :: Microsoft :: Windows
18
+ Classifier: Operating System :: POSIX
19
+ Classifier: Programming Language :: Python :: 3
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Programming Language :: Python :: 3.13
24
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
25
+ Provides-Extra: examples
26
+ Requires-Dist: ansys-grantami-bomanalytics-openapi (==3.1.0)
27
+ Requires-Dist: ansys-openapi-common (>=2.0.0,<3.0.0)
28
+ Requires-Dist: ipywidgets (>=8.1.1,<9.0.0) ; extra == "examples"
29
+ Requires-Dist: jupyterlab (>=3,<5) ; extra == "examples"
30
+ Requires-Dist: lxml (>=4,<6) ; extra == "examples"
31
+ Requires-Dist: pandas (>=2.0,<3.0) ; extra == "examples"
32
+ Requires-Dist: plotly (>=5.17.0,<6.0.0) ; extra == "examples"
33
+ Requires-Dist: tabulate (>=0.9,<0.10) ; extra == "examples"
34
+ Requires-Dist: xmlschema (>=3.0.1,<4.0)
35
+ Project-URL: Documentation, https://bomanalytics.grantami.docs.pyansys.com
36
+ Project-URL: Repository, https://github.com/ansys/grantami-bomanalytics
37
+ Description-Content-Type: text/x-rst
38
+
39
+ |pyansys| |python| |pypi| |GH-CI| |codecov| |MIT| |black| |pre-commit-ci|
40
+
41
+ .. |pyansys| image:: https://img.shields.io/badge/Py-Ansys-ffc107.svg?labelColor=black&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAABDklEQVQ4jWNgoDfg5mD8vE7q/3bpVyskbW0sMRUwofHD7Dh5OBkZGBgW7/3W2tZpa2tLQEOyOzeEsfumlK2tbVpaGj4N6jIs1lpsDAwMJ278sveMY2BgCA0NFRISwqkhyQ1q/Nyd3zg4OBgYGNjZ2ePi4rB5loGBhZnhxTLJ/9ulv26Q4uVk1NXV/f///////69du4Zdg78lx//t0v+3S88rFISInD59GqIH2esIJ8G9O2/XVwhjzpw5EAam1xkkBJn/bJX+v1365hxxuCAfH9+3b9/+////48cPuNehNsS7cDEzMTAwMMzb+Q2u4dOnT2vWrMHu9ZtzxP9vl/69RVpCkBlZ3N7enoDXBwEAAA+YYitOilMVAAAAAElFTkSuQmCC
42
+ :target: https://docs.pyansys.com/
43
+ :alt: PyAnsys
44
+
45
+ .. |python| image:: https://img.shields.io/pypi/pyversions/ansys-grantami-bomanalytics?logo=pypi
46
+ :target: https://pypi.org/project/ansys-grantami-bomanalytics/
47
+ :alt: Python
48
+
49
+ .. |pypi| image:: https://img.shields.io/pypi/v/ansys-grantami-bomanalytics.svg?logo=python&logoColor=white
50
+ :target: https://pypi.org/project/ansys-grantami-bomanalytics
51
+ :alt: PyPI
52
+
53
+ .. |codecov| image:: https://codecov.io/gh/ansys/grantami-bomanalytics/branch/main/graph/badge.svg
54
+ :target: https://codecov.io/gh/ansys/grantami-bomanalytics
55
+ :alt: Codecov
56
+
57
+ .. |GH-CI| image:: https://github.com/ansys/grantami-bomanalytics/actions/workflows/ci_cd.yml/badge.svg
58
+ :target: https://github.com/ansys/grantami-bomanalytics/actions/workflows/ci_cd.yml
59
+ :alt: GH-CI
60
+
61
+ .. |MIT| image:: https://img.shields.io/badge/License-MIT-yellow.svg
62
+ :target: https://opensource.org/licenses/MIT
63
+ :alt: MIT
64
+
65
+ .. |black| image:: https://img.shields.io/badge/code%20style-black-000000.svg?style=flat
66
+ :target: https://github.com/psf/black
67
+ :alt: Black
68
+
69
+ .. |pre-commit-ci| image:: https://results.pre-commit.ci/badge/github/ansys/grantami-bomanalytics/main.svg
70
+ :target: https://results.pre-commit.ci/latest/github/ansys/grantami-bomanalytics/main
71
+ :alt: pre-commit.ci status
72
+
73
+
74
+ PyGranta BoM Analytics
75
+ ======================
76
+
77
+ ..
78
+ _after-badges
79
+
80
+ The MI Restricted Substances and MI Sustainability solutions for Granta MI include REST APIs for:
81
+
82
+ - Evaluating compliance of products, assemblies, specifications, and
83
+ materials against legislations.
84
+ - Evaluating the environmental performance of products, assemblies, materials and processes.
85
+
86
+ This package abstracts automatically-generated code into an easy-to-use client library.
87
+
88
+
89
+ Dependencies
90
+ ------------
91
+ .. readme_software_requirements
92
+
93
+ To use the ``grantami-bomanalytics`` package, you must have access to a Granta MI server that
94
+ includes MI Restricted Substances and Sustainability Reports 2024 R2 or later.
95
+
96
+ ``MI Restricted Substances`` and ``MI Sustainability`` are licensed separately.
97
+ Endpoints available to end users depend on the available licenses.
98
+
99
+ The ``ansys.grantami.bomanalytics`` package currently supports Python version 3.10 through 3.13.
100
+
101
+ .. readme_software_requirements_end
102
+
103
+
104
+ Installation
105
+ ------------
106
+ .. readme_installation
107
+
108
+ To install the latest PyGranta BoM Analytics release from
109
+ `PyPI <https://pypi.org/project/ansys-grantami-bomanalytics/>`_, run this command:
110
+
111
+ .. code::
112
+
113
+ pip install ansys-grantami-bomanalytics
114
+
115
+ To install a release compatible with a specific version of Granta MI Restricted Substances and Sustainability Reports,
116
+ install the `PyGranta <https://grantami.docs.pyansys.com/>`_ metapackage with a requirement specifier:
117
+
118
+ .. code::
119
+
120
+ pip install pygranta==2023.2.0
121
+
122
+ To see which individual PyGranta package versions are installed with each version of the PyGranta metapackage, consult
123
+ the `Package versions <https://grantami.docs.pyansys.com/version/dev/package_versions.html>`_ section of the PyGranta
124
+ documentation.
125
+
126
+ Alternatively, to install the latest development version from the
127
+ `PyGranta BoM Analytics repository <https://github.com/ansys/grantami-bomanalytics>`_, run this command:
128
+
129
+ .. code::
130
+
131
+ pip install git+https://github.com/ansys/grantami-bomanalytics.git
132
+
133
+
134
+ To install a local *development* version with Git and Poetry, run these commands:
135
+
136
+ .. code::
137
+
138
+ git clone https://github.com/ansys/grantami-bomanalytics
139
+ cd grantami-bomanalytics
140
+ poetry install
141
+
142
+
143
+ The preceding commands install the package in development mode so that you can modify
144
+ it locally. Your changes are reflected in your Python setup after restarting the Python kernel.
145
+
146
+ .. readme_installation_end
147
+
@@ -0,0 +1,108 @@
1
+ |pyansys| |python| |pypi| |GH-CI| |codecov| |MIT| |black| |pre-commit-ci|
2
+
3
+ .. |pyansys| image:: https://img.shields.io/badge/Py-Ansys-ffc107.svg?labelColor=black&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAABDklEQVQ4jWNgoDfg5mD8vE7q/3bpVyskbW0sMRUwofHD7Dh5OBkZGBgW7/3W2tZpa2tLQEOyOzeEsfumlK2tbVpaGj4N6jIs1lpsDAwMJ278sveMY2BgCA0NFRISwqkhyQ1q/Nyd3zg4OBgYGNjZ2ePi4rB5loGBhZnhxTLJ/9ulv26Q4uVk1NXV/f///////69du4Zdg78lx//t0v+3S88rFISInD59GqIH2esIJ8G9O2/XVwhjzpw5EAam1xkkBJn/bJX+v1365hxxuCAfH9+3b9/+////48cPuNehNsS7cDEzMTAwMMzb+Q2u4dOnT2vWrMHu9ZtzxP9vl/69RVpCkBlZ3N7enoDXBwEAAA+YYitOilMVAAAAAElFTkSuQmCC
4
+ :target: https://docs.pyansys.com/
5
+ :alt: PyAnsys
6
+
7
+ .. |python| image:: https://img.shields.io/pypi/pyversions/ansys-grantami-bomanalytics?logo=pypi
8
+ :target: https://pypi.org/project/ansys-grantami-bomanalytics/
9
+ :alt: Python
10
+
11
+ .. |pypi| image:: https://img.shields.io/pypi/v/ansys-grantami-bomanalytics.svg?logo=python&logoColor=white
12
+ :target: https://pypi.org/project/ansys-grantami-bomanalytics
13
+ :alt: PyPI
14
+
15
+ .. |codecov| image:: https://codecov.io/gh/ansys/grantami-bomanalytics/branch/main/graph/badge.svg
16
+ :target: https://codecov.io/gh/ansys/grantami-bomanalytics
17
+ :alt: Codecov
18
+
19
+ .. |GH-CI| image:: https://github.com/ansys/grantami-bomanalytics/actions/workflows/ci_cd.yml/badge.svg
20
+ :target: https://github.com/ansys/grantami-bomanalytics/actions/workflows/ci_cd.yml
21
+ :alt: GH-CI
22
+
23
+ .. |MIT| image:: https://img.shields.io/badge/License-MIT-yellow.svg
24
+ :target: https://opensource.org/licenses/MIT
25
+ :alt: MIT
26
+
27
+ .. |black| image:: https://img.shields.io/badge/code%20style-black-000000.svg?style=flat
28
+ :target: https://github.com/psf/black
29
+ :alt: Black
30
+
31
+ .. |pre-commit-ci| image:: https://results.pre-commit.ci/badge/github/ansys/grantami-bomanalytics/main.svg
32
+ :target: https://results.pre-commit.ci/latest/github/ansys/grantami-bomanalytics/main
33
+ :alt: pre-commit.ci status
34
+
35
+
36
+ PyGranta BoM Analytics
37
+ ======================
38
+
39
+ ..
40
+ _after-badges
41
+
42
+ The MI Restricted Substances and MI Sustainability solutions for Granta MI include REST APIs for:
43
+
44
+ - Evaluating compliance of products, assemblies, specifications, and
45
+ materials against legislations.
46
+ - Evaluating the environmental performance of products, assemblies, materials and processes.
47
+
48
+ This package abstracts automatically-generated code into an easy-to-use client library.
49
+
50
+
51
+ Dependencies
52
+ ------------
53
+ .. readme_software_requirements
54
+
55
+ To use the ``grantami-bomanalytics`` package, you must have access to a Granta MI server that
56
+ includes MI Restricted Substances and Sustainability Reports 2024 R2 or later.
57
+
58
+ ``MI Restricted Substances`` and ``MI Sustainability`` are licensed separately.
59
+ Endpoints available to end users depend on the available licenses.
60
+
61
+ The ``ansys.grantami.bomanalytics`` package currently supports Python version 3.10 through 3.13.
62
+
63
+ .. readme_software_requirements_end
64
+
65
+
66
+ Installation
67
+ ------------
68
+ .. readme_installation
69
+
70
+ To install the latest PyGranta BoM Analytics release from
71
+ `PyPI <https://pypi.org/project/ansys-grantami-bomanalytics/>`_, run this command:
72
+
73
+ .. code::
74
+
75
+ pip install ansys-grantami-bomanalytics
76
+
77
+ To install a release compatible with a specific version of Granta MI Restricted Substances and Sustainability Reports,
78
+ install the `PyGranta <https://grantami.docs.pyansys.com/>`_ metapackage with a requirement specifier:
79
+
80
+ .. code::
81
+
82
+ pip install pygranta==2023.2.0
83
+
84
+ To see which individual PyGranta package versions are installed with each version of the PyGranta metapackage, consult
85
+ the `Package versions <https://grantami.docs.pyansys.com/version/dev/package_versions.html>`_ section of the PyGranta
86
+ documentation.
87
+
88
+ Alternatively, to install the latest development version from the
89
+ `PyGranta BoM Analytics repository <https://github.com/ansys/grantami-bomanalytics>`_, run this command:
90
+
91
+ .. code::
92
+
93
+ pip install git+https://github.com/ansys/grantami-bomanalytics.git
94
+
95
+
96
+ To install a local *development* version with Git and Poetry, run these commands:
97
+
98
+ .. code::
99
+
100
+ git clone https://github.com/ansys/grantami-bomanalytics
101
+ cd grantami-bomanalytics
102
+ poetry install
103
+
104
+
105
+ The preceding commands install the package in development mode so that you can modify
106
+ it locally. Your changes are reflected in your Python setup after restarting the Python kernel.
107
+
108
+ .. readme_installation_end
@@ -0,0 +1,179 @@
1
+ [build-system]
2
+ requires = ["poetry-core>=1.0.0"]
3
+ build-backend = "poetry.core.masonry.api"
4
+
5
+ [tool.poetry]
6
+ name = "ansys-grantami-bomanalytics"
7
+ description = "Perform compliance and sustainability analysis on materials data stored in Granta MI."
8
+ version = "2.2.0"
9
+ license = "MIT"
10
+ authors = ["ANSYS, Inc. <pyansys.core@ansys.com>"]
11
+ maintainers = ["ANSYS, Inc. <pyansys.core@ansys.com>"]
12
+ repository = "https://github.com/ansys/grantami-bomanalytics"
13
+ documentation = "https://bomanalytics.grantami.docs.pyansys.com"
14
+ readme = "README.rst"
15
+ keywords = [
16
+ "Ansys",
17
+ "Granta MI",
18
+ "Bill of Materials",
19
+ ]
20
+ classifiers = [
21
+ "License :: OSI Approved :: MIT License",
22
+ "Development Status :: 5 - Production/Stable",
23
+ "Intended Audience :: Science/Research",
24
+ "Topic :: Scientific/Engineering :: Information Analysis",
25
+ "Operating System :: Microsoft :: Windows",
26
+ "Operating System :: POSIX",
27
+ "Operating System :: MacOS",
28
+ "Programming Language :: Python :: 3",
29
+ "Programming Language :: Python :: 3.10",
30
+ "Programming Language :: Python :: 3.11",
31
+ "Programming Language :: Python :: 3.12",
32
+ "Programming Language :: Python :: 3.13",
33
+ ]
34
+ packages = [
35
+ { include = "ansys", from = "src" }
36
+ ]
37
+
38
+ [tool.poetry.dependencies]
39
+ python = "^3.10.0"
40
+
41
+ # Packages for core library
42
+ ansys-openapi-common = "^2.0.0"
43
+ ansys-grantami-bomanalytics-openapi = { version = "3.1.0", allow-prereleases = true }
44
+ xmlschema = ">=3.0.1,<4.0"
45
+
46
+ # Packages for the examples extra
47
+ jupyterlab = { version = ">=3,<5", optional = true }
48
+ lxml = { version = ">=4,<6", optional = true }
49
+ pandas = { version = "^2.0", optional = true }
50
+ tabulate = { version = "^0.9", optional = true }
51
+ plotly = { version = "^5.17.0", optional = true }
52
+ ipywidgets = { version = "^8.1.1", optional = true }
53
+
54
+
55
+ [tool.poetry.group.dev.dependencies]
56
+ # Common packages for test and examples
57
+ jupyterlab = ">=3,<5"
58
+ lxml = ">=4,<6"
59
+ pandas = "^2.0"
60
+ tabulate = "^0.9"
61
+ pytest = ">=7,<9"
62
+ pytest-cov = ">=4,<7"
63
+ requests-mock = "^1"
64
+ ipython = "^8"
65
+ plotly = "^5.17.0"
66
+ ipywidgets = "^8.1.1"
67
+ mypy = "^1.9.0"
68
+
69
+ [tool.poetry.group.doc]
70
+ optional = true
71
+
72
+ [tool.poetry.group.doc.dependencies]
73
+ # Doc packages
74
+ ansys-sphinx-theme = ">=0.12,<1.3"
75
+ numpydoc = "^1.6.0"
76
+ sphinx = ">=7.1,<9.0"
77
+ sphinx-notfound-page = "^1.0.0"
78
+ sphinx-copybutton = "^0.5.2"
79
+ sphinx-design = ">=0.5,<0.7"
80
+ enum_tools = ">=0.11,<0.13"
81
+ sphinx-toolbox = "^3.5.0"
82
+ jupytext = "^1.15.2"
83
+ nbsphinx = "^0.9.3"
84
+
85
+ [tool.poetry.extras]
86
+
87
+ examples = [
88
+ "lxml",
89
+ "tabulate",
90
+ "pandas",
91
+ "jupyterlab",
92
+ "plotly",
93
+ "ipywidgets",
94
+ ]
95
+
96
+ [tool.mypy]
97
+ warn_return_any = true
98
+ warn_unused_configs = true
99
+ warn_redundant_casts = true
100
+ warn_unused_ignores = true
101
+ disallow_untyped_defs = true
102
+ no_implicit_optional = true
103
+ check_untyped_defs = true
104
+ show_error_codes = true
105
+ files = "src"
106
+ explicit_package_bases = true
107
+ mypy_path = "$MYPY_CONFIG_FILE_DIR/src"
108
+ namespace_packages = true
109
+
110
+ [tool.pytest.ini_options]
111
+ testpaths = "./tests"
112
+ markers = [
113
+ """integration: test requires a real database (deselect with '-m \"not integration\"')"""
114
+ ]
115
+
116
+ [tool.black]
117
+ line-length = 120
118
+
119
+ [tool.pydocstyle]
120
+ convention = "numpy"
121
+
122
+ [tool.isort]
123
+ profile = "black"
124
+ force_sort_within_sections = true
125
+ line_length = 100
126
+ default_section = "THIRDPARTY"
127
+ skip_gitignore = true
128
+ skip = [".ipython", "cicd", "examples", "examples-dummy"]
129
+ src_paths = ["src", "tests"]
130
+
131
+ [tool.towncrier]
132
+ package = "ansys.grantami.bomanalytics"
133
+ directory = "doc/changelog.d"
134
+ filename = "CHANGELOG.md"
135
+ start_string = "<!-- towncrier release notes start -->\n"
136
+ underlines = ["", "", ""]
137
+ template = "doc/changelog.d/changelog_template.jinja"
138
+ title_format = "## [{version}](https://github.com/ansys/grantami-bomanalytics/releases/tag/v{version}) - {project_date}"
139
+ issue_format = "[#{issue}](https://github.com/ansys/grantami-bomanalytics/pull/{issue})"
140
+
141
+ [[tool.towncrier.type]]
142
+ directory = "added"
143
+ name = "Added"
144
+ showcontent = true
145
+
146
+ [[tool.towncrier.type]]
147
+ directory = "changed"
148
+ name = "Changed"
149
+ showcontent = true
150
+
151
+ [[tool.towncrier.type]]
152
+ directory = "fixed"
153
+ name = "Fixed"
154
+ showcontent = true
155
+
156
+ [[tool.towncrier.type]]
157
+ directory = "dependencies"
158
+ name = "Dependencies"
159
+ showcontent = true
160
+
161
+ [[tool.towncrier.type]]
162
+ directory = "miscellaneous"
163
+ name = "Miscellaneous"
164
+ showcontent = true
165
+
166
+ [[tool.towncrier.type]]
167
+ directory = "documentation"
168
+ name = "Documentation"
169
+ showcontent = true
170
+
171
+ [[tool.towncrier.type]]
172
+ directory = "maintenance"
173
+ name = "Maintenance"
174
+ showcontent = true
175
+
176
+ [[tool.towncrier.type]]
177
+ directory = "test"
178
+ name = "Test"
179
+ showcontent = true
@@ -0,0 +1,29 @@
1
+ # Copyright (C) 2022 - 2024 ANSYS, Inc. and/or its affiliates.
2
+ # SPDX-License-Identifier: MIT
3
+ #
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+
23
+ from importlib import metadata as metadata
24
+
25
+ from ._bom_helper import BoMHandler
26
+ from ._connection import Connection
27
+ from ._exceptions import GrantaMIException, LicensingException
28
+
29
+ __version__ = metadata.version("ansys-grantami-bomanalytics")
@@ -0,0 +1,173 @@
1
+ # Copyright (C) 2022 - 2024 ANSYS, Inc. and/or its affiliates.
2
+ # SPDX-License-Identifier: MIT
3
+ #
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+
23
+ """BoM Analytics runtime type checker.
24
+
25
+ Provides a decorator that performs runtime type checking of the arguments passed into a function or method.
26
+
27
+ Attributes
28
+ ----------
29
+ T
30
+ Generic type to ensure static-type checking works as expected.
31
+ """
32
+
33
+ import functools
34
+ from typing import Any, Callable, Type, TypeVar
35
+
36
+ T = TypeVar("T")
37
+
38
+
39
+ def validate_argument_type(*allowed_types: Any) -> Callable:
40
+ """Validates the types of values passed into a method. This decorator function accepts one or more
41
+ objects against which types are checked.
42
+
43
+ * If one object is provided, the value must be of that object's type.
44
+ * If multiple objects are provided, the value must be of at least one object's types.
45
+ * If a container of objects are provided, the types are validated recursively.
46
+
47
+ Tuples and lists can be heterogeneous, where the ordering of the items in the containers is taken into account.
48
+ Dictionaries and sets must be homogeneous. If they are not exactly one item in length, a ``ValueError`` is raised.
49
+
50
+ Parameters
51
+ ----------
52
+ *allowed_types
53
+ Tuple of objects whose type should match the corresponding function argument's type.
54
+
55
+ Raises
56
+ ------
57
+ TypeError
58
+ If the type of an object passed to the decorator does not match the type of the corresponding argument.
59
+ If the number of objects passed to the decorator does not match the number of arguments passed to the wrapped
60
+ function.
61
+ ValueError
62
+ If a list or tuple does not contain either one item or a number of items equal to the container being checked.
63
+ If a dictionary or set does not contain exactly one item.
64
+
65
+ Examples
66
+ --------
67
+ >>> @validate_argument_type([str]):
68
+ >>> def process_records(self, records):
69
+ >>> ...
70
+
71
+ >>> self.process_records(['Record 1', 'Record 2']) # No error raised
72
+
73
+ >>> self.process_records('Record 1') # TypeError ('Record 1' is not a list)
74
+
75
+ >>> self.process_records(['Record 1', 2]) # TypeError (2 is not a str)
76
+ """
77
+
78
+ def decorator(method: Type[T]) -> Callable[[Any, Any], T]:
79
+ @functools.wraps(method)
80
+ def check_types(*args: Any, **kwargs: Any) -> T:
81
+ values = list(args)[1:] + list(kwargs.values())
82
+ if len(values) != 1:
83
+ raise TypeError(
84
+ f"The allowed_types decorator can only be used on a method called with "
85
+ f'exactly one argument. The method "{method.__name__}" was called with {len(values)} '
86
+ f"arguments."
87
+ )
88
+ value = values[0]
89
+ result = any([_check_type_wrapper(value, allowed_type) for allowed_type in allowed_types])
90
+ if not result:
91
+ raise TypeError(f'Incorrect type for value "{value}". Expected "{allowed_types}"')
92
+ return method(*args, **kwargs)
93
+
94
+ return check_types
95
+
96
+ return decorator
97
+
98
+
99
+ def _check_type_wrapper(value_obj: Any, type_obj: Any) -> bool:
100
+ try:
101
+ _check_type(value_obj, type_obj)
102
+ return True
103
+ except AssertionError:
104
+ return False
105
+
106
+
107
+ def _check_type(value_obj: Any, type_obj: Any) -> None:
108
+ """Recursively checks the type of an object against an allowed type.
109
+
110
+ Recursive checking is performed if the ``allowed_type`` parameter is a container. First the type of the
111
+ container itself is checked. The contents of object are then checked against the contents of the
112
+ ``allowed_type`` parameter.
113
+
114
+ Parameters
115
+ ----------
116
+ value_obj
117
+ Object to check.
118
+ type_obj
119
+ Object to checked against.
120
+
121
+ Returns
122
+ -------
123
+ None
124
+ This function never returns a value. It either returns ``None`` or raises an exception.
125
+
126
+ Raises
127
+ ------
128
+ AssertionError
129
+ If the type of ``obj`` does not match the type of ``allowed_type``.
130
+ ValueError
131
+ If a container's length is mismatched against the object being checked.
132
+ """
133
+
134
+ if isinstance(type_obj, (list, tuple)):
135
+ assert isinstance(value_obj, (list, tuple))
136
+ if len(type_obj) == 1:
137
+ contained_type = type_obj[0]
138
+ for value in value_obj:
139
+ _check_type(value, contained_type)
140
+ elif len(type_obj) == len(value_obj):
141
+ for value, contained_type in zip(value_obj, type_obj):
142
+ _check_type(value, contained_type)
143
+ else:
144
+ raise ValueError(
145
+ "List or tuple containers must be either of length one or the same length as the "
146
+ "object being checked."
147
+ f"Container length: {len(type_obj)}, object length: {len(value_obj)}"
148
+ )
149
+ elif isinstance(type_obj, set):
150
+ assert isinstance(value_obj, set)
151
+ if len(type_obj) != 1:
152
+ raise ValueError(
153
+ "Sets must be homogeneous: they can only contain a single object against "
154
+ "which the type should be checked."
155
+ )
156
+ contained_type = next(iter(type_obj))
157
+ for value in value_obj:
158
+ _check_type(value, contained_type)
159
+ elif isinstance(type_obj, dict):
160
+ assert isinstance(value_obj, dict)
161
+ if len(type_obj) != 1:
162
+ raise ValueError(
163
+ "Dictionaries must be homogeneous: they can only contain a single object "
164
+ "against which the type should be checked."
165
+ )
166
+ contained_key_type = next(iter(type_obj.keys()))
167
+ for key in value_obj.keys():
168
+ _check_type(key, contained_key_type)
169
+ contained_value_type = next(iter(type_obj.values()))
170
+ for value in value_obj.values():
171
+ _check_type(value, contained_value_type)
172
+ else:
173
+ assert isinstance(value_obj, type_obj)