Be explicit about complete-ability

This commit is contained in:
Vincent Jacques
2012-05-12 14:12:03 +02:00
parent f23ed6341d
commit 8956796e7f
5 changed files with 68 additions and 30 deletions
-22
View File
@@ -14,37 +14,29 @@ class GitTreeElement( object ):
self.__completed = False
self.__initAttributes()
self.__useAttributes( attributes )
if not lazy:
self.__complete()
@property
def mode( self ):
self.__completeIfNeeded( self.__mode )
return self.__mode
@property
def path( self ):
self.__completeIfNeeded( self.__path )
return self.__path
@property
def sha( self ):
self.__completeIfNeeded( self.__sha )
return self.__sha
@property
def size( self ):
self.__completeIfNeeded( self.__size )
return self.__size
@property
def type( self ):
self.__completeIfNeeded( self.__type )
return self.__type
@property
def url( self ):
self.__completeIfNeeded( self.__url )
return self.__url
def __initAttributes( self ):
@@ -55,20 +47,6 @@ class GitTreeElement( object ):
self.__type = None
self.__url = None
def __completeIfNeeded( self, testedAttribute ):
if not self.__completed and testedAttribute is None:
self.__complete()
def __complete( self ):
status, headers, data = self.__requester.request(
"GET",
self.__url,
None,
None
)
self.__useAttributes( data )
self.__completed = True
def __useAttributes( self, attributes ):
# @todo Remove this debug weakness: we shall assume that github will add new attributes
for attribute in attributes: