summaryrefslogtreecommitdiff
path: root/freebase
diff options
context:
space:
mode:
Diffstat (limited to 'freebase')
-rwxr-xr-xfreebase/fcl/commands.py9
-rwxr-xr-xfreebase/fcl/fcl.py14
-rwxr-xr-xfreebase/fcl/inspection.py (renamed from freebase/fcl/inspect.py)0
-rw-r--r--freebase/fcl/schema.py2
4 files changed, 20 insertions, 5 deletions
diff --git a/freebase/fcl/commands.py b/freebase/fcl/commands.py
index bb31d19..73b649e 100755
--- a/freebase/fcl/commands.py
+++ b/freebase/fcl/commands.py
@@ -30,7 +30,10 @@ import os, sys, re, time
from fbutil import *
from cmdutil import *
-import simplejson
+try:
+ import simplejson as json
+except ImportError:
+ import json
import freebase.rison as rison
from freebase.api import attrdict
@@ -410,9 +413,9 @@ def cmd_dump(fb, id):
"""
id = fb.absid(id)
- import inspect
+ import inspection
- r = inspect.inspect_object(fb.mss, id)
+ r = inspection.inspect_object(fb.mss, id)
if r is None:
raise CmdException('no match for id %r' % id)
diff --git a/freebase/fcl/fcl.py b/freebase/fcl/fcl.py
index 2b30b56..812b7fe 100755
--- a/freebase/fcl/fcl.py
+++ b/freebase/fcl/fcl.py
@@ -33,7 +33,12 @@ from optparse import OptionParser
import getpass
import cookielib
import logging
-import simplejson
+import inspect
+
+try:
+ import simplejson as json
+except ImportError:
+ import json
from cmdutil import CmdException, log, out
@@ -182,6 +187,13 @@ class FclCommandHandler(object):
def dispatch(self, cmd, args, kws):
try:
+ spec = inspect.getargspec(cmd.func)
+ required = len(spec.args) - len(spec.defaults or ())
+ if len(args) < (required-1):
+ sys.stderr.write("%s: arguments \"%s\" required\n" %
+ (cmd.func.__name__,
+ '\", \"'.join(spec.args[1:required])))
+ sys.exit(1)
cmd.func(self, *args, **kws)
# flush the output
diff --git a/freebase/fcl/inspect.py b/freebase/fcl/inspection.py
index 8cd04d2..8cd04d2 100755
--- a/freebase/fcl/inspect.py
+++ b/freebase/fcl/inspection.py
diff --git a/freebase/fcl/schema.py b/freebase/fcl/schema.py
index 47eb1fa..e10e72a 100644
--- a/freebase/fcl/schema.py
+++ b/freebase/fcl/schema.py
@@ -28,7 +28,7 @@ def cmd_dump_type(fb, baseid, follow_types=True):
"""
print >> sys.stdout, json.dumps(dump_type(fb.mss, typeid, follow_types), indent=2)
-def cmd_restore(fb, newlocation, graphfile):
+def cmd_restore(fb, newlocation=None, graphfile=None):
"""restore a graph object to the graph
%prog restore newlocation graphfile