|
3 | 3 | import argparse |
4 | 4 | import collections |
5 | 5 | import contextlib |
| 6 | +import importlib.resources |
6 | 7 | import itertools |
7 | 8 | import multiprocessing.pool |
8 | 9 | import os.path |
9 | 10 | import sqlite3 |
10 | 11 | from collections import Counter |
| 12 | +from collections.abc import Callable |
11 | 13 | from collections.abc import Generator |
12 | 14 | from collections.abc import Iterable |
13 | 15 | from collections.abc import Sequence |
14 | 16 | from re import Pattern |
15 | | -from typing import Callable |
16 | 17 | from typing import TypeVar |
17 | 18 |
|
18 | | -import pkg_resources |
19 | | - |
20 | 19 | from git_code_debt import options |
21 | 20 | from git_code_debt.discovery import get_metric_parsers_from_args |
22 | 21 | from git_code_debt.file_diff_stat import FileDiffStat |
@@ -163,13 +162,10 @@ def load_data( |
163 | 162 |
|
164 | 163 | def create_schema(db: sqlite3.Connection) -> None: |
165 | 164 | """Creates the database schema.""" |
166 | | - schema_dir = pkg_resources.resource_filename('git_code_debt', 'schema') |
167 | | - schema_files = os.listdir(schema_dir) |
| 165 | + schema_dir = importlib.resources.files('git_code_debt.schema') |
168 | 166 |
|
169 | | - for sql_file in schema_files: |
170 | | - resource_filename = os.path.join(schema_dir, sql_file) |
171 | | - with open(resource_filename) as resource: |
172 | | - db.executescript(resource.read()) |
| 167 | + for sql_file in schema_dir.iterdir(): |
| 168 | + db.executescript(sql_file.read_text()) |
173 | 169 |
|
174 | 170 |
|
175 | 171 | def get_metrics_info( |
|
0 commit comments