示例#1
0
def PQDescPath(coll, f, lcs):
    f = eval(f, globals(), lcs) if f != '_' else None
    stack = []
    if isList(coll):
        stack = [i for i in flatten(coll)]
    elif isMap(coll):
        stack = [map_tuple(k, v) for (k, v) in coll.items()]

    while stack:
        i = stack.pop()

        if isinstance(i, map_tuple):
            if f is None:
                yield i.value
            elif f and i.key == f:
                yield i.value

            i = i.value

        if isList(i):
            it = iter(i)
            frst = next(it)
            [stack.append(j) for j in it]
            if isList(frst):
                stack.extend([ci for ci in frst])
            elif isMap(frst):
                stack.extend([map_tuple(k, v) for (k, v) in frst.items()])

        elif isMap(i):
            keys = list(i.keys())
            [stack.append(map_tuple(j, i[j])) for j in keys]
示例#2
0
def PQDescPath(coll,f,lcs):
  f = eval(f,globals(),lcs) if f!='_' else None
  stack = []
  if isList(coll):
    stack = [i for i in flatten(coll)]
  elif isMap(coll):
    stack = [map_tuple(k,v) for (k,v) in coll.items()]

  while stack:
    i = stack.pop()

    if isinstance(i,map_tuple):
      if f is None:
        yield i.value
      elif f and i.key==f:
        yield i.value

      i = i.value

    if isList(i):
      it = iter(i)
      frst = next(it)
      [stack.append(j) for j in it]
      if isList(frst):
        stack.extend([ci for ci in frst])
      elif isMap(frst):
        stack.extend([map_tuple(k,v) for (k,v) in frst.items()])

    elif isMap(i):
      keys = list(i.keys())
      [stack.append(map_tuple(j,i[j])) for j in keys]
示例#3
0
def PQChildPath(coll, f, lcs):
    f = eval(str_dec(f), globals(), lcs) if f != '_' else None
    if isList(coll):
        for i in flatten(coll):
            if isMap(i):
                for j in i.keys():
                    if f is None:
                        yield i[j]
                    elif f and j == f:
                        yield i[j]

    if isMap(coll):
        for i in coll.keys():
            if f is None:
                yield coll[i]
            elif f and i == f:
                yield coll[i]
示例#4
0
def PQChildPath (coll,f,lcs):
  f = eval(str_dec(f), globals(), lcs) if f!='_' else None
  if isList(coll):
    for i in flatten(coll):
      if isMap(i):
        for j in i.keys():
          if f is None:
            yield i[j]
          elif f and j==f:
            yield i[j]

  if isMap(coll):
    for i in coll.keys():
      if f is None:
        yield coll[i]
      elif f and i==f:
        yield coll[i]