本文整理汇总了Python中md_utils.md_common.warning函数的典型用法代码示例。如果您正苦于以下问题:Python warning函数的具体用法?Python warning怎么用?Python warning使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了warning函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parse_cmdline
def parse_cmdline(argv):
"""
Returns the parsed argument list and return code.
`argv` is a list of arguments, or `None` for ``sys.argv[1:]``.
"""
if argv is None:
argv = sys.argv[1:]
# initialize the parser object:
parser = argparse.ArgumentParser(description='Reads in a file and counts the number of columns on the first line.')
parser.add_argument("-f", "--file", help="The location of the file to be analyzed.")
parser.add_argument("-n", "--new_name", help="Name of amended file.",
default=DEF_NEW_FNAME)
args = None
try:
args = parser.parse_args(argv)
except IOError as e:
warning("Problems reading file:", e)
parser.print_help()
return args, IO_ERROR
except KeyError as e:
warning("Input data missing:", e)
parser.print_help()
return args, INPUT_ERROR
return args, GOOD_RET
示例2: parse_cmdline
def parse_cmdline(argv):
"""
Returns the parsed argument list and return code.
`argv` is a list of arguments, or `None` for ``sys.argv[1:]``.
"""
if argv is None:
argv = sys.argv[1:]
# initialize the parser object:
parser = argparse.ArgumentParser(description='Compares sequential lines of files. If two consecutive lines are '
'equal, keeps only the first.')
parser.add_argument("-f", "--src_file", help="The location of the file to be processed.")
args = None
try:
args = parser.parse_args(argv)
except IOError as e:
warning("Problems reading file:", e)
parser.print_help()
return args, IO_ERROR
except KeyError as e:
warning("Input data missing:", e)
parser.print_help()
return args, INPUT_ERROR
return args, GOOD_RET
示例3: parse_cmdline
def parse_cmdline(argv):
"""
Returns the parsed argument list and return code.
`argv` is a list of arguments, or `None` for ``sys.argv[1:]``.
"""
if argv is None:
argv = sys.argv[1:]
# initialize the parser object:
parser = argparse.ArgumentParser(
description="Creates a new version of a psf file. " "Options include renumbering molecules."
)
parser.add_argument(
"-c",
"--config",
help="The location of the configuration file in ini format. "
"The default file name is {}, located in the "
"base directory where the program as run.".format(DEF_CFG_FILE),
default=DEF_CFG_FILE,
type=read_cfg,
)
args = None
try:
args = parser.parse_args(argv)
except IOError as e:
warning("Problems reading file:", e)
parser.print_help()
return args, IO_ERROR
except (KeyError, InvalidDataError) as e:
warning(e)
parser.print_help()
return args, INPUT_ERROR
return args, GOOD_RET
示例4: parse_cmdline
def parse_cmdline(argv):
"""
Returns the parsed argument list and return code.
:param argv: is a list of arguments, or `None` for ``sys.argv[1:]``.
"""
if argv is None:
argv = sys.argv[1:]
# initialize the parser object:
parser = argparse.ArgumentParser(description='Calculates the average and standard deviation '
'for the given radially-corrected free '
'energy data for a set of coordinates.')
parser.add_argument("-d", "--base_dir", help="The starting point for a file search "
"(defaults to current directory)",
default=os.getcwd())
parser.add_argument('-p', "--pattern", help="The file pattern to search for "
"(defaults to '{}')".format(DEF_FILE_PAT),
default=DEF_FILE_PAT)
parser.add_argument('-o', "--overwrite", help='Overwrite existing target file',
action='store_true')
try:
args = parser.parse_args(argv)
except SystemExit as e:
warning(e)
parser.print_help()
return [], INPUT_ERROR
return args, GOOD_RET
示例5: parse_cmdline
def parse_cmdline(argv):
"""
Returns the parsed argument list and return code.
:param argv: is a list of arguments, or `None` for ``sys.argv[1:]``.
"""
if argv is None:
argv = sys.argv[1:]
# initialize the parser object:
parser = argparse.ArgumentParser(description='Calculates the proton dissociation constant '
'(PKA) for the given radially-corrected free '
'energy data for a set of coordinates.')
parser.add_argument("-d", "--base_dir", help="The starting point for a file search "
"(defaults to current directory)",
default=os.getcwd())
parser.add_argument("-f", "--src_file", help="The single file to read from (takes precedence "
"over base_dir)")
parser.add_argument('-p', "--pattern", help="The file pattern to search for "
"(defaults to '{}')".format(DEF_FILE_PAT),
default=DEF_FILE_PAT)
parser.add_argument('-o', "--overwrite", help='Overwrite existing target file',
action='store_true')
parser.add_argument('-c', "--coord_ts", help='Manually entered coordinate of TS. '
'Used in place of first local maximum.',
type=float)
parser.add_argument("temp", help="The temperature in Kelvin for the simulation", type=float)
try:
args = parser.parse_args(argv)
except SystemExit as e:
warning(e)
parser.print_help()
return [], INPUT_ERROR
return args, GOOD_RET
示例6: parse_cmdline
def parse_cmdline(argv):
"""
Returns the parsed argument list and return code.
`argv` is a list of arguments, or `None` for ``sys.argv[1:]``.
"""
if argv is None:
argv = sys.argv[1:]
# initialize the parser object:
parser = argparse.ArgumentParser(description='Compares parameters (i.e. bond coeffs) of data files to '
'determine differences. The first is read to align with the first'
'column in the dictionary; the rest to the second.')
parser.add_argument("-c", "--config", help='The location of the configuration file in ini format. See the '
'example file /test/test_data/evbd2d/compare_data_types.ini. '
'The default file name is compare_data_types.ini, located in the '
'base directory where the program as run.',
default=DEF_CFG_FILE, type=read_cfg)
args = None
try:
args = parser.parse_args(argv)
except IOError as e:
warning("Problems reading file:", e)
parser.print_help()
return args, IO_ERROR
except KeyError as e:
warning("Input data missing:", e)
parser.print_help()
return args, INPUT_ERROR
return args, GOOD_RET
示例7: parse_cmdline
def parse_cmdline(argv):
"""
Returns the parsed argument list and return code.
`argv` is a list of arguments, or `None` for ``sys.argv[1:]``.
"""
if argv is None:
argv = sys.argv[1:]
# initialize the parser object:
parser = argparse.ArgumentParser(description='Creates pdb files from lammps data, given a template pdb file.')
parser.add_argument("-c", "--config", help="The location of the configuration file in ini format. "
"The default file name is {}, located in the "
"base directory where the program as run.".format(DEF_CFG_FILE),
default=DEF_CFG_FILE, type=read_cfg)
args = None
try:
args = parser.parse_args(argv)
except IOError as e:
warning("Problems reading file:", e)
parser.print_help()
return args, IO_ERROR
except (KeyError, InvalidDataError, MissingSectionHeaderError, SystemExit) as e:
if e.message == 0:
return args, GOOD_RET
warning(e)
parser.print_help()
return args, INPUT_ERROR
return args, GOOD_RET
示例8: parse_cmdline
def parse_cmdline(argv):
"""
Returns the parsed argument list and return code.
`argv` is a list of arguments, or `None` for ``sys.argv[1:]``.
"""
if argv is None:
argv = sys.argv[1:]
# initialize the parser object:
parser = argparse.ArgumentParser(description='For each timestep, find the highest protonated state ci^2 and '
'highest ci^2 for a hydronium. '
'Currently, this script expects only one protonatable residue.')
parser.add_argument("-c", "--config", help="The location of the configuration file in ini format. "
"The default file name is {}, located in the "
"base directory where the program as run.".format(DEF_CFG_FILE),
default=DEF_CFG_FILE, type=read_cfg)
args = None
try:
args = parser.parse_args(argv)
except IOError as e:
warning("Problems reading file:", e)
parser.print_help()
return args, IO_ERROR
except (KeyError, InvalidDataError, SystemExit) as e:
if e.message == 0:
return args, GOOD_RET
warning(e)
parser.print_help()
return args, INPUT_ERROR
return args, GOOD_RET
示例9: read_cfg
def read_cfg(floc, cfg_proc=process_cfg):
"""
Reads the given configuration file, returning a dict with the converted values supplemented by default values.
:param floc: The location of the file to read.
:param cfg_proc: The processor to use for the raw configuration values. Uses default values when the raw
value is missing.
:return: A dict of the processed configuration file's data.
"""
config = ConfigParser()
try:
good_files = config.read(floc)
if not good_files:
raise IOError('Could not read file {}'.format(floc))
main_proc = cfg_proc(dict(config.items(MAIN_SEC)), DEF_CFG_VALS, REQ_KEYS, int_list=False)
except (ParsingError, KeyError) as e:
raise InvalidDataError(e)
# Check the config file does not have sections that will be ignored
for section in config.sections():
if section not in SECTIONS:
warning("Found section '{}', which will be ignored. Expected section names are: {}"
.format(section, ", ".join(SECTIONS)))
# # Validate conversion input
for conv in [COL1_CONV, COL2_CONV]:
if main_proc[conv]:
main_proc[conv] = conv_str_to_func(main_proc[conv])
return main_proc
示例10: parse_cmdline
def parse_cmdline(argv):
"""
Returns the parsed argument list and return code.
`argv` is a list of arguments, or `None` for ``sys.argv[1:]``.
"""
if argv is None:
argv = sys.argv[1:]
# initialize the parser object:
parser = argparse.ArgumentParser(description='Creates a new version of a pdb file. Atoms will be numbered '
'starting from one. Options include renumbering molecules.')
parser.add_argument("-c", "--config", help="The location of the configuration file in ini format. "
"The default file name is {}, located in the "
"base directory where the program as run.".format(DEF_CFG_FILE),
default=DEF_CFG_FILE, type=read_cfg)
args = None
try:
args = parser.parse_args(argv)
except IOError as e:
warning(e)
parser.print_help()
return args, IO_ERROR
except (KeyError, InvalidDataError, SystemExit) as e:
if e.message == 0:
return args, GOOD_RET
warning("Input data missing:", e)
parser.print_help()
return args, INPUT_ERROR
return args, GOOD_RET
示例11: parse_cmdline
def parse_cmdline(argv):
"""
Returns the parsed argument list and return code.
`argv` is a list of arguments, or `None` for ``sys.argv[1:]``.
"""
if argv is None:
argv = sys.argv[1:]
# initialize the parser object:
parser = argparse.ArgumentParser(description='Creates data files from lammps data in the format of a template data '
'file. The required input file provides the location of the '
'template file, a file with a list of data files to convert, and '
'(optionally) dictionaries mapping old data number or types to new, '
'to reorder and/or check that the atom type order '
'is the same in the files to convert and the template file. \n'
'Note: Dictionaries of data types can be made, **assuming the atom '
'numbers correspond**. The check on whether they do can be used to '
'make a list of which atom numbers require remapping.')
parser.add_argument("-c", "--config", help="The location of the configuration file in ini format. "
"The default file name is {}, located in the "
"base directory where the program as run.".format(DEF_CFG_FILE),
default=DEF_CFG_FILE, type=read_cfg)
args = None
try:
args = parser.parse_args(argv)
except IOError as e:
warning("Problems reading file:", e)
parser.print_help()
return args, IO_ERROR
except KeyError as e:
warning("Input data missing:", e)
parser.print_help()
return args, INPUT_ERROR
return args, GOOD_RET
示例12: parse_cmdline
def parse_cmdline(argv):
"""
Returns the parsed argument list and return code.
:param argv: is a list of arguments, or `None` for ``sys.argv[1:]``.
"""
if argv is None:
argv = sys.argv[1:]
# initialize the parser object:
parser = argparse.ArgumentParser(description='Sorts the data in given XYZ input file '
'into bins of the given interval, producing '
'a VMD-formatted file containing the average '
'XYZ coordinate, plus a detailed log file.')
parser.add_argument("-s", "--bin_size", help="The size interval for each bin in Angstroms",
default=0.1, type=float)
parser.add_argument("-c", "--bin_coordinate", help='The xyz coordinate to use for bin sorting',
default='z', choices=COORDS)
parser.add_argument("infile", help="A three-field-per-line XYZ coordinate file to process")
args = None
try:
args = parser.parse_args(argv)
except SystemExit as e:
if e.message == 0:
return args, GOOD_RET
warning(e)
parser.print_help()
return args, INPUT_ERROR
return args, GOOD_RET
示例13: parse_cmdline
def parse_cmdline(argv=None):
"""
Returns the parsed argument list and return code.
:param argv: A list of arguments, or `None` for ``sys.argv[1:]``.
"""
if argv is None:
argv = sys.argv[1:]
# initialize the parser object:
parser = argparse.ArgumentParser(description='Block averages input data for WHAM')
parser.add_argument("-d", "--base_dir", help="The starting point for a meta file search "
"(defaults to current directory)",
default=os.getcwd())
parser.add_argument('-p', "--pattern", help="The meta file pattern to search for "
"(defaults to '{}')".format(DEF_FILE_PAT),
default=DEF_FILE_PAT)
parser.add_argument('-s', "--steps", help="The number of averaging steps to take "
"(defaults to '{}')".format(DEF_STEPS_NUM),
type=int, default=DEF_STEPS_NUM)
parser.add_argument('-o', "--overwrite", help='Overwrite existing locations',
action='store_true')
args = None
try:
args = parser.parse_args(argv)
except SystemExit as e:
if e.message == 0:
return args, GOOD_RET
warning(e)
parser.print_help()
return args, INPUT_ERROR
return args, GOOD_RET
示例14: parse_cmdline
def parse_cmdline(argv):
"""
Returns the parsed argument list and return code.
`argv` is a list of arguments, or `None` for ``sys.argv[1:]``.
"""
if argv is None:
argv = sys.argv[1:]
# initialize the parser object:
parser = argparse.ArgumentParser(description='Grabs selected info from the designated file. '
'The required input file provides the location of the file. '
'Optional info is an atom index for the last atom not to consider.')
parser.add_argument("-c", "--config", help="The location of the configuration file in ini "
"The default file name is {}, located in the "
"base directory where the program as run.".format(DEF_CFG_FILE),
default=DEF_CFG_FILE, type=read_cfg)
args = None
try:
args = parser.parse_args(argv)
except IOError as e:
warning("Problems reading file:", e)
parser.print_help()
return args, IO_ERROR
except KeyError as e:
warning("Input data missing:", e)
parser.print_help()
return args, INPUT_ERROR
return args, GOOD_RET
示例15: main
def main(argv=None):
"""
Runs the main program.
:param argv: The command line arguments.
:return: The return code for the program's termination.
"""
args, ret = parse_cmdline(argv)
if ret != GOOD_RET or args is None:
return ret
found_files = find_files_by_dir(args.base_dir, args.pattern)
print("Found {} dirs with files to combine".format(len(found_files)))
for f_dir, files in found_files.items():
if not files:
logger.warn("No files with pattern '{}' found for dir '{}'".format(args.pattern, f_dir))
continue
combo_file = os.path.join(f_dir, args.target_file)
if os.path.exists(combo_file) and not args.overwrite:
warning("Target file already exists: '{}' \n"
"Skipping dir '{}'".format(combo_file, f_dir))
continue
combo = combine([os.path.join(f_dir, tgt) for tgt in files])
write_combo(extract_header(os.path.join(f_dir, files[0])), combo, combo_file)
return GOOD_RET # success