Sourcery refactored master branch#73
Conversation
| loglevel = log_levels[level] | ||
| else: | ||
| loglevel = log_levels['3'] | ||
| loglevel = log_levels.get(level, log_levels['3']) |
There was a problem hiding this comment.
Function setup_logging refactored with the following changes:
- Simplify dictionary access using default get
| if type(s) is unicode: | ||
| if type(s) is unicode or type(s) is not str: | ||
| return s | ||
| elif type(s) is str: | ||
| else: | ||
| try: | ||
| return unicode(s, term_encoding) | ||
| except ValueError: | ||
| logger.error('s2or3 exception: {0}'.format(s)) | ||
| else: | ||
| return s |
There was a problem hiding this comment.
Function s2or3 refactored with the following changes:
- Merge duplicate blocks in conditional
- Remove redundant conditional
| if s.upper() == s and s.lower() != s: | ||
| shift = "Shift-" | ||
| else: | ||
| shift = "" | ||
| if mac: | ||
| # return "{0}Cmd-{1}".format(shift, s), "<{0}Command-{1}>".format(shift, s) | ||
| return "{0}Ctrl-{1}".format(shift, s.upper()), "<{0}Control-{1}>".format(shift, s) | ||
| else: | ||
| return "{0}Ctrl-{1}".format(shift, s.upper()), "<{0}Control-{1}>".format(shift, s) | ||
| shift = "Shift-" if s.upper() == s and s.lower() != s else "" | ||
| # return "{0}Cmd-{1}".format(shift, s), "<{0}Command-{1}>".format(shift, s) | ||
| return "{0}Ctrl-{1}".format(shift, s.upper()), "<{0}Control-{1}>".format(shift, s) |
There was a problem hiding this comment.
Function commandShortcut refactored with the following changes:
- Hoist repeated code outside conditional statement
- Replace if statement with if expression
| if s.upper() == s and s.lower() != s: | ||
| shift = "Shift-" | ||
| else: | ||
| shift = "" | ||
| shift = "Shift-" if s.upper() == s and s.lower() != s else "" |
There was a problem hiding this comment.
Function optionShortcut refactored with the following changes:
- Replace if statement with if expression
| if dn > 1: | ||
| days = dn - 1 | ||
| else: | ||
| days = 0 | ||
| days = dn - 1 if dn > 1 else 0 |
There was a problem hiding this comment.
Function get_week refactored with the following changes:
- Inline variable that is only used once
- Replace if statement with if expression
| Checkbutton(self.win, text=self.options[i][0], padx=20, variable=self.check_values[i]).pack(padx=10, anchor=W) | ||
| Checkbutton( | ||
| self.win, text=txt, padx=20, variable=self.check_values[i] | ||
| ).pack(padx=10, anchor=W) | ||
|
|
There was a problem hiding this comment.
Function OptionsDialog.__init__ refactored with the following changes:
- Swap positions of nested conditionals
- Hoist repeated code outside conditional statement
- Use previously assigned local variable
| width0 = self.tree.column('#0')['width'] | ||
| if self.labels: | ||
| width0 = self.tree.column('#0')['width'] | ||
| self.tree.column('#0', width=width0 + self.col2_width) | ||
| self.tree.column('#1', width=0) | ||
| self.labels = False | ||
| else: | ||
| width0 = self.tree.column('#0')['width'] |
There was a problem hiding this comment.
Function App.toggleLabels refactored with the following changes:
- Hoist repeated code outside conditional statement
| if self.weekly or self.monthly: | ||
| master = self.canvas | ||
| else: | ||
| master = self.tree | ||
|
|
||
| master = self.canvas if self.weekly or self.monthly else self.tree |
There was a problem hiding this comment.
Function App.selectCalendars refactored with the following changes:
- Replace if statement with if expression
| if mac: | ||
| cmd = 'open' + " {0}".format(path) | ||
| else: | ||
| cmd = 'xdg-open' + " {0}".format(path) | ||
| cmd = 'open' + " {0}".format(path) if mac else 'xdg-open' + " {0}".format(path) |
There was a problem hiding this comment.
Function App.openWithDefault refactored with the following changes:
- Replace if statement with if expression
| return | ||
| else: | ||
| cmd = "lp -s -o media='letter' -o cpi=12 -o lpi=8 -o page-left=48 -o page-right=48 -o page-top=48 -o page-bottom=48 {0}\n".format(loop.tmpfile) | ||
| # cmd = "lpr -l {0}".format(loop.tmpfile) | ||
| self.check_output(cmd) | ||
| return | ||
|
|
||
| return |
There was a problem hiding this comment.
Function App.printWithDefault refactored with the following changes:
- Hoist repeated code outside conditional statement
Branch
masterrefactored by Sourcery.If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.
See our documentation here.
Run Sourcery locally
Reduce the feedback loop during development by using the Sourcery editor plugin:
Review changes via command line
To manually merge these changes, make sure you're on the
masterbranch, then run: