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

Python3 support for restapi #2117

Merged
merged 50 commits into from Oct 26, 2018
Merged

Conversation

waychal
Copy link
Contributor

@waychal waychal commented Oct 25, 2018

No description provided.

ltalirz and others added 30 commits October 23, 2018 10:50
select working version of PycCifRW for python2 and python3
_exportstring should return bytes.
to reflect this, we are renaming it and updating its docstring
errors were only converted to test failures
(the interactive part of the test is failing now)
still to do: fix base64 conversion
Functions affected:
1) test_contents_encoding_1()
2) cif_encode_contents
3) encode_textfield_quoted_printable
…ke them runnable both on Python 2 and Python 3.
Copy link
Member

@giovannipizzi giovannipizzi left a comment

Choose a reason for hiding this comment

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

Also try to reduce the number of exclusions when possible, thanks!

id=id,
query_string=request.query_string,
id=node_id,
query_string=query_string,
Copy link
Member

Choose a reason for hiding this comment

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

Before it was unquoted. Was it wrong before or now? Note there is another place in the code which has a similar pattern, good to check what is done there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unquoted and quoted query string in response object both works in same way.

@coveralls
Copy link

Coverage Status

Coverage decreased (-7.7%) to 60.888% when pulling 85308fb on waychal:python3_restapi into 9cceedb on aiidateam:develop.

@coveralls
Copy link

coveralls commented Oct 25, 2018

Coverage Status

Coverage increased (+7.7%) to 68.622% when pulling de993a0 on waychal:python3_restapi into 0f8721a on aiidateam:develop.

dev-zero
dev-zero previously approved these changes Oct 26, 2018
Copy link
Contributor

@dev-zero dev-zero left a comment

Choose a reason for hiding this comment

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

there is one common anti-pattern here:

def func(something=None):
  if something is None:
    something = "some default value"
  pass

where I would do instead:

def func(something="some default value"):
  pass

for k, v in headers.items():
response.headers[k] = v
for key, val in headers.items():
response.headers[key] = val
Copy link
Contributor

Choose a reason for hiding this comment

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

for next time, possibly use respone.headers.update(headers) as a shorthand

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here response.header is not a type of dict so we can not directly update it with another dictionary.


@staticmethod
def get_visualization_data(node, format=None):
def get_visualization_data(node, visformat=None):
Copy link
Contributor

Choose a reason for hiding this comment

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

why not put visformat="xsf" here directly? then its clear by looking at the signature of the function what the default is

@staticmethod
def get_downloadable_data(node, format=None):
def get_downloadable_data(node, download_format=None):
Copy link
Contributor

Choose a reason for hiding this comment

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

... same here

@giovannipizzi
Copy link
Member

This fixes #2086

@giovannipizzi giovannipizzi merged commit d8fca45 into aiidateam:develop Oct 26, 2018
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

7 participants