diff options
author | Louie Shprung <lshprung@scu.edu> | 2023-04-01 17:14:09 -0700 |
---|---|---|
committer | Louie Shprung <lshprung@scu.edu> | 2023-04-01 17:14:09 -0700 |
commit | 18774e2e797f64cf951b3ba1ea8051ea6ad525f4 (patch) | |
tree | d600833a04fb7209ac48f3078fbfab4afa0bf7cc /backend/endpoints |
First commit
Diffstat (limited to 'backend/endpoints')
-rw-r--r-- | backend/endpoints/get_plist.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/backend/endpoints/get_plist.py b/backend/endpoints/get_plist.py new file mode 100644 index 0000000..76275b7 --- /dev/null +++ b/backend/endpoints/get_plist.py @@ -0,0 +1,40 @@ +import json +import logging +import os +import plistlib + +from ..config import Config + +output = dict() +output["paths"] = [] + +def find_plist(path): + with os.scandir(path) as it: + for entry in it: + if entry.name == "." or entry.name == "..": + continue + if(os.DirEntry.is_dir(entry)): + find_plist(path + "/" + entry.name) + elif(entry.name == "Info.plist"): + #parse_plist(path + "/" + entry.name) + output["paths"] += path + "/" + entry.name + +def parse_plist(path): + with open(path, "rb") as fp: + pl = plistlib.load(fp) + print(pl["CFBundleIdentifier"]) + print(pl["CFBundleName"]) + + + +if not os.path.isdir(Config.docset_base): + e = "Invalid DOCSET_BASE \"" + Config.docset_base + "\"" + logging.error(e); + output["success"] = False + output["message"] = e + +else: + find_plist(Config.docset_base); + output["success"] = True + +print(json.dumps(output)) |