gnu po文件的分析器

pop的Python项目详细描述


https://travis-ci.org/murataydos/popy.svghttps://coveralls.io/repos/murataydos/popy/badge.svg

gnu po文件的分析器

安装

使用pip安装:

pip install popy

用法

使用popy分析po文件:

from popy.po_file import PoFile

f = PoFile(path='/path/to/your/file.po')
messages = f.get_messages() # gets all the messages
messages[0]
# MessageEntry object
messages[0].msgid
# First message's msgid
messages[1].msgstr
# Second message's msgstr as a list

MessageEntry对象

这些是属性:

msgid: str
msgstr: list of strings
msgid_plural: str
msgctxt: str
translator_comments: list of strings
extracted_comments: list of strings
references: list of strings
flags: list of strings
is_fuzzy: boolean

这些是重要的方法:

fix_newline_matching()
# Adds or removes newlines to/from msgstr in order to match msgid and msgstr newlines at the beginning or end.

__str__()
# Generates a message block

pofile对象

这些是属性:

path: str
messages: list of MessageEntry objects

这些是重要的方法:

get_messages()
# Reads messages and returns list of MessageEntry objects

write_messages()
# Writes MessageEntry objects into the file

fix_newline_matching()
# Applys fix_newline_matching to the whole file

__str__()
# Generates a message block

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java的单元测试测试用例库。util。列出实现   java通过超类进行序列化/反序列化   java Android获取设备语言ISO字符串   java如何打开广告的行动。移动   Eclipse IDE for(嵌入式C/C++)开发者202012:经典的深色主题深黑色背景和菜单中的文本   java使用不同的内容动态创建TableView(JavaFX)   java JAXB将多个同名节点解组   java ClassDefNotFoundException,即使类由类加载器加载(服务器上安装了多个应用程序)   java有没有办法关闭在后端生成的MqttClient线程?   html如何在网站上的java小程序中包含图像?   java无法访问已分配给超类引用的子类实例变量   java在TableViewer中双击打开对话框   列出如何创建ListNode。JAVA   java如何从文本中输出的数组中放入随机图像