summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Larson <chris_larson@mentor.com>2010-04-09 11:49:36 -0700
committerRichard Purdie <rpurdie@linux.intel.com>2010-07-02 15:41:32 +0100
commitbbf83fd988ca3cf9dae7d2b542a11a7c942b1702 (patch)
treeaf91902ea2f1d9132b89a246ac5bb053e956d6bf
parent8306ba50db13eb3adcc0161e120c53c3f7aefe7b (diff)
downloadpoky-bbf83fd988ca3cf9dae7d2b542a11a7c942b1702.tar.gz
Drop doctest, as we aren't utilizing it
We should add back in some proper unit testing. Doctest is rather limited, and we haven't actually made use of it since the original implementation of the datastore when the project started, as far as I'm aware. (Bitbake rev: 3a11c2807972bbbddffde2fa67fc380d159da467) Signed-off-by: Chris Larson <chris_larson@mentor.com> Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
-rw-r--r--bitbake/lib/bb/__init__.py6
-rw-r--r--bitbake/lib/bb/data.py163
-rw-r--r--bitbake/lib/bb/utils.py20
3 files changed, 14 insertions, 175 deletions
diff --git a/bitbake/lib/bb/__init__.py b/bitbake/lib/bb/__init__.py
index 61973c38a9..3ba6beb2c1 100644
--- a/bitbake/lib/bb/__init__.py
+++ b/bitbake/lib/bb/__init__.py
@@ -86,9 +86,3 @@ from bb.fetch import MalformedUrl, encodeurl, decodeurl
86from bb.data import VarExpandError 86from bb.data import VarExpandError
87from bb.utils import mkdirhier, movefile, copyfile, which 87from bb.utils import mkdirhier, movefile, copyfile, which
88from bb.utils import vercmp_string as vercmp 88from bb.utils import vercmp_string as vercmp
89
90
91if __name__ == "__main__":
92 import doctest, bb
93 bb.msg.set_debug_level(0)
94 doctest.testmod(bb)
diff --git a/bitbake/lib/bb/data.py b/bitbake/lib/bb/data.py
index 5938277273..cc5594e41e 100644
--- a/bitbake/lib/bb/data.py
+++ b/bitbake/lib/bb/data.py
@@ -77,90 +77,33 @@ def initVar(var, d):
77 77
78 78
79def setVar(var, value, d): 79def setVar(var, value, d):
80 """Set a variable to a given value 80 """Set a variable to a given value"""
81
82 Example:
83 >>> d = init()
84 >>> setVar('TEST', 'testcontents', d)
85 >>> print getVar('TEST', d)
86 testcontents
87 """
88 d.setVar(var,value) 81 d.setVar(var,value)
89 82
90 83
91def getVar(var, d, exp = 0): 84def getVar(var, d, exp = 0):
92 """Gets the value of a variable 85 """Gets the value of a variable"""
93
94 Example:
95 >>> d = init()
96 >>> setVar('TEST', 'testcontents', d)
97 >>> print getVar('TEST', d)
98 testcontents
99 """
100 return d.getVar(var,exp) 86 return d.getVar(var,exp)
101 87
102 88
103def renameVar(key, newkey, d): 89def renameVar(key, newkey, d):
104 """Renames a variable from key to newkey 90 """Renames a variable from key to newkey"""
105
106 Example:
107 >>> d = init()
108 >>> setVar('TEST', 'testcontents', d)
109 >>> renameVar('TEST', 'TEST2', d)
110 >>> print getVar('TEST2', d)
111 testcontents
112 """
113 d.renameVar(key, newkey) 91 d.renameVar(key, newkey)
114 92
115def delVar(var, d): 93def delVar(var, d):
116 """Removes a variable from the data set 94 """Removes a variable from the data set"""
117
118 Example:
119 >>> d = init()
120 >>> setVar('TEST', 'testcontents', d)
121 >>> print getVar('TEST', d)
122 testcontents
123 >>> delVar('TEST', d)
124 >>> print getVar('TEST', d)
125 None
126 """
127 d.delVar(var) 95 d.delVar(var)
128 96
129def setVarFlag(var, flag, flagvalue, d): 97def setVarFlag(var, flag, flagvalue, d):
130 """Set a flag for a given variable to a given value 98 """Set a flag for a given variable to a given value"""
131
132 Example:
133 >>> d = init()
134 >>> setVarFlag('TEST', 'python', 1, d)
135 >>> print getVarFlag('TEST', 'python', d)
136 1
137 """
138 d.setVarFlag(var,flag,flagvalue) 99 d.setVarFlag(var,flag,flagvalue)
139 100
140def getVarFlag(var, flag, d): 101def getVarFlag(var, flag, d):
141 """Gets given flag from given var 102 """Gets given flag from given var"""
142
143 Example:
144 >>> d = init()
145 >>> setVarFlag('TEST', 'python', 1, d)
146 >>> print getVarFlag('TEST', 'python', d)
147 1
148 """
149 return d.getVarFlag(var,flag) 103 return d.getVarFlag(var,flag)
150 104
151def delVarFlag(var, flag, d): 105def delVarFlag(var, flag, d):
152 """Removes a given flag from the variable's flags 106 """Removes a given flag from the variable's flags"""
153
154 Example:
155 >>> d = init()
156 >>> setVarFlag('TEST', 'testflag', 1, d)
157 >>> print getVarFlag('TEST', 'testflag', d)
158 1
159 >>> delVarFlag('TEST', 'testflag', d)
160 >>> print getVarFlag('TEST', 'testflag', d)
161 None
162
163 """
164 d.delVarFlag(var,flag) 107 d.delVarFlag(var,flag)
165 108
166def setVarFlags(var, flags, d): 109def setVarFlags(var, flags, d):
@@ -170,54 +113,19 @@ def setVarFlags(var, flags, d):
170 setVarFlags will not clear previous 113 setVarFlags will not clear previous
171 flags. Think of this method as 114 flags. Think of this method as
172 addVarFlags 115 addVarFlags
173
174 Example:
175 >>> d = init()
176 >>> myflags = {}
177 >>> myflags['test'] = 'blah'
178 >>> setVarFlags('TEST', myflags, d)
179 >>> print getVarFlag('TEST', 'test', d)
180 blah
181 """ 116 """
182 d.setVarFlags(var,flags) 117 d.setVarFlags(var,flags)
183 118
184def getVarFlags(var, d): 119def getVarFlags(var, d):
185 """Gets a variable's flags 120 """Gets a variable's flags"""
186
187 Example:
188 >>> d = init()
189 >>> setVarFlag('TEST', 'test', 'blah', d)
190 >>> print getVarFlags('TEST', d)['test']
191 blah
192 """
193 return d.getVarFlags(var) 121 return d.getVarFlags(var)
194 122
195def delVarFlags(var, d): 123def delVarFlags(var, d):
196 """Removes a variable's flags 124 """Removes a variable's flags"""
197
198 Example:
199 >>> data = init()
200 >>> setVarFlag('TEST', 'testflag', 1, data)
201 >>> print getVarFlag('TEST', 'testflag', data)
202 1
203 >>> delVarFlags('TEST', data)
204 >>> print getVarFlags('TEST', data)
205 None
206
207 """
208 d.delVarFlags(var) 125 d.delVarFlags(var)
209 126
210def keys(d): 127def keys(d):
211 """Return a list of keys in d 128 """Return a list of keys in d"""
212
213 Example:
214 >>> d = init()
215 >>> setVar('TEST', 1, d)
216 >>> setVar('MOO' , 2, d)
217 >>> setVarFlag('TEST', 'test', 1, d)
218 >>> keys(d)
219 ['TEST', 'MOO']
220 """
221 return d.keys() 129 return d.keys()
222 130
223def getData(d): 131def getData(d):
@@ -253,32 +161,7 @@ __expand_var_regexp__ = re.compile(r"\${[^{}]+}")
253__expand_python_regexp__ = re.compile(r"\${@.+?}") 161__expand_python_regexp__ = re.compile(r"\${@.+?}")
254 162
255def expand(s, d, varname = None): 163def expand(s, d, varname = None):
256 """Variable expansion using the data store. 164 """Variable expansion using the data store"""
257
258 Example:
259 Standard expansion:
260 >>> d = init()
261 >>> setVar('A', 'sshd', d)
262 >>> print expand('/usr/bin/${A}', d)
263 /usr/bin/sshd
264
265 Python expansion:
266 >>> d = init()
267 >>> print expand('result: ${@37 * 72}', d)
268 result: 2664
269
270 Shell expansion:
271 >>> d = init()
272 >>> print expand('${TARGET_MOO}', d)
273 ${TARGET_MOO}
274 >>> setVar('TARGET_MOO', 'yupp', d)
275 >>> print expand('${TARGET_MOO}',d)
276 yupp
277 >>> setVar('SRC_URI', 'http://somebug.${TARGET_MOO}', d)
278 >>> delVar('TARGET_MOO', d)
279 >>> print expand('${SRC_URI}', d)
280 http://somebug.${TARGET_MOO}
281 """
282 return d.expand(s, varname) 165 return d.expand(s, varname)
283 166
284def expandKeys(alterdata, readdata = None): 167def expandKeys(alterdata, readdata = None):
@@ -304,17 +187,8 @@ def expandKeys(alterdata, readdata = None):
304 187
305def expandData(alterdata, readdata = None): 188def expandData(alterdata, readdata = None):
306 """For each variable in alterdata, expand it, and update the var contents. 189 """For each variable in alterdata, expand it, and update the var contents.
307 Replacements use data from readdata. 190 Replacements use data from readdata
308 191 """
309 Example:
310 >>> a=init()
311 >>> b=init()
312 >>> setVar("dlmsg", "dl_dir is ${DL_DIR}", a)
313 >>> setVar("DL_DIR", "/path/to/whatever", b)
314 >>> expandData(a, b)
315 >>> print getVar("dlmsg", a)
316 dl_dir is /path/to/whatever
317 """
318 if readdata == None: 192 if readdata == None:
319 readdata = alterdata 193 readdata = alterdata
320 194
@@ -418,14 +292,3 @@ def inherits_class(klass, d):
418 if os.path.join('classes', '%s.bbclass' % klass) in val: 292 if os.path.join('classes', '%s.bbclass' % klass) in val:
419 return True 293 return True
420 return False 294 return False
421
422def _test():
423 """Start a doctest run on this module"""
424 import doctest
425 import bb
426 from bb import data
427 bb.msg.set_debug_level(0)
428 doctest.testmod(data)
429
430if __name__ == "__main__":
431 _test()
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
index eee97276a2..5015ee440a 100644
--- a/bitbake/lib/bb/utils.py
+++ b/bitbake/lib/bb/utils.py
@@ -97,14 +97,7 @@ _package_ends_ = ["pre", "p", "alpha", "beta", "rc", "cvs", "bk", "HEAD" ]
97 97
98def relparse(myver): 98def relparse(myver):
99 """Parses the last elements of a version number into a triplet, that can 99 """Parses the last elements of a version number into a triplet, that can
100 later be compared: 100 later be compared.
101
102 >>> relparse('1.2_pre3')
103 [1.2, -2, 3.0]
104 >>> relparse('1.2b')
105 [1.2, 98, 0]
106 >>> relparse('1.2')
107 [1.2, 0, 0]
108 """ 101 """
109 102
110 number = 0 103 number = 0
@@ -150,17 +143,6 @@ __vercmp_cache__ = {}
150def vercmp_string(val1,val2): 143def vercmp_string(val1,val2):
151 """This takes two version strings and returns an integer to tell you whether 144 """This takes two version strings and returns an integer to tell you whether
152 the versions are the same, val1>val2 or val2>val1. 145 the versions are the same, val1>val2 or val2>val1.
153
154 >>> vercmp('1', '2')
155 -1.0
156 >>> vercmp('2', '1')
157 1.0
158 >>> vercmp('1', '1.0')
159 0
160 >>> vercmp('1', '1.1')
161 -1.0
162 >>> vercmp('1.1', '1_p2')
163 1.0
164 """ 146 """
165 147
166 # quick short-circuit 148 # quick short-circuit