Parser for GNU Po files
Project description
Parser for GNU Po files
Installation
Install using pip:
pip install popy
Usage
Using popy to parse a PO file:
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 object
These are the attributes:
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
These are the important methods:
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 object
These are the attributes:
path: str messages: list of MessageEntry objects
These are the important methods:
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
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
popy-0.3.0.tar.gz
(3.5 kB
view details)
File details
Details for the file popy-0.3.0.tar.gz.
File metadata
- Download URL: popy-0.3.0.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
390d16d791e82f6b11af803efd01d3440d9b1f6e5847fe8817a779e25940ccea
|
|
| MD5 |
4e0861687af86651b2a71a277aa78da4
|
|
| BLAKE2b-256 |
6b3b1f475a70661665ab61aad8ab62e216841d2c3769d752881a0b59ffc4a45f
|