Skip to content

Commit 42d1e30

Browse files
improve: black formatting
1 parent 37b1bca commit 42d1e30

File tree

9 files changed

+699
-592
lines changed

9 files changed

+699
-592
lines changed

docs/source/conf.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,23 @@
1212
#
1313
import os
1414
import sys
15-
sys.path.insert(0, os.path.abspath('../..'))
15+
16+
sys.path.insert(0, os.path.abspath("../.."))
1617
sys.setrecursionlimit(1500)
1718

1819

1920
# -- Project information -----------------------------------------------------
2021

21-
project = 'kmm'
22-
copyright = '2020, Aiwizo'
23-
author = 'Richard Löwenström, Felix Abrahamsson'
22+
project = "kmm"
23+
copyright = "2020, Aiwizo"
24+
author = "Richard Löwenström, Felix Abrahamsson"
2425

2526
# The full version, including alpha/beta/rc tags
2627
# release = '0.1.0'
2728
from pkg_resources import get_distribution, DistributionNotFound
29+
2830
try:
29-
release = get_distribution('kmm').version
31+
release = get_distribution("kmm").version
3032
except DistributionNotFound:
3133
pass
3234

@@ -37,23 +39,23 @@
3739
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
3840
# ones.
3941
extensions = [
40-
'sphinx.ext.autodoc',
41-
'sphinx.ext.autosummary',
42-
'recommonmark',
43-
'sphinx.ext.viewcode',
44-
'sphinx_rtd_theme',
42+
"sphinx.ext.autodoc",
43+
"sphinx.ext.autosummary",
44+
"recommonmark",
45+
"sphinx.ext.viewcode",
46+
"sphinx_rtd_theme",
4547
]
4648

4749
# Add any paths that contain templates here, relative to this directory.
48-
templates_path = ['_templates']
50+
templates_path = ["_templates"]
4951

5052
# List of patterns, relative to source directory, that match files and
5153
# directories to ignore when looking for source files.
5254
# This pattern also affects html_static_path and html_extra_path.
5355
exclude_patterns = []
5456

5557
# The name of the Pygments (syntax highlighting) style to use.
56-
pygments_style = 'sphinx'
58+
pygments_style = "sphinx"
5759

5860
# -- Options for HTML output -------------------------------------------------
5961

@@ -68,4 +70,3 @@
6870
# relative to this directory. They are copied after the builtin static files,
6971
# so a file named "default.css" will overwrite the builtin "default.css".
7072
# html_static_path = ['_static']
71-

kmm/header/car_direction.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@
77
def car_direction(tree: ElementTree):
88

99
root = tree.getroot()
10-
start_tags = [
11-
child.text
12-
for child in root
13-
if child.tag == "Start"
14-
]
10+
start_tags = [child.text for child in root if child.tag == "Start"]
1511

1612
if len(start_tags) != 1:
1713
raise ValueError(f"Expected 1 'Start' tag in header, found {len(start_tags)}")

kmm/header/position_sync.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@
55
def position_sync(tree: ElementTree):
66

77
root = tree.getroot()
8-
sync_tags = [
9-
child.text
10-
for child in root
11-
if child.tag == "Sync"
12-
]
8+
sync_tags = [child.text for child in root if child.tag == "Sync"]
139

1410
if len(sync_tags) == 0:
1511
raise ValueError("Did not find a Sync tag in header.")

kmm/positions/positions.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Config:
1818
def from_path(
1919
path: Path,
2020
raise_on_malformed_data: bool = True,
21-
replace_commas: bool=True,
21+
replace_commas: bool = True,
2222
):
2323
"""
2424
Loads positions from .kmm or .kmm2 file.
@@ -27,7 +27,9 @@ def from_path(
2727
dataframe = kmm.positions.read_kmm(path)
2828
elif path.suffix == ".kmm2":
2929
dataframe = kmm.positions.read_kmm2(
30-
path, raise_on_malformed_data=raise_on_malformed_data, replace_commas=replace_commas
30+
path,
31+
raise_on_malformed_data=raise_on_malformed_data,
32+
replace_commas=replace_commas,
3133
)
3234
else:
3335
raise ValueError(f"Unable to parse file type {path.suffix}")
@@ -41,15 +43,19 @@ def read_sync_adjust(
4143
header_path: Path,
4244
adjustment: kmm.PositionAdjustment = kmm.PositionAdjustment.WIRE_CAMERA,
4345
raise_on_malformed_data: bool = True,
44-
replace_commas: bool=True,
46+
replace_commas: bool = True,
4547
):
4648
"""
4749
Loads positions from .kmm or .kmm2 file + .hdr file, then performs
4850
frame index sync, position adjustment and geodetic coordinate transformation.
4951
"""
5052
header = kmm.Header.from_path(header_path, raise_on_malformed_data)
5153
return (
52-
Positions.from_path(kmm_path, raise_on_malformed_data=raise_on_malformed_data, replace_commas=replace_commas)
54+
Positions.from_path(
55+
kmm_path,
56+
raise_on_malformed_data=raise_on_malformed_data,
57+
replace_commas=replace_commas,
58+
)
5359
.sync_frame_index(header, adjustment, raise_on_malformed_data)
5460
.geodetic()
5561
)

kmm/positions/read_kmm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88

99
@validate_arguments
10-
def read_kmm(path: Path, replace_commas: bool=True):
10+
def read_kmm(path: Path, replace_commas: bool = True):
1111
try:
1212
if replace_commas:
1313
with open(path, "r", encoding="latin1") as f:

kmm/positions/read_kmm2.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@
4747

4848

4949
@validate_arguments
50-
def read_kmm2(path: Path, raise_on_malformed_data: bool = True, replace_commas: bool=True):
50+
def read_kmm2(
51+
path: Path, raise_on_malformed_data: bool = True, replace_commas: bool = True
52+
):
5153
skiprows = [
5254
index
5355
for index, line in enumerate(path.read_text(encoding="latin1").splitlines())
@@ -59,7 +61,7 @@ def read_kmm2(path: Path, raise_on_malformed_data: bool = True, replace_commas:
5961
skiprows = [0] + skiprows
6062
elif raise_on_malformed_data and not line.startswith("POS"):
6163
raise ValueError("Malformed data, first line is not POS or VER")
62-
64+
6365
try:
6466
if replace_commas:
6567
with open(path, "r", encoding="latin1") as f:
@@ -68,7 +70,7 @@ def read_kmm2(path: Path, raise_on_malformed_data: bool = True, replace_commas:
6870
file_obj = StringIO(content)
6971
else:
7072
file_obj = path
71-
73+
7274
try:
7375
df = pd.read_csv(
7476
file_obj,

0 commit comments

Comments
 (0)