mirror of
https://github.com/status-im/PyGithub.git
synced 2026-09-01 19:31:10 +00:00
Refactor
This commit is contained in:
@@ -2,23 +2,6 @@ import itertools
|
||||
|
||||
import ArgumentsChecker
|
||||
|
||||
class ListOfReferences:
|
||||
def __init__( self, attributeName, type, addable = False, removable = False, hasable = False, getParameters = [] ):
|
||||
self.__capacities = list()
|
||||
self.attributeName = attributeName
|
||||
self.type = type
|
||||
self.__capacities.append( ListGetable( [], getParameters ) )
|
||||
if addable:
|
||||
self.__capacities.append( ElementAddable() )
|
||||
if removable:
|
||||
self.__capacities.append( ElementRemoveable() )
|
||||
if hasable:
|
||||
self.__capacities.append( ElementHasable() )
|
||||
|
||||
def apply( self, cls ):
|
||||
for capacity in self.__capacities:
|
||||
capacity.apply( self, cls )
|
||||
|
||||
class ElementAddable:
|
||||
def apply( self, list, cls ):
|
||||
self.__type = list.type
|
||||
@@ -102,3 +85,15 @@ class ListOfObjects:
|
||||
def apply( self, cls ):
|
||||
for capacity in self.__capacities:
|
||||
capacity.apply( self, cls )
|
||||
|
||||
class ListOfReferences( ListOfObjects ):
|
||||
def __init__( self, attributeName, type, addable = False, removable = False, hasable = False, getParameters = [] ):
|
||||
capacities = list()
|
||||
capacities.append( ListGetable( [], getParameters ) )
|
||||
if addable:
|
||||
capacities.append( ElementAddable() )
|
||||
if removable:
|
||||
capacities.append( ElementRemoveable() )
|
||||
if hasable:
|
||||
capacities.append( ElementHasable() )
|
||||
ListOfObjects.__init__( self, attributeName, type, *capacities )
|
||||
|
||||
Reference in New Issue
Block a user