Skip to main content

Parser for GNU Po files

Project description

Parser for GNU Po files


Install using pip:

pip install popy


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
# MessageEntry object
# First message's msgid
# 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:

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

# Generates a message block

PoFile object

These are the attributes:

path: str
messages: list of MessageEntry objects

These are the important methods:

# Reads messages and returns list of MessageEntry objects

# Writes MessageEntry objects into the file

# Applys fix_newline_matching to the whole file

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

Files for popy, version 0.3.0
Filename, size File type Python version Upload date Hashes
Filename, size popy-0.3.0.tar.gz (3.5 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page