Skip to content

Commit

Permalink
Apply isort
Browse files Browse the repository at this point in the history
  • Loading branch information
17o2 authored and laurierloi committed Jan 19, 2023
1 parent 3a18989 commit e6f76f9
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 34 deletions.
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
# -*- coding: utf-8 -*-

from pathlib import Path
from setuptools import setup, find_packages

from src.wireviz import __version__, CMD_NAME, APP_URL
from setuptools import find_packages, setup

from src.wireviz import APP_URL, CMD_NAME, __version__

README_PATH = Path(__file__).parent / 'docs' / 'README.md'

Expand Down
9 changes: 4 additions & 5 deletions src/wireviz/DataClasses.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# -*- coding: utf-8 -*-

from dataclasses import InitVar, dataclass, field
from enum import Enum, auto
from typing import Dict, List, Optional, Tuple, Union
from dataclasses import dataclass, field, InitVar
from pathlib import Path
from typing import Dict, List, Optional, Tuple, Union

from wireviz.wv_helper import int2tuple, aspect_ratio
from wireviz.wv_colors import Color, Colors, ColorMode, ColorScheme, COLOR_CODES

from wireviz.wv_colors import COLOR_CODES, Color, ColorMode, Colors, ColorScheme
from wireviz.wv_helper import aspect_ratio, int2tuple

# Each type alias have their legal values described in comments - validation might be implemented in the future
PlainText = str # Text not containing HTML tags nor newlines
Expand Down
60 changes: 46 additions & 14 deletions src/wireviz/Harness.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,57 @@
# -*- coding: utf-8 -*-

from graphviz import Graph
import re
from collections import Counter
from typing import Any, List, Union
from dataclasses import dataclass
from pathlib import Path
from itertools import zip_longest
import re
from pathlib import Path
from typing import Any, List, Union

from wireviz import wv_colors, __version__, APP_NAME, APP_URL
from wireviz.DataClasses import Cable, Connector, MatePin, MateComponent, Metadata, Options, Tweak, Side
from graphviz import Graph

from wireviz import APP_NAME, APP_URL, __version__, wv_colors
from wireviz.DataClasses import (
Cable,
Connector,
MateComponent,
MatePin,
Metadata,
Options,
Tweak,
Side,
)
from wireviz.wv_bom import (
HEADER_MPN,
HEADER_PN,
HEADER_SPN,
bom_list,
component_table_entry,
generate_bom,
get_additional_component_table,
pn_info_string,
)
from wireviz.wv_colors import get_color_hex, translate_color
from wireviz.wv_gv_html import nested_html_table, \
html_bgcolor_attr, html_bgcolor, html_colorbar, \
html_image, html_caption, remove_links, html_line_breaks
from wireviz.wv_bom import pn_info_string, component_table_entry, \
get_additional_component_table, bom_list, generate_bom, \
HEADER_PN, HEADER_MPN, HEADER_SPN
from wireviz.wv_gv_html import (
html_bgcolor,
html_bgcolor_attr,
html_caption,
html_colorbar,
html_image,
html_line_breaks,
nested_html_table,
remove_links,
)
from wireviz.wv_helper import (
awg_equiv,
flatten2d,
is_arrow,
mm2_equiv,
open_file_read,
open_file_write,
tuplelist2tsv,
)
from wireviz.wv_html import generate_html_output
from wireviz.wv_helper import awg_equiv, mm2_equiv, tuplelist2tsv, flatten2d, \
open_file_read, open_file_write, is_arrow


@dataclass
class Harness:
Expand Down
6 changes: 3 additions & 3 deletions src/wireviz/build_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@

import argparse
import os
from pathlib import Path
import sys
from pathlib import Path

script_path = Path(__file__).absolute()

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

from wireviz import APP_NAME, __version__, wireviz

dir = script_path.parent.parent.parent
readme = 'readme.md'
Expand Down
10 changes: 8 additions & 2 deletions src/wireviz/wireviz.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from pathlib import Path
import sys
from pathlib import Path
from typing import Any, Dict, List, Tuple

import yaml
Expand All @@ -12,7 +12,13 @@

from wireviz.DataClasses import Metadata, Options, Tweak
from wireviz.Harness import Harness
from wireviz.wv_helper import expand, get_single_key_and_value, is_arrow, open_file_read, smart_file_resolve
from wireviz.wv_helper import (
expand,
get_single_key_and_value,
is_arrow,
open_file_read,
smart_file_resolve,
)


def parse_text(yaml_str: str, file_out: (str, Path) = None, output_formats: (None, str, Tuple[str]) = ('html','png','svg','tsv'), return_types: (None, str, Tuple[str]) = None, image_paths: List = []) -> Any:
Expand Down
4 changes: 2 additions & 2 deletions src/wireviz/wv_cli.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# -*- coding: utf-8 -*-

import os
from pathlib import Path
import sys
from pathlib import Path

import click

if __name__ == '__main__':
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))

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

format_codes = {'c': 'csv', 'g': 'gv', 'h': 'html', 'p': 'png', 'P': 'pdf', 's': 'svg', 't': 'tsv'}
Expand Down
4 changes: 3 additions & 1 deletion src/wireviz/wv_gv_html.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# -*- coding: utf-8 -*-

from typing import List, Optional, Union
import re
from typing import List, Optional, Union

from wireviz.DataClasses import Color
from wireviz.wv_colors import translate_color
from wireviz.wv_helper import remove_links


def nested_html_table(rows: List[Union[str, List[Optional[str]], None]], table_attrs: str = '') -> str:
# input: list, each item may be scalar or list
# output: a parent table with one child table per parent item that is list, and one cell per parent item that is scalar
Expand Down Expand Up @@ -73,6 +74,7 @@ def html_caption(image):

def html_size_attr(image):
from wireviz.DataClasses import Image

# Return Graphviz HTML attributes to specify minimum or fixed size of a TABLE or TD object
return ((f' width="{image.width}"' if image.width else '')
+ (f' height="{image.height}"' if image.height else '')
Expand Down
4 changes: 2 additions & 2 deletions src/wireviz/wv_helper.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-

from typing import Dict, List
from pathlib import Path
import re
from pathlib import Path
from typing import Dict, List

awg_equiv_table = {
'0.09': '28',
Expand Down
12 changes: 9 additions & 3 deletions src/wireviz/wv_html.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
# -*- coding: utf-8 -*-

import re
from pathlib import Path
from typing import Dict, List, Union
import re

from wireviz import __version__, APP_NAME, APP_URL, wv_colors
from wireviz import APP_NAME, APP_URL, __version__, wv_colors
from wireviz.DataClasses import Metadata, Options
from wireviz.wv_helper import flatten2d, open_file_read, open_file_write, smart_file_resolve
from wireviz.wv_gv_html import html_line_breaks
from wireviz.wv_helper import (
flatten2d,
open_file_read,
open_file_write,
smart_file_resolve,
)


def generate_html_output(filename: Union[str, Path], bom_list: List[List[str]], metadata: Metadata, options: Options):

Expand Down

0 comments on commit e6f76f9

Please sign in to comment.