diff options
-rw-r--r-- | lesana/collection.py | 20 | ||||
-rw-r--r-- | tests/data/simple/settings.yaml (renamed from tests/data/simple/schema.yaml) | 0 | ||||
-rw-r--r-- | tests/data/wrong/settings.yaml (renamed from tests/data/wrong/schema.yaml) | 0 | ||||
-rw-r--r-- | tests/test_collection.py | 10 |
4 files changed, 17 insertions, 13 deletions
diff --git a/lesana/collection.py b/lesana/collection.py index 64b4246..cff94f7 100644 --- a/lesana/collection.py +++ b/lesana/collection.py @@ -30,18 +30,21 @@ class Collection(object): def __init__(self, directory=None): self.basedir = directory or os.getcwd() try: - with open(os.path.join(self.basedir, 'schema.yaml')) as fp: - self.schema = ruamel.yaml.load(fp, ruamel.yaml.RoundTripLoader) + with open(os.path.join(self.basedir, 'settings.yaml')) as fp: + self.settings = ruamel.yaml.load( + fp, + ruamel.yaml.RoundTripLoader + ) except FileNotFoundError: - self.schema = ruamel.yaml.load("{}") + self.settings = ruamel.yaml.load("{}") os.makedirs(os.path.join(self.basedir, '.lesana'), exist_ok=True) - if 'lang' in self.schema: + if 'lang' in self.settings: try: - self.stemmer = xapian.Stem(self.schema['lang']) + self.stemmer = xapian.Stem(self.settings['lang']) except xapian.InvalidArgumentError: logging.warning( - "Invalid language %s, in schema.yaml: using english.", - self.schema['lang'] + "Invalid language %s, in settings.yaml: using english.", + self.settings['lang'] ) self.stemmer = xapian.Stem('english') else: @@ -105,7 +108,8 @@ class Collection(object): except IOError as e: logging.warning("Could not load file {}: {}".format( fname, - str(e))) + str(e)) + ) else: updated += 1 return updated diff --git a/tests/data/simple/schema.yaml b/tests/data/simple/settings.yaml index 177aa92..177aa92 100644 --- a/tests/data/simple/schema.yaml +++ b/tests/data/simple/settings.yaml diff --git a/tests/data/wrong/schema.yaml b/tests/data/wrong/settings.yaml index 56031e4..56031e4 100644 --- a/tests/data/wrong/schema.yaml +++ b/tests/data/wrong/settings.yaml diff --git a/tests/test_collection.py b/tests/test_collection.py index b70c85f..be9a4e5 100644 --- a/tests/test_collection.py +++ b/tests/test_collection.py @@ -12,7 +12,7 @@ class testCollectionLoading(unittest.TestCase): def test_empty(self): self.collection = lesana.Collection('tests/data/empty') - self.assertEqual(self.collection.schema, {}) + self.assertEqual(self.collection.settings, {}) self.collection.update_cache() self.assertIsNotNone(self.collection.cache) @@ -20,9 +20,9 @@ class testCollectionLoading(unittest.TestCase): def test_simple(self): self.collection = lesana.Collection('tests/data/simple') - self.assertIsNotNone(self.collection.schema) - self.assertEqual(self.collection.schema['name'], "Simple lesana collection") - self.assertEqual(len(self.collection.schema['fields']), 3) + self.assertIsNotNone(self.collection.settings) + self.assertEqual(self.collection.settings['name'], "Simple lesana collection") + self.assertEqual(len(self.collection.settings['fields']), 3) self.collection.update_cache() self.assertIsNotNone(self.collection.cache) @@ -36,7 +36,7 @@ class testCollectionLoading(unittest.TestCase): self.assertIn("Invalid language", cm.output[0]) # The collection will default to english, but should still work. self.collection.update_cache() - self.assertIsNotNone(self.collection.schema) + self.assertIsNotNone(self.collection.settings) self.assertIsNotNone(self.collection.cache) self.assertIsNotNone(self.collection.stemmer) |