Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
methane merged 4 commits intopython-doc-ja:intl-3.6fromcocoatomo:avoid-sed-inconpatibility
Feb 28, 2017
Merged

Avoid sed inconpatibility#1

methane merged 4 commits intopython-doc-ja:intl-3.6fromcocoatomo:avoid-sed-inconpatibility
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.



defdelete_pot_creation_date(filename):
withcodecs.open(filename,'r',encoding='utf-8')asf:

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

@cocoatomococoatomoFeb 28, 2017
edited
Loading

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

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
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

Choose a reason for hiding this comment

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

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

@methanemethane merged commit85b44c3 intopython-doc-ja:intl-3.6Feb 28, 2017
@cocoatomococoatomo deleted the avoid-sed-inconpatibility branchMarch 1, 2017 01:41
methane pushed a commit that referenced this pull requestMar 1, 2017
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@methanemethanemethane requested changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@cocoatomo@methane

[8]ページ先頭

©2009-2025 Movatter.jp