From 3848de8959002183478f6f285dc38933602b9b33 Mon Sep 17 00:00:00 2001 From: KnucklesSG1 Date: Fri, 9 Aug 2024 00:07:07 -0500 Subject: [PATCH] Commiting cleaned up comments --- gitlab_api/utils.py | 52 --------------------------------------------- 1 file changed, 52 deletions(-) diff --git a/gitlab_api/utils.py b/gitlab_api/utils.py index f7b88ec..35c55ba 100644 --- a/gitlab_api/utils.py +++ b/gitlab_api/utils.py @@ -299,55 +299,3 @@ def create_table(db_instance, engine): print(f"Table {table_name} created.") else: print(f"Table {table_name} already exists.") - - -# def remove_none_values(d: dict) -> dict: -# return {k: v for k, v in d.items() if v is not None} -# -# def get_related_model(sqlalchemy_model, key): -# mapper = class_mapper(sqlalchemy_model) -# for prop in mapper.iterate_properties: -# if prop.key == key: -# print(f"\n\nRelated Model: {prop.mapper.class_} for key: {key}") -# return prop.mapper.class_ -# raise ValueError(f"Unable to find related model for key: {key}") -# -# def validate_value(key, value, session, sqlalchemy_model): -# if isinstance(value, list): -# print(f"\n\nInstance is a list: {value}") -# return [pydantic_to_sqlalchemy(item, session) if hasattr(item, "Meta") and hasattr(item.Meta, "orm_model") else item for item in value] -# elif isinstance(value, dict): -# print(f"\n\nInstance is a dict: {value}") -# related_model = get_related_model(sqlalchemy_model, key) -# nested_model = related_model(**remove_none_values(value)) -# return pydantic_to_sqlalchemy(nested_model, session) -# else: -# print(f"\n\nInstance is a value: {value}") -# return value -# -# def pydantic_to_sqlalchemy(pydantic_model, session): -# if not hasattr(pydantic_model, "Meta") or not hasattr(pydantic_model.Meta, "orm_model"): -# return pydantic_model -# -# sqlalchemy_model = pydantic_model.Meta.orm_model -# model_instance = sqlalchemy_model() -# -# for key, value in pydantic_model.model_dump(exclude_unset=True).items(): -# if value is not None: -# new_value = validate_value(key, value, session, sqlalchemy_model) -# setattr(model_instance, key, new_value) -# -# session.add(model_instance) -# session.flush() # Ensure any new IDs are generated before returning -# return model_instance -# -# -# def create_table(db_instance, engine): -# inspector = reflection.Inspector.from_engine(engine) -# table_name = db_instance.__table__.name -# -# if not inspector.has_table(table_name): -# db_instance.__table__.create(engine) -# print(f"Table {table_name} created.") -# else: -# print(f"Table {table_name} already exists.")