Skip to content

Commit

Permalink
Rename modules, adjust imports, move build_examples.py
Browse files Browse the repository at this point in the history
  • Loading branch information
formatc1702 committed Oct 22, 2021
1 parent 6c84db7 commit b3fd091
Show file tree
Hide file tree
Showing 14 changed files with 315 additions and 327 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ jobs:
python -m pip install --upgrade pip
pip install .
- name: Create Examples
run: PYTHONPATH=$(pwd)/src:$PYTHONPATH cd src/wireviz/ && python build_examples.py
run: PYTHONPATH=$(pwd)/src:$PYTHONPATH && python src/wireviz/tools/build_examples.py
- name: Upload examples, demos, and tutorials
uses: actions/upload-artifact@v2
with:
name: examples-and-tutorials
path: |
examples/
tutorial/
tutorial/
File renamed without changes.
52 changes: 0 additions & 52 deletions src/wireviz/svgembed.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@
from pathlib import Path

script_path = Path(__file__).absolute()

sys.path.insert(0, str(script_path.parent.parent)) # to find wireviz module
from wv_helper import open_file_append, open_file_read, open_file_write
sys.path.insert(0, str(script_path.parent.parent.parent)) # to find wireviz module

from wireviz import APP_NAME, __version__, wireviz
from wireviz.wv_utils import open_file_append, open_file_read, open_file_write

dir = script_path.parent.parent.parent
dir = script_path.parent.parent.parent.parent
readme = "readme.md"
groups = {
"examples": {
Expand Down
19 changes: 6 additions & 13 deletions src/wireviz/wireviz.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
if __name__ == "__main__":
sys.path.insert(0, str(Path(__file__).parent.parent)) # add src/wireviz to PATH

from wireviz.DataClasses import AUTOGENERATED_PREFIX, Metadata, Options, Tweak
from wireviz.Harness import Harness
from wireviz.wv_helper import (
from wireviz.wv_dataclasses import AUTOGENERATED_PREFIX, Metadata, Options, Tweak
from wireviz.wv_harness import Harness
from wireviz.wv_utils import (
expand,
get_single_key_and_value,
is_arrow,
Expand Down Expand Up @@ -396,19 +396,12 @@ def alternate_type(): # flip between connector and cable/arrow
def _get_yaml_data_and_path(inp: Union[str, Path, Dict]) -> (Dict, Path):
# determine whether inp is a file path, a YAML string, or a Dict
if not isinstance(inp, Dict): # received a str or a Path
try:
if isinstance(inp, Path) or (isinstance(inp, str) and not "\n" in inp):
yaml_path = Path(inp).expanduser().resolve(strict=True)
# if no FileNotFoundError exception happens, get file contents
yaml_str = open_file_read(yaml_path).read()
except (FileNotFoundError, OSError) as e:
# if inp is a long YAML string, Pathlib will raise OSError: [Errno 63]
# when trying to expand and resolve it as a path.
# Catch this error, but raise any others
if type(e) is OSError and e.errno != 63:
raise e
# file does not exist; assume inp is a YAML string
yaml_str = inp
else:
yaml_path = None
yaml_str = inp
yaml_data = yaml.safe_load(yaml_str)
else:
# received a Dict, use as-is
Expand Down
2 changes: 1 addition & 1 deletion src/wireviz/wv_bom.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from enum import Enum
from typing import List, Optional, Union

from wireviz.wv_helper import html_line_breaks
from wireviz.wv_utils import html_line_breaks

BOM_HASH_FIELDS = "description unit partnumbers"
BomHash = namedtuple("BomHash", BOM_HASH_FIELDS)
Expand Down
5 changes: 3 additions & 2 deletions src/wireviz/wv_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import wireviz.wireviz as wv
from wireviz import APP_NAME, __version__
from wireviz.wv_helper import open_file_read
from wireviz.wv_utils import open_file_read

format_codes = {
"c": "csv",
Expand All @@ -23,10 +23,11 @@
"t": "tsv",
}


epilog = (
"The -f or --format option accepts a string containing one or more of the "
"following characters to specify which file types to output:\n"
f", ".join([f"{key} ({value.upper()})" for key, value in format_codes.items()])
+ f", ".join([f"{key} ({value.upper()})" for key, value in format_codes.items()])
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
SingleColor,
get_color_by_colorcode_index,
)
from wireviz.wv_helper import aspect_ratio, awg_equiv, mm2_equiv, remove_links
from wireviz.wv_utils import aspect_ratio, awg_equiv, mm2_equiv, remove_links

# Each type alias have their legal values described in comments
# - validation might be implemented in the future
Expand Down
8 changes: 4 additions & 4 deletions src/wireviz/wv_gv_html.py → src/wireviz/wv_graphviz.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
from typing import Any, List, Union

from wireviz import APP_NAME, APP_URL, __version__
from wireviz.DataClasses import (
from wireviz.wv_bom import partnumbers_to_list
from wireviz.wv_dataclasses import (
ArrowDirection,
ArrowWeight,
Cable,
Expand All @@ -18,9 +19,8 @@
ShieldClass,
WireClass,
)
from wireviz.wv_bom import partnumbers_to_list
from wireviz.wv_helper import html_line_breaks, remove_links
from wireviz.wv_table_util import * # TODO: explicitly import each needed tag later
from wireviz.wv_html import Img, Table, Td, Tr
from wireviz.wv_utils import html_line_breaks, remove_links


def gv_node_component(component: Component) -> Table:
Expand Down
9 changes: 4 additions & 5 deletions src/wireviz/Harness.py → src/wireviz/wv_harness.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from graphviz import Graph

import wireviz.wv_colors
from wireviz.DataClasses import (
from wireviz.wv_dataclasses import (
AUTOGENERATED_PREFIX,
AdditionalComponent,
Arrow,
Expand All @@ -23,8 +23,7 @@
Side,
Tweak,
)
from wireviz.svgembed import embed_svg_images_file
from wireviz.wv_gv_html import (
from wireviz.wv_graphviz import (
apply_dot_tweaks,
calculate_node_bgcolor,
gv_connector_loops,
Expand All @@ -34,8 +33,8 @@
parse_arrow_str,
set_dot_basics,
)
from wireviz.wv_helper import open_file_write, tuplelist2tsv
from wireviz.wv_html import generate_html_output
from wireviz.wv_output import embed_svg_images_file, generate_html_output
from wireviz.wv_utils import open_file_write, tuplelist2tsv


@dataclass
Expand Down
Loading

0 comments on commit b3fd091

Please sign in to comment.