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

File encoding and CRLFs #11

Merged
merged 2 commits into from
Jun 23, 2017
Merged

File encoding and CRLFs #11

merged 2 commits into from
Jun 23, 2017

Conversation

mwhamgenomics
Copy link
Collaborator

@mwhamgenomics mwhamgenomics commented Jun 22, 2017

When a requests response object's text property is called, self.encoding is applied to self.content. Usually this is None and falls back to self.apparent_encoding.

In a case we were seeing though, a UTF-16-encoded XML file from a Windows machine was breaking this: since the Content-Type response header contained the string text, ISO-8859-1 encoding was being applied (see http://docs.python-requests.org/en/latest/user/advanced/?highlight=encoding#encodings).

Closes #10 by adding optional encodings and ability to convert CRLFs to \n.

@coveralls
Copy link

coveralls commented Jun 22, 2017

Coverage Status

Coverage increased (+0.5%) to 68.307% when pulling e43d179 on file_encodings into 14dae08 on master.

@@ -100,7 +100,11 @@ def get_file_contents(self, id=None, uri=None):
url = urljoin(self.baseuri, '/'.join(segments))
Copy link

Choose a reason for hiding this comment

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

I know it is not something you wrote but can you change this urljoin to self.get_uri?

@coveralls
Copy link

coveralls commented Jun 23, 2017

Coverage Status

Coverage increased (+0.6%) to 68.433% when pulling d51f63f on file_encodings into 14dae08 on master.

Copy link

@tcezard tcezard left a comment

Choose a reason for hiding this comment

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

Looks good

@tcezard tcezard merged commit 30488ca into master Jun 23, 2017
@mwhamgenomics mwhamgenomics deleted the file_encodings branch May 2, 2018 09:38
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