-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,
Simon Michael <[EMAIL PROTECTED]> implemented exclude path:
http://zopewiki.org/I18nextract

Here come an update patch made against Zope 3.1.0.

Regards,
- --
Encolpe Degoute
INGENIWEB (TM) - S.A.S 50000 Euros - RC B 438 725 632
17 rue Louise Michel - 92300 Levallois Perret - France
web : www.ingeniweb.com - « les Services Web Ingénieux »
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iD8DBQFDuldgvFPzBBlIZMMRAjB1AJ9s3k5I8zO/CSRwmTOEgtIG9o1VCgCfXYkS
/W6TJsEdWW3O/3NKIFHx+7E=
=zp27
-----END PGP SIGNATURE-----
diff -ru --exclude '*py?' Zope-3.1.0.orig/lib/python/zope/app/locales/extract.py Zope-3.1.0/lib/python/zope/app/locales/extract.py
--- Zope-3.1.0.orig/lib/python/zope/app/locales/extract.py	2005-10-02 20:47:31.000000000 +0200
+++ Zope-3.1.0/lib/python/zope/app/locales/extract.py	2005-11-08 10:17:25.000000000 +0100
@@ -118,9 +118,9 @@
                self.msgid.default is not None):
             default = self.msgid.default.strip()
             lines = normalize(default).split("\n")
-            lines[0] = "# Default: %s\n" % lines[0]
+            lines[0] = "#. Default: %s\n" % lines[0]
             for i in range(1, len(lines)):
-                lines[i] = "#  %s\n" % lines[i]
+                lines[i] = "#.  %s\n" % lines[i]
             file.write("".join(lines))
         file.write('msgid %s\n' % normalize(self.msgid))
         file.write('msgstr ""\n')
@@ -317,6 +317,7 @@
     files = []
 
     def visit(files, dirname, names):
+        names[:] = filter(lambda x:x not in exclude, names)
         files += [os.path.join(dirname, name)
                   for name in fnmatch.filter(names, pattern)
                   if name not in exclude]
@@ -324,13 +325,13 @@
     os.path.walk(dir, visit, files)
     return files
 
-def py_strings(dir, domain="zope"):
+def py_strings(dir, domain="zope", exclude=[]):
     """Retrieve all Python messages from `dir` that are in the `domain`.
     """
     eater = TokenEater()
     make_escapes(0)
     for filename in find_files(dir, '*.py', 
-                               exclude=('extract.py', 'pygettext.py')):
+                               exclude=('extract.py', 'pygettext.py')+tuple(exclude)):
         fp = open(filename)
         try:
             eater.set_filename(filename)
@@ -360,7 +361,7 @@
     context = config(site_zcml, execute=False)
     return context.i18n_strings.get(domain, {})
 
-def tal_strings(dir, domain="zope", include_default_domain=False):
+def tal_strings(dir, domain="zope", include_default_domain=False, exclude=[]):
     """Retrieve all TAL messages from `dir` that are in the `domain`.
     """
     # We import zope.tal.talgettext here because we can't rely on the
@@ -373,7 +374,7 @@
         def write(self, s):
             pass
 
-    for filename in find_files(dir, '*.pt'):
+    for filename in find_files(dir, '*.pt', exclude=tuple(exclude)):
         try:
             engine.file = filename
             p = HTMLTALParser()
diff -ru --exclude '*py?' Zope-3.1.0.orig/zopeskel/bin/i18nextract.in Zope-3.1.0/zopeskel/bin/i18nextract.in
--- Zope-3.1.0.orig/zopeskel/bin/i18nextract.in	2005-01-06 15:41:57.000000000 +0100
+++ Zope-3.1.0/zopeskel/bin/i18nextract.in	2005-11-08 10:24:17.000000000 +0100
@@ -40,6 +40,9 @@
     -o dir
         Specifies a directory, relative to the package in which to put the
         output translation template.
+    -x dir
+        Specifies a directory, relative to the package, to exclude.
+        May be used more than once.
 
 $Id$
 """
@@ -83,7 +86,7 @@
     try:
         opts, args = getopt.getopt(
             sys.argv[1:],
-            'hd:p:o:',
+            'hd:p:o:x:',
             ['help', 'domain=', 'path=', 'python-only'])
     except getopt.error, msg:
         usage(1, msg)
@@ -92,6 +95,7 @@
     path = app_dir()
     include_default_domain = True
     output_dir = None
+    exclude_dirs = []
     python_only = None
     for opt, arg in opts:
         if opt in ('-h', '--help'):
@@ -101,6 +105,8 @@
             include_default_domain = False
         elif opt in ('-o', ):
             output_dir = arg
+        elif opt in ('-x', ):
+            exclude_dirs.append(arg)
         elif opt in ('--python-only',):
             python_only = True
         elif opt in ('-p', '--path'):
@@ -127,18 +133,18 @@
             os.mkdir(output_dir)
         output_file = os.path.join(output_dir, output_file)
 
-    print "base path: %r\nsearch path: %r\ndomain: %r\noutput file: %r" \
-        % (base_dir, path, domain, output_file)
+    print "base path: %r\nsearch path: %s\nexclude dirs: %r\ndomain: %r\noutput file: %r" \
+        % (base_dir, path, exclude_dirs, domain, output_file)
 
     from zope.app.locales.extract import POTMaker, \
          py_strings, tal_strings, zcml_strings
 
     maker = POTMaker(output_file, path)
-    maker.add(py_strings(path, domain), base_dir)
+    maker.add(py_strings(path, domain, exclude=exclude_dirs), base_dir)
     if not python_only:
         site_zcml = os.path.join(INSTANCE_HOME, 'etc', 'site.zcml')
         maker.add(zcml_strings(path, domain, site_zcml), base_dir)
-        maker.add(tal_strings(path, domain, include_default_domain), base_dir)
+        maker.add(tal_strings(path, domain, include_default_domain, exclude=exclude_dirs), base_dir)
     maker.write()
 
 
_______________________________________________
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com

Reply via email to