Edgewall Software
Modify

Opened 8 years ago

Closed 7 years ago

Last modified 7 years ago

#12852 closed defect (fixed)

extract_messages command failing without Genshi

Reported by: Jun Omae Owned by: Jun Omae
Priority: normal Milestone: 1.3.2
Component: i18n Version:
Severity: normal Keywords:
Cc: Branch:
Release Notes:
API Changes:

Error is raised when extracting messages from Genshi template if Genshi is not installed.

Internal Changes:

Description

$ /dev/shm/trac-trunk/bin/python setup.py extract_messages
...
extracting messages from trac/templates/genshi/about.html (line_comment_prefix="##", line_statement_prefix="#", trim_blocks="yes", newstyle_gettext="yes", variable_start_string="${", extensions="jinja2.ext.with_", variable_end_string="}", lstrip_blocks="yes")
Traceback (most recent call last):
  File "setup.py", line 158, in <module>
    **extra
  File "/usr/lib/python2.7/distutils/core.py", line 151, in setup
    dist.run_commands()
  File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/dev/shm/trac-trunk/local/lib/python2.7/site-packages/babel/messages/frontend.py", line 467, in run
    for filename, lineno, message, comments, context in extracted:
  File "/dev/shm/trac-trunk/local/lib/python2.7/site-packages/babel/messages/extract.py", line 156, in extract_from_dir
    dirpath=absname,
  File "/dev/shm/trac-trunk/local/lib/python2.7/site-packages/babel/messages/extract.py", line 211, in check_and_call_extract_file
    strip_comment_tags=strip_comment_tags
  File "/dev/shm/trac-trunk/local/lib/python2.7/site-packages/babel/messages/extract.py", line 240, in extract_from_file
    strip_comment_tags))
  File "/dev/shm/trac-trunk/local/lib/python2.7/site-packages/babel/messages/extract.py", line 321, in extract
    for lineno, funcname, messages, comments in results:
  File "/home/jun66j5/src/tracdev/git/trac/dist.py", line 319, in extract_html
    for m in extractor(fileobj, keywords, comment_tags, options):
TypeError: 'NoneType' object is not callable
make: *** [extract] Error 1
Python: /dev/shm/trac-trunk/bin/python

  Package        Version
  ------------------------------------------------------
  Python       : 2.7.6 (default, Jun 22 2015, 17:58:13)
               : [GCC 4.8.2]
  Setuptools   : 36.0.1
  Jinja2       : 2.9.6
  Genshi       : not installed
  Babel        : 2.4.0
  sqlite3      : 2.6.0 (3.8.2)
  PySqlite     : not installed
  PyMySQL      : not installed
  Psycopg2     : not installed
  SVN bindings : not installed
  Mercurial    : not installed
  Pygments     : not installed
  Textile      : not installed
  Pytz         : 2017.2
  Docutils     : not installed
  Twill        : not installed
  LXML         : not installed
  coverage     : not installed
  figleaf      : not installed

Variables:
  PATH=/dev/shm/trac-trunk/bin:/home/jun66j5/bin:/home/jun66j5/venv/tools/bin:/home/jun66j5/.gem/ruby/2.0.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
  PYTHONPATH=.
  TRAC_TEST_DB_URI=
  server-options= -p 3000 -a '*,/home/jun66j5/src/trac-htdigest.txt,auth'  -e

External dependencies:
  Git version: git version 1.9.1
  Subversion version: 1.8.8

That command works with Genshi.

Attachments (0)

Change History (4)

comment:1 by Ryan J Ollos, 7 years ago

Should we just skip the Genshi templates when running the extraction without Genshi installed?:

  • trac/dist.py

    diff --git a/trac/dist.py b/trac/dist.py
    index ce1622aa6..f99c01648 100644
    a b try:  
    315315                    extractor = genshi_extractor
    316316            else:
    317317                extractor = jinja2_extractor
    318             fileobj.seek(0)
    319             for m in extractor(fileobj, keywords, comment_tags, options):
    320                 # lineno, func, message, comments = m
    321                 if m[1] in ('gettext', None):
    322                     #   (Jinja2 trans, Genshi)
    323                     yield m[0], m[1], simplify_message(m[2]), m[3]
    324                 else:
    325                     yield m
     318            if extractor:
     319                fileobj.seek(0)
     320                for m in extractor(fileobj, keywords, comment_tags, options):
     321                    # lineno, func, message, comments = m
     322                    if m[1] in ('gettext', None):
     323                        #   (Jinja2 trans, Genshi)
     324                        yield m[0], m[1], simplify_message(m[2]), m[3]
     325                    else:
     326                        yield m
    326327
    327328    def extract_text(fileobj, keywords, comment_tags, options):
    328329        """Extract messages from Genshi or Jinja2 text templates.

comment:2 by Jun Omae, 7 years ago

Genshi template and i18n feature is still supported on Trac 1.3.x for Trac core and plugins. I think we should raise an error rather than skip those Genshi templates when messages extraction from Genshi templates is requested.

  • trac/dist.py

    diff --git a/trac/dist.py b/trac/dist.py
    index ce1622aa6..868ad7343 100644
    a b try:  
    308308        # TODO (1.5.1) remove genshi support
    309309        if fileobj:
    310310            if 'xmlns:py="http://genshi.edgewall.org/"' in fileobj.read():
    311                 if genshi:
    312                     if text:
    313                         options.update(template_class=
    314                                        'genshi.template:NewTextTemplate')
    315                     extractor = genshi_extractor
     311                if not genshi:
     312                    raise ValueError("Cannot extract messages from a legacy "
     313                                     "Genshi template because Genshi is "
     314                                     "unavailable.")
     315                if text:
     316                    options.update(template_class=
     317                                   'genshi.template:NewTextTemplate')
     318                extractor = genshi_extractor
    316319            else:
    317320                extractor = jinja2_extractor
    318321            fileobj.seek(0)

comment:3 by Ryan J Ollos, 7 years ago

API Changes: modified (diff)
Resolution: fixed
Status: newclosed

Work for me. Fixed in r16104.

comment:4 by Ryan J Ollos, 7 years ago

Owner: set to Jun Omae

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jun Omae.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Jun Omae to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.