mirror of
https://github.com/joshuadavidthomas/django-language-server.git
synced 2025-07-07 20:55:02 +00:00
* add djls-django crate * rework * oops * add check for GDAL and GeoDjango * lots of things * remove unused scripts * move scripts to dedicated mod and make static consts * inline gdal check * rename mod * rename mod * move server info to consts * adjust pyproject * hide rustfmt config * simplify django setup * adjust printing
21 lines
492 B
Python
21 lines
492 B
Python
# 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))
|