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

Feature: allow to specify encoding for load, save, replace_in_files #5902

Merged
merged 3 commits into from Oct 24, 2019

Conversation

@SSE4
Copy link
Contributor

SSE4 commented Oct 14, 2019

closes: #5840
Changelog: Feature: Allow to specify encoding for tools.load, tools.save and tools.replace_in_files.
Docs: conan-io/docs#1446

add encoding argument to the:

  • tools.load
  • tools.save
  • tools.save_append
  • tools.save_files
  • tools.replace_in_file
  • tools.replace_path_in_file
  • tools.to_file_bytes

the auto encoding is for auto-detect

Q: Should I touch replace_prefix_in_pc_file and dos2unix/unix2dos as well?

  • Refer to the issue that supports this Pull Request.
  • If the issue has missing info, explain the purpose/use case/pain/need that covers this Pull Request.
  • I've read the Contributing guide.
  • I've followed the PEP8 style guides for Python code.
  • I've opened another PR in the Conan docs repo to the develop branch, documenting this one.

Note: By default this PR will skip the slower tests and will use a limited set of python versions. Check here how to increase the testing level by writing some tags in the current PR body text.

@SSE4 SSE4 force-pushed the SSE4:replace_in_file_encoding branch from 6e308ca to 87cec3d Oct 14, 2019
Signed-off-by: SSE4 <tomskside@gmail.com>
@SSE4 SSE4 force-pushed the SSE4:replace_in_file_encoding branch from 87cec3d to 3067a24 Oct 14, 2019
@SSE4 SSE4 marked this pull request as ready for review Oct 15, 2019
@lasote lasote added this to the 1.20 milestone Oct 21, 2019
@lasote

This comment has been minimized.

Copy link
Contributor

lasote commented Oct 21, 2019

Q: Should I touch replace_prefix_in_pc_file and dos2unix/unix2dos as well?

I don't think we need it to change everything now.

Add the docs, always add the docs before considering a PR completed.

@SSE4

This comment has been minimized.

Copy link
Contributor Author

SSE4 commented Oct 21, 2019

added docs

conans/util/files.py Show resolved Hide resolved
Copy link
Member

memsharded left a comment

I think this is necessary, don't love it, but that is the annoying thing of encodings, not this PR. This PR is ok. The only thing I would consider is to have just 1 encoding for "replace" methods, so they keep the current encoding, and that function will not do also a change of encoding.

Then, later (Conan 2.0), we probably want to revisit our encoding rules and behaviors, maybe use the open(encoding=xxx) argument instead of encoding ourselves, etc.

conans/client/tools/files.py Outdated Show resolved Hide resolved
conans/client/tools/files.py Outdated Show resolved Hide resolved
Signed-off-by: SSE4 <tomskside@gmail.com>
@memsharded memsharded merged commit bdc5901 into conan-io:develop Oct 24, 2019
2 checks passed
2 checks passed
continuous-integration/jenkins/pr-head This commit looks good
Details
license/cla Contributor License Agreement is signed.
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.