Further fixes for python3
This commit is contained in:
parent
07d8d43a7c
commit
bb297adfc5
@ -9,7 +9,7 @@
|
|||||||
# Phyks
|
# Phyks
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
from __future__ import unicode_literals
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import libbmc.tools as tools
|
import libbmc.tools as tools
|
||||||
@ -136,7 +136,7 @@ def deleteId(ident):
|
|||||||
try:
|
try:
|
||||||
with open(config.get("folder")+'index.bib', 'r', encoding='utf-8') \
|
with open(config.get("folder")+'index.bib', 'r', encoding='utf-8') \
|
||||||
as fh:
|
as fh:
|
||||||
bibtex = BibTexParser(fh.read().decode('utf-8'))
|
bibtex = BibTexParser(fh.read())
|
||||||
bibtex = bibtex.get_entry_dict()
|
bibtex = bibtex.get_entry_dict()
|
||||||
except (IOError, TypeError):
|
except (IOError, TypeError):
|
||||||
tools.warning("Unable to open index file.")
|
tools.warning("Unable to open index file.")
|
||||||
@ -172,7 +172,7 @@ def deleteFile(filename):
|
|||||||
try:
|
try:
|
||||||
with open(config.get("folder")+'index.bib', 'r', encoding='utf-8') \
|
with open(config.get("folder")+'index.bib', 'r', encoding='utf-8') \
|
||||||
as fh:
|
as fh:
|
||||||
bibtex = BibTexParser(fh.read().decode('utf-8'))
|
bibtex = BibTexParser(fh.read())
|
||||||
bibtex = bibtex.get_entry_dict()
|
bibtex = bibtex.get_entry_dict()
|
||||||
except (TypeError, IOError):
|
except (TypeError, IOError):
|
||||||
tools.warning("Unable to open index file.")
|
tools.warning("Unable to open index file.")
|
||||||
@ -315,7 +315,7 @@ def updateArXiv(entry):
|
|||||||
|
|
||||||
last_bibtex = BibTexParser(fetcher.arXiv2Bib(arxiv_id_no_v))
|
last_bibtex = BibTexParser(fetcher.arXiv2Bib(arxiv_id_no_v))
|
||||||
last_bibtex = last_bibtex.get_entry_dict()
|
last_bibtex = last_bibtex.get_entry_dict()
|
||||||
last_bibtex = last_bibtex[last_bibtex.keys()[0]]
|
last_bibtex = last_bibtex[list(last_bibtex.keys())[0]]
|
||||||
|
|
||||||
if last_bibtex['eprint'] not in ids:
|
if last_bibtex['eprint'] not in ids:
|
||||||
return last_bibtex
|
return last_bibtex
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import unicode_literals
|
||||||
import os
|
import os
|
||||||
import errno
|
import errno
|
||||||
import imp
|
import imp
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
# <del>beer</del> soda in return.
|
# <del>beer</del> soda in return.
|
||||||
# Phyks
|
# Phyks
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
from __future__ import unicode_literals
|
||||||
import unittest
|
import unittest
|
||||||
from libbmc.backend import *
|
from libbmc.backend import *
|
||||||
from bibtexparser.bparser import BibTexParser
|
from bibtexparser.bparser import BibTexParser
|
||||||
@ -43,7 +44,7 @@ Lattice},
|
|||||||
year={2013},
|
year={2013},
|
||||||
}""" % config.get("folder")
|
}""" % config.get("folder")
|
||||||
self.bibtex_article = BibTexParser(self.bibtex_article_string).get_entry_dict()
|
self.bibtex_article = BibTexParser(self.bibtex_article_string).get_entry_dict()
|
||||||
self.bibtex_article = self.bibtex_article[self.bibtex_article.keys()[0]]
|
self.bibtex_article = self.bibtex_article[list(self.bibtex_article.keys())[0]]
|
||||||
|
|
||||||
self.bibtex_book_string = """
|
self.bibtex_book_string = """
|
||||||
@book{9780521846516,
|
@book{9780521846516,
|
||||||
@ -55,7 +56,7 @@ Lattice},
|
|||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
self.bibtex_book = BibTexParser(self.bibtex_book_string).get_entry_dict()
|
self.bibtex_book = BibTexParser(self.bibtex_book_string).get_entry_dict()
|
||||||
self.bibtex_book = self.bibtex_book[self.bibtex_book.keys()[0]]
|
self.bibtex_book = self.bibtex_book[list(self.bibtex_book.keys())[0]]
|
||||||
|
|
||||||
def test_getNewName_article(self):
|
def test_getNewName_article(self):
|
||||||
self.assertEqual(getNewName("test.pdf", self.bibtex_article),
|
self.assertEqual(getNewName("test.pdf", self.bibtex_article),
|
||||||
@ -99,7 +100,7 @@ Lattice},
|
|||||||
open(config.get("folder")+'test.pdf', 'w').close()
|
open(config.get("folder")+'test.pdf', 'w').close()
|
||||||
deleteId(self.bibtex_article['id'])
|
deleteId(self.bibtex_article['id'])
|
||||||
with open(config.get("folder")+'index.bib', 'r') as fh:
|
with open(config.get("folder")+'index.bib', 'r') as fh:
|
||||||
self.assertEquals(fh.read().strip(), "")
|
self.assertEqual(fh.read().strip(), "")
|
||||||
self.assertFalse(os.path.isfile(config.get("folder")+'test.pdf'))
|
self.assertFalse(os.path.isfile(config.get("folder")+'test.pdf'))
|
||||||
|
|
||||||
def test_deleteFile(self):
|
def test_deleteFile(self):
|
||||||
@ -108,7 +109,7 @@ Lattice},
|
|||||||
open(config.get("folder")+'test.pdf', 'w').close()
|
open(config.get("folder")+'test.pdf', 'w').close()
|
||||||
deleteFile(self.bibtex_article['file'])
|
deleteFile(self.bibtex_article['file'])
|
||||||
with open(config.get("folder")+'index.bib', 'r') as fh:
|
with open(config.get("folder")+'index.bib', 'r') as fh:
|
||||||
self.assertEquals(fh.read().strip(), "")
|
self.assertEqual(fh.read().strip(), "")
|
||||||
self.assertFalse(os.path.isfile(config.get("folder")+'test.pdf'))
|
self.assertFalse(os.path.isfile(config.get("folder")+'test.pdf'))
|
||||||
|
|
||||||
def test_diffFilesIndex(self):
|
def test_diffFilesIndex(self):
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
# <del>beer</del> soda in return.
|
# <del>beer</del> soda in return.
|
||||||
# Phyks
|
# Phyks
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
from __future__ import unicode_literals
|
||||||
import unittest
|
import unittest
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
# <del>beer</del> soda in return.
|
# <del>beer</del> soda in return.
|
||||||
# Phyks
|
# Phyks
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
from libbmc.tools import *
|
from libbmc.tools import *
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function, unicode_literals
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
@ -72,8 +72,7 @@ def rawInput(string):
|
|||||||
|
|
||||||
def warning(*objs):
|
def warning(*objs):
|
||||||
"""Write warnings to stderr"""
|
"""Write warnings to stderr"""
|
||||||
printed = [i.encode('utf-8') for i in objs]
|
print("WARNING: ", *objs, file=sys.stderr)
|
||||||
print("WARNING: ", *printed, file=sys.stderr)
|
|
||||||
|
|
||||||
|
|
||||||
def listDir(path):
|
def listDir(path):
|
||||||
|
Loading…
Reference in New Issue
Block a user