extract_from_dir(dirname=' /Users/chris/Projects/Edgewall/Babel/tags/0.9.1 ' ,
method_map=[ ( ' **.py ' , ' python ' ) ] ,
options_map={ ' territory_zones ' : { ' 001 ' : [ ' Etc/GMT ' , ' Etc/GMT-1 ' , ' Etc/GMT- ... ,
keywords={ ' N_ ' : None, ' _ ' : None, ' dgettext ' : ( 2) , ' dngettext ' : ( 2, 3) , ... ,
comment_tags=( ) ,
callback={ ' territory_zones ' : { ' 001 ' : [ ' Etc/GMT ' , ' Etc/GMT-1 ' , ' Etc/GMT- ... )
|
|
Extract messages from any source files found in the given directory.
This function generates tuples of the form:
(filename, lineno, message, comments)
Which extraction method is used per file is determined by the method_map
parameter, which maps extended glob patterns to extraction method names.
For example, the following is the default mapping:
>>> method_map = [
... ('**.py', 'python')
... ]
This basically says that files with the filename extension ".py" at any
level inside the directory should be processed by the "python" extraction
method. Files that don't match any of the mapping patterns are ignored. See
the documentation of the pathmatch function for details on the pattern
syntax.
The following extended mapping would also use the "genshi" extraction
method on any file in "templates" subdirectory:
>>> method_map = [
... ('**/templates/**.*', 'genshi'),
... ('**.py', 'python')
... ]
The dictionary provided by the optional options_map parameter augments
these mappings. It uses extended glob patterns as keys, and the values are
dictionaries mapping options names to option values (both strings).
The glob patterns of the options_map do not necessarily need to be the
same as those used in the method mapping. For example, while all files in
the templates folders in an application may be Genshi applications, the
options for those files may differ based on extension:
>>> options_map = {
... '**/templates/**.txt': {
... 'template_class': 'genshi.template:TextTemplate',
... 'encoding': 'latin-1'
... },
... '**/templates/**.html': {
... 'include_attrs': ''
... }
... }
- Parameters:
dirname - the path to the directory to extract messages from
method_map - a list of (pattern, method) tuples that maps of
extraction method names to extended glob patterns
options_map - a dictionary of additional options (optional)
keywords - a dictionary mapping keywords (i.e. names of functions
that should be recognized as translation functions) to
tuples that specify which of their arguments contain
localizable strings
comment_tags - a list of tags of translator comments to search for
and include in the results
callback - a function that is called for every file that message are
extracted from, just before the extraction itself is
performed; the function is passed the filename, the name
of the extraction method and and the options dictionary as
positional arguments, in that order
- Returns: iterator
- an iterator over (filename, lineno, funcname, message) tuples
|