Skip to content

Commit

Permalink
Don't escape strings and fix import blocks (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
koenvervloesem committed Apr 25, 2023
1 parent 2a3c4c8 commit 7ba81ad
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 14 deletions.
5 changes: 1 addition & 4 deletions scripts/generate_modules.py
Expand Up @@ -17,7 +17,7 @@
OUI_RE = re.compile(r"^([0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2})\s*\(hex\)\s+(.*)\s*$")

file_loader = FileSystemLoader(TEMPLATE_DIR)
env = Environment(loader=file_loader, autoescape=True)
env = Environment(loader=file_loader, autoescape=False) # noqa: S701


def generate_uuid16_dictionary(kind: str) -> dict[int, str]:
Expand Down Expand Up @@ -81,7 +81,6 @@ def generate_uuid_module(
"""
template = env.get_template(UUID_TEMPLATE)
with (Path(CODE_DIR) / f"_{kind}s.py").open("w") as python_file:
python_file.write("# pylint: skip-file\n")
python_file.write(
template.render(uuids16=uuid16_dict, uuids128=uuid128_dict, uuid_dict=kind),
)
Expand Down Expand Up @@ -114,7 +113,6 @@ def generate_cic_module(cic_dict: dict[str, str]) -> None:
"""
template = env.get_template(CIC_TEMPLATE)
with (Path(CODE_DIR) / "_companies.py").open("w") as python_file:
python_file.write("# pylint: skip-file\n")
python_file.write(template.render(cics=cic_dict))


Expand Down Expand Up @@ -144,7 +142,6 @@ def generate_oui_module(oui_dict: dict[str, str]) -> None:
"""
template = env.get_template(OUI_TEMPLATE)
with (Path(CODE_DIR) / "_ouis.py").open("w") as python_file:
python_file.write("# pylint: skip-file\n")
python_file.write(template.render(ouis=oui_dict))


Expand Down
2 changes: 0 additions & 2 deletions src/bluetooth_numbers/_characteristics.py
@@ -1,4 +1,3 @@
# pylint: skip-file
"""Module with UUIDs and names for Bluetooth characteristics.
Usage:
Expand All @@ -10,7 +9,6 @@
>>> characteristic[UUID("6E400002-B5A3-F393-E0A9-E50E24DCCA9E")]
'UART RX Characteristic'
"""
# pylint: skip-file
from uuid import UUID

from bluetooth_numbers.dicts import UUIDDict
Expand Down
1 change: 0 additions & 1 deletion src/bluetooth_numbers/_companies.py
@@ -1,4 +1,3 @@
# pylint: skip-file
"""Module with Bluetooth company IDs and their names.
Usage:
Expand Down
2 changes: 0 additions & 2 deletions src/bluetooth_numbers/_descriptors.py
@@ -1,4 +1,3 @@
# pylint: skip-file
"""Module with UUIDs and names for Bluetooth descriptors.
Usage:
Expand All @@ -7,7 +6,6 @@
>>> descriptor[0x2901]
'Characteristic User Descriptor'
"""
# pylint: skip-file

from bluetooth_numbers.dicts import UUIDDict

Expand Down
1 change: 0 additions & 1 deletion src/bluetooth_numbers/_ouis.py
@@ -1,4 +1,3 @@
# pylint: skip-file
"""Module with OUIs for Bluetooth addresses.

Usage:
Expand Down
2 changes: 0 additions & 2 deletions src/bluetooth_numbers/_services.py
@@ -1,4 +1,3 @@
# pylint: skip-file
"""Module with UUIDs and names for Bluetooth services.
Usage:
Expand All @@ -10,7 +9,6 @@
>>> service[UUID("6E400001-B5A3-F393-E0A9-E50E24DCCA9E")]
'Nordic UART Service'
"""
# pylint: skip-file
from uuid import UUID

from bluetooth_numbers.dicts import UUIDDict
Expand Down
4 changes: 2 additions & 2 deletions templates/uuids.py.jinja
Expand Up @@ -16,8 +16,8 @@ Usage:
>>> descriptor[0x2901]
'Characteristic User Descriptor'{% endif %}
"""
# pylint: skip-file
{% if uuids128|length > 1 %}from uuid import UUID{% endif %}
{% if uuids128|length > 1 %}from uuid import UUID
{% endif %}
from bluetooth_numbers.dicts import UUIDDict
{{ uuid_dict }} = UUIDDict({ {% for uuid, name in uuids16.items() %}
0x{{ uuid }}: "{{ name }}",
Expand Down

0 comments on commit 7ba81ad

Please sign in to comment.