Back to index

python3.2  3.2.2
Classes | Functions | Variables
pygettext Namespace Reference

Classes

class  TokenEater

Functions

def usage
def make_escapes
def escape
def safe_eval
def normalize
def containsAny
def _visit_pyfiles
def _get_modpkg_path
def getFilesForName
def __waiting
 import token print >> sys.stderr, 'ttype:', token.tok_name[ttype], \ 'tstring:', tstring
def __suiteseen
def __suitedocstring
def __keywordseen
def __openseen
def __addentry
def set_filename
def write
def main

Variables

 _ = fintl.gettext
tuple __doc__ = _("""pygettext -- Python equivalent of xgettext(1)Many systems (Solaris, Linux, Gnu) provide extensive tools that ease theinternationalization of C programs. Most of these tools are independent ofthe programming language and can be used from within Python programs.Martin von Loewis' work[1] helps considerably in this regard.There's one problem though; xgettext is the program that scans source codelooking for message strings, but it groks only C (or C++). Pythonintroduces a few wrinkles, such as dual quoting characters, triple quotedstrings, and raw strings. xgettext understands none of this.Enter pygettext, which uses Python's standard tokenize module to scanPython source code, generating .pot files identical to what GNU xgettext[2]generates for C and C++ code. From there, the standard GNU tools can beused.A word about marking Python strings as candidates for translation. GNUxgettext recognizes the following keywords: gettext, dgettext, dcgettext,and gettext_noop. But those can be a lot of text to include all over yourcode. C and C++ have a trick: they use the C preprocessor. Mostinternationalized C source includes a #define for gettext() to _() so thatwhat has to be written in the source is much less. Thus these are bothtranslatable strings: gettext("Translatable String") _("Translatable String")Python of course has no preprocessor so this doesn't work so well. Thus,pygettext searches only for _() by default, but see the -k/--keyword flagbelow for how to augment this. [1] http://www.python.org/workshops/1997-10/proceedings/loewis.html [2] http://www.gnu.org/software/gettext/gettext.htmlNOTE: pygettext attempts to be option and feature compatible with GNUxgettext where ever possible. However some options are still missing or arenot fully implemented. Also, xgettext's use of command line switches withoption arguments is broken, and in these cases, pygettext just definesadditional switches.Usage: pygettext [options] inputfile ...Options: -a --extract-all Extract all strings. -d name --default-domain=name Rename the default output file from messages.pot to name.pot. -E --escape Replace non-ASCII characters with octal escape sequences. -D --docstrings Extract module, class, method, and function docstrings. These do not need to be wrapped in _() markers, and in fact cannot be for Python to consider them docstrings. (See also the -X option). -h --help Print this help message and exit. -k word --keyword=word Keywords to look for in addition to the default set, which are: %(DEFAULTKEYWORDS)s You can have multiple -k flags on the command line. -K --no-default-keywords Disable the default set of keywords (see above). Any keywords explicitly added with the -k/--keyword option are still recognized. --no-location Do not write filename/lineno location comments. -n --add-location Write filename/lineno location comments indicating where each extracted string is found in the source. These lines appear before each msgid. The style of comments is controlled by the -S/--style option. This is the default. -o filename --output=filename Rename the default output file from messages.pot to filename. If filename is `-' then the output is sent to standard out. -p dir --output-dir=dir Output files will be placed in directory dir. -S stylename --style stylename Specify which style to use for location comments. Two styles are supported: Solaris # File: filename, line: line-number GNU #: filename:line The style name is case insensitive. GNU style is the default. -v --verbose Print the names of the files being processed. -V --version Print the version of pygettext and exit. -w columns --width=columns Set width of output to columns. -x filename --exclude-file=filename Specify a file that contains a list of strings that are not be extracted from the input files. Each string to be excluded must appear on a line by itself in the file. -X filename --no-docstrings=filename Specify a file that contains a list of files (one per line) that should not have their docstrings extracted. This is only useful in conjunction with the -D option above.If `inputfile' is -, standard input is read.""")
string __version__ = '1.5'
list default_keywords = ['_']
string DEFAULTKEYWORDS = ', '
string EMPTYSTRING = ''
tuple pot_header
list escapes = []
 __freshmodule
 __state
 __data
 __lineno
 __curfile

Function Documentation

def pygettext.__addentry (   self,
  msg,
  lineno = None,
  isdocstring = 0 
) [private]

Definition at line 435 of file pygettext.py.

00435 
00436     def __addentry(self, msg, lineno=None, isdocstring=0):
00437         if lineno is None:
00438             lineno = self.__lineno
00439         if not msg in self.__options.toexclude:
00440             entry = (self.__curfile, lineno)
00441             self.__messages.setdefault(msg, {})[entry] = isdocstring

def pygettext.__keywordseen (   self,
  ttype,
  tstring,
  lineno 
) [private]

Definition at line 404 of file pygettext.py.

00404 
00405     def __keywordseen(self, ttype, tstring, lineno):
00406         if ttype == tokenize.OP and tstring == '(':
00407             self.__data = []
00408             self.__lineno = lineno
00409             self.__state = self.__openseen
00410         else:
00411             self.__state = self.__waiting

def pygettext.__openseen (   self,
  ttype,
  tstring,
  lineno 
) [private]

Definition at line 412 of file pygettext.py.

00412 
00413     def __openseen(self, ttype, tstring, lineno):
00414         if ttype == tokenize.OP and tstring == ')':
00415             # We've seen the last of the translatable strings.  Record the
00416             # line number of the first line of the strings and update the list
00417             # of messages seen.  Reset state for the next batch.  If there
00418             # were no strings inside _(), then just ignore this entry.
00419             if self.__data:
00420                 self.__addentry(EMPTYSTRING.join(self.__data))
00421             self.__state = self.__waiting
00422         elif ttype == tokenize.STRING:
00423             self.__data.append(safe_eval(tstring))
00424         elif ttype not in [tokenize.COMMENT, token.INDENT, token.DEDENT,
00425                            token.NEWLINE, tokenize.NL]:
00426             # warn if we see anything else than STRING or whitespace
00427             print(_(
00428                 '*** %(file)s:%(lineno)s: Seen unexpected token "%(token)s"'
00429                 ) % {
00430                 'token': tstring,
00431                 'file': self.__curfile,
00432                 'lineno': self.__lineno
00433                 }, file=sys.stderr)
00434             self.__state = self.__waiting

Here is the call graph for this function:

def pygettext.__suitedocstring (   self,
  ttype,
  tstring,
  lineno 
) [private]

Definition at line 394 of file pygettext.py.

00394 
00395     def __suitedocstring(self, ttype, tstring, lineno):
00396         # ignore any intervening noise
00397         if ttype == tokenize.STRING:
00398             self.__addentry(safe_eval(tstring), lineno, isdocstring=1)
00399             self.__state = self.__waiting
00400         elif ttype not in (tokenize.NEWLINE, tokenize.INDENT,
00401                            tokenize.COMMENT):
00402             # there was no class docstring
00403             self.__state = self.__waiting

Here is the call graph for this function:

def pygettext.__suiteseen (   self,
  ttype,
  tstring,
  lineno 
) [private]

Definition at line 389 of file pygettext.py.

00389 
00390     def __suiteseen(self, ttype, tstring, lineno):
00391         # ignore anything until we see the colon
00392         if ttype == tokenize.OP and tstring == ':':
00393             self.__state = self.__suitedocstring

def pygettext.__waiting (   self,
  ttype,
  tstring,
  lineno 
) [private]

import token print >> sys.stderr, 'ttype:', token.tok_name[ttype], \ 'tstring:', tstring

Definition at line 370 of file pygettext.py.

00370 
00371     def __waiting(self, ttype, tstring, lineno):
00372         opts = self.__options
00373         # Do docstring extractions, if enabled
00374         if opts.docstrings and not opts.nodocstrings.get(self.__curfile):
00375             # module docstring?
00376             if self.__freshmodule:
00377                 if ttype == tokenize.STRING:
00378                     self.__addentry(safe_eval(tstring), lineno, isdocstring=1)
00379                     self.__freshmodule = 0
00380                 elif ttype not in (tokenize.COMMENT, tokenize.NL):
00381                     self.__freshmodule = 0
00382                 return
00383             # class docstring?
00384             if ttype == tokenize.NAME and tstring in ('class', 'def'):
00385                 self.__state = self.__suiteseen
00386                 return
00387         if ttype == tokenize.NAME and tstring in opts.keywords:
00388             self.__state = self.__keywordseen

Here is the call graph for this function:

def pygettext._get_modpkg_path (   dotted_name,
  pathlist = None 
) [private]
Get the filesystem path for a module or a package.

Return the file system path to a file for a module, and to a directory for
a package. Return None if the name is not found, or is a builtin or
extension module.

Definition at line 284 of file pygettext.py.

00284 
00285 def _get_modpkg_path(dotted_name, pathlist=None):
00286     """Get the filesystem path for a module or a package.
00287 
00288     Return the file system path to a file for a module, and to a directory for
00289     a package. Return None if the name is not found, or is a builtin or
00290     extension module.
00291     """
00292     # split off top-most name
00293     parts = dotted_name.split('.', 1)
00294 
00295     if len(parts) > 1:
00296         # we have a dotted path, import top-level package
00297         try:
00298             file, pathname, description = imp.find_module(parts[0], pathlist)
00299             if file: file.close()
00300         except ImportError:
00301             return None
00302 
00303         # check if it's indeed a package
00304         if description[2] == imp.PKG_DIRECTORY:
00305             # recursively handle the remaining name parts
00306             pathname = _get_modpkg_path(parts[1], [pathname])
00307         else:
00308             pathname = None
00309     else:
00310         # plain name
00311         try:
00312             file, pathname, description = imp.find_module(
00313                 dotted_name, pathlist)
00314             if file:
00315                 file.close()
00316             if description[2] not in [imp.PY_SOURCE, imp.PKG_DIRECTORY]:
00317                 pathname = None
00318         except ImportError:
00319             pathname = None
00320 
00321     return pathname
00322 

Here is the caller graph for this function:

def pygettext._visit_pyfiles (   list,
  dirname,
  names 
) [private]
Helper for getFilesForName().

Definition at line 265 of file pygettext.py.

00265 
00266 def _visit_pyfiles(list, dirname, names):
00267     """Helper for getFilesForName()."""
00268     # get extension for python source files
00269     if '_py_ext' not in globals():
00270         global _py_ext
00271         _py_ext = [triple[0] for triple in imp.get_suffixes()
00272                    if triple[2] == imp.PY_SOURCE][0]
00273 
00274     # don't recurse into CVS directories
00275     if 'CVS' in names:
00276         names.remove('CVS')
00277 
00278     # add all *.py files to list
00279     list.extend(
00280         [os.path.join(dirname, file) for file in names
00281          if os.path.splitext(file)[1] == _py_ext]
00282         )
00283 

def pygettext.containsAny (   str,
  set 
)
Check whether 'str' contains ANY of the chars in 'set'

Definition at line 260 of file pygettext.py.

00260 
00261 def containsAny(str, set):
00262     """Check whether 'str' contains ANY of the chars in 'set'"""
00263     return 1 in [c in str for c in set]
00264 

Here is the caller graph for this function:

def pygettext.escape (   s)

Definition at line 230 of file pygettext.py.

00230 
00231 def escape(s):
00232     global escapes
00233     s = list(s)
00234     for i in range(len(s)):
00235         s[i] = escapes[ord(s[i])]
00236     return EMPTYSTRING.join(s)
00237 

Here is the call graph for this function:

Here is the caller graph for this function:

def pygettext.getFilesForName (   name)
Get a list of module files for a filename, a module or package name,
or a directory.

Definition at line 323 of file pygettext.py.

00323 
00324 def getFilesForName(name):
00325     """Get a list of module files for a filename, a module or package name,
00326     or a directory.
00327     """
00328     if not os.path.exists(name):
00329         # check for glob chars
00330         if containsAny(name, "*?[]"):
00331             files = glob.glob(name)
00332             list = []
00333             for file in files:
00334                 list.extend(getFilesForName(file))
00335             return list
00336 
00337         # try to find module or package
00338         name = _get_modpkg_path(name)
00339         if not name:
00340             return []
00341 
00342     if os.path.isdir(name):
00343         # find all python files in directory
00344         list = []
00345         os.walk(name, _visit_pyfiles, list)
00346         return list
00347     elif os.path.exists(name):
00348         # a single file
00349         return [name]
00350 
00351     return []
00352 


Here is the call graph for this function:

Here is the caller graph for this function:

def pygettext.main ( void  )

Definition at line 500 of file pygettext.py.

00500 
00501 def main():
00502     global default_keywords
00503     try:
00504         opts, args = getopt.getopt(
00505             sys.argv[1:],
00506             'ad:DEhk:Kno:p:S:Vvw:x:X:',
00507             ['extract-all', 'default-domain=', 'escape', 'help',
00508              'keyword=', 'no-default-keywords',
00509              'add-location', 'no-location', 'output=', 'output-dir=',
00510              'style=', 'verbose', 'version', 'width=', 'exclude-file=',
00511              'docstrings', 'no-docstrings',
00512              ])
00513     except getopt.error as msg:
00514         usage(1, msg)
00515 
00516     # for holding option values
00517     class Options:
00518         # constants
00519         GNU = 1
00520         SOLARIS = 2
00521         # defaults
00522         extractall = 0 # FIXME: currently this option has no effect at all.
00523         escape = 0
00524         keywords = []
00525         outpath = ''
00526         outfile = 'messages.pot'
00527         writelocations = 1
00528         locationstyle = GNU
00529         verbose = 0
00530         width = 78
00531         excludefilename = ''
00532         docstrings = 0
00533         nodocstrings = {}
00534 
00535     options = Options()
00536     locations = {'gnu' : options.GNU,
00537                  'solaris' : options.SOLARIS,
00538                  }
00539 
00540     # parse options
00541     for opt, arg in opts:
00542         if opt in ('-h', '--help'):
00543             usage(0)
00544         elif opt in ('-a', '--extract-all'):
00545             options.extractall = 1
00546         elif opt in ('-d', '--default-domain'):
00547             options.outfile = arg + '.pot'
00548         elif opt in ('-E', '--escape'):
00549             options.escape = 1
00550         elif opt in ('-D', '--docstrings'):
00551             options.docstrings = 1
00552         elif opt in ('-k', '--keyword'):
00553             options.keywords.append(arg)
00554         elif opt in ('-K', '--no-default-keywords'):
00555             default_keywords = []
00556         elif opt in ('-n', '--add-location'):
00557             options.writelocations = 1
00558         elif opt in ('--no-location',):
00559             options.writelocations = 0
00560         elif opt in ('-S', '--style'):
00561             options.locationstyle = locations.get(arg.lower())
00562             if options.locationstyle is None:
00563                 usage(1, _('Invalid value for --style: %s') % arg)
00564         elif opt in ('-o', '--output'):
00565             options.outfile = arg
00566         elif opt in ('-p', '--output-dir'):
00567             options.outpath = arg
00568         elif opt in ('-v', '--verbose'):
00569             options.verbose = 1
00570         elif opt in ('-V', '--version'):
00571             print(_('pygettext.py (xgettext for Python) %s') % __version__)
00572             sys.exit(0)
00573         elif opt in ('-w', '--width'):
00574             try:
00575                 options.width = int(arg)
00576             except ValueError:
00577                 usage(1, _('--width argument must be an integer: %s') % arg)
00578         elif opt in ('-x', '--exclude-file'):
00579             options.excludefilename = arg
00580         elif opt in ('-X', '--no-docstrings'):
00581             fp = open(arg)
00582             try:
00583                 while 1:
00584                     line = fp.readline()
00585                     if not line:
00586                         break
00587                     options.nodocstrings[line[:-1]] = 1
00588             finally:
00589                 fp.close()
00590 
00591     # calculate escapes
00592     make_escapes(options.escape)
00593 
00594     # calculate all keywords
00595     options.keywords.extend(default_keywords)
00596 
00597     # initialize list of strings to exclude
00598     if options.excludefilename:
00599         try:
00600             fp = open(options.excludefilename)
00601             options.toexclude = fp.readlines()
00602             fp.close()
00603         except IOError:
00604             print(_(
00605                 "Can't read --exclude-file: %s") % options.excludefilename, file=sys.stderr)
00606             sys.exit(1)
00607     else:
00608         options.toexclude = []
00609 
00610     # resolve args to module lists
00611     expanded = []
00612     for arg in args:
00613         if arg == '-':
00614             expanded.append(arg)
00615         else:
00616             expanded.extend(getFilesForName(arg))
00617     args = expanded
00618 
00619     # slurp through all the files
00620     eater = TokenEater(options)
00621     for filename in args:
00622         if filename == '-':
00623             if options.verbose:
00624                 print(_('Reading standard input'))
00625             fp = sys.stdin
00626             closep = 0
00627         else:
00628             if options.verbose:
00629                 print(_('Working on %s') % filename)
00630             fp = open(filename)
00631             closep = 1
00632         try:
00633             eater.set_filename(filename)
00634             try:
00635                 tokens = tokenize.generate_tokens(fp.readline)
00636                 for _token in tokens:
00637                     eater(*_token)
00638             except tokenize.TokenError as e:
00639                 print('%s: %s, line %d, column %d' % (
00640                     e.args[0], filename, e.args[1][0], e.args[1][1]),
00641                     file=sys.stderr)
00642         finally:
00643             if closep:
00644                 fp.close()
00645 
00646     # write the output
00647     if options.outfile == '-':
00648         fp = sys.stdout
00649         closep = 0
00650     else:
00651         if options.outpath:
00652             options.outfile = os.path.join(options.outpath, options.outfile)
00653         fp = open(options.outfile, 'w')
00654         closep = 1
00655     try:
00656         eater.write(fp)
00657     finally:
00658         if closep:
00659             fp.close()
00660 


Here is the call graph for this function:

def pygettext.make_escapes (   pass_iso8859)

Definition at line 209 of file pygettext.py.

00209 
00210 def make_escapes(pass_iso8859):
00211     global escapes
00212     if pass_iso8859:
00213         # Allow iso-8859 characters to pass through so that e.g. 'msgid
00214         # "Höhe"' would result not result in 'msgid "H\366he"'.  Otherwise we
00215         # escape any character outside the 32..126 range.
00216         mod = 128
00217     else:
00218         mod = 256
00219     for i in range(256):
00220         if 32 <= (i % mod) <= 126:
00221             escapes.append(chr(i))
00222         else:
00223             escapes.append("\\%03o" % i)
00224     escapes[ord('\\')] = '\\\\'
00225     escapes[ord('\t')] = '\\t'
00226     escapes[ord('\r')] = '\\r'
00227     escapes[ord('\n')] = '\\n'
00228     escapes[ord('\"')] = '\\"'
00229 

Here is the call graph for this function:

Here is the caller graph for this function:

def pygettext.normalize (   s)

Definition at line 243 of file pygettext.py.

00243 
00244 def normalize(s):
00245     # This converts the various Python string types into a format that is
00246     # appropriate for .po files, namely much closer to C style.
00247     lines = s.split('\n')
00248     if len(lines) == 1:
00249         s = '"' + escape(s) + '"'
00250     else:
00251         if not lines[-1]:
00252             del lines[-1]
00253             lines[-1] = lines[-1] + '\n'
00254         for i in range(len(lines)):
00255             lines[i] = escape(lines[i])
00256         lineterm = '\\n"\n"'
00257         s = '""\n"' + lineterm.join(lines) + '"'
00258     return s
00259 


Here is the call graph for this function:

Here is the caller graph for this function:

def pygettext.safe_eval (   s)

Definition at line 238 of file pygettext.py.

00238 
00239 def safe_eval(s):
00240     # unwrap quotes, safely
00241     return eval(s, {'__builtins__':{}}, {})
00242 

Here is the caller graph for this function:

def pygettext.set_filename (   self,
  filename 
)

Definition at line 442 of file pygettext.py.

00442 
00443     def set_filename(self, filename):
00444         self.__curfile = filename
00445         self.__freshmodule = 1

def pygettext.usage (   code,
  msg = '' 
)

Definition at line 199 of file pygettext.py.

00199 
00200 def usage(code, msg=''):
00201     print(__doc__ % globals(), file=sys.stderr)
00202     if msg:
00203         print(msg, file=sys.stderr)
00204     sys.exit(code)
00205 
00206 


Here is the caller graph for this function:

def pygettext.write (   self,
  fp 
)

Definition at line 446 of file pygettext.py.

00446 
00447     def write(self, fp):
00448         options = self.__options
00449         timestamp = time.strftime('%Y-%m-%d %H:%M+%Z')
00450         # The time stamp in the header doesn't have the same format as that
00451         # generated by xgettext...
00452         print(pot_header % {'time': timestamp, 'version': __version__}, file=fp)
00453         # Sort the entries.  First sort each particular entry's keys, then
00454         # sort all the entries by their first item.
00455         reverse = {}
00456         for k, v in self.__messages.items():
00457             keys = sorted(v.keys())
00458             reverse.setdefault(tuple(keys), []).append((k, v))
00459         rkeys = sorted(reverse.keys())
00460         for rkey in rkeys:
00461             rentries = reverse[rkey]
00462             rentries.sort()
00463             for k, v in rentries:
00464                 # If the entry was gleaned out of a docstring, then add a
00465                 # comment stating so.  This is to aid translators who may wish
00466                 # to skip translating some unimportant docstrings.
00467                 isdocstring = any(v.values())
00468                 # k is the message string, v is a dictionary-set of (filename,
00469                 # lineno) tuples.  We want to sort the entries in v first by
00470                 # file name and then by line number.
00471                 v = sorted(v.keys())
00472                 if not options.writelocations:
00473                     pass
00474                 # location comments are different b/w Solaris and GNU:
00475                 elif options.locationstyle == options.SOLARIS:
00476                     for filename, lineno in v:
00477                         d = {'filename': filename, 'lineno': lineno}
00478                         print(_(
00479                             '# File: %(filename)s, line: %(lineno)d') % d, file=fp)
00480                 elif options.locationstyle == options.GNU:
00481                     # fit as many locations on one line, as long as the
00482                     # resulting line length doesn't exceeds 'options.width'
00483                     locline = '#:'
00484                     for filename, lineno in v:
00485                         d = {'filename': filename, 'lineno': lineno}
00486                         s = _(' %(filename)s:%(lineno)d') % d
00487                         if len(locline) + len(s) <= options.width:
00488                             locline = locline + s
00489                         else:
00490                             print(locline, file=fp)
00491                             locline = "#:" + s
00492                     if len(locline) > 2:
00493                         print(locline, file=fp)
00494                 if isdocstring:
00495                     print('#, docstring', file=fp)
00496                 print('msgid', normalize(k), file=fp)
00497                 print('msgstr ""\n', file=fp)
00498 
00499 


Here is the call graph for this function:


Variable Documentation

pygettext._ = fintl.gettext

Definition at line 19 of file pygettext.py.

Definition at line 443 of file pygettext.py.

Definition at line 406 of file pygettext.py.

tuple pygettext.__doc__ = _("""pygettext -- Python equivalent of xgettext(1)Many systems (Solaris, Linux, Gnu) provide extensive tools that ease theinternationalization of C programs. Most of these tools are independent ofthe programming language and can be used from within Python programs.Martin von Loewis' work[1] helps considerably in this regard.There's one problem though; xgettext is the program that scans source codelooking for message strings, but it groks only C (or C++). Pythonintroduces a few wrinkles, such as dual quoting characters, triple quotedstrings, and raw strings. xgettext understands none of this.Enter pygettext, which uses Python's standard tokenize module to scanPython source code, generating .pot files identical to what GNU xgettext[2]generates for C and C++ code. From there, the standard GNU tools can beused.A word about marking Python strings as candidates for translation. GNUxgettext recognizes the following keywords: gettext, dgettext, dcgettext,and gettext_noop. But those can be a lot of text to include all over yourcode. C and C++ have a trick: they use the C preprocessor. Mostinternationalized C source includes a #define for gettext() to _() so thatwhat has to be written in the source is much less. Thus these are bothtranslatable strings: gettext("Translatable String") _("Translatable String")Python of course has no preprocessor so this doesn't work so well. Thus,pygettext searches only for _() by default, but see the -k/--keyword flagbelow for how to augment this. [1] http://www.python.org/workshops/1997-10/proceedings/loewis.html [2] http://www.gnu.org/software/gettext/gettext.htmlNOTE: pygettext attempts to be option and feature compatible with GNUxgettext where ever possible. However some options are still missing or arenot fully implemented. Also, xgettext's use of command line switches withoption arguments is broken, and in these cases, pygettext just definesadditional switches.Usage: pygettext [options] inputfile ...Options: -a --extract-all Extract all strings. -d name --default-domain=name Rename the default output file from messages.pot to name.pot. -E --escape Replace non-ASCII characters with octal escape sequences. -D --docstrings Extract module, class, method, and function docstrings. These do not need to be wrapped in _() markers, and in fact cannot be for Python to consider them docstrings. (See also the -X option). -h --help Print this help message and exit. -k word --keyword=word Keywords to look for in addition to the default set, which are: %(DEFAULTKEYWORDS)s You can have multiple -k flags on the command line. -K --no-default-keywords Disable the default set of keywords (see above). Any keywords explicitly added with the -k/--keyword option are still recognized. --no-location Do not write filename/lineno location comments. -n --add-location Write filename/lineno location comments indicating where each extracted string is found in the source. These lines appear before each msgid. The style of comments is controlled by the -S/--style option. This is the default. -o filename --output=filename Rename the default output file from messages.pot to filename. If filename is `-' then the output is sent to standard out. -p dir --output-dir=dir Output files will be placed in directory dir. -S stylename --style stylename Specify which style to use for location comments. Two styles are supported: Solaris # File: filename, line: line-number GNU #: filename:line The style name is case insensitive. GNU style is the default. -v --verbose Print the names of the files being processed. -V --version Print the version of pygettext and exit. -w columns --width=columns Set width of output to columns. -x filename --exclude-file=filename Specify a file that contains a list of strings that are not be extracted from the input files. Each string to be excluded must appear on a line by itself in the file. -X filename --no-docstrings=filename Specify a file that contains a list of files (one per line) that should not have their docstrings extracted. This is only useful in conjunction with the -D option above.If `inputfile' is -, standard input is read.""")

Definition at line 23 of file pygettext.py.

Definition at line 378 of file pygettext.py.

Definition at line 407 of file pygettext.py.

Definition at line 384 of file pygettext.py.

Definition at line 168 of file pygettext.py.

Definition at line 170 of file pygettext.py.

Definition at line 171 of file pygettext.py.

Definition at line 173 of file pygettext.py.

list pygettext.escapes = []

Definition at line 207 of file pygettext.py.

Initial value:
00001 _('''\
00002 # SOME DESCRIPTIVE TITLE.
00003 # Copyright (C) YEAR ORGANIZATION
00004 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
00005 #
00006 msgid ""
00007 msgstr ""
00008 "Project-Id-Version: PACKAGE VERSION\\n"
00009 "POT-Creation-Date: %(time)s\\n"
00010 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\\n"
00011 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\\n"
00012 "Language-Team: LANGUAGE <LL@li.org>\\n"
00013 "MIME-Version: 1.0\\n"
00014 "Content-Type: text/plain; charset=CHARSET\\n"
00015 "Content-Transfer-Encoding: ENCODING\\n"
00016 "Generated-By: pygettext.py %(version)s\\n"
00017 
00018 ''')

Definition at line 179 of file pygettext.py.