Ignore:
Timestamp:
28/09/15 17:47:08 (5 years ago)
Author:
mjuckes
Message:

miscellaneous cleaning for 01.beta

File:
1 edited

Legend:

Unmodified
Added
Removed
  • CMIP6dreq/trunk/src/dreq.py

    r390 r394  
    5959             if a[0] != '_' or full: 
    6060               if self._a[a].rClass == 'internalLink' and self._base._indexInitialised: 
    61                  targ = self._base._inx.uid[ self.__dict__[a] ][1] 
     61                 targ = self._base._inx.uid[ self.__dict__[a] ] 
    6262                 print '   %s: [%s]%s [%s]' % ( a, targ._h.label, targ.label, self.__dict__[a] ) 
    6363               else: 
     
    9090                   m = '<li>%s: %s [missing link]</li>' % ( a, self.__dict__[a] ) 
    9191                 else: 
    92                    targ = self._base._inx.uid[ self.__dict__[a] ][1] 
     92                   targ = self._base._inx.uid[ self.__dict__[a] ] 
    9393                   m = '<li>%s: [%s] %s [%s]</li>' % ( a, targ._h.label, targ.label, targ.__href__() ) 
    9494               else: 
     
    113113                   am.append( '<h3>%s</h3>' % t ) 
    114114                   am.append( '<ul>' ) 
    115                    items = [self._inx.uid[u][1] for  u in self._inx.iref_by_sect[self.uid].a[t] ] 
     115                   items = [self._inx.uid[u] for  u in self._inx.iref_by_sect[self.uid].a[t] ] 
    116116                   items.sort( ds('label').cmp ) 
    117117                   for targ in items: 
     
    244244      tables[t[0].label] = t 
    245245      self.tableClasses[t[0].label] = self.itemClassFact( t, ns=self.ns ) 
    246  
    247246 
    248247    self.recordAttributeDefn = tables 
     
    314313object._a: a python dictionary defining the attributes in each record. The keys in the dictionary correspond to the attribute names and the values are python "named tuples" (from the "collections" module). E.g. object._a['priority'].type contains the type of the 'priority' attribute. Type is expressed using XSD schema language, so "xs:integer" implies integer.  The "rClass" attribute carries information about usage. If object._a['xxx'].rClass = u'internalLink' then the record attribute provides a link to another element and object.xxx is the unique identifier of that element. 
    315314 
    316 object._h: a python named tuple describing the section. E.g. object.parent.header.title is the section title (E.g. "CMOR Variables") 
     315object._h: a python named tuple describing the section. E.g. object._h.title is the section title (E.g. "CMOR Variables") 
    317316""" 
    318317       _base=dreqItemBase 
    319318        
     319     dreqItem.__name__ = 'dreqItem_%s' % str( sectionInfo.header.label ) 
    320320     dreqItem._h = sectionInfo.header 
    321321     dreqItem._a = sectionInfo.attributes 
     
    404404            self.uid2[i.uid].append( (k,i) ) 
    405405          else: 
    406             self.uid[i.uid] = (k,i) 
     406### create index bx uid. 
     407            self.uid[i.uid] = i 
    407408 
    408409    self.missingIds = collections.defaultdict( list ) 
     
    416417            if id2 != '__unset__': 
    417418              sect = i._h.label 
    418               self.iref_by_uid[ id2 ].append( (sect,i.uid) ) 
     419## append attribute name and target  -- item i.uid, attribute k2 reference item id2 
     420              self.iref_by_uid[ id2 ].append( (k2,i.uid) ) 
    419421              self.iref_by_sect[ id2 ].a[sect].append( i.uid ) 
    420422              if self.uid.has_key( id2 ): 
     
    443445 
    444446src1 = '../workbook/trial_20150831.xml' 
     447 
     448#DEFAULT LOCATION -- changed automatically when building distribution 
     449defaultDreq = '../docs/dreq.xml' 
     450#DEFAULT CONFIG 
     451defaultConfig = '../docs/dreq2Defn.xml' 
     452 
    445453class loadDreq(object): 
    446   def __init__(self,dreqXML='../docs/dreq.xml',configdoc='../docs/dreq2Defn.xml', useShelve=False ): 
     454  def __init__(self,dreqXML=defaultDreq, configdoc=defaultConfig, useShelve=False ): 
    447455    self.c = config( thisdoc=dreqXML, configdoc=configdoc, useShelve=useShelve) 
    448456    self.coll = self.c.get() 
     
    462470##    dreqItemBase._htmlStyle['__general__'] = {'addRemarks':True} 
    463471 
    464     self.pageTmpl = """<html><head><title>%s</title></head><body>%s</body></html>""" 
     472    self.pageTmpl = """<html><head><title>%s</title> 
     473<link rel="stylesheet" type="text/css" href="%scss/dreq.css"> 
     474</head><body> 
     475<div id="top">CMIP6 Data Request</div> 
     476%s</body></html>""" 
    465477 
    466478  def makeHtml(self,odir='./html'): 
    467479    for k in self.inx.uid.keys(): 
    468       i = self.inx.uid[k][1] 
     480      i = self.inx.uid[k] 
    469481      ttl = 'Data Request Record: [%s]%s' % (i._h.label,i.label) 
    470482      bdy = string.join( i.__html__( ), '\n' ) 
    471483      oo = open( '%s/u/%s.html' % (odir,i.uid), 'w' ) 
    472       oo.write( self.pageTmpl % (ttl, bdy ) ) 
     484      oo.write( self.pageTmpl % (ttl, '../', bdy ) ) 
    473485      oo.close() 
    474486 
     
    491503      bdy = string.join( msg, '\n' ) 
    492504      oo = open( '%s/index/%s.html' % (odir,k), 'w' ) 
    493       oo.write( self.pageTmpl % (ttl, bdy ) ) 
     505      oo.write( self.pageTmpl % (ttl, '../', bdy ) ) 
    494506      oo.close() 
    495507    msg0.append( '</ul>' ) 
    496508    bdy = string.join( msg0, '\n' ) 
    497509    oo = open( '%s/index.html' % odir, 'w' ) 
    498     oo.write( self.pageTmpl % (ttl, bdy ) ) 
     510    oo.write( self.pageTmpl % (ttl0, '', bdy ) ) 
    499511    oo.close() 
    500512     
Note: See TracChangeset for help on using the changeset viewer.