From d192217e780adafcdfcc93e05c87822c3f1b2053 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Wed, 12 Jun 2024 18:44:51 +1000 Subject: [PATCH] bSDD workflow now uses VERSION --- .github/workflows/ci-bsdd-pypi.yaml | 13 ---- src/bsdd/Makefile | 10 ++- src/bsdd/__init__.py | 1 - src/bsdd/bsdd.py | 103 +++++++++++++++++++--------- src/bsdd/pyproject.toml | 28 ++++---- 5 files changed, 88 insertions(+), 67 deletions(-) delete mode 100644 src/bsdd/__init__.py diff --git a/.github/workflows/ci-bsdd-pypi.yaml b/.github/workflows/ci-bsdd-pypi.yaml index e1ccf133b0..67da096296 100644 --- a/.github/workflows/ci-bsdd-pypi.yaml +++ b/.github/workflows/ci-bsdd-pypi.yaml @@ -1,21 +1,8 @@ name: ci-bsdd-pypi on: - schedule: - # ┌───────────── minute (0 - 59) - # │ ┌───────────── hour (0 - 23) - # │ │ ┌───────────── day of the month (1 - 31) - # │ │ │ ┌───────────── month (1 - 12 or JAN-DEC) - # │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT) - # * * * * * - - cron: "0 0 18 * *" workflow_dispatch: -env: - major: 0 - minor: 0 - name: ifcopenshell - jobs: activate: runs-on: ubuntu-latest diff --git a/src/bsdd/Makefile b/src/bsdd/Makefile index 6880922653..4dc7bdc5f5 100644 --- a/src/bsdd/Makefile +++ b/src/bsdd/Makefile @@ -16,7 +16,7 @@ # You should have received a copy of the GNU Lesser General Public License # along with bSDD. If not, see . -VERSION:=`date '+%y%m%d'` +VERSION:=$(shell cat ../../VERSION) SED:=sed -i ifeq ($(UNAME_S),Darwin) SED:=sed -i '' -e @@ -29,6 +29,10 @@ test: .PHONY: dist dist: rm -rf dist - $(SED) "s/999999/$(VERSION)/" pyproject.toml + cp pyproject.toml pyproject.toml.bak + cp bsdd.py bsdd.py.bak + $(SED) 's/version = "0.0.0"/version = "$(VERSION)"/' pyproject.toml + $(SED) 's/version = "0.0.0"/version = "$(VERSION)"/' bsdd.py python -m build - $(SED) "s/$(VERSION)/999999/" pyproject.toml + mv pyproject.toml.bak pyproject.toml + mv bsdd.py.bak bsdd.py diff --git a/src/bsdd/__init__.py b/src/bsdd/__init__.py deleted file mode 100644 index e3ef289dcf..0000000000 --- a/src/bsdd/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .bsdd import * \ No newline at end of file diff --git a/src/bsdd/bsdd.py b/src/bsdd/bsdd.py index 7cc7301668..31c87ecdcb 100644 --- a/src/bsdd/bsdd.py +++ b/src/bsdd/bsdd.py @@ -25,6 +25,9 @@ import webbrowser import http.server from typing import TypedDict, Literal, Optional + +__version__ = version = "0.0.0" + Status = Literal["Preview", "Active", "Inactive"] ClassTypes = Literal["Class", "GroupOfProperties", "AlternativeUse", "Material"] @@ -517,14 +520,16 @@ class Client: # deprecated def Property(self, namespaceUri, version="v2", languageCode=""): print(f"function 'Client.Property' is deprecated, use 'Client.get_property' instead") - return self._get_deprecated(f"api/Property/{version}", - {"namespaceUri": namespaceUri, "languageCode": languageCode}) + return self._get_deprecated( + f"api/Property/{version}", {"namespaceUri": namespaceUri, "languageCode": languageCode} + ) # deprecated def PropertyValue(self, namespaceUri, version="v1", languageCode=""): print(f"function 'Client.PropertyValue' is deprecated, use 'Client.get_property_value' instead") - return self._get_deprecated(f"api/PropertyValue/{version}", - {"namespaceUri": namespaceUri, "languageCode": languageCode}) + return self._get_deprecated( + f"api/PropertyValue/{version}", {"namespaceUri": namespaceUri, "languageCode": languageCode} + ) # deprecated def ReferenceDocument(self, version="v1"): @@ -574,9 +579,16 @@ class Client: } return self.get(endpoint, params) - def get_classes(self, dictionary_uri: str, use_nested_classes: bool = True, - class_type: ClassTypes = "Class", - language_code: str = "", version: int = 1, offset=0, limit=1000) -> DictionaryClassesResponseContractV1: + def get_classes( + self, + dictionary_uri: str, + use_nested_classes: bool = True, + class_type: ClassTypes = "Class", + language_code: str = "", + version: int = 1, + offset=0, + limit=1000, + ) -> DictionaryClassesResponseContractV1: """ Get Dictionary with tree of classes This API replaces Domain @@ -587,29 +599,32 @@ class Client: "UseNestedClasses": use_nested_classes, "ClassType": class_type, "languageCode": language_code, - "offset" : offset, - "limit" : limit + "offset": offset, + "limit": limit, } return self.get(endpoint, params) - def get_properties(self, dictionary_uri: str, offset: int = 0, limit: int = 100, language_code: str = "", - version: int = 1) -> DictionaryPropertiesResponseContractV1: + def get_properties( + self, dictionary_uri: str, offset: int = 0, limit: int = 100, language_code: str = "", version: int = 1 + ) -> DictionaryPropertiesResponseContractV1: """ Get Dictionary with its properties """ endpoint = f"Dictionary/v{version}/Properties" - params = { - "Uri": dictionary_uri, - "languageCode": language_code, - "offset": offset, - "limit": limit - } + params = {"Uri": dictionary_uri, "languageCode": language_code, "offset": offset, "limit": limit} return self.get(endpoint, params) - def get_class(self, class_uri: str, include_class_properties: bool = True, - include_child_class_reference: bool = True, include_class_relations: bool = True, - include_reverse_relations: bool = False, reverse_relation_dictionary_uris: Optional[list[str]]=None, - language_code: str = "", version: int = 1) -> ClassContractV1: + def get_class( + self, + class_uri: str, + include_class_properties: bool = True, + include_child_class_reference: bool = True, + include_class_relations: bool = True, + include_reverse_relations: bool = False, + reverse_relation_dictionary_uris: Optional[list[str]] = None, + language_code: str = "", + version: int = 1, + ) -> ClassContractV1: """ Get Class details this API replaces Classification @@ -627,8 +642,7 @@ class Client: params = {k: v for k, v in params.items() if v is not None} return self.get(endpoint, params) - def get_property(self, uri, include_classes=False, language_code="", - version: int = 4) -> PropertyContractV4: + def get_property(self, uri, include_classes=False, language_code="", version: int = 4) -> PropertyContractV4: """ Get Property Detail this API replaces Property @@ -654,8 +668,15 @@ class Client: } return self.get(endpoint, params) - def search_text(self, search_text: str, type_filter="All", dictionary_uris=None, - version: int = 1, offset: int = 0, limit: int = 100) -> TextSearchResponseContractV1: + def search_text( + self, + search_text: str, + type_filter="All", + dictionary_uris=None, + version: int = 1, + offset: int = 0, + limit: int = 100, + ) -> TextSearchResponseContractV1: """ Search the bSDD database using free text, get list of Classes and/or Properties matching the text. Pagination options are for Classes and Properties combined. @@ -670,14 +691,21 @@ class Client: "TypeFilter": type_filter, "DictionaryUris": dictionary_uris, "offset": offset, - "limit": limit + "limit": limit, } return self.get(endpoint, params) pass - def search_in_dictionary(self, dictionary_uri: str, search_text: str = "", language_code: str = "", - related_ifc_entity: str = "", - version: int = 1, offset: int = 0, limit: int = 100) -> SearchInDictionaryResponseContractV1: + def search_in_dictionary( + self, + dictionary_uri: str, + search_text: str = "", + language_code: str = "", + related_ifc_entity: str = "", + version: int = 1, + offset: int = 0, + limit: int = 100, + ) -> SearchInDictionaryResponseContractV1: """ Search the bSDD database, get list of Classes without details. This version uses new naming and returns one Dictionary instead of a list with always one Dictionary. @@ -690,12 +718,19 @@ class Client: "LanguageCode": language_code, "RelatedIfcEntity": related_ifc_entity, "offset": offset, - "limit": limit + "limit": limit, } return self.get(endpoint, params) - def search_class(self, search_text: str, dictionary_uris=None, related_ifc_entities=None, - version: int = 1, offset: int = 0, limit: int = 100) -> ClassSearchResponseContractV1: + def search_class( + self, + search_text: str, + dictionary_uris=None, + related_ifc_entities=None, + version: int = 1, + offset: int = 0, + limit: int = 100, + ) -> ClassSearchResponseContractV1: """ Search the bSDD database using free text, get list of Classes matching the text and optional additional filters. this API replaces ClassificationSearch @@ -711,13 +746,13 @@ class Client: "DictionaryUris": dictionary_uris, "RelatedIfcEntities": related_ifc_entities, "offset": offset, - "limit": limit + "limit": limit, } return self.get(endpoint, params) def get_countries(self, version: int = 1) -> list[CountryContractV1]: """ - Get list of all Countries + Get list of all Countries this API replaces Country """ endpoint = f"Country/v{version}" diff --git a/src/bsdd/pyproject.toml b/src/bsdd/pyproject.toml index 2b9e471050..c648a82d32 100644 --- a/src/bsdd/pyproject.toml +++ b/src/bsdd/pyproject.toml @@ -1,21 +1,20 @@ [build-system] -requires = ["hatchling"] -build-backend = "hatchling.build" +requires = ["setuptools>=61.0"] +build-backend = "setuptools.build_meta" [project] name = "bsdd" -version = "0.0.999999" +version = "0.0.0" authors = [ { name="Dion Moult", email="dion@thinkmoult.com" }, ] description = "Library to interact with the buildingSMART Data Dictionary" readme = "README.md" -requires-python = ">=3.8" +requires-python = ">=3.9" keywords = ["IFC", "bSDD", "BIM"] classifiers = [ "Development Status :: 4 - Beta", "Programming Language :: Python", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", @@ -26,19 +25,16 @@ classifiers = [ ] dependencies = ["requests"] +[project.optional-dependencies] +dev = [ + "coverage[toml]>=6.5", + "pytest", +] + [project.urls] Homepage = "http://ifcopenshell.org" Documentation = "https://docs.ifcopenshell.org" Issues = "https://github.com/IfcOpenShell/IfcOpenShell/issues" -[tool.hatch.envs.default] -dependencies = [ - "coverage[toml]>=6.5", - "pytest", -] - -[[tool.hatch.envs.all.matrix]] -python = ["3.8", "3.9", "3.10", "3.11", "3.12"] - -[tool.pytest.ini_options] -pythonpath = [".", "src"] +[tool.setuptools] +py-modules = ["bsdd"]