reogranized imports

This commit is contained in:
Louis Heredero 2024-03-24 11:33:34 +01:00
parent dd2ffebca2
commit 5a4d30e162
9 changed files with 25 additions and 8 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
__pycache__ __pycache__
*.jpg *.jpg
*.png

View File

@ -1,6 +1,7 @@
import json import json
import re import re
class Config: class Config:
DEFAULT_FONT_FAMILY = "Ubuntu Mono" DEFAULT_FONT_FAMILY = "Ubuntu Mono"
DEFAULT_FONT_SIZE = 16 DEFAULT_FONT_SIZE = 16

View File

@ -3,6 +3,7 @@ import os
from schema import InstructionSetSchema from schema import InstructionSetSchema
description = """Examples: description = """Examples:
- Default theme (black on white): - Default theme (black on white):
python main.py schema.xml -o out.jpg 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 python main.py schema.xml -o out.png -c transparent.json
""" """
if __name__ == "__main__": if __name__ == "__main__":
parser = argparse.ArgumentParser(description=description, formatter_class=argparse.RawTextHelpFormatter) 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") parser.add_argument("schema", help="Path to the schema description. Accepted formats are: YAML, JSON and XML")

View File

@ -1,6 +1,8 @@
from __future__ import annotations from __future__ import annotations
from typing import Union from typing import Union
class Range: class Range:
def __init__(self, def __init__(self,
start: int, start: int,

View File

@ -1,16 +1,19 @@
from __future__ import annotations from __future__ import annotations
import os import os
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
if TYPE_CHECKING:
from config import Config
from range import Range
from schema import InstructionSetSchema
import pygame import pygame
from structure import Structure from structure import Structure
from vec import Vec from vec import Vec
if TYPE_CHECKING:
from config import Config
from range import Range
from schema import InstructionSetSchema
class Renderer: class Renderer:
WIDTH = 1200 WIDTH = 1200
HEIGHT = 800 HEIGHT = 800
@ -45,8 +48,7 @@ class Renderer:
def drawStructure(self, def drawStructure(self,
struct: Structure, struct: Structure,
structures: dict[str, structures: dict[str, Structure],
Structure],
ox: float = 0, ox: float = 0,
oy: float = 0) -> float: oy: float = 0) -> float:

View File

@ -1,5 +1,6 @@
import json import json
import os import os
import yaml import yaml
from config import Config from config import Config
@ -7,9 +8,11 @@ from renderer import Renderer
from structure import Structure from structure import Structure
from xml_loader import XMLLoader from xml_loader import XMLLoader
class UnsupportedFormatException(Exception): class UnsupportedFormatException(Exception):
... ...
class InstructionSetSchema: class InstructionSetSchema:
VALID_EXTENSIONS = ("yaml", "json", "xml") VALID_EXTENSIONS = ("yaml", "json", "xml")

View File

@ -1,6 +1,8 @@
from __future__ import annotations from __future__ import annotations
from range import Range from range import Range
class Structure: class Structure:
def __init__(self, def __init__(self,
name: str, name: str,

2
vec.py
View File

@ -1,6 +1,8 @@
from __future__ import annotations from __future__ import annotations
from math import sqrt from math import sqrt
class Vec: class Vec:
def __init__(self, x: float = 0, y: float = 0) -> None: def __init__(self, x: float = 0, y: float = 0) -> None:
self.x = x self.x = x

View File

@ -1,7 +1,9 @@
from __future__ import annotations from __future__ import annotations
from bs4 import BeautifulSoup
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from bs4 import BeautifulSoup
if TYPE_CHECKING: if TYPE_CHECKING:
from io import TextIOWrapper from io import TextIOWrapper