summaryrefslogtreecommitdiff
path: root/freebase/__init__.py
diff options
context:
space:
mode:
authornitromaster101 <nitromaster101@5914aa95-5b3a-0410-a3b5-7b719e7fe9b2>2009-06-17 19:02:50 +0000
committernitromaster101 <nitromaster101@5914aa95-5b3a-0410-a3b5-7b719e7fe9b2>2009-06-17 19:02:50 +0000
commitdd2da52625e890e29a6fdbba43456dd8475d51ac (patch)
tree1929e92309255c54d0b1bee11489872824f93739 /freebase/__init__.py
parentcf63c2faee674cc40e1b38975ee05125ee09a232 (diff)
reorganize package inorder to emphasize freebase-api as the main one
git-svn-id: http://freebase-python.googlecode.com/svn/trunk@88 5914aa95-5b3a-0410-a3b5-7b719e7fe9b2
Diffstat (limited to 'freebase/__init__.py')
-rwxr-xr-xfreebase/__init__.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/freebase/__init__.py b/freebase/__init__.py
new file mode 100755
index 0000000..3cca4ff
--- /dev/null
+++ b/freebase/__init__.py
@@ -0,0 +1,40 @@
+import sys
+
+from freebase.api.session import HTTPMetawebSession
+import sandbox
+
+__all__ = ["HTTPMetawebSession", "sandbox"]
+
+base = HTTPMetawebSession("freebase.com")
+
+# we want to add base's functions to __init__.py
+# so that we can say freebase.func() and really
+# just call base.func()
+
+# a little trick to refer to __init__
+# self isn't defined because __init__ is in
+# a world in and of itself
+self = sys.modules[__name__]
+
+for funcname in dir(base):
+
+ # we only want the 'real' functions
+ if not funcname.startswith("_"):
+ func = getattr(base, funcname)
+
+ # let's make sure we're getting functions
+ # instead of constants or whatever
+ if callable(func):
+
+ # we're setting these functions
+ # so that they can be called like
+ # freebase.funcname -> base.func()
+ setattr(self, funcname, func)
+
+ # make sure we import the base's
+ # functions if we import freebase
+ __all__.append(funcname)
+
+# we don't want any self-referencing
+# business going. Plus, this is cleaner.
+del self