示例#1
0
文件: builtin.py 项目: Jmos/pysh
def pycmd_orderby(args, input, options):
  assert len(args) == 2 or len(args) == 3
  table = CreateTableFromIterableRows(input)
  asc = True
  if len(args) == 3:
    args2 = args[2].lower()
    if args2 == 'desc':
      asc = False
    elif args2 != 'asc':
      raise Exception('args[2] must be desc or asc.')
  return table.orderby(args[1], asc, options.globals(), options.locals())
示例#2
0
文件: builtin.py 项目: rootAir/pysh
def pycmd_orderby(args, input, options):
    assert len(args) == 2 or len(args) == 3
    table = CreateTableFromIterableRows(input)
    asc = True
    if len(args) == 3:
        args2 = args[2].lower()
        if args2 == 'desc':
            asc = False
        elif args2 != 'asc':
            raise Exception('args[2] must be desc or asc.')
    return table.orderby(args[1], asc, options.globals(), options.locals())
示例#3
0
文件: builtin.py 项目: rootAir/pysh
def pycmd_tocsv(args, input, options):
    table = CreateTableFromIterableRows(input)
    io = StringIO.StringIO()
    w = csv.writer(io)
    w.writerow(table.columns)
    for row in table:
        w.writerow(row.values())
    return io.getvalue().split('\r\n')[:-1]
示例#4
0
文件: builtin.py 项目: Jmos/pysh
def pycmd_where(args, input, options):
  assert len(args) == 2
  table = CreateTableFromIterableRows(input)
  return table.where(args[1], options.globals(), options.locals())
示例#5
0
文件: builtin.py 项目: rootAir/pysh
def pycmd_where(args, input, options):
    assert len(args) == 2
    table = CreateTableFromIterableRows(input)
    return table.where(args[1], options.globals(), options.locals())