repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
contentful/contentful.py | contentful/content_type_field_types.py | ArrayField.coerce | def coerce(self, value, **kwargs):
"""Coerces array items with proper coercion."""
result = []
for v in value:
result.append(self._coercion.coerce(v, **kwargs))
return result | python | def coerce(self, value, **kwargs):
"""Coerces array items with proper coercion."""
result = []
for v in value:
result.append(self._coercion.coerce(v, **kwargs))
return result | [
"def",
"coerce",
"(",
"self",
",",
"value",
",",
"**",
"kwargs",
")",
":",
"result",
"=",
"[",
"]",
"for",
"v",
"in",
"value",
":",
"result",
".",
"append",
"(",
"self",
".",
"_coercion",
".",
"coerce",
"(",
"v",
",",
"**",
"kwargs",
")",
")",
... | Coerces array items with proper coercion. | [
"Coerces",
"array",
"items",
"with",
"proper",
"coercion",
"."
] | 73fe01d6ae5a1f8818880da65199107b584681dd | https://github.com/contentful/contentful.py/blob/73fe01d6ae5a1f8818880da65199107b584681dd/contentful/content_type_field_types.py#L124-L130 | train |
contentful/contentful.py | contentful/content_type_field_types.py | RichTextField.coerce | def coerce(self, value, includes=None, errors=None, resources=None, default_locale='en-US', locale=None):
"""Coerces Rich Text properly."""
if includes is None:
includes = []
if errors is None:
errors = []
return self._coerce_block(
value,
... | python | def coerce(self, value, includes=None, errors=None, resources=None, default_locale='en-US', locale=None):
"""Coerces Rich Text properly."""
if includes is None:
includes = []
if errors is None:
errors = []
return self._coerce_block(
value,
... | [
"def",
"coerce",
"(",
"self",
",",
"value",
",",
"includes",
"=",
"None",
",",
"errors",
"=",
"None",
",",
"resources",
"=",
"None",
",",
"default_locale",
"=",
"'en-US'",
",",
"locale",
"=",
"None",
")",
":",
"if",
"includes",
"is",
"None",
":",
"in... | Coerces Rich Text properly. | [
"Coerces",
"Rich",
"Text",
"properly",
"."
] | 73fe01d6ae5a1f8818880da65199107b584681dd | https://github.com/contentful/contentful.py/blob/73fe01d6ae5a1f8818880da65199107b584681dd/contentful/content_type_field_types.py#L225-L240 | train |
contentful/contentful.py | contentful/content_type_field.py | ContentTypeField.coerce | def coerce(self, value, **kwargs):
"""Coerces the value to the proper type."""
if value is None:
return None
return self._coercion.coerce(value, **kwargs) | python | def coerce(self, value, **kwargs):
"""Coerces the value to the proper type."""
if value is None:
return None
return self._coercion.coerce(value, **kwargs) | [
"def",
"coerce",
"(",
"self",
",",
"value",
",",
"**",
"kwargs",
")",
":",
"if",
"value",
"is",
"None",
":",
"return",
"None",
"return",
"self",
".",
"_coercion",
".",
"coerce",
"(",
"value",
",",
"**",
"kwargs",
")"
] | Coerces the value to the proper type. | [
"Coerces",
"the",
"value",
"to",
"the",
"proper",
"type",
"."
] | 73fe01d6ae5a1f8818880da65199107b584681dd | https://github.com/contentful/contentful.py/blob/73fe01d6ae5a1f8818880da65199107b584681dd/contentful/content_type_field.py#L34-L39 | train |
contentful/contentful.py | contentful/client.py | Client.content_type | def content_type(self, content_type_id, query=None):
"""Fetches a Content Type by ID.
API Reference: https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/content-types/content-type/get-a-single-content-type
:param content_type_id: The ID of the target Content ... | python | def content_type(self, content_type_id, query=None):
"""Fetches a Content Type by ID.
API Reference: https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/content-types/content-type/get-a-single-content-type
:param content_type_id: The ID of the target Content ... | [
"def",
"content_type",
"(",
"self",
",",
"content_type_id",
",",
"query",
"=",
"None",
")",
":",
"return",
"self",
".",
"_get",
"(",
"self",
".",
"environment_url",
"(",
"'/content_types/{0}'",
".",
"format",
"(",
"content_type_id",
")",
")",
",",
"query",
... | Fetches a Content Type by ID.
API Reference: https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/content-types/content-type/get-a-single-content-type
:param content_type_id: The ID of the target Content Type.
:param query: (optional) Dict with API options.
... | [
"Fetches",
"a",
"Content",
"Type",
"by",
"ID",
"."
] | 73fe01d6ae5a1f8818880da65199107b584681dd | https://github.com/contentful/contentful.py/blob/73fe01d6ae5a1f8818880da65199107b584681dd/contentful/client.py#L153-L173 | train |
contentful/contentful.py | contentful/client.py | Client.entry | def entry(self, entry_id, query=None):
"""Fetches an Entry by ID.
API Reference: https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/entries/entry/get-a-single-entry
:param entry_id: The ID of the target Entry.
:param query: (optional) Dict with API o... | python | def entry(self, entry_id, query=None):
"""Fetches an Entry by ID.
API Reference: https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/entries/entry/get-a-single-entry
:param entry_id: The ID of the target Entry.
:param query: (optional) Dict with API o... | [
"def",
"entry",
"(",
"self",
",",
"entry_id",
",",
"query",
"=",
"None",
")",
":",
"if",
"query",
"is",
"None",
":",
"query",
"=",
"{",
"}",
"self",
".",
"_normalize_select",
"(",
"query",
")",
"try",
":",
"query",
".",
"update",
"(",
"{",
"'sys.id... | Fetches an Entry by ID.
API Reference: https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/entries/entry/get-a-single-entry
:param entry_id: The ID of the target Entry.
:param query: (optional) Dict with API options.
:return: :class:`Entry <contentful... | [
"Fetches",
"an",
"Entry",
"by",
"ID",
"."
] | 73fe01d6ae5a1f8818880da65199107b584681dd | https://github.com/contentful/contentful.py/blob/73fe01d6ae5a1f8818880da65199107b584681dd/contentful/client.py#L197-L225 | train |
contentful/contentful.py | contentful/client.py | Client.asset | def asset(self, asset_id, query=None):
"""Fetches an Asset by ID.
API Reference: https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/assets/asset/get-a-single-asset
:param asset_id: The ID of the target Asset.
:param query: (optional) Dict with API op... | python | def asset(self, asset_id, query=None):
"""Fetches an Asset by ID.
API Reference: https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/assets/asset/get-a-single-asset
:param asset_id: The ID of the target Asset.
:param query: (optional) Dict with API op... | [
"def",
"asset",
"(",
"self",
",",
"asset_id",
",",
"query",
"=",
"None",
")",
":",
"return",
"self",
".",
"_get",
"(",
"self",
".",
"environment_url",
"(",
"'/assets/{0}'",
".",
"format",
"(",
"asset_id",
")",
")",
",",
"query",
")"
] | Fetches an Asset by ID.
API Reference: https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/assets/asset/get-a-single-asset
:param asset_id: The ID of the target Asset.
:param query: (optional) Dict with API options.
:return: :class:`Asset <Asset>` obj... | [
"Fetches",
"an",
"Asset",
"by",
"ID",
"."
] | 73fe01d6ae5a1f8818880da65199107b584681dd | https://github.com/contentful/contentful.py/blob/73fe01d6ae5a1f8818880da65199107b584681dd/contentful/client.py#L259-L279 | train |
contentful/contentful.py | contentful/client.py | Client.sync | def sync(self, query=None):
"""Fetches content from the Sync API.
API Reference: https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/synchronization/initial-synchronization/query-entries
:param query: (optional) Dict with API options.
:return: :class:... | python | def sync(self, query=None):
"""Fetches content from the Sync API.
API Reference: https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/synchronization/initial-synchronization/query-entries
:param query: (optional) Dict with API options.
:return: :class:... | [
"def",
"sync",
"(",
"self",
",",
"query",
"=",
"None",
")",
":",
"if",
"query",
"is",
"None",
":",
"query",
"=",
"{",
"}",
"self",
".",
"_normalize_sync",
"(",
"query",
")",
"return",
"self",
".",
"_get",
"(",
"self",
".",
"environment_url",
"(",
"... | Fetches content from the Sync API.
API Reference: https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/synchronization/initial-synchronization/query-entries
:param query: (optional) Dict with API options.
:return: :class:`SyncPage <contentful.sync_page.SyncPag... | [
"Fetches",
"content",
"from",
"the",
"Sync",
"API",
"."
] | 73fe01d6ae5a1f8818880da65199107b584681dd | https://github.com/contentful/contentful.py/blob/73fe01d6ae5a1f8818880da65199107b584681dd/contentful/client.py#L330-L351 | train |
contentful/contentful.py | contentful/client.py | Client._request_headers | def _request_headers(self):
"""
Sets the default Request Headers.
"""
headers = {
'X-Contentful-User-Agent': self._contentful_user_agent(),
'Content-Type': 'application/vnd.contentful.delivery.v{0}+json'.format( # noqa: E501
self.api_version
... | python | def _request_headers(self):
"""
Sets the default Request Headers.
"""
headers = {
'X-Contentful-User-Agent': self._contentful_user_agent(),
'Content-Type': 'application/vnd.contentful.delivery.v{0}+json'.format( # noqa: E501
self.api_version
... | [
"def",
"_request_headers",
"(",
"self",
")",
":",
"headers",
"=",
"{",
"'X-Contentful-User-Agent'",
":",
"self",
".",
"_contentful_user_agent",
"(",
")",
",",
"'Content-Type'",
":",
"'application/vnd.contentful.delivery.v{0}+json'",
".",
"format",
"(",
"self",
".",
... | Sets the default Request Headers. | [
"Sets",
"the",
"default",
"Request",
"Headers",
"."
] | 73fe01d6ae5a1f8818880da65199107b584681dd | https://github.com/contentful/contentful.py/blob/73fe01d6ae5a1f8818880da65199107b584681dd/contentful/client.py#L476-L493 | train |
contentful/contentful.py | contentful/client.py | Client._url | def _url(self, url):
"""
Creates the Request URL.
"""
protocol = 'https' if self.https else 'http'
return '{0}://{1}/spaces/{2}{3}'.format(
protocol,
self.api_url,
self.space_id,
url
) | python | def _url(self, url):
"""
Creates the Request URL.
"""
protocol = 'https' if self.https else 'http'
return '{0}://{1}/spaces/{2}{3}'.format(
protocol,
self.api_url,
self.space_id,
url
) | [
"def",
"_url",
"(",
"self",
",",
"url",
")",
":",
"protocol",
"=",
"'https'",
"if",
"self",
".",
"https",
"else",
"'http'",
"return",
"'{0}://{1}/spaces/{2}{3}'",
".",
"format",
"(",
"protocol",
",",
"self",
".",
"api_url",
",",
"self",
".",
"space_id",
... | Creates the Request URL. | [
"Creates",
"the",
"Request",
"URL",
"."
] | 73fe01d6ae5a1f8818880da65199107b584681dd | https://github.com/contentful/contentful.py/blob/73fe01d6ae5a1f8818880da65199107b584681dd/contentful/client.py#L495-L506 | train |
contentful/contentful.py | contentful/client.py | Client._normalize_query | def _normalize_query(self, query):
"""
Converts Arrays in the query to comma
separaters lists for proper API handling.
"""
for k, v in query.items():
if isinstance(v, list):
query[k] = ','.join([str(e) for e in v]) | python | def _normalize_query(self, query):
"""
Converts Arrays in the query to comma
separaters lists for proper API handling.
"""
for k, v in query.items():
if isinstance(v, list):
query[k] = ','.join([str(e) for e in v]) | [
"def",
"_normalize_query",
"(",
"self",
",",
"query",
")",
":",
"for",
"k",
",",
"v",
"in",
"query",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"v",
",",
"list",
")",
":",
"query",
"[",
"k",
"]",
"=",
"','",
".",
"join",
"(",
"[",
... | Converts Arrays in the query to comma
separaters lists for proper API handling. | [
"Converts",
"Arrays",
"in",
"the",
"query",
"to",
"comma",
"separaters",
"lists",
"for",
"proper",
"API",
"handling",
"."
] | 73fe01d6ae5a1f8818880da65199107b584681dd | https://github.com/contentful/contentful.py/blob/73fe01d6ae5a1f8818880da65199107b584681dd/contentful/client.py#L508-L516 | train |
contentful/contentful.py | contentful/client.py | Client._http_get | def _http_get(self, url, query):
"""
Performs the HTTP GET Request.
"""
if not self.authorization_as_header:
query.update({'access_token': self.access_token})
response = None
self._normalize_query(query)
kwargs = {
'params': query,
... | python | def _http_get(self, url, query):
"""
Performs the HTTP GET Request.
"""
if not self.authorization_as_header:
query.update({'access_token': self.access_token})
response = None
self._normalize_query(query)
kwargs = {
'params': query,
... | [
"def",
"_http_get",
"(",
"self",
",",
"url",
",",
"query",
")",
":",
"if",
"not",
"self",
".",
"authorization_as_header",
":",
"query",
".",
"update",
"(",
"{",
"'access_token'",
":",
"self",
".",
"access_token",
"}",
")",
"response",
"=",
"None",
"self"... | Performs the HTTP GET Request. | [
"Performs",
"the",
"HTTP",
"GET",
"Request",
"."
] | 73fe01d6ae5a1f8818880da65199107b584681dd | https://github.com/contentful/contentful.py/blob/73fe01d6ae5a1f8818880da65199107b584681dd/contentful/client.py#L518-L546 | train |
contentful/contentful.py | contentful/client.py | Client._get | def _get(self, url, query=None):
"""
Wrapper for the HTTP Request,
Rate Limit Backoff is handled here,
Responses are Processed with ResourceBuilder.
"""
if query is None:
query = {}
response = retry_request(self)(self._http_get)(url, query=query)
... | python | def _get(self, url, query=None):
"""
Wrapper for the HTTP Request,
Rate Limit Backoff is handled here,
Responses are Processed with ResourceBuilder.
"""
if query is None:
query = {}
response = retry_request(self)(self._http_get)(url, query=query)
... | [
"def",
"_get",
"(",
"self",
",",
"url",
",",
"query",
"=",
"None",
")",
":",
"if",
"query",
"is",
"None",
":",
"query",
"=",
"{",
"}",
"response",
"=",
"retry_request",
"(",
"self",
")",
"(",
"self",
".",
"_http_get",
")",
"(",
"url",
",",
"query... | Wrapper for the HTTP Request,
Rate Limit Backoff is handled here,
Responses are Processed with ResourceBuilder. | [
"Wrapper",
"for",
"the",
"HTTP",
"Request",
"Rate",
"Limit",
"Backoff",
"is",
"handled",
"here",
"Responses",
"are",
"Processed",
"with",
"ResourceBuilder",
"."
] | 73fe01d6ae5a1f8818880da65199107b584681dd | https://github.com/contentful/contentful.py/blob/73fe01d6ae5a1f8818880da65199107b584681dd/contentful/client.py#L548-L576 | train |
contentful/contentful.py | contentful/client.py | Client._proxy_parameters | def _proxy_parameters(self):
"""
Builds Proxy parameters Dict from
client options.
"""
proxy_protocol = ''
if self.proxy_host.startswith('https'):
proxy_protocol = 'https'
else:
proxy_protocol = 'http'
proxy = '{0}://'.format(prox... | python | def _proxy_parameters(self):
"""
Builds Proxy parameters Dict from
client options.
"""
proxy_protocol = ''
if self.proxy_host.startswith('https'):
proxy_protocol = 'https'
else:
proxy_protocol = 'http'
proxy = '{0}://'.format(prox... | [
"def",
"_proxy_parameters",
"(",
"self",
")",
":",
"proxy_protocol",
"=",
"''",
"if",
"self",
".",
"proxy_host",
".",
"startswith",
"(",
"'https'",
")",
":",
"proxy_protocol",
"=",
"'https'",
"else",
":",
"proxy_protocol",
"=",
"'http'",
"proxy",
"=",
"'{0}:... | Builds Proxy parameters Dict from
client options. | [
"Builds",
"Proxy",
"parameters",
"Dict",
"from",
"client",
"options",
"."
] | 73fe01d6ae5a1f8818880da65199107b584681dd | https://github.com/contentful/contentful.py/blob/73fe01d6ae5a1f8818880da65199107b584681dd/contentful/client.py#L585-L609 | train |
contentful/contentful.py | contentful/asset.py | Asset.url | def url(self, **kwargs):
"""Returns a formatted URL for the Asset's File
with serialized parameters.
Usage:
>>> my_asset.url()
"//images.contentful.com/spaces/foobar/..."
>>> my_asset.url(w=120, h=160)
"//images.contentful.com/spaces/foobar/...?w=... | python | def url(self, **kwargs):
"""Returns a formatted URL for the Asset's File
with serialized parameters.
Usage:
>>> my_asset.url()
"//images.contentful.com/spaces/foobar/..."
>>> my_asset.url(w=120, h=160)
"//images.contentful.com/spaces/foobar/...?w=... | [
"def",
"url",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"url",
"=",
"self",
".",
"file",
"[",
"'url'",
"]",
"args",
"=",
"[",
"'{0}={1}'",
".",
"format",
"(",
"k",
",",
"v",
")",
"for",
"k",
",",
"v",
"in",
"kwargs",
".",
"items",
"(",
")",... | Returns a formatted URL for the Asset's File
with serialized parameters.
Usage:
>>> my_asset.url()
"//images.contentful.com/spaces/foobar/..."
>>> my_asset.url(w=120, h=160)
"//images.contentful.com/spaces/foobar/...?w=120&h=160" | [
"Returns",
"a",
"formatted",
"URL",
"for",
"the",
"Asset",
"s",
"File",
"with",
"serialized",
"parameters",
"."
] | 73fe01d6ae5a1f8818880da65199107b584681dd | https://github.com/contentful/contentful.py/blob/73fe01d6ae5a1f8818880da65199107b584681dd/contentful/asset.py#L22-L39 | train |
contentful/contentful.py | contentful/resource.py | FieldsResource.fields | def fields(self, locale=None):
"""Get fields for a specific locale
:param locale: (optional) Locale to fetch, defaults to default_locale.
"""
if locale is None:
locale = self._locale()
return self._fields.get(locale, {}) | python | def fields(self, locale=None):
"""Get fields for a specific locale
:param locale: (optional) Locale to fetch, defaults to default_locale.
"""
if locale is None:
locale = self._locale()
return self._fields.get(locale, {}) | [
"def",
"fields",
"(",
"self",
",",
"locale",
"=",
"None",
")",
":",
"if",
"locale",
"is",
"None",
":",
"locale",
"=",
"self",
".",
"_locale",
"(",
")",
"return",
"self",
".",
"_fields",
".",
"get",
"(",
"locale",
",",
"{",
"}",
")"
] | Get fields for a specific locale
:param locale: (optional) Locale to fetch, defaults to default_locale. | [
"Get",
"fields",
"for",
"a",
"specific",
"locale"
] | 73fe01d6ae5a1f8818880da65199107b584681dd | https://github.com/contentful/contentful.py/blob/73fe01d6ae5a1f8818880da65199107b584681dd/contentful/resource.py#L152-L160 | train |
contentful/contentful.py | contentful/resource.py | Link.resolve | def resolve(self, client):
"""Resolves Link to a specific Resource"""
resolve_method = getattr(client, snake_case(self.link_type))
if self.link_type == 'Space':
return resolve_method()
else:
return resolve_method(self.id) | python | def resolve(self, client):
"""Resolves Link to a specific Resource"""
resolve_method = getattr(client, snake_case(self.link_type))
if self.link_type == 'Space':
return resolve_method()
else:
return resolve_method(self.id) | [
"def",
"resolve",
"(",
"self",
",",
"client",
")",
":",
"resolve_method",
"=",
"getattr",
"(",
"client",
",",
"snake_case",
"(",
"self",
".",
"link_type",
")",
")",
"if",
"self",
".",
"link_type",
"==",
"'Space'",
":",
"return",
"resolve_method",
"(",
")... | Resolves Link to a specific Resource | [
"Resolves",
"Link",
"to",
"a",
"specific",
"Resource"
] | 73fe01d6ae5a1f8818880da65199107b584681dd | https://github.com/contentful/contentful.py/blob/73fe01d6ae5a1f8818880da65199107b584681dd/contentful/resource.py#L182-L189 | train |
contentful/contentful.py | contentful/utils.py | snake_case | def snake_case(a_string):
"""Returns a snake cased version of a string.
:param a_string: any :class:`str` object.
Usage:
>>> snake_case('FooBar')
"foo_bar"
"""
partial = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', a_string)
return re.sub('([a-z0-9])([A-Z])', r'\1_\2', partial).lower(... | python | def snake_case(a_string):
"""Returns a snake cased version of a string.
:param a_string: any :class:`str` object.
Usage:
>>> snake_case('FooBar')
"foo_bar"
"""
partial = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', a_string)
return re.sub('([a-z0-9])([A-Z])', r'\1_\2', partial).lower(... | [
"def",
"snake_case",
"(",
"a_string",
")",
":",
"partial",
"=",
"re",
".",
"sub",
"(",
"'(.)([A-Z][a-z]+)'",
",",
"r'\\1_\\2'",
",",
"a_string",
")",
"return",
"re",
".",
"sub",
"(",
"'([a-z0-9])([A-Z])'",
",",
"r'\\1_\\2'",
",",
"partial",
")",
".",
"lowe... | Returns a snake cased version of a string.
:param a_string: any :class:`str` object.
Usage:
>>> snake_case('FooBar')
"foo_bar" | [
"Returns",
"a",
"snake",
"cased",
"version",
"of",
"a",
"string",
"."
] | 73fe01d6ae5a1f8818880da65199107b584681dd | https://github.com/contentful/contentful.py/blob/73fe01d6ae5a1f8818880da65199107b584681dd/contentful/utils.py#L56-L67 | train |
contentful/contentful.py | contentful/utils.py | is_link_array | def is_link_array(value):
"""Checks if value is an array of links.
:param value: any object.
:return: Boolean
:rtype: bool
Usage:
>>> is_link_array('foo')
False
>>> is_link_array([1, 2, 3])
False
>>> is_link([{'sys': {'type': 'Link', 'id': 'foobar'}}])
... | python | def is_link_array(value):
"""Checks if value is an array of links.
:param value: any object.
:return: Boolean
:rtype: bool
Usage:
>>> is_link_array('foo')
False
>>> is_link_array([1, 2, 3])
False
>>> is_link([{'sys': {'type': 'Link', 'id': 'foobar'}}])
... | [
"def",
"is_link_array",
"(",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"list",
")",
"and",
"len",
"(",
"value",
")",
">",
"0",
":",
"return",
"is_link",
"(",
"value",
"[",
"0",
"]",
")",
"return",
"False"
] | Checks if value is an array of links.
:param value: any object.
:return: Boolean
:rtype: bool
Usage:
>>> is_link_array('foo')
False
>>> is_link_array([1, 2, 3])
False
>>> is_link([{'sys': {'type': 'Link', 'id': 'foobar'}}])
True | [
"Checks",
"if",
"value",
"is",
"an",
"array",
"of",
"links",
"."
] | 73fe01d6ae5a1f8818880da65199107b584681dd | https://github.com/contentful/contentful.py/blob/73fe01d6ae5a1f8818880da65199107b584681dd/contentful/utils.py#L90-L108 | train |
contentful/contentful.py | contentful/utils.py | resource_for_link | def resource_for_link(link, includes, resources=None, locale=None):
"""Returns the resource that matches the link"""
if resources is not None:
cache_key = "{0}:{1}:{2}".format(
link['sys']['linkType'],
link['sys']['id'],
locale
)
if cache_key in resou... | python | def resource_for_link(link, includes, resources=None, locale=None):
"""Returns the resource that matches the link"""
if resources is not None:
cache_key = "{0}:{1}:{2}".format(
link['sys']['linkType'],
link['sys']['id'],
locale
)
if cache_key in resou... | [
"def",
"resource_for_link",
"(",
"link",
",",
"includes",
",",
"resources",
"=",
"None",
",",
"locale",
"=",
"None",
")",
":",
"if",
"resources",
"is",
"not",
"None",
":",
"cache_key",
"=",
"\"{0}:{1}:{2}\"",
".",
"format",
"(",
"link",
"[",
"'sys'",
"]"... | Returns the resource that matches the link | [
"Returns",
"the",
"resource",
"that",
"matches",
"the",
"link"
] | 73fe01d6ae5a1f8818880da65199107b584681dd | https://github.com/contentful/contentful.py/blob/73fe01d6ae5a1f8818880da65199107b584681dd/contentful/utils.py#L121-L137 | train |
phalt/swapi-python | swapi/utils.py | all_resource_urls | def all_resource_urls(query):
''' Get all the URLs for every resource '''
urls = []
next = True
while next:
response = requests.get(query)
json_data = json.loads(response.content)
for resource in json_data['results']:
urls.append(resource['url'])
if bool(json_... | python | def all_resource_urls(query):
''' Get all the URLs for every resource '''
urls = []
next = True
while next:
response = requests.get(query)
json_data = json.loads(response.content)
for resource in json_data['results']:
urls.append(resource['url'])
if bool(json_... | [
"def",
"all_resource_urls",
"(",
"query",
")",
":",
"urls",
"=",
"[",
"]",
"next",
"=",
"True",
"while",
"next",
":",
"response",
"=",
"requests",
".",
"get",
"(",
"query",
")",
"json_data",
"=",
"json",
".",
"loads",
"(",
"response",
".",
"content",
... | Get all the URLs for every resource | [
"Get",
"all",
"the",
"URLs",
"for",
"every",
"resource"
] | cb9195fc498a1d1fc3b1998d485edc94b8408ca7 | https://github.com/phalt/swapi-python/blob/cb9195fc498a1d1fc3b1998d485edc94b8408ca7/swapi/utils.py#L17-L30 | train |
phalt/swapi-python | swapi/swapi.py | get_all | def get_all(resource):
''' Return all of a single resource '''
QUERYSETS = {
settings.PEOPLE: PeopleQuerySet,
settings.PLANETS: PlanetQuerySet,
settings.STARSHIPS: StarshipQuerySet,
settings.VEHICLES: VehicleQuerySet,
settings.SPECIES: SpeciesQuerySet,
settings.FI... | python | def get_all(resource):
''' Return all of a single resource '''
QUERYSETS = {
settings.PEOPLE: PeopleQuerySet,
settings.PLANETS: PlanetQuerySet,
settings.STARSHIPS: StarshipQuerySet,
settings.VEHICLES: VehicleQuerySet,
settings.SPECIES: SpeciesQuerySet,
settings.FI... | [
"def",
"get_all",
"(",
"resource",
")",
":",
"QUERYSETS",
"=",
"{",
"settings",
".",
"PEOPLE",
":",
"PeopleQuerySet",
",",
"settings",
".",
"PLANETS",
":",
"PlanetQuerySet",
",",
"settings",
".",
"STARSHIPS",
":",
"StarshipQuerySet",
",",
"settings",
".",
"V... | Return all of a single resource | [
"Return",
"all",
"of",
"a",
"single",
"resource"
] | cb9195fc498a1d1fc3b1998d485edc94b8408ca7 | https://github.com/phalt/swapi-python/blob/cb9195fc498a1d1fc3b1998d485edc94b8408ca7/swapi/swapi.py#L46-L61 | train |
phalt/swapi-python | swapi/swapi.py | get_planet | def get_planet(planet_id):
''' Return a single planet '''
result = _get(planet_id, settings.PLANETS)
return Planet(result.content) | python | def get_planet(planet_id):
''' Return a single planet '''
result = _get(planet_id, settings.PLANETS)
return Planet(result.content) | [
"def",
"get_planet",
"(",
"planet_id",
")",
":",
"result",
"=",
"_get",
"(",
"planet_id",
",",
"settings",
".",
"PLANETS",
")",
"return",
"Planet",
"(",
"result",
".",
"content",
")"
] | Return a single planet | [
"Return",
"a",
"single",
"planet"
] | cb9195fc498a1d1fc3b1998d485edc94b8408ca7 | https://github.com/phalt/swapi-python/blob/cb9195fc498a1d1fc3b1998d485edc94b8408ca7/swapi/swapi.py#L64-L67 | train |
phalt/swapi-python | swapi/swapi.py | get_starship | def get_starship(starship_id):
''' Return a single starship '''
result = _get(starship_id, settings.STARSHIPS)
return Starship(result.content) | python | def get_starship(starship_id):
''' Return a single starship '''
result = _get(starship_id, settings.STARSHIPS)
return Starship(result.content) | [
"def",
"get_starship",
"(",
"starship_id",
")",
":",
"result",
"=",
"_get",
"(",
"starship_id",
",",
"settings",
".",
"STARSHIPS",
")",
"return",
"Starship",
"(",
"result",
".",
"content",
")"
] | Return a single starship | [
"Return",
"a",
"single",
"starship"
] | cb9195fc498a1d1fc3b1998d485edc94b8408ca7 | https://github.com/phalt/swapi-python/blob/cb9195fc498a1d1fc3b1998d485edc94b8408ca7/swapi/swapi.py#L76-L79 | train |
phalt/swapi-python | swapi/swapi.py | get_vehicle | def get_vehicle(vehicle_id):
''' Return a single vehicle '''
result = _get(vehicle_id, settings.VEHICLES)
return Vehicle(result.content) | python | def get_vehicle(vehicle_id):
''' Return a single vehicle '''
result = _get(vehicle_id, settings.VEHICLES)
return Vehicle(result.content) | [
"def",
"get_vehicle",
"(",
"vehicle_id",
")",
":",
"result",
"=",
"_get",
"(",
"vehicle_id",
",",
"settings",
".",
"VEHICLES",
")",
"return",
"Vehicle",
"(",
"result",
".",
"content",
")"
] | Return a single vehicle | [
"Return",
"a",
"single",
"vehicle"
] | cb9195fc498a1d1fc3b1998d485edc94b8408ca7 | https://github.com/phalt/swapi-python/blob/cb9195fc498a1d1fc3b1998d485edc94b8408ca7/swapi/swapi.py#L82-L85 | train |
phalt/swapi-python | swapi/swapi.py | get_species | def get_species(species_id):
''' Return a single species '''
result = _get(species_id, settings.SPECIES)
return Species(result.content) | python | def get_species(species_id):
''' Return a single species '''
result = _get(species_id, settings.SPECIES)
return Species(result.content) | [
"def",
"get_species",
"(",
"species_id",
")",
":",
"result",
"=",
"_get",
"(",
"species_id",
",",
"settings",
".",
"SPECIES",
")",
"return",
"Species",
"(",
"result",
".",
"content",
")"
] | Return a single species | [
"Return",
"a",
"single",
"species"
] | cb9195fc498a1d1fc3b1998d485edc94b8408ca7 | https://github.com/phalt/swapi-python/blob/cb9195fc498a1d1fc3b1998d485edc94b8408ca7/swapi/swapi.py#L88-L91 | train |
phalt/swapi-python | swapi/swapi.py | get_film | def get_film(film_id):
''' Return a single film '''
result = _get(film_id, settings.FILMS)
return Film(result.content) | python | def get_film(film_id):
''' Return a single film '''
result = _get(film_id, settings.FILMS)
return Film(result.content) | [
"def",
"get_film",
"(",
"film_id",
")",
":",
"result",
"=",
"_get",
"(",
"film_id",
",",
"settings",
".",
"FILMS",
")",
"return",
"Film",
"(",
"result",
".",
"content",
")"
] | Return a single film | [
"Return",
"a",
"single",
"film"
] | cb9195fc498a1d1fc3b1998d485edc94b8408ca7 | https://github.com/phalt/swapi-python/blob/cb9195fc498a1d1fc3b1998d485edc94b8408ca7/swapi/swapi.py#L94-L97 | train |
phalt/swapi-python | swapi/models.py | BaseQuerySet.order_by | def order_by(self, order_attribute):
''' Return the list of items in a certain order '''
to_return = []
for f in sorted(self.items, key=lambda i: getattr(i, order_attribute)):
to_return.append(f)
return to_return | python | def order_by(self, order_attribute):
''' Return the list of items in a certain order '''
to_return = []
for f in sorted(self.items, key=lambda i: getattr(i, order_attribute)):
to_return.append(f)
return to_return | [
"def",
"order_by",
"(",
"self",
",",
"order_attribute",
")",
":",
"to_return",
"=",
"[",
"]",
"for",
"f",
"in",
"sorted",
"(",
"self",
".",
"items",
",",
"key",
"=",
"lambda",
"i",
":",
"getattr",
"(",
"i",
",",
"order_attribute",
")",
")",
":",
"t... | Return the list of items in a certain order | [
"Return",
"the",
"list",
"of",
"items",
"in",
"a",
"certain",
"order"
] | cb9195fc498a1d1fc3b1998d485edc94b8408ca7 | https://github.com/phalt/swapi-python/blob/cb9195fc498a1d1fc3b1998d485edc94b8408ca7/swapi/models.py#L24-L29 | train |
phalt/swapi-python | swapi/models.py | Film.print_crawl | def print_crawl(self):
''' Print the opening crawl one line at a time '''
print("Star Wars")
time.sleep(.5)
print("Episode {0}".format(self.episode_id))
time.sleep(.5)
print("")
time.sleep(.5)
print("{0}".format(self.title))
for line in self.gen_op... | python | def print_crawl(self):
''' Print the opening crawl one line at a time '''
print("Star Wars")
time.sleep(.5)
print("Episode {0}".format(self.episode_id))
time.sleep(.5)
print("")
time.sleep(.5)
print("{0}".format(self.title))
for line in self.gen_op... | [
"def",
"print_crawl",
"(",
"self",
")",
":",
"print",
"(",
"\"Star Wars\"",
")",
"time",
".",
"sleep",
"(",
".5",
")",
"print",
"(",
"\"Episode {0}\"",
".",
"format",
"(",
"self",
".",
"episode_id",
")",
")",
"time",
".",
"sleep",
"(",
".5",
")",
"pr... | Print the opening crawl one line at a time | [
"Print",
"the",
"opening",
"crawl",
"one",
"line",
"at",
"a",
"time"
] | cb9195fc498a1d1fc3b1998d485edc94b8408ca7 | https://github.com/phalt/swapi-python/blob/cb9195fc498a1d1fc3b1998d485edc94b8408ca7/swapi/models.py#L135-L146 | train |
gccxml/pygccxml | pygccxml/utils/utils.py | is_str | def is_str(string):
"""
Python 2 and 3 compatible string checker.
Args:
string (str | basestring): the string to check
Returns:
bool: True or False
"""
if sys.version_info[:2] >= (3, 0):
return isinstance(string, str)
return isinstance(string, basestring) | python | def is_str(string):
"""
Python 2 and 3 compatible string checker.
Args:
string (str | basestring): the string to check
Returns:
bool: True or False
"""
if sys.version_info[:2] >= (3, 0):
return isinstance(string, str)
return isinstance(string, basestring) | [
"def",
"is_str",
"(",
"string",
")",
":",
"if",
"sys",
".",
"version_info",
"[",
":",
"2",
"]",
">=",
"(",
"3",
",",
"0",
")",
":",
"return",
"isinstance",
"(",
"string",
",",
"str",
")",
"return",
"isinstance",
"(",
"string",
",",
"basestring",
")... | Python 2 and 3 compatible string checker.
Args:
string (str | basestring): the string to check
Returns:
bool: True or False | [
"Python",
"2",
"and",
"3",
"compatible",
"string",
"checker",
"."
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/utils/utils.py#L18-L32 | train |
gccxml/pygccxml | pygccxml/utils/utils.py | _create_logger_ | def _create_logger_(name):
"""Implementation detail, creates a logger."""
logger = logging.getLogger(name)
handler = logging.StreamHandler()
handler.setFormatter(logging.Formatter('%(levelname)s %(message)s'))
logger.addHandler(handler)
logger.setLevel(logging.INFO)
return logger | python | def _create_logger_(name):
"""Implementation detail, creates a logger."""
logger = logging.getLogger(name)
handler = logging.StreamHandler()
handler.setFormatter(logging.Formatter('%(levelname)s %(message)s'))
logger.addHandler(handler)
logger.setLevel(logging.INFO)
return logger | [
"def",
"_create_logger_",
"(",
"name",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"name",
")",
"handler",
"=",
"logging",
".",
"StreamHandler",
"(",
")",
"handler",
".",
"setFormatter",
"(",
"logging",
".",
"Formatter",
"(",
"'%(levelname)s %... | Implementation detail, creates a logger. | [
"Implementation",
"detail",
"creates",
"a",
"logger",
"."
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/utils/utils.py#L79-L86 | train |
gccxml/pygccxml | pygccxml/utils/utils.py | remove_file_no_raise | def remove_file_no_raise(file_name, config):
"""Removes file from disk if exception is raised."""
# The removal can be disabled by the config for debugging purposes.
if config.keep_xml:
return True
try:
if os.path.exists(file_name):
os.remove(file_name)
except IOError as... | python | def remove_file_no_raise(file_name, config):
"""Removes file from disk if exception is raised."""
# The removal can be disabled by the config for debugging purposes.
if config.keep_xml:
return True
try:
if os.path.exists(file_name):
os.remove(file_name)
except IOError as... | [
"def",
"remove_file_no_raise",
"(",
"file_name",
",",
"config",
")",
":",
"if",
"config",
".",
"keep_xml",
":",
"return",
"True",
"try",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"file_name",
")",
":",
"os",
".",
"remove",
"(",
"file_name",
")"... | Removes file from disk if exception is raised. | [
"Removes",
"file",
"from",
"disk",
"if",
"exception",
"is",
"raised",
"."
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/utils/utils.py#L150-L162 | train |
gccxml/pygccxml | pygccxml/utils/utils.py | create_temp_file_name | def create_temp_file_name(suffix, prefix=None, dir=None, directory=None):
"""
Small convenience function that creates temporary files.
This function is a wrapper around the Python built-in
function tempfile.mkstemp.
"""
if dir is not None:
warnings.warn(
"The dir argument i... | python | def create_temp_file_name(suffix, prefix=None, dir=None, directory=None):
"""
Small convenience function that creates temporary files.
This function is a wrapper around the Python built-in
function tempfile.mkstemp.
"""
if dir is not None:
warnings.warn(
"The dir argument i... | [
"def",
"create_temp_file_name",
"(",
"suffix",
",",
"prefix",
"=",
"None",
",",
"dir",
"=",
"None",
",",
"directory",
"=",
"None",
")",
":",
"if",
"dir",
"is",
"not",
"None",
":",
"warnings",
".",
"warn",
"(",
"\"The dir argument is deprecated.\\n\"",
"+",
... | Small convenience function that creates temporary files.
This function is a wrapper around the Python built-in
function tempfile.mkstemp. | [
"Small",
"convenience",
"function",
"that",
"creates",
"temporary",
"files",
"."
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/utils/utils.py#L166-L186 | train |
gccxml/pygccxml | pygccxml/utils/utils.py | contains_parent_dir | def contains_parent_dir(fpath, dirs):
"""
Returns true if paths in dirs start with fpath.
Precondition: dirs and fpath should be normalized before calling
this function.
"""
# Note: this function is used nowhere in pygccxml but is used
# at least by pypluplus; so it should stay here.
... | python | def contains_parent_dir(fpath, dirs):
"""
Returns true if paths in dirs start with fpath.
Precondition: dirs and fpath should be normalized before calling
this function.
"""
# Note: this function is used nowhere in pygccxml but is used
# at least by pypluplus; so it should stay here.
... | [
"def",
"contains_parent_dir",
"(",
"fpath",
",",
"dirs",
")",
":",
"return",
"bool",
"(",
"[",
"x",
"for",
"x",
"in",
"dirs",
"if",
"_f",
"(",
"fpath",
",",
"x",
")",
"]",
")"
] | Returns true if paths in dirs start with fpath.
Precondition: dirs and fpath should be normalized before calling
this function. | [
"Returns",
"true",
"if",
"paths",
"in",
"dirs",
"start",
"with",
"fpath",
"."
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/utils/utils.py#L194-L205 | train |
gccxml/pygccxml | pygccxml/declarations/cpptypes.py | free_function_type_t.create_decl_string | def create_decl_string(
return_type, arguments_types, with_defaults=True):
"""
Returns free function type
:param return_type: function return type
:type return_type: :class:`type_t`
:param arguments_types: list of argument :class:`type <type_t>`
:rtype: :clas... | python | def create_decl_string(
return_type, arguments_types, with_defaults=True):
"""
Returns free function type
:param return_type: function return type
:type return_type: :class:`type_t`
:param arguments_types: list of argument :class:`type <type_t>`
:rtype: :clas... | [
"def",
"create_decl_string",
"(",
"return_type",
",",
"arguments_types",
",",
"with_defaults",
"=",
"True",
")",
":",
"return",
"free_function_type_t",
".",
"NAME_TEMPLATE",
"%",
"{",
"'return_type'",
":",
"return_type",
".",
"build_decl_string",
"(",
"with_defaults",... | Returns free function type
:param return_type: function return type
:type return_type: :class:`type_t`
:param arguments_types: list of argument :class:`type <type_t>`
:rtype: :class:`free_function_type_t` | [
"Returns",
"free",
"function",
"type"
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/cpptypes.py#L696-L711 | train |
gccxml/pygccxml | pygccxml/declarations/cpptypes.py | free_function_type_t.create_typedef | def create_typedef(self, typedef_name, unused=None, with_defaults=True):
"""returns string, that contains valid C++ code, that defines typedef
to function type
:param name: the desired name of typedef
"""
return free_function_type_t.TYPEDEF_NAME_TEMPLATE % {
'typede... | python | def create_typedef(self, typedef_name, unused=None, with_defaults=True):
"""returns string, that contains valid C++ code, that defines typedef
to function type
:param name: the desired name of typedef
"""
return free_function_type_t.TYPEDEF_NAME_TEMPLATE % {
'typede... | [
"def",
"create_typedef",
"(",
"self",
",",
"typedef_name",
",",
"unused",
"=",
"None",
",",
"with_defaults",
"=",
"True",
")",
":",
"return",
"free_function_type_t",
".",
"TYPEDEF_NAME_TEMPLATE",
"%",
"{",
"'typedef_name'",
":",
"typedef_name",
",",
"'return_type'... | returns string, that contains valid C++ code, that defines typedef
to function type
:param name: the desired name of typedef | [
"returns",
"string",
"that",
"contains",
"valid",
"C",
"++",
"code",
"that",
"defines",
"typedef",
"to",
"function",
"type"
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/cpptypes.py#L728-L739 | train |
gccxml/pygccxml | pygccxml/declarations/cpptypes.py | member_function_type_t.create_typedef | def create_typedef(
self,
typedef_name,
class_alias=None,
with_defaults=True):
"""creates typedef to the function type
:param typedef_name: desired type name
:rtype: string
"""
has_const_str = ''
if self.has_const:
... | python | def create_typedef(
self,
typedef_name,
class_alias=None,
with_defaults=True):
"""creates typedef to the function type
:param typedef_name: desired type name
:rtype: string
"""
has_const_str = ''
if self.has_const:
... | [
"def",
"create_typedef",
"(",
"self",
",",
"typedef_name",
",",
"class_alias",
"=",
"None",
",",
"with_defaults",
"=",
"True",
")",
":",
"has_const_str",
"=",
"''",
"if",
"self",
".",
"has_const",
":",
"has_const_str",
"=",
"'const'",
"if",
"None",
"is",
"... | creates typedef to the function type
:param typedef_name: desired type name
:rtype: string | [
"creates",
"typedef",
"to",
"the",
"function",
"type"
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/cpptypes.py#L781-L806 | train |
gccxml/pygccxml | pygccxml/parser/__init__.py | parse | def parse(
files,
config=None,
compilation_mode=COMPILATION_MODE.FILE_BY_FILE,
cache=None):
"""
Parse header files.
:param files: The header files that should be parsed
:type files: list of str
:param config: Configuration object or None
:type config: :class:`par... | python | def parse(
files,
config=None,
compilation_mode=COMPILATION_MODE.FILE_BY_FILE,
cache=None):
"""
Parse header files.
:param files: The header files that should be parsed
:type files: list of str
:param config: Configuration object or None
:type config: :class:`par... | [
"def",
"parse",
"(",
"files",
",",
"config",
"=",
"None",
",",
"compilation_mode",
"=",
"COMPILATION_MODE",
".",
"FILE_BY_FILE",
",",
"cache",
"=",
"None",
")",
":",
"if",
"not",
"config",
":",
"config",
"=",
"xml_generator_configuration_t",
"(",
")",
"parse... | Parse header files.
:param files: The header files that should be parsed
:type files: list of str
:param config: Configuration object or None
:type config: :class:`parser.xml_generator_configuration_t`
:param compilation_mode: Determines whether the files are parsed
ind... | [
"Parse",
"header",
"files",
"."
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/parser/__init__.py#L29-L53 | train |
gccxml/pygccxml | pygccxml/declarations/type_traits.py | remove_alias | def remove_alias(type_):
"""
Returns `type_t` without typedef
Args:
type_ (type_t | declaration_t): type or declaration
Returns:
type_t: the type associated to the inputted declaration
"""
if isinstance(type_, cpptypes.type_t):
type_ref = type_
elif isinstance(type_... | python | def remove_alias(type_):
"""
Returns `type_t` without typedef
Args:
type_ (type_t | declaration_t): type or declaration
Returns:
type_t: the type associated to the inputted declaration
"""
if isinstance(type_, cpptypes.type_t):
type_ref = type_
elif isinstance(type_... | [
"def",
"remove_alias",
"(",
"type_",
")",
":",
"if",
"isinstance",
"(",
"type_",
",",
"cpptypes",
".",
"type_t",
")",
":",
"type_ref",
"=",
"type_",
"elif",
"isinstance",
"(",
"type_",
",",
"typedef",
".",
"typedef_t",
")",
":",
"type_ref",
"=",
"type_",... | Returns `type_t` without typedef
Args:
type_ (type_t | declaration_t): type or declaration
Returns:
type_t: the type associated to the inputted declaration | [
"Returns",
"type_t",
"without",
"typedef"
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/type_traits.py#L45-L66 | train |
gccxml/pygccxml | pygccxml/declarations/type_traits.py | is_pointer | def is_pointer(type_):
"""returns True, if type represents C++ pointer type, False otherwise"""
return does_match_definition(type_,
cpptypes.pointer_t,
(cpptypes.const_t, cpptypes.volatile_t)) \
or does_match_definition(type_,
... | python | def is_pointer(type_):
"""returns True, if type represents C++ pointer type, False otherwise"""
return does_match_definition(type_,
cpptypes.pointer_t,
(cpptypes.const_t, cpptypes.volatile_t)) \
or does_match_definition(type_,
... | [
"def",
"is_pointer",
"(",
"type_",
")",
":",
"return",
"does_match_definition",
"(",
"type_",
",",
"cpptypes",
".",
"pointer_t",
",",
"(",
"cpptypes",
".",
"const_t",
",",
"cpptypes",
".",
"volatile_t",
")",
")",
"or",
"does_match_definition",
"(",
"type_",
... | returns True, if type represents C++ pointer type, False otherwise | [
"returns",
"True",
"if",
"type",
"represents",
"C",
"++",
"pointer",
"type",
"False",
"otherwise"
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/type_traits.py#L229-L236 | train |
gccxml/pygccxml | pygccxml/declarations/type_traits.py | remove_pointer | def remove_pointer(type_):
"""removes pointer from the type definition
If type is not pointer type, it will be returned as is.
"""
nake_type = remove_alias(type_)
if not is_pointer(nake_type):
return type_
elif isinstance(nake_type, cpptypes.volatile_t) and \
isinstance(nake... | python | def remove_pointer(type_):
"""removes pointer from the type definition
If type is not pointer type, it will be returned as is.
"""
nake_type = remove_alias(type_)
if not is_pointer(nake_type):
return type_
elif isinstance(nake_type, cpptypes.volatile_t) and \
isinstance(nake... | [
"def",
"remove_pointer",
"(",
"type_",
")",
":",
"nake_type",
"=",
"remove_alias",
"(",
"type_",
")",
"if",
"not",
"is_pointer",
"(",
"nake_type",
")",
":",
"return",
"type_",
"elif",
"isinstance",
"(",
"nake_type",
",",
"cpptypes",
".",
"volatile_t",
")",
... | removes pointer from the type definition
If type is not pointer type, it will be returned as is. | [
"removes",
"pointer",
"from",
"the",
"type",
"definition"
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/type_traits.py#L250-L271 | train |
gccxml/pygccxml | pygccxml/declarations/type_traits.py | is_array | def is_array(type_):
"""returns True, if type represents C++ array type, False otherwise"""
nake_type = remove_alias(type_)
nake_type = remove_reference(nake_type)
nake_type = remove_cv(nake_type)
return isinstance(nake_type, cpptypes.array_t) | python | def is_array(type_):
"""returns True, if type represents C++ array type, False otherwise"""
nake_type = remove_alias(type_)
nake_type = remove_reference(nake_type)
nake_type = remove_cv(nake_type)
return isinstance(nake_type, cpptypes.array_t) | [
"def",
"is_array",
"(",
"type_",
")",
":",
"nake_type",
"=",
"remove_alias",
"(",
"type_",
")",
"nake_type",
"=",
"remove_reference",
"(",
"nake_type",
")",
"nake_type",
"=",
"remove_cv",
"(",
"nake_type",
")",
"return",
"isinstance",
"(",
"nake_type",
",",
... | returns True, if type represents C++ array type, False otherwise | [
"returns",
"True",
"if",
"type",
"represents",
"C",
"++",
"array",
"type",
"False",
"otherwise"
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/type_traits.py#L280-L285 | train |
gccxml/pygccxml | pygccxml/declarations/type_traits.py | array_size | def array_size(type_):
"""returns array size"""
nake_type = remove_alias(type_)
nake_type = remove_reference(nake_type)
nake_type = remove_cv(nake_type)
assert isinstance(nake_type, cpptypes.array_t)
return nake_type.size | python | def array_size(type_):
"""returns array size"""
nake_type = remove_alias(type_)
nake_type = remove_reference(nake_type)
nake_type = remove_cv(nake_type)
assert isinstance(nake_type, cpptypes.array_t)
return nake_type.size | [
"def",
"array_size",
"(",
"type_",
")",
":",
"nake_type",
"=",
"remove_alias",
"(",
"type_",
")",
"nake_type",
"=",
"remove_reference",
"(",
"nake_type",
")",
"nake_type",
"=",
"remove_cv",
"(",
"nake_type",
")",
"assert",
"isinstance",
"(",
"nake_type",
",",
... | returns array size | [
"returns",
"array",
"size"
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/type_traits.py#L288-L294 | train |
gccxml/pygccxml | pygccxml/declarations/type_traits.py | array_item_type | def array_item_type(type_):
"""returns array item type"""
if is_array(type_):
type_ = remove_alias(type_)
type_ = remove_cv(type_)
return type_.base
elif is_pointer(type_):
return remove_pointer(type_)
else:
raise RuntimeError(
"array_item_type functio... | python | def array_item_type(type_):
"""returns array item type"""
if is_array(type_):
type_ = remove_alias(type_)
type_ = remove_cv(type_)
return type_.base
elif is_pointer(type_):
return remove_pointer(type_)
else:
raise RuntimeError(
"array_item_type functio... | [
"def",
"array_item_type",
"(",
"type_",
")",
":",
"if",
"is_array",
"(",
"type_",
")",
":",
"type_",
"=",
"remove_alias",
"(",
"type_",
")",
"type_",
"=",
"remove_cv",
"(",
"type_",
")",
"return",
"type_",
".",
"base",
"elif",
"is_pointer",
"(",
"type_",... | returns array item type | [
"returns",
"array",
"item",
"type"
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/type_traits.py#L297-L308 | train |
gccxml/pygccxml | pygccxml/declarations/type_traits.py | remove_reference | def remove_reference(type_):
"""removes reference from the type definition
If type is not reference type, it will be returned as is.
"""
nake_type = remove_alias(type_)
if not is_reference(nake_type):
return type_
return nake_type.base | python | def remove_reference(type_):
"""removes reference from the type definition
If type is not reference type, it will be returned as is.
"""
nake_type = remove_alias(type_)
if not is_reference(nake_type):
return type_
return nake_type.base | [
"def",
"remove_reference",
"(",
"type_",
")",
":",
"nake_type",
"=",
"remove_alias",
"(",
"type_",
")",
"if",
"not",
"is_reference",
"(",
"nake_type",
")",
":",
"return",
"type_",
"return",
"nake_type",
".",
"base"
] | removes reference from the type definition
If type is not reference type, it will be returned as is. | [
"removes",
"reference",
"from",
"the",
"type",
"definition"
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/type_traits.py#L311-L320 | train |
gccxml/pygccxml | pygccxml/declarations/type_traits.py | remove_const | def remove_const(type_):
"""removes const from the type definition
If type is not const type, it will be returned as is
"""
nake_type = remove_alias(type_)
if not is_const(nake_type):
return type_
else:
# Handling for const and volatile qualified types. There is a
# dif... | python | def remove_const(type_):
"""removes const from the type definition
If type is not const type, it will be returned as is
"""
nake_type = remove_alias(type_)
if not is_const(nake_type):
return type_
else:
# Handling for const and volatile qualified types. There is a
# dif... | [
"def",
"remove_const",
"(",
"type_",
")",
":",
"nake_type",
"=",
"remove_alias",
"(",
"type_",
")",
"if",
"not",
"is_const",
"(",
"nake_type",
")",
":",
"return",
"type_",
"else",
":",
"if",
"isinstance",
"(",
"nake_type",
",",
"cpptypes",
".",
"array_t",
... | removes const from the type definition
If type is not const type, it will be returned as is | [
"removes",
"const",
"from",
"the",
"type",
"definition"
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/type_traits.py#L335-L366 | train |
gccxml/pygccxml | pygccxml/declarations/type_traits.py | is_same | def is_same(type1, type2):
"""returns True, if type1 and type2 are same types"""
nake_type1 = remove_declarated(type1)
nake_type2 = remove_declarated(type2)
return nake_type1 == nake_type2 | python | def is_same(type1, type2):
"""returns True, if type1 and type2 are same types"""
nake_type1 = remove_declarated(type1)
nake_type2 = remove_declarated(type2)
return nake_type1 == nake_type2 | [
"def",
"is_same",
"(",
"type1",
",",
"type2",
")",
":",
"nake_type1",
"=",
"remove_declarated",
"(",
"type1",
")",
"nake_type2",
"=",
"remove_declarated",
"(",
"type2",
")",
"return",
"nake_type1",
"==",
"nake_type2"
] | returns True, if type1 and type2 are same types | [
"returns",
"True",
"if",
"type1",
"and",
"type2",
"are",
"same",
"types"
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/type_traits.py#L383-L387 | train |
gccxml/pygccxml | pygccxml/declarations/type_traits.py | is_elaborated | def is_elaborated(type_):
"""returns True, if type represents C++ elaborated type, False otherwise"""
nake_type = remove_alias(type_)
if isinstance(nake_type, cpptypes.elaborated_t):
return True
elif isinstance(nake_type, cpptypes.reference_t):
return is_elaborated(nake_type.base)
el... | python | def is_elaborated(type_):
"""returns True, if type represents C++ elaborated type, False otherwise"""
nake_type = remove_alias(type_)
if isinstance(nake_type, cpptypes.elaborated_t):
return True
elif isinstance(nake_type, cpptypes.reference_t):
return is_elaborated(nake_type.base)
el... | [
"def",
"is_elaborated",
"(",
"type_",
")",
":",
"nake_type",
"=",
"remove_alias",
"(",
"type_",
")",
"if",
"isinstance",
"(",
"nake_type",
",",
"cpptypes",
".",
"elaborated_t",
")",
":",
"return",
"True",
"elif",
"isinstance",
"(",
"nake_type",
",",
"cpptype... | returns True, if type represents C++ elaborated type, False otherwise | [
"returns",
"True",
"if",
"type",
"represents",
"C",
"++",
"elaborated",
"type",
"False",
"otherwise"
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/type_traits.py#L390-L403 | train |
gccxml/pygccxml | pygccxml/declarations/type_traits.py | is_volatile | def is_volatile(type_):
"""returns True, if type represents C++ volatile type, False otherwise"""
nake_type = remove_alias(type_)
if isinstance(nake_type, cpptypes.volatile_t):
return True
elif isinstance(nake_type, cpptypes.const_t):
return is_volatile(nake_type.base)
elif isinstanc... | python | def is_volatile(type_):
"""returns True, if type represents C++ volatile type, False otherwise"""
nake_type = remove_alias(type_)
if isinstance(nake_type, cpptypes.volatile_t):
return True
elif isinstance(nake_type, cpptypes.const_t):
return is_volatile(nake_type.base)
elif isinstanc... | [
"def",
"is_volatile",
"(",
"type_",
")",
":",
"nake_type",
"=",
"remove_alias",
"(",
"type_",
")",
"if",
"isinstance",
"(",
"nake_type",
",",
"cpptypes",
".",
"volatile_t",
")",
":",
"return",
"True",
"elif",
"isinstance",
"(",
"nake_type",
",",
"cpptypes",
... | returns True, if type represents C++ volatile type, False otherwise | [
"returns",
"True",
"if",
"type",
"represents",
"C",
"++",
"volatile",
"type",
"False",
"otherwise"
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/type_traits.py#L421-L430 | train |
gccxml/pygccxml | pygccxml/declarations/type_traits.py | remove_volatile | def remove_volatile(type_):
"""removes volatile from the type definition
If type is not volatile type, it will be returned as is
"""
nake_type = remove_alias(type_)
if not is_volatile(nake_type):
return type_
else:
if isinstance(nake_type, cpptypes.array_t):
is_c = i... | python | def remove_volatile(type_):
"""removes volatile from the type definition
If type is not volatile type, it will be returned as is
"""
nake_type = remove_alias(type_)
if not is_volatile(nake_type):
return type_
else:
if isinstance(nake_type, cpptypes.array_t):
is_c = i... | [
"def",
"remove_volatile",
"(",
"type_",
")",
":",
"nake_type",
"=",
"remove_alias",
"(",
"type_",
")",
"if",
"not",
"is_volatile",
"(",
"nake_type",
")",
":",
"return",
"type_",
"else",
":",
"if",
"isinstance",
"(",
"nake_type",
",",
"cpptypes",
".",
"arra... | removes volatile from the type definition
If type is not volatile type, it will be returned as is | [
"removes",
"volatile",
"from",
"the",
"type",
"definition"
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/type_traits.py#L433-L452 | train |
gccxml/pygccxml | pygccxml/declarations/type_traits.py | remove_cv | def remove_cv(type_):
"""removes const and volatile from the type definition"""
nake_type = remove_alias(type_)
if not is_const(nake_type) and not is_volatile(nake_type):
return type_
result = nake_type
if is_const(result):
result = remove_const(result)
if is_volatile(result):
... | python | def remove_cv(type_):
"""removes const and volatile from the type definition"""
nake_type = remove_alias(type_)
if not is_const(nake_type) and not is_volatile(nake_type):
return type_
result = nake_type
if is_const(result):
result = remove_const(result)
if is_volatile(result):
... | [
"def",
"remove_cv",
"(",
"type_",
")",
":",
"nake_type",
"=",
"remove_alias",
"(",
"type_",
")",
"if",
"not",
"is_const",
"(",
"nake_type",
")",
"and",
"not",
"is_volatile",
"(",
"nake_type",
")",
":",
"return",
"type_",
"result",
"=",
"nake_type",
"if",
... | removes const and volatile from the type definition | [
"removes",
"const",
"and",
"volatile",
"from",
"the",
"type",
"definition"
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/type_traits.py#L455-L468 | train |
gccxml/pygccxml | pygccxml/declarations/type_traits.py | is_fundamental | def is_fundamental(type_):
"""returns True, if type represents C++ fundamental type"""
return does_match_definition(
type_,
cpptypes.fundamental_t,
(cpptypes.const_t, cpptypes.volatile_t)) \
or does_match_definition(
type_,
cpptypes.fundamental_t,
... | python | def is_fundamental(type_):
"""returns True, if type represents C++ fundamental type"""
return does_match_definition(
type_,
cpptypes.fundamental_t,
(cpptypes.const_t, cpptypes.volatile_t)) \
or does_match_definition(
type_,
cpptypes.fundamental_t,
... | [
"def",
"is_fundamental",
"(",
"type_",
")",
":",
"return",
"does_match_definition",
"(",
"type_",
",",
"cpptypes",
".",
"fundamental_t",
",",
"(",
"cpptypes",
".",
"const_t",
",",
"cpptypes",
".",
"volatile_t",
")",
")",
"or",
"does_match_definition",
"(",
"ty... | returns True, if type represents C++ fundamental type | [
"returns",
"True",
"if",
"type",
"represents",
"C",
"++",
"fundamental",
"type"
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/type_traits.py#L471-L480 | train |
gccxml/pygccxml | pygccxml/declarations/pattern_parser.py | parser_t.args | def args(self, decl_string):
"""
Extracts a list of arguments from the provided declaration string.
Implementation detail. Example usages:
Input: myClass<std::vector<int>, std::vector<double>>
Output: [std::vector<int>, std::vector<double>]
Args:
decl_string ... | python | def args(self, decl_string):
"""
Extracts a list of arguments from the provided declaration string.
Implementation detail. Example usages:
Input: myClass<std::vector<int>, std::vector<double>>
Output: [std::vector<int>, std::vector<double>]
Args:
decl_string ... | [
"def",
"args",
"(",
"self",
",",
"decl_string",
")",
":",
"args_begin",
"=",
"decl_string",
".",
"find",
"(",
"self",
".",
"__begin",
")",
"args_end",
"=",
"decl_string",
".",
"rfind",
"(",
"self",
".",
"__end",
")",
"if",
"-",
"1",
"in",
"(",
"args_... | Extracts a list of arguments from the provided declaration string.
Implementation detail. Example usages:
Input: myClass<std::vector<int>, std::vector<double>>
Output: [std::vector<int>, std::vector<double>]
Args:
decl_string (str): the full declaration string
Retur... | [
"Extracts",
"a",
"list",
"of",
"arguments",
"from",
"the",
"provided",
"declaration",
"string",
"."
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/pattern_parser.py#L72-L150 | train |
gccxml/pygccxml | pygccxml/declarations/has_operator_matcher.py | has_public_binary_operator | def has_public_binary_operator(type_, operator_symbol):
"""returns True, if `type_` has public binary operator, otherwise False"""
type_ = type_traits.remove_alias(type_)
type_ = type_traits.remove_cv(type_)
type_ = type_traits.remove_declarated(type_)
assert isinstance(type_, class_declaration.clas... | python | def has_public_binary_operator(type_, operator_symbol):
"""returns True, if `type_` has public binary operator, otherwise False"""
type_ = type_traits.remove_alias(type_)
type_ = type_traits.remove_cv(type_)
type_ = type_traits.remove_declarated(type_)
assert isinstance(type_, class_declaration.clas... | [
"def",
"has_public_binary_operator",
"(",
"type_",
",",
"operator_symbol",
")",
":",
"type_",
"=",
"type_traits",
".",
"remove_alias",
"(",
"type_",
")",
"type_",
"=",
"type_traits",
".",
"remove_cv",
"(",
"type_",
")",
"type_",
"=",
"type_traits",
".",
"remov... | returns True, if `type_` has public binary operator, otherwise False | [
"returns",
"True",
"if",
"type_",
"has",
"public",
"binary",
"operator",
"otherwise",
"False"
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/has_operator_matcher.py#L7-L49 | train |
gccxml/pygccxml | pygccxml/parser/directory_cache.py | directory_cache_t.update | def update(self, source_file, configuration, declarations, included_files):
"""Replace a cache entry by a new value.
:param source_file: a C++ source file name.
:type source_file: str
:param configuration: configuration object.
:type configuration: :class:`xml_generator_configu... | python | def update(self, source_file, configuration, declarations, included_files):
"""Replace a cache entry by a new value.
:param source_file: a C++ source file name.
:type source_file: str
:param configuration: configuration object.
:type configuration: :class:`xml_generator_configu... | [
"def",
"update",
"(",
"self",
",",
"source_file",
",",
"configuration",
",",
"declarations",
",",
"included_files",
")",
":",
"source_file",
"=",
"os",
".",
"path",
".",
"normpath",
"(",
"source_file",
")",
"included_files",
"=",
"[",
"os",
".",
"path",
".... | Replace a cache entry by a new value.
:param source_file: a C++ source file name.
:type source_file: str
:param configuration: configuration object.
:type configuration: :class:`xml_generator_configuration_t`
:param declarations: declarations contained in the `source_file`
... | [
"Replace",
"a",
"cache",
"entry",
"by",
"a",
"new",
"value",
"."
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/parser/directory_cache.py#L127-L171 | train |
gccxml/pygccxml | pygccxml/parser/directory_cache.py | directory_cache_t.cached_value | def cached_value(self, source_file, configuration):
"""Return the cached declarations or None.
:param source_file: Header file name
:type source_file: str
:param configuration: Configuration object
:type configuration: :class:`parser.xml_generator_configuration_t`
:rtype... | python | def cached_value(self, source_file, configuration):
"""Return the cached declarations or None.
:param source_file: Header file name
:type source_file: str
:param configuration: Configuration object
:type configuration: :class:`parser.xml_generator_configuration_t`
:rtype... | [
"def",
"cached_value",
"(",
"self",
",",
"source_file",
",",
"configuration",
")",
":",
"key",
"=",
"self",
".",
"_create_cache_key",
"(",
"source_file",
")",
"entry",
"=",
"self",
".",
"__index",
".",
"get",
"(",
"key",
")",
"if",
"entry",
"is",
"None",... | Return the cached declarations or None.
:param source_file: Header file name
:type source_file: str
:param configuration: Configuration object
:type configuration: :class:`parser.xml_generator_configuration_t`
:rtype: Cached declarations or None | [
"Return",
"the",
"cached",
"declarations",
"or",
"None",
"."
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/parser/directory_cache.py#L173-L217 | train |
gccxml/pygccxml | pygccxml/parser/directory_cache.py | directory_cache_t._load | def _load(self):
"""Load the cache.
Loads the `index.dat` file, which contains the index table and the
file name repository.
This method is called by the :meth:`__init__`
"""
indexfilename = os.path.join(self.__dir, "index.dat")
if os.path.exists(indexfilename)... | python | def _load(self):
"""Load the cache.
Loads the `index.dat` file, which contains the index table and the
file name repository.
This method is called by the :meth:`__init__`
"""
indexfilename = os.path.join(self.__dir, "index.dat")
if os.path.exists(indexfilename)... | [
"def",
"_load",
"(",
"self",
")",
":",
"indexfilename",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"__dir",
",",
"\"index.dat\"",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"indexfilename",
")",
":",
"data",
"=",
"self",
".",
"_r... | Load the cache.
Loads the `index.dat` file, which contains the index table and the
file name repository.
This method is called by the :meth:`__init__` | [
"Load",
"the",
"cache",
"."
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/parser/directory_cache.py#L219-L243 | train |
gccxml/pygccxml | pygccxml/parser/directory_cache.py | directory_cache_t._save | def _save(self):
"""
save the cache index, in case it was modified.
Saves the index table and the file name repository in the file
`index.dat`
"""
if self.__modified_flag:
self.__filename_rep.update_id_counter()
indexfilename = os.path.join(self.... | python | def _save(self):
"""
save the cache index, in case it was modified.
Saves the index table and the file name repository in the file
`index.dat`
"""
if self.__modified_flag:
self.__filename_rep.update_id_counter()
indexfilename = os.path.join(self.... | [
"def",
"_save",
"(",
"self",
")",
":",
"if",
"self",
".",
"__modified_flag",
":",
"self",
".",
"__filename_rep",
".",
"update_id_counter",
"(",
")",
"indexfilename",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"__dir",
",",
"\"index.dat\"",
")... | save the cache index, in case it was modified.
Saves the index table and the file name repository in the file
`index.dat` | [
"save",
"the",
"cache",
"index",
"in",
"case",
"it",
"was",
"modified",
"."
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/parser/directory_cache.py#L245-L261 | train |
gccxml/pygccxml | pygccxml/parser/directory_cache.py | directory_cache_t._read_file | def _read_file(self, filename):
"""
read a Python object from a cache file.
Reads a pickled object from disk and returns it.
:param filename: Name of the file that should be read.
:type filename: str
:rtype: object
"""
if self.__compression:
... | python | def _read_file(self, filename):
"""
read a Python object from a cache file.
Reads a pickled object from disk and returns it.
:param filename: Name of the file that should be read.
:type filename: str
:rtype: object
"""
if self.__compression:
... | [
"def",
"_read_file",
"(",
"self",
",",
"filename",
")",
":",
"if",
"self",
".",
"__compression",
":",
"f",
"=",
"gzip",
".",
"GzipFile",
"(",
"filename",
",",
"\"rb\"",
")",
"else",
":",
"f",
"=",
"open",
"(",
"filename",
",",
"\"rb\"",
")",
"res",
... | read a Python object from a cache file.
Reads a pickled object from disk and returns it.
:param filename: Name of the file that should be read.
:type filename: str
:rtype: object | [
"read",
"a",
"Python",
"object",
"from",
"a",
"cache",
"file",
"."
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/parser/directory_cache.py#L263-L280 | train |
gccxml/pygccxml | pygccxml/parser/directory_cache.py | directory_cache_t._write_file | def _write_file(self, filename, data):
"""Write a data item into a file.
The data object is written to a file using the pickle mechanism.
:param filename: Output file name
:type filename: str
:param data: A Python object that will be pickled
"""
if self.__compr... | python | def _write_file(self, filename, data):
"""Write a data item into a file.
The data object is written to a file using the pickle mechanism.
:param filename: Output file name
:type filename: str
:param data: A Python object that will be pickled
"""
if self.__compr... | [
"def",
"_write_file",
"(",
"self",
",",
"filename",
",",
"data",
")",
":",
"if",
"self",
".",
"__compression",
":",
"f",
"=",
"gzip",
".",
"GzipFile",
"(",
"filename",
",",
"\"wb\"",
")",
"else",
":",
"f",
"=",
"open",
"(",
"filename",
",",
"\"wb\"",... | Write a data item into a file.
The data object is written to a file using the pickle mechanism.
:param filename: Output file name
:type filename: str
:param data: A Python object that will be pickled | [
"Write",
"a",
"data",
"item",
"into",
"a",
"file",
"."
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/parser/directory_cache.py#L282-L297 | train |
gccxml/pygccxml | pygccxml/parser/directory_cache.py | directory_cache_t._remove_entry | def _remove_entry(self, source_file, key):
"""Remove an entry from the cache.
source_file is the name of the header and key is its corresponding
cache key (obtained by a call to :meth:_create_cache_key ).
The entry is removed from the index table, any referenced file
name is rel... | python | def _remove_entry(self, source_file, key):
"""Remove an entry from the cache.
source_file is the name of the header and key is its corresponding
cache key (obtained by a call to :meth:_create_cache_key ).
The entry is removed from the index table, any referenced file
name is rel... | [
"def",
"_remove_entry",
"(",
"self",
",",
"source_file",
",",
"key",
")",
":",
"entry",
"=",
"self",
".",
"__index",
".",
"get",
"(",
"key",
")",
"if",
"entry",
"is",
"None",
":",
"return",
"for",
"id_",
",",
"_",
"in",
"entry",
".",
"filesigs",
":... | Remove an entry from the cache.
source_file is the name of the header and key is its corresponding
cache key (obtained by a call to :meth:_create_cache_key ).
The entry is removed from the index table, any referenced file
name is released and the cache file is deleted.
If key r... | [
"Remove",
"an",
"entry",
"from",
"the",
"cache",
"."
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/parser/directory_cache.py#L299-L333 | train |
gccxml/pygccxml | pygccxml/parser/directory_cache.py | directory_cache_t._create_cache_key | def _create_cache_key(source_file):
"""
return the cache key for a header file.
:param source_file: Header file name
:type source_file: str
:rtype: str
"""
path, name = os.path.split(source_file)
return name + str(hash(path)) | python | def _create_cache_key(source_file):
"""
return the cache key for a header file.
:param source_file: Header file name
:type source_file: str
:rtype: str
"""
path, name = os.path.split(source_file)
return name + str(hash(path)) | [
"def",
"_create_cache_key",
"(",
"source_file",
")",
":",
"path",
",",
"name",
"=",
"os",
".",
"path",
".",
"split",
"(",
"source_file",
")",
"return",
"name",
"+",
"str",
"(",
"hash",
"(",
"path",
")",
")"
] | return the cache key for a header file.
:param source_file: Header file name
:type source_file: str
:rtype: str | [
"return",
"the",
"cache",
"key",
"for",
"a",
"header",
"file",
"."
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/parser/directory_cache.py#L336-L345 | train |
gccxml/pygccxml | pygccxml/parser/directory_cache.py | directory_cache_t._create_cache_filename | def _create_cache_filename(self, source_file):
"""
return the cache file name for a header file.
:param source_file: Header file name
:type source_file: str
:rtype: str
"""
res = self._create_cache_key(source_file) + ".cache"
return os.path.join(self.__di... | python | def _create_cache_filename(self, source_file):
"""
return the cache file name for a header file.
:param source_file: Header file name
:type source_file: str
:rtype: str
"""
res = self._create_cache_key(source_file) + ".cache"
return os.path.join(self.__di... | [
"def",
"_create_cache_filename",
"(",
"self",
",",
"source_file",
")",
":",
"res",
"=",
"self",
".",
"_create_cache_key",
"(",
"source_file",
")",
"+",
"\".cache\"",
"return",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"__dir",
",",
"res",
")"
] | return the cache file name for a header file.
:param source_file: Header file name
:type source_file: str
:rtype: str | [
"return",
"the",
"cache",
"file",
"name",
"for",
"a",
"header",
"file",
"."
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/parser/directory_cache.py#L347-L356 | train |
gccxml/pygccxml | pygccxml/parser/directory_cache.py | directory_cache_t._create_config_signature | def _create_config_signature(config):
"""
return the signature for a config object.
The signature is computed as sha1 digest of the contents of
working_directory, include_paths, define_symbols and
undefine_symbols.
:param config: Configuration object
:type confi... | python | def _create_config_signature(config):
"""
return the signature for a config object.
The signature is computed as sha1 digest of the contents of
working_directory, include_paths, define_symbols and
undefine_symbols.
:param config: Configuration object
:type confi... | [
"def",
"_create_config_signature",
"(",
"config",
")",
":",
"m",
"=",
"hashlib",
".",
"sha1",
"(",
")",
"m",
".",
"update",
"(",
"config",
".",
"working_directory",
".",
"encode",
"(",
"\"utf-8\"",
")",
")",
"for",
"p",
"in",
"config",
".",
"include_path... | return the signature for a config object.
The signature is computed as sha1 digest of the contents of
working_directory, include_paths, define_symbols and
undefine_symbols.
:param config: Configuration object
:type config: :class:`parser.xml_generator_configuration_t`
:... | [
"return",
"the",
"signature",
"for",
"a",
"config",
"object",
"."
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/parser/directory_cache.py#L359-L381 | train |
gccxml/pygccxml | pygccxml/parser/directory_cache.py | filename_repository_t.acquire_filename | def acquire_filename(self, name):
"""Acquire a file name and return its id and its signature.
"""
id_ = self.__id_lut.get(name)
# Is this a new entry?
if id_ is None:
# then create one...
id_ = self.__next_id
self.__next_id += 1
se... | python | def acquire_filename(self, name):
"""Acquire a file name and return its id and its signature.
"""
id_ = self.__id_lut.get(name)
# Is this a new entry?
if id_ is None:
# then create one...
id_ = self.__next_id
self.__next_id += 1
se... | [
"def",
"acquire_filename",
"(",
"self",
",",
"name",
")",
":",
"id_",
"=",
"self",
".",
"__id_lut",
".",
"get",
"(",
"name",
")",
"if",
"id_",
"is",
"None",
":",
"id_",
"=",
"self",
".",
"__next_id",
"self",
".",
"__next_id",
"+=",
"1",
"self",
"."... | Acquire a file name and return its id and its signature. | [
"Acquire",
"a",
"file",
"name",
"and",
"return",
"its",
"id",
"and",
"its",
"signature",
"."
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/parser/directory_cache.py#L466-L484 | train |
gccxml/pygccxml | pygccxml/parser/directory_cache.py | filename_repository_t.release_filename | def release_filename(self, id_):
"""Release a file name.
"""
entry = self.__entries.get(id_)
if entry is None:
raise ValueError("Invalid filename id (%d)" % id_)
# Decrease reference count and check if the entry has to be removed...
if entry.dec_ref_count() ... | python | def release_filename(self, id_):
"""Release a file name.
"""
entry = self.__entries.get(id_)
if entry is None:
raise ValueError("Invalid filename id (%d)" % id_)
# Decrease reference count and check if the entry has to be removed...
if entry.dec_ref_count() ... | [
"def",
"release_filename",
"(",
"self",
",",
"id_",
")",
":",
"entry",
"=",
"self",
".",
"__entries",
".",
"get",
"(",
"id_",
")",
"if",
"entry",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"Invalid filename id (%d)\"",
"%",
"id_",
")",
"if",
"entry... | Release a file name. | [
"Release",
"a",
"file",
"name",
"."
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/parser/directory_cache.py#L486-L497 | train |
gccxml/pygccxml | pygccxml/parser/directory_cache.py | filename_repository_t.is_file_modified | def is_file_modified(self, id_, signature):
"""Check if the file referred to by `id_` has been modified.
"""
entry = self.__entries.get(id_)
if entry is None:
raise ValueError("Invalid filename id_ (%d)" % id_)
# Is the signature already known?
if entry.sig_... | python | def is_file_modified(self, id_, signature):
"""Check if the file referred to by `id_` has been modified.
"""
entry = self.__entries.get(id_)
if entry is None:
raise ValueError("Invalid filename id_ (%d)" % id_)
# Is the signature already known?
if entry.sig_... | [
"def",
"is_file_modified",
"(",
"self",
",",
"id_",
",",
"signature",
")",
":",
"entry",
"=",
"self",
".",
"__entries",
".",
"get",
"(",
"id_",
")",
"if",
"entry",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"Invalid filename id_ (%d)\"",
"%",
"id_",
... | Check if the file referred to by `id_` has been modified. | [
"Check",
"if",
"the",
"file",
"referred",
"to",
"by",
"id_",
"has",
"been",
"modified",
"."
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/parser/directory_cache.py#L499-L517 | train |
gccxml/pygccxml | pygccxml/parser/directory_cache.py | filename_repository_t.update_id_counter | def update_id_counter(self):
"""Update the `id_` counter so that it doesn't grow forever.
"""
if not self.__entries:
self.__next_id = 1
else:
self.__next_id = max(self.__entries.keys()) + 1 | python | def update_id_counter(self):
"""Update the `id_` counter so that it doesn't grow forever.
"""
if not self.__entries:
self.__next_id = 1
else:
self.__next_id = max(self.__entries.keys()) + 1 | [
"def",
"update_id_counter",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"__entries",
":",
"self",
".",
"__next_id",
"=",
"1",
"else",
":",
"self",
".",
"__next_id",
"=",
"max",
"(",
"self",
".",
"__entries",
".",
"keys",
"(",
")",
")",
"+",
"1... | Update the `id_` counter so that it doesn't grow forever. | [
"Update",
"the",
"id_",
"counter",
"so",
"that",
"it",
"doesn",
"t",
"grow",
"forever",
"."
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/parser/directory_cache.py#L519-L526 | train |
gccxml/pygccxml | pygccxml/parser/directory_cache.py | filename_repository_t._get_signature | def _get_signature(self, entry):
"""Return the signature of the file stored in entry.
"""
if self._sha1_sigs:
# return sha1 digest of the file content...
if not os.path.exists(entry.filename):
return None
try:
with open(entry.f... | python | def _get_signature(self, entry):
"""Return the signature of the file stored in entry.
"""
if self._sha1_sigs:
# return sha1 digest of the file content...
if not os.path.exists(entry.filename):
return None
try:
with open(entry.f... | [
"def",
"_get_signature",
"(",
"self",
",",
"entry",
")",
":",
"if",
"self",
".",
"_sha1_sigs",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"entry",
".",
"filename",
")",
":",
"return",
"None",
"try",
":",
"with",
"open",
"(",
"entry",
... | Return the signature of the file stored in entry. | [
"Return",
"the",
"signature",
"of",
"the",
"file",
"stored",
"in",
"entry",
"."
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/parser/directory_cache.py#L528-L548 | train |
gccxml/pygccxml | pygccxml/declarations/type_traits_classes.py | is_union | def is_union(declaration):
"""
Returns True if declaration represents a C++ union
Args:
declaration (declaration_t): the declaration to be checked.
Returns:
bool: True if declaration represents a C++ union
"""
if not is_class(declaration):
return False
decl = class_... | python | def is_union(declaration):
"""
Returns True if declaration represents a C++ union
Args:
declaration (declaration_t): the declaration to be checked.
Returns:
bool: True if declaration represents a C++ union
"""
if not is_class(declaration):
return False
decl = class_... | [
"def",
"is_union",
"(",
"declaration",
")",
":",
"if",
"not",
"is_class",
"(",
"declaration",
")",
":",
"return",
"False",
"decl",
"=",
"class_traits",
".",
"get_declaration",
"(",
"declaration",
")",
"return",
"decl",
".",
"class_type",
"==",
"class_declarati... | Returns True if declaration represents a C++ union
Args:
declaration (declaration_t): the declaration to be checked.
Returns:
bool: True if declaration represents a C++ union | [
"Returns",
"True",
"if",
"declaration",
"represents",
"a",
"C",
"++",
"union"
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/type_traits_classes.py#L18-L31 | train |
gccxml/pygccxml | pygccxml/declarations/type_traits_classes.py | is_struct | def is_struct(declaration):
"""
Returns True if declaration represents a C++ struct
Args:
declaration (declaration_t): the declaration to be checked.
Returns:
bool: True if declaration represents a C++ struct
"""
if not is_class(declaration):
return False
decl = cla... | python | def is_struct(declaration):
"""
Returns True if declaration represents a C++ struct
Args:
declaration (declaration_t): the declaration to be checked.
Returns:
bool: True if declaration represents a C++ struct
"""
if not is_class(declaration):
return False
decl = cla... | [
"def",
"is_struct",
"(",
"declaration",
")",
":",
"if",
"not",
"is_class",
"(",
"declaration",
")",
":",
"return",
"False",
"decl",
"=",
"class_traits",
".",
"get_declaration",
"(",
"declaration",
")",
"return",
"decl",
".",
"class_type",
"==",
"class_declarat... | Returns True if declaration represents a C++ struct
Args:
declaration (declaration_t): the declaration to be checked.
Returns:
bool: True if declaration represents a C++ struct | [
"Returns",
"True",
"if",
"declaration",
"represents",
"a",
"C",
"++",
"struct"
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/type_traits_classes.py#L34-L47 | train |
gccxml/pygccxml | pygccxml/declarations/type_traits_classes.py | find_trivial_constructor | def find_trivial_constructor(type_):
"""
Returns reference to trivial constructor.
Args:
type_ (declarations.class_t): the class to be searched.
Returns:
declarations.constructor_t: the trivial constructor
"""
assert isinstance(type_, class_declaration.class_t)
trivial = ... | python | def find_trivial_constructor(type_):
"""
Returns reference to trivial constructor.
Args:
type_ (declarations.class_t): the class to be searched.
Returns:
declarations.constructor_t: the trivial constructor
"""
assert isinstance(type_, class_declaration.class_t)
trivial = ... | [
"def",
"find_trivial_constructor",
"(",
"type_",
")",
":",
"assert",
"isinstance",
"(",
"type_",
",",
"class_declaration",
".",
"class_t",
")",
"trivial",
"=",
"type_",
".",
"constructors",
"(",
"lambda",
"x",
":",
"is_trivial_constructor",
"(",
"x",
")",
",",... | Returns reference to trivial constructor.
Args:
type_ (declarations.class_t): the class to be searched.
Returns:
declarations.constructor_t: the trivial constructor | [
"Returns",
"reference",
"to",
"trivial",
"constructor",
"."
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/type_traits_classes.py#L111-L131 | train |
gccxml/pygccxml | pygccxml/declarations/type_traits_classes.py | find_copy_constructor | def find_copy_constructor(type_):
"""
Returns reference to copy constructor.
Args:
type_ (declarations.class_t): the class to be searched.
Returns:
declarations.constructor_t: the copy constructor
"""
copy_ = type_.constructors(
lambda x: is_copy_constructor(x),
... | python | def find_copy_constructor(type_):
"""
Returns reference to copy constructor.
Args:
type_ (declarations.class_t): the class to be searched.
Returns:
declarations.constructor_t: the copy constructor
"""
copy_ = type_.constructors(
lambda x: is_copy_constructor(x),
... | [
"def",
"find_copy_constructor",
"(",
"type_",
")",
":",
"copy_",
"=",
"type_",
".",
"constructors",
"(",
"lambda",
"x",
":",
"is_copy_constructor",
"(",
"x",
")",
",",
"recursive",
"=",
"False",
",",
"allow_empty",
"=",
"True",
")",
"if",
"copy_",
":",
"... | Returns reference to copy constructor.
Args:
type_ (declarations.class_t): the class to be searched.
Returns:
declarations.constructor_t: the copy constructor | [
"Returns",
"reference",
"to",
"copy",
"constructor",
"."
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/type_traits_classes.py#L134-L152 | train |
gccxml/pygccxml | pygccxml/declarations/type_traits_classes.py | find_noncopyable_vars | def find_noncopyable_vars(class_type, already_visited_cls_vars=None):
"""
Returns list of all `noncopyable` variables.
If an already_visited_cls_vars list is provided as argument, the returned
list will not contain these variables. This list will be extended with
whatever variables pointing to clas... | python | def find_noncopyable_vars(class_type, already_visited_cls_vars=None):
"""
Returns list of all `noncopyable` variables.
If an already_visited_cls_vars list is provided as argument, the returned
list will not contain these variables. This list will be extended with
whatever variables pointing to clas... | [
"def",
"find_noncopyable_vars",
"(",
"class_type",
",",
"already_visited_cls_vars",
"=",
"None",
")",
":",
"assert",
"isinstance",
"(",
"class_type",
",",
"class_declaration",
".",
"class_t",
")",
"logger",
"=",
"utils",
".",
"loggers",
".",
"cxx_parser",
"mvars",... | Returns list of all `noncopyable` variables.
If an already_visited_cls_vars list is provided as argument, the returned
list will not contain these variables. This list will be extended with
whatever variables pointing to classes have been found.
Args:
class_type (declarations.class_t): the cla... | [
"Returns",
"list",
"of",
"all",
"noncopyable",
"variables",
"."
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/type_traits_classes.py#L155-L228 | train |
gccxml/pygccxml | pygccxml/declarations/type_traits_classes.py | has_trivial_constructor | def has_trivial_constructor(class_):
"""if class has public trivial constructor, this function will return
reference to it, None otherwise"""
class_ = class_traits.get_declaration(class_)
trivial = find_trivial_constructor(class_)
if trivial and trivial.access_type == 'public':
return trivia... | python | def has_trivial_constructor(class_):
"""if class has public trivial constructor, this function will return
reference to it, None otherwise"""
class_ = class_traits.get_declaration(class_)
trivial = find_trivial_constructor(class_)
if trivial and trivial.access_type == 'public':
return trivia... | [
"def",
"has_trivial_constructor",
"(",
"class_",
")",
":",
"class_",
"=",
"class_traits",
".",
"get_declaration",
"(",
"class_",
")",
"trivial",
"=",
"find_trivial_constructor",
"(",
"class_",
")",
"if",
"trivial",
"and",
"trivial",
".",
"access_type",
"==",
"'p... | if class has public trivial constructor, this function will return
reference to it, None otherwise | [
"if",
"class",
"has",
"public",
"trivial",
"constructor",
"this",
"function",
"will",
"return",
"reference",
"to",
"it",
"None",
"otherwise"
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/type_traits_classes.py#L231-L237 | train |
gccxml/pygccxml | pygccxml/declarations/type_traits_classes.py | has_copy_constructor | def has_copy_constructor(class_):
"""if class has public copy constructor, this function will return
reference to it, None otherwise"""
class_ = class_traits.get_declaration(class_)
copy_constructor = find_copy_constructor(class_)
if copy_constructor and copy_constructor.access_type == 'public':
... | python | def has_copy_constructor(class_):
"""if class has public copy constructor, this function will return
reference to it, None otherwise"""
class_ = class_traits.get_declaration(class_)
copy_constructor = find_copy_constructor(class_)
if copy_constructor and copy_constructor.access_type == 'public':
... | [
"def",
"has_copy_constructor",
"(",
"class_",
")",
":",
"class_",
"=",
"class_traits",
".",
"get_declaration",
"(",
"class_",
")",
"copy_constructor",
"=",
"find_copy_constructor",
"(",
"class_",
")",
"if",
"copy_constructor",
"and",
"copy_constructor",
".",
"access... | if class has public copy constructor, this function will return
reference to it, None otherwise | [
"if",
"class",
"has",
"public",
"copy",
"constructor",
"this",
"function",
"will",
"return",
"reference",
"to",
"it",
"None",
"otherwise"
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/type_traits_classes.py#L240-L246 | train |
gccxml/pygccxml | pygccxml/declarations/type_traits_classes.py | has_destructor | def has_destructor(class_):
"""if class has destructor, this function will return reference to it,
None otherwise"""
class_ = class_traits.get_declaration(class_)
destructor = class_.decls(
decl_type=calldef_members.destructor_t,
recursive=False,
allow_empty=True)
if destruct... | python | def has_destructor(class_):
"""if class has destructor, this function will return reference to it,
None otherwise"""
class_ = class_traits.get_declaration(class_)
destructor = class_.decls(
decl_type=calldef_members.destructor_t,
recursive=False,
allow_empty=True)
if destruct... | [
"def",
"has_destructor",
"(",
"class_",
")",
":",
"class_",
"=",
"class_traits",
".",
"get_declaration",
"(",
"class_",
")",
"destructor",
"=",
"class_",
".",
"decls",
"(",
"decl_type",
"=",
"calldef_members",
".",
"destructor_t",
",",
"recursive",
"=",
"False... | if class has destructor, this function will return reference to it,
None otherwise | [
"if",
"class",
"has",
"destructor",
"this",
"function",
"will",
"return",
"reference",
"to",
"it",
"None",
"otherwise"
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/type_traits_classes.py#L249-L258 | train |
gccxml/pygccxml | pygccxml/declarations/type_traits_classes.py | has_public_constructor | def has_public_constructor(class_):
"""if class has any public constructor, this function will return list of
them, otherwise None"""
class_ = class_traits.get_declaration(class_)
decls = class_.constructors(
lambda c: not is_copy_constructor(c) and c.access_type == 'public',
recursive=F... | python | def has_public_constructor(class_):
"""if class has any public constructor, this function will return list of
them, otherwise None"""
class_ = class_traits.get_declaration(class_)
decls = class_.constructors(
lambda c: not is_copy_constructor(c) and c.access_type == 'public',
recursive=F... | [
"def",
"has_public_constructor",
"(",
"class_",
")",
":",
"class_",
"=",
"class_traits",
".",
"get_declaration",
"(",
"class_",
")",
"decls",
"=",
"class_",
".",
"constructors",
"(",
"lambda",
"c",
":",
"not",
"is_copy_constructor",
"(",
"c",
")",
"and",
"c"... | if class has any public constructor, this function will return list of
them, otherwise None | [
"if",
"class",
"has",
"any",
"public",
"constructor",
"this",
"function",
"will",
"return",
"list",
"of",
"them",
"otherwise",
"None"
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/type_traits_classes.py#L261-L270 | train |
gccxml/pygccxml | pygccxml/declarations/type_traits_classes.py | has_public_assign | def has_public_assign(class_):
"""returns True, if class has public assign operator, False otherwise"""
class_ = class_traits.get_declaration(class_)
decls = class_.member_operators(
lambda o: o.symbol == '=' and o.access_type == 'public',
recursive=False,
allow_empty=True)
retur... | python | def has_public_assign(class_):
"""returns True, if class has public assign operator, False otherwise"""
class_ = class_traits.get_declaration(class_)
decls = class_.member_operators(
lambda o: o.symbol == '=' and o.access_type == 'public',
recursive=False,
allow_empty=True)
retur... | [
"def",
"has_public_assign",
"(",
"class_",
")",
":",
"class_",
"=",
"class_traits",
".",
"get_declaration",
"(",
"class_",
")",
"decls",
"=",
"class_",
".",
"member_operators",
"(",
"lambda",
"o",
":",
"o",
".",
"symbol",
"==",
"'='",
"and",
"o",
".",
"a... | returns True, if class has public assign operator, False otherwise | [
"returns",
"True",
"if",
"class",
"has",
"public",
"assign",
"operator",
"False",
"otherwise"
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/type_traits_classes.py#L273-L280 | train |
gccxml/pygccxml | pygccxml/declarations/type_traits_classes.py | has_vtable | def has_vtable(decl_type):
"""True, if class has virtual table, False otherwise"""
assert isinstance(decl_type, class_declaration.class_t)
return bool(
decl_type.calldefs(
lambda f: isinstance(f, calldef_members.member_function_t) and
f.virtuality != calldef_types.VIRTUALITY_... | python | def has_vtable(decl_type):
"""True, if class has virtual table, False otherwise"""
assert isinstance(decl_type, class_declaration.class_t)
return bool(
decl_type.calldefs(
lambda f: isinstance(f, calldef_members.member_function_t) and
f.virtuality != calldef_types.VIRTUALITY_... | [
"def",
"has_vtable",
"(",
"decl_type",
")",
":",
"assert",
"isinstance",
"(",
"decl_type",
",",
"class_declaration",
".",
"class_t",
")",
"return",
"bool",
"(",
"decl_type",
".",
"calldefs",
"(",
"lambda",
"f",
":",
"isinstance",
"(",
"f",
",",
"calldef_memb... | True, if class has virtual table, False otherwise | [
"True",
"if",
"class",
"has",
"virtual",
"table",
"False",
"otherwise"
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/type_traits_classes.py#L289-L297 | train |
gccxml/pygccxml | pygccxml/declarations/type_traits_classes.py | is_base_and_derived | def is_base_and_derived(based, derived):
"""returns True, if there is "base and derived" relationship between
classes, False otherwise"""
assert isinstance(based, class_declaration.class_t)
assert isinstance(derived, (class_declaration.class_t, tuple))
if isinstance(derived, class_declaration.class... | python | def is_base_and_derived(based, derived):
"""returns True, if there is "base and derived" relationship between
classes, False otherwise"""
assert isinstance(based, class_declaration.class_t)
assert isinstance(derived, (class_declaration.class_t, tuple))
if isinstance(derived, class_declaration.class... | [
"def",
"is_base_and_derived",
"(",
"based",
",",
"derived",
")",
":",
"assert",
"isinstance",
"(",
"based",
",",
"class_declaration",
".",
"class_t",
")",
"assert",
"isinstance",
"(",
"derived",
",",
"(",
"class_declaration",
".",
"class_t",
",",
"tuple",
")",... | returns True, if there is "base and derived" relationship between
classes, False otherwise | [
"returns",
"True",
"if",
"there",
"is",
"base",
"and",
"derived",
"relationship",
"between",
"classes",
"False",
"otherwise"
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/type_traits_classes.py#L300-L315 | train |
gccxml/pygccxml | pygccxml/declarations/type_traits_classes.py | is_noncopyable | def is_noncopyable(class_, already_visited_cls_vars=None):
"""
Checks if class is non copyable
Args:
class_ (declarations.class_t): the class to be checked
already_visited_cls_vars (list): optional list of vars that should not
be checked a second time, to prevent infinite recurs... | python | def is_noncopyable(class_, already_visited_cls_vars=None):
"""
Checks if class is non copyable
Args:
class_ (declarations.class_t): the class to be checked
already_visited_cls_vars (list): optional list of vars that should not
be checked a second time, to prevent infinite recurs... | [
"def",
"is_noncopyable",
"(",
"class_",
",",
"already_visited_cls_vars",
"=",
"None",
")",
":",
"logger",
"=",
"utils",
".",
"loggers",
".",
"cxx_parser",
"class_decl",
"=",
"class_traits",
".",
"get_declaration",
"(",
"class_",
")",
"true_header",
"=",
"\"is_no... | Checks if class is non copyable
Args:
class_ (declarations.class_t): the class to be checked
already_visited_cls_vars (list): optional list of vars that should not
be checked a second time, to prevent infinite recursions.
In general you can ignore this argument, it is mainly... | [
"Checks",
"if",
"class",
"is",
"non",
"copyable"
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/type_traits_classes.py#L708-L785 | train |
gccxml/pygccxml | pygccxml/declarations/type_traits_classes.py | is_unary_operator | def is_unary_operator(oper):
"""returns True, if operator is unary operator, otherwise False"""
# definition:
# member in class
# ret-type operator symbol()
# ret-type operator [++ --](int)
# globally
# ret-type operator symbol( arg )
# ret-type operator [++ --](X&, int)
symbols = ['... | python | def is_unary_operator(oper):
"""returns True, if operator is unary operator, otherwise False"""
# definition:
# member in class
# ret-type operator symbol()
# ret-type operator [++ --](int)
# globally
# ret-type operator symbol( arg )
# ret-type operator [++ --](X&, int)
symbols = ['... | [
"def",
"is_unary_operator",
"(",
"oper",
")",
":",
"symbols",
"=",
"[",
"'!'",
",",
"'&'",
",",
"'~'",
",",
"'*'",
",",
"'+'",
",",
"'++'",
",",
"'-'",
",",
"'--'",
"]",
"if",
"not",
"isinstance",
"(",
"oper",
",",
"calldef_members",
".",
"operator_t... | returns True, if operator is unary operator, otherwise False | [
"returns",
"True",
"if",
"operator",
"is",
"unary",
"operator",
"otherwise",
"False"
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/type_traits_classes.py#L788-L818 | train |
gccxml/pygccxml | pygccxml/declarations/type_traits_classes.py | is_binary_operator | def is_binary_operator(oper):
"""returns True, if operator is binary operator, otherwise False"""
# definition:
# member in class
# ret-type operator symbol(arg)
# globally
# ret-type operator symbol( arg1, arg2 )
symbols = [
',', '()', '[]', '!=', '%', '%=', '&', '&&', '&=', '*', '*... | python | def is_binary_operator(oper):
"""returns True, if operator is binary operator, otherwise False"""
# definition:
# member in class
# ret-type operator symbol(arg)
# globally
# ret-type operator symbol( arg1, arg2 )
symbols = [
',', '()', '[]', '!=', '%', '%=', '&', '&&', '&=', '*', '*... | [
"def",
"is_binary_operator",
"(",
"oper",
")",
":",
"symbols",
"=",
"[",
"','",
",",
"'()'",
",",
"'[]'",
",",
"'!='",
",",
"'%'",
",",
"'%='",
",",
"'&'",
",",
"'&&'",
",",
"'&='",
",",
"'*'",
",",
"'*='",
",",
"'+'",
",",
"'+='",
",",
"'-'",
... | returns True, if operator is binary operator, otherwise False | [
"returns",
"True",
"if",
"operator",
"is",
"binary",
"operator",
"otherwise",
"False"
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/type_traits_classes.py#L821-L844 | train |
gccxml/pygccxml | pygccxml/declarations/type_traits_classes.py | is_copy_constructor | def is_copy_constructor(constructor):
"""
Check if the declaration is a copy constructor,
Args:
constructor (declarations.constructor_t): the constructor
to be checked.
Returns:
bool: True if this is a copy constructor, False instead.
"""
assert isinstance(construc... | python | def is_copy_constructor(constructor):
"""
Check if the declaration is a copy constructor,
Args:
constructor (declarations.constructor_t): the constructor
to be checked.
Returns:
bool: True if this is a copy constructor, False instead.
"""
assert isinstance(construc... | [
"def",
"is_copy_constructor",
"(",
"constructor",
")",
":",
"assert",
"isinstance",
"(",
"constructor",
",",
"calldef_members",
".",
"constructor_t",
")",
"args",
"=",
"constructor",
".",
"arguments",
"parent",
"=",
"constructor",
".",
"parent",
"if",
"len",
"("... | Check if the declaration is a copy constructor,
Args:
constructor (declarations.constructor_t): the constructor
to be checked.
Returns:
bool: True if this is a copy constructor, False instead. | [
"Check",
"if",
"the",
"declaration",
"is",
"a",
"copy",
"constructor"
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/type_traits_classes.py#L847-L900 | train |
gccxml/pygccxml | pygccxml/declarations/class_declaration.py | class_t.get_members | def get_members(self, access=None):
"""
returns list of members according to access type
If access equals to None, then returned list will contain all members.
You should not modify the list content, otherwise different
optimization data will stop work and may to give you wrong ... | python | def get_members(self, access=None):
"""
returns list of members according to access type
If access equals to None, then returned list will contain all members.
You should not modify the list content, otherwise different
optimization data will stop work and may to give you wrong ... | [
"def",
"get_members",
"(",
"self",
",",
"access",
"=",
"None",
")",
":",
"if",
"access",
"==",
"ACCESS_TYPES",
".",
"PUBLIC",
":",
"return",
"self",
".",
"public_members",
"elif",
"access",
"==",
"ACCESS_TYPES",
".",
"PROTECTED",
":",
"return",
"self",
"."... | returns list of members according to access type
If access equals to None, then returned list will contain all members.
You should not modify the list content, otherwise different
optimization data will stop work and may to give you wrong results.
:param access: describes desired membe... | [
"returns",
"list",
"of",
"members",
"according",
"to",
"access",
"type"
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/class_declaration.py#L363-L387 | train |
gccxml/pygccxml | pygccxml/declarations/class_declaration.py | class_t.adopt_declaration | def adopt_declaration(self, decl, access):
"""adds new declaration to the class
:param decl: reference to a :class:`declaration_t`
:param access: member access type
:type access: :class:ACCESS_TYPES
"""
if access == ACCESS_TYPES.PUBLIC:
self.public_members.a... | python | def adopt_declaration(self, decl, access):
"""adds new declaration to the class
:param decl: reference to a :class:`declaration_t`
:param access: member access type
:type access: :class:ACCESS_TYPES
"""
if access == ACCESS_TYPES.PUBLIC:
self.public_members.a... | [
"def",
"adopt_declaration",
"(",
"self",
",",
"decl",
",",
"access",
")",
":",
"if",
"access",
"==",
"ACCESS_TYPES",
".",
"PUBLIC",
":",
"self",
".",
"public_members",
".",
"append",
"(",
"decl",
")",
"elif",
"access",
"==",
"ACCESS_TYPES",
".",
"PROTECTED... | adds new declaration to the class
:param decl: reference to a :class:`declaration_t`
:param access: member access type
:type access: :class:ACCESS_TYPES | [
"adds",
"new",
"declaration",
"to",
"the",
"class"
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/class_declaration.py#L389-L407 | train |
gccxml/pygccxml | pygccxml/declarations/class_declaration.py | class_t.remove_declaration | def remove_declaration(self, decl):
"""
removes decl from members list
:param decl: declaration to be removed
:type decl: :class:`declaration_t`
"""
access_type = self.find_out_member_access_type(decl)
if access_type == ACCESS_TYPES.PUBLIC:
containe... | python | def remove_declaration(self, decl):
"""
removes decl from members list
:param decl: declaration to be removed
:type decl: :class:`declaration_t`
"""
access_type = self.find_out_member_access_type(decl)
if access_type == ACCESS_TYPES.PUBLIC:
containe... | [
"def",
"remove_declaration",
"(",
"self",
",",
"decl",
")",
":",
"access_type",
"=",
"self",
".",
"find_out_member_access_type",
"(",
"decl",
")",
"if",
"access_type",
"==",
"ACCESS_TYPES",
".",
"PUBLIC",
":",
"container",
"=",
"self",
".",
"public_members",
"... | removes decl from members list
:param decl: declaration to be removed
:type decl: :class:`declaration_t` | [
"removes",
"decl",
"from",
"members",
"list"
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/class_declaration.py#L409-L425 | train |
gccxml/pygccxml | pygccxml/declarations/class_declaration.py | class_t.find_out_member_access_type | def find_out_member_access_type(self, member):
"""
returns member access type
:param member: member of the class
:type member: :class:`declaration_t`
:rtype: :class:ACCESS_TYPES
"""
assert member.parent is self
if not member.cache.access_type:
... | python | def find_out_member_access_type(self, member):
"""
returns member access type
:param member: member of the class
:type member: :class:`declaration_t`
:rtype: :class:ACCESS_TYPES
"""
assert member.parent is self
if not member.cache.access_type:
... | [
"def",
"find_out_member_access_type",
"(",
"self",
",",
"member",
")",
":",
"assert",
"member",
".",
"parent",
"is",
"self",
"if",
"not",
"member",
".",
"cache",
".",
"access_type",
":",
"if",
"member",
"in",
"self",
".",
"public_members",
":",
"access_type"... | returns member access type
:param member: member of the class
:type member: :class:`declaration_t`
:rtype: :class:ACCESS_TYPES | [
"returns",
"member",
"access",
"type"
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/class_declaration.py#L427-L450 | train |
gccxml/pygccxml | pygccxml/declarations/class_declaration.py | class_t.top_class | def top_class(self):
"""reference to a parent class, which contains this class and defined
within a namespace
if this class is defined under a namespace, self will be returned"""
curr = self
parent = self.parent
while isinstance(parent, class_t):
curr = paren... | python | def top_class(self):
"""reference to a parent class, which contains this class and defined
within a namespace
if this class is defined under a namespace, self will be returned"""
curr = self
parent = self.parent
while isinstance(parent, class_t):
curr = paren... | [
"def",
"top_class",
"(",
"self",
")",
":",
"curr",
"=",
"self",
"parent",
"=",
"self",
".",
"parent",
"while",
"isinstance",
"(",
"parent",
",",
"class_t",
")",
":",
"curr",
"=",
"parent",
"parent",
"=",
"parent",
".",
"parent",
"return",
"curr"
] | reference to a parent class, which contains this class and defined
within a namespace
if this class is defined under a namespace, self will be returned | [
"reference",
"to",
"a",
"parent",
"class",
"which",
"contains",
"this",
"class",
"and",
"defined",
"within",
"a",
"namespace"
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/class_declaration.py#L494-L504 | train |
gccxml/pygccxml | pygccxml/declarations/enumeration.py | enumeration_t.append_value | def append_value(self, valuename, valuenum=None):
"""Append another enumeration value to the `enum`.
The numeric value may be None in which case it is automatically
determined by increasing the value of the last item.
When the 'values' attribute is accessed the resulting list will be i... | python | def append_value(self, valuename, valuenum=None):
"""Append another enumeration value to the `enum`.
The numeric value may be None in which case it is automatically
determined by increasing the value of the last item.
When the 'values' attribute is accessed the resulting list will be i... | [
"def",
"append_value",
"(",
"self",
",",
"valuename",
",",
"valuenum",
"=",
"None",
")",
":",
"if",
"valuenum",
"is",
"None",
":",
"if",
"not",
"self",
".",
"_values",
":",
"valuenum",
"=",
"0",
"else",
":",
"valuenum",
"=",
"self",
".",
"_values",
"... | Append another enumeration value to the `enum`.
The numeric value may be None in which case it is automatically
determined by increasing the value of the last item.
When the 'values' attribute is accessed the resulting list will be in
the same order as append_value() was called.
... | [
"Append",
"another",
"enumeration",
"value",
"to",
"the",
"enum",
"."
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/enumeration.py#L92-L114 | train |
gccxml/pygccxml | pygccxml/declarations/enumeration.py | enumeration_t.has_value_name | def has_value_name(self, name):
"""Check if this `enum` has a particular name among its values.
:param name: Enumeration value name
:type name: str
:rtype: True if there is an enumeration value with the given name
"""
for val, _ in self._values:
if val == nam... | python | def has_value_name(self, name):
"""Check if this `enum` has a particular name among its values.
:param name: Enumeration value name
:type name: str
:rtype: True if there is an enumeration value with the given name
"""
for val, _ in self._values:
if val == nam... | [
"def",
"has_value_name",
"(",
"self",
",",
"name",
")",
":",
"for",
"val",
",",
"_",
"in",
"self",
".",
"_values",
":",
"if",
"val",
"==",
"name",
":",
"return",
"True",
"return",
"False"
] | Check if this `enum` has a particular name among its values.
:param name: Enumeration value name
:type name: str
:rtype: True if there is an enumeration value with the given name | [
"Check",
"if",
"this",
"enum",
"has",
"a",
"particular",
"name",
"among",
"its",
"values",
"."
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/enumeration.py#L116-L126 | train |
gccxml/pygccxml | pygccxml/parser/patcher.py | update_unnamed_class | def update_unnamed_class(decls):
"""
Adds name to class_t declarations.
If CastXML is being used, the type definitions with an unnamed
class/struct are split across two nodes in the XML tree. For example,
typedef struct {} cls;
produces
<Struct id="_7" name="" context="_1" .../>
... | python | def update_unnamed_class(decls):
"""
Adds name to class_t declarations.
If CastXML is being used, the type definitions with an unnamed
class/struct are split across two nodes in the XML tree. For example,
typedef struct {} cls;
produces
<Struct id="_7" name="" context="_1" .../>
... | [
"def",
"update_unnamed_class",
"(",
"decls",
")",
":",
"for",
"decl",
"in",
"decls",
":",
"if",
"isinstance",
"(",
"decl",
",",
"declarations",
".",
"typedef_t",
")",
":",
"referent",
"=",
"decl",
".",
"decl_type",
"if",
"isinstance",
"(",
"referent",
",",... | Adds name to class_t declarations.
If CastXML is being used, the type definitions with an unnamed
class/struct are split across two nodes in the XML tree. For example,
typedef struct {} cls;
produces
<Struct id="_7" name="" context="_1" .../>
<Typedef id="_8" name="cls" type="_7"... | [
"Adds",
"name",
"to",
"class_t",
"declarations",
"."
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/parser/patcher.py#L266-L305 | train |
gccxml/pygccxml | pygccxml/parser/project_reader.py | project_reader_t.get_os_file_names | def get_os_file_names(files):
"""
returns file names
:param files: list of strings and\\or :class:`file_configuration_t`
instances.
:type files: list
"""
fnames = []
for f in files:
if utils.is_str(f):
fnames.app... | python | def get_os_file_names(files):
"""
returns file names
:param files: list of strings and\\or :class:`file_configuration_t`
instances.
:type files: list
"""
fnames = []
for f in files:
if utils.is_str(f):
fnames.app... | [
"def",
"get_os_file_names",
"(",
"files",
")",
":",
"fnames",
"=",
"[",
"]",
"for",
"f",
"in",
"files",
":",
"if",
"utils",
".",
"is_str",
"(",
"f",
")",
":",
"fnames",
".",
"append",
"(",
"f",
")",
"elif",
"isinstance",
"(",
"f",
",",
"file_config... | returns file names
:param files: list of strings and\\or :class:`file_configuration_t`
instances.
:type files: list | [
"returns",
"file",
"names"
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/parser/project_reader.py#L213-L234 | train |
gccxml/pygccxml | pygccxml/parser/project_reader.py | project_reader_t.read_files | def read_files(
self,
files,
compilation_mode=COMPILATION_MODE.FILE_BY_FILE):
"""
parses a set of files
:param files: list of strings and\\or :class:`file_configuration_t`
instances.
:type files: list
:param compilation_... | python | def read_files(
self,
files,
compilation_mode=COMPILATION_MODE.FILE_BY_FILE):
"""
parses a set of files
:param files: list of strings and\\or :class:`file_configuration_t`
instances.
:type files: list
:param compilation_... | [
"def",
"read_files",
"(",
"self",
",",
"files",
",",
"compilation_mode",
"=",
"COMPILATION_MODE",
".",
"FILE_BY_FILE",
")",
":",
"if",
"compilation_mode",
"==",
"COMPILATION_MODE",
".",
"ALL_AT_ONCE",
"and",
"len",
"(",
"files",
")",
"==",
"len",
"(",
"self",
... | parses a set of files
:param files: list of strings and\\or :class:`file_configuration_t`
instances.
:type files: list
:param compilation_mode: determines whether the files are parsed
individually or as one single chunk
:type compi... | [
"parses",
"a",
"set",
"of",
"files"
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/parser/project_reader.py#L236-L264 | train |
gccxml/pygccxml | pygccxml/parser/project_reader.py | project_reader_t.read_xml | def read_xml(self, file_configuration):
"""parses C++ code, defined on the file_configurations and returns
GCCXML generated file content"""
xml_file_path = None
delete_xml_file = True
fc = file_configuration
reader = source_reader.source_reader_t(
self.__conf... | python | def read_xml(self, file_configuration):
"""parses C++ code, defined on the file_configurations and returns
GCCXML generated file content"""
xml_file_path = None
delete_xml_file = True
fc = file_configuration
reader = source_reader.source_reader_t(
self.__conf... | [
"def",
"read_xml",
"(",
"self",
",",
"file_configuration",
")",
":",
"xml_file_path",
"=",
"None",
"delete_xml_file",
"=",
"True",
"fc",
"=",
"file_configuration",
"reader",
"=",
"source_reader",
".",
"source_reader_t",
"(",
"self",
".",
"__config",
",",
"None",... | parses C++ code, defined on the file_configurations and returns
GCCXML generated file content | [
"parses",
"C",
"++",
"code",
"defined",
"on",
"the",
"file_configurations",
"and",
"returns",
"GCCXML",
"generated",
"file",
"content"
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/parser/project_reader.py#L373-L417 | train |
gccxml/pygccxml | pygccxml/declarations/dependencies.py | get_dependencies_from_decl | def get_dependencies_from_decl(decl, recursive=True):
"""
Returns the list of all types and declarations the declaration depends on.
"""
result = []
if isinstance(decl, typedef.typedef_t) or \
isinstance(decl, variable.variable_t):
return [dependency_info_t(decl, decl.decl_type)... | python | def get_dependencies_from_decl(decl, recursive=True):
"""
Returns the list of all types and declarations the declaration depends on.
"""
result = []
if isinstance(decl, typedef.typedef_t) or \
isinstance(decl, variable.variable_t):
return [dependency_info_t(decl, decl.decl_type)... | [
"def",
"get_dependencies_from_decl",
"(",
"decl",
",",
"recursive",
"=",
"True",
")",
":",
"result",
"=",
"[",
"]",
"if",
"isinstance",
"(",
"decl",
",",
"typedef",
".",
"typedef_t",
")",
"or",
"isinstance",
"(",
"decl",
",",
"variable",
".",
"variable_t",... | Returns the list of all types and declarations the declaration depends on. | [
"Returns",
"the",
"list",
"of",
"all",
"types",
"and",
"declarations",
"the",
"declaration",
"depends",
"on",
"."
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/dependencies.py#L16-L53 | train |
gccxml/pygccxml | pygccxml/declarations/container_traits.py | find_container_traits | def find_container_traits(cls_or_string):
"""
Find the container traits type of a declaration.
Args:
cls_or_string (str | declarations.declaration_t): a string
Returns:
declarations.container_traits: a container traits
"""
if utils.is_str(cls_or_string):
if not templat... | python | def find_container_traits(cls_or_string):
"""
Find the container traits type of a declaration.
Args:
cls_or_string (str | declarations.declaration_t): a string
Returns:
declarations.container_traits: a container traits
"""
if utils.is_str(cls_or_string):
if not templat... | [
"def",
"find_container_traits",
"(",
"cls_or_string",
")",
":",
"if",
"utils",
".",
"is_str",
"(",
"cls_or_string",
")",
":",
"if",
"not",
"templates",
".",
"is_instantiation",
"(",
"cls_or_string",
")",
":",
"return",
"None",
"name",
"=",
"templates",
".",
... | Find the container traits type of a declaration.
Args:
cls_or_string (str | declarations.declaration_t): a string
Returns:
declarations.container_traits: a container traits | [
"Find",
"the",
"container",
"traits",
"type",
"of",
"a",
"declaration",
"."
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/container_traits.py#L697-L732 | train |
gccxml/pygccxml | pygccxml/declarations/container_traits.py | container_traits_impl_t.get_container_or_none | def get_container_or_none(self, type_):
"""
Returns reference to the class declaration or None.
"""
type_ = type_traits.remove_alias(type_)
type_ = type_traits.remove_cv(type_)
utils.loggers.queries_engine.debug(
"Container traits: cleaned up search %s", ty... | python | def get_container_or_none(self, type_):
"""
Returns reference to the class declaration or None.
"""
type_ = type_traits.remove_alias(type_)
type_ = type_traits.remove_cv(type_)
utils.loggers.queries_engine.debug(
"Container traits: cleaned up search %s", ty... | [
"def",
"get_container_or_none",
"(",
"self",
",",
"type_",
")",
":",
"type_",
"=",
"type_traits",
".",
"remove_alias",
"(",
"type_",
")",
"type_",
"=",
"type_traits",
".",
"remove_cv",
"(",
"type_",
")",
"utils",
".",
"loggers",
".",
"queries_engine",
".",
... | Returns reference to the class declaration or None. | [
"Returns",
"reference",
"to",
"the",
"class",
"declaration",
"or",
"None",
"."
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/container_traits.py#L375-L430 | train |
gccxml/pygccxml | pygccxml/declarations/container_traits.py | container_traits_impl_t.class_declaration | def class_declaration(self, type_):
"""
Returns reference to the class declaration.
"""
utils.loggers.queries_engine.debug(
"Container traits: searching class declaration for %s", type_)
cls_declaration = self.get_container_or_none(type_)
if not cls_declara... | python | def class_declaration(self, type_):
"""
Returns reference to the class declaration.
"""
utils.loggers.queries_engine.debug(
"Container traits: searching class declaration for %s", type_)
cls_declaration = self.get_container_or_none(type_)
if not cls_declara... | [
"def",
"class_declaration",
"(",
"self",
",",
"type_",
")",
":",
"utils",
".",
"loggers",
".",
"queries_engine",
".",
"debug",
"(",
"\"Container traits: searching class declaration for %s\"",
",",
"type_",
")",
"cls_declaration",
"=",
"self",
".",
"get_container_or_no... | Returns reference to the class declaration. | [
"Returns",
"reference",
"to",
"the",
"class",
"declaration",
"."
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/container_traits.py#L440-L454 | train |
gccxml/pygccxml | pygccxml/declarations/container_traits.py | container_traits_impl_t.element_type | def element_type(self, type_):
"""returns reference to the class value\\mapped type declaration"""
return self.__find_xxx_type(
type_,
self.element_type_index,
self.element_type_typedef,
'container_element_type') | python | def element_type(self, type_):
"""returns reference to the class value\\mapped type declaration"""
return self.__find_xxx_type(
type_,
self.element_type_index,
self.element_type_typedef,
'container_element_type') | [
"def",
"element_type",
"(",
"self",
",",
"type_",
")",
":",
"return",
"self",
".",
"__find_xxx_type",
"(",
"type_",
",",
"self",
".",
"element_type_index",
",",
"self",
".",
"element_type_typedef",
",",
"'container_element_type'",
")"
] | returns reference to the class value\\mapped type declaration | [
"returns",
"reference",
"to",
"the",
"class",
"value",
"\\\\",
"mapped",
"type",
"declaration"
] | 2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e | https://github.com/gccxml/pygccxml/blob/2b1efbb9e37ceb2ae925c7f3ce1570f476db9e1e/pygccxml/declarations/container_traits.py#L488-L494 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.