Skip to content

Commit 74bd435

Browse files
committed
add checks for previous auth rules config that needs to be updated
1 parent 8e13d24 commit 74bd435

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

loris/resolver.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@
22
`resolver` -- Resolve Identifiers to Image Paths
33
================================================
44
"""
5+
from contextlib import closing
6+
import glob
7+
import json
58
from logging import getLogger
69
from os.path import join, exists, dirname, split
710
from os import remove
811
from shutil import copy
912
import tempfile
10-
from contextlib import closing
11-
import glob
12-
import json
13-
import os
1413
from urllib.parse import unquote
14+
import warnings
1515

1616
import requests
1717

1818
from loris import constants
1919
from loris.identifiers import CacheNamer, IdentRegexChecker
20-
from loris.loris_exception import ResolverException
20+
from loris.loris_exception import ResolverException, ConfigError
2121
from loris.utils import mkdir_p, safe_rename
2222
from loris.img_info import ImageInfo
2323

@@ -30,6 +30,14 @@ class _AbstractResolver:
3030
def __init__(self, config):
3131
self.config = config
3232
if config:
33+
# check for previous settings
34+
if "use_extra_info" in self.config and "use_auth_rules" in self.config:
35+
raise ConfigError("You cannot set both use_extra_info and use_auth_rules. Please remove use_extra_info from your config.")
36+
37+
if "use_extra_info" in self.config:
38+
warnings.warn("The use_extra_info field has been renamed to use_auth_rules and will be removed in a future version. Please update your config.", DeprecationWarning)
39+
self.config["use_auth_rules"] = self.config["use_extra_info"]
40+
3341
self.auth_rules_ext = self.config.get('auth_rules_ext', 'rules.json')
3442
self.use_auth_rules = self.config.get('use_auth_rules', False)
3543

@@ -269,7 +277,7 @@ def _web_request_url(self, ident):
269277
return (url, self.request_options())
270278

271279
def cache_dir_path(self, ident):
272-
return os.path.join(
280+
return join(
273281
self.cache_root,
274282
CacheNamer.cache_directory_name(ident=ident),
275283
ident,

0 commit comments

Comments
 (0)