mirror of
https://github.com/novoid/filetags.git
synced 2026-02-16 14:04:14 +00:00
Merge pull request #81 from jneidel/fix-open
Fix codecs.open deprecation warning
This commit is contained in:
commit
7c56c70774
2 changed files with 17 additions and 2 deletions
|
|
@ -52,7 +52,6 @@ from tkinter import ttk ## for --gui
|
|||
safe_import('operator') # for sorting dicts
|
||||
safe_import('difflib') # for good enough matching words
|
||||
safe_import('readline') # for raw_input() reading from stdin
|
||||
safe_import('codecs') # for handling Unicode content in .tagfiles
|
||||
safe_import('math') # (integer) calculations
|
||||
safe_import('clint') # for config file handling
|
||||
safe_import('itertools') # for calculating permutations of tagtrees
|
||||
|
|
@ -2024,7 +2023,7 @@ def parse_controlled_vocabulary(filename):
|
|||
included_files.append(os.path.realpath(filename))
|
||||
|
||||
tags = []
|
||||
with codecs.open(filename, encoding='utf-8') as filehandle:
|
||||
with open(filename, encoding='utf-8') as filehandle:
|
||||
logging.debug('parse_controlled_vocabulary: reading controlled vocabulary in [%s]' %
|
||||
filename)
|
||||
global controlled_vocabulary_filename
|
||||
|
|
|
|||
|
|
@ -461,6 +461,22 @@ class TestLocateAndParseControlledVocabulary(unittest.TestCase):
|
|||
cv = filetags.locate_and_parse_controlled_vocabulary(cv_file)
|
||||
self.assertEqual(set(cv), set(["foo", "bar", "baz", "tag"]))
|
||||
|
||||
def test_unicode_symbols_in_cv(self):
|
||||
"""
|
||||
Ensure unicode symbols and non-ASCII characters in controlled vocabulary
|
||||
files are parsed correctly.
|
||||
"""
|
||||
tempdir = tempfile.mkdtemp(prefix='TestControlledVocabulary_Unicode_')
|
||||
print("\ntempdir: " + tempdir + ' <<<' + '#' * 10)
|
||||
assert(os.path.isdir(tempdir))
|
||||
|
||||
cv_file = os.path.join(tempdir, '.filetags')
|
||||
self.create_file(cv_file, "café\nnaïve\npi_π\nstar_★\nsnow_雪\n")
|
||||
assert(os.path.isfile(cv_file))
|
||||
|
||||
cv = filetags.locate_and_parse_controlled_vocabulary(cv_file)
|
||||
self.assertEqual(set(cv), set(["café", "naïve", "pi_π", "star_★", "snow_雪"]))
|
||||
|
||||
|
||||
def test_include_lines_in_cv_not_circular(self):
|
||||
"""
|
||||
|
|
|
|||
Loading…
Reference in a new issue