diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
new file mode 100644
index 000000000..29bca3fb8
--- /dev/null
+++ b/.pre-commit-config.yaml
@@ -0,0 +1,5 @@
+repos:
+ - repo: https://github.com/psf/black
+ rev: stable
+ hooks:
+ - id: black
diff --git a/pyproject.toml b/pyproject.toml
index 6586ec12f..2a22c41bf 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -13,16 +13,22 @@ extend-exclude = '''
source = ["asammdf"]
omit = ["*/asammdf/gui/ui/*"]
-
-[tool.isort]
-force_sort_within_sections = true
-order_by_type = false
-profile = "black"
-skip_glob = ["src/asammdf/gui/ui"]
-
[tool.cibuildwheel]
test-requires = "pytest"
test-command = "pytest {project}/test"
build-frontend = "build"
archs = ["auto64"] # only build for 64bit architectures
skip = "pp* *_ppc64le *_s390x *-musllinux* cp312-*" # skip pypy and irrelevant architectures
+
+[tool.ruff]
+select = [
+ "UP", # pyupgrade
+ "I", # isort
+]
+exclude = ["./src/asammdf/gui/ui"]
+target-version = "py38"
+
+[tool.ruff.isort]
+known-first-party = ["asammdf"]
+order-by-type = false
+force-sort-within-sections = true
\ No newline at end of file
diff --git a/requirements.txt b/requirements.txt
index 068532c7a..d14e6fd57 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -6,4 +6,4 @@ pandas
typing_extensions
python-dateutil
isal; platform_machine == "x86_64" or platform_machine == "AMD64"
-lxml<=4.9.2
+lxml>=4.9.3
diff --git a/requirements_exe_build.txt b/requirements_exe_build.txt
index d7a39f3ff..9ffb6f0f7 100644
--- a/requirements_exe_build.txt
+++ b/requirements_exe_build.txt
@@ -5,11 +5,11 @@ numpy>=1.23.0
pandas
typing_extensions
isal; platform_machine == "x86_64" or platform_machine == "AMD64"
-lxml<=4.9.2
+lxml==4.9.3
natsort
psutil
-PySide6==6.2.2
-pyqtgraph==0.12.4
+PySide6==6.6.0
+pyqtgraph==0.13.3
QtPy==2.3.1
pyqtlet2
pyopengl
@@ -21,8 +21,8 @@ cChardet==2.1.5
chardet
cryptography
keyring
-pyinstaller<6.0; sys_platform=="win32"
+pyinstaller; sys_platform=="win32"
pyinstaller<6.0; sys_platform=="darwin"
-pyinstaller==4.10; sys_platform=="linux"
+pyinstaller<6.0; sys_platform=="linux"
scipy
sympy
diff --git a/run_black_and_isort.bat b/run_black_and_isort.bat
deleted file mode 100644
index 7df16b6be..000000000
--- a/run_black_and_isort.bat
+++ /dev/null
@@ -1,7 +0,0 @@
-pip install -U black isort && ^
-black --config pyproject.toml . && ^
-black --config pyproject.toml asammdf.spec && ^
-black --config pyproject.toml setup.py && ^
-isort --settings-path pyproject.toml asammdf.spec && ^
-isort --settings-path pyproject.toml setup.py && ^
-isort --settings-path pyproject.toml .
diff --git a/run_black_and_ruff.bat b/run_black_and_ruff.bat
new file mode 100644
index 000000000..d3ab2d875
--- /dev/null
+++ b/run_black_and_ruff.bat
@@ -0,0 +1,6 @@
+pip install -U black ruff && ^
+ruff check --fix ./src && ^
+ruff check --fix ./setup.py && ^
+black --config pyproject.toml . && ^
+black --config pyproject.toml asammdf.spec && ^
+black --config pyproject.toml setup.py
diff --git a/setup.py b/setup.py
index 8ce6227db..b6e95bb03 100644
--- a/setup.py
+++ b/setup.py
@@ -104,18 +104,19 @@ def _get_ext_modules():
"export": [
"fastparquet",
"h5py",
- "hdf5storage>=0.1.17",
+ "hdf5storage>=0.1.19",
"python-snappy",
],
"export_matlab_v5": "scipy",
"gui": [
- "lxml<=4.9.2",
+ "lxml>=4.9.2",
"natsort",
"psutil",
- "PySide6<=6.3.1",
- "pyqtgraph>=0.12.4",
- "pyqtlet2>=0.8.0",
+ "PySide6==6.6.0",
+ "pyqtgraph==0.13.3",
+ "pyqtlet2==0.9.3",
"packaging",
+ "QtPy==2.3.1",
],
"encryption": ["cryptography", "keyring"],
"symbolic_math": "sympy",
diff --git a/src/asammdf/__init__.py b/src/asammdf/__init__.py
index 35fb2e7fa..a4a0fb437 100644
--- a/src/asammdf/__init__.py
+++ b/src/asammdf/__init__.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
""" asammdf is a parser and editor for ASAM MDF files """
import logging
diff --git a/src/asammdf/blocks/conversion_utils.py b/src/asammdf/blocks/conversion_utils.py
index 58886d981..3123de528 100644
--- a/src/asammdf/blocks/conversion_utils.py
+++ b/src/asammdf/blocks/conversion_utils.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
"""
asammdf utility functions for channel conversions
"""
@@ -8,11 +7,11 @@
from copy import deepcopy
from typing import Any, Union
+from ..types import ChannelConversionType
from . import v2_v3_blocks as v3b
from . import v2_v3_constants as v3c
from . import v4_blocks as v4b
from . import v4_constants as v4c
-from ..types import ChannelConversionType
__all__ = ["conversion_transfer", "from_dict"]
@@ -379,7 +378,7 @@ def from_dict(conversion: dict[str, Any]) -> v4b.ChannelConversion:
return conversion
-def to_dict(conversion: ChannelConversionType) -> Union[dict, None]:
+def to_dict(conversion: ChannelConversionType) -> dict | None:
if not conversion:
return None
diff --git a/src/asammdf/blocks/mdf_v2.py b/src/asammdf/blocks/mdf_v2.py
index 6f4b8d7bd..1a84f529b 100644
--- a/src/asammdf/blocks/mdf_v2.py
+++ b/src/asammdf/blocks/mdf_v2.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
""" ASAM MDF version 2 file format module """
from __future__ import annotations
diff --git a/src/asammdf/blocks/mdf_v3.py b/src/asammdf/blocks/mdf_v3.py
index 062fd571f..0e21e9182 100644
--- a/src/asammdf/blocks/mdf_v3.py
+++ b/src/asammdf/blocks/mdf_v3.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
""" ASAM MDF version 3 file format module """
from __future__ import annotations
@@ -44,11 +43,11 @@
from pandas import DataFrame
from typing_extensions import Literal, TypedDict
-from . import v2_v3_constants as v23c
from .. import tool
from ..signal import Signal
from ..types import ChannelsType, CompressionType, RasterType, StrPathType
from ..version import __version__
+from . import v2_v3_constants as v23c
from .conversion_utils import conversion_transfer
from .cutils import get_channel_raw_bytes
from .mdf_common import MDF_Common
@@ -1799,7 +1798,7 @@ def append(
sd_nr = len(component_samples)
kargs = {"sd_nr": sd_nr}
for i, dim in enumerate(shape[::-1]):
- kargs["dim_{}".format(i)] = dim
+ kargs[f"dim_{i}"] = dim
parent_dep = ChannelDependency(**kargs)
new_gp_dep.append(parent_dep)
diff --git a/src/asammdf/blocks/mdf_v4.py b/src/asammdf/blocks/mdf_v4.py
index ba83aa616..9e849874b 100644
--- a/src/asammdf/blocks/mdf_v4.py
+++ b/src/asammdf/blocks/mdf_v4.py
@@ -75,8 +75,6 @@
from numpy.typing import NDArray
from pandas import DataFrame
-from . import bus_logging_utils
-from . import v4_constants as v4c
from .. import tool
from ..signal import Signal
from ..types import (
@@ -89,6 +87,8 @@
WritableBufferType,
)
from ..version import __version__
+from . import bus_logging_utils
+from . import v4_constants as v4c
from .conversion_utils import conversion_transfer
from .mdf_common import MDF_Common
from .options import get_global_option
diff --git a/src/asammdf/blocks/source_utils.py b/src/asammdf/blocks/source_utils.py
index 5bc8bdc14..feabce9c2 100644
--- a/src/asammdf/blocks/source_utils.py
+++ b/src/asammdf/blocks/source_utils.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
"""
asammdf utility functions for source information
"""
@@ -7,11 +6,11 @@
from functools import lru_cache
+from ..types import SourceType
from . import v2_v3_blocks as v3b
from . import v2_v3_constants as v3c
from . import v4_blocks as v4b
from . import v4_constants as v4c
-from ..types import SourceType
class Source:
diff --git a/src/asammdf/blocks/utils.py b/src/asammdf/blocks/utils.py
index 89fa742b9..046b5cbc4 100644
--- a/src/asammdf/blocks/utils.py
+++ b/src/asammdf/blocks/utils.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
"""
asammdf utility functions and classes
"""
@@ -94,8 +93,6 @@ def detect(text: bytes) -> DetectDict:
from numpy.typing import NDArray
from pandas import Series
-from . import v2_v3_constants as v3c
-from . import v4_constants as v4c
from ..types import (
ChannelType,
DataGroupType,
@@ -104,6 +101,8 @@ def detect(text: bytes) -> DetectDict:
ReadableBufferType,
StrPathType,
)
+from . import v2_v3_constants as v3c
+from . import v4_constants as v4c
UINT8_u = Struct(" bool:
return True
-class UniqueDB(object):
+class UniqueDB:
def __init__(self) -> None:
self._db = {}
@@ -1279,8 +1278,7 @@ def clear(self) -> None:
self.data_blocks_info_generator = None
def get_data_blocks(self) -> Iterator[DataBlockInfo]:
- for blk in self.data_blocks:
- yield blk
+ yield from self.data_blocks
while True:
try:
@@ -1294,8 +1292,7 @@ def get_signal_data_blocks(self, index: int) -> Iterator[SignalDataBlockInfo]:
signal_data = self.signal_data[index]
if signal_data is not None:
signal_data, signal_generator = signal_data
- for blk in signal_data:
- yield blk
+ yield from signal_data
while True:
try:
@@ -2322,7 +2319,7 @@ def load_channel_names_from_file(file_name, lab_section=""):
channels = load_dsp(file_name, flat=True)
elif extension == ".dspf":
- with open(file_name, "r") as infile:
+ with open(file_name) as infile:
info = json.load(infile)
channels = []
@@ -2345,16 +2342,16 @@ def load_channel_names_from_file(file_name, lab_section=""):
channels = [name.split(";")[0] for name in channels]
elif extension == ".cfg":
- with open(file_name, "r") as infile:
+ with open(file_name) as infile:
info = json.load(infile)
channels = info.get("selected_channels", [])
elif extension == ".txt":
try:
- with open(file_name, "r") as infile:
+ with open(file_name) as infile:
info = json.load(infile)
channels = info.get("selected_channels", [])
except:
- with open(file_name, "r") as infile:
+ with open(file_name) as infile:
channels = [line.strip() for line in infile.readlines()]
channels = [name for name in channels if name]
@@ -2363,7 +2360,7 @@ def load_channel_names_from_file(file_name, lab_section=""):
def load_lab(file):
sections = {}
- with open(file, "r") as lab:
+ with open(file) as lab:
for line in lab:
line = line.strip()
if not line:
diff --git a/src/asammdf/blocks/v2_v3_blocks.py b/src/asammdf/blocks/v2_v3_blocks.py
index 23ef14447..cfea9a7b9 100644
--- a/src/asammdf/blocks/v2_v3_blocks.py
+++ b/src/asammdf/blocks/v2_v3_blocks.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
""" classes that implement the blocks for MDF versions 2 and 3 """
from __future__ import annotations
@@ -25,8 +24,8 @@
import numpy as np
-from . import v2_v3_constants as v23c
from ..version import __version__
+from . import v2_v3_constants as v23c
from .utils import (
escape_xml_string,
get_fields,
@@ -1566,16 +1565,13 @@ def convert(self, values, as_object=False, as_bytes=False, ignore_value2text_con
P6 = self.P6
X = values
- if (P1, P4, P5, P6) == (0, 0, 0, 1):
- if (P2, P3) != (1, 0):
- values = values * P2
- if P3:
- values += P3
- elif (P3, P4, P5, P6) == (0, 0, 1, 0):
- if (P1, P2) != (1, 0):
- values = values * P1
- if P2:
- values += P2
+ if (P1, P3, P4, P5) == (0, 0, 0, 0):
+ if P2 != P6:
+ values = values * (P2 / P6)
+
+ elif (P2, P3, P4, P6) == (0, 0, 0, 0):
+ if P1 != P5:
+ values = values * (P1 / P5)
else:
try:
values = evaluate(v23c.RAT_CONV_TEXT)
@@ -1761,7 +1757,7 @@ def __init__(self, **kwargs) -> None:
(self.id, self.block_len, self.dependency_type, self.sd_nr) = unpack("<2s3H", stream.read(8))
links_size = 3 * 4 * self.sd_nr
- links = unpack("<{}I".format(3 * self.sd_nr), stream.read(links_size))
+ links = unpack(f"<{3 * self.sd_nr}I", stream.read(links_size))
for i in range(self.sd_nr):
self[f"dg_{i}"] = links[3 * i]
@@ -2727,7 +2723,7 @@ def __init__(self, **kwargs) -> None:
user = getuser()
except ModuleNotFoundError:
user = ""
- self.author_field = "{:\0<32}".format(user).encode("latin-1")
+ self.author_field = f"{user:\0<32}".encode("latin-1")
self.department_field = "{:\0<32}".format("").encode("latin-1")
self.project_field = "{:\0<32}".format("").encode("latin-1")
self.subject_field = "{:\0<32}".format("").encode("latin-1")
@@ -3162,12 +3158,12 @@ def __init__(self, **kwargs) -> None:
nr = self.trigger_events_nr
if nr:
- values = unpack("<{}d".format(3 * nr), block[10:])
+ values = unpack(f"<{3 * nr}d", block[10:])
for i in range(nr):
(
- self["trigger_{}_time".format(i)],
- self["trigger_{}_pretime".format(i)],
- self["trigger_{}_posttime".format(i)],
+ self[f"trigger_{i}_time"],
+ self[f"trigger_{i}_pretime"],
+ self[f"trigger_{i}_posttime"],
) = (values[i * 3], values[3 * i + 1], values[3 * i + 2])
if self.text_addr:
@@ -3182,7 +3178,7 @@ def __init__(self, **kwargs) -> None:
except KeyError:
self.address = 0
nr = 0
- while "trigger_{}_time".format(nr) in kwargs:
+ while f"trigger_{nr}_time" in kwargs:
nr += 1
self.id = b"TR"
@@ -3191,11 +3187,11 @@ def __init__(self, **kwargs) -> None:
self.trigger_events_nr = nr
for i in range(nr):
- key = "trigger_{}_time".format(i)
+ key = f"trigger_{i}_time"
self[key] = kwargs[key]
- key = "trigger_{}_pretime".format(i)
+ key = f"trigger_{i}_pretime"
self[key] = kwargs[key]
- key = "trigger_{}_posttime".format(i)
+ key = f"trigger_{i}_posttime"
self[key] = kwargs[key]
def to_blocks(self, address: int, blocks: list[Any]) -> int:
@@ -3223,13 +3219,13 @@ def __setitem__(self, item: str, value: Any) -> None:
def __bytes__(self) -> bytes:
triggers_nr = self.trigger_events_nr
- fmt = "<2sHIH{}d".format(triggers_nr * 3)
+ fmt = f"<2sHIH{triggers_nr * 3}d"
keys = ("id", "block_len", "text_addr", "trigger_events_nr")
for i in range(triggers_nr):
keys += (
- "trigger_{}_time".format(i),
- "trigger_{}_pretime".format(i),
- "trigger_{}_posttime".format(i),
+ f"trigger_{i}_time",
+ f"trigger_{i}_pretime",
+ f"trigger_{i}_posttime",
)
result = pack(fmt, *[self[key] for key in keys])
return result
diff --git a/src/asammdf/blocks/v2_v3_constants.py b/src/asammdf/blocks/v2_v3_constants.py
index 0b81bd2cb..a26396bf8 100644
--- a/src/asammdf/blocks/v2_v3_constants.py
+++ b/src/asammdf/blocks/v2_v3_constants.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
""" MDF v2 and v3 constants """
import struct
diff --git a/src/asammdf/blocks/v4_blocks.py b/src/asammdf/blocks/v4_blocks.py
index 10757bb37..36531ae4a 100644
--- a/src/asammdf/blocks/v4_blocks.py
+++ b/src/asammdf/blocks/v4_blocks.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
"""
classes that implement the blocks for MDF version 4
"""
@@ -42,8 +41,8 @@
import numpy as np
-from . import v4_constants as v4c
from ..version import __version__
+from . import v4_constants as v4c
from .utils import (
block_fields,
escape_xml_string,
@@ -1766,7 +1765,7 @@ def __bytes__(self) -> bytes:
if self.storage:
keys += tuple(f"cycle_count_{i}" for i in range(data_links_nr))
- fmt = "<4sI{}Q2BHIiI{}Q{}d{}Q".format(self.links_nr + 2, dims_nr, sum(dim_sizes), data_links_nr)
+ fmt = f"<4sI{self.links_nr + 2}Q2BHIiI{dims_nr}Q{sum(dim_sizes)}d{data_links_nr}Q"
result = pack(fmt, *[getattr(self, key) for key in keys])
return result
@@ -3155,17 +3154,13 @@ def convert(self, values, as_object=False, as_bytes=False, ignore_value2text_con
if names:
name = names[0]
vals = values[name]
- if (P1, P4, P5, P6) == (0, 0, 0, 1):
- if (P2, P3) != (1, 0):
- vals = values[name] * P2
- if P3:
- vals = vals + P3
-
- elif (P3, P4, P5, P6) == (0, 0, 1, 0):
- if (P1, P2) != (1, 0):
- vals = values[name] * P1
- if P2:
- vals = vals + P2
+ if (P1, P3, P4, P5) == (0, 0, 0, 0):
+ if P2 != P6:
+ vals = vals * (P2 / P6)
+
+ elif (P2, P3, P4, P6) == (0, 0, 0, 0):
+ if P1 != P5:
+ vals = vals * (P1 / P5)
else:
X = vals
@@ -3182,16 +3177,13 @@ def convert(self, values, as_object=False, as_bytes=False, ignore_value2text_con
else:
X = values
- if (P1, P4, P5, P6) == (0, 0, 0, 1):
- if (P2, P3) != (1, 0):
- values = values * P2
- if P3:
- values = values + P3
- elif (P3, P4, P5, P6) == (0, 0, 1, 0):
- if (P1, P2) != (1, 0):
- values = values * P1
- if P2:
- values += P2
+ if (P1, P3, P4, P5) == (0, 0, 0, 0):
+ if P2 != P6:
+ values = values * (P2 / P6)
+
+ elif (P2, P3, P4, P6) == (0, 0, 0, 0):
+ if P1 != P5:
+ values = values * (P1 / P5)
else:
try:
values = evaluate(v4c.CONV_RAT_TEXT)
@@ -3851,7 +3843,7 @@ def convert(self, values, as_object=False, as_bytes=False, ignore_value2text_con
phys = [
conv
if isinstance(conv, bytes)
- else ((f"{conv.name}=".encode("utf-8"), conv) if conv.name else (b"", conv))
+ else ((f"{conv.name}=".encode(), conv) if conv.name else (b"", conv))
for conv in phys
]
@@ -4176,20 +4168,20 @@ def __bytes__(self) -> bytes:
v4c.CONVERSION_TYPE_TABI,
v4c.CONVERSION_TYPE_TAB,
):
- fmt = "<4sI{}Q2B3H{}d".format(self.links_nr + 2, self.val_param_nr + 2)
+ fmt = f"<4sI{self.links_nr + 2}Q2B3H{self.val_param_nr + 2}d"
keys = v4c.KEYS_CONVERSION_NONE
for i in range(self.val_param_nr // 2):
keys += (f"raw_{i}", f"phys_{i}")
result = pack(fmt, *[getattr(self, key) for key in keys])
elif self.conversion_type == v4c.CONVERSION_TYPE_RTAB:
- fmt = "<4sI{}Q2B3H{}d".format(self.links_nr + 2, self.val_param_nr + 2)
+ fmt = f"<4sI{self.links_nr + 2}Q2B3H{self.val_param_nr + 2}d"
keys = v4c.KEYS_CONVERSION_NONE
for i in range(self.val_param_nr // 3):
keys += (f"lower_{i}", f"upper_{i}", f"phys_{i}")
keys += ("default",)
result = pack(fmt, *[getattr(self, key) for key in keys])
elif self.conversion_type == v4c.CONVERSION_TYPE_TABX:
- fmt = "<4sI{}Q2B3H{}d".format(self.links_nr + 2, self.val_param_nr + 2)
+ fmt = f"<4sI{self.links_nr + 2}Q2B3H{self.val_param_nr + 2}d"
keys = (
"id",
"reserved0",
@@ -4214,7 +4206,7 @@ def __bytes__(self) -> bytes:
keys += tuple(f"val_{i}" for i in range(self.val_param_nr))
result = pack(fmt, *[getattr(self, key) for key in keys])
elif self.conversion_type == v4c.CONVERSION_TYPE_RTABX:
- fmt = "<4sI{}Q2B3H{}d".format(self.links_nr + 2, self.val_param_nr + 2)
+ fmt = f"<4sI{self.links_nr + 2}Q2B3H{self.val_param_nr + 2}d"
keys = (
"id",
"reserved0",
@@ -4240,7 +4232,7 @@ def __bytes__(self) -> bytes:
keys += (f"lower_{i}", f"upper_{i}")
result = pack(fmt, *[getattr(self, key) for key in keys])
elif self.conversion_type == v4c.CONVERSION_TYPE_TTAB:
- fmt = "<4sI{}Q2B3H{}d".format(self.links_nr + 2, self.val_param_nr + 2)
+ fmt = f"<4sI{self.links_nr + 2}Q2B3H{self.val_param_nr + 2}d"
keys = (
"id",
"reserved0",
@@ -4265,7 +4257,7 @@ def __bytes__(self) -> bytes:
keys += ("val_default",)
result = pack(fmt, *[getattr(self, key) for key in keys])
elif self.conversion_type == v4c.CONVERSION_TYPE_TRANS:
- fmt = "<4sI{}Q2B3H{}d".format(self.links_nr + 2, self.val_param_nr + 2)
+ fmt = f"<4sI{self.links_nr + 2}Q2B3H{self.val_param_nr + 2}d"
keys = (
"id",
"reserved0",
@@ -4293,7 +4285,7 @@ def __bytes__(self) -> bytes:
result = pack(fmt, *[getattr(self, key) for key in keys])
elif self.conversion_type == v4c.CONVERSION_TYPE_BITFIELD:
- fmt = "<4sI{}Q2B3H2d{}Q".format(self.links_nr + 2, self.val_param_nr)
+ fmt = f"<4sI{self.links_nr + 2}Q2B3H2d{self.val_param_nr}Q"
keys = (
"id",
"reserved0",
@@ -4400,7 +4392,7 @@ def __init__(self, **kwargs) -> None:
if type not in ("DT", "SD", "RD", "DV", "DI"):
type = "DT"
- self.id = "##{}".format(type).encode("ascii")
+ self.id = f"##{type}".encode("ascii")
self.reserved0 = 0
self.block_len = len(kwargs["data"]) + COMMON_SIZE
self.links_nr = 0
@@ -4416,7 +4408,7 @@ def __bytes__(self) -> bytes:
return v4c.COMMON_p(self.id, self.reserved0, self.block_len, self.links_nr) + self.data
-class DataZippedBlock(object):
+class DataZippedBlock:
"""*DataZippedBlock* has the following attributes, that are also available
as dict like key-value pairs
@@ -4856,7 +4848,7 @@ def __init__(self, **kwargs) -> None:
else:
(self.reserved1, self.data_block_nr) = unpack("<3sI", stream.read(7))
offsets = unpack(
- "<{}Q".format(self.links_nr - 1),
+ f"<{self.links_nr - 1}Q",
stream.read((self.links_nr - 1) * 8),
)
for i, offset in enumerate(offsets):
@@ -4885,7 +4877,7 @@ def __init__(self, **kwargs) -> None:
else:
(self.reserved1, self.data_block_nr) = unpack("<3sI", stream.read(7))
offsets = unpack(
- "<{}Q".format(self.links_nr - 1),
+ f"<{self.links_nr - 1}Q",
stream.read((self.links_nr - 1) * 8),
)
for i, offset in enumerate(offsets):
@@ -5282,8 +5274,8 @@ def __init__(self, **kwargs) -> None:
except KeyError:
version = kwargs.get("version", "4.00")
- self.file_identification = "MDF ".encode("utf-8")
- self.version_str = "{} ".format(version).encode("utf-8")
+ self.file_identification = b"MDF "
+ self.version_str = f"{version} ".encode()
self.program_identification = "amdf{}".format(__version__.replace(".", "")).encode("utf-8")
self.reserved0 = b"\0" * 4
self.mdf_version = int(version.replace(".", ""))
diff --git a/src/asammdf/blocks/v4_constants.py b/src/asammdf/blocks/v4_constants.py
index 06ea21b3c..d86839316 100644
--- a/src/asammdf/blocks/v4_constants.py
+++ b/src/asammdf/blocks/v4_constants.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
""" MDF v4 constants """
import re
import struct
diff --git a/src/asammdf/gui/__init__.py b/src/asammdf/gui/__init__.py
index e69de29bb..8b1378917 100644
--- a/src/asammdf/gui/__init__.py
+++ b/src/asammdf/gui/__init__.py
@@ -0,0 +1 @@
+
diff --git a/src/asammdf/gui/asammdfgui.py b/src/asammdf/gui/asammdfgui.py
index fc3a74a75..ab407ef6f 100644
--- a/src/asammdf/gui/asammdfgui.py
+++ b/src/asammdf/gui/asammdfgui.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
import argparse
import os
import sys
@@ -6,6 +5,7 @@
os.environ["QT_API"] = "pyside6"
os.environ["PYQTGRAPH_QT_LIB"] = "PySide6"
os.environ["QT_ENABLE_HIGHDPI_SCALING"] = "0"
+os.environ["PYSIDE6_OPTION_PYTHON_ENUM"] = "2"
alternative_sitepacakges = os.environ.get("ASAMMDF_PYTHONPATH", "")
diff --git a/src/asammdf/gui/dialogs/advanced_search.py b/src/asammdf/gui/dialogs/advanced_search.py
index 7718073d3..c44b523b2 100644
--- a/src/asammdf/gui/dialogs/advanced_search.py
+++ b/src/asammdf/gui/dialogs/advanced_search.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
import os
import re
from traceback import format_exc
diff --git a/src/asammdf/gui/dialogs/bus_database_manager.py b/src/asammdf/gui/dialogs/bus_database_manager.py
index 815de77ed..6e2a4580f 100644
--- a/src/asammdf/gui/dialogs/bus_database_manager.py
+++ b/src/asammdf/gui/dialogs/bus_database_manager.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from PySide6 import QtCore, QtWidgets
from ..widgets.bus_database_manager import BusDatabaseManager
diff --git a/src/asammdf/gui/dialogs/channel_group_info.py b/src/asammdf/gui/dialogs/channel_group_info.py
index a6261e3e6..2ead2663d 100644
--- a/src/asammdf/gui/dialogs/channel_group_info.py
+++ b/src/asammdf/gui/dialogs/channel_group_info.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from PySide6 import QtCore, QtGui, QtWidgets
from ..ui import resource_rc
diff --git a/src/asammdf/gui/dialogs/channel_info.py b/src/asammdf/gui/dialogs/channel_info.py
index 981639f64..3d40a3f73 100644
--- a/src/asammdf/gui/dialogs/channel_info.py
+++ b/src/asammdf/gui/dialogs/channel_info.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from PySide6 import QtCore, QtGui, QtWidgets
from ..ui import resource_rc
diff --git a/src/asammdf/gui/dialogs/conversion_editor.py b/src/asammdf/gui/dialogs/conversion_editor.py
index 895422e46..ba91b2d91 100644
--- a/src/asammdf/gui/dialogs/conversion_editor.py
+++ b/src/asammdf/gui/dialogs/conversion_editor.py
@@ -1,5 +1,3 @@
-# -*- coding: utf-8 -*-
-
import numpy as np
from PySide6 import QtCore, QtGui, QtWidgets
diff --git a/src/asammdf/gui/dialogs/define_channel.py b/src/asammdf/gui/dialogs/define_channel.py
index 865dabdbf..4296344d4 100644
--- a/src/asammdf/gui/dialogs/define_channel.py
+++ b/src/asammdf/gui/dialogs/define_channel.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from functools import partial
import inspect
import os
diff --git a/src/asammdf/gui/dialogs/error_dialog.py b/src/asammdf/gui/dialogs/error_dialog.py
index 19852c6c4..a8047453e 100644
--- a/src/asammdf/gui/dialogs/error_dialog.py
+++ b/src/asammdf/gui/dialogs/error_dialog.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from threading import Thread
from time import sleep
diff --git a/src/asammdf/gui/dialogs/functions_manager.py b/src/asammdf/gui/dialogs/functions_manager.py
index 0b3f47900..b8414910d 100644
--- a/src/asammdf/gui/dialogs/functions_manager.py
+++ b/src/asammdf/gui/dialogs/functions_manager.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from copy import deepcopy
import os
from traceback import format_exc
diff --git a/src/asammdf/gui/dialogs/gps_dialog.py b/src/asammdf/gui/dialogs/gps_dialog.py
index d4831356e..b9c108ca6 100644
--- a/src/asammdf/gui/dialogs/gps_dialog.py
+++ b/src/asammdf/gui/dialogs/gps_dialog.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
import re
from natsort import natsorted
diff --git a/src/asammdf/gui/dialogs/multi_search.py b/src/asammdf/gui/dialogs/multi_search.py
index 4325fe446..361d30bd3 100644
--- a/src/asammdf/gui/dialogs/multi_search.py
+++ b/src/asammdf/gui/dialogs/multi_search.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
import os
import re
from textwrap import wrap
@@ -100,7 +99,7 @@ def _apply(self, event):
self.result = set()
for i in range(count):
text = self.selection.item(i).text()
- file_index, channel_name = [item.strip() for item in text.split(":")]
+ file_index, channel_name = (item.strip() for item in text.split(":"))
file_index = int(file_index) - 1
for entry in self.channels_dbs[file_index][channel_name]:
self.result.add((file_index, entry))
diff --git a/src/asammdf/gui/dialogs/range_editor.py b/src/asammdf/gui/dialogs/range_editor.py
index 79f4b6c10..ded836574 100644
--- a/src/asammdf/gui/dialogs/range_editor.py
+++ b/src/asammdf/gui/dialogs/range_editor.py
@@ -1,6 +1,3 @@
-# -*- coding: utf-8 -*-
-
-
from PySide6 import QtCore, QtWidgets
from ..ui import resource_rc
diff --git a/src/asammdf/gui/dialogs/simple_search.py b/src/asammdf/gui/dialogs/simple_search.py
index 3552f0dab..e1999bfaf 100644
--- a/src/asammdf/gui/dialogs/simple_search.py
+++ b/src/asammdf/gui/dialogs/simple_search.py
@@ -1,5 +1,3 @@
-# -*- coding: utf-8 -*-
-
from functools import partial
import os
import re
diff --git a/src/asammdf/gui/dialogs/window_selection_dialog.py b/src/asammdf/gui/dialogs/window_selection_dialog.py
index cd48c5d41..ec596aad5 100644
--- a/src/asammdf/gui/dialogs/window_selection_dialog.py
+++ b/src/asammdf/gui/dialogs/window_selection_dialog.py
@@ -1,5 +1,3 @@
-# -*- coding: utf-8 -*-
-
from PySide6 import QtWidgets
from ..ui import resource_rc
diff --git a/src/asammdf/gui/plot.py b/src/asammdf/gui/plot.py
index 300e5fc3d..92070f8e5 100644
--- a/src/asammdf/gui/plot.py
+++ b/src/asammdf/gui/plot.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
import logging
import os
import sys
diff --git a/src/asammdf/gui/utils.py b/src/asammdf/gui/utils.py
index e07b61ac6..564766ebd 100644
--- a/src/asammdf/gui/utils.py
+++ b/src/asammdf/gui/utils.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
import ctypes
from datetime import datetime
from functools import reduce
@@ -172,7 +171,7 @@ def excepthook(exc_type, exc_value, tracebackobj):
msg = "\n".join(sections)
print("".join(traceback.format_tb(tracebackobj)))
- print("{0}: {1}".format(exc_type, exc_value))
+ print(f"{exc_type}: {exc_value}")
ErrorDialog(message=errmsg, trace=msg, title="The following error was triggered").exec_()
diff --git a/src/asammdf/gui/widgets/attachment.py b/src/asammdf/gui/widgets/attachment.py
index 043be4fd1..416f940ff 100644
--- a/src/asammdf/gui/widgets/attachment.py
+++ b/src/asammdf/gui/widgets/attachment.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from pathlib import Path
from PySide6 import QtWidgets
diff --git a/src/asammdf/gui/widgets/bar.py b/src/asammdf/gui/widgets/bar.py
index 1d6e92751..aa1c26231 100644
--- a/src/asammdf/gui/widgets/bar.py
+++ b/src/asammdf/gui/widgets/bar.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
import os
import re
diff --git a/src/asammdf/gui/widgets/batch.py b/src/asammdf/gui/widgets/batch.py
index 41e86b4f1..3525363c3 100644
--- a/src/asammdf/gui/widgets/batch.py
+++ b/src/asammdf/gui/widgets/batch.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from datetime import datetime, timedelta, timezone
import json
import os
diff --git a/src/asammdf/gui/widgets/bus_database_manager.py b/src/asammdf/gui/widgets/bus_database_manager.py
index 6cdc5832c..60d58e4e1 100644
--- a/src/asammdf/gui/widgets/bus_database_manager.py
+++ b/src/asammdf/gui/widgets/bus_database_manager.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from pathlib import Path
from PySide6 import QtCore, QtWidgets
diff --git a/src/asammdf/gui/widgets/can_bus_trace.py b/src/asammdf/gui/widgets/can_bus_trace.py
index fbeb030e8..7e210866e 100644
--- a/src/asammdf/gui/widgets/can_bus_trace.py
+++ b/src/asammdf/gui/widgets/can_bus_trace.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
import datetime
import logging
diff --git a/src/asammdf/gui/widgets/channel_bar_display.py b/src/asammdf/gui/widgets/channel_bar_display.py
index 18d99ca7c..09ed07d25 100644
--- a/src/asammdf/gui/widgets/channel_bar_display.py
+++ b/src/asammdf/gui/widgets/channel_bar_display.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
import json
import math
@@ -59,8 +58,8 @@ def drawWidget(self, qp):
w = size.width()
h = size.height()
- till = int(((w / self.max) * self.value))
- full = int(((w / self.max) * self.over))
+ till = int((w / self.max) * self.value)
+ full = int((w / self.max) * self.over)
if self.value >= self.over:
qp.setPen(QtGui.QColor(self.color))
diff --git a/src/asammdf/gui/widgets/channel_group_info.py b/src/asammdf/gui/widgets/channel_group_info.py
index d89e3d018..494e45296 100644
--- a/src/asammdf/gui/widgets/channel_group_info.py
+++ b/src/asammdf/gui/widgets/channel_group_info.py
@@ -1,5 +1,3 @@
-# -*- coding: utf-8 -*-
-
import numpy as np
import pandas as pd
from PySide6 import QtCore, QtGui, QtWidgets
diff --git a/src/asammdf/gui/widgets/channel_info.py b/src/asammdf/gui/widgets/channel_info.py
index df531d5c5..5a1943fd2 100644
--- a/src/asammdf/gui/widgets/channel_info.py
+++ b/src/asammdf/gui/widgets/channel_info.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from PySide6 import QtWidgets
from ..ui import resource_rc
diff --git a/src/asammdf/gui/widgets/channel_stats.py b/src/asammdf/gui/widgets/channel_stats.py
index 6561efe78..363cd1a23 100644
--- a/src/asammdf/gui/widgets/channel_stats.py
+++ b/src/asammdf/gui/widgets/channel_stats.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from copy import deepcopy
import numpy as np
diff --git a/src/asammdf/gui/widgets/collapsiblebox.py b/src/asammdf/gui/widgets/collapsiblebox.py
index b274e8f2e..2d8ba632d 100644
--- a/src/asammdf/gui/widgets/collapsiblebox.py
+++ b/src/asammdf/gui/widgets/collapsiblebox.py
@@ -1,11 +1,9 @@
-# -*- coding: utf-8 -*-
-
from PySide6 import QtCore, QtWidgets
class CollapsibleBox(QtWidgets.QWidget):
def __init__(self, title="", parent=None):
- super(CollapsibleBox, self).__init__(parent)
+ super().__init__(parent)
self.toggle_button = QtWidgets.QToolButton(text=title, checkable=True, checked=False)
self.toggle_button.setStyleSheet("QToolButton { border: none; }")
diff --git a/src/asammdf/gui/widgets/cursor.py b/src/asammdf/gui/widgets/cursor.py
index a5b3837b5..2831a7860 100644
--- a/src/asammdf/gui/widgets/cursor.py
+++ b/src/asammdf/gui/widgets/cursor.py
@@ -1,5 +1,3 @@
-# -*- coding: utf-8 -*-
-
import pyqtgraph as pg
from PySide6 import QtCore, QtGui
diff --git a/src/asammdf/gui/widgets/database_item.py b/src/asammdf/gui/widgets/database_item.py
index b40d68cd2..40a3bca98 100644
--- a/src/asammdf/gui/widgets/database_item.py
+++ b/src/asammdf/gui/widgets/database_item.py
@@ -1,5 +1,3 @@
-# -*- coding: utf-8 -*-
-
from PySide6 import QtWidgets
from ..ui.database_item import Ui_DatabaseItemUI
diff --git a/src/asammdf/gui/widgets/fft_window.py b/src/asammdf/gui/widgets/fft_window.py
index 39d3fb0e4..509addb8e 100644
--- a/src/asammdf/gui/widgets/fft_window.py
+++ b/src/asammdf/gui/widgets/fft_window.py
@@ -1,5 +1,3 @@
-# -*- coding: utf-8 -*-
-
import numpy as np
from PySide6 import QtCore, QtGui, QtWidgets
import scipy.signal as scipy_signal
diff --git a/src/asammdf/gui/widgets/file.py b/src/asammdf/gui/widgets/file.py
index 95253bbd7..1df73e059 100644
--- a/src/asammdf/gui/widgets/file.py
+++ b/src/asammdf/gui/widgets/file.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from datetime import datetime, timezone
from functools import partial
from hashlib import sha1
@@ -1071,12 +1070,12 @@ def load_channel_list(self, event=None, file_name=None, manually=False):
channels = [name.split(";")[0] for name in info[section]]
elif extension in (".cfg", ".txt"):
- with open(file_name, "r") as infile:
+ with open(file_name) as infile:
info = json.load(infile)
channels = info.get("selected_channels", [])
elif extension == ".dspf":
- with open(file_name, "r") as infile:
+ with open(file_name) as infile:
info = json.load(infile)
channels = info.get("selected_channels", [])
@@ -3118,17 +3117,12 @@ def embed_display_file(self, event=None):
)
fh_block = FileHistory()
- fh_block.comment = """
Build information:
Copyright © 2018-2023 Daniel Hrisca