예제 #1
0
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)
예제 #2
0
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)
예제 #3
0
 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)
예제 #4
0
파일: mascot.py 프로젝트: boscoh/peptagram
 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)
예제 #5
0
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
예제 #6
0
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
예제 #7
0
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)