diff options
author | Milan Shah <mshah@mvista.com> | 2021-01-05 15:01:58 +0530 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-01-08 10:11:42 +0000 |
commit | 0fa7258d27e64984c41e03580921ebd48eba5a64 (patch) | |
tree | 4823f41722c4fbbdd7c66ceafb976b84bdb5db01 /bitbake/lib/bb/utils.py | |
parent | 8877980c99045d53c2465faeb45aa6e81f126708 (diff) | |
download | poky-0fa7258d27e64984c41e03580921ebd48eba5a64.tar.gz |
bitbake: utils: add docstrings to functions
A list of functions that now has a docstring.
* vercmp_string
* explode_dep_versions
* prunedir
* prune_suffix
* to_boolean
* contains_any
* export_proxies
See [YOCTO #9725] for details.
(Bitbake rev: b61ba4a18693a9e553d2a93161feb0bcc1c82384)
Signed-off-by: Milan Shah <mshah@mvista.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/utils.py')
-rw-r--r-- | bitbake/lib/bb/utils.py | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py index f73d31fb73..5c775bd8a8 100644 --- a/bitbake/lib/bb/utils.py +++ b/bitbake/lib/bb/utils.py | |||
@@ -129,6 +129,7 @@ def vercmp(ta, tb): | |||
129 | return r | 129 | return r |
130 | 130 | ||
131 | def vercmp_string(a, b): | 131 | def vercmp_string(a, b): |
132 | """ Split version strings and compare them """ | ||
132 | ta = split_version(a) | 133 | ta = split_version(a) |
133 | tb = split_version(b) | 134 | tb = split_version(b) |
134 | return vercmp(ta, tb) | 135 | return vercmp(ta, tb) |
@@ -247,6 +248,12 @@ def explode_dep_versions2(s, *, sort=True): | |||
247 | return r | 248 | return r |
248 | 249 | ||
249 | def explode_dep_versions(s): | 250 | def explode_dep_versions(s): |
251 | """ | ||
252 | Take an RDEPENDS style string of format: | ||
253 | "DEPEND1 (optional version) DEPEND2 (optional version) ..." | ||
254 | skip null value and items appeared in dependancy string multiple times | ||
255 | and return a dictionary of dependencies and versions. | ||
256 | """ | ||
250 | r = explode_dep_versions2(s) | 257 | r = explode_dep_versions2(s) |
251 | for d in r: | 258 | for d in r: |
252 | if not r[d]: | 259 | if not r[d]: |
@@ -692,7 +699,7 @@ def remove(path, recurse=False, ionice=False): | |||
692 | raise | 699 | raise |
693 | 700 | ||
694 | def prunedir(topdir, ionice=False): | 701 | def prunedir(topdir, ionice=False): |
695 | # Delete everything reachable from the directory named in 'topdir'. | 702 | """ Delete everything reachable from the directory named in 'topdir'. """ |
696 | # CAUTION: This is dangerous! | 703 | # CAUTION: This is dangerous! |
697 | if _check_unsafe_delete_path(topdir): | 704 | if _check_unsafe_delete_path(topdir): |
698 | raise Exception('bb.utils.prunedir: called with dangerous path "%s", refusing to delete!' % topdir) | 705 | raise Exception('bb.utils.prunedir: called with dangerous path "%s", refusing to delete!' % topdir) |
@@ -703,8 +710,10 @@ def prunedir(topdir, ionice=False): | |||
703 | # but thats possibly insane and suffixes is probably going to be small | 710 | # but thats possibly insane and suffixes is probably going to be small |
704 | # | 711 | # |
705 | def prune_suffix(var, suffixes, d): | 712 | def prune_suffix(var, suffixes, d): |
706 | # See if var ends with any of the suffixes listed and | 713 | """ |
707 | # remove it if found | 714 | See if var ends with any of the suffixes listed and |
715 | remove it if found | ||
716 | """ | ||
708 | for suffix in suffixes: | 717 | for suffix in suffixes: |
709 | if suffix and var.endswith(suffix): | 718 | if suffix and var.endswith(suffix): |
710 | return var[:-len(suffix)] | 719 | return var[:-len(suffix)] |
@@ -956,6 +965,10 @@ def umask(new_mask): | |||
956 | os.umask(current_mask) | 965 | os.umask(current_mask) |
957 | 966 | ||
958 | def to_boolean(string, default=None): | 967 | def to_boolean(string, default=None): |
968 | """ | ||
969 | Check input string and return boolean value True/False/None | ||
970 | depending upon the checks | ||
971 | """ | ||
959 | if not string: | 972 | if not string: |
960 | return default | 973 | return default |
961 | 974 | ||
@@ -999,6 +1012,23 @@ def contains(variable, checkvalues, truevalue, falsevalue, d): | |||
999 | return falsevalue | 1012 | return falsevalue |
1000 | 1013 | ||
1001 | def contains_any(variable, checkvalues, truevalue, falsevalue, d): | 1014 | def contains_any(variable, checkvalues, truevalue, falsevalue, d): |
1015 | """Check if a variable contains any values specified. | ||
1016 | |||
1017 | Arguments: | ||
1018 | |||
1019 | variable -- the variable name. This will be fetched and expanded (using | ||
1020 | d.getVar(variable)) and then split into a set(). | ||
1021 | |||
1022 | checkvalues -- if this is a string it is split on whitespace into a set(), | ||
1023 | otherwise coerced directly into a set(). | ||
1024 | |||
1025 | truevalue -- the value to return if checkvalues is a subset of variable. | ||
1026 | |||
1027 | falsevalue -- the value to return if variable is empty or if checkvalues is | ||
1028 | not a subset of variable. | ||
1029 | |||
1030 | d -- the data store. | ||
1031 | """ | ||
1002 | val = d.getVar(variable) | 1032 | val = d.getVar(variable) |
1003 | if not val: | 1033 | if not val: |
1004 | return falsevalue | 1034 | return falsevalue |
@@ -1560,8 +1590,8 @@ def set_process_name(name): | |||
1560 | except: | 1590 | except: |
1561 | pass | 1591 | pass |
1562 | 1592 | ||
1563 | # export common proxies variables from datastore to environment | ||
1564 | def export_proxies(d): | 1593 | def export_proxies(d): |
1594 | """ export common proxies variables from datastore to environment """ | ||
1565 | import os | 1595 | import os |
1566 | 1596 | ||
1567 | variables = ['http_proxy', 'HTTP_PROXY', 'https_proxy', 'HTTPS_PROXY', | 1597 | variables = ['http_proxy', 'HTTP_PROXY', 'https_proxy', 'HTTPS_PROXY', |