triplep 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- triplep-1.0.0/LICENSE +21 -0
- triplep-1.0.0/PKG-INFO +51 -0
- triplep-1.0.0/README.md +24 -0
- triplep-1.0.0/pyproject.toml +33 -0
- triplep-1.0.0/setup.cfg +4 -0
- triplep-1.0.0/triplep.egg-info/PKG-INFO +51 -0
- triplep-1.0.0/triplep.egg-info/SOURCES.txt +11 -0
- triplep-1.0.0/triplep.egg-info/dependency_links.txt +1 -0
- triplep-1.0.0/triplep.egg-info/top_level.txt +1 -0
- triplep-1.0.0/wai/__init__.py +13 -0
- triplep-1.0.0/wai/main.py +64 -0
- triplep-1.0.0/wai/models.py +51 -0
- triplep-1.0.0/wai/utils.py +121 -0
triplep-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Nikita Belomestnykh
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
triplep-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: triplep
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: TripleP - PPP - PyProject Parser is a lightweight Python utility that enables effortless access to your project's metadata directly from pyproject.toml at runtime.
|
|
5
|
+
Author-email: Nikita Belomestnykh <medbeebs@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/medbeebs/triplep
|
|
8
|
+
Project-URL: Repository, https://github.com/medbeebs/triplep
|
|
9
|
+
Project-URL: Issues, https://github.com/medbeebs/triplep/issues
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
12
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
13
|
+
Classifier: Topic :: Software Development
|
|
14
|
+
Classifier: Typing :: Typed
|
|
15
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
16
|
+
Classifier: Intended Audience :: Developers
|
|
17
|
+
Classifier: Programming Language :: Python
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
22
|
+
Classifier: Topic :: Utilities
|
|
23
|
+
Requires-Python: >=3.13
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Dynamic: license-file
|
|
27
|
+
|
|
28
|
+
# TripleP - PPP - PyProject Parser
|
|
29
|
+
|
|
30
|
+

|
|
31
|
+

|
|
32
|
+

|
|
33
|
+

|
|
34
|
+
|
|
35
|
+
WAI (What Am I?) is a lightweight Python utility that enables effortless access to your project's metadata directly from pyproject.toml at runtime.
|
|
36
|
+
|
|
37
|
+
## Installation
|
|
38
|
+
|
|
39
|
+
`pip install triplep`
|
|
40
|
+
|
|
41
|
+
## Features
|
|
42
|
+
|
|
43
|
+
- Automatic `pyproject.toml` file discovery
|
|
44
|
+
- Parsing metadata into dataclass objects
|
|
45
|
+
- Raw access when required
|
|
46
|
+
- Fully typed
|
|
47
|
+
|
|
48
|
+
## Limitations
|
|
49
|
+
|
|
50
|
+
- Basic support for dataclass parsing of `[project]` block
|
|
51
|
+
- Sync only
|
triplep-1.0.0/README.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# TripleP - PPP - PyProject Parser
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+

|
|
7
|
+
|
|
8
|
+
WAI (What Am I?) is a lightweight Python utility that enables effortless access to your project's metadata directly from pyproject.toml at runtime.
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
`pip install triplep`
|
|
13
|
+
|
|
14
|
+
## Features
|
|
15
|
+
|
|
16
|
+
- Automatic `pyproject.toml` file discovery
|
|
17
|
+
- Parsing metadata into dataclass objects
|
|
18
|
+
- Raw access when required
|
|
19
|
+
- Fully typed
|
|
20
|
+
|
|
21
|
+
## Limitations
|
|
22
|
+
|
|
23
|
+
- Basic support for dataclass parsing of `[project]` block
|
|
24
|
+
- Sync only
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "triplep"
|
|
3
|
+
version = "1.0.0"
|
|
4
|
+
description = "TripleP - PPP - PyProject Parser is a lightweight Python utility that enables effortless access to your project's metadata directly from pyproject.toml at runtime."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
requires-python = ">=3.13"
|
|
9
|
+
authors = [{ name = "Nikita Belomestnykh", email = "medbeebs@gmail.com" }]
|
|
10
|
+
classifiers = [
|
|
11
|
+
"Operating System :: OS Independent",
|
|
12
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
13
|
+
"Topic :: Software Development :: Libraries",
|
|
14
|
+
"Topic :: Software Development",
|
|
15
|
+
"Typing :: Typed",
|
|
16
|
+
"Development Status :: 5 - Production/Stable",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"Programming Language :: Python",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
21
|
+
"Programming Language :: Python :: 3.13",
|
|
22
|
+
"Programming Language :: Python :: 3.14",
|
|
23
|
+
"Topic :: Utilities",
|
|
24
|
+
]
|
|
25
|
+
dependencies = []
|
|
26
|
+
|
|
27
|
+
[project.urls]
|
|
28
|
+
Homepage = "https://github.com/medbeebs/triplep"
|
|
29
|
+
Repository = "https://github.com/medbeebs/triplep"
|
|
30
|
+
Issues = "https://github.com/medbeebs/triplep/issues"
|
|
31
|
+
|
|
32
|
+
[dependency-groups]
|
|
33
|
+
dev = ["ruff>=0.14.8"]
|
triplep-1.0.0/setup.cfg
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: triplep
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: TripleP - PPP - PyProject Parser is a lightweight Python utility that enables effortless access to your project's metadata directly from pyproject.toml at runtime.
|
|
5
|
+
Author-email: Nikita Belomestnykh <medbeebs@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/medbeebs/triplep
|
|
8
|
+
Project-URL: Repository, https://github.com/medbeebs/triplep
|
|
9
|
+
Project-URL: Issues, https://github.com/medbeebs/triplep/issues
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
12
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
13
|
+
Classifier: Topic :: Software Development
|
|
14
|
+
Classifier: Typing :: Typed
|
|
15
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
16
|
+
Classifier: Intended Audience :: Developers
|
|
17
|
+
Classifier: Programming Language :: Python
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
22
|
+
Classifier: Topic :: Utilities
|
|
23
|
+
Requires-Python: >=3.13
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Dynamic: license-file
|
|
27
|
+
|
|
28
|
+
# TripleP - PPP - PyProject Parser
|
|
29
|
+
|
|
30
|
+

|
|
31
|
+

|
|
32
|
+

|
|
33
|
+

|
|
34
|
+
|
|
35
|
+
WAI (What Am I?) is a lightweight Python utility that enables effortless access to your project's metadata directly from pyproject.toml at runtime.
|
|
36
|
+
|
|
37
|
+
## Installation
|
|
38
|
+
|
|
39
|
+
`pip install triplep`
|
|
40
|
+
|
|
41
|
+
## Features
|
|
42
|
+
|
|
43
|
+
- Automatic `pyproject.toml` file discovery
|
|
44
|
+
- Parsing metadata into dataclass objects
|
|
45
|
+
- Raw access when required
|
|
46
|
+
- Fully typed
|
|
47
|
+
|
|
48
|
+
## Limitations
|
|
49
|
+
|
|
50
|
+
- Basic support for dataclass parsing of `[project]` block
|
|
51
|
+
- Sync only
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
wai
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from .main import PyProject, load_pyproject
|
|
2
|
+
from .models import Project
|
|
3
|
+
from .utils import find_pyproject
|
|
4
|
+
|
|
5
|
+
pyproject = load_pyproject()
|
|
6
|
+
|
|
7
|
+
__version__ = "1.0.0"
|
|
8
|
+
__all__ = [
|
|
9
|
+
"load_pyproject",
|
|
10
|
+
"find_pyproject",
|
|
11
|
+
"PyProject",
|
|
12
|
+
"Project",
|
|
13
|
+
]
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import io
|
|
2
|
+
import logging
|
|
3
|
+
import tomllib
|
|
4
|
+
from contextlib import contextmanager
|
|
5
|
+
from typing import IO, Any, Iterator
|
|
6
|
+
|
|
7
|
+
from .models import Project
|
|
8
|
+
from .utils import StrPath, find_pyproject, is_file_or_fifo
|
|
9
|
+
|
|
10
|
+
logger = logging.getLogger(__name__)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class PyProject:
|
|
14
|
+
def __init__(self, pyproject_path: StrPath | None):
|
|
15
|
+
self.pyproject_path = pyproject_path
|
|
16
|
+
|
|
17
|
+
self.parse()
|
|
18
|
+
|
|
19
|
+
@contextmanager
|
|
20
|
+
def _get_fp(self) -> Iterator[IO[bytes]]:
|
|
21
|
+
if self.pyproject_path and is_file_or_fifo(self.pyproject_path):
|
|
22
|
+
with open(self.pyproject_path, mode="rb") as fp:
|
|
23
|
+
yield fp
|
|
24
|
+
|
|
25
|
+
else:
|
|
26
|
+
if self.verbose:
|
|
27
|
+
logger.info(
|
|
28
|
+
"WAI could not find configuration file %s.",
|
|
29
|
+
self.pyproject_path or "pyproject.toml",
|
|
30
|
+
)
|
|
31
|
+
yield io.BytesIO(b"")
|
|
32
|
+
|
|
33
|
+
def load(self) -> dict[str, Any]:
|
|
34
|
+
"""Returns contents of pyproject TOML file as dict"""
|
|
35
|
+
|
|
36
|
+
with self._get_fp() as fp:
|
|
37
|
+
return tomllib.load(fp)
|
|
38
|
+
|
|
39
|
+
def parse(self):
|
|
40
|
+
"""Loads/reloads and parses contents of pyproject TOML file as dataclass entities"""
|
|
41
|
+
self.raw = self.load()
|
|
42
|
+
self.project = Project(**(self.raw["project"]))
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def load_pyproject(
|
|
46
|
+
pyproject_path: StrPath | None = None,
|
|
47
|
+
) -> PyProject:
|
|
48
|
+
"""Parse a pyproject.toml file and return contents
|
|
49
|
+
|
|
50
|
+
Parameters:
|
|
51
|
+
pyproject_path: Absolute or relative path to pyproject.toml file.
|
|
52
|
+
Returns:
|
|
53
|
+
PyProject: A class defining parsed and war contents of pyproject file.
|
|
54
|
+
|
|
55
|
+
If `pyproject_path` is `None`, `find_pyproject()` is used to find the
|
|
56
|
+
pyproject.toml file with it's default parameters. If you need to change the default parameters
|
|
57
|
+
of `find_pyproject()`, you can explicitly call `find_pyproject()` and pass the result
|
|
58
|
+
to this function as `pyproject_path`.
|
|
59
|
+
"""
|
|
60
|
+
|
|
61
|
+
if pyproject_path is None:
|
|
62
|
+
pyproject_path = find_pyproject()
|
|
63
|
+
|
|
64
|
+
return PyProject(pyproject_path=pyproject_path)
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
from dataclasses import dataclass, fields
|
|
2
|
+
from functools import wraps
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def kebab_to_snake(name: str) -> str:
|
|
6
|
+
"""Convert kebab-case string to snake_case"""
|
|
7
|
+
return name.replace("-", "_")
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def accept_kebab_case(cls):
|
|
11
|
+
"""Decorator to allow dataclasses to accept kebab-case kwargs"""
|
|
12
|
+
|
|
13
|
+
original_init = cls.__init__
|
|
14
|
+
|
|
15
|
+
@wraps(original_init)
|
|
16
|
+
def new_init(self, *args, **kwargs):
|
|
17
|
+
transformed_kwargs = {
|
|
18
|
+
kebab_to_snake(key): value for key, value in kwargs.items()
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
valid_fields = {f.name for f in fields(cls)}
|
|
22
|
+
filtered_kwargs = {
|
|
23
|
+
key: value
|
|
24
|
+
for key, value in transformed_kwargs.items()
|
|
25
|
+
if key in valid_fields
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
original_init(self, *args, **filtered_kwargs)
|
|
29
|
+
|
|
30
|
+
cls.__init__ = new_init
|
|
31
|
+
return cls
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
@accept_kebab_case
|
|
35
|
+
@dataclass(kw_only=True)
|
|
36
|
+
class Project:
|
|
37
|
+
"""Dataclass model defining [project] section of pyproject.toml"""
|
|
38
|
+
|
|
39
|
+
name: str
|
|
40
|
+
version: str
|
|
41
|
+
description: str | None
|
|
42
|
+
|
|
43
|
+
urls: dict[str, str] | None
|
|
44
|
+
|
|
45
|
+
readme: str | None
|
|
46
|
+
license: str | None
|
|
47
|
+
license_files: str | None
|
|
48
|
+
|
|
49
|
+
requires_python: str | None
|
|
50
|
+
classifiers: list[str] | None
|
|
51
|
+
dependencies: list[str] | None
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Copyright (c) 2014, Saurabh Kumar (python-dotenv), 2013, Ted Tieken (django-dotenv-rw), 2013, Jacob Kaplan-Moss (django-dotenv)
|
|
3
|
+
|
|
4
|
+
Redistribution and use in source and binary forms, with or without modification,
|
|
5
|
+
are permitted provided that the following conditions are met:
|
|
6
|
+
|
|
7
|
+
- Redistributions of source code must retain the above copyright notice,
|
|
8
|
+
this list of conditions and the following disclaimer.
|
|
9
|
+
|
|
10
|
+
- Redistributions in binary form must reproduce the above copyright notice,
|
|
11
|
+
this list of conditions and the following disclaimer in the documentation
|
|
12
|
+
and/or other materials provided with the distribution.
|
|
13
|
+
|
|
14
|
+
- Neither the name of django-dotenv nor the names of its contributors
|
|
15
|
+
may be used to endorse or promote products derived from this software
|
|
16
|
+
without specific prior written permission.
|
|
17
|
+
|
|
18
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
19
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
20
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
21
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
22
|
+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
23
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
24
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
25
|
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
26
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
27
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
28
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
import os
|
|
32
|
+
import stat
|
|
33
|
+
import sys
|
|
34
|
+
from typing import Iterator, Union
|
|
35
|
+
|
|
36
|
+
# A type alias for a string path to be used for the paths in this file.
|
|
37
|
+
# These paths may flow to `open()` and `shutil.move()`; `shutil.move()`
|
|
38
|
+
# only accepts string paths, not byte paths or file descriptors. See
|
|
39
|
+
# https://github.com/python/typeshed/pull/6832.
|
|
40
|
+
StrPath = Union[str, "os.PathLike[str]"]
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def is_file_or_fifo(path: StrPath) -> bool:
|
|
44
|
+
"""Return True if `path` exists and is either a regular file or a FIFO"""
|
|
45
|
+
|
|
46
|
+
if os.path.isfile(path):
|
|
47
|
+
return True
|
|
48
|
+
|
|
49
|
+
try:
|
|
50
|
+
st = os.stat(path)
|
|
51
|
+
except (FileNotFoundError, OSError):
|
|
52
|
+
return False
|
|
53
|
+
|
|
54
|
+
return stat.S_ISFIFO(st.st_mode)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def walk_to_root(path: str) -> Iterator[str]:
|
|
58
|
+
"""Yield directories starting from the given directory up to the root"""
|
|
59
|
+
|
|
60
|
+
if not os.path.exists(path):
|
|
61
|
+
raise IOError("Starting path not found")
|
|
62
|
+
|
|
63
|
+
if os.path.isfile(path):
|
|
64
|
+
path = os.path.dirname(path)
|
|
65
|
+
|
|
66
|
+
last_dir = None
|
|
67
|
+
current_dir = os.path.abspath(path)
|
|
68
|
+
while last_dir != current_dir:
|
|
69
|
+
yield current_dir
|
|
70
|
+
parent_dir = os.path.abspath(os.path.join(current_dir, os.path.pardir))
|
|
71
|
+
last_dir, current_dir = current_dir, parent_dir
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def find_pyproject(
|
|
75
|
+
filename: str = "pyproject.toml",
|
|
76
|
+
raise_error_if_not_found: bool = False,
|
|
77
|
+
usecwd: bool = False,
|
|
78
|
+
) -> str:
|
|
79
|
+
"""Search in increasingly higher folders for the given file
|
|
80
|
+
|
|
81
|
+
Returns path to the file if found, or an empty string otherwise
|
|
82
|
+
"""
|
|
83
|
+
|
|
84
|
+
def _is_interactive():
|
|
85
|
+
"""Decide whether this is running in a REPL or IPython notebook"""
|
|
86
|
+
if hasattr(sys, "ps1") or hasattr(sys, "ps2"):
|
|
87
|
+
return True
|
|
88
|
+
try:
|
|
89
|
+
main = __import__("__main__", None, None, fromlist=["__file__"])
|
|
90
|
+
except ModuleNotFoundError:
|
|
91
|
+
return False
|
|
92
|
+
return not hasattr(main, "__file__")
|
|
93
|
+
|
|
94
|
+
def _is_debugger():
|
|
95
|
+
return sys.gettrace() is not None
|
|
96
|
+
|
|
97
|
+
if usecwd or _is_interactive() or _is_debugger() or getattr(sys, "frozen", False):
|
|
98
|
+
# Should work without __file__, e.g. in REPL or IPython notebook.
|
|
99
|
+
path = os.getcwd()
|
|
100
|
+
else:
|
|
101
|
+
# will work for .py files
|
|
102
|
+
frame = sys._getframe()
|
|
103
|
+
current_file = __file__
|
|
104
|
+
|
|
105
|
+
while frame.f_code.co_filename == current_file or not os.path.exists(
|
|
106
|
+
frame.f_code.co_filename
|
|
107
|
+
):
|
|
108
|
+
assert frame.f_back is not None
|
|
109
|
+
frame = frame.f_back
|
|
110
|
+
frame_filename = frame.f_code.co_filename
|
|
111
|
+
path = os.path.dirname(os.path.abspath(frame_filename))
|
|
112
|
+
|
|
113
|
+
for dirname in walk_to_root(path):
|
|
114
|
+
check_path = os.path.join(dirname, filename)
|
|
115
|
+
if is_file_or_fifo(check_path):
|
|
116
|
+
return check_path
|
|
117
|
+
|
|
118
|
+
if raise_error_if_not_found:
|
|
119
|
+
raise IOError("File not found")
|
|
120
|
+
|
|
121
|
+
return ""
|