Example #1
0
def main():
    print("content.py has no syntax errors")
    which = content_types["for_testing"]
    lpr = printers["X6505_e1"]
    letter = prepare_letter_template(which, lpr)
    email = prepare_email_template(which)
    rec = dict(
        first="Jane",
        last="Doe",
        address="nnn An Ave.",
        town="Any Town",
        postal_code="CODE",
        state="CA",
        country="USA",
        email="*****@*****.**",
        extra="""A lot more junk:
Certainly nothing very serious!
Just a lot of junk.""",
    )
    print("Letter follows...")
    print(letter.format(**rec))
    with open("letter2print", 'w') as fout:
        fout.write(helpers.indent(letter.format(**rec), lpr['indent']))
    print("Email follows...")
    print(email.format(**rec))
    with open("email2print", 'w') as fout:
        fout.write(email.format(**rec))
Example #2
0
def __smart_save(data, fpath, verbose):
    ' helper '
    dpath, fname = os.path.split(fpath)
    fname_noext, ext_ = os.path.splitext(fname)
    save_func = ext2_save_func[ext_]
    if verbose > 1:
        print('[io] saving: %r' % (type(data),))
    try:
        save_func(fpath, data)
        if verbose > 1:
            print('[io] saved %s ' % (filesize_str(fpath),))
    except Exception as ex:
        print('[io] ! Exception will saving %r' % fpath)
        print(helpers.indent(repr(ex), '[io]    '))
        raise
Example #3
0
def __smart_save(data, fpath, verbose):
    ' helper '
    dpath, fname = os.path.split(fpath)
    fname_noext, ext_ = os.path.splitext(fname)
    save_func = ext2_save_func[ext_]
    if verbose > 1:
        print('[io] saving: %r' % (type(data), ))
    try:
        save_func(fpath, data)
        if verbose > 1:
            print('[io] saved %s ' % (filesize_str(fpath), ))
    except Exception as ex:
        print('[io] ! Exception will saving %r' % fpath)
        print(helpers.indent(repr(ex), '[io]    '))
        raise
Example #4
0
 def prefix_print(msg):
     helpers.println(helpers.indent(str(msg), pprefix))
Example #5
0
def file_letter(record, club):
    entry = club.letter.format(**record)
    path2write = os.path.join(club.MAILING_DIR, "_".join(
        (record["last"], record["first"])))
    with open(path2write, 'w') as file_obj:
        file_obj.write(helpers.indent(entry, club.lpr["indent"]))
def test_indent(source, indent_n, expected):
    assert helpers.indent(source, indent_n) == expected
def test_indent(text, n_spaces, expected):
    assert helpers.indent(text, n_spaces) == expected
Example #8
0
 def prefix_print(msg):
     helpers.println(helpers.indent(str(msg), pprefix))