[dvsim] PEP8 fixes in dvsim
These should cause no functional change. Detailed list of code changes:
- Get rid of 'import *': this defeats static analysis tools. Don't
do it.
- Add newline after colon in "if foo: bar"
- Use 'is' to check for equality with boolean literals
- Don't catch exceptions when running os.system in Deploy.py: the
os.system function returns the program's exit code.
- Delete some variables that are written but not read.
- Minor whitespace changes (missing blank lines between functions;
weird indentation; missing space after '#')
- Delete autogenerated module docstrings (they didn't contain any
information. Maybe it would be good to have a docstring, but at
the moment it's just noise).
- Don't use \ as a line continuation character. Use parentheses if
necessary.
- Replace code like "foo" + \ "bar" with just "foo" "bar" (Python
concatenates adjacent string literals just like C). (I didn't do
this everywhere, but it happened a lot next to the backslash
continuations, so I got rid of the unnecessary '+' then).
- Replace "not foo in bar" with "foo not in bar"
- Use raw strings for regexes with backslashes (r'a\+', not 'a\+')
With these changes, you can run:
find util/dvsim -name '*.py' | xargs flake8
and see no errors.
Signed-off-by: Rupert Swarbrick <rswarbrick@lowrisc.org>
diff --git a/util/dvsim/SynCfg.py b/util/dvsim/SynCfg.py
index 7479fd6..a901a4d 100644
--- a/util/dvsim/SynCfg.py
+++ b/util/dvsim/SynCfg.py
@@ -6,15 +6,13 @@
"""
import logging as log
-import sys
from pathlib import Path
+import hjson
from tabulate import tabulate
-from Deploy import *
-from Modes import *
from OneShotCfg import OneShotCfg
-from utils import *
+from utils import subst_wildcards
class SynCfg(OneShotCfg):
@@ -243,7 +241,8 @@
# go through submodules
for name in self.result["area"]["instances"].keys():
- if name == self.result["top"]: continue
+ if name == self.result["top"]:
+ continue
row = [name]
for field in ["comb", "buf", "reg", "macro", "total"]:
row += [
@@ -329,11 +328,11 @@
total_power = sum(power)
- row = [_create_entry(power[0], 1.0E-3) + " / " + \
+ row = [_create_entry(power[0], 1.0E-3) + " / " +
_create_entry(power[0], 1.0E-3, total_power),
- _create_entry(power[1], 1.0E-3) + " / " + \
+ _create_entry(power[1], 1.0E-3) + " / " +
_create_entry(power[1], 1.0E-3, total_power),
- _create_entry(power[2], 1.0E-3) + " / " + \
+ _create_entry(power[2], 1.0E-3) + " / " +
_create_entry(power[2], 1.0E-3, total_power),
_create_entry(total_power, 1.0E-3)]