changeset 897:d7f3c658184e

make POTFILES automatically
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Fri, 07 Jul 2006 12:36:22 +0200
parents 9dcd18a790ab
children a629ae02b25b
files MoinMoin/i18n/Makefile MoinMoin/i18n/POTFILES.in MoinMoin/i18n/tools/mk_POTFILES.py
diffstat 3 files changed, 233 insertions(+), 90 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/i18n/Makefile	Fri Jul 07 12:29:58 2006 +0200
+++ b/MoinMoin/i18n/Makefile	Fri Jul 07 12:36:22 2006 +0200
@@ -8,9 +8,13 @@
 
 -include POTFILES
 
-POTFILES: POTFILES.in
-	@echo "POTFILES = \\" > POTFILES
-	@sed -e '/^#/d' -e "/^[ ]*\$$/d" -e 's,.*,	../& \\,' -e '$$s/\(.*\) \\/\1/' < POTFILES.in >> POTFILES
+# both POTFILES.in and POTFILES are now generated by the same tool
+#POTFILES: POTFILES.in
+#	@echo "POTFILES = \\" > POTFILES
+#	@sed -e '/^#/d' -e "/^[ ]*\$$/d" -e 's,.*,	../& \\,' -e '$$s/\(.*\) \\/\1/' < POTFILES.in >> POTFILES
+
+POTFILES.in POTFILES:
+	tools/mk_POTFILES.py
 
 #.po.mo:
 #	@lang=`echo $@ | sed -e 's/\.mo$$//'`; \
--- a/MoinMoin/i18n/POTFILES.in	Fri Jul 07 12:29:58 2006 +0200
+++ b/MoinMoin/i18n/POTFILES.in	Fri Jul 07 12:36:22 2006 +0200
@@ -1,66 +1,106 @@
 Page.py
+PageEditor.py
 PageGraphicalEditor.py
 __init__.py
+_template.py
 caching.py
 config.py
 error.py
+failure.py
+user.py
+multiconfig.py
+packages.py
 search.py
-user.py
 userform.py
 version.py
-wikiutil.py
 wikidicts.py
-failure.py
-PageEditor.py
-packages.py
-multiconfig.py
-
-action/__init__.py
-action/PackagePages.py
-action/login.py
+wikiutil.py
+Xapian.py
+patchlevel.py
+action/AttachFile.py
+action/DeletePage.py
+action/Despam.py
 action/LikePages.py
 action/LocalSiteMap.py
 action/MyPages.py
+action/PackagePages.py
 action/RenamePage.py
+action/RenderAsDocbook.py
 action/SpellCheck.py
+action/SubscribeUser.py
+action/__init__.py
+action/backup.py
 action/fckdialog.py
 action/fullsearch.py
 action/links.py
+action/login.py
+action/logout.py
 action/newpage.py
 action/rss_rc.py
+action/test.py
 action/titleindex.py
-action/Despam.py
-action/SubscribeUser.py
-action/logout.py
-action/RenderAsDocbook.py
-action/DeletePage.py
-action/backup.py
-action/AttachFile.py
 action/userprefs.py
-
+action/thread_monitor.py
+action/sitemap.py
 auth/_PHPsessionParser.py
-
+auth/__init__.py
+auth/http.py
+auth/interwiki.py
+auth/ldap_login.py
+auth/log.py
+auth/mysql_group.py
+auth/php_session.py
+auth/smb_mount.py
+auth/sslclientcert.py
 converter/__init__.py
 converter/text_html_text_moin_wiki.py
-
+filter/EXIF.py
+filter/__init__.py
+filter/application_msword.py
+filter/application_octet_stream.py
+filter/application_pdf.py
+filter/application_vnd_ms_excel.py
+filter/application_vnd_sun_xml.py
+filter/application_vnd_sun_xml_calc.py
+filter/application_vnd_sun_xml_writer.py
+filter/audio.py
+filter/image.py
+filter/image_jpeg.py
+filter/text.py
+filter/text_html.py
+filter/text_rtf.py
+filter/text_xml.py
+filter/video.py
+filter/application_vnd_oasis_opendocument.py
+filter/application_vnd_oasis_opendocument_presentation.py
+filter/application_vnd_oasis_opendocument_spreadsheet.py
+filter/application_vnd_oasis_opendocument_text.py
 formatter/__init__.py
+formatter/dom_xml.py
 formatter/pagelinks.py
-formatter/dom_xml.py
-formatter/text_plain.py
-formatter/text_html.py
-formatter/text_xml.py
 formatter/text_docbook.py
 formatter/text_gedit.py
+formatter/text_html.py
+formatter/text_plain.py
 formatter/text_python.py
-
+formatter/text_xml.py
 i18n/__init__.py
 i18n/dummy.py
-
+i18n/msgfmt.py
+i18n/save/__init__.py
+i18n/save/dummy.py
+i18n/save/msgfmt.py
+i18n/tools/check_i18n.py
+i18n/tools/mail_i18n-maintainers.py
+i18n/tools/po2wiki.py
+i18n/tools/prepend.py
+i18n/tools/recode.py
+i18n/tools/wiki2po.py
+i18n/tools/__init__.py
+i18n/tools/mk_POTFILES.py
 logfile/__init__.py
 logfile/editlog.py
 logfile/eventlog.py
-
-macro/__init__.py
 macro/AbandonedPages.py
 macro/Action.py
 macro/AttachInfo.py
@@ -69,11 +109,13 @@
 macro/EditTemplates.py
 macro/EditedSystemPages.py
 macro/FootNote.py
-macro/Login.py
+macro/FullSearch.py
+macro/FullSearchCached.py
 macro/GetText.py
 macro/ImageLink.py
-macro/FullSearchCached.py
+macro/Include.py
 macro/LikePages.py
+macro/Login.py
 macro/MonthCalendar.py
 macro/Navigation.py
 macro/NewPage.py
@@ -83,59 +125,92 @@
 macro/RandomPage.py
 macro/RandomQuote.py
 macro/RecentChanges.py
-macro/FullSearch.py
+macro/ShowSmileys.py
+macro/StatsChart.py
 macro/SystemAdmin.py
+macro/SystemInfo.py
 macro/TableOfContents.py
 macro/TeudView.py
 macro/Verbatim.py
 macro/WantedPages.py
-macro/StatsChart.py
-macro/Include.py
-macro/ShowSmileys.py
-
+macro/__init__.py
+macro/EmbedObject.py
+mail/__init__.py
+mail/mailimport.py
+mail/sendmail.py
+parser/ParserBase.py
 parser/__init__.py
 parser/text.py
+parser/text_cplusplus.py
 parser/text_csv.py
-parser/text_cplusplus.py
 parser/text_docbook.py
+parser/text_html.py
 parser/text_irssi.py
 parser/text_java.py
+parser/text_moin_wiki.py
 parser/text_pascal.py
 parser/text_python.py
 parser/text_rst.py
-parser/text_moin_wiki.py
 parser/text_xslt.py
-parser/ParserBase.py
-
+request/CGI.py
+request/CLI.py
+request/FCGI.py
+request/MODPYTHON.py
+request/STANDALONE.py
+request/TWISTED.py
+request/WSGI.py
+request/__init__.py
+script/__init__.py
+script/moin.py
+script/account/__init__.py
+script/account/check.py
+script/account/create.py
+script/account/disable.py
+script/cli/__init__.py
+script/cli/show.py
+script/export/__init__.py
+script/export/dump.py
+script/import/__init__.py
+script/import/irclog.py
+script/maint/__init__.py
+script/maint/cleancache.py
+script/maint/cleanpage.py
+script/maint/globaledit.py
+script/maint/mkpagepacks.py
+script/maint/reducewiki.py
+script/migration/1050300.py
+script/migration/1050301.py
+script/migration/__init__.py
+script/migration/data.py
+script/migration/migutil.py
+script/migration/1050400.py
+script/migration/12_to_13_mig01.py
+script/migration/12_to_13_mig06.py
+script/migration/12_to_13_mig07.py
+script/xmlrpc/__init__.py
+script/xmlrpc/mailimport.py
+script/index/__init__.py
+script/index/build.py
 security/__init__.py
 security/antispam.py
 security/autoadmin.py
-
 server/__init__.py
 server/daemon.py
+server/standalone.py
 server/twistedmoin.py
 server/wsgi.py
-server/standalone.py
-
 stats/__init__.py
 stats/chart.py
 stats/hitcounts.py
 stats/pagesize.py
 stats/useragents.py
-
-support/BasicAuthTransport.py
-support/__init__.py
-support/cgitb.py
-support/thfcgi.py
-support/copy.py
-
 theme/__init__.py
 theme/classic.py
 theme/modern.py
 theme/rightsidebar.py
-
 util/__init__.py
 util/chartypes.py
+util/chartypes_create.py
 util/dataset.py
 util/diff.py
 util/diff3.py
@@ -143,52 +218,21 @@
 util/lock.py
 util/profile.py
 util/pysupport.py
-util/web.py
+util/thread_monitor.py
 util/timefuncs.py
-util/chartypes_create.py
-
+util/web.py
+util/lang_enc_detect.py
 widget/__init__.py
 widget/base.py
 widget/browser.py
 widget/dialog.py
 widget/html.py
-
 wikixml/__init__.py
 wikixml/marshal.py
 wikixml/util.py
-
-xmlrpc/__init__.py
 xmlrpc/HelloWorld.py
+xmlrpc/ProcessMail.py
 xmlrpc/UpdateGroup.py
-xmlrpc/putClientInfo.py
 xmlrpc/WhoAmI.py
-
-filter/__init__.py
-filter/image.py
-filter/text.py
-filter/audio.py
-filter/video.py
-filter/EXIF.py
-filter/application_pdf.py
-filter/image_jpeg.py
-filter/text_html.py
-filter/application_msword.py
-filter/application_vnd_ms_excel.py
-filter/application_vnd_sun_xml.py
-filter/text_rtf.py
-filter/text_xml.py
-filter/application_vnd_sun_xml_calc.py
-filter/application_vnd_sun_xml_writer.py
-filter/application_octet_stream.py
-
-request/__init__.py
-request/CGI.py
-request/FCGI.py
-request/CLI.py
-request/WSGI.py
-request/MODPYTHON.py
-request/TWISTED.py
-request/STANDALONE.py
-
-script/moin.py
-
+xmlrpc/__init__.py
+xmlrpc/putClientInfo.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MoinMoin/i18n/tools/mk_POTFILES.py	Fri Jul 07 12:36:22 2006 +0200
@@ -0,0 +1,95 @@
+#!/usr/bin/env python
+
+import os
+
+# Define the starting directory.
+
+startdir = os.path.join("..") # MoinMoin
+
+# Define a blacklist.
+
+blacklist = ["_tests", os.path.join("script", "old"), "support"]
+
+# Define an output file for the filenames.
+
+outname_in = "POTFILES.in"
+outname_final = "POTFILES"
+
+# Functions.
+
+def get_files((files, prefix, blacklist), d, names):
+
+    """
+    Store pathnames in 'files', removing 'prefix', excluding those mentioned
+    in the 'blacklist', building such pathnames from the directory 'd' and
+    the given 'names'.
+    """
+
+    for name in names:
+        if name.endswith(".py"):
+            path = os.path.join(d, name)
+
+            # Strip the prefix.
+
+            if path.startswith(prefix):
+                path = path[len(prefix):]
+
+            # Test for exact blacklist matches.
+
+            if path in blacklist:
+                continue
+
+            # Test for directory blacklist matches.
+
+            found = 0
+            for blackitem in blacklist:
+                if path.startswith(blackitem):
+                    found = 1
+                    break
+
+            if not found:
+                files.append(path)
+
+def find_files(startdir, blacklist):
+
+    "Find files under 'startdir' excluding those in the 'blacklist'."
+
+    # Calculate the prefix from the start directory.
+
+    prefix = os.path.join(startdir, "")
+
+    # Start with an empty list of files.
+
+    files = []
+    os.path.walk(startdir, get_files, (files, prefix, blacklist))
+    return files
+
+if __name__ == "__main__":
+
+    # Find those files using the module defaults.
+
+    files = find_files(startdir, blacklist)
+
+    # Write the names out.
+
+    outfile = open(outname_in, "w")
+    try:
+        for file in files:
+            outfile.write(file + "\n")
+    finally:
+        outfile.close()
+
+    # Write the processed list out, ready for other purposes.
+
+    outfile = open(outname_final, "w")
+    outfile.write("POTFILES = \\\n")
+    try:
+        for file in files[:-1]:
+            outfile.write("\t" + os.path.join("..", file) + " \\\n")
+        if files[-1]:
+            file = files[-1]
+            outfile.write("\t" + os.path.join("..", file) + "\n")
+    finally:
+        outfile.close()
+
+# vim: tabstop=4 expandtab shiftwidth=4