[elbe-devel] [PATCH v1 1/2] Add decorator for RPCAPTCache to register to base manager

Torben Hohn torben.hohn at linutronix.de
Mon Jun 17 13:20:59 CEST 2019


On Tue, May 28, 2019 at 02:43:08PM +0200, dion at linutronix.de wrote:
> From: Olivier Dion <dion at linutronix.de>
> 
> This make more sens in my opinion than registering after the
> definition of the class.
> 
> Signed-off-by: Olivier Dion <dion at linutronix.de>

Reviewed-by: Torben Hohn <torben.hohn at linutronix.de>

> ---
>  elbepack/rpcaptcache.py | 21 ++++++++++++---------
>  1 file changed, 12 insertions(+), 9 deletions(-)
> 
> diff --git a/elbepack/rpcaptcache.py b/elbepack/rpcaptcache.py
> index d4f4a794..5f35d419 100644
> --- a/elbepack/rpcaptcache.py
> +++ b/elbepack/rpcaptcache.py
> @@ -21,14 +21,25 @@ from elbepack.aptprogress import (ElbeAcquireProgress, ElbeInstallProgress,
>                                    ElbeOpProgress)
>  from elbepack.aptpkgutils import getalldeps, APTPackage
>  
> +class MyMan(BaseManager):
> +
> +    @staticmethod
> +    def register(cls):
> +        BaseManager.register(cls.typeid, cls)
> +        return cls
> +
> +
>  class InChRootObject(object):
>      def __init__(self, rfs):
>          self.rfs = rfs
>          self.rfs.enter_chroot()
>          self.finalizer = Finalize(self, self.rfs.leave_chroot, exitpriority=10)
>  
> -
> + at MyMan.register
>  class RPCAPTCache(InChRootObject):
> +
> +    typeid = "RPCAPTCache"
> +
>      # pylint: disable=too-many-public-methods
>      def __init__(
>              self,
> @@ -275,14 +286,6 @@ class RPCAPTCache(InChRootObject):
>                                                 unpack=False)
>              return self.rfs.fname(rel_filename)
>  
> -
> -class MyMan(BaseManager):
> -    pass
> -
> -
> -MyMan.register("RPCAPTCache", RPCAPTCache)
> -
> -
>  def get_rpcaptcache(
>          rfs,
>          log,
> -- 
> 2.11.0
> 
> 
> _______________________________________________
> elbe-devel mailing list
> elbe-devel at linutronix.de
> https://lists.linutronix.de/mailman/listinfo/elbe-devel

-- 
Torben Hohn
Linutronix GmbH | Bahnhofstrasse 3 | D-88690 Uhldingen-Mühlhofen
Phone: +49 7556 25 999 18; Fax.: +49 7556 25 999 99

Hinweise zum Datenschutz finden Sie hier (Informations on data privacy 
can be found here): https://linutronix.de/kontakt/Datenschutz.php

Linutronix GmbH | Firmensitz (Registered Office): Uhldingen-Mühlhofen | 
Registergericht (Registration Court): Amtsgericht Freiburg i.Br., HRB700 
806 | Geschäftsführer (Managing Directors): Heinz Egger, Thomas Gleixner



More information about the elbe-devel mailing list