Source code for mockslurm.utils

import argparse

from mockslurm.process_db import DB_DEFAULTS


[docs] def filter_dict_from_args(args: argparse.Namespace): # Transform the arguments values into a map {field: value, field2: [values], etc...} for filtering DB field_filter_values = {} for arg, value in vars(args).items(): if arg in DB_DEFAULTS.keys(): if isinstance(value, str): field_filter_values[arg] = value.encode() elif isinstance(value, list): field_filter_values[arg] = [v.encode() if isinstance(v, str) else v for v in value] elif value is not None: field_filter_values[arg] = value return field_filter_values