Passed
Push — main ( 05fcff...04a574 )
by Eran
01:28
created

web   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 9
dl 0
loc 16
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A graphinate.server.web.get_static_path() 0 2 1
A graphinate.server.web.current_file() 0 3 1
1
import inspect
2
import pathlib
3
from collections.abc import Mapping
4
5
6
def current_file() -> pathlib.Path:
7
    """Returns current file name"""
8
    return pathlib.Path(inspect.getfile(inspect.currentframe().f_back))
9
10
11
paths_mapping: Mapping[str, pathlib.Path] = {p.name: p for p in current_file().parent.iterdir() if p.is_dir()}
12
13
14
def get_static_path(relative_path: str) -> pathlib.Path:
15
    return paths_mapping['static'] / relative_path
16