File: petl

package info (click to toggle)
python-petl 1.7.17-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,224 kB
  • sloc: python: 22,617; makefile: 109; xml: 9
file content (31 lines) | stat: -rwxr-xr-x 730 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env python

from __future__ import print_function, division, absolute_import
import sys
import os
import os.path
import glob
from optparse import OptionParser

from petl import __version__
from petl import *

parser = OptionParser(
    usage="%prog [options] expression",
    description="Evaluate a Python expression.  The expression will be "
                "evaluated using eval(), with petl functions imported.",
    version=__version__)

options, args = parser.parse_args()

try:
    (expression,) = args
except ValueError:
    parser.error("invalid number of arguments (%s)" % len(args))
r = eval(expression)

if r is not None:
    if isinstance(r, Table):
        print(look(r))
    else:
        print(str(r))