Skip to content

Commit

Permalink
more formatting changes to increase pylint score
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobdbrown4 committed Aug 30, 2023
1 parent 93efbf3 commit f1d2692
Show file tree
Hide file tree
Showing 16 changed files with 57 additions and 272 deletions.
19 changes: 9 additions & 10 deletions spydrnet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import pkgutil
import sys
from pathlib import Path
import requests

# ===================
# Setup Logging
Expand Down Expand Up @@ -141,9 +142,6 @@ def determine_example_netlists_path(download_option):
response = input()
if response == "y":
print("Downloading example netlists...")

import requests

url = (
"https://github.com/byuccl/spydrnet/archive/refs/heads/next_release.zip"
)
Expand Down Expand Up @@ -200,19 +198,20 @@ def get_example_netlist_names(path):
get_example_netlist_names(example_netlists_path)


def load_example_netlist_by_name(name, format=EDIF):
def load_example_netlist_by_name(name, netlist_format=EDIF):
example_netlists_path = determine_example_netlists_path(True)
get_example_netlist_names(example_netlists_path)
error_message = "Example netlist not found. Either run 'export EXAMPLE_NETLISTS_PATH=<path>' or allow downloading to /tmp/spydrnet_example_netlists."
if format is EDIF:
if netlist_format is EDIF:
assert name in example_netlist_names, error_message
return parse(Path(example_netlists_path, "EDIF_netlists", name + ".edf.zip"))
elif format is VERILOG:
if netlist_format is VERILOG:
assert name in verilog_example_netlist_names, error_message
return parse(Path(example_netlists_path, "verilog_netlists", name + ".v.zip"))
elif format is EBLIF:
if netlist_format is EBLIF:
assert name in eblif_example_netlist_names, error_message
return parse(Path(example_netlists_path, "eblif_netlists", name + ".eblif.zip"))
else: # if no version is recognized, default to edif
assert name in example_netlist_names, error_message
return parse(Path(example_netlists_path, "EDIF_netlists", name + ".edf.zip"))

# if no version is recognized, default to edif
assert name in example_netlist_names, error_message
return parse(Path(example_netlists_path, "EDIF_netlists", name + ".edf.zip"))
3 changes: 0 additions & 3 deletions spydrnet/clone.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from spydrnet import ir
from copy import deepcopy, copy, error

"""provide the clone function for spydrnet."""


Expand Down
26 changes: 13 additions & 13 deletions spydrnet/compare/compare_netlists.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ def compare(self):
# except Exception:
# import pdb; pdb.set_trace()
for orig_library in self.ir_orig.libraries:
if orig_library.name == None:
if orig_library.name is None:
# ports with no name are not compared
print("WARNING: library with name == None exists and is not compared")
print("WARNING: library with name is None exists and is not compared")
continue
else:
patterns = orig_library.name
Expand Down Expand Up @@ -66,10 +66,10 @@ def compare_libraries(self, library_orig, library_composer):
# except Exception:
# import pdb; pdb.set_trace()
for orig_definition in library_orig.definitions:
if orig_definition.name == None:
if orig_definition.name is None:
# ports with no name are not compared
print(
"WARNING: definitions with name == None exist but are not compared"
"WARNING: definitions with name is None exist but are not compared"
)
continue
else:
Expand Down Expand Up @@ -97,9 +97,9 @@ def compare_definition(
# self.compare_ports(orig_port, composer_port)
# do a smarter compare
for orig_port in definition_orig.ports:
if orig_port.name == None:
if orig_port.name is None:
# ports with no name are not compared
print("WARNING: ports with name == None exist and are not compared")
print("WARNING: ports with name is None exist and are not compared")
continue
else:
patterns = orig_port.name
Expand All @@ -118,9 +118,9 @@ def compare_definition(
)

for orig_cable in definition_orig.cables:
if orig_cable.name == None:
if orig_cable.name is None:
# ports with no name are not compared
print("WARNING: cables with name == None exist and are not compared")
print("WARNING: cables with name is None exist and are not compared")
continue
else:
patterns = orig_cable.name
Expand All @@ -133,9 +133,9 @@ def compare_definition(
# for orig_instance, composer_cable in zip(definition_orig.children, definition_composer.children):
# self.compare_instances(orig_instance, composer_cable)
for orig_instance in definition_orig.children:
if orig_instance.name == None:
if orig_instance.name is None:
# ports with no name are not compared
print("WARNING: children with name == None exist and are not compared")
print("WARNING: children with name is None exist and are not compared")
continue
else:
if orig_instance.name.startswith("SDN_Assignment_"):
Expand Down Expand Up @@ -349,7 +349,7 @@ def compare_instances(self, instances_orig, instances_composer):
)

assert (
instances_orig.reference == None and instances_composer.reference == None
instances_orig.reference is None and instances_composer.reference is None
) or (
self.get_identifier(instances_orig.reference)
== self.get_identifier(instances_composer.reference)
Expand All @@ -371,15 +371,15 @@ def compare_instances(self, instances_orig, instances_composer):

@staticmethod
def get_identifier(obj):
if obj == None:
if obj is None:
return None
return obj.name
# if "EDIF.identifier" in obj:
# return obj["EDIF.identifier"]

@staticmethod
def get_original_identifier(obj):
if obj == None:
if obj is None:
return None
if "EDIF.original_identifier" in obj:
return obj["EDIF.original_identifier"]
1 change: 0 additions & 1 deletion spydrnet/composers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
def compose(
netlist,
filename,
voters=[],
definition_list=[],
write_blackbox=True,
write_eblif_cname=True,
Expand Down
3 changes: 1 addition & 2 deletions spydrnet/flatten.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# Copyright 2020 Dallin Skouson, Andrew Keller, Michael Wirthlin

from spydrnet.ir import *
from collections import deque
from spydrnet.uniquify import uniquify
from spydrnet.ir import *

"""How to flatten (brainstorm):
start at the top and take all of the subelements out and add them to the top definition
Expand Down
2 changes: 1 addition & 1 deletion spydrnet/ir/cable.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from copy import deepcopy
from spydrnet.ir import Bundle
from spydrnet.ir import Wire
from spydrnet.ir.views.listview import ListView
from spydrnet.global_state import global_callback
from spydrnet.global_state.global_callback import _call_create_cable
from copy import deepcopy, copy, error


class Cable(Bundle):
Expand Down
2 changes: 1 addition & 1 deletion spydrnet/ir/definition.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from copy import copy, deepcopy, error
from copy import copy, deepcopy

from spydrnet.global_state import global_callback
from spydrnet.global_state.global_callback import _call_create_definition
Expand Down
12 changes: 5 additions & 7 deletions spydrnet/parsers/eblif/eblif_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ def __init__(self):
self.work = None
self.blackbox_holder = self.BlackboxHolder()

def createTokenizer(self):
def create_tokenizer(self):
self.tokenizer = Tokenizer(self.file_name)

#######################################################
# parse functions
#######################################################
def parse(self):
self.createTokenizer()
self.create_tokenizer()
self.parse_eblif()
return self.netlist

Expand All @@ -95,8 +95,7 @@ def parse_eblif(self):
self.parse_comment()
elif token == et.MODEL:
self.parse_model()
else:
None

self.set_subcircuit_names_by_convention()
self.insert_comments_into_netlist_data()
self.add_blackbox_definitions()
Expand Down Expand Up @@ -129,8 +128,7 @@ def parse_model_helper(self, model_name):
is_blackbox = True
elif token == et.END:
break
else:
None

if is_blackbox:
self.primitives.add_definition(model)
else:
Expand Down Expand Up @@ -295,7 +293,7 @@ def connect_instance_pins(self, instance):
# cable_info = self.current_instance_info[key]
cable_name, cable_index = self.get_port_name_and_index(cable_info) # get connected cable name and wire index
port_name, pin_index = self.get_port_name_and_index(key) # get own port name and pin index
if (cable_name == et.UNCONN): # intentionally disconnected so put that into metadata
if cable_name == et.UNCONN: # intentionally disconnected so put that into metadata
try:
instance[et.UNCONN]
except KeyError:
Expand Down
8 changes: 3 additions & 5 deletions spydrnet/parsers/eblif/eblif_tokenizer.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import io
import re
import zipfile
import io
from spydrnet.parsers.eblif.eblif_tokens import BACKSLASH
from pathlib import Path
from spydrnet.parsers.eblif.eblif_tokens import BACKSLASH


class Tokenizer:
Expand Down Expand Up @@ -31,10 +29,10 @@ def __init__(self, input_source):
self.current_line_tokens = []
if isinstance(input_source, str):
if zipfile.is_zipfile(input_source):
zip = zipfile.ZipFile(input_source)
zipped = zipfile.ZipFile(input_source)
filename = Path(input_source).name
filename = filename[: filename.rindex(".")]
stream = zip.open(filename)
stream = zipped.open(filename)
stream = io.TextIOWrapper(stream)
self.input_stream = stream
else:
Expand Down
17 changes: 8 additions & 9 deletions spydrnet/parsers/edif/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -926,18 +926,17 @@ def parse_property_like_element(self):
def parse_typedValue(self):
if self.construct_is(BOOLEAN):
return self.parse_boolean()
elif self.construct_is(INTEGER):
if self.construct_is(INTEGER):
return self.parse_integer()
elif self.construct_is(MI_NO_MAX):
if self.construct_is(MI_NO_MAX):
raise NotImplementedError()
elif self.construct_is(NUMBER):
if self.construct_is(NUMBER):
return self.parse_number()
elif self.construct_is(POINT):
if self.construct_is(POINT):
raise NotImplementedError()
elif self.construct_is(STRING):
if self.construct_is(STRING):
return self.parse_string()
else:
return self.expect("|".join([BOOLEAN, INTEGER, NUMBER, STRING]))
return self.expect("|".join([BOOLEAN, INTEGER, NUMBER, STRING]))

def parse_boolean(self):
self.expect(BOOLEAN)
Expand Down Expand Up @@ -1005,7 +1004,7 @@ def multibit_add_cable(self, definition, cable):
n_index, n_short = self.separate_name_and_index(c_name, "[")

index = n_index
if e_index == None:
if e_index is None:
index = None

existing_cable = next(definition.get_cables(n_short), None)
Expand All @@ -1026,7 +1025,7 @@ def multibit_add_cable(self, definition, cable):
definition.add_cable(cable)

else: # there is alread a cable that could need to be merged.
if existing_cable.is_array == False or index == None:
if existing_cable.is_array is False or index is None:
definition.add_cable(cable) # if this works great. otherwise the parent code will handle the error
else: # the cables should be merged
if index > existing_cable.lower_index:
Expand Down
1 change: 0 additions & 1 deletion spydrnet/parsers/primitive_library_reader.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import spydrnet as sdn
from spydrnet.ir import Library
from spydrnet.parsers.verilog.parser import VerilogParser
import spydrnet.parsers.verilog.verilog_tokens as vt
Expand Down
Loading

0 comments on commit f1d2692

Please sign in to comment.