def run_listproperties(self, *args): """ List all found global AiiDA properties. """ import argparse from aiida.common.setup import ( _property_table, exists_property, get_property) parser = argparse.ArgumentParser( prog=self.get_full_command_name(), description='List all custom properties stored in the user configuration file.') parser.add_argument('-a', '--all', dest='all', action='store_true', help="Show all properties, even if not explicitly defined, if they " "have a default value.") parser.set_defaults(all=False) parsed_args = parser.parse_args(args) show_all = parsed_args.all for prop in sorted(_property_table.keys()): try: # To enforce the generation of an exception, even if # there is a default value if show_all or exists_property(prop): val = get_property(prop) print "{} = {}".format(prop, val) except KeyError: pass
def devel_listproperties(all_entries): """List all the properties that are explicitly set for the current profile.""" from aiida.common.setup import _property_table, exists_property, get_property for prop in sorted(_property_table.keys()): try: # To enforce the generation of an exception, even if there is a default value if all_entries or exists_property(prop): val = get_property(prop) echo.echo('{} = {}'.format(prop, val)) except KeyError: pass
def test_del_property(self): """Test the `verdi devel delproperty` command.""" property_name = 'daemon.timeout' property_value = 30 options = [property_name, str(property_value)] result = self.runner.invoke(cmd_devel.devel_setproperty, options) options = [property_name] result = self.runner.invoke(cmd_devel.devel_delproperty, options) self.assertIsNone(result.exception) self.assertIn(property_name, result.output.strip()) self.assertFalse(exists_property(property_name))
def tearDown(self): """Delete any properties that were set.""" for prop in sorted(_property_table.keys()): if exists_property(prop): del_property(prop)