Passed
Push — main ( bc64e0...ce7d48 )
by Eran
01:35
created

graphinate.server.web.get_static_path()   A

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 2
rs 10
c 0
b 0
f 0
cc 1
nop 1
1
import inspect
2
import pathlib
3
from collections.abc import Mapping
4
5
6
def current_file() -> pathlib.Path | None:
7
    """Returns current file name"""
8
    if current_frame := inspect.currentframe():
9
        return pathlib.Path(inspect.getfile(current_frame.f_back))
10
    return None
11
12
13
paths_mapping: Mapping[str, pathlib.Path] = {p.name: p for p in current_file().parent.iterdir() if p.is_dir()}
14
15
16
def get_static_path(relative_path: str) -> pathlib.Path:
17
    return paths_mapping['static'] / relative_path
18