11
11
"""
12
12
13
13
import sys
14
- import os .path as osp
14
+ # import os.path as osp
15
15
from pathlib import Path
16
16
17
17
def get_module_path (modname ):
18
18
"""Return module *modname* base path"""
19
- return osp .abspath (
20
- osp .dirname (sys .modules [modname ].__file__ )
21
- )
19
+ #return osp.abspath(
20
+ # osp.dirname(sys.modules[modname].__file__)
21
+ #)
22
+ return str (Path (sys .modules [modname ].__file__ ).parent .resolve ())
22
23
23
24
24
25
def get_module_data_path (
@@ -35,20 +36,21 @@ def get_module_data_path(
35
36
datapath = get_module_path (modname )
36
37
# parentdir = osp.join(datapath, osp.pardir)
37
38
parentdir = str (Path (datapath ).parent )
38
- if osp .isfile (parentdir ):
39
+ #if osp.isfile(parentdir):
40
+ if Path (parentdir ).is_file ():
39
41
# Parent directory is not a directory but the 'library.zip' file:
40
42
# this is either a py2exe or a cx_Freeze distribution
41
- datapath = osp .abspath (
43
+ # datapath = osp.abspath(
42
44
# osp.join(
43
45
# osp.join(parentdir, osp.pardir), modname
44
46
# )
45
- str ( Path ( parentdir ). parent / modname )
46
- )
47
+ #)
48
+ datapath = str (( Path ( parentdir ). parent / modname ). resolve () )
47
49
if relpath is not None :
48
- datapath = osp .abspath (
50
+ # datapath = osp.abspath(
49
51
# osp.join(datapath, relpath)
50
- str ( Path ( datapath ) / relpath )
51
- )
52
+ # )
53
+ datapath = str (( Path ( datapath ) / relpath ). resolve () )
52
54
return datapath
53
55
54
56
0 commit comments