Пример #1
0
def move_protocol_to_wiki(session, pad_name_addon=None):
    if pad_name_addon:
        pad_name = session.pad_name.format(pad_name_addon)
    else:
        pad_name = session.pad_name
    pad_lines = download_pad(session.pad_team, pad_name)
    logg.debug("downloaded pad for %s", pad_name)
    #vorspann wegwerfen
    pad_it = dropwhile(lambda s: "= Protokoll ab hier =" not in s, pad_lines)
    next(pad_it)
    # leere Zeilen wegwerfen
    pad_it = dropwhile(lambda s: not s.strip(), pad_it)
    header = next(pad_it)
    match = re.search(r"(\d+)\.(\d+)\.(\d\d+)", header)
    if not match:
        raise Exception("Mit dem Protokoll-Anfang stimmt was nicht, Datum konnte nicht erkannt werden: {}".format(header))
    day, month, year = [int(e) for e in match.groups()]
    if year < 100:
        year += 2000
    session_date = date(year=year, month=month, day=day)
    reversed_date = reverse_date_format(session_date)
    unquote_func = lambda s: s.replace("&gt;", ">").replace("&lt;", "<")
    edit_uri = "http://wiki.piratenpartei.de/wiki//index.php?title={}&action=edit"
    logg.debug("Header ist:\n%s, Protokoll-Datum %s", header, reversed_date)
    logg.info("Inhalt:" + "-" * 80)
    print(header + "".join(imap(unquote_func, pad_it)))
    logg.info("-" * 80)
    logg.info("Seiten-URI fürs Protokoll:")
    logg.info(edit_uri.format(session.wiki_protocol_uri.format(date=reversed_date)))
Пример #2
0
def runpad2beamer(argv):
    ps = argparse.ArgumentParser("pad2beamer")
    ps.add_argument("--pad")
    ps.add_argument("--team")
    ps.add_argument("--file")
    ps.add_argument("--out")
    ps.add_argument("--outpdf")
    args = ps.parse_args()

    if args.pad:
        #get pad content with wiki markup
        raw_lines = download_pad(args.team, args.pad)
    else:
        with open(args.file) as wikifile:
            raw_lines = wikifile.readlines()

    pad_it = dropwhile(lambda s: "= Präsentation ab hier =" not in s, raw_lines)
    next(pad_it)
    # leere Zeilen wegwerfen
    pad_it = dropwhile(lambda s: not s.strip(), pad_it)
    lines = correct_wikilines(pad_it)
    logg.debug("showing input for convert2beamer\n" + "-" * 80)
    for line in lines:
        logg.debug(line)

    # do it
    logg.debug("running wiki2beamer...")
    result = wiki2beamer.convert2beamer(lines)

    # write resulting latex code to file or stdout
    if args.out:
        with open(args.out, "w") as w_file:
            w_file.writelines(result)

    # make complete latex file and run latex
    elif args.outpdf:
        pass


    else:
        logg.info("showing result latex code\n" + "-" * 80)
        for line in result[1:]:
            print(line)
        logg.info("finished")