summaryrefslogtreecommitdiff
path: root/bitbake/lib/bb/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb/__init__.py')
-rw-r--r--bitbake/lib/bb/__init__.py92
1 files changed, 49 insertions, 43 deletions
diff --git a/bitbake/lib/bb/__init__.py b/bitbake/lib/bb/__init__.py
index c7cd0f62d..88adfc1df 100644
--- a/bitbake/lib/bb/__init__.py
+++ b/bitbake/lib/bb/__init__.py
@@ -21,39 +21,14 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-__version__ = "1.9.0"
-
-__all__ = [
-
- "debug",
- "note",
- "error",
- "fatal",
-
- "mkdirhier",
- "movefile",
- "vercmp",
-
-# fetch
- "decodeurl",
- "encodeurl",
-
-# modules
- "parse",
- "data",
- "command",
- "event",
- "build",
- "fetch",
- "manifest",
- "methodpool",
- "cache",
- "runqueue",
- "taskdata",
- "providers",
- ]
-
-import sys, os, types, re, string
+__version__ = "1.11.0"
+
+import sys
+if sys.version_info < (2, 6, 0):
+ raise RuntimeError("Sorry, python 2.6.0 or later is required for this version of bitbake")
+
+import os
+import bb.msg
if "BBDEBUG" in os.environ:
level = int(os.environ["BBDEBUG"])
@@ -81,14 +56,45 @@ def fatal(*args):
bb.msg.fatal(None, ''.join(args))
-# For compatibility
-from bb.fetch import MalformedUrl, encodeurl, decodeurl
-from bb.data import VarExpandError
-from bb.utils import mkdirhier, movefile, copyfile, which
-from bb.utils import vercmp
+def deprecated(func, name = None, advice = ""):
+ """This is a decorator which can be used to mark functions
+ as deprecated. It will result in a warning being emmitted
+ when the function is used."""
+ import warnings
+
+ if advice:
+ advice = ": %s" % advice
+ if name is None:
+ name = func.__name__
+
+ def newFunc(*args, **kwargs):
+ warnings.warn("Call to deprecated function %s%s." % (name,
+ advice),
+ category = PendingDeprecationWarning,
+ stacklevel = 2)
+ return func(*args, **kwargs)
+ newFunc.__name__ = func.__name__
+ newFunc.__doc__ = func.__doc__
+ newFunc.__dict__.update(func.__dict__)
+ return newFunc
-
-if __name__ == "__main__":
- import doctest, bb
- bb.msg.set_debug_level(0)
- doctest.testmod(bb)
+# For compatibility
+def deprecate_import(current, modulename, fromlist, renames = None):
+ """Import objects from one module into another, wrapping them with a DeprecationWarning"""
+ import sys
+
+ module = __import__(modulename, fromlist = fromlist)
+ for position, objname in enumerate(fromlist):
+ obj = getattr(module, objname)
+ newobj = deprecated(obj, "{0}.{1}".format(current, objname),
+ "Please use {0}.{1} instead".format(modulename, objname))
+ if renames:
+ newname = renames[position]
+ else:
+ newname = objname
+
+ setattr(sys.modules[current], newname, newobj)
+
+deprecate_import(__name__, "bb.fetch", ("MalformedUrl", "encodeurl", "decodeurl"))
+deprecate_import(__name__, "bb.utils", ("mkdirhier", "movefile", "copyfile", "which"))
+deprecate_import(__name__, "bb.utils", ["vercmp_string"], ["vercmp"])