All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] bitbake: utils: add docstrings to functions
@ 2021-01-05  9:31 Milan Shah
  2021-01-11 12:15 ` Milan Shah
  0 siblings, 1 reply; 4+ messages in thread
From: Milan Shah @ 2021-01-05  9:31 UTC (permalink / raw)
  To: bitbake-devel

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.

Signed-off-by: Milan Shah <mshah@mvista.com>
---
 lib/bb/utils.py | 38 ++++++++++++++++++++++++++++++++++----
 1 file changed, 34 insertions(+), 4 deletions(-)

diff --git a/lib/bb/utils.py b/lib/bb/utils.py
index f73d31f..5c775bd 100644
--- a/lib/bb/utils.py
+++ b/lib/bb/utils.py
@@ -129,6 +129,7 @@ def vercmp(ta, tb):
     return r
 
 def vercmp_string(a, b):
+    """ Split version strings and compare them """
     ta = split_version(a)
     tb = split_version(b)
     return vercmp(ta, tb)
@@ -247,6 +248,12 @@ def explode_dep_versions2(s, *, sort=True):
     return r
 
 def explode_dep_versions(s):
+    """
+    Take an RDEPENDS style string of format:
+    "DEPEND1 (optional version) DEPEND2 (optional version) ..."
+    skip null value and items appeared in dependancy string multiple times
+    and return a dictionary of dependencies and versions.
+    """
     r = explode_dep_versions2(s)
     for d in r:
         if not r[d]:
@@ -692,7 +699,7 @@ def remove(path, recurse=False, ionice=False):
                 raise
 
 def prunedir(topdir, ionice=False):
-    # Delete everything reachable from the directory named in 'topdir'.
+    """ Delete everything reachable from the directory named in 'topdir'. """
     # CAUTION:  This is dangerous!
     if _check_unsafe_delete_path(topdir):
         raise Exception('bb.utils.prunedir: called with dangerous path "%s", refusing to delete!' % topdir)
@@ -703,8 +710,10 @@ def prunedir(topdir, ionice=False):
 # but thats possibly insane and suffixes is probably going to be small
 #
 def prune_suffix(var, suffixes, d):
-    # See if var ends with any of the suffixes listed and
-    # remove it if found
+    """ 
+    See if var ends with any of the suffixes listed and
+    remove it if found 
+    """
     for suffix in suffixes:
         if suffix and var.endswith(suffix):
             return var[:-len(suffix)]
@@ -956,6 +965,10 @@ def umask(new_mask):
         os.umask(current_mask)
 
 def to_boolean(string, default=None):
+    """ 
+    Check input string and return boolean value True/False/None
+    depending upon the checks 
+    """
     if not string:
         return default
 
@@ -999,6 +1012,23 @@ def contains(variable, checkvalues, truevalue, falsevalue, d):
     return falsevalue
 
 def contains_any(variable, checkvalues, truevalue, falsevalue, d):
+    """Check if a variable contains any values specified.
+
+    Arguments:
+
+    variable -- the variable name. This will be fetched and expanded (using
+    d.getVar(variable)) and then split into a set().
+
+    checkvalues -- if this is a string it is split on whitespace into a set(),
+    otherwise coerced directly into a set().
+
+    truevalue -- the value to return if checkvalues is a subset of variable.
+
+    falsevalue -- the value to return if variable is empty or if checkvalues is
+    not a subset of variable.
+
+    d -- the data store.
+    """
     val = d.getVar(variable)
     if not val:
         return falsevalue
@@ -1560,8 +1590,8 @@ def set_process_name(name):
     except:
         pass
 
-# export common proxies variables from datastore to environment
 def export_proxies(d):
+    """ export common proxies variables from datastore to environment """
     import os
 
     variables = ['http_proxy', 'HTTP_PROXY', 'https_proxy', 'HTTPS_PROXY',
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] bitbake: utils: add docstrings to functions
  2021-01-05  9:31 [PATCH] bitbake: utils: add docstrings to functions Milan Shah
@ 2021-01-11 12:15 ` Milan Shah
  2021-01-11 12:38   ` [bitbake-devel] " Paul Barker
  0 siblings, 1 reply; 4+ messages in thread
From: Milan Shah @ 2021-01-11 12:15 UTC (permalink / raw)
  To: bitbake-devel, Randy MacLeod, brian.avery

[-- Attachment #1: Type: text/plain, Size: 4082 bytes --]

Hi All,

This is a gentle reminder to review this patch.

-----------------------
Thanks & Regards,
*Milan Shah*
MontaVista Software, Bangalore, India


On Tue, Jan 5, 2021 at 3:02 PM Milan Shah <mshah@mvista.com> wrote:

> 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.
>
> Signed-off-by: Milan Shah <mshah@mvista.com>
> ---
>  lib/bb/utils.py | 38 ++++++++++++++++++++++++++++++++++----
>  1 file changed, 34 insertions(+), 4 deletions(-)
>
> diff --git a/lib/bb/utils.py b/lib/bb/utils.py
> index f73d31f..5c775bd 100644
> --- a/lib/bb/utils.py
> +++ b/lib/bb/utils.py
> @@ -129,6 +129,7 @@ def vercmp(ta, tb):
>      return r
>
>  def vercmp_string(a, b):
> +    """ Split version strings and compare them """
>      ta = split_version(a)
>      tb = split_version(b)
>      return vercmp(ta, tb)
> @@ -247,6 +248,12 @@ def explode_dep_versions2(s, *, sort=True):
>      return r
>
>  def explode_dep_versions(s):
> +    """
> +    Take an RDEPENDS style string of format:
> +    "DEPEND1 (optional version) DEPEND2 (optional version) ..."
> +    skip null value and items appeared in dependancy string multiple times
> +    and return a dictionary of dependencies and versions.
> +    """
>      r = explode_dep_versions2(s)
>      for d in r:
>          if not r[d]:
> @@ -692,7 +699,7 @@ def remove(path, recurse=False, ionice=False):
>                  raise
>
>  def prunedir(topdir, ionice=False):
> -    # Delete everything reachable from the directory named in 'topdir'.
> +    """ Delete everything reachable from the directory named in 'topdir'.
> """
>      # CAUTION:  This is dangerous!
>      if _check_unsafe_delete_path(topdir):
>          raise Exception('bb.utils.prunedir: called with dangerous path
> "%s", refusing to delete!' % topdir)
> @@ -703,8 +710,10 @@ def prunedir(topdir, ionice=False):
>  # but thats possibly insane and suffixes is probably going to be small
>  #
>  def prune_suffix(var, suffixes, d):
> -    # See if var ends with any of the suffixes listed and
> -    # remove it if found
> +    """
> +    See if var ends with any of the suffixes listed and
> +    remove it if found
> +    """
>      for suffix in suffixes:
>          if suffix and var.endswith(suffix):
>              return var[:-len(suffix)]
> @@ -956,6 +965,10 @@ def umask(new_mask):
>          os.umask(current_mask)
>
>  def to_boolean(string, default=None):
> +    """
> +    Check input string and return boolean value True/False/None
> +    depending upon the checks
> +    """
>      if not string:
>          return default
>
> @@ -999,6 +1012,23 @@ def contains(variable, checkvalues, truevalue,
> falsevalue, d):
>      return falsevalue
>
>  def contains_any(variable, checkvalues, truevalue, falsevalue, d):
> +    """Check if a variable contains any values specified.
> +
> +    Arguments:
> +
> +    variable -- the variable name. This will be fetched and expanded
> (using
> +    d.getVar(variable)) and then split into a set().
> +
> +    checkvalues -- if this is a string it is split on whitespace into a
> set(),
> +    otherwise coerced directly into a set().
> +
> +    truevalue -- the value to return if checkvalues is a subset of
> variable.
> +
> +    falsevalue -- the value to return if variable is empty or if
> checkvalues is
> +    not a subset of variable.
> +
> +    d -- the data store.
> +    """
>      val = d.getVar(variable)
>      if not val:
>          return falsevalue
> @@ -1560,8 +1590,8 @@ def set_process_name(name):
>      except:
>          pass
>
> -# export common proxies variables from datastore to environment
>  def export_proxies(d):
> +    """ export common proxies variables from datastore to environment """
>      import os
>
>      variables = ['http_proxy', 'HTTP_PROXY', 'https_proxy', 'HTTPS_PROXY',
> --
> 2.7.4
>
>

[-- Attachment #2: Type: text/html, Size: 5939 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [bitbake-devel] [PATCH] bitbake: utils: add docstrings to functions
  2021-01-11 12:15 ` Milan Shah
@ 2021-01-11 12:38   ` Paul Barker
  2021-01-11 12:42     ` Milan Shah
  0 siblings, 1 reply; 4+ messages in thread
From: Paul Barker @ 2021-01-11 12:38 UTC (permalink / raw)
  To: Milan Shah; +Cc: bitbake-devel, Randy MacLeod, brian.avery

On Mon, 11 Jan 2021 at 12:15, Milan Shah <mshah@mvista.com> wrote:
>
> Hi All,
>
> This is a gentle reminder to review this patch.

Looks like this has already been accepted into master:
https://git.openembedded.org/bitbake/commit/?id=b61ba4a18693a9e553d2a93161feb0bcc1c82384

-- 
Paul Barker
Konsulko Group

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [bitbake-devel] [PATCH] bitbake: utils: add docstrings to functions
  2021-01-11 12:38   ` [bitbake-devel] " Paul Barker
@ 2021-01-11 12:42     ` Milan Shah
  0 siblings, 0 replies; 4+ messages in thread
From: Milan Shah @ 2021-01-11 12:42 UTC (permalink / raw)
  To: Paul Barker; +Cc: bitbake-devel, Randy MacLeod

[-- Attachment #1: Type: text/plain, Size: 623 bytes --]

Thanks, Paul for responding.

I didn't know that it is accepted. Should I close the bug now?

-----------------------
Thanks & Regards,
*Milan Shah*
MontaVista Software, Bangalore, India


On Mon, Jan 11, 2021 at 6:08 PM Paul Barker <pbarker@konsulko.com> wrote:

> On Mon, 11 Jan 2021 at 12:15, Milan Shah <mshah@mvista.com> wrote:
> >
> > Hi All,
> >
> > This is a gentle reminder to review this patch.
>
> Looks like this has already been accepted into master:
>
> https://git.openembedded.org/bitbake/commit/?id=b61ba4a18693a9e553d2a93161feb0bcc1c82384
>
> --
> Paul Barker
> Konsulko Group
>

[-- Attachment #2: Type: text/html, Size: 1964 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-01-11 12:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-05  9:31 [PATCH] bitbake: utils: add docstrings to functions Milan Shah
2021-01-11 12:15 ` Milan Shah
2021-01-11 12:38   ` [bitbake-devel] " Paul Barker
2021-01-11 12:42     ` Milan Shah

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.