[Zope3-checkins] CVS: Zope3/utilities - i18nextract.py:1.3
Dmitry Vasiliev
dima at hlabs.spb.ru
Tue Mar 23 04:11:17 EST 2004
Update of /cvs-repository/Zope3/utilities
In directory cvs.zope.org:/tmp/cvs-serv22321
Modified Files:
i18nextract.py
Log Message:
i18nextract.py updates:
- search for base dir now going from right to left;
- search path information is printing before processing files;
- sys.path patching now goes before all imports from zope package;
=== Zope3/utilities/i18nextract.py 1.2 => 1.3 ===
--- Zope3/utilities/i18nextract.py:1.2 Wed Dec 17 09:06:54 2003
+++ Zope3/utilities/i18nextract.py Tue Mar 23 04:11:16 2004
@@ -40,9 +40,7 @@
$Id$
"""
-import os, sys, fnmatch, getopt
-from zope.app.translation_files.extract import POTMaker, \
- py_strings, tal_strings, zcml_strings
+import os, sys, getopt
def usage(code, msg=''):
# Python 2.1 required
@@ -59,16 +57,18 @@
# path
# Get the path of the src
- path = os.path.abspath(os.path.dirname(sys.argv[0]))
+ path = os.path.abspath(os.getcwd())
while not path.endswith('src'):
path = os.path.dirname(path)
sys.path.insert(0, path)
- import zope.app
-
- dir = os.path.dirname(zope.app.__file__)
+ try:
+ import zope.app
+ except ImportError:
+ usage(1, "Make sure the script has been executed "
+ "inside Zope 3 source tree.")
- return dir
+ return os.path.dirname(zope.app.__file__)
def main(argv=sys.argv):
try:
@@ -105,7 +105,7 @@
# When generating the comments, we will not need the base directory info,
# since it is specific to everyone's installation
- src_start = path.find('src')
+ src_start = path.rfind('src')
base_dir = path[:src_start]
output_file = domain+'.pot'
@@ -115,6 +115,10 @@
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)
+ from zope.app.translation_files.extract import POTMaker, \
+ py_strings, tal_strings, zcml_strings
maker = POTMaker(output_file, path)
maker.add(py_strings(path, domain), base_dir)
maker.add(zcml_strings(path, domain), base_dir)
More information about the Zope3-Checkins
mailing list