mirror of
https://gitee.com/openharmony/third_party_jinja2
synced 2024-11-23 23:29:58 +00:00
Simplify splitting import_name in import_string()
This commit is contained in:
parent
9a877fa6c7
commit
486a2f4afa
@ -136,9 +136,7 @@ def import_string(import_name, silent=False):
|
||||
if ':' in import_name:
|
||||
module, obj = import_name.split(':', 1)
|
||||
elif '.' in import_name:
|
||||
items = import_name.split('.')
|
||||
module = '.'.join(items[:-1])
|
||||
obj = items[-1]
|
||||
module, _, obj = import_name.rpartition('.')
|
||||
else:
|
||||
return __import__(import_name)
|
||||
return getattr(__import__(module, None, None, [obj]), obj)
|
||||
|
Loading…
Reference in New Issue
Block a user