Conditions | 10 |
Total Lines | 20 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Complex classes like Login.build() often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
1 | #!/usr/bin/env python |
||
8 | @staticmethod |
||
9 | def build(config, greeting, args = {}): |
||
10 | if not args.get('login'): |
||
11 | args['login'] = config['epp']['login'] |
||
12 | if not args.get('pw'): |
||
13 | args['pw'] = config['epp']['password'] |
||
14 | if not greeting: |
||
15 | Error.die(4, 'no greeting given') |
||
16 | greeting = Response.parsexml(greeting) |
||
17 | if not args.get('objURIs'): |
||
18 | args['objURIs'] = greeting.get('objURIs') |
||
19 | for uri in list(args['objURIs']): |
||
20 | if not uri in Request.modules: |
||
21 | del args['objURIs'][uri] |
||
22 | if not args.get('extURIs'): |
||
23 | args['extURIs'] = greeting.get('extURIs') |
||
24 | for uri in list(args['extURIs']): |
||
25 | if not uri in Request.modules: |
||
26 | del args['extURIs'][uri] |
||
27 | return Request.build('epp:login', args) |
||
28 |