Bugfix with tempfile
This commit is contained in:
parent
6e6418fbad
commit
0c8e52844a
@ -100,9 +100,10 @@ Here are some sources of inspirations for this project :
|
|||||||
|
|
||||||
A list of ideas and TODO. Don't hesitate to give feedback on the ones you really want or to propose your owns.
|
A list of ideas and TODO. Don't hesitate to give feedback on the ones you really want or to propose your owns.
|
||||||
|
|
||||||
* if doi not found ? if no doi ?
|
* if doi does not exist ?
|
||||||
* store url of articles
|
* download djvu
|
||||||
* test file field for bibtex
|
* test file field for bibtex
|
||||||
|
* No fail if proxy not accessible
|
||||||
* Open
|
* Open
|
||||||
* Confirmation for deletion
|
* Confirmation for deletion
|
||||||
* Rebuild
|
* Rebuild
|
||||||
|
11
main.py
11
main.py
@ -267,6 +267,7 @@ def addFile(src, filetype):
|
|||||||
else:
|
else:
|
||||||
# Idem
|
# Idem
|
||||||
bibtex = isbn2Bib(isbn).strip()+"\n"
|
bibtex = isbn2Bib(isbn).strip()+"\n"
|
||||||
|
|
||||||
bibtex = checkBibtex(src, bibtex)
|
bibtex = checkBibtex(src, bibtex)
|
||||||
|
|
||||||
authors = re.split(' and ', bibtex['author'])
|
authors = re.split(' and ', bibtex['author'])
|
||||||
@ -296,7 +297,7 @@ def addFile(src, filetype):
|
|||||||
else:
|
else:
|
||||||
new_name = rename
|
new_name = rename
|
||||||
bibtex['file'] = new_name
|
bibtex['file'] = new_name
|
||||||
|
|
||||||
try:
|
try:
|
||||||
shutil.copy2(src, new_name)
|
shutil.copy2(src, new_name)
|
||||||
except IOError:
|
except IOError:
|
||||||
@ -352,13 +353,13 @@ def deleteFile(filename):
|
|||||||
|
|
||||||
|
|
||||||
def downloadFile(url, filetype):
|
def downloadFile(url, filetype):
|
||||||
pdf = fetcher.download_url(url)
|
dl = fetcher.download_url(url)
|
||||||
|
|
||||||
if pdf is not False:
|
if dl is not False:
|
||||||
tmp = tempfile.NamedTemporaryFile()
|
tmp = tempfile.NamedTemporaryFile(suffix='.pdf')
|
||||||
|
|
||||||
with open(tmp.name, 'w+') as fh:
|
with open(tmp.name, 'w+') as fh:
|
||||||
fh.write(pdf)
|
fh.write(dl)
|
||||||
new_name = addFile(tmp.name, filetype)
|
new_name = addFile(tmp.name, filetype)
|
||||||
tmp.close()
|
tmp.close()
|
||||||
return new_name
|
return new_name
|
||||||
|
Loading…
Reference in New Issue
Block a user