|
9 | 9 | log = getLogger(__name__) |
10 | 10 |
|
11 | 11 |
|
12 | | -def convert_sqlite_to_functional_sqlite(database_name: str) -> dict: |
13 | | - return SQLiteToFunctionalSQLite.convert(database_name) |
| 12 | +def convert_sqlite_to_functional_sqlite(database_dict: dict) -> dict: |
| 13 | + return SQLiteToFunctionalSQLite.convert(database_dict) |
14 | 14 |
|
15 | 15 |
|
16 | 16 | class SQLiteToFunctionalSQLite: |
17 | 17 | @classmethod |
18 | | - def convert(cls, database_name: str): |
19 | | - db = bd.Database(database_name) |
20 | | - |
21 | | - if not isinstance(db, SQLiteBackend): |
22 | | - raise TypeError("Database is not of type SQLite.") |
23 | | - |
| 18 | + def convert(cls, database_dict: dict): |
24 | 19 | converted = {} |
25 | 20 |
|
26 | | - for key, ds in tqdm.tqdm(db.load().items()): |
| 21 | + for key, ds in tqdm.tqdm(database_dict.items()): |
27 | 22 | if ds["type"] in ["process", "processwithreferenceproduct"]: |
28 | 23 | converted.update(cls.convert_process(key, ds)) |
29 | 24 |
|
@@ -87,24 +82,18 @@ def convert_exchanges(key, ds) -> None: |
87 | 82 | exc["input"] = (database, exc["input"][1] + "_function") |
88 | 83 |
|
89 | 84 |
|
90 | | -def convert_functional_sqlite_to_sqlite(database_name: str): |
91 | | - return FunctionalSQLiteToSQLite.convert(database_name) |
| 85 | +def convert_functional_sqlite_to_sqlite(database_dict: dict): |
| 86 | + return FunctionalSQLiteToSQLite.convert(database_dict) |
92 | 87 |
|
93 | 88 |
|
94 | 89 | class FunctionalSQLiteToSQLite: |
95 | 90 | @classmethod |
96 | | - def convert(cls, database_name: str): |
97 | | - db = bd.Database(database_name) |
98 | | - |
99 | | - if not isinstance(db, FunctionalSQLiteDatabase): |
100 | | - raise TypeError("Database is not of type functional_sqlite.") |
101 | | - |
102 | | - raw = db.load() |
| 91 | + def convert(cls, database_dict: dict): |
103 | 92 | converted = {} |
104 | 93 |
|
105 | | - for key, ds in tqdm.tqdm(raw.items()): |
| 94 | + for key, ds in tqdm.tqdm(database_dict.items()): |
106 | 95 | if ds["type"] in ["product", "waste"]: |
107 | | - processor = raw[ds["processor"]] |
| 96 | + processor = database_dict[ds["processor"]] |
108 | 97 | converted[key] = cls.convert_function(key, ds, processor) |
109 | 98 |
|
110 | 99 | return converted |
|
0 commit comments