@@ -904,19 +904,22 @@ def getscm(self):
904
904
return scm
905
905
906
906
# Pass backend SCM commands and parameters if SCM exists
907
- def __scm_call (self , method , * args , ** kwargs ):
908
- if self .scm and hasattr (self .scm , method ) and callable (getattr (self .scm , method )):
909
- with cd (self .path ):
910
- return getattr (self .scm , method )(* args , ** kwargs )
911
-
912
- def geturl (self , * args , ** kwargs ):
913
- return self .__scm_call ('geturl' , * args , ** kwargs )
914
-
915
- def getrev (self , * args , ** kwargs ):
916
- return self .__scm_call ('getrev' , * args , ** kwargs )
917
-
918
- def add (self , * args , ** kwargs ):
919
- return self .__scm_call ('add' , * args , ** kwargs )
907
+ def __wrap_scm (self , method ):
908
+ def __scm_call (* args , ** kwargs ):
909
+ if self .scm and hasattr (self .scm , method ) and callable (getattr (self .scm , method )):
910
+ with cd (self .path ):
911
+ return getattr (self .scm , method )(* args , ** kwargs )
912
+ return __scm_call
913
+
914
+ def __getattr__ (self , attr ):
915
+ if attr in ['geturl' , 'getrev' , 'add' , 'remove' , 'ignores' , 'ignore' , 'unignore' ,
916
+ 'status' , 'dirty' , 'commit' , 'outgoing' , 'publish' , 'checkout' , 'update' ,
917
+ 'isdetached' ]:
918
+ wrapper = self .__wrap_scm (attr )
919
+ self .__dict__ [attr ] = wrapper
920
+ return wrapper
921
+ else :
922
+ raise AttributeError ("Repo instance doesn't have attribute '%s'" % attr )
920
923
921
924
def remove (self , dest , * args , ** kwargs ):
922
925
if os .path .isfile (dest ):
@@ -926,39 +929,6 @@ def remove(self, dest, *args, **kwargs):
926
929
pass
927
930
return self .__scm_call ('remove' , dest , * args , ** kwargs )
928
931
929
- def ignores (self , * args , ** kwargs ):
930
- return self .__scm_call ('ignores' , * args , ** kwargs )
931
-
932
- def ignore (self , * args , ** kwargs ):
933
- return self .__scm_call ('ignore' , * args , ** kwargs )
934
-
935
- def unignore (self , * args , ** kwargs ):
936
- return self .__scm_call ('unignore' , * args , ** kwargs )
937
-
938
- def status (self , * args , ** kwargs ):
939
- return self .__scm_call ('status' , * args , ** kwargs )
940
-
941
- def dirty (self , * args , ** kwargs ):
942
- return self .__scm_call ('dirty' , * args , ** kwargs )
943
-
944
- def commit (self , * args , ** kwargs ):
945
- return self .__scm_call ('commit' , * args , ** kwargs )
946
-
947
- def outgoing (self , * args , ** kwargs ):
948
- return self .__scm_call ('outgoing' , * args , ** kwargs )
949
-
950
- def publish (self , * args , ** kwargs ):
951
- return self .__scm_call ('publish' , * args , ** kwargs )
952
-
953
- def checkout (self , * args , ** kwargs ):
954
- return self .__scm_call ('checkout' , * args , ** kwargs )
955
-
956
- def update (self , * args , ** kwargs ):
957
- return self .__scm_call ('update' , * args , ** kwargs )
958
-
959
- def isdetached (self , * args , ** kwargs ):
960
- return self .__scm_call ('isdetached' , * args , ** kwargs )
961
-
962
932
def getlibs (self ):
963
933
for root , dirs , files in os .walk (self .path ):
964
934
dirs [:] = [d for d in dirs if not d .startswith ('.' )]
0 commit comments