update formatting
This commit is contained in:
63
materials.py
63
materials.py
@@ -1,13 +1,26 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
# -*- mode: python-mode; python-indent-offset: 2; tab-width: 2 -*-
|
||||
"""\
|
||||
Material database.
|
||||
"""
|
||||
Created on Mon Dec 21 19:39:44 2015
|
||||
__author__ = "Daniel Weschke"
|
||||
__copyright__ = "Copyright 2019 Daniel Weschke"
|
||||
__credits__ = ["Daniel Weschke"]
|
||||
__license__ = "MIT"
|
||||
__version__ = "2019.02.03"
|
||||
__maintainer__ = "Daniel Weschke"
|
||||
__email__ = "daniel.weschke@directbox.de"
|
||||
__status__ = "Production" # "Prototype", "Development", "Production"
|
||||
|
||||
@author: Daniel
|
||||
VERSION = """\
|
||||
%(prog)s version {version} {copyright}
|
||||
""".format(
|
||||
version=__version__, copyright=__copyright__)
|
||||
|
||||
EPILOG = """\
|
||||
"""
|
||||
import sys, os
|
||||
import argparse
|
||||
|
||||
import os
|
||||
|
||||
|
||||
def list():
|
||||
@@ -65,41 +78,55 @@ def read(input, search_keys=None):
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description='Material database.')
|
||||
"""\
|
||||
Main function
|
||||
"""
|
||||
import argparse
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
description=__doc__, prefix_chars='-', epilog=EPILOG,
|
||||
#usage="%(prog)s [OPTION]... NAME",
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
)
|
||||
parser.add_argument('-v', '--verbose', action="store_true", help="Verbose output")
|
||||
parser.add_argument('-V', '--version', action='version', version=VERSION)
|
||||
parser.add_argument('-D', '--debug', dest='debug', action='store_true', help=argparse.SUPPRESS)
|
||||
|
||||
subparsers = parser.add_subparsers(help='commands', dest='command')
|
||||
|
||||
# list materials
|
||||
list_parser = subparsers.add_parser('list',
|
||||
parser_list = subparsers.add_parser('list',
|
||||
description='List materials.',
|
||||
help='list all available materials')
|
||||
|
||||
# material
|
||||
material_parser = subparsers.add_parser('material',
|
||||
help='the material to get information from')
|
||||
material_parser.add_argument('materialname', action='store',
|
||||
parser_material = subparsers.add_parser('material',
|
||||
help='the material to get information from')
|
||||
parser_material.add_argument('materialname', action='store',
|
||||
help='list available material information')
|
||||
material_parser.add_argument('-r', '--rho', dest='const_collection',
|
||||
parser_material.add_argument('-r', '--rho', dest='const_collection',
|
||||
action='append_const', const="rho",
|
||||
help='get density from material')
|
||||
material_parser.add_argument('-T', '--Tm', dest='const_collection',
|
||||
parser_material.add_argument('-T', '--Tm', dest='const_collection',
|
||||
action='append_const', const="Tm",
|
||||
help='get melting point temperature')
|
||||
|
||||
parser.add_argument('-v', '--version', action='version',
|
||||
version='%(prog)s 1.0')
|
||||
|
||||
args = parser.parse_args()
|
||||
print(args)
|
||||
|
||||
if args.debug:
|
||||
print(args)
|
||||
|
||||
if args.command == 'list':
|
||||
list()
|
||||
|
||||
elif args.command == 'material':
|
||||
if args.const_collection:
|
||||
read(args.materialname, search_keys=args.const_collection)
|
||||
else:
|
||||
read(args.materialname)
|
||||
|
||||
return 0
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
import sys
|
||||
sys.exit(main())
|
||||
|
||||
Reference in New Issue
Block a user