def final(self): yield tuple('c' + str(i) for i in range(1, self.numofargs)) for groupkey, sumcols in self.groupsdict.items(): cols = list(groupkey) # print(cols) for col in sumcols: try: cols.append(sum(col)) except TypeError: cols.append(jopts.toj(sorted(set(jopts.fromj(*col))))) yield cols
def regexpr(*args): """ .. function:: regexp(pattern,expression[,replacestr]) This function returns a match to the first parenthesis of *pattern* or replaces the matches of *pattern* in *expression* with *replacestr*. `Pattern Syntax <http://docs.python.org/library/re.html#re-syntax>`_ is according to python's re module. Examples use `inversion`. Examples: >>> table1(''' ... 25 ... ''') >>> sql("regexpr 'start\s(\w+)\send' 'start otherword end' ") regexpr('start\s(\w+)\send','start otherword end') -------------------------------------------------- otherword >>> sql("regexpr '\W+' '@#$%@$#% tobereplaced @#$%@#$%' 'nonword' ") regexpr('\W+','@#$%@$#% tobereplaced @#$%@#$%','nonword') --------------------------------------------------------- nonwordtobereplacednonword >>> sql("select regexpr('(\w+).*?(\w+)', 'one two three')") regexpr('(\w+).*?(\w+)', 'one two three') ----------------------------------------- ["one","two"] """ if len(args) < 2: return if len(args) == 2: a = re.search(args[0], str(args[1]), re.UNICODE) if a != None: if len(a.groups()) > 0: return jopts.toj(a.groups()) else: return True else: return None if len(args) == 3: try: return re.sub(args[0], args[2], args[1], flags=re.UNICODE) except TypeError: return re.sub(args[0], args[2], args[1])
def final(self): yield tuple(['C' + str(i) for i in range(1, self.lenargs)]) yield [jopts.toj(list(i)) for i in self.vals]
def final(self): return jopts.toj(self.outgroup)