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

Fixed issue with single-item lists rendering incorrectly. Fixed all naming conventions and coding standards to adhere to PEP8. #17

Merged
merged 1 commit into from Dec 28, 2016

Conversation

lekic
Copy link
Contributor

@lekic lekic commented Apr 29, 2016

The changes are predominately formatting and conventions, with a minor change in the header generation section that allows for correct handling of one-item lists.

…aming conventions and coding standards to adhere to PEP8.
@muellermichel
Copy link
Contributor

I support this patch, it's much cleaner and adheres mostly to PEP8. I wonder what you meant with

with a minor change in the header generation section that allows for correct handling of one-item lists.

.. can't find it in the code.

convertedOutput += '</td></tr>'
converted_output += '<tr><td>'
converted_output += '</td><td>'.join([markup(list_entry[column_header]) for column_header in
column_headers])
Copy link
Contributor

Choose a reason for hiding this comment

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

how about

converted_output += '</td><td>'.join([
    markup(list_entry[column_header])
    for column_header in column_headers
])

I like this style of closing brackets better, I find it much more readable.

if len(inputtedJson) < 2:
return None
if not isinstance(inputtedJson[0], dict):
if not inputted_json or not isinstance(inputted_json[0], dict):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@softvar here is the functional change. Apologies it is hard to find amongst all the PEP8 changes - I should have made two separate commits. The issue was with the len(inputtedJson) < 2, whereas it should have been 1 to deal with the edge case. The final line is a nicer way to achieve the desired effect.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah so you want lists to always follow the table style, even if only one item is present. Makes sense I think for consistency. The old way just created multiple two-column rows right?

Copy link
Owner

Choose a reason for hiding this comment

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

@lekic Ah, now I get that line :)
The change ideally looks good.

Would be great if you could add a screenshot comparing the changes. This way, it helps in keeping track of changes.

Thanks for the patch. 👍
Will be merging it for sure after this.

@@ -78,88 +78,81 @@ def columnHeadersFromListOfDicts(self, inputtedJson):
-----------------------------

@contributed by: @muellermichel
'''
"""

Copy link
Contributor

Choose a reason for hiding this comment

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

I recommend adding an exception here when inputted_json is not a list. Actually inputted_json would better be renamed to input_list. The old code would throw an exception in most cases because len wouldn't exist, however a graceful error would be better for code stability in later iterations.

@softvar
Copy link
Owner

softvar commented Dec 28, 2016

Thanks @lekic for the awesome work.
Great! 👍

@softvar softvar merged commit 9bd00f2 into softvar:master Dec 28, 2016
@softvar
Copy link
Owner

softvar commented Dec 28, 2016

It's there in v1.0.3 now -> https://pypi.python.org/pypi/json2html

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.

None yet

3 participants