materials_commons.cli.list_objects module¶
- class materials_commons.cli.list_objects.ListObjects(cmdname, typename, typename_plural, desc=None, requires_project=True, non_proj_member=False, proj_member=True, expt_member=True, dataset_member=False, remote_help='Select remote', list_columns=None, headers=None, deletable=False, dry_runable=False, has_owner=True, creatable=False, custom_actions=[], custom_selection_actions=[], request_confirmation_actions={})[source]¶
Bases:
object
Base class to create
mc X
CLI program commands that list objects of type X.Expected derived class members:
list_data(self, args, obj)
required
print_details(self, obj, args, out=sys.stdout)
required
get_all_from_experiment(self, expt)
required if self.expt_member==True
get_all_from_dataset(self, dataset)
required if self.dataset_member==True
get_all_from_project(self, proj)
required if self.proj_member==True
get_all(self)
required if self.non_proj_member==True
Optional derived class members:
create(self, args)
implement if type is createable
delete(self, objects, dry_run, out=sys.stdout)
implemented if type is deleteable
add_create_options(self, parser)
called if exists in derived class
add_custom_options(self, parser)
called if exists in derived class
Custom derived class actions (derived class member functions) should have the form:
<name>(self, args, out=sys.stdout)
Custom derived class “selection” actions (derived class member functions that act on a selection of objects) should have the form:
<name>(self, objects, args, out=sys.stdout)
See
materials_commons.cli.subcommands.proj.ProjSubcommand
for an example.- Parameters
cmdname – List[str] Names to use for ‘mc X Y …’, for instance: [“casm”, “prim”] for “mc casm prim”
typename – str With capitalization, for instance: “Process”
typename_plural – str With capitalization, for instance: “Processes”
desc – str Used for help command description
requires_project – bool If True and not in current project, raise MCCLIException
non_proj_member – bool Enable get_all_from_remote. If non_proj_member and proj_member, enable –all option to query all projects.
proj_member – bool Enable get_all_from_project. Restrict queries to current project by default
expt_member – bool Enable get_all_from_experiment. Include –expt option to restrict queries to current experiment
dataset_member – bool Enable get_all_from_dataset. Includes –dataset option to restrict queries to specified dataset
list_columns – List[str] List of column names
headers – List[str] List of column header names, use list_columns if None
deletable – bool If true, enable –delete
dry_runable – bool If true, enable –dry-run
has_owner – bool If true, enable –owner
creatable – bool If true, object can be created via derived class ‘create’ function
custom_actions –
List of str Custom action names which are called via:
<name>(self, args, outout=sys.stdout)
custom_selection_actions –
List of str Custom action names which are called via:
<name>(self, objects, args, outout=sys.stdout)
request_confirmation_actions – Dict of name:msg Dictionary of names of custom_selection_actions which require prompting the user for confirmation before executing. The value is the message shown at the prompt. Delete is always confirmed and is not included here.