Cosmit
This commit is contained in:
parent
0dd51aff58
commit
81f2661593
@ -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:
|
||||
|
@ -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)]
|
||||
|
||||
|
@ -39,6 +39,7 @@ else:
|
||||
# for test_usecase.
|
||||
def _get_raw_stdout():
|
||||
return sys.stdout.buffer
|
||||
|
||||
def _get_raw_stderr():
|
||||
return sys.stderr.buffer
|
||||
|
||||
|
15
pubs/repo.py
15
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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user