oscar.flag provides extensible, namespaced flags which can be parsed from environment variables, command-line arguments and config files.
Flags are declared where they are used in an application or library, and they are accessed through a namespace matching their fully qualified module path.
Documentation lives at Read the Docs, the code on GitHub.
Example
Application entry-point:
import sys
from oscar import flag
import other_module
FLAGS = flag.namespace(__name__)
FLAGS.some_int = flag.Int('some integer value', default=1)
if __name__ == '__main__':
flag.parse_commandline(sys.argv[1:])
flag.die_on_missing_required()
print 'other_module.multiply_by(%d) = %d' % (
FLAGS.some_int,
other_module.multiply_by(FLAGS.some_int))
other_module.py:
from oscar import flag
FLAGS = flag.namespace(__name__)
FLAGS.multiplier = flag.Int('some integer', default=flag.REQUIRED)
def multiply_by(i):
return i * FLAGS.multiplier
shell:
$ python example.py
Missing required flags:
[other_module.]multiplier
Usage of example.py:
__main__:
[__main__.]some_int=None: some integer value
other_module:
[other_module.]multiplier=<required>: some integer
# Note the namespaced reference --other_module.multiplier.
$ python example.py --other_module.multiplier=2 --some_int=3
other_module.multiply_by(3) = 6
License
Copyright 2015 Mulberry Health Inc.
Licensed under the Apache License, Version 2.0.
Metadata
Release files for oscar.flag 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| oscar.flag-0.1.2.tar.gz | 19.5 kB | Without provenance | Details for oscar.flag-0.1.2.tar.gz |
Release files / oscar.flag-0.1.2.tar.gz
| Download URL | oscar.flag-0.1.2.tar.gz |
|---|---|
| Size | 19.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
351900d4770e0d56be32df8d08f300d4bb37b9df451269f4ea2957a3d23bf30f
|
|
BLAKE2b-256 checksum How to use checksums |
f912d0d2bb1f347d7486fbf48b86fa4466ed4ce18840ce9614d451b577b0fec0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for oscar.flag 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.