aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/bb/__init__.py6
-rw-r--r--lib/bb/data.py163
-rw-r--r--lib/bb/fetch/__init__.py30
-rw-r--r--lib/bb/utils.py20
4 files changed, 14 insertions, 205 deletions
diff --git a/lib/bb/__init__.py b/lib/bb/__init__.py
index 61973c38a..3ba6beb2c 100644
--- a/lib/bb/__init__.py
+++ b/lib/bb/__init__.py
@@ -86,9 +86,3 @@ 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_string as vercmp
-
-
-if __name__ == "__main__":
- import doctest, bb
- bb.msg.set_debug_level(0)
- doctest.testmod(bb)
diff --git a/lib/bb/data.py b/lib/bb/data.py
index c3bb1a1f4..1064178e5 100644
--- a/lib/bb/data.py
+++ b/lib/bb/data.py
@@ -77,90 +77,33 @@ def initVar(var, d):
def setVar(var, value, d):
- """Set a variable to a given value
-
- Example:
- >>> d = init()
- >>> setVar('TEST', 'testcontents', d)
- >>> print getVar('TEST', d)
- testcontents
- """
+ """Set a variable to a given value"""
d.setVar(var,value)
def getVar(var, d, exp = 0):
- """Gets the value of a variable
-
- Example:
- >>> d = init()
- >>> setVar('TEST', 'testcontents', d)
- >>> print getVar('TEST', d)
- testcontents
- """
+ """Gets the value of a variable"""
return d.getVar(var,exp)
def renameVar(key, newkey, d):
- """Renames a variable from key to newkey
-
- Example:
- >>> d = init()
- >>> setVar('TEST', 'testcontents', d)
- >>> renameVar('TEST', 'TEST2', d)
- >>> print getVar('TEST2', d)
- testcontents
- """
+ """Renames a variable from key to newkey"""
d.renameVar(key, newkey)
def delVar(var, d):
- """Removes a variable from the data set
-
- Example:
- >>> d = init()
- >>> setVar('TEST', 'testcontents', d)
- >>> print getVar('TEST', d)
- testcontents
- >>> delVar('TEST', d)
- >>> print getVar('TEST', d)
- None
- """
+ """Removes a variable from the data set"""
d.delVar(var)
def setVarFlag(var, flag, flagvalue, d):
- """Set a flag for a given variable to a given value
-
- Example:
- >>> d = init()
- >>> setVarFlag('TEST', 'python', 1, d)
- >>> print getVarFlag('TEST', 'python', d)
- 1
- """
+ """Set a flag for a given variable to a given value"""
d.setVarFlag(var,flag,flagvalue)
def getVarFlag(var, flag, d):
- """Gets given flag from given var
-
- Example:
- >>> d = init()
- >>> setVarFlag('TEST', 'python', 1, d)
- >>> print getVarFlag('TEST', 'python', d)
- 1
- """
+ """Gets given flag from given var"""
return d.getVarFlag(var,flag)
def delVarFlag(var, flag, d):
- """Removes a given flag from the variable's flags
-
- Example:
- >>> d = init()
- >>> setVarFlag('TEST', 'testflag', 1, d)
- >>> print getVarFlag('TEST', 'testflag', d)
- 1
- >>> delVarFlag('TEST', 'testflag', d)
- >>> print getVarFlag('TEST', 'testflag', d)
- None
-
- """
+ """Removes a given flag from the variable's flags"""
d.delVarFlag(var,flag)
def setVarFlags(var, flags, d):
@@ -170,54 +113,19 @@ def setVarFlags(var, flags, d):
setVarFlags will not clear previous
flags. Think of this method as
addVarFlags
-
- Example:
- >>> d = init()
- >>> myflags = {}
- >>> myflags['test'] = 'blah'
- >>> setVarFlags('TEST', myflags, d)
- >>> print getVarFlag('TEST', 'test', d)
- blah
"""
d.setVarFlags(var,flags)
def getVarFlags(var, d):
- """Gets a variable's flags
-
- Example:
- >>> d = init()
- >>> setVarFlag('TEST', 'test', 'blah', d)
- >>> print getVarFlags('TEST', d)['test']
- blah
- """
+ """Gets a variable's flags"""
return d.getVarFlags(var)
def delVarFlags(var, d):
- """Removes a variable's flags
-
- Example:
- >>> data = init()
- >>> setVarFlag('TEST', 'testflag', 1, data)
- >>> print getVarFlag('TEST', 'testflag', data)
- 1
- >>> delVarFlags('TEST', data)
- >>> print getVarFlags('TEST', data)
- None
-
- """
+ """Removes a variable's flags"""
d.delVarFlags(var)
def keys(d):
- """Return a list of keys in d
-
- Example:
- >>> d = init()
- >>> setVar('TEST', 1, d)
- >>> setVar('MOO' , 2, d)
- >>> setVarFlag('TEST', 'test', 1, d)
- >>> keys(d)
- ['TEST', 'MOO']
- """
+ """Return a list of keys in d"""
return d.keys()
def getData(d):
@@ -253,32 +161,7 @@ __expand_var_regexp__ = re.compile(r"\${[^{}]+}")
__expand_python_regexp__ = re.compile(r"\${@.+?}")
def expand(s, d, varname = None):
- """Variable expansion using the data store.
-
- Example:
- Standard expansion:
- >>> d = init()
- >>> setVar('A', 'sshd', d)
- >>> print expand('/usr/bin/${A}', d)
- /usr/bin/sshd
-
- Python expansion:
- >>> d = init()
- >>> print expand('result: ${@37 * 72}', d)
- result: 2664
-
- Shell expansion:
- >>> d = init()
- >>> print expand('${TARGET_MOO}', d)
- ${TARGET_MOO}
- >>> setVar('TARGET_MOO', 'yupp', d)
- >>> print expand('${TARGET_MOO}',d)
- yupp
- >>> setVar('SRC_URI', 'http://somebug.${TARGET_MOO}', d)
- >>> delVar('TARGET_MOO', d)
- >>> print expand('${SRC_URI}', d)
- http://somebug.${TARGET_MOO}
- """
+ """Variable expansion using the data store"""
return d.expand(s, varname)
def expandKeys(alterdata, readdata = None):
@@ -304,17 +187,8 @@ def expandKeys(alterdata, readdata = None):
def expandData(alterdata, readdata = None):
"""For each variable in alterdata, expand it, and update the var contents.
- Replacements use data from readdata.
-
- Example:
- >>> a=init()
- >>> b=init()
- >>> setVar("dlmsg", "dl_dir is ${DL_DIR}", a)
- >>> setVar("DL_DIR", "/path/to/whatever", b)
- >>> expandData(a, b)
- >>> print getVar("dlmsg", a)
- dl_dir is /path/to/whatever
- """
+ Replacements use data from readdata
+ """
if readdata == None:
readdata = alterdata
@@ -552,14 +426,3 @@ def inherits_class(klass, d):
if os.path.join('classes', '%s.bbclass' % klass) in val:
return True
return False
-
-def _test():
- """Start a doctest run on this module"""
- import doctest
- import bb
- from bb import data
- bb.msg.set_debug_level(0)
- doctest.testmod(data)
-
-if __name__ == "__main__":
- _test()
diff --git a/lib/bb/fetch/__init__.py b/lib/bb/fetch/__init__.py
index dbc9c8b51..9351a6d37 100644
--- a/lib/bb/fetch/__init__.py
+++ b/lib/bb/fetch/__init__.py
@@ -53,21 +53,6 @@ class InvalidSRCREV(Exception):
def decodeurl(url):
"""Decodes an URL into the tokens (scheme, network location, path,
user, password, parameters).
-
- >>> decodeurl("http://www.google.com/index.html")
- ('http', 'www.google.com', '/index.html', '', '', {})
-
- CVS url with username, host and cvsroot. The cvs module to check out is in the
- parameters:
-
- >>> decodeurl("cvs://anoncvs@cvs.handhelds.org/cvs;module=familiar/dist/ipkg")
- ('cvs', 'cvs.handhelds.org', '/cvs', 'anoncvs', '', {'module': 'familiar/dist/ipkg'})
-
- Dito, but this time the username has a password part. And we also request a special tag
- to check out.
-
- >>> decodeurl("cvs://anoncvs:anonymous@cvs.handhelds.org/cvs;module=familiar/dist/ipkg;tag=V0-99-81")
- ('cvs', 'cvs.handhelds.org', '/cvs', 'anoncvs', 'anonymous', {'tag': 'V0-99-81', 'module': 'familiar/dist/ipkg'})
"""
m = re.compile('(?P<type>[^:]*)://((?P<user>.+)@)?(?P<location>[^;]+)(;(?P<parm>.*))?').match(url)
@@ -108,21 +93,6 @@ def decodeurl(url):
def encodeurl(decoded):
"""Encodes a URL from tokens (scheme, network location, path,
user, password, parameters).
-
- >>> encodeurl(['http', 'www.google.com', '/index.html', '', '', {}])
- 'http://www.google.com/index.html'
-
- CVS with username, host and cvsroot. The cvs module to check out is in the
- parameters:
-
- >>> encodeurl(['cvs', 'cvs.handhelds.org', '/cvs', 'anoncvs', '', {'module': 'familiar/dist/ipkg'}])
- 'cvs://anoncvs@cvs.handhelds.org/cvs;module=familiar/dist/ipkg'
-
- Dito, but this time the username has a password part. And we also request a special tag
- to check out.
-
- >>> encodeurl(['cvs', 'cvs.handhelds.org', '/cvs', 'anoncvs', 'anonymous', {'tag': 'V0-99-81', 'module': 'familiar/dist/ipkg'}])
- 'cvs://anoncvs:anonymous@cvs.handhelds.org/cvs;tag=V0-99-81;module=familiar/dist/ipkg'
"""
(type, host, path, user, pswd, p) = decoded
diff --git a/lib/bb/utils.py b/lib/bb/utils.py
index 477c48823..83d05aaa7 100644
--- a/lib/bb/utils.py
+++ b/lib/bb/utils.py
@@ -97,14 +97,7 @@ _package_ends_ = ["pre", "p", "alpha", "beta", "rc", "cvs", "bk", "HEAD" ]
def relparse(myver):
"""Parses the last elements of a version number into a triplet, that can
- later be compared:
-
- >>> relparse('1.2_pre3')
- [1.2, -2, 3.0]
- >>> relparse('1.2b')
- [1.2, 98, 0]
- >>> relparse('1.2')
- [1.2, 0, 0]
+ later be compared.
"""
number = 0
@@ -150,17 +143,6 @@ __vercmp_cache__ = {}
def vercmp_string(val1,val2):
"""This takes two version strings and returns an integer to tell you whether
the versions are the same, val1>val2 or val2>val1.
-
- >>> vercmp('1', '2')
- -1.0
- >>> vercmp('2', '1')
- 1.0
- >>> vercmp('1', '1.0')
- 0
- >>> vercmp('1', '1.1')
- -1.0
- >>> vercmp('1.1', '1_p2')
- 1.0
"""
# quick short-circuit