Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] refactor dict usage (#321) #338

Merged
merged 6 commits into from
Apr 5, 2019
Merged

[WIP] refactor dict usage (#321) #338

merged 6 commits into from
Apr 5, 2019

Conversation

ebroecker
Copy link
Owner

No description provided.

@codecov-io
Copy link

codecov-io commented Mar 29, 2019

Codecov Report

Merging #338 into development will not change coverage.
The diff coverage is 6.25%.

Impacted file tree graph

@@             Coverage Diff              @@
##           development     #338   +/-   ##
============================================
  Coverage        40.31%   40.31%           
============================================
  Files               37       37           
  Lines             7023     7023           
  Branches          1654     1653    -1     
============================================
  Hits              2831     2831           
  Misses            3989     3989           
  Partials           203      203
Impacted Files Coverage Δ
src/canmatrix/formats/cmjson.py 67.34% <ø> (ø) ⬆️
src/canmatrix/formats/xls.py 10.93% <0%> (+0.05%) ⬆️
src/canmatrix/formats/xlsx.py 1.16% <0%> (-0.01%) ⬇️
src/canmatrix/formats/dbc.py 52.4% <50%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2820f53...f09c24a. Read the comment docs.

src/canmatrix/cli/compare.py Outdated Show resolved Hide resolved
@@ -242,8 +242,7 @@ def compare_attributes(ele1, ele2, ignore=None):
if ignore is None:
ignore = dict()
result = CompareResult("equal", "ATTRIBUTES", ele1)
if "ATTRIBUTE" in ignore and (
ignore["ATTRIBUTE"] == "*" or ignore["ATTRIBUTE"] == ele1):
if ignore.get("ATTRIBUTE", "") == "*" or ignore.get("ATTRIBUTE","") == ele1:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

neither here

additionalFrameColums = [] # type: typing.List[str]
if "additionalFrameAttributes" in options and options["additionalFrameAttributes"]:
additionalFrameColums = options["additionalFrameAttributes"].split(",")
if options.get("additionalFrameAttributes",False):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add space after comma (PEP8), or even simplify to single line

additionalFrameColums = options.get("additionalFrameAttributes", "").split(",")

It should be enough, because "".split(",") is exactly []

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eeeeeee sorry, the "".split(",") is NOT [] but [""] so most of my comments are WRONG!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about how to write it on single line, so that the code is more condensated. Maybe this:

additionalFrameColums = [x for x in options.get("additionalFrameAttributes", "").split(",") if x]

@@ -192,10 +193,9 @@ def load(f, **options):
newframe = canmatrix.Frame(frame["name"],
arbitration_id=frame["id"],
size=8)
if "length" in frame:
newframe.size = frame["length"]
newframe.size = frame.get("length",0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wait, really zero? Or rather the size=8 from above? I think this code was OK, no need to change.

@@ -221,7 +221,7 @@ def load(f, **options):
factor=signal["factor"],
offset=signal["offset"])

if signal.get("min") is not None:
if signal.get("min", False) is not None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reparied it already... to

if signal.get("min", False):

else:
additional_signal_colums = []#["attributes['DisplayDecimalPlaces']"]

if "additionalFrameAttributes" in options and len(options["additionalFrameAttributes"]) > 0:
additional_frame_colums = options["additionalFrameAttributes"].split(",")
if len(options.get("additionalFrameAttributes","")) > 0:
Copy link
Contributor

@Funth0mas Funth0mas Mar 29, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to single line

motorolaBitFormat = options["xlsMotorolaBitFormat"]
else:
motorolaBitFormat = "msbreverse"
motorolaBitFormat = options.get("xlsMotorolaBitFormat","msbreverse")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

space after comma. Generally I think that it is good idea to keep the code style rules, because the IDE (pycharm) marks various issues and if we eliminate such superfluous warning sources, we can focus/see real problems. Of course the codestyle check can be disabled, but... yes the python freedom has some costs. But of course it is not my codebase, feel free to ignore me.

@@ -469,7 +466,7 @@ def load(file, **options):
mux, signalComment = signalComment[4:].split(':', 1)
multiplex = int(mux.strip())

if "byteorder" in index:
if index.get("byteorder", False):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

original code was OK I think

@@ -123,13 +123,13 @@ def dump(db, filename, **options):
'Byteorder']
head_tail = ['Value', 'Name / Phys. Range', 'Function / Increment Unit']

if "additionalAttributes" in options and len(options["additionalAttributes"]) > 0:
additional_signal_colums = options["additionalAttributes"].split(",")
if len(options.get("additionalAttributes", "")) > 0:
Copy link
Contributor

@Funth0mas Funth0mas Mar 29, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

convert to single line

else:
additional_signal_colums = []#["attributes['DisplayDecimalPlaces']"]

if "additionalFrameAttributes" in options and len(options["additionalFrameAttributes"]) > 0:
additional_frame_colums = options["additionalFrameAttributes"].split(",")
if len(options.get("additionalFrameAttributes", "")) > 0:
Copy link
Contributor

@Funth0mas Funth0mas Mar 29, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

convert to single line

Co-Authored-By: ebroecker <eduard.broecker@gmail.com>
@ebroecker
Copy link
Owner Author

@Funth0mas
Thanks for your review, gonna work on it

@ebroecker ebroecker merged commit 50d1693 into development Apr 5, 2019
@ebroecker ebroecker deleted the iss321 branch May 6, 2019 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants