From 5a4d30e162d0e485aa4a80439ffaec88882bd117 Mon Sep 17 00:00:00 2001 From: LordBaryhobal Date: Sun, 24 Mar 2024 11:33:34 +0100 Subject: [PATCH] reogranized imports --- .gitignore | 3 ++- config.py | 1 + main.py | 2 ++ range.py | 2 ++ renderer.py | 14 ++++++++------ schema.py | 3 +++ structure.py | 2 ++ vec.py | 2 ++ xml_loader.py | 4 +++- 9 files changed, 25 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index a5c8c0a..f4ed3dd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ __pycache__ -*.jpg \ No newline at end of file +*.jpg +*.png \ No newline at end of file diff --git a/config.py b/config.py index aba5f2b..84ae2a4 100644 --- a/config.py +++ b/config.py @@ -1,6 +1,7 @@ import json import re + class Config: DEFAULT_FONT_FAMILY = "Ubuntu Mono" DEFAULT_FONT_SIZE = 16 diff --git a/main.py b/main.py index 11c0793..144b2db 100644 --- a/main.py +++ b/main.py @@ -3,6 +3,7 @@ import os from schema import InstructionSetSchema + description = """Examples: - Default theme (black on white): python main.py schema.xml -o out.jpg @@ -17,6 +18,7 @@ description = """Examples: python main.py schema.xml -o out.png -c transparent.json """ + if __name__ == "__main__": parser = argparse.ArgumentParser(description=description, formatter_class=argparse.RawTextHelpFormatter) parser.add_argument("schema", help="Path to the schema description. Accepted formats are: YAML, JSON and XML") diff --git a/range.py b/range.py index fe4b6c4..b25c961 100644 --- a/range.py +++ b/range.py @@ -1,6 +1,8 @@ from __future__ import annotations + from typing import Union + class Range: def __init__(self, start: int, diff --git a/renderer.py b/renderer.py index bac28cc..d755d5a 100644 --- a/renderer.py +++ b/renderer.py @@ -1,16 +1,19 @@ from __future__ import annotations + import os from typing import TYPE_CHECKING -if TYPE_CHECKING: - from config import Config - from range import Range - from schema import InstructionSetSchema import pygame from structure import Structure from vec import Vec +if TYPE_CHECKING: + from config import Config + from range import Range + from schema import InstructionSetSchema + + class Renderer: WIDTH = 1200 HEIGHT = 800 @@ -45,8 +48,7 @@ class Renderer: def drawStructure(self, struct: Structure, - structures: dict[str, - Structure], + structures: dict[str, Structure], ox: float = 0, oy: float = 0) -> float: diff --git a/schema.py b/schema.py index 798eaf8..54ba976 100644 --- a/schema.py +++ b/schema.py @@ -1,5 +1,6 @@ import json import os + import yaml from config import Config @@ -7,9 +8,11 @@ from renderer import Renderer from structure import Structure from xml_loader import XMLLoader + class UnsupportedFormatException(Exception): ... + class InstructionSetSchema: VALID_EXTENSIONS = ("yaml", "json", "xml") diff --git a/structure.py b/structure.py index 96623b0..1bed8a4 100644 --- a/structure.py +++ b/structure.py @@ -1,6 +1,8 @@ from __future__ import annotations + from range import Range + class Structure: def __init__(self, name: str, diff --git a/vec.py b/vec.py index 8b69f3a..6cedfaf 100644 --- a/vec.py +++ b/vec.py @@ -1,6 +1,8 @@ from __future__ import annotations + from math import sqrt + class Vec: def __init__(self, x: float = 0, y: float = 0) -> None: self.x = x diff --git a/xml_loader.py b/xml_loader.py index 04a0283..e15920e 100644 --- a/xml_loader.py +++ b/xml_loader.py @@ -1,7 +1,9 @@ from __future__ import annotations -from bs4 import BeautifulSoup + from typing import TYPE_CHECKING +from bs4 import BeautifulSoup + if TYPE_CHECKING: from io import TextIOWrapper