예제 #1
0
 def update_pada(self,pada,tabstr):
  if pada not in self.padas:
   self.padas.append(pada)
   self.tables[pada] = tabstr
  else:
   # handle duplicates
   toldstr = self.tables[pada]
   told = conjstr_listify(toldstr)
   tnew = conjstr_listify(tabstr)
   for i in xrange(0,len(told)):
    old = told[i] # a list of strings
    new = tnew[i] # ditto
    for x in new:
     if x not in old:
      old.append(x)
    told[i] = old
   self.tables[pada] = prettify(told)
예제 #2
0
 def update_pada(self, pada, tabstr):
     if pada not in self.padas:
         self.padas.append(pada)
         self.tables[pada] = tabstr
     else:
         # handle duplicates
         toldstr = self.tables[pada]
         told = conjstr_listify(toldstr)
         tnew = conjstr_listify(tabstr)
         for i in xrange(0, len(told)):
             old = told[i]  # a list of strings
             new = tnew[i]  # ditto
             for x in new:
                 if x not in old:
                     old.append(x)
             told[i] = old
         self.tables[pada] = prettify(told)
예제 #3
0
 def update_pada(self, kind, pada, tabstr):
     kp = "%s%s" % (kind, pada)
     if kp not in self.kps:
         self.kps.append(kp)
         self.tables[kp] = tabstr
     else:
         # handle duplicates
         toldstr = self.tables[kp]
         told = conjstr_listify(toldstr)
         tnew = conjstr_listify(tabstr)
         for i in xrange(0, len(told)):
             old = told[i]  # a list of strings
             new = tnew[i]  # ditto
             for x in new:
                 if x not in old:
                     old.append(x)
             told[i] = old
         self.tables[kp] = prettify(told)
예제 #4
0
 def update_pada(self,kind,pada,tabstr):
  kp = "%s%s" %(kind,pada)
  if kp not in self.kps:
   self.kps.append(kp)
   self.tables[kp] = tabstr
  else:
   # handle duplicates
   toldstr = self.tables[kp]
   told = conjstr_listify(toldstr)
   tnew = conjstr_listify(tabstr)
   for i in xrange(0,len(told)):
    old = told[i] # a list of strings
    new = tnew[i] # ditto
    for x in new:
     if x not in old:
      old.append(x)
    told[i] = old
   self.tables[kp] = prettify(told)
예제 #5
0
def conjstr_join(tab1str, tab2str):
    """ tab1str, tab2str are in Elisp format
     tablen is length of the tables
     convert the inputs to lists,
     join the lists (element-wise)
     reconstruct lists in Elisp format
 """
    tab1 = conjstr_listify(tab1str)
    tab2 = conjstr_listify(tab2str)
    #print "tab1str=",tab1str,"\ntab2str=",tab2str
    #print "tab1=",tab1,"\ntab2=",tab2
    tablen = len(tab1)
    # join the tab1, tab2 lists
    tab = []
    for i in xrange(0, tablen):
        # assumes each element is a list
        t = tab1[i] + tab2[i]
        tab.append(t)
    #print "tab=",tab
    tabstr = Elisp_serialize(tab, tablen)
    #print "tabstr=",tabstr
    return tabstr
예제 #6
0
def conjstr_join(tab1str,tab2str):
 """ tab1str, tab2str are in Elisp format
     tablen is length of the tables
     convert the inputs to lists,
     join the lists (element-wise)
     reconstruct lists in Elisp format
 """
 tab1 =  conjstr_listify(tab1str)
 tab2 =  conjstr_listify(tab2str)
 #print "tab1str=",tab1str,"\ntab2str=",tab2str
 #print "tab1=",tab1,"\ntab2=",tab2
 tablen = len(tab1)
 # join the tab1, tab2 lists
 tab=[]
 for i in xrange(0,tablen):
  # assumes each element is a list
  t = tab1[i]+tab2[i]
  tab.append(t)
 #print "tab=",tab
 tabstr = Elisp_serialize(tab,tablen)
 #print "tabstr=",tabstr
 return tabstr