diff --git a/pubs/bibstruct.py b/pubs/bibstruct.py index 30af00b..a8312b0 100644 --- a/pubs/bibstruct.py +++ b/pubs/bibstruct.py @@ -51,6 +51,12 @@ def author_last(author_str): return author_str.split(',')[0] +def valid_citekey(citekey): + """Return if a citekey is a valid filename or not""" + # FIXME: a bit crude, but efficient for now (and allows unicode citekeys) + return not '/' in citekey + + def generate_citekey(bibdata): """ Generate a citekey from bib_data. diff --git a/pubs/commands/__init__.py b/pubs/commands/__init__.py index ddd40ad..ed5defa 100644 --- a/pubs/commands/__init__.py +++ b/pubs/commands/__init__.py @@ -18,4 +18,3 @@ from . import import_cmd # bonus from . import websearch_cmd from . import url_cmd -#from . import bibtex_cmd diff --git a/pubs/pubs_cmd.py b/pubs/pubs_cmd.py index 08911cb..740c709 100644 --- a/pubs/pubs_cmd.py +++ b/pubs/pubs_cmd.py @@ -32,7 +32,6 @@ CORE_CMDS = collections.OrderedDict([ ('websearch', commands.websearch_cmd), ('url', commands.url_cmd), - #('bibtex', commands.bibtex_cmd), ]) diff --git a/pubs/repo.py b/pubs/repo.py index f747bf3..69ca1d7 100644 --- a/pubs/repo.py +++ b/pubs/repo.py @@ -198,11 +198,9 @@ class Repository(object): :param base_key: the base key in question. :param bibentry: the bib entry to possibly generate the citekey. """ - # can't have `/` in citekeys - # FIXME: a bit crude, but efficient for now (and allows unicode citekeys) - # TODO: check that the generated citekey does not have a slash too. - if '/' in base_key: + if not bibstruct.valid_citekey(base_key): base_key = bibstruct.generate_citekey(bibentry) + # TODO: check that the generated citekey does not have a slash too. for n in itertools.count(): if not base_key + _base27(n) in self.citekeys: return base_key + _base27(n)