93 for task in argumentsList[:initialTasks]: |
81 for task in argumentsList[:initialTasks]: |
94 taskQueue.put(task) |
82 taskQueue.put(task) |
95 |
83 |
96 # Start worker processes |
84 # Start worker processes |
97 for _ in range(NumberOfProcesses): |
85 for _ in range(NumberOfProcesses): |
98 multiprocessing.Process(target=worker, args=(taskQueue, doneQueue))\ |
86 multiprocessing.Process( |
99 .start() |
87 target=worker, args=(taskQueue, doneQueue)).start() |
100 |
88 |
101 # Get and send results |
89 # Get and send results |
102 endIndex = len(argumentsList) - initialTasks |
90 endIndex = len(argumentsList) - initialTasks |
103 for i in range(len(argumentsList)): |
91 for i in range(len(argumentsList)): |
104 resultSent = False |
92 resultSent = False |
155 @return tuple containing the result dictionary |
143 @return tuple containing the result dictionary |
156 @rtype (tuple of dict) |
144 @rtype (tuple of dict) |
157 """ |
145 """ |
158 from radon.complexity import cc_visit, cc_rank |
146 from radon.complexity import cc_visit, cc_rank |
159 |
147 |
160 # Check type for py2: if not str it's unicode |
|
161 if sys.version_info[0] == 2: |
|
162 try: |
|
163 text = text.encode('utf-8') |
|
164 except UnicodeError: |
|
165 pass |
|
166 |
|
167 try: |
148 try: |
168 cc = cc_visit(text) |
149 cc = cc_visit(text) |
169 res = {"result": [v for v in map(__cc2Dict, cc) |
150 res = {"result": [v for v in map(__cc2Dict, cc) |
170 if v["type"] != "method"]} |
151 if v["type"] != "method"]} |
171 totalCC = 0 |
152 totalCC = 0 |
203 |
184 |
204 result = { |
185 result = { |
205 'type': __getType(obj), |
186 'type': __getType(obj), |
206 'rank': cc_rank(obj.complexity), |
187 'rank': cc_rank(obj.complexity), |
207 } |
188 } |
208 attrs = set(Function._fields) - set(('is_method', 'closures')) |
189 attrs = set(Function._fields) - {'is_method', 'closures'} |
209 attrs.add("fullname") |
190 attrs.add("fullname") |
210 for attr in attrs: |
191 for attr in attrs: |
211 v = getattr(obj, attr, None) |
192 v = getattr(obj, attr, None) |
212 if v is not None: |
193 if v is not None: |
213 result[attr] = v |
194 result[attr] = v |