Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Avoid sed inconpatibility #1

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

Merged
merged 4 commits into from
Feb 28, 2017
Merged

Avoid sed inconpatibility #1

merged 4 commits into from
Feb 28, 2017

Conversation

cocoatomo
Copy link

sed command has inconpatibility on -i option behavior between GNU sed and BSD sed.
In addition to this inconpatibility, Windows has no sed command natively.

In order to deal with these difference between platforms, Python script would be helpful.



def delete_pot_creation_date(filename):
with codecs.open(filename, 'r', encoding='utf-8') as f:
Copy link

Choose a reason for hiding this comment

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

Python 2/3 共通のコード書くときは、 codecs.open よりも io.open の方が好み。

Copy link
Author

@cocoatomo cocoatomo Feb 28, 2017

Choose a reason for hiding this comment

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

ちょっと分かりづらいんですが, howto/logging-cookbook.rst に ascii の範囲を越える文字が使われていて, 組み込み関数の open を使うと Windows でエラーが出ていたんで encoding 指定できる codecs.open を使った.

具体的な箇所はここの二重引用符
https://github.com/python-doc-ja/cpython-doc-intl/blame/intl-3.6/Doc/howto/logging-cookbook.rst#L1988

よく見ると QUOTATION MARK (0x22) ではなく LEFT DOUBLE QUOTATION MARK (0x201C) と RIGHT DOUBLE QUOTATION MARK (0x201D) が使われている.

Copy link
Author

Choose a reason for hiding this comment

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

エラーメッセージ

>>> open('locale\pot\howto\logging-cookbook.pot').readlines()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
UnicodeDecodeError: 'cp932' codec can't decode byte 0x9c in position 2194: illegal multibyte sequence

Copy link

Choose a reason for hiding this comment

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

組み込みの open じゃなくて io.open ね。 Python 2.7 でも encoding 指定できるはず。

Copy link
Author

Choose a reason for hiding this comment

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

あ、こっちか。間違って os.open 見てました ;p

https://docs.python.jp/3/library/io.html#high-level-module-interface
https://docs.python.jp/2.7/library/io.html#text-i-o
これか。オプション引数多いし、こっちが良さそう。

Doc/Makefile Outdated
@@ -189,4 +189,4 @@ autobuild-stable-html:
.PHONY: gettext
gettext:
sphinx-build -E -b gettext -D gettext_compact=0 -w warnings.txt -d build/.doctrees . locale/pot
find locale/pot -name '*.pot' | xargs sed -i -e '/^"POT-Creation-Date: 20/d'
python tools/delete_pot_creation_date.py locale/pot
Copy link

Choose a reason for hiding this comment

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

他のところに合わせて $(PYTHON) ってしておいてください。

@methane methane merged commit 85b44c3 into python-doc-ja:intl-3.6 Feb 28, 2017
@cocoatomo cocoatomo deleted the avoid-sed-inconpatibility branch March 1, 2017 01:41
methane pushed a commit that referenced this pull request Mar 1, 2017
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.

2 participants