summaryrefslogtreecommitdiff
path: root/backend/endpoints/get_plist.py
blob: cfa56bf7803fd360e049f38cca9993976d8622c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import json
import logging
import os
import plistlib
import sys

sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
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 == ".." or entry.name == "Resources":
                continue
            if(os.DirEntry.is_dir(entry)):
                find_plist(path + "/" + entry.name)
            elif(entry.name == "Info.plist"):
                #parse_plist(path + "/" + entry.name)
                output["paths"].append(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))