[PATCH] Factor out duplicate code
Dan Loda
danloda at gmail.com
Fri Oct 14 00:01:41 BST 2005
On Thu, 2005-10-13 at 08:54 +1000, Robert Collins wrote:
> So - a single static method with a lot of parameters - yes, but with an
> if block.
OK. I may not entirely understand. Are you proposing something along the
lines of:
@staticmethod
def create(kind, file_id, name, parent_id, ... , text_sha1=None,
symlink_target=None):
if kind == 'file':
return InventoryFile(file_id, name, parent_id, ... , text_sha1)
if kind == 'symlink':
return InventoryLink(file_id, ... , symlink_target)
...
raise BadeFileKindError(...)
And then modify each subclass accordingly:
class InventoryLink(InventoryEntry):
def __init__(file_id, name, parent_id, ... , symlink_target=None):
...
--
Dan Loda <danloda at gmail.com>
More information about the bazaar
mailing list