/[gzz]/gzz/metacode/pegboard.py
ViewVC logotype

Diff of /gzz/metacode/pegboard.py

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

revision 1.10 by humppake, Tue Nov 5 17:08:38 2002 UTC revision 1.11 by humppake, Tue Nov 5 18:02:22 2002 UTC
# Line 63  def pegcmp(a, b): Line 63  def pegcmp(a, b):
63      bs = b['date'].split('-')      bs = b['date'].split('-')
64      if not len(as) == 3 or not len(bs) == 3:      if not len(as) == 3 or not len(bs) == 3:
65          return len(as) < len(bs) or (len(bs) < len(as)) * -1 or 0          return len(as) < len(bs) or (len(bs) < len(as)) * -1 or 0
66      ac = as[0]*356 + as[1]*30 + as[2]      ac = int(as[0])*10000 + int(as[1])*100 + int(as[2])
67      bc = bs[0]*356 + bs[1]*30 + bs[2]      bc = int(bs[0])*10000 + int(bs[1])*100 + int(bs[2])
68      return ac < bc or (bc < ac) * -1 or 0      return ac < bc or (bc < ac) * -1 or 0
69    
70  #returns the value of the first occurrense or all of the occurrences  #returns the value of the first occurrense or all of the occurrences
71  #of given tagName in docutils' document tree  #of given tagName in docutils' document tree
72  def getTagValue(document, tagName, all=0):  def getTagValue(document, tagName, all=0, always_raw=0):
73      values = []      values = []
74      if document.tagname.lower() == tagName.lower():      if document.tagname.lower() == tagName.lower():
75          if hasattr(document.children[0], 'data'):          if hasattr(document.children[0], 'data') and not always_raw:
76              return document.children[0].data              return document.children[0].data
77          else:          else:
78              return document.rawsource           return document.rawsource
79      if hasattr(document, 'children'):      if hasattr(document, 'children'):
80          for child in document.children:          for child in document.children:
81              value = getTagValue(child, tagName, all)              value = getTagValue(child, tagName, all=all, always_raw=always_raw)
82              if value and not all:              if value and not all:
83                  return value                  return value
84              elif value:              elif value:
# Line 146  for pegdir in pegdirs: Line 146  for pegdir in pegdirs:
146              #conversion have succeeded so far, parsing peg's metadata              #conversion have succeeded so far, parsing peg's metadata
147              #from its document tree              #from its document tree
148              if rstfile == peg['rst']:              if rstfile == peg['rst']:
149                  peg['topic'] = getTagValue(document, 'title')                  peg['topic'] = getTagValue(document, 'title', always_raw=1)
150                  peg['topic'] = peg['topic'].replace('`', '')                  peg['topic'] = peg['topic'].replace('`', '')
151                  peg['date'] = getTagValue(document, 'date')                  peg['date'] = getTagValue(document, 'date')
152                  #we may have got 'rawsource', which need some tidying                  #we may have got 'rawsource', which needs some tidying
153                  if peg['date'].startswith('$Date'):                  if peg['date'].startswith('$Date'):
154                      peg['date'] = peg['date'][7:len(peg['date'])-11].replace('/', '-')                      peg['date'] = peg['date'][7:len(peg['date'])-11].replace('/', '-')
155                  peg['status'] = getTagValue(document, 'status') or undefined                  peg['status'] = getTagValue(document, 'status') or undefined

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11

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