Conditions | 8 |
Total Lines | 51 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | # -*- coding: utf-8 -*- |
||
37 | def __init__(self, config=None, args=None): |
||
38 | # Quiet mode |
||
39 | self._quiet = args.quiet |
||
40 | self.refresh_time = args.time |
||
41 | |||
42 | # Init stats |
||
43 | self.stats = GlancesStats(config=config, args=args) |
||
44 | |||
45 | # If process extended stats is disabled by user |
||
46 | if not args.enable_process_extended: |
||
47 | logger.debug("Extended stats for top process are disabled") |
||
48 | glances_processes.disable_extended() |
||
49 | else: |
||
50 | logger.debug("Extended stats for top process are enabled") |
||
51 | glances_processes.enable_extended() |
||
52 | |||
53 | # Manage optionnal process filter |
||
54 | if args.process_filter is not None: |
||
55 | glances_processes.process_filter = args.process_filter |
||
56 | |||
57 | if (not WINDOWS) and args.no_kernel_threads: |
||
58 | # Ignore kernel threads in process list |
||
59 | glances_processes.disable_kernel_threads() |
||
60 | |||
61 | try: |
||
62 | if args.process_tree: |
||
63 | # Enable process tree view |
||
64 | glances_processes.enable_tree() |
||
65 | except AttributeError: |
||
66 | pass |
||
67 | |||
68 | # Initial system informations update |
||
69 | self.stats.update() |
||
70 | |||
71 | if self.quiet: |
||
72 | logger.info("Quiet mode is ON: Nothing will be displayed") |
||
73 | # In quiet mode, nothing is displayed |
||
74 | glances_processes.max_processes = 0 |
||
75 | else: |
||
76 | # Default number of processes to displayed is set to 50 |
||
77 | glances_processes.max_processes = 50 |
||
78 | |||
79 | # Init screen |
||
80 | self.screen = GlancesCursesStandalone(config=config, args=args) |
||
81 | |||
82 | # Check the latest Glances version |
||
83 | self.outdated = Outdated(config=config, args=args) |
||
84 | |||
85 | # Create the schedule instance |
||
86 | self.schedule = sched.scheduler( |
||
87 | timefunc=time.time, delayfunc=time.sleep) |
||
88 | |||
134 |