diff options
author | Jauhien Piatlicki <jauhien@gentoo.org> | 2015-04-17 17:02:38 +0200 |
---|---|---|
committer | Jauhien Piatlicki <jauhien@gentoo.org> | 2015-04-17 19:10:47 +0200 |
commit | d01b0ddac70c475225b73f36a4b863598653b0b0 (patch) | |
tree | 5ac711e745e0a6d41e58141ea2810d8f794e9bd4 /g_sorcery/db_layout.py | |
parent | [g_sorcery/file_bson] fix BSON support and add tests for it (diff) | |
download | g-sorcery-d01b0ddac70c475225b73f36a4b863598653b0b0.tar.gz g-sorcery-d01b0ddac70c475225b73f36a4b863598653b0b0.tar.bz2 g-sorcery-d01b0ddac70c475225b73f36a4b863598653b0b0.zip |
[g_sorcery/db_layout] fix BSON support and add tests for it
Diffstat (limited to 'g_sorcery/db_layout.py')
-rw-r--r-- | g_sorcery/db_layout.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/g_sorcery/db_layout.py b/g_sorcery/db_layout.py index 1f4514c..da779bd 100644 --- a/g_sorcery/db_layout.py +++ b/g_sorcery/db_layout.py @@ -40,7 +40,7 @@ SUPPORTED_FILE_FORMATS = {JSON_FILE_SUFFIX: CategoryJSON} # bson module is optional, we should check if it is installed try: - from g_sorcery.file_bson.file_bson import FileBSON + from .file_bson.file_bson import FileBSON class CategoryBSON(FileBSON): """ @@ -172,9 +172,13 @@ def get_layout(metadata): return (CategoryJSON, [file_name(CATEGORIES_FILE_NAME)]) elif layout_version == 1: category_format = metadata['category_format'] + wrong_fmt = True try: category_cls = SUPPORTED_FILE_FORMATS[category_format] + wrong_fmt = False except KeyError: + pass + if wrong_fmt: raise DBLayoutError("unsupported packages file format: " + category_format) return (category_cls, [file_name(CATEGORIES_FILE_NAME), file_name(METADATA_FILE_NAME)]) else: |