c27323a6bd91dfd478e0b3e0de023f74e0260c36
wong
  Tue Jan 10 14:59:49 2012 -0800
fixed a bug handling comments internal to stanzas
diff --git python/lib/ucscgenomics/ra.py python/lib/ucscgenomics/ra.py
index ebf8663..0d0dc19 100644
--- python/lib/ucscgenomics/ra.py
+++ python/lib/ucscgenomics/ra.py
@@ -115,30 +115,31 @@
                 if entry != None:
                     if name != None or key == None:
                         if name in self:
                             raise KeyError('Duplicate Key ' + name)
                         self[name] = entry
 
                 stanza = list()
 
         file.close()
 
 
     def readStanza(self, stanza, key=None):
         entry = RaStanza()
         if entry.readStanza(stanza, key) == None:
             return None, None, None
+        entry = RaStanza()
         val1, val2 = entry.readStanza(stanza, key)
         return val1, val2, entry
 
 
     def iter(self):
         pass
 
 
     def iterkeys(self):
         for item in self._OrderedDict__ordering:
             if not(item.startswith('#') or item == ''):
                 yield item
 
 
     def itervalues(self):
@@ -223,32 +224,35 @@
         newCommon = RaFile()
         p = re.compile('^\s*#')
         p2 = re.compile('^\s*$')
         for i in mergedKeys:
             if p.match(i) or p2.match(i):
                 newCommon.append(i)
                 continue
             if i not in selfKeys:
                 newCommon.append(other[i])
             if i not in otherKeys:
                 newCommon.append(self[i])
             if i in otherKeys and i in selfKeys:
                 newStanza = RaStanza()
                 selfStanzaKeys = set(self[i].iterkeys())
                 otherStanzaKeys = set(other[i].iterkeys())
-                stanzaKeys = ucscUtils.mergeList(list(self[i].iterkeys()), list(other[i].iterkeys()))
+                stanzaKeys = ucscUtils.mergeList(list(self[i]), list(other[i]))
                 for j in stanzaKeys:
+                    if p.match(j):
+                        newStanza.append(j)
+                        continue
                     if j not in selfStanzaKeys:
                         newStanza[j] = other[i][j]
                     if j not in otherStanzaKeys:
                         newStanza[j] = self[i][j]
                     if j in selfStanzaKeys and j in otherStanzaKeys:
                         if self[i][j] == other[i][j]:
                             newStanza[j] = self[i][j]
                         else:
                             in_j = '>>>>>%s' % j
                             out_j = '<<<<<%s' % j
                             newStanza[out_j] = self[i][j]
                             newStanza[in_j] = other[i][j]
             newCommon.append(newStanza)
         return newCommon