CPEComponentSimple class

class cpe.comp.cpecomp_simple.CPEComponentSimple(comp_str, comp_att)[source]

Represents a generic string component of CPE name, compatible with the components of all versions of CPE specification.

__init__(comp_str, comp_att)[source]

Store the value of component.

Parameters
  • comp_str (string) – value of component value

  • comp_att (string) – attribute associated with component value

Returns

None

Exception

ValueError - incorrect value of component

__str__()[source]

Returns a human-readable representation of CPE component.

Returns

Representation of CPE component as string

Return type

string

as_fs()[source]

Returns the value of component encoded as formatted string.

Inspect each character in value of component. Certain nonalpha characters pass thru without escaping into the result, but most retain escaping.

Returns

Formatted string associated with component

Return type

string

as_uri_2_3()[source]

Returns the value of component encoded as URI string.

Scans an input string s and applies the following transformations:

  • Pass alphanumeric characters thru untouched

  • Percent-encode quoted non-alphanumerics as needed

  • Unquoted special characters are mapped to their special forms.

Returns

URI string associated with component

Return type

string

as_wfn()[source]

Returns the value of component encoded as Well-Formed Name (WFN) string.

Returns

WFN string associated with component

Return type

string

get_value()[source]

Returns the encoded value of component.

Returns

The encoded value of component

Return type

string

set_value(comp_str, comp_att)[source]

Set the value of component. By default, the component has a simple value.

Parameters
  • comp_str (string) – new value of component

  • comp_att (string) – attribute associated with value of component

Returns

None

Exception

ValueError - incorrect value of component

spechar_to_pce = {'!': '%21', '"': '%22', '#': '%23', '$': '%24', '%': '%25', '&': '%26', "'": '%27', '(': '%28', ')': '%29', '*': '%2a', '+': '%2b', ',': '%2c', '/': '%2f', ':': '%3a', ';': '%3b', '<': '%3c', '=': '%3d', '>': '%3e', '?': '%3f', '@': '%40', '[': '%5b', '\\': '%5c', ']': '%5d', '^': '%5e', '`': '%60', '{': '%7b', '|': '%7c', '}': '%7d', '~': '%7e'}

Characters to convert to percent-encoded characters when converts WFN to URI