gutenberg/cleanup/strip_headers.py
def _main():
    """Command line interface to the module.

    """
    from argparse import ArgumentParser, FileType
    from gutenberg import Error
    from gutenberg._util.os import reopen_encoded

    parser = ArgumentParser(description='Remove headers and footers from a '
                                        'Project Gutenberg text')
    parser.add_argument('infile', type=FileType('r'))
    parser.add_argument('outfile', type=FileType('w'))
    args = parser.parse_args()

    try:
        with reopen_encoded(args.infile, 'r', 'utf8') as infile:
            text = infile.read()
            clean_text = strip_headers(text)

        with reopen_encoded(args.outfile, 'w', 'utf8') as outfile:
            outfile.write(clean_text)
    except Error as error:
        parser.error(str(error))
Command line interface to the module.

    
Command line interface to the module.
Command line interface to the module .
def _main():
    from argparse import ArgumentParser, FileType
    from gutenberg import Error
    from gutenberg._util.os import reopen_encoded
    parser = ArgumentParser(description='Remove headers and footers from a '
                                        'Project Gutenberg text')
    parser.add_argument('infile', type=FileType('r'))
    parser.add_argument('outfile', type=FileType('w'))
    args = parser.parse_args()
    try:
        with reopen_encoded(args.infile, 'r', 'utf8') as infile:
            text = infile.read()
            clean_text = strip_headers(text)
        with reopen_encoded(args.outfile, 'w', 'utf8') as outfile:
            outfile.write(clean_text)
    except Error as error:
        parser.error(str(error))
def _main ( ) : from argparse import ArgumentParser , FileType from gutenberg import Error from gutenberg . _util . os import reopen_encoded parser = ArgumentParser ( description = 'Remove headers and footers from a ' 'Project Gutenberg text' ) parser . add_argument ( 'infile' , type = FileType ( 'r' ) ) parser . add_argument ( 'outfile' , type = FileType ( 'w' ) ) args = parser . parse_args ( ) try : with reopen_encoded ( args . infile , 'r' , 'utf8' ) as infile : text = infile . read ( ) clean_text = strip_headers ( text ) with reopen_encoded ( args . outfile , 'w' , 'utf8' ) as outfile : outfile . write ( clean_text ) except Error as error : parser . error ( str ( error ) )
Command line interface to the module.
Command line interface to the module .
"""Command line interface to the module.

    """