def process_query(l, scan_id, scans): lhs, rhs = l.split("=") if lhs in scans[scan_id]: raise ValueError("%s already in scans[%d]" % (lhs, scan_id)) if lhs == 'title': scans[scan_id][lhs] = urllib.unquote(rhs) else: scans[scan_id][lhs] = parse_string(rhs)
def process_query(l, scan_id, scans): lhs, rhs = l.split("=") if lhs in scans[scan_id]: raise ValueError( "%s already in scans[%d]" % (lhs, scan_id)) if lhs == 'title': scans[scan_id][lhs] = urllib.unquote(rhs) else: scans[scan_id][lhs] = parse_string(rhs)
def process_query(self, l): lhs, rhs = l.split("=") if lhs in self.scans[self.scan_id]: raise ValueError("%s already in scans[%d]" % (lhs, self.scan_id)) if lhs == 'title': self.scans[self.scan_id]['title'] = urllib.unquote(rhs) elif lhs == 'Ions1': pairs = [piece.split(':') for piece in rhs.split(',')] ions = [[float(x), float(y)] for x, y in pairs] self.scans[self.scan_id]['Ions1'] = ions else: self.scans[self.scan_id][lhs] = parse_string(rhs)
def process_query(self, l): lhs, rhs = l.split("=") if lhs in self.scans[self.scan_id]: raise ValueError( "%s already in scans[%d]" % (lhs, self.scan_id)) if lhs == 'title': self.scans[self.scan_id]['title'] = urllib.unquote(rhs) elif lhs == 'Ions1': pairs = [piece.split(':') for piece in rhs.split(',')] ions = [[float(x),float(y)] for x,y in pairs] self.scans[self.scan_id]['Ions1'] = ions else: self.scans[self.scan_id][lhs] = parse_string(rhs)
def read_tsv_iter(tsv_txt): """ Reads a title top TSV file, converts all keys to lower case and returns a list of dictionaries. """ f = open(tsv_txt, "UR") titles = [w.lower() for w in parse.split_tab(f.readline())] results = [] for line in f: group = {} for key, val in zip(titles, parse.split_tab(line)): group[key] = parse.parse_string(val) yield group del group
from parse import parse_string, PyTreeVisitor code = """\ # toplevel comments def f(x:int) -> int: # condition, (inner comments) if x == 0: return 1 else: return x * f(x - 1) """ t = parse_string(code) visitor = PyTreeVisitor() visitor.visit(t)