Skip to content

Commit

Permalink
improvement docs string
Browse files Browse the repository at this point in the history
  • Loading branch information
chuongmep committed May 8, 2024
1 parent 211e608 commit 5e5304b
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 21 deletions.
2 changes: 1 addition & 1 deletion APSToolkitPython/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setuptools.setup(
name="aps-toolkit",
version="0.6.0",
version="0.6.1",
author="chuong mep",
author_email="[email protected]",
description="A Toolkit Autodesk Platform Services for Python",
Expand Down
1 change: 1 addition & 0 deletions APSToolkitPython/src/aps_toolkit/Auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ def refresh_new_token(self, old_refresh_token) -> Token:
def get_user_info(self) -> dict:
"""
This method is used to get user information.
It requires OAuth 2.0 authentication with 3-legged flow.
https://developer.api.autodesk.com/userprofile/v1/userinfo
:return: A dictionary containing user information.
"""
Expand Down
2 changes: 1 addition & 1 deletion APSToolkitPython/src/aps_toolkit/Bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def create_bucket(self, bucket_name: str, policy_key: PublicKey) -> dict:
raise Exception(response.content)
return response.json()

def delete_bucket(self, bucket_name: str) -> dict:
def delete_bucket(self, bucket_name: str):
"""
Deletes a bucket in the Autodesk OSS API.
Expand Down
2 changes: 1 addition & 1 deletion APSToolkitPython/src/aps_toolkit/ProDbReaderCad.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def get_all_categories(self) -> dict:
db_categories[child] = p.value
return db_categories

def get_data_by_category(self, category) -> pd.DataFrame:
def get_data_by_category(self, category: str) -> pd.DataFrame:
"""
Get data by cad category : eg: MText, Line, Circle, ...
:param category: the category name of cad file, e.g : MText, Line, Circle,Tables ...
Expand Down
4 changes: 2 additions & 2 deletions APSToolkitPython/src/aps_toolkit/ProDbReaderNavis.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ def get_all_categories(self) -> List[str]:
categories.append(self.attrs[i][1])
return categories

def get_data_by_category(self, category) -> pd.DataFrame:
def get_data_by_category(self, category: str) -> pd.DataFrame:
db_ids = [1]
df = self._get_recursive_ids_by_category(db_ids, category)
df = df.drop_duplicates(subset=df.columns.difference(['DbId']))
return df

def _get_recursive_ids_by_category(self, db_ids: List[int], category) -> pd.DataFrame:
def _get_recursive_ids_by_category(self, db_ids: List[int], category: str) -> pd.DataFrame:
dataframe = pd.DataFrame()
props_ignore = ['parent', 'instanceof_objid', 'child', "viewable_in"]
if len(db_ids) == 0:
Expand Down
28 changes: 16 additions & 12 deletions APSToolkitPython/src/aps_toolkit/ProDbReaderRevit.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def get_all_categories(self) -> dict:
self._get_recursive_child(categories, 1, "_RC")
return categories

def get_all_data(self, is_get_sub_family=False, display_unit=False) -> pd.DataFrame:
def get_all_data(self, is_get_sub_family: bool = False, display_unit: bool = False) -> pd.DataFrame:
"""
Get all data from model, include all categories
:param is_get_sub_family: the flag to get sub family or not, default is False
Expand Down Expand Up @@ -172,7 +172,8 @@ def get_all_families_types(self) -> dict:
self._get_recursive_child(families_types, 1, "_RFT")
return families_types

def get_data_by_category(self, category, is_get_sub_family=False, display_unit=False) -> pd.DataFrame:
def get_data_by_category(self, category: str, is_get_sub_family: bool = False,
display_unit: bool = False) -> pd.DataFrame:
"""
Get data by category in model
:param category: the category name need get data, e.g: Walls, Doors, Windows, etc
Expand All @@ -188,8 +189,8 @@ def get_data_by_category(self, category, is_get_sub_family=False, display_unit=F
dataframe = self._get_recursive_ids(category_id, is_get_sub_family, display_unit)
return dataframe

def get_data_by_categories(self, categories: List[str], is_get_sub_family=False,
display_unit=False) -> pd.DataFrame:
def get_data_by_categories(self, categories: List[str], is_get_sub_family: bool = False,
display_unit: bool = False) -> pd.DataFrame:
"""
Get data by list of categories in model
:param categories: the list of categories need get data, e.g: ["Walls", "Doors", "Windows"]
Expand All @@ -204,7 +205,7 @@ def get_data_by_categories(self, categories: List[str], is_get_sub_family=False,
return dataframe

def get_data_by_categories_and_params(self, categories: List[str], params: List[str],
is_get_sub_family=False, display_unit=False) -> pd.DataFrame:
is_get_sub_family: bool = False, display_unit: bool = False) -> pd.DataFrame:
"""
Get data by list of categories and list of parameters in model
:param categories: the list of categories need get data, e.g: ["Walls", "Doors", "Windows"]
Expand All @@ -225,7 +226,8 @@ def get_data_by_categories_and_params(self, categories: List[str], params: List[
subset=[col for col in dataframe.columns if col not in ['dbId', 'external_id']])
return dataframe

def get_data_by_family(self, family_name, is_get_sub_family=False, display_unit=False) -> pd.DataFrame:
def get_data_by_family(self, family_name: str, is_get_sub_family: bool = False,
display_unit: bool = False) -> pd.DataFrame:
"""
Get data by family name in model
:param family_name: the family name need get data, e.g: "Seating-LAMMHULTS-PENNE-Chair"
Expand All @@ -238,7 +240,8 @@ def get_data_by_family(self, family_name, is_get_sub_family=False, display_unit=
dataframe = self._get_recursive_ids(category_id, is_get_sub_family, display_unit)
return dataframe

def get_data_by_family_type(self, family_type, is_get_sub_family=False, display_unit=False) -> pd.DataFrame:
def get_data_by_family_type(self, family_type: str, is_get_sub_family: bool = False,
display_unit: bool = False) -> pd.DataFrame:
"""
Get data by family type in model
:param family_type: the family type name need get data, e.g: "Plastic-Seat"
Expand All @@ -251,7 +254,7 @@ def get_data_by_family_type(self, family_type, is_get_sub_family=False, display_
dataframe = self._get_recursive_ids(type_id, is_get_sub_family, display_unit)
return dataframe

def _get_recursive_ids(self, db_ids: List[int], get_sub_family, display_unit=False) -> pd.DataFrame:
def _get_recursive_ids(self, db_ids: List[int], get_sub_family: bool, display_unit: bool = False) -> pd.DataFrame:
dataframe = pd.DataFrame()
props_ignore = ['parent', 'instanceof_objid', 'child', "viewable_in"]
if len(db_ids) == 0:
Expand Down Expand Up @@ -308,8 +311,8 @@ def _get_recursive_ids(self, db_ids: List[int], get_sub_family, display_unit=Fal
['dbId', 'external_id'] + [col for col in dataframe.columns if col not in ['dbId', 'external_id']]]
return dataframe

def _get_recursive_ids_prams(self, childs: List[int], params: List[str], get_sub_family,
display_unit=False) -> pd.DataFrame:
def _get_recursive_ids_prams(self, childs: List[int], params: List[str], get_sub_family: bool,
display_unit: bool = False) -> pd.DataFrame:
"""
Get recursive ids by list of parameters
:param childs: List of child ids, ids is database id
Expand Down Expand Up @@ -387,7 +390,8 @@ def _get_recursive_ids_prams(self, childs: List[int], params: List[str], get_sub
['dbId', 'external_id'] + [col for col in dataframe.columns if col not in ['dbId', 'external_id']]]
return dataframe

def get_data_by_external_id(self, external_id, is_get_sub_family=False, display_unit=False) -> pd.DataFrame:
def get_data_by_external_id(self, external_id: str, is_get_sub_family: bool = False,
display_unit: bool = False) -> pd.DataFrame:
"""
Get data by external id(UniqueId Element) in model
:param external_id: The unique id of element in model
Expand All @@ -405,7 +409,7 @@ def get_data_by_external_id(self, external_id, is_get_sub_family=False, display_
dataframe = self._get_recursive_ids([db_id], is_get_sub_family, display_unit)
return dataframe

def get_data_by_element_id(self, element_id) -> dict:
def get_data_by_element_id(self, element_id: str) -> dict:
"""
Get data by element id in model
:param element_id: the element id of element in model. e.g: 9895625
Expand Down
2 changes: 1 addition & 1 deletion APSToolkitPython/src/aps_toolkit/PropReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def _read_metadata(self):
else:
raise Exception("No manifest item found")

def _read_metadata_item(self, derivative, manifest_item):
def _read_metadata_item(self, derivative: Derivative, manifest_item: ManifestItem):
items = [
"objects_attrs.json.gz",
"objects_vals.json.gz",
Expand Down
2 changes: 1 addition & 1 deletion APSToolkitPython/src/aps_toolkit/Token.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


class Token():
def __init__(self, access_token, token_type, expires_in, refresh_token=None):
def __init__(self, access_token: str, token_type: str, expires_in: int, refresh_token: str = None):
self.access_token = access_token
self.token_type = token_type
self.expires_in = expires_in
Expand Down
3 changes: 1 addition & 2 deletions APSToolkitPython/src/aps_toolkit/units/DisplayUnits.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,11 @@ def _read_units_local(self):
self.units = json.load(file)
# convert to dict
self.units = {unit["TypeId"]: unit["UnitLabel"] for unit in self.units}
print("Units loaded")
except FileNotFoundError:
print(f"Error: File '{file_path}' not found.")
except json.JSONDecodeError as e:
print(f"Error decoding JSON file: {e}")

def parse_symbol(self, type_id):
def parse_symbol(self, type_id: str):
type_id = type_id.split("-")[0]
return self.units.get(type_id, "Unknown")

0 comments on commit 5e5304b

Please sign in to comment.