Skip to main content

Opinionated but handy app startup wrapper.

Project description

pyglib provides a clean, consistent setup for writing commandline scripts and applications in Python. It makes use of python-gflags and python-glog, and adds an app startup helper that deals with initialization boilerplate so you don’t have to think about it.

Example usage:

#!/usr/bin/env python

from pyglib import app, gflags, log

gflags.DEFINE_integer('bananas', 7, 'Number of bananas.')

FLAGS = gflags.FLAGS


def main(args):
    log.info('There are %s bananas.', FLAGS.bananas)
    log.debug('This will only show up if you run with --verbosity=10')


if __name__ == __main__:
    app.run()

The above module is usable as a commandline app, complete with argument parsing and validation. It automatically has a few flags like --help and --verbosity that come from gflags and glog. Any positional arguments left over after parsing flags are passed along to the main() function.

This example module can also be imported as a library for use in another app. When used that way, any script that imports this one will inherit the --bananas flag defined here.

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyglib-0.1.tar.gz (4.0 kB view details)

Uploaded Source

File details

Details for the file pyglib-0.1.tar.gz.

File metadata

  • Download URL: pyglib-0.1.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pyglib-0.1.tar.gz
Algorithm Hash digest
SHA256 a063c5a847f57b025fd6d569f375aaac284e4d75bc24019b818b14356254e539
MD5 3203a34549986f0bed305823ae5fafda
BLAKE2b-256 e8b21d8f675bf1fbb894b190315eb3aa3c4bfb164fb8417ca33028e11a3fceb7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page