/[navidoc]/navidoc/navidoc/directives/pegboard.py
ViewVC logotype

Diff of /navidoc/navidoc/directives/pegboard.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7 by humppake, Fri Mar 21 14:39:37 2003 UTC revision 1.8 by humppake, Mon Mar 24 08:08:13 2003 UTC
# Line 25  Line 25 
25    
26  __docformat__ = 'reStructuredText'  __docformat__ = 'reStructuredText'
27    
   
28  import os, string  import os, string
29    
30  from docutils import Component  from docutils import Component
# Line 121  def build_pegtable(): Line 120  def build_pegtable():
120                    
121          peg = {'authors': [], 'status': config.pegboard_undefined, 'topic': pegdir,          peg = {'authors': [], 'status': config.pegboard_undefined, 'topic': pegdir,
122                 'stakeholders': [], 'last-modified': '', 'dir': pegdir, 'files': '',                 'stakeholders': [], 'last-modified': '', 'dir': pegdir, 'files': '',
123                 'html': '', 'rst': '', 'rstfiles': [], 'cvsignore': [] }                 'html': '', 'rst': '', 'rstfiles': [], 'ignore': [] }
124                    
125          peg['files'] = [f for f in os.listdir(config.working_directory) \          peg['files'] = [f for f in os.listdir(config.working_directory) \
126                          if os.path.isfile(_slashify(config.working_directory)+f)                          if os.path.isfile(_slashify(config.working_directory)+f)
127                          and not f.startswith('.') and '#' not in f and '~' not in f]                          and not f.startswith('.') and '#' not in f and '~' not in f]
128    
129          try:          if peg['files'].count('peg.rst') > 0:
130              index = peg['files'].index('peg.rst')              peg['rst'] = 'peg.rst'
131              peg['rst'] = peg['files'][index]          else:
         except ValueError:  
132              for pegfile in peg['files']:              for pegfile in peg['files']:
133                  if pegfile.endswith('.rst'):                  if pegfile.endswith('.rst'):
134                      peg['rst'] = pegfile                      peg['rst'] = pegfile
# Line 141  def build_pegtable(): Line 139  def build_pegtable():
139              pub = Publisher()              pub = Publisher()
140              pub.set_reader('standalone', None, 'restructuredtext')              pub.set_reader('standalone', None, 'restructuredtext')
141              filename = _slashify(config.working_directory)+rstfile              filename = _slashify(config.working_directory)+rstfile
142              #" tmp" at the end of the next line is for jython to avoid negative arraylength :)              pub.process_command_line(argv=('--config '+config.docutils+' '+filename+'').split())
             pub.process_command_line(argv=("--config "+config.docutils+" "+filename+" tmp").split())  
143                            
144              #conversion may fail because of bad restructuredtext              #conversion may fail because of bad restructuredtext
145              try:              try:
146                  pub.set_io()                  pub.set_io()
147                  document = pub.reader.read(pub.source, pub.parser, pub.settings)                  document = pub.reader.read(pub.source, pub.parser, pub.settings)
148                  pub.apply_transforms(document)                  pub.apply_transforms(document)
149                  peg['cvsignore'].append(rstfile[0:len(rstfile)-4]+'.gen.html')                  peg['ignore'].append(rstfile[0:len(rstfile)-4]+'.gen.html')
150    
151                  #conversion have succeeded so far, parsing peg's metadata                  #conversion have succeeded so far, parsing peg's metadata
152                  #from its document tree                  #from its document tree
# Line 176  def build_pegtable(): Line 173  def build_pegtable():
173                  dbg_fail('PEG %s: Docutil raised an exception while converting %s. ' % (pegdir, rstfile))                  dbg_fail('PEG %s: Docutil raised an exception while converting %s. ' % (pegdir, rstfile))
174                  dbg_fail('Conversion failed and HTML not created.\n')                  dbg_fail('Conversion failed and HTML not created.\n')
175    
176      if not peg['html']:          if not peg['html']:
177          for file in peg['files']:              for file in peg['files']:
178              if file[len(file)-5:len(file)] == '.html':                  if file[len(file)-5:len(file)] == '.html':
179                  peg['html'] = file                      peg['html'] = file
180                  break                      break
181              elif file[len(file)-4:len(file)] in ('.rst', '.txt'):                  elif file[len(file)-4:len(file)] in ('.rst', '.txt'):
182                  peg['html'] = file                      peg['html'] = file
183                  break                      break
184                    
185      config.working_directory = init_working_directory          #finally adds peg's metadata into pegtable
186            pegtable.append(peg)
187    
188      #finally adds peg's metadata into pegtable      config.working_directory = init_working_directory
     pegtable.append(peg)  
189      return pegtable      return pegtable
190    
191  #create the ``.. pegboard::`` directive  #create the ``.. pegboard::`` directive
# Line 250  def pegboard_directive(*args): Line 247  def pegboard_directive(*args):
247          status_emph += status_comment          status_emph += status_comment
248                    
249          status = [          status = [
250              nodes.Text(status_field[0] + " "),              nodes.Text(status_field[0] + ' '),
251              status_emph              status_emph
252          ]          ]
253                    
# Line 304  def td(__node, **args): Line 301  def td(__node, **args):
301    
302  def make_files(peg):  def make_files(peg):
303      # again, cpython and 'class'      # again, cpython and 'class'
304      # list = nodes.bullet_list(class="plain")      # list = nodes.bullet_list(class='pain')
305      list = nodes.bullet_list()      list = nodes.bullet_list()
306      list['class'] = 'plain'      list['class'] = 'plain'
307    
# Line 316  def make_files(peg): Line 313  def make_files(peg):
313            
314      for file in peg['files']:      for file in peg['files']:
315          try:          try:
316              if peg['cvsignore'].index(file):              if peg['ignore'].index(file):
317                  pass                  pass
318          except ValueError:          except ValueError:
319              converted = 0              converted = 0
# Line 325  def make_files(peg): Line 322  def make_files(peg):
322                  for rstfile in peg['rstfiles']:                  for rstfile in peg['rstfiles']:
323                      if rstfile['filename'] == file:                      if rstfile['filename'] == file:
324                          status = rstfile['status']                          status = rstfile['status']
325                  for htmlfile in peg['cvsignore']:                  for htmlfile in peg['ignore']:
326                      if htmlfile == file[0:len(file)-4]+'.html':                      if htmlfile == file[0:len(file)-4]+'.html':
327                          converted = htmlfile                          converted = htmlfile
328              if converted:              if converted:

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26