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))
|