Method: flask.cli.prepare_import
Calls: 24, Exceptions: 0, Paths: 7Back
Path 1: 7 calls (0.29)
'wsgi.py' (5) 'test.py' (1) '/Users/andrehora/Documents/git/projects-pathspotter/flask/tests/test_apps/cliapp/app.py' (1)
'wsgi' (4) 'test' (1) 'cliapp.app' (1) 'cliapp.wsgi' (1)
1def prepare_import(path):
2 """Given a filename this will try to calculate the python path, add it
3 to the search path and return the actual module name that is expected.
4 """
5 path = os.path.realpath(path)
6
7 fname, ext = os.path.splitext(path)
8 if ext == ".py":
9 path = fname
10
11 if os.path.basename(path) == "__init__":
12 path = os.path.dirname(path)
13
14 module_name = []
15
16 # move up until outside package structure (no __init__.py)
17 while True:
18 path, name = os.path.split(path)
19 module_name.append(name)
20
21 if not os.path.exists(os.path.join(path, "__init__.py")):
22 break
23
24 if sys.path[0] != path:
25 sys.path.insert(0, path)
26
27 return ".".join(module_name[::-1])
Path 2: 7 calls (0.29)
'app.py' (5) '/Users/andrehora/Documents/git/projects-pathspotter/flask/tests/test_apps/cliapp/app.py' (1) 'wsgi.py' (1)
'app' (4) 'cliapp.app' (2) 'wsgi' (1)
1def prepare_import(path):
2 """Given a filename this will try to calculate the python path, add it
3 to the search path and return the actual module name that is expected.
4 """
5 path = os.path.realpath(path)
6
7 fname, ext = os.path.splitext(path)
8 if ext == ".py":
9 path = fname
10
11 if os.path.basename(path) == "__init__":
12 path = os.path.dirname(path)
13
14 module_name = []
15
16 # move up until outside package structure (no __init__.py)
17 while True:
18 path, name = os.path.split(path)
19 module_name.append(name)
20
21 if not os.path.exists(os.path.join(path, "__init__.py")):
22 break
23
24 if sys.path[0] != path:
25 sys.path.insert(0, path)
26
27 return ".".join(module_name[::-1])
Path 3: 4 calls (0.17)
'test' (1) 'a/test' (1) 'test.a.b' (1) 'cliapp.app' (1)
'test' (2) 'test.a.b' (1) 'cliapp.app' (1)
1def prepare_import(path):
2 """Given a filename this will try to calculate the python path, add it
3 to the search path and return the actual module name that is expected.
4 """
5 path = os.path.realpath(path)
6
7 fname, ext = os.path.splitext(path)
8 if ext == ".py":
9 path = fname
10
11 if os.path.basename(path) == "__init__":
12 path = os.path.dirname(path)
13
14 module_name = []
15
16 # move up until outside package structure (no __init__.py)
17 while True:
18 path, name = os.path.split(path)
19 module_name.append(name)
20
21 if not os.path.exists(os.path.join(path, "__init__.py")):
22 break
23
24 if sys.path[0] != path:
25 sys.path.insert(0, path)
26
27 return ".".join(module_name[::-1])
Path 4: 3 calls (0.12)
PosixPath (3)
'cliapp.inner1.inner2' (1) 'cliapp.app' (1) 'cliapp.message.txt' (1)
1def prepare_import(path):
2 """Given a filename this will try to calculate the python path, add it
3 to the search path and return the actual module name that is expected.
4 """
5 path = os.path.realpath(path)
6
7 fname, ext = os.path.splitext(path)
8 if ext == ".py":
9 path = fname
10
11 if os.path.basename(path) == "__init__":
12 path = os.path.dirname(path)
13
14 module_name = []
15
16 # move up until outside package structure (no __init__.py)
17 while True:
18 path, name = os.path.split(path)
19 module_name.append(name)
20
21 if not os.path.exists(os.path.join(path, "__init__.py")):
22 break
23
24 if sys.path[0] != path:
25 sys.path.insert(0, path)
26
27 return ".".join(module_name[::-1])
Path 5: 1 calls (0.04)
'test/__init__.py' (1)
'test' (1)
1def prepare_import(path):
2 """Given a filename this will try to calculate the python path, add it
3 to the search path and return the actual module name that is expected.
4 """
5 path = os.path.realpath(path)
6
7 fname, ext = os.path.splitext(path)
8 if ext == ".py":
9 path = fname
10
11 if os.path.basename(path) == "__init__":
12 path = os.path.dirname(path)
13
14 module_name = []
15
16 # move up until outside package structure (no __init__.py)
17 while True:
18 path, name = os.path.split(path)
19 module_name.append(name)
20
21 if not os.path.exists(os.path.join(path, "__init__.py")):
22 break
23
24 if sys.path[0] != path:
25 sys.path.insert(0, path)
26
27 return ".".join(module_name[::-1])
Path 6: 1 calls (0.04)
'test/__init__' (1)
'test' (1)
1def prepare_import(path):
2 """Given a filename this will try to calculate the python path, add it
3 to the search path and return the actual module name that is expected.
4 """
5 path = os.path.realpath(path)
6
7 fname, ext = os.path.splitext(path)
8 if ext == ".py":
9 path = fname
10
11 if os.path.basename(path) == "__init__":
12 path = os.path.dirname(path)
13
14 module_name = []
15
16 # move up until outside package structure (no __init__.py)
17 while True:
18 path, name = os.path.split(path)
19 module_name.append(name)
20
21 if not os.path.exists(os.path.join(path, "__init__.py")):
22 break
23
24 if sys.path[0] != path:
25 sys.path.insert(0, path)
26
27 return ".".join(module_name[::-1])
Path 7: 1 calls (0.04)
PosixPath (1)
'cliapp.inner1' (1)
1def prepare_import(path):
2 """Given a filename this will try to calculate the python path, add it
3 to the search path and return the actual module name that is expected.
4 """
5 path = os.path.realpath(path)
6
7 fname, ext = os.path.splitext(path)
8 if ext == ".py":
9 path = fname
10
11 if os.path.basename(path) == "__init__":
12 path = os.path.dirname(path)
13
14 module_name = []
15
16 # move up until outside package structure (no __init__.py)
17 while True:
18 path, name = os.path.split(path)
19 module_name.append(name)
20
21 if not os.path.exists(os.path.join(path, "__init__.py")):
22 break
23
24 if sys.path[0] != path:
25 sys.path.insert(0, path)
26
27 return ".".join(module_name[::-1])