Skip to content

Commit 52c90a4

Browse files
Fix deprecation warnings
1 parent 5a769f5 commit 52c90a4

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

cloudinary_cli/core/overrides.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
from click.parser import split_opt
21
from click.utils import make_str
32
from cloudinary import api, uploader
43
from cloudinary.uploader import upload as original_upload
54
from cloudinary.utils import cloudinary_url as original_cloudinary_url
5+
from cloudinary_cli.utils.utils import split_opt
66

77

88
# overrides click.MultiCommand.resolve_command

cloudinary_cli/utils/utils.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,3 +379,25 @@ def duplicate_values(items, value_key, key_of_interest=None):
379379
rev_multidict.setdefault(value[value_key], set()).add(value[key_of_interest] if key_of_interest is not None else key)
380380

381381
return {key: values for key, values in rev_multidict.items() if len(values) > 1}
382+
383+
384+
def split_opt(opt):
385+
"""
386+
Splits an option string into prefix and value parts.
387+
388+
This function replaces the deprecated click.parser.split_opt import.
389+
Returns a tuple of (prefix, value) where prefix is the option prefix
390+
(like '-' or '--') and value is the remaining part, or ('', opt)
391+
if it doesn't look like an option.
392+
393+
:param opt: The option string to parse.
394+
:type opt: str
395+
:return: Tuple of (prefix, value)
396+
:rtype: tuple
397+
"""
398+
first = opt[:1]
399+
if first.isalnum():
400+
return '', opt
401+
if opt[1:2] == first:
402+
return opt[:2], opt[2:]
403+
return first, opt[1:]

0 commit comments

Comments
 (0)