Exemple #1
0
 def expandLine(self, s, event):
     logger.debug("expand1 <%s>", s)
     spos = 0
     while True:
         mp = paramRE.search(s, spos)
         if mp is None:
             logger.debug("noexp %s", s[spos:])
             self.insertText(s[spos:], self.run)
             return
         gp = mp.group(1).lower()
         # logger.debug("expand2 %s", gp)
         sp = mp.span()
         self.insertText(s[spos:sp[0]], self.run)
         mf = fmtRE.search(s, pos=spos)
         if mf is not None and sp[1] == mf.span(
         )[0]:  # i.e. if ${param] is followed immediately by .fmt()
             gf = mf.group(1)
             sf = mf.span()
             spos = sf[1]
             expanded = self.expandParam(gp, event, gf)
         else:
             expanded = self.expandParam(gp, event, None)
             spos = sp[1]
         # logger.debug("expand3 <%s>", str(expanded))
         if expanded is None:  # special case for beschreibung, handled as markdown
             return
         if isinstance(expanded, list):  # list is n runs + 1 string
             for run in expanded:
                 if isinstance(run, ScrbRun):
                     self.insertText(run.text, run)
                 else:
                     self.insertText(run, self.run)
         else:
             self.insertText(expanded, self.run)
Exemple #2
0
def getWinners(winners, lines, n, nbLines):
    res={}
    n=n-1
    while (n<nbLines):
        n=inc_n(n, nbLines)
        if n==nbLines : break
        pattern = re.compile(r"wins") # Construct the pattern
        match = pattern.search(lines[n]) # Search the pattern
        if match is None :
            break
        else:
            playerName = lines[n][0:match.start()-1]
            playerName = re.sub("'", "\\'", playerName)
            pattern = re.compile(r"side") # Construct the pattern
            lines[n]=lines[n].replace(",","")
            match = pattern.search(lines[n]) # Search the pattern
            
            match_amount = re.findall(r"(\d+(\.\d+)?)", lines[n]) # Search all numbers
            
            if match :
                amount=float(match_amount[len(match_amount)-2][0])
                if playerName in winners.keys() :
                    winners[playerName]=(winners[playerName]*100+amount*100)/100
                else :
                    winners[playerName]=amount
            else :                                                        
                amount=float(match_amount[len(match_amount)-1][0])
                if playerName in winners.keys() :
                    winners[playerName]=(winners[playerName]*100+amount*100)/100
                else :
                    winners[playerName]=amount
            logger.debug("winners[" + playerName + "]: " + str(winners[playerName]))
    res["n"]=n
    res["winners"]=winners
    return res
Exemple #3
0
 def insertText(self, text, run):
     if text is None or text == "":
         return
     pos = self.insertPos
     scribus.insertText(text, pos, self.textbox)
     tlen = len(text)
     logger.debug(
         "insert pos=%d len=%d npos=%d text='%s' style=%s cstyle=%s", pos,
         tlen, pos + tlen, text, run.pstyle, run.cstyle)
     global lastPStyle, lastCStyle
     if run.pstyle != lastPStyle:
         scribus.selectText(pos, tlen, self.textbox)
         scribus.setParagraphStyle(
             noPStyle if run.pstyle is None else run.pstyle, self.textbox)
         lastPStyle = run.pstyle
     if run.cstyle != lastCStyle:
         scribus.selectText(pos, tlen, self.textbox)
         scribus.setCharacterStyle(
             noCStyle if run.cstyle is None else run.cstyle, self.textbox)
         lastCStyle = run.cstyle
     if False and self.url is not None:  # TODO
         logger.debug("URL: %s", self.url)
         scribus.selectText(pos, tlen, self.textbox)
         frame = None  # see http://forums.scribus.net/index.php/topic,3487.0.html
         scribus.setURIAnnotation(self.url, frame)
         self.url = None
     self.insertPos += tlen
Exemple #4
0
 def tourLoc(self, tl):
         if tl is None:
             return None
         typ = tl.get("Type")
         if typ != "Startpunkt" and typ != "Treffpunkt" and typ != "Zielort":
             return None
         beginning = tl.get("Beginning")
         logger.debug("beginning %s", beginning)  # '2018-04-24T12:00:00'
         beginning = event.convertToMEZOrMSZ(beginning)  # '2018-04-24T14:00:00'
         beginning = beginning[11:16]  # 14:00
         name = tl.get("Name")
         street = tl.get("Street")
         city = tl.get("City")
         logger.debug("name '%s' street '%s' city '%s'", name, street, city)
         loc = name
         if city != "":
             if loc == "":
                 loc = city
             else:
                 loc = loc + " " + city
         if street != "":
             if loc == "":
                 loc = street
             else:
                 loc = loc + " " + street
         if typ == "Startpunkt":
             if self.isTermin():
                 typ = "Treffpunkt"
             else:
                 typ = "Start"
         if typ == "Zielort":
             typ = "Ziel"
         return (typ, beginning, loc)
Exemple #5
0
def selNotTourNr(tour, lst):
    nr = int(tour.getNummer())
    if nr in lst:
        logger.debug("tour %s nicht nichttournr %s", tour.getTitel(), lst)
        return False
    else:
        return True
Exemple #6
0
def selTitelEnthaelt(event, lst):
    titel = event.getTitel()
    for elem in lst:
        if titel.find(elem) >= 0:
            return True
    logger.debug("event %s nicht enthält %s", event.getTitel(), lst)
    return False
Exemple #7
0
 def checkCaptcha(self):
     ok = False
     g = self.getCaptchaImg()
     g.send(None)
     while not ok:
         # g = self.getCaptchaImg()
         posInfo = self.getPosInfo()
         captchaForm = {
             "answer": posInfo,
             "login_site": "E",
             "rand": "sjrand",
         }
         logger.debug(captchaForm)
         retCode, retData = self.doPOST(self._captchaChk,
                                        parse.urlencode(captchaForm))
         logger.info("retCode:[{}]".format(retCode))
         if retCode == 200:
             try:
                 result = json.loads(retData.decode("utf-8"))
                 logger.info("retData:[{}]".format(result))
                 if result["result_code"] == "4":
                     ok = True
                     break
             except:
                 pass
         g.send(None)
     g.close()
     logger.info("验证码校验成功, 尝试登陆")
Exemple #8
0
def selRadTyp(tour, lst):
    if "Alles" in lst:
        return True
    radTyp = tour.getRadTyp()
    if radTyp in lst:
        return True
    logger.debug("tour %s nicht radtyp %s", tour.getTitel(), lst)
    return False
Exemple #9
0
 def getEndDatum(self):
     beginning = self.eventItem.get("End")
     datum = event.convertToMEZOrMSZ(beginning)  # '2018-04-24T14:00:00'
     logger.debug("datum <%s>", str(datum))
     day = str(datum[0:10])
     date = time.strptime(day, "%Y-%m-%d")
     weekday = event.weekdays[date.tm_wday]
     res = (weekday + ", " + day[8:10] + "." + day[5:7] + "." + day[0:4], datum[11:16])
     return res
Exemple #10
0
def checkCStyleExi(style):
    logger.debug("checkCExi %s", style)
    if style in cstyles:
        if style not in cstylesConfigured:
            logger.debug("createCharStyle %s", str(cstyles[style]))
            scribus.createCharStyle(**cstyles[style])
            cstylesConfigured[style] = style
        return True
    raise ValueError("Character Style " + style + " not defined")