appl120716_sample.app001_explainΒΆ

The subfolder-ed application

To make application into subfolder is a feature to sort out the application.

As applications tend to have complicated source code, using snippet folder is also an good idea.

''' The subfolder-ed application

To make application into subfolder is a feature
to sort out the application.

As applications tend to have complicated source code,
using ``snippet`` folder is also an good idea.
'''

from optparse import OptionParser

from scripts.appl120716_sample import sub

def print_arguments(args):
    print('OK!', args)
    sub.print_another()


def main():
    usage = "usage: %prog [options] arg"
    parser = OptionParser(usage)
    parser.add_option("-f", "--file", dest="filename",
        help="read data from FILENAME")
    parser.add_option("-v", "--verbose",
            action="store_true", dest="verbose")
    parser.add_option("-q", "--quiet",
        action="store_false", dest="verbose")

    (options, args) = parser.parse_args()
    if len(args) != 1:
        parser.error("incorrect number of arguments")
    if options.verbose:
        print("reading %s..." % options.filename)

    print_arguments(args)


if __name__ == "__main__":
    main()