@@ -1022,11 +1022,10 @@ def get_aliases(self):
10221022 aliases = {}
10231023 for name in names :
10241024 func = getattr (self .o , name )
1025+ if not self .is_alias (func ): continue
10251026 docstring = func .__doc__
1026- if docstring is None : continue
1027- if docstring .startswith ('alias for ' ):
1028- fullname = docstring [10 :]
1029- aliases [fullname [4 :]] = name [4 :]
1027+ fullname = docstring [10 :]
1028+ aliases [fullname [4 :]] = name [4 :]
10301029 return aliases
10311030
10321031 def get_valid_values (self , attr ):
@@ -1039,13 +1038,14 @@ def get_valid_values(self, attr):
10391038
10401039 name = 'set_%s' % attr
10411040 if not hasattr (self .o , name ):
1042- raise AttributeError ('%s has no function %s' % (h ,name ))
1041+ raise AttributeError ('%s has no function %s' % (self . o ,name ))
10431042 func = getattr (self .o , name )
10441043
10451044 docstring = func .__doc__
10461045 if docstring is None : return 'unknown'
10471046
1048- if docstring .startswith ('alias' ): return docstring
1047+ if docstring .startswith ('alias for ' ):
1048+ return None
10491049 for line in docstring .split ('\n ' ):
10501050 line = line .lstrip ()
10511051 if not line .startswith ('ACCEPTS:' ): continue
@@ -1057,10 +1057,21 @@ def get_setters(self):
10571057 Get the attribute strings with setters for object h
10581058 """
10591059
1060- return [name [4 :] for name in dir (self .o )
1061- if name .startswith ('set_' ) and
1062- callable (getattr (self .o ,name ))]
1063-
1060+ setters = []
1061+ for name in dir (self .o ):
1062+ if not name .startswith ('set_' ): continue
1063+ o = getattr (self .o ,name )
1064+ if not callable (o ): continue
1065+ func = o
1066+ if self .is_alias (func ): continue
1067+ setters .append (name [4 :])
1068+ return setters
1069+
1070+ def is_alias (self , o ):
1071+ ds = o .__doc__
1072+ if ds is None : return False
1073+ return ds .startswith ('alias for ' )
1074+
10641075 def aliased_name (self , s ):
10651076 """
10661077 return 'fullname or alias' if s has an alias.
@@ -1083,8 +1094,9 @@ def pprint_setters(self, property=None):
10831094 return ' %s: %s' % (property , accepts )
10841095
10851096 attrs = self .get_setters ()
1086- lines = []
10871097 attrs .sort ()
1098+ lines = []
1099+
10881100 for property in attrs :
10891101 accepts = self .get_valid_values (property )
10901102 name = self .aliased_name (property )
@@ -1102,10 +1114,9 @@ def pprint_getters(self):
11021114 lines = []
11031115 for name in getters :
11041116 func = getattr (self .o , name )
1105- docstring = func .__doc__
1106- if docstring is not None and docstring .startswith ('alias' ): continue
1117+ if self .is_alias (func ): continue
11071118 try : val = func ()
1108- except : pass
1119+ except : continue
11091120 if iterable (val ) and len (val )> 6 :
11101121 s = str (val [:6 ]) + '...'
11111122 else :
0 commit comments