inspirehep/ops — pull request #7 by tsgit (2014-06-03 21:57:48+00:00)
Title: BibDocFile: ignore purely numerical extensions

currently the mimetypes modules is used to generate a list of extensions used by bibdocfile to split names into basename + extension.

this is suboptimal, since the list of recognized extensions is quite long and contains many things that might show up as part of a regular basename containing a dot, e.g. figure.1.ps

this patch removes purely numerical extensions from the list to address that specific issue. a more general overhaul of extension handling should be done as resources permit

the effect of the patch is demonstrated here:

In [34]: _tmp_extensions = _mimes.encodings_map.keys() + \
_mimes.suffix_map.keys() + \
_mimes.types_map[1].keys()

In [35]: full=_tmp_extensions

In [36]: nonum=[ext for ext in _tmp_extensions if not ext.strip('.').isdigit()]

In [37]: set(full) - set(nonum)
Out[37]: set(['.3', '.726', '.8', '.6', '.1', '.2', '.669', '.4', '.5', '.123', '.7'])

In [38]: set(nonum) - set(full)
Out[38]: set([])