Skip to content

Commit 7feebc6

Browse files
committed
rewrite definitions without pkg_resources
1 parent 54a35b8 commit 7feebc6

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,27 @@
1-
import pkg_resources
1+
from importlib.resources import files, as_file
22

33

44
def templates_dir():
55
"""Directory where the templates are found (for internal use, mainly)"""
6-
return pkg_resources.resource_filename('opengen', 'templates/')
6+
resource = files("opengen") / "templates"
7+
with as_file(resource) as path:
8+
return str(path)
79

810

911
def templates_subdir(subdir=None):
1012
"""
1113
Directory where the templates are found and subfolder relative
12-
to that path(for internal use, mainly)
14+
to that path (for internal use, mainly)
1315
"""
14-
if subdir is None:
15-
return templates_dir()
16-
return pkg_resources.resource_filename('opengen', 'templates/%s/' % subdir)
16+
resource = files("opengen") / "templates"
17+
if subdir is not None:
18+
resource = resource / subdir
19+
with as_file(resource) as path:
20+
return str(path)
1721

1822

1923
def original_icasadi_dir():
2024
"""Directory where the original icasadi files are found (for internal use)"""
21-
return pkg_resources.resource_filename('opengen', 'icasadi/')
25+
resource = files("opengen") / "icasadi"
26+
with as_file(resource) as path:
27+
return str(path)

0 commit comments

Comments
 (0)