def Run(self, args): config_name = named_configs.ConfigurationStore.ActiveConfig().name if config_name != 'default': log.status.write( 'Your active configuration is: [{0}]\n'.format(config_name)) section, prop = properties.ParsePropertyString(args.property) if not prop: if section: err_msg = ('You cannot call get-value on a SECTION/. ' 'Did you mean `gcloud config list SECTION`?') raise c_exc.InvalidArgumentException('property', err_msg) raise c_exc.InvalidArgumentException( 'property', 'Must be in the form: [SECTION/]PROPERTY') try: value = properties.VALUES.Section(section).Property(prop).Get( validate=True) if not value: # Writing message to stderr but returning any potentially empty # value to caller as is log.err.Print('(unset)') except properties.InvalidValueError as e: # Writing warning to stderr but returning invalid value as is log.warn(str(e)) value = properties.VALUES.Section(section).Property(prop).Get( validate=False) return value
def AssertPropertySet(self, prop, value, scope): section, name = properties.ParsePropertyString(prop) if scope == properties.Scope.USER: values = (named_configs.ConfigurationStore.AllConfigs() ['default'].GetProperties()) else: values = (properties_file.PropertiesFile( [config.Paths().installation_properties_path]).AllProperties()) self.assertEqual(value, values.get(section, {}).get(name, None))
def _GetPropertiesToDisplay(self, args): """List available regular properties.""" section, prop = properties.ParsePropertyString(args.property) if prop: return {section: { prop: properties.VALUES.Section(section).Property(prop).Get()}} if section: return {section: properties.VALUES.Section(section).AllValues( list_unset=args.all)} return properties.VALUES.AllValues(list_unset=args.all)
def _GetPropertiesToDisplay(self, args): """List available regular properties.""" # Don't try to look up real properties that don't exist. if List._PositionalRequestsMetaProperties(args): return {} section, prop = properties.ParsePropertyString(args.property) if prop: return { section: { prop: properties.VALUES.Section(section).Property(prop).Get() } } if section: return { section: properties.VALUES.Section(section).AllValues( list_unset=args.all) } return properties.VALUES.AllValues(list_unset=args.all)