def validate_attributes(cls, bundle, item_id, attributes): if attributes.get('delete', False): for attr in attributes.keys(): if attr not in ['delete'] + list( BUILTIN_ITEM_ATTRIBUTES.keys()): raise BundleError( _("{item} from bundle '{bundle}' cannot have other " "attributes besides 'delete'").format( item=item_id, bundle=bundle.name)) if 'hash_method' in attributes and \ attributes['hash_method'] not in HASH_METHODS: raise BundleError( _("Invalid hash method for {item} in bundle '{bundle}': '{method}'" ).format( bundle=bundle.name, item=item_id, method=attributes['hash_method'], )) if 'password_hash' in attributes and ('password' in attributes or 'salt' in attributes): raise BundleError( _("{item} in bundle '{bundle}': 'password_hash' " "cannot be used with 'password' or 'salt'").format( bundle=bundle.name, item=item_id)) if 'salt' in attributes and 'password' not in attributes: raise BundleError( _("{}: salt given without a password").format(item_id))
def validate_attributes(cls, bundle, item_id, attributes): if attributes.get('delete', False): for attr in attributes.keys(): if attr not in ['delete'] + list(BUILTIN_ITEM_ATTRIBUTES.keys()): raise BundleError(_( "{item} from bundle '{bundle}' cannot have other " "attributes besides 'delete'" ).format(item=item_id, bundle=bundle.name)) if 'content' in attributes and 'source' in attributes: raise BundleError(_( "{item} from bundle '{bundle}' cannot have both 'content' and 'source'" ).format(item=item_id, bundle=bundle.name)) if ( attributes.get('content_type', None) == "any" and ( 'content' in attributes or 'encoding' in attributes or 'source' in attributes ) ): raise BundleError(_( "{item} from bundle '{bundle}' with content_type 'any' " "must not define 'content', 'encoding' and/or 'source'" ).format(item=item_id, bundle=bundle.name)) for key, value in attributes.items(): ATTRIBUTE_VALIDATORS[key](item_id, value)
def validate_attributes(cls, bundle, item_id, attributes): if attributes.get('delete', False): for attr in attributes.keys(): if attr not in ['delete'] + list(BUILTIN_ITEM_ATTRIBUTES.keys()): raise BundleError(_( "{item} from bundle '{bundle}' cannot have other " "attributes besides 'delete'" ).format(item=item_id, bundle=bundle.name)) if 'hash_method' in attributes and \ attributes['hash_method'] not in HASH_METHODS: raise BundleError( _("Invalid hash method for {item} in bundle '{bundle}': '{method}'").format( bundle=bundle.name, item=item_id, method=attributes['hash_method'], ) ) if 'password_hash' in attributes and ( 'password' in attributes or 'salt' in attributes ): raise BundleError(_( "{item} in bundle '{bundle}': 'password_hash' " "cannot be used with 'password' or 'salt'" ).format(bundle=bundle.name, item=item_id)) if 'salt' in attributes and 'password' not in attributes: raise BundleError( _("{}: salt given without a password").format(item_id) )
def validate_attributes(cls, bundle, item_id, attributes): if attributes.get('delete', False): for attr in attributes.keys(): if attr not in ['delete'] + list(BUILTIN_ITEM_ATTRIBUTES.keys()): raise BundleError(_( "{item} from bundle '{bundle}' cannot have other " "attributes besides 'delete'" ).format(item=item_id, bundle=bundle.name))
def validate_attributes(cls, bundle, item_id, attributes): if attributes.get('delete', False): for attr in attributes.keys(): if attr not in ['delete'] + list(BUILTIN_ITEM_ATTRIBUTES.keys()): raise BundleError(_( "{item} from bundle '{bundle}' cannot have other " "attributes besides 'delete'" ).format(item=item_id, bundle=bundle.name)) if attributes.get('manifest') and attributes.get('manifest_file'): raise BundleError(_( "{item} from bundle '{bundle}' cannot have both 'manifest' and 'manifest_file'" ).format(item=item_id, bundle=bundle.name)) if attributes.get('manifest_processor') not in (None, 'jinja2', 'mako'): raise BundleError(_( "{item} from bundle '{bundle}' has invalid manifest_processor " "(must be 'jinja2' or 'mako')" ).format(item=item_id, bundle=bundle.name))
def validate_attributes(cls, bundle, item_id, attributes): if attributes.get("delete", False): for attr in attributes.keys(): if attr not in ["delete"] + list(BUILTIN_ITEM_ATTRIBUTES.keys()): raise BundleError( _("{item} from bundle '{bundle}' cannot have other " "attributes besides 'delete'").format( item=item_id, bundle=bundle.name ) ) if "content" in attributes and "source" in attributes: raise BundleError( _("{item} from bundle '{bundle}' cannot have both 'content' and 'source'").format( item=item_id, bundle=bundle.name ) ) if "content" in attributes and attributes.get("content_type") == "binary": raise BundleError( _( "{item} from bundle '{bundle}' cannot have binary inline content " "(use content_type 'base64' instead)" ).format(item=item_id, bundle=bundle.name) ) if "encoding" in attributes and attributes.get("content_type") in ("any", "base64", "binary"): raise BundleError( _( "content_type of {item} from bundle '{bundle}' cannot provide different encoding " "(remove the 'encoding' attribute)" ).format(item=item_id, bundle=bundle.name) ) if attributes.get("content_type", None) == "any" and ( "content" in attributes or "encoding" in attributes or "source" in attributes ): raise BundleError( _( "{item} from bundle '{bundle}' with content_type 'any' " "must not define 'content', 'encoding' and/or 'source'" ).format(item=item_id, bundle=bundle.name) ) for key, value in attributes.items(): ATTRIBUTE_VALIDATORS[key](item_id, value)
def validate_attributes(cls, bundle, item_id, attributes): if attributes.get('delete', False): for attr in attributes.keys(): if attr not in ['delete'] + list( BUILTIN_ITEM_ATTRIBUTES.keys()): raise BundleError( _("{item} from bundle '{bundle}' cannot have other " "attributes besides 'delete'").format( item=item_id, bundle=bundle.name)) if 'content' in attributes and 'source' in attributes: raise BundleError( _("{item} from bundle '{bundle}' cannot have both 'content' and 'source'" ).format(item=item_id, bundle=bundle.name)) if 'content' in attributes and attributes.get( 'content_type') == 'binary': raise BundleError( _("{item} from bundle '{bundle}' cannot have binary inline content " "(use content_type 'base64' instead)").format( item=item_id, bundle=bundle.name)) if 'encoding' in attributes and attributes.get('content_type') in ( 'any', 'base64', 'binary', ): raise BundleError( _("content_type of {item} from bundle '{bundle}' cannot provide different encoding " "(remove the 'encoding' attribute)").format( item=item_id, bundle=bundle.name)) if (attributes.get('content_type', None) == "any" and ('content' in attributes or 'encoding' in attributes or 'source' in attributes)): raise BundleError( _("{item} from bundle '{bundle}' with content_type 'any' " "must not define 'content', 'encoding' and/or 'source'"). format(item=item_id, bundle=bundle.name)) for key, value in attributes.items(): ATTRIBUTE_VALIDATORS[key](item_id, value)