[2/5] framework: fix grouptools.commonprefix when len(args) == 1

Submitted by Marek Olšák on May 2, 2018, 8:32 p.m.

Details

Message ID 20180502203247.11284-2-maraeo@gmail.com
State New
Headers show
Series "Series without cover letter" ( rev: 1 ) in Piglit

Not browsing as part of any series.

Commit Message

Marek Olšák May 2, 2018, 8:32 p.m.
From: Nicolai Hähnle <nicolai.haehnle@amd.com>

---
 framework/grouptools.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/framework/grouptools.py b/framework/grouptools.py
index f28241d3c..ce2e97c79 100644
--- a/framework/grouptools.py
+++ b/framework/grouptools.py
@@ -82,21 +82,21 @@  def splitname(group):
     i = group.rfind(SEPARATOR) + 1
     head, tail = group[:i], group[i:]
     head = head.rstrip(SEPARATOR)
 
     return head, tail
 
 
 def commonprefix(args):
     """Given a list of groups, returns the longest common leading component."""
     if len(args) == 1:
-        return args
+        return args[0]
     elif any(e == '' for e in args):
         return ''
 
     common = []
 
     for elems in zip(*[split(a) for a in args]):
         iter_ = iter(elems)
         first = next(iter_)
         if all(first == r for r in iter_):
             common.append(first)

Comments

Reviewed-by: Dylan Baker <dylan@pnwbakers.com>

Quoting Marek Olšák (2018-05-02 13:32:44)
> From: Nicolai Hähnle <nicolai.haehnle@amd.com>
> 
> ---
>  framework/grouptools.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/framework/grouptools.py b/framework/grouptools.py
> index f28241d3c..ce2e97c79 100644
> --- a/framework/grouptools.py
> +++ b/framework/grouptools.py
> @@ -82,21 +82,21 @@ def splitname(group):
>      i = group.rfind(SEPARATOR) + 1
>      head, tail = group[:i], group[i:]
>      head = head.rstrip(SEPARATOR)
>  
>      return head, tail
>  
>  
>  def commonprefix(args):
>      """Given a list of groups, returns the longest common leading component."""
>      if len(args) == 1:
> -        return args
> +        return args[0]
>      elif any(e == '' for e in args):
>          return ''
>  
>      common = []
>  
>      for elems in zip(*[split(a) for a in args]):
>          iter_ = iter(elems)
>          first = next(iter_)
>          if all(first == r for r in iter_):
>              common.append(first)
> -- 
> 2.17.0
> 
> _______________________________________________
> Piglit mailing list
> Piglit@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/piglit