#! /usr/bin/python3 -t MODULE_NAME = "mformula_args" MODULE_DESC = "Command line parsing for molecular diagrams" MODULE_VERS = "1.0" MODULE_COPYRIGHT = "Copyright © 2010-02-18 by the State University of Campinas (UNICAMP)" import sys, os, math, copy from math import sqrt,sin,cos,pi import rn import argparser; from argparser import ArgParser ARG_HELP = \ "[ -style [B1|B2|S1] ] [ -hydro [0|1] ]"; ARG_INFO = \ """The '-style' option selects ball style ('B1','B2') or symbolic skeleton ('S1'). For some compounds, the '-hydro' option specifies whether any hydrogen atoms attached to carbons should be omitted (0) or shown (1).""" def parse(ppopt) : "Parses the command line argument, returns dictionary with keys 'style', 'hydro', etc.\n" if ppopt == None : pp = ArgParser(sys.argv, sys.stderr, ARG_HELP, ARG_INFO); else : pp = ppopt; options = {} # Ignore Python library options: while pp.keyword_present("-m") : pp.get_next(); pp.get_next(); if pp.keyword_present("-style") : style = pp.get_next(); else : style = 'B' options['style'] = style if pp.keyword_present("-hydro") : hydro = int(pp.get_next()); else : hydro = None options['hydro'] = hydro if (ppopt == None) : pp.finish(); return options #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -