polib._BaseFile

Module polib :: Class _BaseFile |
[hide private]
[frames] | no frames]

# Class _BaseFile

source code

    object --+
             |
          list --+
                 |
                _BaseFile

Known Subclasses:
  MOFile, POFile

Common parent class for POFile and MOFile classes. This class must not be instanciated directly.

Instance Methods | [hide private]
__init__(self, fpath=None, wrapwidth=78) Constructor. | source code
__str__(self) String representation of the file. | source code
__repr__(self) Return the official string representation of the object. | source code
metadata_as_entry(self) Return the metadata as an entry | source code
save(self, fpath=None, repr_method=`'``__str__``'`) Save the po file to file fpath if no file handle exists for the object. | source code
ordered_metadata(self) Convenience method that return the metadata ordered. | source code
charset(self) Return the file encoding charset. | source code
to_binary(self) Return the mofile binary representation. | source code
Inherited from `list`: `__add__`, `__contains__`, `__delitem__`, `__delslice__`, `__eq__`, `__ge__`, `__getattribute__`, `__getitem__`, `__getslice__`, `__gt__`, `__hash__`, `__iadd__`, `__imul__`, `__iter__`, `__le__`, `__len__`, `__lt__`, `__mul__`, `__ne__`, `__new__`, `__reversed__`, `__rmul__`, `__setitem__`, `__setslice__`, `append`, `count`, `extend`, `index`, `insert`, `pop`, `remove`, `reverse`, `sort` Inherited from `object`: `__delattr__`, `__reduce__`, `__reduce_ex__`, `__setattr__`

Properties | [hide private]
Inherited from `object`: `__class__`

Method Details | [hide private]

### __init__(self, fpath=None, wrapwidth=78) (Constructor) | source code
  Constructor. Keyword arguments: fpath: string, path to po or mo file wrapwidth: integer, the wrap width, only useful when -w option was passed to xgettext to generate the po file that was used to format the mo file, default to 78 (optional). Returns:
      new list
Overrides: list.__init__

### __str__(self) (Informal representation operator) | source code
String representation of the file. Overrides: object.__str__

### __repr__(self) (Representation operator) | source code
Return the official string representation of the object. Overrides: list.__repr__

### save(self, fpath=None, repr_method=`'``__str__``'`) | source code
Save the po file to file fpath if no file handle exists for the object. If there's already an open file and no fpath is provided, then the existing file is rewritten with the modified data. Keyword arguments: fpath: string, full or relative path to the file. repr_method: string, the method to use for output.

### ordered_metadata(self) | source code
Convenience method that return the metadata ordered. The return value is list of tuples (metadata name, metadata_value).

### charset(self) | source code
Return the file encoding charset. If the charset cannot be found in metadata, the function returns None.