def search(template_file, mlist=None, language=None):
"""Generator that provides file system search order.
This is Mailman's internal template search algorithm. The first locations
searched are within the $var_dir/templates directory, allowing a site to
override a template for a specific mailing list, all the mailing lists in
a domain, or site-wide.
The <language> path component is variable, and described below.
* The list-specific language directory
<var_dir>/templates/lists/<mlist.fqdn_listname>/<language>
* The domain-specific language directory
<var_dir>/templates/domains/<mlist.mail_host>/<language>
* The site-wide language directory
<var_dir>/templates/site/<language>
The <language> path component is calculated as follows, in this order:
* The `language` parameter if given
* `mlist.preferred_language` if given
* The server's default language
* English ('en')
Languages are iterated after each of the four locations are searched. So
for example, when searching for the 'foo.txt' template, where the server's
default language is 'fr', the mailing list's (<email address hidden>) language
is 'de' and the `language` parameter is 'it', these locations are searched
in order:
def search( template_ file, mlist=None, language=None):
"""Generator that provides file system search order.
This is Mailman's internal template search algorithm. The first locations
searched are within the $var_dir/templates directory, allowing a site to
override a template for a specific mailing list, all the mailing lists in
a domain, or site-wide.
The <language> path component is variable, and described below.
* The list-specific language directory var_dir> /templates/ lists/< mlist.fqdn_ listname> /<language>
<
* The domain-specific language directory var_dir> /templates/ domains/ <mlist. mail_host> /<language>
<
* The site-wide language directory var_dir> /templates/ site/<language>
<
The <language> path component is calculated as follows, in this order:
* The `language` parameter if given preferred_ language` if given
* `mlist.
* The server's default language
* English ('en')
Languages are iterated after each of the four locations are searched. So
for example, when searching for the 'foo.txt' template, where the server's
default language is 'fr', the mailing list's (<email address hidden>) language
is 'de' and the `language` parameter is 'it', these locations are searched
in order:
* <var_dir>/<email address hidden>/it/foo.txt /templates/ domains/ example. com/it/ foo.txt /templates/ site/it/ foo.txt
* <var_dir>
* <var_dir>
* <var_dir>/<email address hidden>/de/foo.txt /templates/ domains/ example. com/de/ foo.txt /templates/ site/de/ foo.txt
* <var_dir>
* <var_dir>
* <var_dir>/<email address hidden>/fr/foo.txt /templates/ domains/ example. com/fr/ foo.txt /templates/ site/fr/ foo.txt
* <var_dir>
* <var_dir>
* <var_dir>/<email address hidden>/en/foo.txt /templates/ domains/ example. com/en/ foo.txt /templates/ site/en/ foo.txt
* <var_dir>
* <var_dir>
After all those paths are searched, the final fallback is the English
template within the Mailman source tree.
* <source_ dir>/templates/ en/foo. txt
"""