Frontends for the message extraction functionality.
Unknown Field: copyright | |
| |
Unknown Field: license | |
BSD, see LICENSE for more details. |
Variable | po_file_read_mode |
Undocumented |
Class | Command |
Undocumented |
Class | CommandLineInterface |
Command-line interface. |
Class | compile_catalog |
Catalog compilation command for use in setup.py scripts. |
Class | extract_messages |
Message extraction command for use in setup.py scripts. |
Class | init_catalog |
New catalog initialization command for use in setup.py scripts. |
Class | update_catalog |
Catalog merging command for use in setup.py scripts. |
Function | check_message_extractors |
Validate the message_extractors keyword argument to setup(). |
Function | listify_value |
Make a list out of an argument. |
Function | main |
Undocumented |
Function | parse_keywords |
Parse keywords specifications from the given list of strings. |
Function | parse_mapping |
Parse an extraction method mapping from a file-like object. |
Parameters | |
dist | the distutils/setuptools Distribution object |
name | the name of the keyword argument (should always be "message_extractors") |
value | the value of the keyword argument |
Raises | |
DistutilsSetupError | if the value is not valid |
Make a list out of an argument.
Values from distutils
argument parsing are always single strings;
values from optparse
parsing may be lists of strings that may need
to be further split.
No matter the input, this function returns a flat list of whitespace-trimmed
strings, with None
values filtered out.
>>> listify_value("foo bar") ['foo', 'bar'] >>> listify_value(["foo bar"]) ['foo', 'bar'] >>> listify_value([["foo"], "bar"]) ['foo', 'bar'] >>> listify_value([["foo"], ["bar", None, "foo"]]) ['foo', 'bar', 'foo'] >>> listify_value("foo, bar, quux", ",") ['foo', 'bar', 'quux']
Parameters | |
arg | A string or a list of strings |
split | The argument to pass to str.split() . |
Returns | |
Parse keywords specifications from the given list of strings.
>>> kw = sorted(parse_keywords(['_', 'dgettext:2', 'dngettext:2,3', 'pgettext:1c,2']).items()) >>> for keyword, indices in kw: ... print((keyword, indices)) ('_', None) ('dgettext', (2,)) ('dngettext', (2, 3)) ('pgettext', ((1, 'c'), 2))
Parse an extraction method mapping from a file-like object.
>>> buf = StringIO(''' ... [extractors] ... custom = mypackage.module:myfunc ... ... # Python source files ... [python: **.py] ... ... # Genshi templates ... [genshi: **/templates/**.html] ... include_attrs = ... [genshi: **/templates/**.txt] ... template_class = genshi.template:TextTemplate ... encoding = latin-1 ... ... # Some custom extractor ... [custom: **/custom/*.*] ... ''')
>>> method_map, options_map = parse_mapping(buf) >>> len(method_map) 4
>>> method_map[0] ('**.py', 'python') >>> options_map['**.py'] {} >>> method_map[1] ('**/templates/**.html', 'genshi') >>> options_map['**/templates/**.html']['include_attrs'] '' >>> method_map[2] ('**/templates/**.txt', 'genshi') >>> options_map['**/templates/**.txt']['template_class'] 'genshi.template:TextTemplate' >>> options_map['**/templates/**.txt']['encoding'] 'latin-1'
>>> method_map[3] ('**/custom/*.*', 'mypackage.module:myfunc') >>> options_map['**/custom/*.*'] {}
Parameters | |
fileobj | a readable file-like object containing the configuration text to parse |
filename | Undocumented |
See Also | |
extract_from_directory |