120 @type str |
125 @type str |
121 @return tuple containing the result list |
126 @return tuple containing the result list |
122 @rtype (list) |
127 @rtype (list) |
123 """ |
128 """ |
124 from radon.raw import analyze |
129 from radon.raw import analyze |
125 res = analyze(text) |
130 try: |
|
131 res = __raw2Dict(analyze(text)) |
|
132 except Exception as err: |
|
133 res = {"error": str(err)} |
126 return (res, ) |
134 return (res, ) |
|
135 |
|
136 |
|
137 def __raw2Dict(obj): |
|
138 """ |
|
139 Private function to convert an object holding raw analysis results into a |
|
140 dictionary. |
|
141 |
|
142 @param obj object as returned from analyze() |
|
143 @type radon.raw.Module |
|
144 @return conversion result |
|
145 @rtype dict |
|
146 """ |
|
147 result = {} |
|
148 for a in obj._fields: |
|
149 v = getattr(obj, a, None) |
|
150 if v is not None: |
|
151 result[a] = v |
|
152 return result |