@@ -861,7 +861,7 @@ def add(self, t, p1, p2=None, p3=None, p4=None, p5=None):
861861 branch = getattr (branch , element .replace ('-' ,'_' ))
862862 else :
863863 branch = getattr (branch , element )
864- except :
864+ except AttributeError :
865865 # missing path - should never happen unless api_v4 is a busted file
866866 branch = None
867867 break
@@ -916,7 +916,11 @@ def api_list(self, m=None, s=''):
916916 if n in ['delete' , 'get' , 'patch' , 'post' , 'put' ]:
917917 # gone too far
918918 continue
919- a = getattr (m , n )
919+ try :
920+ a = getattr (m , n )
921+ except AttributeError :
922+ # really should not happen!
923+ raise CloudFlareAPIError (0 , '%s: not found - should not happen' % (n ))
920924 d = dir (a )
921925 if '_base' in d :
922926 # it's a known api call - lets show the result and continue down the tree
@@ -934,6 +938,7 @@ def api_list(self, m=None, s=''):
934938 # handle underscores by returning the actual API call vs the method name
935939 w .append (str (a )[1 :- 1 ])
936940 ## w.append(str(a)[1:-1].replace('/:id/','/'))
941+ # now recurse downwards into the tree
937942 w = w + self .api_list (a , s + '/' + n )
938943 return w
939944
@@ -1032,3 +1037,12 @@ def __repr__(self):
10321037 self ._base .base_url , self ._base .raw , self ._base .user_agent
10331038 )
10341039 return s
1040+
1041+ def __getattr__ (self , key ):
1042+ """ __getattr__ """
1043+
1044+ # this code will expand later
1045+ if key in dir (self ):
1046+ return self [key ]
1047+ # this is call to a non-existent endpoint
1048+ raise AttributeError (key )
0 commit comments