Пример #1
0
def parseLocal(path, url=None):
    if not os.path.exists(path):
        print("File doesn't exists:", path)
        return
    with open(path) as f:
        home = Home()
        (dirname, filename, ext) = common.getFileParts(path)
        pathOut = os.path.join(dirname, filename + ".home.jhome")
        if os.path.exists(pathOut):
            jsonTools.load(home, pathOut)
        data = f.read()

        sources = {
            "pap.fr": parsePAP,
            "leboncoin.fr": parseLeBonCoin,
            "seloger.com": None,
            "acheter-louer.fr": None,
            "explorimmo.com": parseExplorimmo,
            "logic-immo.com": parseLogicImmo,
        }
        for key in sources:
            if (url and key.lower() in url.lower()) or (key in data):
                if sources[key]:
                    sources[key](home, data)
                    break
        if url:
            home.www = url
        home.validate()
        jsonTools.save(home, pathOut, encoding="utf-8")
        jsonTools.save(home, pathOut + ".bak", encoding="utf-8")
        return home
Пример #2
0
 def onClicked():
     home.sold = not home.sold
     filePath = self.getHomeFilePath(home)
     jsonTools.save(home, filePath)
     self.displayHomes()