mirror of
https://github.com/joshuadavidthomas/django-language-server.git
synced 2025-07-23 12:25:05 +00:00
move scripts to dedicated module (#13)
This commit is contained in:
parent
5c8157057a
commit
cb10d0ca1e
6 changed files with 1 additions and 1 deletions
21
python/djls/scripts/has_import.py
Normal file
21
python/djls/scripts/has_import.py
Normal file
|
@ -0,0 +1,21 @@
|
|||
# has_import.py
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import sys
|
||||
|
||||
|
||||
def check_import(module: str) -> bool:
|
||||
try:
|
||||
module_parts = module.split(".")
|
||||
current = __import__(module_parts[0])
|
||||
for part in module_parts[1:]:
|
||||
current = getattr(current, part)
|
||||
return True
|
||||
except (ImportError, AttributeError):
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
result = {"can_import": check_import(sys.argv[1])}
|
||||
print(json.dumps(result))
|
Loading…
Add table
Add a link
Reference in a new issue