[apparmor] [patch] Drop unused matchregexp(), commonsuffix() and commonprefix() from aa.py

Seth Arnold seth.arnold at canonical.com
Mon Oct 3 18:32:47 UTC 2016


On Sun, Oct 02, 2016 at 01:18:15AM +0200, Christian Boltz wrote:
> Hello,
> 
> $subject.
> 
> matchregexp() was the last user of convert_regexp() in aa.py, so we
> don't need to import it anymore.
> 
> 
> 
> [ 02-drop-matchregexp-commonprefix-commonsuffix-from-aa.py.diff ]
> 

My favorite thing, removing code that's commented out. :)

Acked-by: Seth Arnold <seth.arnold at canonical.com>

Thanks

> --- utils/apparmor/aa.py        2016-10-01 21:01:03.863002592 +0200
> +++ utils/apparmor/aa.py        2016-10-02 00:18:38.298646321 +0200
> @@ -34,7 +34,7 @@
>  from apparmor.aare import AARE
>  
>  from apparmor.common import (AppArmorException, AppArmorBug, open_file_read, valid_path, hasher,
> -                             open_file_write, convert_regexp, DebugLogger)
> +                             open_file_write, DebugLogger)
>  
>  import apparmor.ui as aaui
>  
> @@ -3687,42 +3687,6 @@
>      else:
>          return '%s^%s' % (name1, name2)
>  
> -def commonprefix(new, old):
> -    match = re.search(r'^([^\0]*)[^\0]*(\0\1[^\0]*)*$', '\0'.join([new, old]))
> -    if match:
> -        return match.groups()[0]
> -    return match
> -
> -def commonsuffix(new, old):
> -    match = commonprefix(new[-1::-1], old[-1::-1])
> -    if match:
> -        return match[-1::-1]
> -
> -def matchregexp(new, old):
> -    if re.search('\{.*(\,.*)*\}', old):
> -        return None
> -
> -#     if re.search('\[.+\]', old) or re.search('\*', old) or re.search('\?', old):
> -#
> -#         new_reg = convert_regexp(new)
> -#         old_reg = convert_regexp(old)
> -#
> -#         pref = commonprefix(new, old)
> -#         if pref:
> -#             if convert_regexp('(*,**)$') in pref:
> -#                 pref = pref.replace(convert_regexp('(*,**)$'), '')
> -#             new = new.replace(pref, '', 1)
> -#             old = old.replace(pref, '', 1)
> -#
> -#         suff = commonsuffix(new, old)
> -#         if suffix:
> -#             pass
> -    new_reg = convert_regexp(new)
> -    if re.search(new_reg, old):
> -        return True
> -
> -    return None
> -
>  def logger_path():
>      logger = conf.find_first_file(cfg['settings']['logger']) or '/bin/logger'
>      if not os.path.isfile(logger) or not os.access(logger, os.EX_OK):
> 
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: not available
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20161003/5921a8a1/attachment.pgp>


More information about the AppArmor mailing list