diff --git a/Makefile b/Makefile index e641d0dd9..ab7ab9dcc 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ html: $(MAKE) -C docs html style: - $(PYTHON) $(CHECKSCRIPT) $(PLYER_DIR) + $(PYTHON) $(CHECKSCRIPT) . stylereport: $(PYTHON) $(CHECKSCRIPT) -html $(PLYER_DIR) diff --git a/plyer/platforms/linux/filechooser.py b/plyer/platforms/linux/filechooser.py index 8b44ad384..093102a7e 100644 --- a/plyer/platforms/linux/filechooser.py +++ b/plyer/platforms/linux/filechooser.py @@ -50,7 +50,7 @@ def _run_command(self, cmd): self._process = sp.Popen(cmd, stdout=sp.PIPE) while True: ret = self._process.poll() - if ret != None: + if ret is not None: if ret == self.successretcode: out = self._process.communicate()[0].strip() self.selection = self._split_output(out) @@ -88,7 +88,8 @@ class ZenityFileChooser(SubprocessFileChooser): successretcode = 0 def _gen_cmdline(self): - cmdline = [which(self.executable), "--file-selection", "--confirm-overwrite"] + cmdline = [which(self.executable), + "--file-selection", "--confirm-overwrite"] if self.multiple: cmdline += ["--multiple"] if self.mode == "save": @@ -98,16 +99,20 @@ def _gen_cmdline(self): if self.path: cmdline += ["--filename", self.path] if self.title: - cmdline += ["--name", self.title] + cmdline += ["--name", self.title] if self.icon: cmdline += ["--window-icon", self.icon] for f in self.filters: if type(f) == str: cmdline += ["--file-filter", f] else: - cmdline += ["--file-filter", "{name} | {flt}".format(name=f[0], flt=" ".join(f[1:]))] + cmdline += [ + "--file-filter", + "{name} | {flt}".format(name=f[0], flt=" ".join(f[1:])) + ] return cmdline + class KDialogFileChooser(SubprocessFileChooser): """A FileChooser implementation using KDialog (on GNU/Linux). @@ -132,11 +137,22 @@ def _gen_cmdline(self): filt += list(f[1:]) if self.mode == "dir": - cmdline += ["--getexistingdirectory", (self.path if self.path else os.path.expanduser("~"))] + cmdline += [ + "--getexistingdirectory", + (self.path if self.path else os.path.expanduser("~")) + ] elif self.mode == "save": - cmdline += ["--getopenfilename", (self.path if self.path else os.path.expanduser("~")), " ".join(filt)] + cmdline += [ + "--getopenfilename", + (self.path if self.path else os.path.expanduser("~")), + " ".join(filt) + ] else: - cmdline += ["--getopenfilename", (self.path if self.path else os.path.expanduser("~")), " ".join(filt)] + cmdline += [ + "--getopenfilename", + (self.path if self.path else os.path.expanduser("~")), + " ".join(filt) + ] if self.multiple: cmdline += ["--multiple", "--separate-output"] if self.title: @@ -145,6 +161,7 @@ def _gen_cmdline(self): cmdline += ["--icon", self.icon] return cmdline + class YADFileChooser(SubprocessFileChooser): """A NativeFileChooser implementation using YAD (on GNU/Linux). @@ -157,7 +174,8 @@ class YADFileChooser(SubprocessFileChooser): successretcode = 0 def _gen_cmdline(self): - cmdline = [which(self.executable), "--file-selection", "--confirm-overwrite", "--geometry", "800x600+150+150"] + cmdline = [which(self.executable), "--file-selection", + "--confirm-overwrite", "--geometry", "800x600+150+150"] if self.multiple: cmdline += ["--multiple", "--separator", self.separator] if self.mode == "save": @@ -169,19 +187,25 @@ def _gen_cmdline(self): if self.path: cmdline += ["--filename", self.path] if self.title: - cmdline += ["--name", self.title] + cmdline += ["--name", self.title] if self.icon: cmdline += ["--window-icon", self.icon] for f in self.filters: if type(f) == str: cmdline += ["--file-filter", f] else: - cmdline += ["--file-filter", "{name} | {flt}".format(name=f[0], flt=" ".join(f[1:]))] + cmdline += [ + "--file-filter", + "{name} | {flt}".format(name=f[0], flt=" ".join(f[1:])) + ] return cmdline -CHOOSERS = {"gnome": ZenityFileChooser, - "kde": KDialogFileChooser, - "yad": YADFileChooser} +CHOOSERS = { + "gnome": ZenityFileChooser, + "kde": KDialogFileChooser, + "yad": YADFileChooser +} + class LinuxFileChooser(FileChooser): """FileChooser implementation for GNu/Linux. Accepts one additional @@ -193,7 +217,8 @@ class LinuxFileChooser(FileChooser): """ desktop = None - if str(os.environ.get("XDG_CURRENT_DESKTOP")).lower() == "kde" and which("kdialog"): + if str(os.environ.get("XDG_CURRENT_DESKTOP")).lower() == "kde" \ + and which("kdialog"): desktop = "kde" elif which("yad"): desktop = "yad" diff --git a/plyer/platforms/win/filechooser.py b/plyer/platforms/win/filechooser.py index 80cd43189..8c478c741 100644 --- a/plyer/platforms/win/filechooser.py +++ b/plyer/platforms/win/filechooser.py @@ -46,7 +46,7 @@ def run(self): args = {} if self.path: - atgs["InitialDir"] = os.path.dirname(self.path) + args["InitialDir"] = os.path.dirname(self.path) args["File"] = os.path.splitext(os.path.dirname(self.path))[0] args["DefExt"] = os.path.splitext(os.path.dirname(self.path))[1] args["Title"] = self.title if self.title else "Pick a file..." diff --git a/plyer/tools/pep8checker/pep8.py b/plyer/tools/pep8checker/pep8.py index bc79acdc9..5daeb4339 100644 --- a/plyer/tools/pep8checker/pep8.py +++ b/plyer/tools/pep8checker/pep8.py @@ -106,9 +106,9 @@ def blank_lines(logical_line, blank_lines, indent_level, line_number) from fnmatch import fnmatch try: from ConfigParser import RawConfigParser - from io import TextIOWrapper except ImportError: from configparser import RawConfigParser + from io import TextIOWrapper DEFAULT_EXCLUDE = '.svn,CVS,.bzr,.hg,.git' DEFAULT_IGNORE = 'E24' @@ -1328,6 +1328,26 @@ def check_all(self, expected=None, line_offset=0): pos = 'l.%s' % token[3][0] print(('l.%s\t%s\t%s\t%r' % (token[2][0], pos, tokenize.tok_name[token[0]], text))) + if token_type == tokenize.COMMENT or token_type == tokenize.STRING: + for sre in re.finditer(r"[:.;,] ?[A-Za-z]", text): + pos = sre.span()[0] + part = text[:pos] + line = token[2][0] + part.count('\n') + offset = 0 if part.count('\n') > 0 else token[2][1] + col = offset + pos - part.rfind('\n') + 1 + if sre.group(0)[0] == '.': + self.report_error(line, col, + 'E289 Too many spaces after period. Use only one.', + check=None) + elif sre.group(0)[0] == ',': + self.report_error(line, col, + 'E288 Too many spaces after comma. Use only one.', + check=None) + else: + self.report_error(line, col, + 'E287 Too many spaces after punctuation. ' + 'Use only one.', + check=None) if token_type == tokenize.OP: if text in '([{': parens += 1 @@ -1352,6 +1372,11 @@ def check_all(self, expected=None, line_offset=0): if COMMENT_WITH_NL: # The comment also ends a physical line self.tokens = [] + if self.blank_lines > 1: + self.report_error(token[2][0],0, + 'E389 File ends in multiple blank lines', + check=None) + return self.report.get_file_results() @@ -1479,7 +1504,7 @@ def error(self, line_number, offset, text, check): line = self.lines[line_number - 1] print((line.rstrip())) print((' ' * offset + '^')) - if self._show_pep8: + if self._show_pep8 and check is not None: print((check.__doc__.lstrip('\n').rstrip())) return code diff --git a/plyer/tools/pep8checker/pep8kivy.py b/plyer/tools/pep8checker/pep8kivy.py index 96e013581..245928e57 100644 --- a/plyer/tools/pep8checker/pep8kivy.py +++ b/plyer/tools/pep8checker/pep8kivy.py @@ -57,8 +57,11 @@ def check(fn): return checker.check_all() errors = 0 - exclude_dirs = ['/pep8', '/doc'] - exclude_files = [] + exclude_dirs = ['/lib', '/coverage', '/pep8', '/doc'] + exclude_files = ['kivy/gesture.py', 'osx/build.py', 'win32/build.py', + 'kivy/tools/stub-gl-debug.py', + 'kivy/modules/webdebugger.py', + 'kivy/modules/_webdebugger.py'] for target in targets: if isdir(target): if htmlmode: