summaryrefslogtreecommitdiff
path: root/backend/endpoints/get_plist.py
blob: 76275b7331940e59e5e9907d49f1dc225e295b8b (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
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))