Ejemplo n.º 1
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('--no-info',
                        action="store_true",
                        help="Do not fetch info; print RJ code only.")
    args = parser.parse_args()

    if args.no_info:
        printer = _simple_printer
    else:
        printer = _info_printer

    for line in sys.stdin:
        try:
            rjcode = workinfo.parse_rjcode(line)
        except ValueError:
            continue
        printer(rjcode)
Ejemplo n.º 2
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('file')
    parser.add_argument('rjcode',
                        nargs='?',
                        default=None,
                        type=workinfo.parse_rjcode)
    args = parser.parse_args()
    logging.basicConfig(level='DEBUG')

    if args.rjcode is None:
        rjcode = workinfo.parse_rjcode(args.file)
    else:
        rjcode = args.rjcode

    with api.get_fetcher() as fetcher:
        work = fetcher(rjcode)
    os.rename(args.file, workinfo.work_filename(work))
Ejemplo n.º 3
0
def test_parse_rjcode_when_missing():
    with pytest.raises(ValueError):
        workinfo.parse_rjcode('asdf')
Ejemplo n.º 4
0
def test_parse_rjcode():
    assert workinfo.parse_rjcode('asdf RJ123 asdf') == 'RJ123'
Ejemplo n.º 5
0
def _get_path_work(fetcher, path: 'Path') -> 'workinfo.Work':
    rjcode = workinfo.parse_rjcode(path.name)
    return fetcher(rjcode)