diff --git a/pubs/content.py b/pubs/content.py index 796302b..ee5f2af 100644 --- a/pubs/content.py +++ b/pubs/content.py @@ -52,16 +52,17 @@ def _open(path, mode): else: return open(system_path(path), mode, encoding='utf-8') + def check_file(path, fail=True): syspath = system_path(path) - return (_check_system_path_exists(syspath, fail=fail) - and _check_system_path_is(u'isfile', syspath, fail=fail)) + return (_check_system_path_exists(syspath, fail=fail) and + _check_system_path_is(u'isfile', syspath, fail=fail)) def check_directory(path, fail=True): syspath = system_path(path) - return (_check_system_path_exists(syspath, fail=fail) - and _check_system_path_is(u'isdir', syspath, fail=fail)) + return (_check_system_path_exists(syspath, fail=fail) and + _check_system_path_is(u'isdir', syspath, fail=fail)) def read_text_file(filepath, fail=True): @@ -79,6 +80,7 @@ def read_text_file(filepath, fail=True): return content + def read_binary_file(filepath, fail=True): check_file(filepath, fail=fail) with _open(filepath, 'rb') as f: diff --git a/pubs/filebroker.py b/pubs/filebroker.py index 47a8bd8..c20ceea 100644 --- a/pubs/filebroker.py +++ b/pubs/filebroker.py @@ -13,7 +13,7 @@ def filter_filename(filename, ext): """ Return the filename without the extension if the extension matches ext. Otherwise return None """ - pattern ='.*\{}$'.format(ext) + pattern = '.*\{}$'.format(ext) if re.match(pattern, filename) is not None: return filename[:-len(ext)] diff --git a/pubs/p3.py b/pubs/p3.py index 93229d6..9c9082c 100644 --- a/pubs/p3.py +++ b/pubs/p3.py @@ -39,6 +39,7 @@ else: # for test_usecase. def _get_raw_stdout(): return sys.stdout.buffer + def _get_raw_stderr(): return sys.stderr.buffer diff --git a/pubs/repo.py b/pubs/repo.py index 32026d3..fd942b0 100644 --- a/pubs/repo.py +++ b/pubs/repo.py @@ -110,8 +110,9 @@ class Repository(object): self.databroker.remove_note(citekey, self.conf['main']['note_extension'], silent=True) except IOError: - pass # FIXME: if IOError is about being unable to - # remove the file, we need to issue an error. + # FIXME: if IOError is about being unable to + # remove the file, we need to issue an error. + pass self.citekeys.remove(citekey) self.databroker.remove(citekey) @@ -126,16 +127,18 @@ class Repository(object): p.docpath = None self.push_paper(p, overwrite=True, event=False) except IOError: - pass # FIXME: if IOError is about being unable to - # remove the file, we need to issue an error.I + # FIXME: if IOError is about being unable to + # remove the file, we need to issue an error.I + pass def pull_docpath(self, citekey): try: p = self.pull_paper(citekey) return self.databroker.real_docpath(p.docpath) except IOError: - pass # FIXME: if IOError is about being unable to - # remove the file, we need to issue an error.I + # FIXME: if IOError is about being unable to + # remove the file, we need to issue an error.I + pass def rename_paper(self, paper, new_citekey=None, old_citekey=None): if old_citekey is None: