Skip to content

Commit

Permalink
Fix Imports
Browse files Browse the repository at this point in the history
  • Loading branch information
salkinium committed Nov 16, 2024
1 parent 82a430c commit 72c81e5
Show file tree
Hide file tree
Showing 28 changed files with 208 additions and 45 deletions.
44 changes: 31 additions & 13 deletions src/modm_data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,37 @@
__version__ = "0.0.1"


from . import cubehal
from . import cubemx
from . import cube2owl
from . import dl
from . import header2svd
from . import html
from . import html2owl
from . import html2svd
from . import owl
from . import pdf
from . import pdf2html
from . import svd
from . import utils
from . import (
cubehal,
cubemx,
cube2owl,
dl,
header2svd,
html,
html2owl,
html2svd,
owl,
pdf,
pdf2html,
svd,
utils,
)

__all__ = (
"cubehal",
"cubemx",
"cube2owl",
"dl",
"header2svd",
"html",
"html2owl",
"html2svd",
"owl",
"pdf",
"pdf2html",
"svd",
"utils",
)

# Silence warnings about path import order when calling modules directly
import sys
Expand Down
2 changes: 1 addition & 1 deletion src/modm_data/cube2owl/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from modm_data.header2svd.stmicro import Header
from modm_data.html.stmicro import datasheet_for_device, reference_manual_for_device
from modm_data.owl.stmicro import create_ontology
from modm_data.py2owl.stmicro import *
from modm_data.py2owl.stmicro import owl_from_did, owl_from_cubemx, owl_from_header, owl_from_doc


def main():
Expand Down
2 changes: 2 additions & 0 deletions src/modm_data/cubehal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@
"""

from .dmamux_requests import read_request_map

__all__ = ["read_request_map"]
8 changes: 6 additions & 2 deletions src/modm_data/cubemx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@

"""
# STMicro STM32CubeMX Database
"""

from .device_data import devices_from_prefix, devices_from_partname, cubemx_device_list

__all__ = [
"devices_from_prefix",
"devices_from_partname",
"cubemx_device_list",
]
2 changes: 2 additions & 0 deletions src/modm_data/dl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
# SPDX-License-Identifier: MPL-2.0

from . import stmicro

__all__ = ["stmicro"]
14 changes: 10 additions & 4 deletions src/modm_data/dl/stmicro/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
# Copyright 2022, Niklas Hauser
# SPDX-License-Identifier: MPL-2.0

from .document import Document
from .document import load_remote_info, load_local_info
from .document import store_remote_info, store_local_info

from .document import Document, load_remote_info, load_local_info, store_remote_info, store_local_info
from .cubemx import download_cubemx

__all__ = [
"Document",
"load_remote_info",
"load_local_info",
"store_remote_info",
"store_local_info",
"download_cubemx",
]
5 changes: 5 additions & 0 deletions src/modm_data/header2svd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@

from . import stmicro
from .header import Header

__all__ = [
"stmicro",
"Header",
]
7 changes: 7 additions & 0 deletions src/modm_data/header2svd/stmicro/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,11 @@
# SPDX-License-Identifier: MPL-2.0

from .header import Header, getDefineForDevice

from .tree import normalize_memory_map

__all__ = [
"Header",
"getDefineForDevice",
"normalize_memory_map",
]
2 changes: 1 addition & 1 deletion src/modm_data/header2svd/stmicro/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import logging
from anytree.search import findall, find_by_attr, findall_by_attr
from collections import defaultdict
from ...svd import *
from ...svd import Device, PeripheralType, Peripheral, Register, BitField


LOGGER = logging.getLogger(__file__)
Expand Down
13 changes: 12 additions & 1 deletion src/modm_data/html/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
# Copyright 2022, Niklas Hauser
# SPDX-License-Identifier: MPL-2.0

from . import stmicro
from .document import Document
from .chapter import Chapter
from .table import Table
from .text import Text, Heading, replace, listify
from .list import List

from . import stmicro
__all__ = [
"stmicro",
"Document",
"Chapter",
"Table",
"Text",
"Heading",
"replace",
"listify",
"List",
]
14 changes: 12 additions & 2 deletions src/modm_data/html/stmicro/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@
from .datasheet_sensor import DatasheetSensor
from .datasheet_stm32 import DatasheetStm32
from .reference import ReferenceManual
from .document import load_documents, load_document_devices
from .document import datasheet_for_device, reference_manual_for_device
from .document import load_documents, load_document_devices, datasheet_for_device, reference_manual_for_device
from .helper import find_device_filter

__all__ = [
"DatasheetSensor",
"DatasheetStm32",
"ReferenceManual",
"load_documents",
"load_document_devices",
"datasheet_for_device",
"reference_manual_for_device",
"find_device_filter",
]
4 changes: 2 additions & 2 deletions src/modm_data/html/stmicro/datasheet_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
from functools import cache


import modm_data.html as html
from ..document import Document


class DatasheetSensor(html.Document):
class DatasheetSensor(Document):
def __init__(self, path: str):
super().__init__(path)

Expand Down
20 changes: 10 additions & 10 deletions src/modm_data/html/stmicro/datasheet_stm32.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
from collections import defaultdict

from .helper import split_device_filter, split_package
from ...html.text import ReDict
from ...html.text import ReDict, listify as html_listify, replace as html
from ...owl import DeviceIdentifier
from ...owl.stmicro import did_from_string
import modm_data.html as html
from ..document import Document


class DatasheetStm32(html.Document):
class DatasheetStm32(Document):
def __init__(self, path: str):
super().__init__(path)
self._id = {}
Expand Down Expand Up @@ -42,7 +42,7 @@ def devices(self) -> list[DeviceIdentifier]:
if table.domains_x("Product +summary"):
for row in table.cell_rows():
for cells in row.values():
ndevices.extend(html.listify(cells[-1].text(br=" ", sup=" ")))
ndevices.extend(html_listify(cells[-1].text(br=" ", sup=" ")))
break
else:
# print(chapter._path.relative_to(Path().cwd()))
Expand Down Expand Up @@ -107,7 +107,7 @@ def devices(self) -> list[DeviceIdentifier]:
for row in tables[0].cell_rows("code"):
for cells in row.values():
for cell in cells:
devices.extend(html.listify(cell.text()))
devices.extend(html_listify(cell.text()))

# convert to proper device identifiers
dids = set()
Expand Down Expand Up @@ -178,7 +178,7 @@ def packages(self):
if "DS13311" in self.name or "DS13312" in self.name:
ndpackage = ndpackage.replace("+SMPS", "")
if (match := re.search(r":(STM32.*?):", domain)) is not None:
devs = html.listify(match.group(1))
devs = html_listify(match.group(1))
ndpackage += "+" + "|".join(d.replace("x", ".") for d in devs)
ndpackage, *filters = ndpackage.split("+")
filters = ("+" + "+".join(filters)) if filters else ""
Expand Down Expand Up @@ -240,25 +240,25 @@ def packages_pins(self):
if ptype:
data_pin["type"] = ptype
if ptype == "I/O" and "STM32F1" not in self.device_family:
signals = html.listify(row.match_value("additional")[0].text(**add_replace))
signals = html_listify(row.match_value("additional")[0].text(**add_replace))
data_pin["additional"] = set(signals)

for domain, package_name in packages:
if ppos := html.listify(row[domain][0].text(**pos_replace)):
if ppos := html_listify(row[domain][0].text(**pos_replace)):
data_packages[package_name].append((pin_name, ppos))

# Import the alternate functions
for table in self._tables_alternate_functions:
cells = table.domains("port|pin +name").cells(r"AF(IO)?\d+")
for pin, afs in cells.items():
name = html.replace(pin.split(":")[-1], **pin_replace)
name = html_replace(pin.split(":")[-1], **pin_replace)
data_pin = data_pins[name]
if "alternate" not in data_pin:
data_pin["alternate"] = defaultdict(list)
for af, csignals in afs.items():
af = int(re.search(r"AF(IO)?(\d{1,2})", af).group(2))
for csignal in csignals:
signals = html.listify(csignal.text(**sig_replace))
signals = html_listify(csignal.text(**sig_replace))
data_pin["alternate"][af].extend(signals)

return data_packages, data_pins
2 changes: 1 addition & 1 deletion src/modm_data/html/stmicro/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import json
from collections import defaultdict
from ...html import Document
from ..document import Document
from ...utils import cache_path, ext_path
from .datasheet_stm32 import DatasheetStm32
from .datasheet_sensor import DatasheetSensor
Expand Down
3 changes: 2 additions & 1 deletion src/modm_data/html/stmicro/reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
from collections import defaultdict
import modm_data.html as html
from .helper import device_filter_from
from ..document import Document


class ReferenceManual(html.Document):
class ReferenceManual(Document):
def __init__(self, path: str):
super().__init__(path)

Expand Down
2 changes: 2 additions & 0 deletions src/modm_data/html2owl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@
"""

from . import stmicro

__all__ = ["stmicro"]
2 changes: 2 additions & 0 deletions src/modm_data/html2svd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@
"""

from . import stmicro

__all__ = ["stmicro"]
5 changes: 5 additions & 0 deletions src/modm_data/html2svd/stmicro/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@

from .reference import memory_map_from_reference_manual
from .datasheet import memory_map_from_datasheet

__all__ = [
"memory_map_from_reference_manual",
"memory_map_from_datasheet",
]
6 changes: 6 additions & 0 deletions src/modm_data/owl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@
from .store import Store
from .identifier import DeviceIdentifier
from . import stmicro

__all__ = [
"stmicro",
"Store",
"DeviceIdentifier",
]
24 changes: 23 additions & 1 deletion src/modm_data/owl/stmicro/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,26 @@
from .device import owls, owl_devices, owl_device, load_owl_device
from .identifier import did_from_string
from .ontology import create_ontology
from .model import *
from .model import (
owl_from_datasheet,
owl_from_reference_manual,
owl_from_doc,
owl_from_did,
owl_from_cubemx,
owl_from_header,
)

__all__ = [
"owls",
"owl_devices",
"owl_device",
"load_owl_device",
"did_from_string",
"create_ontology",
"owl_from_datasheet",
"owl_from_reference_manual",
"owl_from_doc",
"owl_from_did",
"owl_from_cubemx",
"owl_from_header",
]
11 changes: 11 additions & 0 deletions src/modm_data/pdf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,14 @@
from .path import Path
from .image import Image
from .render import render_page_pdf

__all__ = [
"Document",
"Page",
"Character",
"ObjLink",
"WebLink",
"Path",
"Image",
"render_page_pdf",
]
9 changes: 9 additions & 0 deletions src/modm_data/pdf2html/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,12 @@
from .render import render_page_pdf
from .convert import convert, patch
from .html import format_document, write_html

__all__ = [
"stmicro",
"render_page_pdf",
"convert",
"patch",
"format_document",
"write_html",
]
4 changes: 4 additions & 0 deletions src/modm_data/pdf2html/stmicro/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@


from .document import Document

__all__ = [
"Document",
]
Loading

0 comments on commit 72c81e5

Please sign in to comment.