diff options
author | Picca Frédéric-Emmanuel <picca@debian.org> | 2021-01-06 14:10:12 +0100 |
---|---|---|
committer | Picca Frédéric-Emmanuel <picca@debian.org> | 2021-01-06 14:10:12 +0100 |
commit | b3bea947efa55d2c0f198b6c6795b3177be27f45 (patch) | |
tree | 4116758aafe4483bf472c1d54b519e685737fd77 /silx/io/url.py | |
parent | 5ad425ff4e62f5e003178813ebd073577679a00e (diff) |
New upstream version 0.14.0+dfsg
Diffstat (limited to 'silx/io/url.py')
-rw-r--r-- | silx/io/url.py | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/silx/io/url.py b/silx/io/url.py index 7607ae5..044977c 100644 --- a/silx/io/url.py +++ b/silx/io/url.py @@ -178,8 +178,20 @@ class DataUrl(object): def str_to_slice(string): if string == "...": return Ellipsis - elif string == ":": - return slice(None) + elif ':' in string: + if string == ":": + return slice(None) + else: + def get_value(my_str): + if my_str in ('', None): + return None + else: + return int(my_str) + sss = string.split(':') + start = get_value(sss[0]) + stop = get_value(sss[1] if len(sss) > 1 else None) + step = get_value(sss[2] if len(sss) > 2 else None) + return slice(start, stop, step) else: return int(string) @@ -201,7 +213,10 @@ class DataUrl(object): :param str path: Path representing the URL. """ self.__path = path - path = path.replace("::", "?", 1) + # only replace if ? not here already. Otherwise can mess sith + # data_slice if == ::2 for example + if '?' not in path: + path = path.replace("::", "?", 1) url = parse.urlparse(path) is_valid = True |