partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
pairwise_distances
r""" pairwise_distances(x, y=None, *, exponent=1) Pairwise distance between points. Return the pairwise distance between points in two sets, or in the same set if only one set is passed. Parameters ---------- x: array_like An :math:`n \times m` array of :math:`n` observations in ...
dcor/distances.py
def pairwise_distances(x, y=None, **kwargs): r""" pairwise_distances(x, y=None, *, exponent=1) Pairwise distance between points. Return the pairwise distance between points in two sets, or in the same set if only one set is passed. Parameters ---------- x: array_like An :math:...
def pairwise_distances(x, y=None, **kwargs): r""" pairwise_distances(x, y=None, *, exponent=1) Pairwise distance between points. Return the pairwise distance between points in two sets, or in the same set if only one set is passed. Parameters ---------- x: array_like An :math:...
[ "r", "pairwise_distances", "(", "x", "y", "=", "None", "*", "exponent", "=", "1", ")" ]
vnmabus/dcor
python
https://github.com/vnmabus/dcor/blob/b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d/dcor/distances.py#L92-L149
[ "def", "pairwise_distances", "(", "x", ",", "y", "=", "None", ",", "*", "*", "kwargs", ")", ":", "x", "=", "_transform_to_2d", "(", "x", ")", "if", "y", "is", "None", "or", "y", "is", "x", ":", "return", "_pdist", "(", "x", ",", "*", "*", "kwar...
b0ff1273c0a52efdabdfdadefc7ff2a49def7e8d
train
Receiver.respond
Respond to the request. This generates the :attr:`mohawk.Receiver.response_header` attribute. :param content=EmptyValue: Byte string of response body that will be sent. :type content=EmptyValue: str :param content_type=EmptyValue: content-type header value for response. ...
mohawk/receiver.py
def respond(self, content=EmptyValue, content_type=EmptyValue, always_hash_content=True, ext=None): """ Respond to the request. This generates the :attr:`mohawk.Receiver.response_header` attribute. :param content=E...
def respond(self, content=EmptyValue, content_type=EmptyValue, always_hash_content=True, ext=None): """ Respond to the request. This generates the :attr:`mohawk.Receiver.response_header` attribute. :param content=E...
[ "Respond", "to", "the", "request", "." ]
kumar303/mohawk
python
https://github.com/kumar303/mohawk/blob/037be67ccf50ae704705e67add44e02737a65d21/mohawk/receiver.py#L123-L171
[ "def", "respond", "(", "self", ",", "content", "=", "EmptyValue", ",", "content_type", "=", "EmptyValue", ",", "always_hash_content", "=", "True", ",", "ext", "=", "None", ")", ":", "log", ".", "debug", "(", "'generating response header'", ")", "resource", "...
037be67ccf50ae704705e67add44e02737a65d21
train
calculate_payload_hash
Calculates a hash for a given payload.
mohawk/util.py
def calculate_payload_hash(payload, algorithm, content_type): """Calculates a hash for a given payload.""" p_hash = hashlib.new(algorithm) parts = [] parts.append('hawk.' + str(HAWK_VER) + '.payload\n') parts.append(parse_content_type(content_type) + '\n') parts.append(payload or '') parts....
def calculate_payload_hash(payload, algorithm, content_type): """Calculates a hash for a given payload.""" p_hash = hashlib.new(algorithm) parts = [] parts.append('hawk.' + str(HAWK_VER) + '.payload\n') parts.append(parse_content_type(content_type) + '\n') parts.append(payload or '') parts....
[ "Calculates", "a", "hash", "for", "a", "given", "payload", "." ]
kumar303/mohawk
python
https://github.com/kumar303/mohawk/blob/037be67ccf50ae704705e67add44e02737a65d21/mohawk/util.py#L49-L69
[ "def", "calculate_payload_hash", "(", "payload", ",", "algorithm", ",", "content_type", ")", ":", "p_hash", "=", "hashlib", ".", "new", "(", "algorithm", ")", "parts", "=", "[", "]", "parts", ".", "append", "(", "'hawk.'", "+", "str", "(", "HAWK_VER", ")...
037be67ccf50ae704705e67add44e02737a65d21
train
calculate_mac
Calculates a message authorization code (MAC).
mohawk/util.py
def calculate_mac(mac_type, resource, content_hash): """Calculates a message authorization code (MAC).""" normalized = normalize_string(mac_type, resource, content_hash) log.debug(u'normalized resource for mac calc: {norm}' .format(norm=normalized)) digestmod = getattr(hashlib, resource.cr...
def calculate_mac(mac_type, resource, content_hash): """Calculates a message authorization code (MAC).""" normalized = normalize_string(mac_type, resource, content_hash) log.debug(u'normalized resource for mac calc: {norm}' .format(norm=normalized)) digestmod = getattr(hashlib, resource.cr...
[ "Calculates", "a", "message", "authorization", "code", "(", "MAC", ")", "." ]
kumar303/mohawk
python
https://github.com/kumar303/mohawk/blob/037be67ccf50ae704705e67add44e02737a65d21/mohawk/util.py#L72-L88
[ "def", "calculate_mac", "(", "mac_type", ",", "resource", ",", "content_hash", ")", ":", "normalized", "=", "normalize_string", "(", "mac_type", ",", "resource", ",", "content_hash", ")", "log", ".", "debug", "(", "u'normalized resource for mac calc: {norm}'", ".", ...
037be67ccf50ae704705e67add44e02737a65d21
train
calculate_ts_mac
Calculates a message authorization code (MAC) for a timestamp.
mohawk/util.py
def calculate_ts_mac(ts, credentials): """Calculates a message authorization code (MAC) for a timestamp.""" normalized = ('hawk.{hawk_ver}.ts\n{ts}\n' .format(hawk_ver=HAWK_VER, ts=ts)) log.debug(u'normalized resource for ts mac calc: {norm}' .format(norm=normalized)) dig...
def calculate_ts_mac(ts, credentials): """Calculates a message authorization code (MAC) for a timestamp.""" normalized = ('hawk.{hawk_ver}.ts\n{ts}\n' .format(hawk_ver=HAWK_VER, ts=ts)) log.debug(u'normalized resource for ts mac calc: {norm}' .format(norm=normalized)) dig...
[ "Calculates", "a", "message", "authorization", "code", "(", "MAC", ")", "for", "a", "timestamp", "." ]
kumar303/mohawk
python
https://github.com/kumar303/mohawk/blob/037be67ccf50ae704705e67add44e02737a65d21/mohawk/util.py#L91-L106
[ "def", "calculate_ts_mac", "(", "ts", ",", "credentials", ")", ":", "normalized", "=", "(", "'hawk.{hawk_ver}.ts\\n{ts}\\n'", ".", "format", "(", "hawk_ver", "=", "HAWK_VER", ",", "ts", "=", "ts", ")", ")", "log", ".", "debug", "(", "u'normalized resource for ...
037be67ccf50ae704705e67add44e02737a65d21
train
normalize_string
Serializes mac_type and resource into a HAWK string.
mohawk/util.py
def normalize_string(mac_type, resource, content_hash): """Serializes mac_type and resource into a HAWK string.""" normalized = [ 'hawk.' + str(HAWK_VER) + '.' + mac_type, normalize_header_attr(resource.timestamp), normalize_header_attr(resource.nonce), normalize_header_attr(res...
def normalize_string(mac_type, resource, content_hash): """Serializes mac_type and resource into a HAWK string.""" normalized = [ 'hawk.' + str(HAWK_VER) + '.' + mac_type, normalize_header_attr(resource.timestamp), normalize_header_attr(resource.nonce), normalize_header_attr(res...
[ "Serializes", "mac_type", "and", "resource", "into", "a", "HAWK", "string", "." ]
kumar303/mohawk
python
https://github.com/kumar303/mohawk/blob/037be67ccf50ae704705e67add44e02737a65d21/mohawk/util.py#L109-L136
[ "def", "normalize_string", "(", "mac_type", ",", "resource", ",", "content_hash", ")", ":", "normalized", "=", "[", "'hawk.'", "+", "str", "(", "HAWK_VER", ")", "+", "'.'", "+", "mac_type", ",", "normalize_header_attr", "(", "resource", ".", "timestamp", ")"...
037be67ccf50ae704705e67add44e02737a65d21
train
parse_authorization_header
Example Authorization header: 'Hawk id="dh37fgj492je", ts="1367076201", nonce="NPHgnG", ext="and welcome!", mac="CeWHy4d9kbLGhDlkyw2Nh3PJ7SDOdZDa267KH4ZaNMY="'
mohawk/util.py
def parse_authorization_header(auth_header): """ Example Authorization header: 'Hawk id="dh37fgj492je", ts="1367076201", nonce="NPHgnG", ext="and welcome!", mac="CeWHy4d9kbLGhDlkyw2Nh3PJ7SDOdZDa267KH4ZaNMY="' """ if len(auth_header) > MAX_LENGTH: raise BadHeaderValue('Header exc...
def parse_authorization_header(auth_header): """ Example Authorization header: 'Hawk id="dh37fgj492je", ts="1367076201", nonce="NPHgnG", ext="and welcome!", mac="CeWHy4d9kbLGhDlkyw2Nh3PJ7SDOdZDa267KH4ZaNMY="' """ if len(auth_header) > MAX_LENGTH: raise BadHeaderValue('Header exc...
[ "Example", "Authorization", "header", ":" ]
kumar303/mohawk
python
https://github.com/kumar303/mohawk/blob/037be67ccf50ae704705e67add44e02737a65d21/mohawk/util.py#L147-L192
[ "def", "parse_authorization_header", "(", "auth_header", ")", ":", "if", "len", "(", "auth_header", ")", ">", "MAX_LENGTH", ":", "raise", "BadHeaderValue", "(", "'Header exceeds maximum length of {max_length}'", ".", "format", "(", "max_length", "=", "MAX_LENGTH", ")"...
037be67ccf50ae704705e67add44e02737a65d21
train
get_bewit
Returns a bewit identifier for the resource as a string. :param resource: Resource to generate a bewit for :type resource: `mohawk.base.Resource`
mohawk/bewit.py
def get_bewit(resource): """ Returns a bewit identifier for the resource as a string. :param resource: Resource to generate a bewit for :type resource: `mohawk.base.Resource` """ if resource.method != 'GET': raise ValueError('bewits can only be generated for GET requests') i...
def get_bewit(resource): """ Returns a bewit identifier for the resource as a string. :param resource: Resource to generate a bewit for :type resource: `mohawk.base.Resource` """ if resource.method != 'GET': raise ValueError('bewits can only be generated for GET requests') i...
[ "Returns", "a", "bewit", "identifier", "for", "the", "resource", "as", "a", "string", "." ]
kumar303/mohawk
python
https://github.com/kumar303/mohawk/blob/037be67ccf50ae704705e67add44e02737a65d21/mohawk/bewit.py#L21-L61
[ "def", "get_bewit", "(", "resource", ")", ":", "if", "resource", ".", "method", "!=", "'GET'", ":", "raise", "ValueError", "(", "'bewits can only be generated for GET requests'", ")", "if", "resource", ".", "nonce", "!=", "''", ":", "raise", "ValueError", "(", ...
037be67ccf50ae704705e67add44e02737a65d21
train
parse_bewit
Returns a `bewittuple` representing the parts of an encoded bewit string. This has the following named attributes: (id, expiration, mac, ext) :param bewit: A base64 encoded bewit string :type bewit: str
mohawk/bewit.py
def parse_bewit(bewit): """ Returns a `bewittuple` representing the parts of an encoded bewit string. This has the following named attributes: (id, expiration, mac, ext) :param bewit: A base64 encoded bewit string :type bewit: str """ decoded_bewit = b64decode(bewit).decode(...
def parse_bewit(bewit): """ Returns a `bewittuple` representing the parts of an encoded bewit string. This has the following named attributes: (id, expiration, mac, ext) :param bewit: A base64 encoded bewit string :type bewit: str """ decoded_bewit = b64decode(bewit).decode(...
[ "Returns", "a", "bewittuple", "representing", "the", "parts", "of", "an", "encoded", "bewit", "string", ".", "This", "has", "the", "following", "named", "attributes", ":", "(", "id", "expiration", "mac", "ext", ")" ]
kumar303/mohawk
python
https://github.com/kumar303/mohawk/blob/037be67ccf50ae704705e67add44e02737a65d21/mohawk/bewit.py#L67-L81
[ "def", "parse_bewit", "(", "bewit", ")", ":", "decoded_bewit", "=", "b64decode", "(", "bewit", ")", ".", "decode", "(", "'ascii'", ")", "bewit_parts", "=", "decoded_bewit", ".", "split", "(", "\"\\\\\"", ")", "if", "len", "(", "bewit_parts", ")", "!=", "...
037be67ccf50ae704705e67add44e02737a65d21
train
strip_bewit
Strips the bewit parameter out of a url. Returns (encoded_bewit, stripped_url) Raises InvalidBewit if no bewit found. :param url: The url containing a bewit parameter :type url: str
mohawk/bewit.py
def strip_bewit(url): """ Strips the bewit parameter out of a url. Returns (encoded_bewit, stripped_url) Raises InvalidBewit if no bewit found. :param url: The url containing a bewit parameter :type url: str """ m = re.search('[?&]bewit=([^&]+)', url) if not m: rai...
def strip_bewit(url): """ Strips the bewit parameter out of a url. Returns (encoded_bewit, stripped_url) Raises InvalidBewit if no bewit found. :param url: The url containing a bewit parameter :type url: str """ m = re.search('[?&]bewit=([^&]+)', url) if not m: rai...
[ "Strips", "the", "bewit", "parameter", "out", "of", "a", "url", "." ]
kumar303/mohawk
python
https://github.com/kumar303/mohawk/blob/037be67ccf50ae704705e67add44e02737a65d21/mohawk/bewit.py#L84-L101
[ "def", "strip_bewit", "(", "url", ")", ":", "m", "=", "re", ".", "search", "(", "'[?&]bewit=([^&]+)'", ",", "url", ")", "if", "not", "m", ":", "raise", "InvalidBewit", "(", "'no bewit data found'", ")", "bewit", "=", "m", ".", "group", "(", "1", ")", ...
037be67ccf50ae704705e67add44e02737a65d21
train
check_bewit
Validates the given bewit. Returns True if the resource has a valid bewit parameter attached, or raises a subclass of HawkFail otherwise. :param credential_lookup: Callable to look up the credentials dict by sender ID. The credentials dict must have the keys: ``id``, ``key``, and `...
mohawk/bewit.py
def check_bewit(url, credential_lookup, now=None): """ Validates the given bewit. Returns True if the resource has a valid bewit parameter attached, or raises a subclass of HawkFail otherwise. :param credential_lookup: Callable to look up the credentials dict by sender ID. The cred...
def check_bewit(url, credential_lookup, now=None): """ Validates the given bewit. Returns True if the resource has a valid bewit parameter attached, or raises a subclass of HawkFail otherwise. :param credential_lookup: Callable to look up the credentials dict by sender ID. The cred...
[ "Validates", "the", "given", "bewit", "." ]
kumar303/mohawk
python
https://github.com/kumar303/mohawk/blob/037be67ccf50ae704705e67add44e02737a65d21/mohawk/bewit.py#L104-L159
[ "def", "check_bewit", "(", "url", ",", "credential_lookup", ",", "now", "=", "None", ")", ":", "raw_bewit", ",", "stripped_url", "=", "strip_bewit", "(", "url", ")", "bewit", "=", "parse_bewit", "(", "raw_bewit", ")", "try", ":", "credentials", "=", "crede...
037be67ccf50ae704705e67add44e02737a65d21
train
Sender.accept_response
Accept a response to this request. :param response_header: A `Hawk`_ ``Server-Authorization`` header such as one created by :class:`mohawk.Receiver`. :type response_header: str :param content=EmptyValue: Byte string of the response body received. :type content=E...
mohawk/sender.py
def accept_response(self, response_header, content=EmptyValue, content_type=EmptyValue, accept_untrusted_content=False, localtime_offset_in_seconds=0, timestamp_skew_in_seconds...
def accept_response(self, response_header, content=EmptyValue, content_type=EmptyValue, accept_untrusted_content=False, localtime_offset_in_seconds=0, timestamp_skew_in_seconds...
[ "Accept", "a", "response", "to", "this", "request", "." ]
kumar303/mohawk
python
https://github.com/kumar303/mohawk/blob/037be67ccf50ae704705e67add44e02737a65d21/mohawk/sender.py#L106-L175
[ "def", "accept_response", "(", "self", ",", "response_header", ",", "content", "=", "EmptyValue", ",", "content_type", "=", "EmptyValue", ",", "accept_untrusted_content", "=", "False", ",", "localtime_offset_in_seconds", "=", "0", ",", "timestamp_skew_in_seconds", "="...
037be67ccf50ae704705e67add44e02737a65d21
train
ChangesMixin.current_state
Returns a ``field -> value`` dict of the current state of the instance.
django_model_changes/changes.py
def current_state(self): """ Returns a ``field -> value`` dict of the current state of the instance. """ field_names = set() [field_names.add(f.name) for f in self._meta.local_fields] [field_names.add(f.attname) for f in self._meta.local_fields] return dict([(fiel...
def current_state(self): """ Returns a ``field -> value`` dict of the current state of the instance. """ field_names = set() [field_names.add(f.name) for f in self._meta.local_fields] [field_names.add(f.attname) for f in self._meta.local_fields] return dict([(fiel...
[ "Returns", "a", "field", "-", ">", "value", "dict", "of", "the", "current", "state", "of", "the", "instance", "." ]
kajic/django-model-changes
python
https://github.com/kajic/django-model-changes/blob/92124ebdf29cba930eb1ced00135823b961041d3/django_model_changes/changes.py#L98-L105
[ "def", "current_state", "(", "self", ")", ":", "field_names", "=", "set", "(", ")", "[", "field_names", ".", "add", "(", "f", ".", "name", ")", "for", "f", "in", "self", ".", "_meta", ".", "local_fields", "]", "[", "field_names", ".", "add", "(", "...
92124ebdf29cba930eb1ced00135823b961041d3
train
ChangesMixin.was_persisted
Returns true if the instance was persisted (saved) in its old state. Examples:: >>> user = User() >>> user.save() >>> user.was_persisted() False >>> user = User.objects.get(pk=1) >>> user.delete() >>> user.was_persist...
django_model_changes/changes.py
def was_persisted(self): """ Returns true if the instance was persisted (saved) in its old state. Examples:: >>> user = User() >>> user.save() >>> user.was_persisted() False >>> user = User.objects.get(pk=1) >>> u...
def was_persisted(self): """ Returns true if the instance was persisted (saved) in its old state. Examples:: >>> user = User() >>> user.save() >>> user.was_persisted() False >>> user = User.objects.get(pk=1) >>> u...
[ "Returns", "true", "if", "the", "instance", "was", "persisted", "(", "saved", ")", "in", "its", "old", "state", "." ]
kajic/django-model-changes
python
https://github.com/kajic/django-model-changes/blob/92124ebdf29cba930eb1ced00135823b961041d3/django_model_changes/changes.py#L149-L167
[ "def", "was_persisted", "(", "self", ")", ":", "pk_name", "=", "self", ".", "_meta", ".", "pk", ".", "name", "return", "bool", "(", "self", ".", "old_state", "(", ")", "[", "pk_name", "]", ")" ]
92124ebdf29cba930eb1ced00135823b961041d3
train
CPE._trim
Remove trailing colons from the URI back to the first non-colon. :param string s: input URI string :returns: URI string with trailing colons removed :rtype: string TEST: trailing colons necessary >>> s = '1:2::::' >>> CPE._trim(s) '1:2' TEST: trailing ...
cpe/cpe.py
def _trim(cls, s): """ Remove trailing colons from the URI back to the first non-colon. :param string s: input URI string :returns: URI string with trailing colons removed :rtype: string TEST: trailing colons necessary >>> s = '1:2::::' >>> CPE._trim(s)...
def _trim(cls, s): """ Remove trailing colons from the URI back to the first non-colon. :param string s: input URI string :returns: URI string with trailing colons removed :rtype: string TEST: trailing colons necessary >>> s = '1:2::::' >>> CPE._trim(s)...
[ "Remove", "trailing", "colons", "from", "the", "URI", "back", "to", "the", "first", "non", "-", "colon", "." ]
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpe.py#L115-L146
[ "def", "_trim", "(", "cls", ",", "s", ")", ":", "reverse", "=", "s", "[", ":", ":", "-", "1", "]", "idx", "=", "0", "for", "i", "in", "range", "(", "0", ",", "len", "(", "reverse", ")", ")", ":", "if", "reverse", "[", "i", "]", "==", "\":...
670d947472a7652af5149324977b50f9a7af9bcf
train
CPE._create_cpe_parts
Create the structure to store the input type of system associated with components of CPE Name (hardware, operating system and software). :param string system: type of system associated with CPE Name :param dict components: CPE Name components to store :returns: None :exception: ...
cpe/cpe.py
def _create_cpe_parts(self, system, components): """ Create the structure to store the input type of system associated with components of CPE Name (hardware, operating system and software). :param string system: type of system associated with CPE Name :param dict components: CPE...
def _create_cpe_parts(self, system, components): """ Create the structure to store the input type of system associated with components of CPE Name (hardware, operating system and software). :param string system: type of system associated with CPE Name :param dict components: CPE...
[ "Create", "the", "structure", "to", "store", "the", "input", "type", "of", "system", "associated", "with", "components", "of", "CPE", "Name", "(", "hardware", "operating", "system", "and", "software", ")", "." ]
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpe.py#L389-L408
[ "def", "_create_cpe_parts", "(", "self", ",", "system", ",", "components", ")", ":", "if", "system", "not", "in", "CPEComponent", ".", "SYSTEM_VALUES", ":", "errmsg", "=", "\"Key '{0}' is not exist\"", ".", "format", "(", "system", ")", "raise", "ValueError", ...
670d947472a7652af5149324977b50f9a7af9bcf
train
CPE._get_attribute_components
Returns the component list of input attribute. :param string att: Attribute name to get :returns: List of Component objects of the attribute in CPE Name :rtype: list :exception: ValueError - invalid attribute name
cpe/cpe.py
def _get_attribute_components(self, att): """ Returns the component list of input attribute. :param string att: Attribute name to get :returns: List of Component objects of the attribute in CPE Name :rtype: list :exception: ValueError - invalid attribute name """...
def _get_attribute_components(self, att): """ Returns the component list of input attribute. :param string att: Attribute name to get :returns: List of Component objects of the attribute in CPE Name :rtype: list :exception: ValueError - invalid attribute name """...
[ "Returns", "the", "component", "list", "of", "input", "attribute", "." ]
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpe.py#L410-L431
[ "def", "_get_attribute_components", "(", "self", ",", "att", ")", ":", "lc", "=", "[", "]", "if", "not", "CPEComponent", ".", "is_valid_attribute", "(", "att", ")", ":", "errmsg", "=", "\"Invalid attribute name '{0}' is not exist\"", ".", "format", "(", "att", ...
670d947472a7652af5149324977b50f9a7af9bcf
train
CPE._pack_edition
Pack the values of the five arguments into the simple edition component. If all the values are blank, just return a blank. :returns: "edition", "sw_edition", "target_sw", "target_hw" and "other" attributes packed in a only value :rtype: string :exception: TypeError - incompa...
cpe/cpe.py
def _pack_edition(self): """ Pack the values of the five arguments into the simple edition component. If all the values are blank, just return a blank. :returns: "edition", "sw_edition", "target_sw", "target_hw" and "other" attributes packed in a only value :rtype: s...
def _pack_edition(self): """ Pack the values of the five arguments into the simple edition component. If all the values are blank, just return a blank. :returns: "edition", "sw_edition", "target_sw", "target_hw" and "other" attributes packed in a only value :rtype: s...
[ "Pack", "the", "values", "of", "the", "five", "arguments", "into", "the", "simple", "edition", "component", ".", "If", "all", "the", "values", "are", "blank", "just", "return", "a", "blank", "." ]
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpe.py#L433-L505
[ "def", "_pack_edition", "(", "self", ")", ":", "COMP_KEYS", "=", "(", "CPEComponent", ".", "ATT_EDITION", ",", "CPEComponent", ".", "ATT_SW_EDITION", ",", "CPEComponent", ".", "ATT_TARGET_SW", ",", "CPEComponent", ".", "ATT_TARGET_HW", ",", "CPEComponent", ".", ...
670d947472a7652af5149324977b50f9a7af9bcf
train
CPE.as_uri_2_3
Returns the CPE Name as URI string of version 2.3. :returns: CPE Name as URI string of version 2.3 :rtype: string :exception: TypeError - incompatible version
cpe/cpe.py
def as_uri_2_3(self): """ Returns the CPE Name as URI string of version 2.3. :returns: CPE Name as URI string of version 2.3 :rtype: string :exception: TypeError - incompatible version """ uri = [] uri.append("cpe:/") ordered_comp_parts = { ...
def as_uri_2_3(self): """ Returns the CPE Name as URI string of version 2.3. :returns: CPE Name as URI string of version 2.3 :rtype: string :exception: TypeError - incompatible version """ uri = [] uri.append("cpe:/") ordered_comp_parts = { ...
[ "Returns", "the", "CPE", "Name", "as", "URI", "string", "of", "version", "2", ".", "3", "." ]
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpe.py#L517-L602
[ "def", "as_uri_2_3", "(", "self", ")", ":", "uri", "=", "[", "]", "uri", ".", "append", "(", "\"cpe:/\"", ")", "ordered_comp_parts", "=", "{", "0", ":", "CPEComponent", ".", "ATT_PART", ",", "1", ":", "CPEComponent", ".", "ATT_VENDOR", ",", "2", ":", ...
670d947472a7652af5149324977b50f9a7af9bcf
train
CPE.as_wfn
Returns the CPE Name as Well-Formed Name string of version 2.3. :return: CPE Name as WFN string :rtype: string :exception: TypeError - incompatible version
cpe/cpe.py
def as_wfn(self): """ Returns the CPE Name as Well-Formed Name string of version 2.3. :return: CPE Name as WFN string :rtype: string :exception: TypeError - incompatible version """ from .cpe2_3_wfn import CPE2_3_WFN wfn = [] wfn.append(CPE2_3_W...
def as_wfn(self): """ Returns the CPE Name as Well-Formed Name string of version 2.3. :return: CPE Name as WFN string :rtype: string :exception: TypeError - incompatible version """ from .cpe2_3_wfn import CPE2_3_WFN wfn = [] wfn.append(CPE2_3_W...
[ "Returns", "the", "CPE", "Name", "as", "Well", "-", "Formed", "Name", "string", "of", "version", "2", ".", "3", "." ]
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpe.py#L604-L666
[ "def", "as_wfn", "(", "self", ")", ":", "from", ".", "cpe2_3_wfn", "import", "CPE2_3_WFN", "wfn", "=", "[", "]", "wfn", ".", "append", "(", "CPE2_3_WFN", ".", "CPE_PREFIX", ")", "for", "i", "in", "range", "(", "0", ",", "len", "(", "CPEComponent", "....
670d947472a7652af5149324977b50f9a7af9bcf
train
CPE.as_fs
Returns the CPE Name as formatted string of version 2.3. :returns: CPE Name as formatted string :rtype: string :exception: TypeError - incompatible version
cpe/cpe.py
def as_fs(self): """ Returns the CPE Name as formatted string of version 2.3. :returns: CPE Name as formatted string :rtype: string :exception: TypeError - incompatible version """ fs = [] fs.append("cpe:2.3:") for i in range(0, len(CPEComponent...
def as_fs(self): """ Returns the CPE Name as formatted string of version 2.3. :returns: CPE Name as formatted string :rtype: string :exception: TypeError - incompatible version """ fs = [] fs.append("cpe:2.3:") for i in range(0, len(CPEComponent...
[ "Returns", "the", "CPE", "Name", "as", "formatted", "string", "of", "version", "2", ".", "3", "." ]
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpe.py#L668-L714
[ "def", "as_fs", "(", "self", ")", ":", "fs", "=", "[", "]", "fs", ".", "append", "(", "\"cpe:2.3:\"", ")", "for", "i", "in", "range", "(", "0", ",", "len", "(", "CPEComponent", ".", "ordered_comp_parts", ")", ")", ":", "ck", "=", "CPEComponent", "....
670d947472a7652af5149324977b50f9a7af9bcf
train
CPEComponentSimple._is_alphanum
Returns True if c is an uppercase letter, a lowercase letter, a digit or an underscore, otherwise False. :param string c: Character to check :returns: True if char is alphanumeric or an underscore, False otherwise :rtype: boolean TEST: a wrong character >>> ...
cpe/comp/cpecomp_simple.py
def _is_alphanum(cls, c): """ Returns True if c is an uppercase letter, a lowercase letter, a digit or an underscore, otherwise False. :param string c: Character to check :returns: True if char is alphanumeric or an underscore, False otherwise :rtype: boolean...
def _is_alphanum(cls, c): """ Returns True if c is an uppercase letter, a lowercase letter, a digit or an underscore, otherwise False. :param string c: Character to check :returns: True if char is alphanumeric or an underscore, False otherwise :rtype: boolean...
[ "Returns", "True", "if", "c", "is", "an", "uppercase", "letter", "a", "lowercase", "letter", "a", "digit", "or", "an", "underscore", "otherwise", "False", "." ]
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp_simple.py#L98-L115
[ "def", "_is_alphanum", "(", "cls", ",", "c", ")", ":", "alphanum_rxc", "=", "re", ".", "compile", "(", "CPEComponentSimple", ".", "_ALPHANUM_PATTERN", ")", "return", "(", "alphanum_rxc", ".", "match", "(", "c", ")", "is", "not", "None", ")" ]
670d947472a7652af5149324977b50f9a7af9bcf
train
CPEComponentSimple._pct_encode_uri
Return the appropriate percent-encoding of character c (URI string). Certain characters are returned without encoding. :param string c: Character to check :returns: Encoded character as URI :rtype: string TEST: >>> c = '.' >>> CPEComponentSimple._pct_encode_uri...
cpe/comp/cpecomp_simple.py
def _pct_encode_uri(cls, c): """ Return the appropriate percent-encoding of character c (URI string). Certain characters are returned without encoding. :param string c: Character to check :returns: Encoded character as URI :rtype: string TEST: >>> c = '...
def _pct_encode_uri(cls, c): """ Return the appropriate percent-encoding of character c (URI string). Certain characters are returned without encoding. :param string c: Character to check :returns: Encoded character as URI :rtype: string TEST: >>> c = '...
[ "Return", "the", "appropriate", "percent", "-", "encoding", "of", "character", "c", "(", "URI", "string", ")", ".", "Certain", "characters", "are", "returned", "without", "encoding", "." ]
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp_simple.py#L118-L143
[ "def", "_pct_encode_uri", "(", "cls", ",", "c", ")", ":", "CPEComponentSimple", ".", "spechar_to_pce", "[", "'-'", "]", "=", "c", "# bound without encoding", "CPEComponentSimple", ".", "spechar_to_pce", "[", "'.'", "]", "=", "c", "# bound without encoding", "retur...
670d947472a7652af5149324977b50f9a7af9bcf
train
CPEComponentSimple._is_valid_language
Return True if the value of component in attribute "language" is valid, and otherwise False. :returns: True if value is valid, False otherwise :rtype: boolean
cpe/comp/cpecomp_simple.py
def _is_valid_language(self): """ Return True if the value of component in attribute "language" is valid, and otherwise False. :returns: True if value is valid, False otherwise :rtype: boolean """ comp_str = self._encoded_value.lower() lang_rxc = re.comp...
def _is_valid_language(self): """ Return True if the value of component in attribute "language" is valid, and otherwise False. :returns: True if value is valid, False otherwise :rtype: boolean """ comp_str = self._encoded_value.lower() lang_rxc = re.comp...
[ "Return", "True", "if", "the", "value", "of", "component", "in", "attribute", "language", "is", "valid", "and", "otherwise", "False", "." ]
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp_simple.py#L184-L195
[ "def", "_is_valid_language", "(", "self", ")", ":", "comp_str", "=", "self", ".", "_encoded_value", ".", "lower", "(", ")", "lang_rxc", "=", "re", ".", "compile", "(", "CPEComponentSimple", ".", "_LANGTAG_PATTERN", ")", "return", "lang_rxc", ".", "match", "(...
670d947472a7652af5149324977b50f9a7af9bcf
train
CPEComponentSimple._is_valid_part
Return True if the value of component in attribute "part" is valid, and otherwise False. :returns: True if value of component is valid, False otherwise :rtype: boolean
cpe/comp/cpecomp_simple.py
def _is_valid_part(self): """ Return True if the value of component in attribute "part" is valid, and otherwise False. :returns: True if value of component is valid, False otherwise :rtype: boolean """ comp_str = self._encoded_value.lower() part_rxc = re...
def _is_valid_part(self): """ Return True if the value of component in attribute "part" is valid, and otherwise False. :returns: True if value of component is valid, False otherwise :rtype: boolean """ comp_str = self._encoded_value.lower() part_rxc = re...
[ "Return", "True", "if", "the", "value", "of", "component", "in", "attribute", "part", "is", "valid", "and", "otherwise", "False", "." ]
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp_simple.py#L197-L208
[ "def", "_is_valid_part", "(", "self", ")", ":", "comp_str", "=", "self", ".", "_encoded_value", ".", "lower", "(", ")", "part_rxc", "=", "re", ".", "compile", "(", "CPEComponentSimple", ".", "_PART_PATTERN", ")", "return", "part_rxc", ".", "match", "(", "c...
670d947472a7652af5149324977b50f9a7af9bcf
train
CPEComponentSimple._parse
Check if the value of component is correct in the attribute "comp_att". :param string comp_att: attribute associated with value of component :returns: None :exception: ValueError - incorrect value of component
cpe/comp/cpecomp_simple.py
def _parse(self, comp_att): """ Check if the value of component is correct in the attribute "comp_att". :param string comp_att: attribute associated with value of component :returns: None :exception: ValueError - incorrect value of component """ errmsg = "Invali...
def _parse(self, comp_att): """ Check if the value of component is correct in the attribute "comp_att". :param string comp_att: attribute associated with value of component :returns: None :exception: ValueError - incorrect value of component """ errmsg = "Invali...
[ "Check", "if", "the", "value", "of", "component", "is", "correct", "in", "the", "attribute", "comp_att", "." ]
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp_simple.py#L223-L259
[ "def", "_parse", "(", "self", ",", "comp_att", ")", ":", "errmsg", "=", "\"Invalid attribute '{0}'\"", ".", "format", "(", "comp_att", ")", "if", "not", "CPEComponent", ".", "is_valid_attribute", "(", "comp_att", ")", ":", "raise", "ValueError", "(", "errmsg",...
670d947472a7652af5149324977b50f9a7af9bcf
train
CPEComponentSimple.as_fs
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 :rtype: string
cpe/comp/cpecomp_simple.py
def as_fs(self): """ 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 co...
def as_fs(self): """ 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 co...
[ "Returns", "the", "value", "of", "component", "encoded", "as", "formatted", "string", "." ]
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp_simple.py#L261-L298
[ "def", "as_fs", "(", "self", ")", ":", "s", "=", "self", ".", "_standard_value", "result", "=", "[", "]", "idx", "=", "0", "while", "(", "idx", "<", "len", "(", "s", ")", ")", ":", "c", "=", "s", "[", "idx", "]", "# get the idx'th character of s", ...
670d947472a7652af5149324977b50f9a7af9bcf
train
CPEComponentSimple.as_uri_2_3
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. ...
cpe/comp/cpecomp_simple.py
def as_uri_2_3(self): """ 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 charac...
def as_uri_2_3(self): """ 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 charac...
[ "Returns", "the", "value", "of", "component", "encoded", "as", "URI", "string", "." ]
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp_simple.py#L300-L344
[ "def", "as_uri_2_3", "(", "self", ")", ":", "s", "=", "self", ".", "_standard_value", "result", "=", "[", "]", "idx", "=", "0", "while", "(", "idx", "<", "len", "(", "s", ")", ")", ":", "thischar", "=", "s", "[", "idx", "]", "# get the idx'th chara...
670d947472a7652af5149324977b50f9a7af9bcf
train
CPEComponentSimple.set_value
Set the value of component. By default, the component has a simple value. :param string comp_str: new value of component :param string comp_att: attribute associated with value of component :returns: None :exception: ValueError - incorrect value of component
cpe/comp/cpecomp_simple.py
def set_value(self, comp_str, comp_att): """ Set the value of component. By default, the component has a simple value. :param string comp_str: new value of component :param string comp_att: attribute associated with value of component :returns: None :exception: V...
def set_value(self, comp_str, comp_att): """ Set the value of component. By default, the component has a simple value. :param string comp_str: new value of component :param string comp_att: attribute associated with value of component :returns: None :exception: V...
[ "Set", "the", "value", "of", "component", ".", "By", "default", "the", "component", "has", "a", "simple", "value", "." ]
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp_simple.py#L367-L390
[ "def", "set_value", "(", "self", ",", "comp_str", ",", "comp_att", ")", ":", "old_value", "=", "self", ".", "_encoded_value", "self", ".", "_encoded_value", "=", "comp_str", "# Check the value of component", "try", ":", "self", ".", "_parse", "(", "comp_att", ...
670d947472a7652af5149324977b50f9a7af9bcf
train
CPEComponent2_3_FS._decode
Convert the characters of string s to standard value (WFN value). Inspect each character in value of component. Copy quoted characters, with their escaping, into the result. Look for unquoted non alphanumerics and if not "*" or "?", add escaping. :exception: ValueError - invalid charact...
cpe/comp/cpecomp2_3_fs.py
def _decode(self): """ Convert the characters of string s to standard value (WFN value). Inspect each character in value of component. Copy quoted characters, with their escaping, into the result. Look for unquoted non alphanumerics and if not "*" or "?", add escaping. :...
def _decode(self): """ Convert the characters of string s to standard value (WFN value). Inspect each character in value of component. Copy quoted characters, with their escaping, into the result. Look for unquoted non alphanumerics and if not "*" or "?", add escaping. :...
[ "Convert", "the", "characters", "of", "string", "s", "to", "standard", "value", "(", "WFN", "value", ")", ".", "Inspect", "each", "character", "in", "value", "of", "component", ".", "Copy", "quoted", "characters", "with", "their", "escaping", "into", "the", ...
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp2_3_fs.py#L93-L165
[ "def", "_decode", "(", "self", ")", ":", "result", "=", "[", "]", "idx", "=", "0", "s", "=", "self", ".", "_encoded_value", "embedded", "=", "False", "errmsg", "=", "[", "]", "errmsg", ".", "append", "(", "\"Invalid character '\"", ")", "while", "(", ...
670d947472a7652af5149324977b50f9a7af9bcf
train
CPE1_1._parse
Checks if the CPE Name is valid. :returns: None :exception: ValueError - bad-formed CPE Name
cpe/cpe1_1.py
def _parse(self): """ Checks if the CPE Name is valid. :returns: None :exception: ValueError - bad-formed CPE Name """ # CPE Name must not have whitespaces if (self.cpe_str.find(" ") != -1): errmsg = "Bad-formed CPE Name: it must not have whitespaces...
def _parse(self): """ Checks if the CPE Name is valid. :returns: None :exception: ValueError - bad-formed CPE Name """ # CPE Name must not have whitespaces if (self.cpe_str.find(" ") != -1): errmsg = "Bad-formed CPE Name: it must not have whitespaces...
[ "Checks", "if", "the", "CPE", "Name", "is", "valid", "." ]
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpe1_1.py#L173-L264
[ "def", "_parse", "(", "self", ")", ":", "# CPE Name must not have whitespaces", "if", "(", "self", ".", "cpe_str", ".", "find", "(", "\" \"", ")", "!=", "-", "1", ")", ":", "errmsg", "=", "\"Bad-formed CPE Name: it must not have whitespaces\"", "raise", "ValueErro...
670d947472a7652af5149324977b50f9a7af9bcf
train
CPE1_1.get_attribute_values
Returns the values of attribute "att_name" of CPE Name. By default a only element in each part. :param string att_name: Attribute name to get :returns: List of attribute values :rtype: list :exception: ValueError - invalid attribute name
cpe/cpe1_1.py
def get_attribute_values(self, att_name): """ Returns the values of attribute "att_name" of CPE Name. By default a only element in each part. :param string att_name: Attribute name to get :returns: List of attribute values :rtype: list :exception: ValueError - in...
def get_attribute_values(self, att_name): """ Returns the values of attribute "att_name" of CPE Name. By default a only element in each part. :param string att_name: Attribute name to get :returns: List of attribute values :rtype: list :exception: ValueError - in...
[ "Returns", "the", "values", "of", "attribute", "att_name", "of", "CPE", "Name", ".", "By", "default", "a", "only", "element", "in", "each", "part", "." ]
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpe1_1.py#L318-L348
[ "def", "get_attribute_values", "(", "self", ",", "att_name", ")", ":", "lc", "=", "[", "]", "if", "not", "CPEComponent", ".", "is_valid_attribute", "(", "att_name", ")", ":", "errmsg", "=", "\"Invalid attribute name: {0}\"", ".", "format", "(", "att_name", ")"...
670d947472a7652af5149324977b50f9a7af9bcf
train
CPEComponent2_3_URI_edpacked.set_value
Set the value of component. :param string comp_str: value of component :returns: None :exception: ValueError - incorrect value of component
cpe/comp/cpecomp2_3_uri_edpacked.py
def set_value(self, comp_str): """ Set the value of component. :param string comp_str: value of component :returns: None :exception: ValueError - incorrect value of component """ self._is_negated = False self._encoded_value = comp_str self._stand...
def set_value(self, comp_str): """ Set the value of component. :param string comp_str: value of component :returns: None :exception: ValueError - incorrect value of component """ self._is_negated = False self._encoded_value = comp_str self._stand...
[ "Set", "the", "value", "of", "component", "." ]
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp2_3_uri_edpacked.py#L91-L103
[ "def", "set_value", "(", "self", ",", "comp_str", ")", ":", "self", ".", "_is_negated", "=", "False", "self", ".", "_encoded_value", "=", "comp_str", "self", ".", "_standard_value", "=", "super", "(", "CPEComponent2_3_URI_edpacked", ",", "self", ")", ".", "_...
670d947472a7652af5149324977b50f9a7af9bcf
train
CPEComponent1_1._decode
Convert the encoded value of component to standard value (WFN value).
cpe/comp/cpecomp1_1.py
def _decode(self): """ Convert the encoded value of component to standard value (WFN value). """ s = self._encoded_value elements = s.replace('~', '').split('!') dec_elements = [] for elem in elements: result = [] idx = 0 whil...
def _decode(self): """ Convert the encoded value of component to standard value (WFN value). """ s = self._encoded_value elements = s.replace('~', '').split('!') dec_elements = [] for elem in elements: result = [] idx = 0 whil...
[ "Convert", "the", "encoded", "value", "of", "component", "to", "standard", "value", "(", "WFN", "value", ")", "." ]
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp1_1.py#L156-L183
[ "def", "_decode", "(", "self", ")", ":", "s", "=", "self", ".", "_encoded_value", "elements", "=", "s", ".", "replace", "(", "'~'", ",", "''", ")", ".", "split", "(", "'!'", ")", "dec_elements", "=", "[", "]", "for", "elem", "in", "elements", ":", ...
670d947472a7652af5149324977b50f9a7af9bcf
train
CPEComponent1_1._is_valid_value
Return True if the value of component in generic attribute is valid, and otherwise False. :returns: True if value is valid, False otherwise :rtype: boolean
cpe/comp/cpecomp1_1.py
def _is_valid_value(self): """ Return True if the value of component in generic attribute is valid, and otherwise False. :returns: True if value is valid, False otherwise :rtype: boolean """ comp_str = self._encoded_value value_pattern = [] valu...
def _is_valid_value(self): """ Return True if the value of component in generic attribute is valid, and otherwise False. :returns: True if value is valid, False otherwise :rtype: boolean """ comp_str = self._encoded_value value_pattern = [] valu...
[ "Return", "True", "if", "the", "value", "of", "component", "in", "generic", "attribute", "is", "valid", "and", "otherwise", "False", "." ]
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp1_1.py#L185-L210
[ "def", "_is_valid_value", "(", "self", ")", ":", "comp_str", "=", "self", ".", "_encoded_value", "value_pattern", "=", "[", "]", "value_pattern", ".", "append", "(", "\"^((\"", ")", "value_pattern", ".", "append", "(", "\"~[\"", ")", "value_pattern", ".", "a...
670d947472a7652af5149324977b50f9a7af9bcf
train
CPEComponent1_1.as_wfn
r""" Returns the value of compoment encoded as Well-Formed Name (WFN) string. :returns: WFN string :rtype: string TEST: >>> val = 'xp!vista' >>> comp1 = CPEComponent1_1(val, CPEComponentSimple.ATT_VERSION) >>> comp1.as_wfn() 'xp\\!vista'
cpe/comp/cpecomp1_1.py
def as_wfn(self): r""" Returns the value of compoment encoded as Well-Formed Name (WFN) string. :returns: WFN string :rtype: string TEST: >>> val = 'xp!vista' >>> comp1 = CPEComponent1_1(val, CPEComponentSimple.ATT_VERSION) >>> comp1.as_wfn() ...
def as_wfn(self): r""" Returns the value of compoment encoded as Well-Formed Name (WFN) string. :returns: WFN string :rtype: string TEST: >>> val = 'xp!vista' >>> comp1 = CPEComponent1_1(val, CPEComponentSimple.ATT_VERSION) >>> comp1.as_wfn() ...
[ "r", "Returns", "the", "value", "of", "compoment", "encoded", "as", "Well", "-", "Formed", "Name", "(", "WFN", ")", "string", "." ]
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp1_1.py#L309-L331
[ "def", "as_wfn", "(", "self", ")", ":", "result", "=", "[", "]", "for", "s", "in", "self", ".", "_standard_value", ":", "result", ".", "append", "(", "s", ")", "result", ".", "append", "(", "CPEComponent1_1", ".", "_ESCAPE_SEPARATOR", ")", "return", "\...
670d947472a7652af5149324977b50f9a7af9bcf
train
CPEComponent1_1.set_value
Set the value of component. By default, the component has a simple value. :param string comp_att: attribute associated with value of component :returns: None :exception: ValueError - incorrect value of component TEST: >>> val = 'xp!vista' >>> val2 = 'sp2' ...
cpe/comp/cpecomp1_1.py
def set_value(self, comp_str, comp_att): """ Set the value of component. By default, the component has a simple value. :param string comp_att: attribute associated with value of component :returns: None :exception: ValueError - incorrect value of component TEST:...
def set_value(self, comp_str, comp_att): """ Set the value of component. By default, the component has a simple value. :param string comp_att: attribute associated with value of component :returns: None :exception: ValueError - incorrect value of component TEST:...
[ "Set", "the", "value", "of", "component", ".", "By", "default", "the", "component", "has", "a", "simple", "value", "." ]
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp1_1.py#L333-L354
[ "def", "set_value", "(", "self", ",", "comp_str", ",", "comp_att", ")", ":", "super", "(", "CPEComponent1_1", ",", "self", ")", ".", "set_value", "(", "comp_str", ",", "comp_att", ")", "self", ".", "_is_negated", "=", "comp_str", ".", "startswith", "(", ...
670d947472a7652af5149324977b50f9a7af9bcf
train
CPE2_3_URI._create_component
Returns a component with value "value". :param string att: Attribute name :param string value: Attribute value :returns: Component object created :rtype: CPEComponent :exception: ValueError - invalid value of attribute
cpe/cpe2_3_uri.py
def _create_component(cls, att, value): """ Returns a component with value "value". :param string att: Attribute name :param string value: Attribute value :returns: Component object created :rtype: CPEComponent :exception: ValueError - invalid value of attribute ...
def _create_component(cls, att, value): """ Returns a component with value "value". :param string att: Attribute name :param string value: Attribute value :returns: Component object created :rtype: CPEComponent :exception: ValueError - invalid value of attribute ...
[ "Returns", "a", "component", "with", "value", "value", "." ]
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpe2_3_uri.py#L104-L131
[ "def", "_create_component", "(", "cls", ",", "att", ",", "value", ")", ":", "if", "value", "==", "CPEComponent2_3_URI", ".", "VALUE_UNDEFINED", ":", "comp", "=", "CPEComponentUndefined", "(", ")", "elif", "(", "value", "==", "CPEComponent2_3_URI", ".", "VALUE_...
670d947472a7652af5149324977b50f9a7af9bcf
train
CPE2_3_URI._unpack_edition
Unpack its elements and set the attributes in wfn accordingly. Parse out the five elements: ~ edition ~ software edition ~ target sw ~ target hw ~ other :param string value: Value of edition attribute :returns: Dictionary with parts of edition attribute :exception: ValueError -...
cpe/cpe2_3_uri.py
def _unpack_edition(cls, value): """ Unpack its elements and set the attributes in wfn accordingly. Parse out the five elements: ~ edition ~ software edition ~ target sw ~ target hw ~ other :param string value: Value of edition attribute :returns: Dictionary with parts ...
def _unpack_edition(cls, value): """ Unpack its elements and set the attributes in wfn accordingly. Parse out the five elements: ~ edition ~ software edition ~ target sw ~ target hw ~ other :param string value: Value of edition attribute :returns: Dictionary with parts ...
[ "Unpack", "its", "elements", "and", "set", "the", "attributes", "in", "wfn", "accordingly", ".", "Parse", "out", "the", "five", "elements", ":" ]
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpe2_3_uri.py#L134-L166
[ "def", "_unpack_edition", "(", "cls", ",", "value", ")", ":", "components", "=", "value", ".", "split", "(", "CPEComponent2_3_URI", ".", "SEPARATOR_PACKED_EDITION", ")", "d", "=", "dict", "(", ")", "ed", "=", "components", "[", "1", "]", "sw_ed", "=", "c...
670d947472a7652af5149324977b50f9a7af9bcf
train
CPE2_3_URI._parse
Checks if the CPE Name is valid. :returns: None :exception: ValueError - bad-formed CPE Name
cpe/cpe2_3_uri.py
def _parse(self): """ Checks if the CPE Name is valid. :returns: None :exception: ValueError - bad-formed CPE Name """ # CPE Name must not have whitespaces if (self._str.find(" ") != -1): msg = "Bad-formed CPE Name: it must not have whitespaces" ...
def _parse(self): """ Checks if the CPE Name is valid. :returns: None :exception: ValueError - bad-formed CPE Name """ # CPE Name must not have whitespaces if (self._str.find(" ") != -1): msg = "Bad-formed CPE Name: it must not have whitespaces" ...
[ "Checks", "if", "the", "CPE", "Name", "is", "valid", "." ]
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpe2_3_uri.py#L254-L343
[ "def", "_parse", "(", "self", ")", ":", "# CPE Name must not have whitespaces", "if", "(", "self", ".", "_str", ".", "find", "(", "\" \"", ")", "!=", "-", "1", ")", ":", "msg", "=", "\"Bad-formed CPE Name: it must not have whitespaces\"", "raise", "ValueError", ...
670d947472a7652af5149324977b50f9a7af9bcf
train
CPE2_3_URI.as_wfn
Returns the CPE Name as Well-Formed Name string of version 2.3. If edition component is not packed, only shows the first seven components, otherwise shows all. :return: CPE Name as WFN string :rtype: string :exception: TypeError - incompatible version
cpe/cpe2_3_uri.py
def as_wfn(self): """ Returns the CPE Name as Well-Formed Name string of version 2.3. If edition component is not packed, only shows the first seven components, otherwise shows all. :return: CPE Name as WFN string :rtype: string :exception: TypeError - incompatib...
def as_wfn(self): """ Returns the CPE Name as Well-Formed Name string of version 2.3. If edition component is not packed, only shows the first seven components, otherwise shows all. :return: CPE Name as WFN string :rtype: string :exception: TypeError - incompatib...
[ "Returns", "the", "CPE", "Name", "as", "Well", "-", "Formed", "Name", "string", "of", "version", "2", ".", "3", ".", "If", "edition", "component", "is", "not", "packed", "only", "shows", "the", "first", "seven", "components", "otherwise", "shows", "all", ...
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpe2_3_uri.py#L345-L415
[ "def", "as_wfn", "(", "self", ")", ":", "if", "self", ".", "_str", ".", "find", "(", "CPEComponent2_3_URI", ".", "SEPARATOR_PACKED_EDITION", ")", "==", "-", "1", ":", "# Edition unpacked, only show the first seven components", "wfn", "=", "[", "]", "wfn", ".", ...
670d947472a7652af5149324977b50f9a7af9bcf
train
CPEComponent2_3_URI._decode
Convert the characters of character in value of component to standard value (WFN value). This function scans the value of component and returns a copy with all percent-encoded characters decoded. :exception: ValueError - invalid character in value of component
cpe/comp/cpecomp2_3_uri.py
def _decode(self): """ Convert the characters of character in value of component to standard value (WFN value). This function scans the value of component and returns a copy with all percent-encoded characters decoded. :exception: ValueError - invalid character in value ...
def _decode(self): """ Convert the characters of character in value of component to standard value (WFN value). This function scans the value of component and returns a copy with all percent-encoded characters decoded. :exception: ValueError - invalid character in value ...
[ "Convert", "the", "characters", "of", "character", "in", "value", "of", "component", "to", "standard", "value", "(", "WFN", "value", ")", ".", "This", "function", "scans", "the", "value", "of", "component", "and", "returns", "a", "copy", "with", "all", "pe...
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp2_3_uri.py#L163-L244
[ "def", "_decode", "(", "self", ")", ":", "result", "=", "[", "]", "idx", "=", "0", "s", "=", "self", ".", "_encoded_value", "embedded", "=", "False", "errmsg", "=", "[", "]", "errmsg", ".", "append", "(", "\"Invalid value: \"", ")", "while", "(", "id...
670d947472a7652af5149324977b50f9a7af9bcf
train
CPEComponent2_3_URI._is_valid_edition
Return True if the input value of attribute "edition" is valid, and otherwise False. :returns: True if value is valid, False otherwise :rtype: boolean
cpe/comp/cpecomp2_3_uri.py
def _is_valid_edition(self): """ Return True if the input value of attribute "edition" is valid, and otherwise False. :returns: True if value is valid, False otherwise :rtype: boolean """ comp_str = self._standard_value[0] packed = [] packed.app...
def _is_valid_edition(self): """ Return True if the input value of attribute "edition" is valid, and otherwise False. :returns: True if value is valid, False otherwise :rtype: boolean """ comp_str = self._standard_value[0] packed = [] packed.app...
[ "Return", "True", "if", "the", "input", "value", "of", "attribute", "edition", "is", "valid", "and", "otherwise", "False", "." ]
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp2_3_uri.py#L246-L271
[ "def", "_is_valid_edition", "(", "self", ")", ":", "comp_str", "=", "self", ".", "_standard_value", "[", "0", "]", "packed", "=", "[", "]", "packed", ".", "append", "(", "\"(\"", ")", "packed", ".", "append", "(", "CPEComponent2_3_URI", ".", "SEPARATOR_PAC...
670d947472a7652af5149324977b50f9a7af9bcf
train
CPEComponent2_3._is_valid_language
Return True if the value of component in attribute "language" is valid, and otherwise False. :returns: True if value is valid, False otherwise :rtype: boolean CASE 1: Language part with/without region part CASE 2: Language part without region part CASE 3: Region part wi...
cpe/comp/cpecomp2_3.py
def _is_valid_language(self): """ Return True if the value of component in attribute "language" is valid, and otherwise False. :returns: True if value is valid, False otherwise :rtype: boolean CASE 1: Language part with/without region part CASE 2: Language part ...
def _is_valid_language(self): """ Return True if the value of component in attribute "language" is valid, and otherwise False. :returns: True if value is valid, False otherwise :rtype: boolean CASE 1: Language part with/without region part CASE 2: Language part ...
[ "Return", "True", "if", "the", "value", "of", "component", "in", "attribute", "language", "is", "valid", "and", "otherwise", "False", "." ]
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp2_3.py#L58-L245
[ "def", "_is_valid_language", "(", "self", ")", ":", "def", "check_generic_language", "(", "self", ",", "value", ")", ":", "\"\"\"\n Check possible values in language part\n when region part exists or not in language value.\n\n Possible values of language ...
670d947472a7652af5149324977b50f9a7af9bcf
train
CPEComponent2_3._is_valid_part
Return True if the value of component in attribute "part" is valid, and otherwise False. :returns: True if value of component is valid, False otherwise :rtype: boolean
cpe/comp/cpecomp2_3.py
def _is_valid_part(self): """ Return True if the value of component in attribute "part" is valid, and otherwise False. :returns: True if value of component is valid, False otherwise :rtype: boolean """ comp_str = self._encoded_value # Check if value of ...
def _is_valid_part(self): """ Return True if the value of component in attribute "part" is valid, and otherwise False. :returns: True if value of component is valid, False otherwise :rtype: boolean """ comp_str = self._encoded_value # Check if value of ...
[ "Return", "True", "if", "the", "value", "of", "component", "in", "attribute", "part", "is", "valid", "and", "otherwise", "False", "." ]
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp2_3.py#L247-L269
[ "def", "_is_valid_part", "(", "self", ")", ":", "comp_str", "=", "self", ".", "_encoded_value", "# Check if value of component do not have wildcard", "if", "(", "(", "comp_str", ".", "find", "(", "self", ".", "WILDCARD_ONE", ")", "==", "-", "1", ")", "and", "(...
670d947472a7652af5149324977b50f9a7af9bcf
train
CPESet2_3._compare
Compares two values associated with a attribute of two WFNs, which may be logical values (ANY or NA) or string values. :param string source: First attribute value :param string target: Second attribute value :returns: The attribute comparison relation. :rtype: int This ...
cpe/cpeset2_3.py
def _compare(cls, source, target): """ Compares two values associated with a attribute of two WFNs, which may be logical values (ANY or NA) or string values. :param string source: First attribute value :param string target: Second attribute value :returns: The attribute ...
def _compare(cls, source, target): """ Compares two values associated with a attribute of two WFNs, which may be logical values (ANY or NA) or string values. :param string source: First attribute value :param string target: Second attribute value :returns: The attribute ...
[ "Compares", "two", "values", "associated", "with", "a", "attribute", "of", "two", "WFNs", "which", "may", "be", "logical", "values", "(", "ANY", "or", "NA", ")", "or", "string", "values", "." ]
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpeset2_3.py#L74-L121
[ "def", "_compare", "(", "cls", ",", "source", ",", "target", ")", ":", "if", "(", "CPESet2_3", ".", "_is_string", "(", "source", ")", ")", ":", "source", "=", "source", ".", "lower", "(", ")", "if", "(", "CPESet2_3", ".", "_is_string", "(", "target",...
670d947472a7652af5149324977b50f9a7af9bcf
train
CPESet2_3._compare_strings
Compares a source string to a target string, and addresses the condition in which the source string includes unquoted special characters. It performs a simple regular expression match, with the assumption that (as required) unquoted special characters appear only at the beginnin...
cpe/cpeset2_3.py
def _compare_strings(cls, source, target): """ Compares a source string to a target string, and addresses the condition in which the source string includes unquoted special characters. It performs a simple regular expression match, with the assumption that (as required) ...
def _compare_strings(cls, source, target): """ Compares a source string to a target string, and addresses the condition in which the source string includes unquoted special characters. It performs a simple regular expression match, with the assumption that (as required) ...
[ "Compares", "a", "source", "string", "to", "a", "target", "string", "and", "addresses", "the", "condition", "in", "which", "the", "source", "string", "includes", "unquoted", "special", "characters", "." ]
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpeset2_3.py#L124-L198
[ "def", "_compare_strings", "(", "cls", ",", "source", ",", "target", ")", ":", "start", "=", "0", "end", "=", "len", "(", "source", ")", "begins", "=", "0", "ends", "=", "0", "# Reading of initial wildcard in source", "if", "source", ".", "startswith", "("...
670d947472a7652af5149324977b50f9a7af9bcf
train
CPESet2_3._contains_wildcards
Return True if the string contains any unquoted special characters (question-mark or asterisk), otherwise False. Ex: _contains_wildcards("foo") => FALSE Ex: _contains_wildcards("foo\?") => FALSE Ex: _contains_wildcards("foo?") => TRUE Ex: _contains_wildcards("\*bar") => FALSE ...
cpe/cpeset2_3.py
def _contains_wildcards(cls, s): """ Return True if the string contains any unquoted special characters (question-mark or asterisk), otherwise False. Ex: _contains_wildcards("foo") => FALSE Ex: _contains_wildcards("foo\?") => FALSE Ex: _contains_wildcards("foo?") => TRUE...
def _contains_wildcards(cls, s): """ Return True if the string contains any unquoted special characters (question-mark or asterisk), otherwise False. Ex: _contains_wildcards("foo") => FALSE Ex: _contains_wildcards("foo\?") => FALSE Ex: _contains_wildcards("foo?") => TRUE...
[ "Return", "True", "if", "the", "string", "contains", "any", "unquoted", "special", "characters", "(", "question", "-", "mark", "or", "asterisk", ")", "otherwise", "False", "." ]
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpeset2_3.py#L201-L235
[ "def", "_contains_wildcards", "(", "cls", ",", "s", ")", ":", "idx", "=", "s", ".", "find", "(", "\"*\"", ")", "if", "idx", "!=", "-", "1", ":", "if", "idx", "==", "0", ":", "return", "True", "else", ":", "if", "s", "[", "idx", "-", "1", "]",...
670d947472a7652af5149324977b50f9a7af9bcf
train
CPESet2_3._is_even_wildcards
Returns True if an even number of escape (backslash) characters precede the character at index idx in string str. :param string str: string to check :returns: True if an even number of escape characters precede the character at index idx in string str, False otherwise. :rtyp...
cpe/cpeset2_3.py
def _is_even_wildcards(cls, str, idx): """ Returns True if an even number of escape (backslash) characters precede the character at index idx in string str. :param string str: string to check :returns: True if an even number of escape characters precede the character...
def _is_even_wildcards(cls, str, idx): """ Returns True if an even number of escape (backslash) characters precede the character at index idx in string str. :param string str: string to check :returns: True if an even number of escape characters precede the character...
[ "Returns", "True", "if", "an", "even", "number", "of", "escape", "(", "backslash", ")", "characters", "precede", "the", "character", "at", "index", "idx", "in", "string", "str", "." ]
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpeset2_3.py#L238-L255
[ "def", "_is_even_wildcards", "(", "cls", ",", "str", ",", "idx", ")", ":", "result", "=", "0", "while", "(", "(", "idx", ">", "0", ")", "and", "(", "str", "[", "idx", "-", "1", "]", "==", "\"\\\\\"", ")", ")", ":", "idx", "-=", "1", "result", ...
670d947472a7652af5149324977b50f9a7af9bcf
train
CPESet2_3._is_string
Return True if arg is a string value, and False if arg is a logical value (ANY or NA). :param string arg: string to check :returns: True if value is a string, False if it is a logical value. :rtype: boolean This function is a support function for _compare().
cpe/cpeset2_3.py
def _is_string(cls, arg): """ Return True if arg is a string value, and False if arg is a logical value (ANY or NA). :param string arg: string to check :returns: True if value is a string, False if it is a logical value. :rtype: boolean This function is a suppor...
def _is_string(cls, arg): """ Return True if arg is a string value, and False if arg is a logical value (ANY or NA). :param string arg: string to check :returns: True if value is a string, False if it is a logical value. :rtype: boolean This function is a suppor...
[ "Return", "True", "if", "arg", "is", "a", "string", "value", "and", "False", "if", "arg", "is", "a", "logical", "value", "(", "ANY", "or", "NA", ")", "." ]
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpeset2_3.py#L258-L273
[ "def", "_is_string", "(", "cls", ",", "arg", ")", ":", "isAny", "=", "arg", "==", "CPEComponent2_3_WFN", ".", "VALUE_ANY", "isNa", "=", "arg", "==", "CPEComponent2_3_WFN", ".", "VALUE_NA", "return", "not", "(", "isAny", "or", "isNa", ")" ]
670d947472a7652af5149324977b50f9a7af9bcf
train
CPESet2_3.compare_wfns
Compares two WFNs and returns a generator of pairwise attribute-value comparison results. It provides full access to the individual comparison results to enable use-case specific implementations of novel name-comparison algorithms. Compare each attribute of the Source WFN to the Target ...
cpe/cpeset2_3.py
def compare_wfns(cls, source, target): """ Compares two WFNs and returns a generator of pairwise attribute-value comparison results. It provides full access to the individual comparison results to enable use-case specific implementations of novel name-comparison algorithms. ...
def compare_wfns(cls, source, target): """ Compares two WFNs and returns a generator of pairwise attribute-value comparison results. It provides full access to the individual comparison results to enable use-case specific implementations of novel name-comparison algorithms. ...
[ "Compares", "two", "WFNs", "and", "returns", "a", "generator", "of", "pairwise", "attribute", "-", "value", "comparison", "results", ".", "It", "provides", "full", "access", "to", "the", "individual", "comparison", "results", "to", "enable", "use", "-", "case"...
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpeset2_3.py#L276-L303
[ "def", "compare_wfns", "(", "cls", ",", "source", ",", "target", ")", ":", "# Compare results using the get() function in WFN", "for", "att", "in", "CPEComponent", ".", "CPE_COMP_KEYS_EXTENDED", ":", "value_src", "=", "source", ".", "get_attribute_values", "(", "att",...
670d947472a7652af5149324977b50f9a7af9bcf
train
CPESet2_3.cpe_disjoint
Compares two WFNs and returns True if the set-theoretic relation between the names is DISJOINT. :param CPE2_3_WFN source: first WFN CPE Name :param CPE2_3_WFN target: seconds WFN CPE Name :returns: True if the set relation between source and target is DISJOINT, otherwise Fal...
cpe/cpeset2_3.py
def cpe_disjoint(cls, source, target): """ Compares two WFNs and returns True if the set-theoretic relation between the names is DISJOINT. :param CPE2_3_WFN source: first WFN CPE Name :param CPE2_3_WFN target: seconds WFN CPE Name :returns: True if the set relation betwe...
def cpe_disjoint(cls, source, target): """ Compares two WFNs and returns True if the set-theoretic relation between the names is DISJOINT. :param CPE2_3_WFN source: first WFN CPE Name :param CPE2_3_WFN target: seconds WFN CPE Name :returns: True if the set relation betwe...
[ "Compares", "two", "WFNs", "and", "returns", "True", "if", "the", "set", "-", "theoretic", "relation", "between", "the", "names", "is", "DISJOINT", "." ]
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpeset2_3.py#L306-L324
[ "def", "cpe_disjoint", "(", "cls", ",", "source", ",", "target", ")", ":", "# If any pairwise comparison returned DISJOINT then", "# the overall name relationship is DISJOINT", "for", "att", ",", "result", "in", "CPESet2_3", ".", "compare_wfns", "(", "source", ",", "ta...
670d947472a7652af5149324977b50f9a7af9bcf
train
CPESet2_3.cpe_equal
Compares two WFNs and returns True if the set-theoretic relation between the names is EQUAL. :param CPE2_3_WFN source: first WFN CPE Name :param CPE2_3_WFN target: seconds WFN CPE Name :returns: True if the set relation between source and target is EQUAL, otherwise False. ...
cpe/cpeset2_3.py
def cpe_equal(cls, source, target): """ Compares two WFNs and returns True if the set-theoretic relation between the names is EQUAL. :param CPE2_3_WFN source: first WFN CPE Name :param CPE2_3_WFN target: seconds WFN CPE Name :returns: True if the set relation between sou...
def cpe_equal(cls, source, target): """ Compares two WFNs and returns True if the set-theoretic relation between the names is EQUAL. :param CPE2_3_WFN source: first WFN CPE Name :param CPE2_3_WFN target: seconds WFN CPE Name :returns: True if the set relation between sou...
[ "Compares", "two", "WFNs", "and", "returns", "True", "if", "the", "set", "-", "theoretic", "relation", "between", "the", "names", "is", "EQUAL", "." ]
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpeset2_3.py#L327-L345
[ "def", "cpe_equal", "(", "cls", ",", "source", ",", "target", ")", ":", "# If any pairwise comparison returned EQUAL then", "# the overall name relationship is EQUAL", "for", "att", ",", "result", "in", "CPESet2_3", ".", "compare_wfns", "(", "source", ",", "target", "...
670d947472a7652af5149324977b50f9a7af9bcf
train
CPESet2_3.cpe_subset
Compares two WFNs and returns True if the set-theoretic relation between the names is (non-proper) SUBSET. :param CPE2_3_WFN source: first WFN CPE Name :param CPE2_3_WFN target: seconds WFN CPE Name :returns: True if the set relation between source and target is SUBSET, othe...
cpe/cpeset2_3.py
def cpe_subset(cls, source, target): """ Compares two WFNs and returns True if the set-theoretic relation between the names is (non-proper) SUBSET. :param CPE2_3_WFN source: first WFN CPE Name :param CPE2_3_WFN target: seconds WFN CPE Name :returns: True if the set relat...
def cpe_subset(cls, source, target): """ Compares two WFNs and returns True if the set-theoretic relation between the names is (non-proper) SUBSET. :param CPE2_3_WFN source: first WFN CPE Name :param CPE2_3_WFN target: seconds WFN CPE Name :returns: True if the set relat...
[ "Compares", "two", "WFNs", "and", "returns", "True", "if", "the", "set", "-", "theoretic", "relation", "between", "the", "names", "is", "(", "non", "-", "proper", ")", "SUBSET", "." ]
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpeset2_3.py#L348-L367
[ "def", "cpe_subset", "(", "cls", ",", "source", ",", "target", ")", ":", "# If any pairwise comparison returned something other than SUBSET", "# or EQUAL, then SUBSET is False.", "for", "att", ",", "result", "in", "CPESet2_3", ".", "compare_wfns", "(", "source", ",", "t...
670d947472a7652af5149324977b50f9a7af9bcf
train
CPESet2_3.cpe_superset
Compares two WFNs and returns True if the set-theoretic relation between the names is (non-proper) SUPERSET. :param CPE2_3_WFN source: first WFN CPE Name :param CPE2_3_WFN target: seconds WFN CPE Name :returns: True if the set relation between source and target is SUPERSET, ...
cpe/cpeset2_3.py
def cpe_superset(cls, source, target): """ Compares two WFNs and returns True if the set-theoretic relation between the names is (non-proper) SUPERSET. :param CPE2_3_WFN source: first WFN CPE Name :param CPE2_3_WFN target: seconds WFN CPE Name :returns: True if the set r...
def cpe_superset(cls, source, target): """ Compares two WFNs and returns True if the set-theoretic relation between the names is (non-proper) SUPERSET. :param CPE2_3_WFN source: first WFN CPE Name :param CPE2_3_WFN target: seconds WFN CPE Name :returns: True if the set r...
[ "Compares", "two", "WFNs", "and", "returns", "True", "if", "the", "set", "-", "theoretic", "relation", "between", "the", "names", "is", "(", "non", "-", "proper", ")", "SUPERSET", "." ]
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpeset2_3.py#L370-L390
[ "def", "cpe_superset", "(", "cls", ",", "source", ",", "target", ")", ":", "# If any pairwise comparison returned something other than SUPERSET", "# or EQUAL, then SUPERSET is False.", "for", "att", ",", "result", "in", "CPESet2_3", ".", "compare_wfns", "(", "source", ","...
670d947472a7652af5149324977b50f9a7af9bcf
train
CPESet2_3.append
Adds a CPE element to the set if not already. Only WFN CPE Names are valid, so this function converts the input CPE object of version 2.3 to WFN style. :param CPE cpe: CPE Name to store in set :returns: None :exception: ValueError - invalid version of CPE Name
cpe/cpeset2_3.py
def append(self, cpe): """ Adds a CPE element to the set if not already. Only WFN CPE Names are valid, so this function converts the input CPE object of version 2.3 to WFN style. :param CPE cpe: CPE Name to store in set :returns: None :exception: ValueError - inv...
def append(self, cpe): """ Adds a CPE element to the set if not already. Only WFN CPE Names are valid, so this function converts the input CPE object of version 2.3 to WFN style. :param CPE cpe: CPE Name to store in set :returns: None :exception: ValueError - inv...
[ "Adds", "a", "CPE", "element", "to", "the", "set", "if", "not", "already", ".", "Only", "WFN", "CPE", "Names", "are", "valid", "so", "this", "function", "converts", "the", "input", "CPE", "object", "of", "version", "2", ".", "3", "to", "WFN", "style", ...
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpeset2_3.py#L396-L421
[ "def", "append", "(", "self", ",", "cpe", ")", ":", "if", "cpe", ".", "VERSION", "!=", "CPE2_3", ".", "VERSION", ":", "errmsg", "=", "\"CPE Name version {0} not valid, version 2.3 expected\"", ".", "format", "(", "cpe", ".", "VERSION", ")", "raise", "ValueErro...
670d947472a7652af5149324977b50f9a7af9bcf
train
CPESet2_3.name_match
Accepts a set of CPE Names K and a candidate CPE Name X. It returns 'True' if X matches any member of K, and 'False' otherwise. :param CPESet self: A set of m known CPE Names K = {K1, K2, …, Km}. :param CPE cpe: A candidate CPE Name X. :returns: True if X matches K, otherwise False. ...
cpe/cpeset2_3.py
def name_match(self, wfn): """ Accepts a set of CPE Names K and a candidate CPE Name X. It returns 'True' if X matches any member of K, and 'False' otherwise. :param CPESet self: A set of m known CPE Names K = {K1, K2, …, Km}. :param CPE cpe: A candidate CPE Name X. :ret...
def name_match(self, wfn): """ Accepts a set of CPE Names K and a candidate CPE Name X. It returns 'True' if X matches any member of K, and 'False' otherwise. :param CPESet self: A set of m known CPE Names K = {K1, K2, …, Km}. :param CPE cpe: A candidate CPE Name X. :ret...
[ "Accepts", "a", "set", "of", "CPE", "Names", "K", "and", "a", "candidate", "CPE", "Name", "X", ".", "It", "returns", "True", "if", "X", "matches", "any", "member", "of", "K", "and", "False", "otherwise", "." ]
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpeset2_3.py#L423-L437
[ "def", "name_match", "(", "self", ",", "wfn", ")", ":", "for", "N", "in", "self", ".", "K", ":", "if", "CPESet2_3", ".", "cpe_superset", "(", "wfn", ",", "N", ")", ":", "return", "True", "return", "False" ]
670d947472a7652af5149324977b50f9a7af9bcf
train
CPE2_3_WFN._parse
Checks if the CPE Name is valid. :returns: None :exception: ValueError - bad-formed CPE Name
cpe/cpe2_3_wfn.py
def _parse(self): """ Checks if the CPE Name is valid. :returns: None :exception: ValueError - bad-formed CPE Name """ # Check prefix and initial bracket of WFN if self._str[0:5] != CPE2_3_WFN.CPE_PREFIX: errmsg = "Bad-formed CPE Name: WFN prefix not...
def _parse(self): """ Checks if the CPE Name is valid. :returns: None :exception: ValueError - bad-formed CPE Name """ # Check prefix and initial bracket of WFN if self._str[0:5] != CPE2_3_WFN.CPE_PREFIX: errmsg = "Bad-formed CPE Name: WFN prefix not...
[ "Checks", "if", "the", "CPE", "Name", "is", "valid", "." ]
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpe2_3_wfn.py#L110-L216
[ "def", "_parse", "(", "self", ")", ":", "# Check prefix and initial bracket of WFN", "if", "self", ".", "_str", "[", "0", ":", "5", "]", "!=", "CPE2_3_WFN", ".", "CPE_PREFIX", ":", "errmsg", "=", "\"Bad-formed CPE Name: WFN prefix not found\"", "raise", "ValueError"...
670d947472a7652af5149324977b50f9a7af9bcf
train
CPELanguage2_2.language_match
Accepts a set of known CPE Names and an expression in the CPE language, and delivers the answer True if the expression matches with the set. Otherwise, it returns False. :param CPELanguage self: An expression in the CPE Applicability Language, represented as the XML infoset for the ...
cpe/cpelang2_2.py
def language_match(self, cpeset, cpel_dom=None): """ Accepts a set of known CPE Names and an expression in the CPE language, and delivers the answer True if the expression matches with the set. Otherwise, it returns False. :param CPELanguage self: An expression in the CPE Applic...
def language_match(self, cpeset, cpel_dom=None): """ Accepts a set of known CPE Names and an expression in the CPE language, and delivers the answer True if the expression matches with the set. Otherwise, it returns False. :param CPELanguage self: An expression in the CPE Applic...
[ "Accepts", "a", "set", "of", "known", "CPE", "Names", "and", "an", "expression", "in", "the", "CPE", "language", "and", "delivers", "the", "answer", "True", "if", "the", "expression", "matches", "with", "the", "set", ".", "Otherwise", "it", "returns", "Fal...
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpelang2_2.py#L59-L149
[ "def", "language_match", "(", "self", ",", "cpeset", ",", "cpel_dom", "=", "None", ")", ":", "# Root element tag", "TAG_ROOT", "=", "'#document'", "# A container for child platform definitions", "TAG_PLATSPEC", "=", "'cpe:platform-specification'", "# Information about a platf...
670d947472a7652af5149324977b50f9a7af9bcf
train
CPESet2_2.append
Adds a CPE Name to the set if not already. :param CPE cpe: CPE Name to store in set :returns: None :exception: ValueError - invalid version of CPE Name TEST: >>> from .cpeset2_2 import CPESet2_2 >>> from .cpe2_2 import CPE2_2 >>> uri1 = 'cpe:/h:hp' >>>...
cpe/cpeset2_2.py
def append(self, cpe): """ Adds a CPE Name to the set if not already. :param CPE cpe: CPE Name to store in set :returns: None :exception: ValueError - invalid version of CPE Name TEST: >>> from .cpeset2_2 import CPESet2_2 >>> from .cpe2_2 import CPE2_2...
def append(self, cpe): """ Adds a CPE Name to the set if not already. :param CPE cpe: CPE Name to store in set :returns: None :exception: ValueError - invalid version of CPE Name TEST: >>> from .cpeset2_2 import CPESet2_2 >>> from .cpe2_2 import CPE2_2...
[ "Adds", "a", "CPE", "Name", "to", "the", "set", "if", "not", "already", "." ]
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpeset2_2.py#L58-L86
[ "def", "append", "(", "self", ",", "cpe", ")", ":", "if", "cpe", ".", "VERSION", "!=", "CPE", ".", "VERSION_2_2", ":", "errmsg", "=", "\"CPE Name version {0} not valid, version 2.2 expected\"", ".", "format", "(", "cpe", ".", "VERSION", ")", "raise", "ValueErr...
670d947472a7652af5149324977b50f9a7af9bcf
train
CPEComponent2_3_WFN.set_value
Set the value of component. :param string comp_str: value of component :param string comp_att: attribute associated with comp_str :returns: None :exception: ValueError - incorrect value of component
cpe/comp/cpecomp2_3_wfn.py
def set_value(self, comp_str, comp_att): """ Set the value of component. :param string comp_str: value of component :param string comp_att: attribute associated with comp_str :returns: None :exception: ValueError - incorrect value of component """ # Del ...
def set_value(self, comp_str, comp_att): """ Set the value of component. :param string comp_str: value of component :param string comp_att: attribute associated with comp_str :returns: None :exception: ValueError - incorrect value of component """ # Del ...
[ "Set", "the", "value", "of", "component", "." ]
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp2_3_wfn.py#L132-L147
[ "def", "set_value", "(", "self", ",", "comp_str", ",", "comp_att", ")", ":", "# Del double quotes of value", "str", "=", "comp_str", "[", "1", ":", "-", "1", "]", "self", ".", "_standard_value", "=", "str", "# Parse the value", "super", "(", "CPEComponent2_3_W...
670d947472a7652af5149324977b50f9a7af9bcf
train
CPESet1_1.append
Adds a CPE Name to the set if not already. :param CPE cpe: CPE Name to store in set :returns: None :exception: ValueError - invalid version of CPE Name TEST: >>> from .cpeset1_1 import CPESet1_1 >>> from .cpe1_1 import CPE1_1 >>> uri1 = 'cpe://microsoft:windows...
cpe/cpeset1_1.py
def append(self, cpe): """ Adds a CPE Name to the set if not already. :param CPE cpe: CPE Name to store in set :returns: None :exception: ValueError - invalid version of CPE Name TEST: >>> from .cpeset1_1 import CPESet1_1 >>> from .cpe1_1 import CPE1_1 ...
def append(self, cpe): """ Adds a CPE Name to the set if not already. :param CPE cpe: CPE Name to store in set :returns: None :exception: ValueError - invalid version of CPE Name TEST: >>> from .cpeset1_1 import CPESet1_1 >>> from .cpe1_1 import CPE1_1 ...
[ "Adds", "a", "CPE", "Name", "to", "the", "set", "if", "not", "already", "." ]
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpeset1_1.py#L56-L83
[ "def", "append", "(", "self", ",", "cpe", ")", ":", "if", "cpe", ".", "VERSION", "!=", "CPE", ".", "VERSION_1_1", ":", "msg", "=", "\"CPE Name version {0} not valid, version 1.1 expected\"", ".", "format", "(", "cpe", ".", "VERSION", ")", "raise", "ValueError"...
670d947472a7652af5149324977b50f9a7af9bcf
train
CPESet1_1.name_match
Accepts a set of known instances of CPE Names and a candidate CPE Name, and returns 'True' if the candidate can be shown to be an instance based on the content of the known instances. Otherwise, it returns 'False'. :param CPESet self: A set of m known CPE Names K = {K1, K2, …, Km}. ...
cpe/cpeset1_1.py
def name_match(self, cpe): """ Accepts a set of known instances of CPE Names and a candidate CPE Name, and returns 'True' if the candidate can be shown to be an instance based on the content of the known instances. Otherwise, it returns 'False'. :param CPESet self: A set...
def name_match(self, cpe): """ Accepts a set of known instances of CPE Names and a candidate CPE Name, and returns 'True' if the candidate can be shown to be an instance based on the content of the known instances. Otherwise, it returns 'False'. :param CPESet self: A set...
[ "Accepts", "a", "set", "of", "known", "instances", "of", "CPE", "Names", "and", "a", "candidate", "CPE", "Name", "and", "returns", "True", "if", "the", "candidate", "can", "be", "shown", "to", "be", "an", "instance", "based", "on", "the", "content", "of"...
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpeset1_1.py#L85-L169
[ "def", "name_match", "(", "self", ",", "cpe", ")", ":", "# An empty set not matching with any CPE", "if", "len", "(", "self", ")", "==", "0", ":", "return", "False", "# If input CPE Name string is in set of CPE Name strings", "# not do searching more because there is a matchi...
670d947472a7652af5149324977b50f9a7af9bcf
train
CPE2_3_FS._parse
Checks if the CPE Name is valid. :returns: None :exception: ValueError - bad-formed CPE Name
cpe/cpe2_3_fs.py
def _parse(self): """ Checks if the CPE Name is valid. :returns: None :exception: ValueError - bad-formed CPE Name """ # CPE Name must not have whitespaces if (self._str.find(" ") != -1): msg = "Bad-formed CPE Name: it must not have whitespaces" ...
def _parse(self): """ Checks if the CPE Name is valid. :returns: None :exception: ValueError - bad-formed CPE Name """ # CPE Name must not have whitespaces if (self._str.find(" ") != -1): msg = "Bad-formed CPE Name: it must not have whitespaces" ...
[ "Checks", "if", "the", "CPE", "Name", "is", "valid", "." ]
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpe2_3_fs.py#L130-L199
[ "def", "_parse", "(", "self", ")", ":", "# CPE Name must not have whitespaces", "if", "(", "self", ".", "_str", ".", "find", "(", "\" \"", ")", "!=", "-", "1", ")", ":", "msg", "=", "\"Bad-formed CPE Name: it must not have whitespaces\"", "raise", "ValueError", ...
670d947472a7652af5149324977b50f9a7af9bcf
train
CPE2_3_FS.get_attribute_values
Returns the values of attribute "att_name" of CPE Name. By default a only element in each part. :param string att_name: Attribute name to get :returns: List of attribute values :rtype: list :exception: ValueError - invalid attribute name
cpe/cpe2_3_fs.py
def get_attribute_values(self, att_name): """ Returns the values of attribute "att_name" of CPE Name. By default a only element in each part. :param string att_name: Attribute name to get :returns: List of attribute values :rtype: list :exception: ValueError - in...
def get_attribute_values(self, att_name): """ Returns the values of attribute "att_name" of CPE Name. By default a only element in each part. :param string att_name: Attribute name to get :returns: List of attribute values :rtype: list :exception: ValueError - in...
[ "Returns", "the", "values", "of", "attribute", "att_name", "of", "CPE", "Name", ".", "By", "default", "a", "only", "element", "in", "each", "part", "." ]
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpe2_3_fs.py#L201-L233
[ "def", "get_attribute_values", "(", "self", ",", "att_name", ")", ":", "lc", "=", "[", "]", "if", "not", "CPEComponent", ".", "is_valid_attribute", "(", "att_name", ")", ":", "errmsg", "=", "\"Invalid attribute name: {0}\"", ".", "format", "(", "att_name", ")"...
670d947472a7652af5149324977b50f9a7af9bcf
train
CPE2_2._parse
Checks if CPE Name is valid. :returns: None :exception: ValueError - bad-formed CPE Name
cpe/cpe2_2.py
def _parse(self): """ Checks if CPE Name is valid. :returns: None :exception: ValueError - bad-formed CPE Name """ # CPE Name must not have whitespaces if (self._str.find(" ") != -1): msg = "Bad-formed CPE Name: it must not have whitespaces" ...
def _parse(self): """ Checks if CPE Name is valid. :returns: None :exception: ValueError - bad-formed CPE Name """ # CPE Name must not have whitespaces if (self._str.find(" ") != -1): msg = "Bad-formed CPE Name: it must not have whitespaces" ...
[ "Checks", "if", "CPE", "Name", "is", "valid", "." ]
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpe2_2.py#L127-L193
[ "def", "_parse", "(", "self", ")", ":", "# CPE Name must not have whitespaces", "if", "(", "self", ".", "_str", ".", "find", "(", "\" \"", ")", "!=", "-", "1", ")", ":", "msg", "=", "\"Bad-formed CPE Name: it must not have whitespaces\"", "raise", "ValueError", ...
670d947472a7652af5149324977b50f9a7af9bcf
train
CPE2_2.as_wfn
Returns the CPE Name as WFN string of version 2.3. Only shows the first seven components. :return: CPE Name as WFN string :rtype: string :exception: TypeError - incompatible version
cpe/cpe2_2.py
def as_wfn(self): """ Returns the CPE Name as WFN string of version 2.3. Only shows the first seven components. :return: CPE Name as WFN string :rtype: string :exception: TypeError - incompatible version """ wfn = [] wfn.append(CPE2_3_WFN.CPE_PRE...
def as_wfn(self): """ Returns the CPE Name as WFN string of version 2.3. Only shows the first seven components. :return: CPE Name as WFN string :rtype: string :exception: TypeError - incompatible version """ wfn = [] wfn.append(CPE2_3_WFN.CPE_PRE...
[ "Returns", "the", "CPE", "Name", "as", "WFN", "string", "of", "version", "2", ".", "3", ".", "Only", "shows", "the", "first", "seven", "components", "." ]
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpe2_2.py#L195-L238
[ "def", "as_wfn", "(", "self", ")", ":", "wfn", "=", "[", "]", "wfn", ".", "append", "(", "CPE2_3_WFN", ".", "CPE_PREFIX", ")", "for", "ck", "in", "CPEComponent", ".", "CPE_COMP_KEYS", ":", "lc", "=", "self", ".", "_get_attribute_components", "(", "ck", ...
670d947472a7652af5149324977b50f9a7af9bcf
train
CPELanguage2_3._fact_ref_eval
Returns True if wfn is a non-proper superset (True superset or equal to) any of the names in cpeset, otherwise False. :param CPESet cpeset: list of CPE bound Names. :param CPE2_3_WFN wfn: WFN CPE Name. :returns: True if wfn is a non-proper superset any of the names in cpeset, otherwise ...
cpe/cpelang2_3.py
def _fact_ref_eval(cls, cpeset, wfn): """ Returns True if wfn is a non-proper superset (True superset or equal to) any of the names in cpeset, otherwise False. :param CPESet cpeset: list of CPE bound Names. :param CPE2_3_WFN wfn: WFN CPE Name. :returns: True if wfn is a ...
def _fact_ref_eval(cls, cpeset, wfn): """ Returns True if wfn is a non-proper superset (True superset or equal to) any of the names in cpeset, otherwise False. :param CPESet cpeset: list of CPE bound Names. :param CPE2_3_WFN wfn: WFN CPE Name. :returns: True if wfn is a ...
[ "Returns", "True", "if", "wfn", "is", "a", "non", "-", "proper", "superset", "(", "True", "superset", "or", "equal", "to", ")", "any", "of", "the", "names", "in", "cpeset", "otherwise", "False", "." ]
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpelang2_3.py#L62-L78
[ "def", "_fact_ref_eval", "(", "cls", ",", "cpeset", ",", "wfn", ")", ":", "for", "n", "in", "cpeset", ":", "# Need to convert each n from bound form to WFN", "if", "(", "CPESet2_3", ".", "cpe_superset", "(", "wfn", ",", "n", ")", ")", ":", "return", "True", ...
670d947472a7652af5149324977b50f9a7af9bcf
train
CPELanguage2_3._check_fact_ref_eval
Returns the result (True, False, Error) of performing the specified check, unless the check isn’t supported, in which case it returns False. Error is a catch-all for all results other than True and False. :param string cpel_dom: XML infoset for the check_fact_ref element. :retur...
cpe/cpelang2_3.py
def _check_fact_ref_eval(cls, cpel_dom): """ Returns the result (True, False, Error) of performing the specified check, unless the check isn’t supported, in which case it returns False. Error is a catch-all for all results other than True and False. :param string cpel_do...
def _check_fact_ref_eval(cls, cpel_dom): """ Returns the result (True, False, Error) of performing the specified check, unless the check isn’t supported, in which case it returns False. Error is a catch-all for all results other than True and False. :param string cpel_do...
[ "Returns", "the", "result", "(", "True", "False", "Error", ")", "of", "performing", "the", "specified", "check", "unless", "the", "check", "isn’t", "supported", "in", "which", "case", "it", "returns", "False", ".", "Error", "is", "a", "catch", "-", "all", ...
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpelang2_3.py#L81-L114
[ "def", "_check_fact_ref_eval", "(", "cls", ",", "cpel_dom", ")", ":", "CHECK_SYSTEM", "=", "\"check-system\"", "CHECK_LOCATION", "=", "\"check-location\"", "CHECK_ID", "=", "\"check-id\"", "checksystemID", "=", "cpel_dom", ".", "getAttribute", "(", "CHECK_SYSTEM", ")"...
670d947472a7652af5149324977b50f9a7af9bcf
train
CPELanguage2_3._unbind
Unbinds a bound form to a WFN. :param string boundname: CPE name :returns: WFN object associated with boundname. :rtype: CPE2_3_WFN
cpe/cpelang2_3.py
def _unbind(cls, boundname): """ Unbinds a bound form to a WFN. :param string boundname: CPE name :returns: WFN object associated with boundname. :rtype: CPE2_3_WFN """ try: fs = CPE2_3_FS(boundname) except: # CPE name is not form...
def _unbind(cls, boundname): """ Unbinds a bound form to a WFN. :param string boundname: CPE name :returns: WFN object associated with boundname. :rtype: CPE2_3_WFN """ try: fs = CPE2_3_FS(boundname) except: # CPE name is not form...
[ "Unbinds", "a", "bound", "form", "to", "a", "WFN", "." ]
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpelang2_3.py#L145-L166
[ "def", "_unbind", "(", "cls", ",", "boundname", ")", ":", "try", ":", "fs", "=", "CPE2_3_FS", "(", "boundname", ")", "except", ":", "# CPE name is not formatted string", "try", ":", "uri", "=", "CPE2_3_URI", "(", "boundname", ")", "except", ":", "# CPE name ...
670d947472a7652af5149324977b50f9a7af9bcf
train
CPELanguage2_3.language_match
Accepts a set of known CPE Names and an expression in the CPE language, and delivers the answer True if the expression matches with the set. Otherwise, it returns False. :param CPELanguage self: An expression in the CPE Applicability Language, represented as the XML infoset for the ...
cpe/cpelang2_3.py
def language_match(self, cpeset, cpel_dom=None): """ Accepts a set of known CPE Names and an expression in the CPE language, and delivers the answer True if the expression matches with the set. Otherwise, it returns False. :param CPELanguage self: An expression in the CPE Applic...
def language_match(self, cpeset, cpel_dom=None): """ Accepts a set of known CPE Names and an expression in the CPE language, and delivers the answer True if the expression matches with the set. Otherwise, it returns False. :param CPELanguage self: An expression in the CPE Applic...
[ "Accepts", "a", "set", "of", "known", "CPE", "Names", "and", "an", "expression", "in", "the", "CPE", "language", "and", "delivers", "the", "answer", "True", "if", "the", "expression", "matches", "with", "the", "set", ".", "Otherwise", "it", "returns", "Fal...
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpelang2_3.py#L172-L277
[ "def", "language_match", "(", "self", ",", "cpeset", ",", "cpel_dom", "=", "None", ")", ":", "# Root element tag", "TAG_ROOT", "=", "'#document'", "# A container for child platform definitions", "TAG_PLATSPEC", "=", "'cpe:platform-specification'", "# Information about a platf...
670d947472a7652af5149324977b50f9a7af9bcf
train
CPESet.name_match
Accepts a set of known instances of CPE Names and a candidate CPE Name, and returns 'True' if the candidate can be shown to be an instance based on the content of the known instances. Otherwise, it returns 'False'. :param CPESet self: A set of m known CPE Names K = {K1, K2, …, Km}. ...
cpe/cpeset.py
def name_match(self, cpe): """ Accepts a set of known instances of CPE Names and a candidate CPE Name, and returns 'True' if the candidate can be shown to be an instance based on the content of the known instances. Otherwise, it returns 'False'. :param CPESet self: A set...
def name_match(self, cpe): """ Accepts a set of known instances of CPE Names and a candidate CPE Name, and returns 'True' if the candidate can be shown to be an instance based on the content of the known instances. Otherwise, it returns 'False'. :param CPESet self: A set...
[ "Accepts", "a", "set", "of", "known", "instances", "of", "CPE", "Names", "and", "a", "candidate", "CPE", "Name", "and", "returns", "True", "if", "the", "candidate", "can", "be", "shown", "to", "be", "an", "instance", "based", "on", "the", "content", "of"...
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpeset.py#L121-L195
[ "def", "name_match", "(", "self", ",", "cpe", ")", ":", "# An empty set not matching with any CPE", "if", "len", "(", "self", ")", "==", "0", ":", "return", "False", "# If input CPE Name string is in set of CPE Name strings", "# not do searching more because there is a matchi...
670d947472a7652af5149324977b50f9a7af9bcf
train
CPEComponent2_2._decode
Convert the encoded value of component to standard value (WFN value).
cpe/comp/cpecomp2_2.py
def _decode(self): """ Convert the encoded value of component to standard value (WFN value). """ result = [] idx = 0 s = self._encoded_value while (idx < len(s)): # Get the idx'th character of s c = s[idx] if (c in CPECompone...
def _decode(self): """ Convert the encoded value of component to standard value (WFN value). """ result = [] idx = 0 s = self._encoded_value while (idx < len(s)): # Get the idx'th character of s c = s[idx] if (c in CPECompone...
[ "Convert", "the", "encoded", "value", "of", "component", "to", "standard", "value", "(", "WFN", "value", ")", "." ]
nilp0inter/cpe
python
https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp2_2.py#L90-L113
[ "def", "_decode", "(", "self", ")", ":", "result", "=", "[", "]", "idx", "=", "0", "s", "=", "self", ".", "_encoded_value", "while", "(", "idx", "<", "len", "(", "s", ")", ")", ":", "# Get the idx'th character of s", "c", "=", "s", "[", "idx", "]",...
670d947472a7652af5149324977b50f9a7af9bcf
train
is_component
Check if the set of ids form a single connected component Parameters ---------- w : spatial weights boject ids : list identifiers of units that are tested to be a single connected component Returns ------- True : if the list of ids represents a single connected...
giddy/components.py
def is_component(w, ids): """Check if the set of ids form a single connected component Parameters ---------- w : spatial weights boject ids : list identifiers of units that are tested to be a single connected component Returns ------- True : if the list of ...
def is_component(w, ids): """Check if the set of ids form a single connected component Parameters ---------- w : spatial weights boject ids : list identifiers of units that are tested to be a single connected component Returns ------- True : if the list of ...
[ "Check", "if", "the", "set", "of", "ids", "form", "a", "single", "connected", "component" ]
pysal/giddy
python
https://github.com/pysal/giddy/blob/13fae6c18933614be78e91a6b5060693bea33a04/giddy/components.py#L11-L50
[ "def", "is_component", "(", "w", ",", "ids", ")", ":", "components", "=", "0", "marks", "=", "dict", "(", "[", "(", "node", ",", "0", ")", "for", "node", "in", "ids", "]", ")", "q", "=", "[", "]", "for", "node", "in", "ids", ":", "if", "marks...
13fae6c18933614be78e91a6b5060693bea33a04
train
check_contiguity
Check if contiguity is maintained if leaver is removed from neighbors Parameters ---------- w : spatial weights object simple contiguity based weights neighbors : list nodes that are to be checked if they form a single \ connec...
giddy/components.py
def check_contiguity(w, neighbors, leaver): """Check if contiguity is maintained if leaver is removed from neighbors Parameters ---------- w : spatial weights object simple contiguity based weights neighbors : list nodes that are to be checked if th...
def check_contiguity(w, neighbors, leaver): """Check if contiguity is maintained if leaver is removed from neighbors Parameters ---------- w : spatial weights object simple contiguity based weights neighbors : list nodes that are to be checked if th...
[ "Check", "if", "contiguity", "is", "maintained", "if", "leaver", "is", "removed", "from", "neighbors" ]
pysal/giddy
python
https://github.com/pysal/giddy/blob/13fae6c18933614be78e91a6b5060693bea33a04/giddy/components.py#L53-L103
[ "def", "check_contiguity", "(", "w", ",", "neighbors", ",", "leaver", ")", ":", "ids", "=", "neighbors", "[", ":", "]", "ids", ".", "remove", "(", "leaver", ")", "return", "is_component", "(", "w", ",", "ids", ")" ]
13fae6c18933614be78e91a6b5060693bea33a04
train
confirm
Ask user a yes/no question and return their response as a boolean. ``question`` should be a simple, grammatically complete question such as "Do you wish to continue?", and will have a string similar to ``" [Y/n] "`` appended automatically. This function will *not* append a question mark for you. B...
invocations/console.py
def confirm(question, assume_yes=True): """ Ask user a yes/no question and return their response as a boolean. ``question`` should be a simple, grammatically complete question such as "Do you wish to continue?", and will have a string similar to ``" [Y/n] "`` appended automatically. This function w...
def confirm(question, assume_yes=True): """ Ask user a yes/no question and return their response as a boolean. ``question`` should be a simple, grammatically complete question such as "Do you wish to continue?", and will have a string similar to ``" [Y/n] "`` appended automatically. This function w...
[ "Ask", "user", "a", "yes", "/", "no", "question", "and", "return", "their", "response", "as", "a", "boolean", "." ]
pyinvoke/invocations
python
https://github.com/pyinvoke/invocations/blob/bbf1b319bd1536817d5301ceb9eeb2f31830e5dc/invocations/console.py#L13-L59
[ "def", "confirm", "(", "question", ",", "assume_yes", "=", "True", ")", ":", "# Set up suffix", "if", "assume_yes", ":", "suffix", "=", "\"Y/n\"", "else", ":", "suffix", "=", "\"y/N\"", "# Loop till we get something we like", "# TODO: maybe don't do this? It can be anno...
bbf1b319bd1536817d5301ceb9eeb2f31830e5dc
train
jsonapi
Declare the view as a JSON API method This converts view return value into a :cls:JsonResponse. The following return types are supported: - tuple: a tuple of (response, status, headers) - any other object is converted to JSON
flask_jsontools/decorators.py
def jsonapi(f): """ Declare the view as a JSON API method This converts view return value into a :cls:JsonResponse. The following return types are supported: - tuple: a tuple of (response, status, headers) - any other object is converted to JSON """ @wraps(f) de...
def jsonapi(f): """ Declare the view as a JSON API method This converts view return value into a :cls:JsonResponse. The following return types are supported: - tuple: a tuple of (response, status, headers) - any other object is converted to JSON """ @wraps(f) de...
[ "Declare", "the", "view", "as", "a", "JSON", "API", "method" ]
kolypto/py-flask-jsontools
python
https://github.com/kolypto/py-flask-jsontools/blob/1abee2d40e6db262e43f0c534e90faaa9b26246a/flask_jsontools/decorators.py#L6-L19
[ "def", "jsonapi", "(", "f", ")", ":", "@", "wraps", "(", "f", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "rv", "=", "f", "(", "*", "args", ",", "*", "*", "kwargs", ")", "return", "make_json_response", "(", "rv",...
1abee2d40e6db262e43f0c534e90faaa9b26246a
train
_unpack
Download + unpack given package into temp dir ``tmp``. Return ``(real_version, source)`` where ``real_version`` is the "actual" version downloaded (e.g. if a Git master was indicated, it will be the SHA of master HEAD) and ``source`` is the source directory (relative to unpacked source) to import into ...
invocations/packaging/vendorize.py
def _unpack(c, tmp, package, version, git_url=None): """ Download + unpack given package into temp dir ``tmp``. Return ``(real_version, source)`` where ``real_version`` is the "actual" version downloaded (e.g. if a Git master was indicated, it will be the SHA of master HEAD) and ``source`` is the s...
def _unpack(c, tmp, package, version, git_url=None): """ Download + unpack given package into temp dir ``tmp``. Return ``(real_version, source)`` where ``real_version`` is the "actual" version downloaded (e.g. if a Git master was indicated, it will be the SHA of master HEAD) and ``source`` is the s...
[ "Download", "+", "unpack", "given", "package", "into", "temp", "dir", "tmp", "." ]
pyinvoke/invocations
python
https://github.com/pyinvoke/invocations/blob/bbf1b319bd1536817d5301ceb9eeb2f31830e5dc/invocations/packaging/vendorize.py#L13-L60
[ "def", "_unpack", "(", "c", ",", "tmp", ",", "package", ",", "version", ",", "git_url", "=", "None", ")", ":", "real_version", "=", "version", "[", ":", "]", "source", "=", "None", "if", "git_url", ":", "pass", "# git clone into tempdir", "# git checko...
bbf1b319bd1536817d5301ceb9eeb2f31830e5dc
train
vendorize
Vendorize Python package ``distribution`` at version/SHA ``version``. Specify the vendor folder (e.g. ``<mypackage>/vendor``) as ``vendor_dir``. For Crate/PyPI releases, ``package`` should be the name of the software entry on those sites, and ``version`` should be a specific version number. E.g. ``ven...
invocations/packaging/vendorize.py
def vendorize( c, distribution, version, vendor_dir, package=None, git_url=None, license=None, ): """ Vendorize Python package ``distribution`` at version/SHA ``version``. Specify the vendor folder (e.g. ``<mypackage>/vendor``) as ``vendor_dir``. For Crate/PyPI releases, ``...
def vendorize( c, distribution, version, vendor_dir, package=None, git_url=None, license=None, ): """ Vendorize Python package ``distribution`` at version/SHA ``version``. Specify the vendor folder (e.g. ``<mypackage>/vendor``) as ``vendor_dir``. For Crate/PyPI releases, ``...
[ "Vendorize", "Python", "package", "distribution", "at", "version", "/", "SHA", "version", "." ]
pyinvoke/invocations
python
https://github.com/pyinvoke/invocations/blob/bbf1b319bd1536817d5301ceb9eeb2f31830e5dc/invocations/packaging/vendorize.py#L64-L118
[ "def", "vendorize", "(", "c", ",", "distribution", ",", "version", ",", "vendor_dir", ",", "package", "=", "None", ",", "git_url", "=", "None", ",", "license", "=", "None", ",", ")", ":", "with", "tmpdir", "(", ")", "as", "tmp", ":", "package", "=", ...
bbf1b319bd1536817d5301ceb9eeb2f31830e5dc
train
make_sudouser
Create a passworded sudo-capable user. Used by other tasks to execute the test suite so sudo tests work.
invocations/travis.py
def make_sudouser(c): """ Create a passworded sudo-capable user. Used by other tasks to execute the test suite so sudo tests work. """ user = c.travis.sudo.user password = c.travis.sudo.password # --create-home because we need a place to put conf files, keys etc # --groups travis becaus...
def make_sudouser(c): """ Create a passworded sudo-capable user. Used by other tasks to execute the test suite so sudo tests work. """ user = c.travis.sudo.user password = c.travis.sudo.password # --create-home because we need a place to put conf files, keys etc # --groups travis becaus...
[ "Create", "a", "passworded", "sudo", "-", "capable", "user", "." ]
pyinvoke/invocations
python
https://github.com/pyinvoke/invocations/blob/bbf1b319bd1536817d5301ceb9eeb2f31830e5dc/invocations/travis.py#L26-L49
[ "def", "make_sudouser", "(", "c", ")", ":", "user", "=", "c", ".", "travis", ".", "sudo", ".", "user", "password", "=", "c", ".", "travis", ".", "sudo", ".", "password", "# --create-home because we need a place to put conf files, keys etc", "# --groups travis becaus...
bbf1b319bd1536817d5301ceb9eeb2f31830e5dc
train
make_sshable
Set up passwordless SSH keypair & authorized_hosts access to localhost.
invocations/travis.py
def make_sshable(c): """ Set up passwordless SSH keypair & authorized_hosts access to localhost. """ user = c.travis.sudo.user home = "~{0}".format(user) # Run sudo() as the new sudo user; means less chown'ing, etc. c.config.sudo.user = user ssh_dir = "{0}/.ssh".format(home) # TODO: ...
def make_sshable(c): """ Set up passwordless SSH keypair & authorized_hosts access to localhost. """ user = c.travis.sudo.user home = "~{0}".format(user) # Run sudo() as the new sudo user; means less chown'ing, etc. c.config.sudo.user = user ssh_dir = "{0}/.ssh".format(home) # TODO: ...
[ "Set", "up", "passwordless", "SSH", "keypair", "&", "authorized_hosts", "access", "to", "localhost", "." ]
pyinvoke/invocations
python
https://github.com/pyinvoke/invocations/blob/bbf1b319bd1536817d5301ceb9eeb2f31830e5dc/invocations/travis.py#L55-L68
[ "def", "make_sshable", "(", "c", ")", ":", "user", "=", "c", ".", "travis", ".", "sudo", ".", "user", "home", "=", "\"~{0}\"", ".", "format", "(", "user", ")", "# Run sudo() as the new sudo user; means less chown'ing, etc.", "c", ".", "config", ".", "sudo", ...
bbf1b319bd1536817d5301ceb9eeb2f31830e5dc
train
sudo_run
Run some command under Travis-oriented sudo subshell/virtualenv. :param str command: Command string to run, e.g. ``inv coverage``, ``inv integration``, etc. (Does not necessarily need to be an Invoke task, but...)
invocations/travis.py
def sudo_run(c, command): """ Run some command under Travis-oriented sudo subshell/virtualenv. :param str command: Command string to run, e.g. ``inv coverage``, ``inv integration``, etc. (Does not necessarily need to be an Invoke task, but...) """ # NOTE: explicit shell wrapper beca...
def sudo_run(c, command): """ Run some command under Travis-oriented sudo subshell/virtualenv. :param str command: Command string to run, e.g. ``inv coverage``, ``inv integration``, etc. (Does not necessarily need to be an Invoke task, but...) """ # NOTE: explicit shell wrapper beca...
[ "Run", "some", "command", "under", "Travis", "-", "oriented", "sudo", "subshell", "/", "virtualenv", "." ]
pyinvoke/invocations
python
https://github.com/pyinvoke/invocations/blob/bbf1b319bd1536817d5301ceb9eeb2f31830e5dc/invocations/travis.py#L72-L85
[ "def", "sudo_run", "(", "c", ",", "command", ")", ":", "# NOTE: explicit shell wrapper because sourcing the venv works best here;", "# test tasks currently use their own subshell to call e.g. 'pytest --blah',", "# so the tactic of '$VIRTUAL_ENV/bin/inv coverage' doesn't help - only that", "# i...
bbf1b319bd1536817d5301ceb9eeb2f31830e5dc
train
blacken
Install and execute ``black`` under appropriate circumstances, with diffs. Installs and runs ``black`` under Python 3.6 (the first version it supports). Since this sort of CI based task only needs to run once per commit (formatting is not going to change between interpreters) this seems like a worthwhi...
invocations/travis.py
def blacken(c): """ Install and execute ``black`` under appropriate circumstances, with diffs. Installs and runs ``black`` under Python 3.6 (the first version it supports). Since this sort of CI based task only needs to run once per commit (formatting is not going to change between interpreters) th...
def blacken(c): """ Install and execute ``black`` under appropriate circumstances, with diffs. Installs and runs ``black`` under Python 3.6 (the first version it supports). Since this sort of CI based task only needs to run once per commit (formatting is not going to change between interpreters) th...
[ "Install", "and", "execute", "black", "under", "appropriate", "circumstances", "with", "diffs", "." ]
pyinvoke/invocations
python
https://github.com/pyinvoke/invocations/blob/bbf1b319bd1536817d5301ceb9eeb2f31830e5dc/invocations/travis.py#L166-L190
[ "def", "blacken", "(", "c", ")", ":", "if", "not", "PYTHON", ".", "startswith", "(", "\"3.6\"", ")", ":", "msg", "=", "\"Not blackening, since Python {} != Python 3.6\"", ".", "format", "(", "PYTHON", ")", "print", "(", "msg", ",", "file", "=", "sys", ".",...
bbf1b319bd1536817d5301ceb9eeb2f31830e5dc
train
Tau._calc
List based implementation of binary tree algorithm for concordance measure after :cite:`Christensen2005`.
giddy/rank.py
def _calc(self, x, y): """ List based implementation of binary tree algorithm for concordance measure after :cite:`Christensen2005`. """ x = np.array(x) y = np.array(y) n = len(y) perm = list(range(n)) perm.sort(key=lambda a: (x[a], y[a])) ...
def _calc(self, x, y): """ List based implementation of binary tree algorithm for concordance measure after :cite:`Christensen2005`. """ x = np.array(x) y = np.array(y) n = len(y) perm = list(range(n)) perm.sort(key=lambda a: (x[a], y[a])) ...
[ "List", "based", "implementation", "of", "binary", "tree", "algorithm", "for", "concordance", "measure", "after", ":", "cite", ":", "Christensen2005", "." ]
pysal/giddy
python
https://github.com/pysal/giddy/blob/13fae6c18933614be78e91a6b5060693bea33a04/giddy/rank.py#L171-L261
[ "def", "_calc", "(", "self", ",", "x", ",", "y", ")", ":", "x", "=", "np", ".", "array", "(", "x", ")", "y", "=", "np", ".", "array", "(", "y", ")", "n", "=", "len", "(", "y", ")", "perm", "=", "list", "(", "range", "(", "n", ")", ")", ...
13fae6c18933614be78e91a6b5060693bea33a04
train
_MethodViewInfo.decorator
Wrapper function to decorate a function
flask_jsontools/views.py
def decorator(self, func): """ Wrapper function to decorate a function """ if inspect.isfunction(func): func._methodview = self elif inspect.ismethod(func): func.__func__._methodview = self else: raise AssertionError('Can only decorate function and met...
def decorator(self, func): """ Wrapper function to decorate a function """ if inspect.isfunction(func): func._methodview = self elif inspect.ismethod(func): func.__func__._methodview = self else: raise AssertionError('Can only decorate function and met...
[ "Wrapper", "function", "to", "decorate", "a", "function" ]
kolypto/py-flask-jsontools
python
https://github.com/kolypto/py-flask-jsontools/blob/1abee2d40e6db262e43f0c534e90faaa9b26246a/flask_jsontools/views.py#L30-L38
[ "def", "decorator", "(", "self", ",", "func", ")", ":", "if", "inspect", ".", "isfunction", "(", "func", ")", ":", "func", ".", "_methodview", "=", "self", "elif", "inspect", ".", "ismethod", "(", "func", ")", ":", "func", ".", "__func__", ".", "_met...
1abee2d40e6db262e43f0c534e90faaa9b26246a
train
_MethodViewInfo.matches
Test if the method matches the provided set of arguments :param verb: HTTP verb. Uppercase :type verb: str :param params: Existing route parameters :type params: set :returns: Whether this view matches :rtype: bool
flask_jsontools/views.py
def matches(self, verb, params): """ Test if the method matches the provided set of arguments :param verb: HTTP verb. Uppercase :type verb: str :param params: Existing route parameters :type params: set :returns: Whether this view matches :rtype: bool """...
def matches(self, verb, params): """ Test if the method matches the provided set of arguments :param verb: HTTP verb. Uppercase :type verb: str :param params: Existing route parameters :type params: set :returns: Whether this view matches :rtype: bool """...
[ "Test", "if", "the", "method", "matches", "the", "provided", "set", "of", "arguments" ]
kolypto/py-flask-jsontools
python
https://github.com/kolypto/py-flask-jsontools/blob/1abee2d40e6db262e43f0c534e90faaa9b26246a/flask_jsontools/views.py#L63-L75
[ "def", "matches", "(", "self", ",", "verb", ",", "params", ")", ":", "return", "(", "self", ".", "ifset", "is", "None", "or", "self", ".", "ifset", "<=", "params", ")", "and", "(", "self", ".", "ifnset", "is", "None", "or", "self", ".", "ifnset", ...
1abee2d40e6db262e43f0c534e90faaa9b26246a
train
MethodView._match_view
Detect a view matching the query :param method: HTTP method :param route_params: Route parameters dict :return: Method :rtype: Callable|None
flask_jsontools/views.py
def _match_view(self, method, route_params): """ Detect a view matching the query :param method: HTTP method :param route_params: Route parameters dict :return: Method :rtype: Callable|None """ method = method.upper() route_params = frozenset(k for k, v i...
def _match_view(self, method, route_params): """ Detect a view matching the query :param method: HTTP method :param route_params: Route parameters dict :return: Method :rtype: Callable|None """ method = method.upper() route_params = frozenset(k for k, v i...
[ "Detect", "a", "view", "matching", "the", "query" ]
kolypto/py-flask-jsontools
python
https://github.com/kolypto/py-flask-jsontools/blob/1abee2d40e6db262e43f0c534e90faaa9b26246a/flask_jsontools/views.py#L112-L127
[ "def", "_match_view", "(", "self", ",", "method", ",", "route_params", ")", ":", "method", "=", "method", ".", "upper", "(", ")", "route_params", "=", "frozenset", "(", "k", "for", "k", ",", "v", "in", "route_params", ".", "items", "(", ")", "if", "v...
1abee2d40e6db262e43f0c534e90faaa9b26246a
train
MethodView.route_as_view
Register the view with an URL route :param app: Flask application :type app: flask.Flask|flask.Blueprint :param name: Unique view name :type name: str :param rules: List of route rules to use :type rules: Iterable[str|werkzeug.routing.Rule] :param class_args: Args...
flask_jsontools/views.py
def route_as_view(cls, app, name, rules, *class_args, **class_kwargs): """ Register the view with an URL route :param app: Flask application :type app: flask.Flask|flask.Blueprint :param name: Unique view name :type name: str :param rules: List of route rules to use ...
def route_as_view(cls, app, name, rules, *class_args, **class_kwargs): """ Register the view with an URL route :param app: Flask application :type app: flask.Flask|flask.Blueprint :param name: Unique view name :type name: str :param rules: List of route rules to use ...
[ "Register", "the", "view", "with", "an", "URL", "route", ":", "param", "app", ":", "Flask", "application", ":", "type", "app", ":", "flask", ".", "Flask|flask", ".", "Blueprint", ":", "param", "name", ":", "Unique", "view", "name", ":", "type", "name", ...
kolypto/py-flask-jsontools
python
https://github.com/kolypto/py-flask-jsontools/blob/1abee2d40e6db262e43f0c534e90faaa9b26246a/flask_jsontools/views.py#L136-L152
[ "def", "route_as_view", "(", "cls", ",", "app", ",", "name", ",", "rules", ",", "*", "class_args", ",", "*", "*", "class_kwargs", ")", ":", "view", "=", "super", "(", "MethodView", ",", "cls", ")", ".", "as_view", "(", "name", ",", "*", "class_args",...
1abee2d40e6db262e43f0c534e90faaa9b26246a
train
steady_state
Calculates the steady state probability vector for a regular Markov transition matrix P. Parameters ---------- P : array (k, k), an ergodic Markov transition probability matrix. Returns ------- : array (k, ), steady state distribution. Exa...
giddy/ergodic.py
def steady_state(P): """ Calculates the steady state probability vector for a regular Markov transition matrix P. Parameters ---------- P : array (k, k), an ergodic Markov transition probability matrix. Returns ------- : array (k, ), st...
def steady_state(P): """ Calculates the steady state probability vector for a regular Markov transition matrix P. Parameters ---------- P : array (k, k), an ergodic Markov transition probability matrix. Returns ------- : array (k, ), st...
[ "Calculates", "the", "steady", "state", "probability", "vector", "for", "a", "regular", "Markov", "transition", "matrix", "P", "." ]
pysal/giddy
python
https://github.com/pysal/giddy/blob/13fae6c18933614be78e91a6b5060693bea33a04/giddy/ergodic.py#L12-L59
[ "def", "steady_state", "(", "P", ")", ":", "v", ",", "d", "=", "la", ".", "eig", "(", "np", ".", "transpose", "(", "P", ")", ")", "d", "=", "np", ".", "array", "(", "d", ")", "# for a regular P maximum eigenvalue will be 1", "mv", "=", "max", "(", ...
13fae6c18933614be78e91a6b5060693bea33a04
train
fmpt
Calculates the matrix of first mean passage times for an ergodic transition probability matrix. Parameters ---------- P : array (k, k), an ergodic Markov transition probability matrix. Returns ------- M : array (k, k), elements are the expected value for the num...
giddy/ergodic.py
def fmpt(P): """ Calculates the matrix of first mean passage times for an ergodic transition probability matrix. Parameters ---------- P : array (k, k), an ergodic Markov transition probability matrix. Returns ------- M : array (k, k), elements are the e...
def fmpt(P): """ Calculates the matrix of first mean passage times for an ergodic transition probability matrix. Parameters ---------- P : array (k, k), an ergodic Markov transition probability matrix. Returns ------- M : array (k, k), elements are the e...
[ "Calculates", "the", "matrix", "of", "first", "mean", "passage", "times", "for", "an", "ergodic", "transition", "probability", "matrix", "." ]
pysal/giddy
python
https://github.com/pysal/giddy/blob/13fae6c18933614be78e91a6b5060693bea33a04/giddy/ergodic.py#L62-L118
[ "def", "fmpt", "(", "P", ")", ":", "P", "=", "np", ".", "matrix", "(", "P", ")", "k", "=", "P", ".", "shape", "[", "0", "]", "A", "=", "np", ".", "zeros_like", "(", "P", ")", "ss", "=", "steady_state", "(", "P", ")", ".", "reshape", "(", ...
13fae6c18933614be78e91a6b5060693bea33a04
train
var_fmpt
Variances of first mean passage times for an ergodic transition probability matrix. Parameters ---------- P : array (k, k), an ergodic Markov transition probability matrix. Returns ------- : array (k, k), elements are the variances for the number of in...
giddy/ergodic.py
def var_fmpt(P): """ Variances of first mean passage times for an ergodic transition probability matrix. Parameters ---------- P : array (k, k), an ergodic Markov transition probability matrix. Returns ------- : array (k, k), elements are the v...
def var_fmpt(P): """ Variances of first mean passage times for an ergodic transition probability matrix. Parameters ---------- P : array (k, k), an ergodic Markov transition probability matrix. Returns ------- : array (k, k), elements are the v...
[ "Variances", "of", "first", "mean", "passage", "times", "for", "an", "ergodic", "transition", "probability", "matrix", "." ]
pysal/giddy
python
https://github.com/pysal/giddy/blob/13fae6c18933614be78e91a6b5060693bea33a04/giddy/ergodic.py#L121-L167
[ "def", "var_fmpt", "(", "P", ")", ":", "P", "=", "np", ".", "matrix", "(", "P", ")", "A", "=", "P", "**", "1000", "n", ",", "k", "=", "A", ".", "shape", "I", "=", "np", ".", "identity", "(", "k", ")", "Z", "=", "la", ".", "inv", "(", "I...
13fae6c18933614be78e91a6b5060693bea33a04
train
_converge
Examine world state, returning data on what needs updating for release. :param c: Invoke ``Context`` object or subclass. :returns: Two dicts (technically, dict subclasses, which allow attribute access), ``actions`` and ``state`` (in that order.) ``actions`` maps release component name...
invocations/packaging/release.py
def _converge(c): """ Examine world state, returning data on what needs updating for release. :param c: Invoke ``Context`` object or subclass. :returns: Two dicts (technically, dict subclasses, which allow attribute access), ``actions`` and ``state`` (in that order.) ``actions...
def _converge(c): """ Examine world state, returning data on what needs updating for release. :param c: Invoke ``Context`` object or subclass. :returns: Two dicts (technically, dict subclasses, which allow attribute access), ``actions`` and ``state`` (in that order.) ``actions...
[ "Examine", "world", "state", "returning", "data", "on", "what", "needs", "updating", "for", "release", "." ]
pyinvoke/invocations
python
https://github.com/pyinvoke/invocations/blob/bbf1b319bd1536817d5301ceb9eeb2f31830e5dc/invocations/packaging/release.py#L110-L240
[ "def", "_converge", "(", "c", ")", ":", "#", "# Data/state gathering", "#", "# Get data about current repo context: what branch are we on & what kind of", "# release does it appear to represent?", "branch", ",", "release_type", "=", "_release_line", "(", "c", ")", "# Short-circ...
bbf1b319bd1536817d5301ceb9eeb2f31830e5dc
train
status
Print current release (version, changelog, tag, etc) status. Doubles as a subroutine, returning the return values from its inner call to ``_converge`` (an ``(actions, state)`` two-tuple of Lexicons).
invocations/packaging/release.py
def status(c): """ Print current release (version, changelog, tag, etc) status. Doubles as a subroutine, returning the return values from its inner call to ``_converge`` (an ``(actions, state)`` two-tuple of Lexicons). """ # TODO: wants some holistic "you don't actually HAVE any changes to ...
def status(c): """ Print current release (version, changelog, tag, etc) status. Doubles as a subroutine, returning the return values from its inner call to ``_converge`` (an ``(actions, state)`` two-tuple of Lexicons). """ # TODO: wants some holistic "you don't actually HAVE any changes to ...
[ "Print", "current", "release", "(", "version", "changelog", "tag", "etc", ")", "status", "." ]
pyinvoke/invocations
python
https://github.com/pyinvoke/invocations/blob/bbf1b319bd1536817d5301ceb9eeb2f31830e5dc/invocations/packaging/release.py#L244-L260
[ "def", "status", "(", "c", ")", ":", "# TODO: wants some holistic \"you don't actually HAVE any changes to", "# release\" final status - i.e. all steps were at no-op status.", "actions", ",", "state", "=", "_converge", "(", "c", ")", "table", "=", "[", "]", "# NOTE: explicit ...
bbf1b319bd1536817d5301ceb9eeb2f31830e5dc
train
prepare
Edit changelog & version, git commit, and git tag, to set up for release.
invocations/packaging/release.py
def prepare(c): """ Edit changelog & version, git commit, and git tag, to set up for release. """ # Print dry-run/status/actions-to-take data & grab programmatic result # TODO: maybe expand the enum-based stuff to have values that split up # textual description, command string, etc. See the TODO...
def prepare(c): """ Edit changelog & version, git commit, and git tag, to set up for release. """ # Print dry-run/status/actions-to-take data & grab programmatic result # TODO: maybe expand the enum-based stuff to have values that split up # textual description, command string, etc. See the TODO...
[ "Edit", "changelog", "&", "version", "git", "commit", "and", "git", "tag", "to", "set", "up", "for", "release", "." ]
pyinvoke/invocations
python
https://github.com/pyinvoke/invocations/blob/bbf1b319bd1536817d5301ceb9eeb2f31830e5dc/invocations/packaging/release.py#L277-L325
[ "def", "prepare", "(", "c", ")", ":", "# Print dry-run/status/actions-to-take data & grab programmatic result", "# TODO: maybe expand the enum-based stuff to have values that split up", "# textual description, command string, etc. See the TODO up by their", "# definition too, re: just making them ...
bbf1b319bd1536817d5301ceb9eeb2f31830e5dc
train
_release_line
Examine current repo state to determine what type of release to prep. :returns: A two-tuple of ``(branch-name, line-type)`` where: - ``branch-name`` is the current branch name, e.g. ``1.1``, ``master``, ``gobbledygook`` (or, usually, ``HEAD`` if not on a branch). - ``line-type`` ...
invocations/packaging/release.py
def _release_line(c): """ Examine current repo state to determine what type of release to prep. :returns: A two-tuple of ``(branch-name, line-type)`` where: - ``branch-name`` is the current branch name, e.g. ``1.1``, ``master``, ``gobbledygook`` (or, usually, ``HEAD`` if not on a...
def _release_line(c): """ Examine current repo state to determine what type of release to prep. :returns: A two-tuple of ``(branch-name, line-type)`` where: - ``branch-name`` is the current branch name, e.g. ``1.1``, ``master``, ``gobbledygook`` (or, usually, ``HEAD`` if not on a...
[ "Examine", "current", "repo", "state", "to", "determine", "what", "type", "of", "release", "to", "prep", "." ]
pyinvoke/invocations
python
https://github.com/pyinvoke/invocations/blob/bbf1b319bd1536817d5301ceb9eeb2f31830e5dc/invocations/packaging/release.py#L330-L364
[ "def", "_release_line", "(", "c", ")", ":", "# TODO: I don't _think_ this technically overlaps with Releases (because", "# that only ever deals with changelog contents, and therefore full release", "# version numbers) but in case it does, move it there sometime.", "# TODO: this and similar calls i...
bbf1b319bd1536817d5301ceb9eeb2f31830e5dc
train
_versions_from_changelog
Return all released versions from given ``changelog``, sorted. :param dict changelog: A changelog dict as returned by ``releases.util.parse_changelog``. :returns: A sorted list of `semantic_version.Version` objects.
invocations/packaging/release.py
def _versions_from_changelog(changelog): """ Return all released versions from given ``changelog``, sorted. :param dict changelog: A changelog dict as returned by ``releases.util.parse_changelog``. :returns: A sorted list of `semantic_version.Version` objects. """ versions = [Version(x...
def _versions_from_changelog(changelog): """ Return all released versions from given ``changelog``, sorted. :param dict changelog: A changelog dict as returned by ``releases.util.parse_changelog``. :returns: A sorted list of `semantic_version.Version` objects. """ versions = [Version(x...
[ "Return", "all", "released", "versions", "from", "given", "changelog", "sorted", "." ]
pyinvoke/invocations
python
https://github.com/pyinvoke/invocations/blob/bbf1b319bd1536817d5301ceb9eeb2f31830e5dc/invocations/packaging/release.py#L381-L391
[ "def", "_versions_from_changelog", "(", "changelog", ")", ":", "versions", "=", "[", "Version", "(", "x", ")", "for", "x", "in", "changelog", "if", "BUGFIX_RELEASE_RE", ".", "match", "(", "x", ")", "]", "return", "sorted", "(", "versions", ")" ]
bbf1b319bd1536817d5301ceb9eeb2f31830e5dc
train
_release_and_issues
Return most recent branch-appropriate release, if any, and its contents. :param dict changelog: Changelog contents, as returned by ``releases.util.parse_changelog``. :param str branch: Branch name. :param release_type: Member of `Release`, e.g. `Release.FEATURE`. :returns: ...
invocations/packaging/release.py
def _release_and_issues(changelog, branch, release_type): """ Return most recent branch-appropriate release, if any, and its contents. :param dict changelog: Changelog contents, as returned by ``releases.util.parse_changelog``. :param str branch: Branch name. :param release_type: ...
def _release_and_issues(changelog, branch, release_type): """ Return most recent branch-appropriate release, if any, and its contents. :param dict changelog: Changelog contents, as returned by ``releases.util.parse_changelog``. :param str branch: Branch name. :param release_type: ...
[ "Return", "most", "recent", "branch", "-", "appropriate", "release", "if", "any", "and", "its", "contents", "." ]
pyinvoke/invocations
python
https://github.com/pyinvoke/invocations/blob/bbf1b319bd1536817d5301ceb9eeb2f31830e5dc/invocations/packaging/release.py#L395-L427
[ "def", "_release_and_issues", "(", "changelog", ",", "branch", ",", "release_type", ")", ":", "# Bugfix lines just use the branch to find issues", "bucket", "=", "branch", "# Features need a bit more logic", "if", "release_type", "is", "Release", ".", "FEATURE", ":", "buc...
bbf1b319bd1536817d5301ceb9eeb2f31830e5dc
train
_get_tags
Return sorted list of release-style tags as semver objects.
invocations/packaging/release.py
def _get_tags(c): """ Return sorted list of release-style tags as semver objects. """ tags_ = [] for tagstr in c.run("git tag", hide=True).stdout.strip().split("\n"): try: tags_.append(Version(tagstr)) # Ignore anything non-semver; most of the time they'll be non-release ...
def _get_tags(c): """ Return sorted list of release-style tags as semver objects. """ tags_ = [] for tagstr in c.run("git tag", hide=True).stdout.strip().split("\n"): try: tags_.append(Version(tagstr)) # Ignore anything non-semver; most of the time they'll be non-release ...
[ "Return", "sorted", "list", "of", "release", "-", "style", "tags", "as", "semver", "objects", "." ]
pyinvoke/invocations
python
https://github.com/pyinvoke/invocations/blob/bbf1b319bd1536817d5301ceb9eeb2f31830e5dc/invocations/packaging/release.py#L430-L445
[ "def", "_get_tags", "(", "c", ")", ":", "tags_", "=", "[", "]", "for", "tagstr", "in", "c", ".", "run", "(", "\"git tag\"", ",", "hide", "=", "True", ")", ".", "stdout", ".", "strip", "(", ")", ".", "split", "(", "\"\\n\"", ")", ":", "try", ":"...
bbf1b319bd1536817d5301ceb9eeb2f31830e5dc
train
_find_package
Try to find 'the' One True Package for this project. Mostly for obtaining the ``_version`` file within it. Uses the ``packaging.package`` config setting if defined. If not defined, fallback is to look for a single top-level Python package (directory containing ``__init__.py``). (This search ignores a ...
invocations/packaging/release.py
def _find_package(c): """ Try to find 'the' One True Package for this project. Mostly for obtaining the ``_version`` file within it. Uses the ``packaging.package`` config setting if defined. If not defined, fallback is to look for a single top-level Python package (directory containing ``__ini...
def _find_package(c): """ Try to find 'the' One True Package for this project. Mostly for obtaining the ``_version`` file within it. Uses the ``packaging.package`` config setting if defined. If not defined, fallback is to look for a single top-level Python package (directory containing ``__ini...
[ "Try", "to", "find", "the", "One", "True", "Package", "for", "this", "project", "." ]
pyinvoke/invocations
python
https://github.com/pyinvoke/invocations/blob/bbf1b319bd1536817d5301ceb9eeb2f31830e5dc/invocations/packaging/release.py#L471-L502
[ "def", "_find_package", "(", "c", ")", ":", "# TODO: is there a way to get this from the same place setup.py does w/o", "# setup.py barfing (since setup() runs at import time and assumes CLI use)?", "configured_value", "=", "c", ".", "get", "(", "\"packaging\"", ",", "{", "}", ")...
bbf1b319bd1536817d5301ceb9eeb2f31830e5dc
train
build
Build sdist and/or wheel archives, optionally in a temp base directory. All parameters save ``directory`` honor config settings of the same name, under the ``packaging`` tree. E.g. say ``.configure({'packaging': {'wheel': True}})`` to force building wheel archives by default. :param bool sdist: ...
invocations/packaging/release.py
def build(c, sdist=True, wheel=False, directory=None, python=None, clean=True): """ Build sdist and/or wheel archives, optionally in a temp base directory. All parameters save ``directory`` honor config settings of the same name, under the ``packaging`` tree. E.g. say ``.configure({'packaging': {'wheel...
def build(c, sdist=True, wheel=False, directory=None, python=None, clean=True): """ Build sdist and/or wheel archives, optionally in a temp base directory. All parameters save ``directory`` honor config settings of the same name, under the ``packaging`` tree. E.g. say ``.configure({'packaging': {'wheel...
[ "Build", "sdist", "and", "/", "or", "wheel", "archives", "optionally", "in", "a", "temp", "base", "directory", "." ]
pyinvoke/invocations
python
https://github.com/pyinvoke/invocations/blob/bbf1b319bd1536817d5301ceb9eeb2f31830e5dc/invocations/packaging/release.py#L518-L590
[ "def", "build", "(", "c", ",", "sdist", "=", "True", ",", "wheel", "=", "False", ",", "directory", "=", "None", ",", "python", "=", "None", ",", "clean", "=", "True", ")", ":", "# Config hooks", "config", "=", "c", ".", "config", ".", "get", "(", ...
bbf1b319bd1536817d5301ceb9eeb2f31830e5dc