Review Request: Packagers: remove duplicate code, consistent naming, simplify some code

Ralf Habacker ralf at habacker.de
Fri Feb 18 10:19:41 CET 2011



> On Feb. 18, 2011, 7:28 a.m., Ralf Habacker wrote:
> > > __installedDBPrefix
> > 
> > InternalPackageBase is derived from PackageBase, so the one in PackageBase is enough. Because __installedDBPrefix is used in InternalPackageBase is should be named  installedDBPrefix without any prefix. 
> > 
> > > simplify code in PackagerFactory (this code is actually unused but it looks like a plan for the future)
> > 
> > PackagerFactory is used by MultiPackager to instantiate packager backends similiar to MultiSource for Source types 
> > 
> > class MultiPackager():
> >     def __init__(self, packagerType=None):
> >         utils.debug( "MultiPackager __init__ %s" %packagerType, 2 )
> >         self.packagers = PackagerFactory(self, packagerType)
> > 
> >     def createPackage(self):
> >         result = True
> >         for packager in self.packagers:
> >             if not packager.createPackage():
> >                 result = False
> >         return result
> > 
> >     def make_package(self):
> >         return self.createPackage()
> > 
> > In ...PackageBase classes normally a single Packager approach is selected 
> > 
> > class CMakePackageBase (PackageBase, MultiSource, CMakeBuildSystem, KDEWinPackager):
> >     """provides a base class for cmake packages from any source"""
> >     def __init__(self):
> >         utils.debug("CMakePackageBase.__init__ called", 2)
> >         PackageBase.__init__(self)
> >         MultiSource.__init__(self)
> >         CMakeBuildSystem.__init__(self)
> >         KDEWinPackager.__init__(self)
> > 
> > The multiple packager approach allows to support more than one packager 
> > 
> > class CMakePackageBase (PackageBase, MultiSource, CMakeBuildSystem, MultiPackager):
> >     """provides a base class for cmake packages from any source"""
> >     def __init__(self):
> >         utils.debug("CMakePackageBase.__init__ called", 2)
> >         PackageBase.__init__(self)
> >         MultiSource.__init__(self)
> >         CMakeBuildSystem.__init__(self)
> >         MultiPackager.__init__(self,["packagertype1","packagertype2"])
> > 
> > (the default packages may be set in the future by a generic option)
> > 
> > 
> > 
> > otherwise looks good. 
> >
> 
> Wolfgang Rohdewald wrote:
>     > Because __installedDBPrefix is used in InternalPackageBase is should be named  installedDBPrefix without any prefix. 
>     
>     because it is only used in a derived class, I renamed it to _installedDBPrefix (only one underscore) being the conventional naming
>     for protected, I do not see the need to make it public
>     
>     > MultiPackager.__init__(self,["packagertype1","packagertype2"])
>     
>     MultiPackager is never instantiated with that list of packagertypes, so that code must currently be unused.
>     Thank you for your explanation - that is what I actually figured out myself
>     
>     Looking at it again, I now simplified it further, so you can do
>     
>     MultiPackager.__init__(self, [KDEWinPackager, CPackPackager]) 
>     
>     Just pass the classes themselves.
>     
>     The previous mapping from string to class is not needed and cannot be checked by pylint. Also,
>     this automatically works for new packagers
>     
>

> the conventional naming for protected, 

ah okay 

> MultiPackager is never instantiated with that list of packagertypes, so that code must currently be unused.

there are other projects outside kde using MultiPackager, for example http://www.gausz.de uses it for building 7z and inno setup packages. 

> MultiPackager.__init__(self, [KDEWinPackager, CPackPackager]) 

that looks very 

> Also this automatically works for new packagers

very good :-) 


- Ralf


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://svn.reviewboard.kde.org/r/6486/#review9878
-----------------------------------------------------------


On Feb. 18, 2011, 8:36 a.m., Wolfgang Rohdewald wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> http://svn.reviewboard.kde.org/r/6486/
> -----------------------------------------------------------
> 
> (Updated Feb. 18, 2011, 8:36 a.m.)
> 
> 
> Review request for kde-windows.
> 
> 
> Summary
> -------
> 
> __installedDBPrefix existed identically in PackageBase and InternalPackageBase. Remove it from InternalPackageBase and rename to _installedDBPrefix
> 
> rename self.packager to self.packagerExe for consistency
> 
> simplify code in PackagerFactory (this code is actually unused but it looks like a plan for the future)
> 
> a few other small simplifications around packager code
> 
> 
> Diffs
> -----
> 
>   /trunk/kdesupport/emerge/bin/Package/InternalPackageBase.py 1221360 
>   /trunk/kdesupport/emerge/bin/Package/PackageBase.py 1221360 
>   /trunk/kdesupport/emerge/bin/Packager/InnoSetupPackager.py 1221360 
>   /trunk/kdesupport/emerge/bin/Packager/KDEWinPackager.py 1221360 
>   /trunk/kdesupport/emerge/bin/Packager/PackagerFactory.py 1221360 
>   /trunk/kdesupport/emerge/bin/Packager/SevenZipPackager.py 1221360 
> 
> Diff: http://svn.reviewboard.kde.org/r/6486/diff
> 
> 
> Testing
> -------
> 
> 
> Thanks,
> 
> Wolfgang
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.kde.org/pipermail/kde-windows/attachments/20110218/cd25cf21/attachment.htm 


More information about the Kde-windows mailing list