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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
eonpatapon/contrail-api-cli | contrail_api_cli/utils.py | continue_prompt | def continue_prompt(message=""):
"""Prompt the user to continue or not
Returns True when the user type Yes.
:param message: message to display
:type message: str
:rtype: bool
"""
answer = False
message = message + "\n'Yes' or 'No' to continue: "
while answer not in ('Yes', 'No'):
... | python | def continue_prompt(message=""):
"""Prompt the user to continue or not
Returns True when the user type Yes.
:param message: message to display
:type message: str
:rtype: bool
"""
answer = False
message = message + "\n'Yes' or 'No' to continue: "
while answer not in ('Yes', 'No'):
... | [
"def",
"continue_prompt",
"(",
"message",
"=",
"\"\"",
")",
":",
"answer",
"=",
"False",
"message",
"=",
"message",
"+",
"\"\\n'Yes' or 'No' to continue: \"",
"while",
"answer",
"not",
"in",
"(",
"'Yes'",
",",
"'No'",
")",
":",
"answer",
"=",
"prompt",
"(",
... | Prompt the user to continue or not
Returns True when the user type Yes.
:param message: message to display
:type message: str
:rtype: bool | [
"Prompt",
"the",
"user",
"to",
"continue",
"or",
"not"
] | 1571bf523fa054f3d6bf83dba43a224fea173a73 | https://github.com/eonpatapon/contrail-api-cli/blob/1571bf523fa054f3d6bf83dba43a224fea173a73/contrail_api_cli/utils.py#L216-L236 | train |
eonpatapon/contrail-api-cli | contrail_api_cli/utils.py | printo | def printo(msg, encoding=None, errors='replace', std_type='stdout'):
"""Write msg on stdout. If no encoding is specified
the detected encoding of stdout is used. If the encoding
can't encode some chars they are replaced by '?'
:param msg: message
:type msg: unicode on python2 | str on python3
"... | python | def printo(msg, encoding=None, errors='replace', std_type='stdout'):
"""Write msg on stdout. If no encoding is specified
the detected encoding of stdout is used. If the encoding
can't encode some chars they are replaced by '?'
:param msg: message
:type msg: unicode on python2 | str on python3
"... | [
"def",
"printo",
"(",
"msg",
",",
"encoding",
"=",
"None",
",",
"errors",
"=",
"'replace'",
",",
"std_type",
"=",
"'stdout'",
")",
":",
"std",
"=",
"getattr",
"(",
"sys",
",",
"std_type",
",",
"sys",
".",
"stdout",
")",
"if",
"encoding",
"is",
"None"... | Write msg on stdout. If no encoding is specified
the detected encoding of stdout is used. If the encoding
can't encode some chars they are replaced by '?'
:param msg: message
:type msg: unicode on python2 | str on python3 | [
"Write",
"msg",
"on",
"stdout",
".",
"If",
"no",
"encoding",
"is",
"specified",
"the",
"detected",
"encoding",
"of",
"stdout",
"is",
"used",
".",
"If",
"the",
"encoding",
"can",
"t",
"encode",
"some",
"chars",
"they",
"are",
"replaced",
"by",
"?"
] | 1571bf523fa054f3d6bf83dba43a224fea173a73 | https://github.com/eonpatapon/contrail-api-cli/blob/1571bf523fa054f3d6bf83dba43a224fea173a73/contrail_api_cli/utils.py#L281-L304 | train |
eonpatapon/contrail-api-cli | contrail_api_cli/utils.py | format_tree | def format_tree(tree):
"""Format a python tree structure
Given the python tree::
tree = {
'node': ['ROOT', 'This is the root of the tree'],
'childs': [{
'node': 'A1',
'childs': [{
'node': 'B1',
'childs': [{... | python | def format_tree(tree):
"""Format a python tree structure
Given the python tree::
tree = {
'node': ['ROOT', 'This is the root of the tree'],
'childs': [{
'node': 'A1',
'childs': [{
'node': 'B1',
'childs': [{... | [
"def",
"format_tree",
"(",
"tree",
")",
":",
"def",
"_traverse_tree",
"(",
"tree",
",",
"parents",
"=",
"None",
")",
":",
"tree",
"[",
"'parents'",
"]",
"=",
"parents",
"childs",
"=",
"tree",
".",
"get",
"(",
"'childs'",
",",
"[",
"]",
")",
"nb_child... | Format a python tree structure
Given the python tree::
tree = {
'node': ['ROOT', 'This is the root of the tree'],
'childs': [{
'node': 'A1',
'childs': [{
'node': 'B1',
'childs': [{
'node... | [
"Format",
"a",
"python",
"tree",
"structure"
] | 1571bf523fa054f3d6bf83dba43a224fea173a73 | https://github.com/eonpatapon/contrail-api-cli/blob/1571bf523fa054f3d6bf83dba43a224fea173a73/contrail_api_cli/utils.py#L345-L434 | train |
eonpatapon/contrail-api-cli | contrail_api_cli/utils.py | parallel_map | def parallel_map(func, iterable, args=None, kwargs=None, workers=None):
"""Map func on a list using gevent greenlets.
:param func: function applied on iterable elements
:type func: function
:param iterable: elements to map the function over
:type iterable: iterable
:param args: arguments of fun... | python | def parallel_map(func, iterable, args=None, kwargs=None, workers=None):
"""Map func on a list using gevent greenlets.
:param func: function applied on iterable elements
:type func: function
:param iterable: elements to map the function over
:type iterable: iterable
:param args: arguments of fun... | [
"def",
"parallel_map",
"(",
"func",
",",
"iterable",
",",
"args",
"=",
"None",
",",
"kwargs",
"=",
"None",
",",
"workers",
"=",
"None",
")",
":",
"if",
"args",
"is",
"None",
":",
"args",
"=",
"(",
")",
"if",
"kwargs",
"is",
"None",
":",
"kwargs",
... | Map func on a list using gevent greenlets.
:param func: function applied on iterable elements
:type func: function
:param iterable: elements to map the function over
:type iterable: iterable
:param args: arguments of func
:type args: tuple
:param kwargs: keyword arguments of func
:type ... | [
"Map",
"func",
"on",
"a",
"list",
"using",
"gevent",
"greenlets",
"."
] | 1571bf523fa054f3d6bf83dba43a224fea173a73 | https://github.com/eonpatapon/contrail-api-cli/blob/1571bf523fa054f3d6bf83dba43a224fea173a73/contrail_api_cli/utils.py#L437-L468 | train |
crm416/semantic | semantic/numbers.py | NumberService.parse | def parse(self, words):
"""A general method for parsing word-representations of numbers.
Supports floats and integers.
Args:
words (str): Description of an arbitrary number.
Returns:
A double representation of the words.
"""
def exact(words):
... | python | def parse(self, words):
"""A general method for parsing word-representations of numbers.
Supports floats and integers.
Args:
words (str): Description of an arbitrary number.
Returns:
A double representation of the words.
"""
def exact(words):
... | [
"def",
"parse",
"(",
"self",
",",
"words",
")",
":",
"def",
"exact",
"(",
"words",
")",
":",
"try",
":",
"return",
"float",
"(",
"words",
")",
"except",
":",
"return",
"None",
"guess",
"=",
"exact",
"(",
"words",
")",
"if",
"guess",
"is",
"not",
... | A general method for parsing word-representations of numbers.
Supports floats and integers.
Args:
words (str): Description of an arbitrary number.
Returns:
A double representation of the words. | [
"A",
"general",
"method",
"for",
"parsing",
"word",
"-",
"representations",
"of",
"numbers",
".",
"Supports",
"floats",
"and",
"integers",
"."
] | 46deb8fefb3ea58aad2fedc8d0d62f3ee254b8fe | https://github.com/crm416/semantic/blob/46deb8fefb3ea58aad2fedc8d0d62f3ee254b8fe/semantic/numbers.py#L91-L122 | train |
crm416/semantic | semantic/numbers.py | NumberService.parseFloat | def parseFloat(self, words):
"""Convert a floating-point number described in words to a double.
Supports two kinds of descriptions: those with a 'point' (e.g.,
"one point two five") and those with a fraction (e.g., "one and
a quarter").
Args:
words (str): Descriptio... | python | def parseFloat(self, words):
"""Convert a floating-point number described in words to a double.
Supports two kinds of descriptions: those with a 'point' (e.g.,
"one point two five") and those with a fraction (e.g., "one and
a quarter").
Args:
words (str): Descriptio... | [
"def",
"parseFloat",
"(",
"self",
",",
"words",
")",
":",
"def",
"pointFloat",
"(",
"words",
")",
":",
"m",
"=",
"re",
".",
"search",
"(",
"r'(.*) point (.*)'",
",",
"words",
")",
"if",
"m",
":",
"whole",
"=",
"m",
".",
"group",
"(",
"1",
")",
"f... | Convert a floating-point number described in words to a double.
Supports two kinds of descriptions: those with a 'point' (e.g.,
"one point two five") and those with a fraction (e.g., "one and
a quarter").
Args:
words (str): Description of the floating-point number.
... | [
"Convert",
"a",
"floating",
"-",
"point",
"number",
"described",
"in",
"words",
"to",
"a",
"double",
"."
] | 46deb8fefb3ea58aad2fedc8d0d62f3ee254b8fe | https://github.com/crm416/semantic/blob/46deb8fefb3ea58aad2fedc8d0d62f3ee254b8fe/semantic/numbers.py#L124-L192 | train |
crm416/semantic | semantic/numbers.py | NumberService.parseInt | def parseInt(self, words):
"""Parses words to the integer they describe.
Args:
words (str): Description of the integer.
Returns:
An integer representation of the words.
"""
# Remove 'and', case-sensitivity
words = words.replace(" and ", " ").lowe... | python | def parseInt(self, words):
"""Parses words to the integer they describe.
Args:
words (str): Description of the integer.
Returns:
An integer representation of the words.
"""
# Remove 'and', case-sensitivity
words = words.replace(" and ", " ").lowe... | [
"def",
"parseInt",
"(",
"self",
",",
"words",
")",
":",
"words",
"=",
"words",
".",
"replace",
"(",
"\" and \"",
",",
"\" \"",
")",
".",
"lower",
"(",
")",
"words",
"=",
"re",
".",
"sub",
"(",
"r'(\\b)a(\\b)'",
",",
"'\\g<1>one\\g<2>'",
",",
"words",
... | Parses words to the integer they describe.
Args:
words (str): Description of the integer.
Returns:
An integer representation of the words. | [
"Parses",
"words",
"to",
"the",
"integer",
"they",
"describe",
"."
] | 46deb8fefb3ea58aad2fedc8d0d62f3ee254b8fe | https://github.com/crm416/semantic/blob/46deb8fefb3ea58aad2fedc8d0d62f3ee254b8fe/semantic/numbers.py#L194-L232 | train |
crm416/semantic | semantic/numbers.py | NumberService.parseMagnitude | def parseMagnitude(m):
"""Parses a number m into a human-ready string representation.
For example, crops off floats if they're too accurate.
Arguments:
m (float): Floating-point number to be cleaned.
Returns:
Human-ready string description of the number.
... | python | def parseMagnitude(m):
"""Parses a number m into a human-ready string representation.
For example, crops off floats if they're too accurate.
Arguments:
m (float): Floating-point number to be cleaned.
Returns:
Human-ready string description of the number.
... | [
"def",
"parseMagnitude",
"(",
"m",
")",
":",
"m",
"=",
"NumberService",
"(",
")",
".",
"parse",
"(",
"m",
")",
"def",
"toDecimalPrecision",
"(",
"n",
",",
"k",
")",
":",
"return",
"float",
"(",
"\"%.*f\"",
"%",
"(",
"k",
",",
"round",
"(",
"n",
"... | Parses a number m into a human-ready string representation.
For example, crops off floats if they're too accurate.
Arguments:
m (float): Floating-point number to be cleaned.
Returns:
Human-ready string description of the number. | [
"Parses",
"a",
"number",
"m",
"into",
"a",
"human",
"-",
"ready",
"string",
"representation",
".",
"For",
"example",
"crops",
"off",
"floats",
"if",
"they",
"re",
"too",
"accurate",
"."
] | 46deb8fefb3ea58aad2fedc8d0d62f3ee254b8fe | https://github.com/crm416/semantic/blob/46deb8fefb3ea58aad2fedc8d0d62f3ee254b8fe/semantic/numbers.py#L242-L282 | train |
go-macaroon-bakery/py-macaroon-bakery | macaroonbakery/bakery/_keys.py | PrivateKey.serialize | def serialize(self, raw=False):
'''Encode the private part of the key in a base64 format by default,
but when raw is True it will return hex encoded bytes.
@return: bytes
'''
if raw:
return self._key.encode()
return self._key.encode(nacl.encoding.Base64Encoder... | python | def serialize(self, raw=False):
'''Encode the private part of the key in a base64 format by default,
but when raw is True it will return hex encoded bytes.
@return: bytes
'''
if raw:
return self._key.encode()
return self._key.encode(nacl.encoding.Base64Encoder... | [
"def",
"serialize",
"(",
"self",
",",
"raw",
"=",
"False",
")",
":",
"if",
"raw",
":",
"return",
"self",
".",
"_key",
".",
"encode",
"(",
")",
"return",
"self",
".",
"_key",
".",
"encode",
"(",
"nacl",
".",
"encoding",
".",
"Base64Encoder",
")"
] | Encode the private part of the key in a base64 format by default,
but when raw is True it will return hex encoded bytes.
@return: bytes | [
"Encode",
"the",
"private",
"part",
"of",
"the",
"key",
"in",
"a",
"base64",
"format",
"by",
"default",
"but",
"when",
"raw",
"is",
"True",
"it",
"will",
"return",
"hex",
"encoded",
"bytes",
"."
] | 63ce1ef1dabe816eb8aaec48fbb46761c34ddf77 | https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/bakery/_keys.py#L37-L44 | train |
swevm/scaleio-py | scaleiopy/api/scaleio/common/connection.py | Connection._do_get | def _do_get(self, url, **kwargs):
"""
Convenient method for GET requests
Returns http request status value from a POST request
"""
#TODO:
# Add error handling. Check for HTTP status here would be much more conveinent than in each calling method
scaleioapi_post_hea... | python | def _do_get(self, url, **kwargs):
"""
Convenient method for GET requests
Returns http request status value from a POST request
"""
#TODO:
# Add error handling. Check for HTTP status here would be much more conveinent than in each calling method
scaleioapi_post_hea... | [
"def",
"_do_get",
"(",
"self",
",",
"url",
",",
"**",
"kwargs",
")",
":",
"scaleioapi_post_headers",
"=",
"{",
"'Content-type'",
":",
"'application/json'",
",",
"'Version'",
":",
"'1.0'",
"}",
"try",
":",
"response",
"=",
"self",
".",
"_session",
".",
"get... | Convenient method for GET requests
Returns http request status value from a POST request | [
"Convenient",
"method",
"for",
"GET",
"requests",
"Returns",
"http",
"request",
"status",
"value",
"from",
"a",
"POST",
"request"
] | d043a0137cb925987fd5c895a3210968ce1d9028 | https://github.com/swevm/scaleio-py/blob/d043a0137cb925987fd5c895a3210968ce1d9028/scaleiopy/api/scaleio/common/connection.py#L104-L125 | train |
swevm/scaleio-py | scaleiopy/api/scaleio/common/connection.py | Connection._do_post | def _do_post(self, url, **kwargs):
"""
Convenient method for POST requests
Returns http request status value from a POST request
"""
#TODO:
# Add error handling. Check for HTTP status here would be much more conveinent than in each calling method
scaleioapi_post_h... | python | def _do_post(self, url, **kwargs):
"""
Convenient method for POST requests
Returns http request status value from a POST request
"""
#TODO:
# Add error handling. Check for HTTP status here would be much more conveinent than in each calling method
scaleioapi_post_h... | [
"def",
"_do_post",
"(",
"self",
",",
"url",
",",
"**",
"kwargs",
")",
":",
"scaleioapi_post_headers",
"=",
"{",
"'Content-type'",
":",
"'application/json'",
",",
"'Version'",
":",
"'1.0'",
"}",
"try",
":",
"response",
"=",
"self",
".",
"_session",
".",
"po... | Convenient method for POST requests
Returns http request status value from a POST request | [
"Convenient",
"method",
"for",
"POST",
"requests",
"Returns",
"http",
"request",
"status",
"value",
"from",
"a",
"POST",
"request"
] | d043a0137cb925987fd5c895a3210968ce1d9028 | https://github.com/swevm/scaleio-py/blob/d043a0137cb925987fd5c895a3210968ce1d9028/scaleiopy/api/scaleio/common/connection.py#L127-L148 | train |
go-macaroon-bakery/py-macaroon-bakery | macaroonbakery/httpbakery/_error.py | discharge_required_response | def discharge_required_response(macaroon, path, cookie_suffix_name,
message=None):
''' Get response content and headers from a discharge macaroons error.
@param macaroon may hold a macaroon that, when discharged, may
allow access to a service.
@param path holds the URL p... | python | def discharge_required_response(macaroon, path, cookie_suffix_name,
message=None):
''' Get response content and headers from a discharge macaroons error.
@param macaroon may hold a macaroon that, when discharged, may
allow access to a service.
@param path holds the URL p... | [
"def",
"discharge_required_response",
"(",
"macaroon",
",",
"path",
",",
"cookie_suffix_name",
",",
"message",
"=",
"None",
")",
":",
"if",
"message",
"is",
"None",
":",
"message",
"=",
"'discharge required'",
"content",
"=",
"json",
".",
"dumps",
"(",
"{",
... | Get response content and headers from a discharge macaroons error.
@param macaroon may hold a macaroon that, when discharged, may
allow access to a service.
@param path holds the URL path to be associated with the macaroon.
The macaroon is potentially valid for all URLs under the given path.
@param... | [
"Get",
"response",
"content",
"and",
"headers",
"from",
"a",
"discharge",
"macaroons",
"error",
"."
] | 63ce1ef1dabe816eb8aaec48fbb46761c34ddf77 | https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/httpbakery/_error.py#L35-L65 | train |
go-macaroon-bakery/py-macaroon-bakery | macaroonbakery/httpbakery/_error.py | request_version | def request_version(req_headers):
''' Determines the bakery protocol version from a client request.
If the protocol cannot be determined, or is invalid, the original version
of the protocol is used. If a later version is found, the latest known
version is used, which is OK because versions are backwardl... | python | def request_version(req_headers):
''' Determines the bakery protocol version from a client request.
If the protocol cannot be determined, or is invalid, the original version
of the protocol is used. If a later version is found, the latest known
version is used, which is OK because versions are backwardl... | [
"def",
"request_version",
"(",
"req_headers",
")",
":",
"vs",
"=",
"req_headers",
".",
"get",
"(",
"BAKERY_PROTOCOL_HEADER",
")",
"if",
"vs",
"is",
"None",
":",
"return",
"bakery",
".",
"VERSION_1",
"try",
":",
"x",
"=",
"int",
"(",
"vs",
")",
"except",
... | Determines the bakery protocol version from a client request.
If the protocol cannot be determined, or is invalid, the original version
of the protocol is used. If a later version is found, the latest known
version is used, which is OK because versions are backwardly compatible.
@param req_headers: the... | [
"Determines",
"the",
"bakery",
"protocol",
"version",
"from",
"a",
"client",
"request",
".",
"If",
"the",
"protocol",
"cannot",
"be",
"determined",
"or",
"is",
"invalid",
"the",
"original",
"version",
"of",
"the",
"protocol",
"is",
"used",
".",
"If",
"a",
... | 63ce1ef1dabe816eb8aaec48fbb46761c34ddf77 | https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/httpbakery/_error.py#L75-L97 | train |
go-macaroon-bakery/py-macaroon-bakery | macaroonbakery/httpbakery/_error.py | Error.from_dict | def from_dict(cls, serialized):
'''Create an error from a JSON-deserialized object
@param serialized the object holding the serialized error {dict}
'''
# Some servers return lower case field names for message and code.
# The Go client is tolerant of this, so be similarly tolerant... | python | def from_dict(cls, serialized):
'''Create an error from a JSON-deserialized object
@param serialized the object holding the serialized error {dict}
'''
# Some servers return lower case field names for message and code.
# The Go client is tolerant of this, so be similarly tolerant... | [
"def",
"from_dict",
"(",
"cls",
",",
"serialized",
")",
":",
"def",
"field",
"(",
"name",
")",
":",
"return",
"serialized",
".",
"get",
"(",
"name",
")",
"or",
"serialized",
".",
"get",
"(",
"name",
".",
"lower",
"(",
")",
")",
"return",
"Error",
"... | Create an error from a JSON-deserialized object
@param serialized the object holding the serialized error {dict} | [
"Create",
"an",
"error",
"from",
"a",
"JSON",
"-",
"deserialized",
"object"
] | 63ce1ef1dabe816eb8aaec48fbb46761c34ddf77 | https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/httpbakery/_error.py#L105-L118 | train |
go-macaroon-bakery/py-macaroon-bakery | macaroonbakery/httpbakery/_error.py | Error.interaction_method | def interaction_method(self, kind, x):
''' Checks whether the error is an InteractionRequired error
that implements the method with the given name, and JSON-unmarshals the
method-specific data into x by calling its from_dict method
with the deserialized JSON object.
@param kind T... | python | def interaction_method(self, kind, x):
''' Checks whether the error is an InteractionRequired error
that implements the method with the given name, and JSON-unmarshals the
method-specific data into x by calling its from_dict method
with the deserialized JSON object.
@param kind T... | [
"def",
"interaction_method",
"(",
"self",
",",
"kind",
",",
"x",
")",
":",
"if",
"self",
".",
"info",
"is",
"None",
"or",
"self",
".",
"code",
"!=",
"ERR_INTERACTION_REQUIRED",
":",
"raise",
"InteractionError",
"(",
"'not an interaction-required error (code {})'",... | Checks whether the error is an InteractionRequired error
that implements the method with the given name, and JSON-unmarshals the
method-specific data into x by calling its from_dict method
with the deserialized JSON object.
@param kind The interaction method kind (string).
@param... | [
"Checks",
"whether",
"the",
"error",
"is",
"an",
"InteractionRequired",
"error",
"that",
"implements",
"the",
"method",
"with",
"the",
"given",
"name",
"and",
"JSON",
"-",
"unmarshals",
"the",
"method",
"-",
"specific",
"data",
"into",
"x",
"by",
"calling",
... | 63ce1ef1dabe816eb8aaec48fbb46761c34ddf77 | https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/httpbakery/_error.py#L120-L140 | train |
go-macaroon-bakery/py-macaroon-bakery | macaroonbakery/httpbakery/_error.py | ErrorInfo.from_dict | def from_dict(cls, serialized):
'''Create a new ErrorInfo object from a JSON deserialized
dictionary
@param serialized The JSON object {dict}
@return ErrorInfo object
'''
if serialized is None:
return None
macaroon = serialized.get('Macaroon')
... | python | def from_dict(cls, serialized):
'''Create a new ErrorInfo object from a JSON deserialized
dictionary
@param serialized The JSON object {dict}
@return ErrorInfo object
'''
if serialized is None:
return None
macaroon = serialized.get('Macaroon')
... | [
"def",
"from_dict",
"(",
"cls",
",",
"serialized",
")",
":",
"if",
"serialized",
"is",
"None",
":",
"return",
"None",
"macaroon",
"=",
"serialized",
".",
"get",
"(",
"'Macaroon'",
")",
"if",
"macaroon",
"is",
"not",
"None",
":",
"macaroon",
"=",
"bakery"... | Create a new ErrorInfo object from a JSON deserialized
dictionary
@param serialized The JSON object {dict}
@return ErrorInfo object | [
"Create",
"a",
"new",
"ErrorInfo",
"object",
"from",
"a",
"JSON",
"deserialized",
"dictionary"
] | 63ce1ef1dabe816eb8aaec48fbb46761c34ddf77 | https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/httpbakery/_error.py#L178-L197 | train |
ph4r05/monero-serialize | monero_serialize/xmrobj.py | dump_blob | async def dump_blob(elem, elem_type=None):
"""
Dumps blob message.
Supports both blob and raw value.
:param writer:
:param elem:
:param elem_type:
:param params:
:return:
"""
elem_is_blob = isinstance(elem, x.BlobType)
data = getattr(elem, x.BlobType.DATA_ATTR) if elem_is_bl... | python | async def dump_blob(elem, elem_type=None):
"""
Dumps blob message.
Supports both blob and raw value.
:param writer:
:param elem:
:param elem_type:
:param params:
:return:
"""
elem_is_blob = isinstance(elem, x.BlobType)
data = getattr(elem, x.BlobType.DATA_ATTR) if elem_is_bl... | [
"async",
"def",
"dump_blob",
"(",
"elem",
",",
"elem_type",
"=",
"None",
")",
":",
"elem_is_blob",
"=",
"isinstance",
"(",
"elem",
",",
"x",
".",
"BlobType",
")",
"data",
"=",
"getattr",
"(",
"elem",
",",
"x",
".",
"BlobType",
".",
"DATA_ATTR",
")",
... | Dumps blob message.
Supports both blob and raw value.
:param writer:
:param elem:
:param elem_type:
:param params:
:return: | [
"Dumps",
"blob",
"message",
".",
"Supports",
"both",
"blob",
"and",
"raw",
"value",
"."
] | cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42 | https://github.com/ph4r05/monero-serialize/blob/cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42/monero_serialize/xmrobj.py#L70-L88 | train |
ph4r05/monero-serialize | monero_serialize/xmrobj.py | dump_container | async def dump_container(obj, container, container_type, params=None, field_archiver=None):
"""
Serializes container as popo
:param obj:
:param container:
:param container_type:
:param params:
:param field_archiver:
:return:
"""
field_archiver = field_archiver if field_archiver ... | python | async def dump_container(obj, container, container_type, params=None, field_archiver=None):
"""
Serializes container as popo
:param obj:
:param container:
:param container_type:
:param params:
:param field_archiver:
:return:
"""
field_archiver = field_archiver if field_archiver ... | [
"async",
"def",
"dump_container",
"(",
"obj",
",",
"container",
",",
"container_type",
",",
"params",
"=",
"None",
",",
"field_archiver",
"=",
"None",
")",
":",
"field_archiver",
"=",
"field_archiver",
"if",
"field_archiver",
"else",
"dump_field",
"elem_type",
"... | Serializes container as popo
:param obj:
:param container:
:param container_type:
:param params:
:param field_archiver:
:return: | [
"Serializes",
"container",
"as",
"popo"
] | cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42 | https://github.com/ph4r05/monero-serialize/blob/cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42/monero_serialize/xmrobj.py#L102-L124 | train |
ph4r05/monero-serialize | monero_serialize/xmrobj.py | load_container | async def load_container(obj, container_type, params=None, container=None, field_archiver=None):
"""
Loads container of elements from the object representation. Supports the container ref.
Returns loaded container.
:param reader:
:param container_type:
:param params:
:param container:
:... | python | async def load_container(obj, container_type, params=None, container=None, field_archiver=None):
"""
Loads container of elements from the object representation. Supports the container ref.
Returns loaded container.
:param reader:
:param container_type:
:param params:
:param container:
:... | [
"async",
"def",
"load_container",
"(",
"obj",
",",
"container_type",
",",
"params",
"=",
"None",
",",
"container",
"=",
"None",
",",
"field_archiver",
"=",
"None",
")",
":",
"field_archiver",
"=",
"field_archiver",
"if",
"field_archiver",
"else",
"load_field",
... | Loads container of elements from the object representation. Supports the container ref.
Returns loaded container.
:param reader:
:param container_type:
:param params:
:param container:
:param field_archiver:
:return: | [
"Loads",
"container",
"of",
"elements",
"from",
"the",
"object",
"representation",
".",
"Supports",
"the",
"container",
"ref",
".",
"Returns",
"loaded",
"container",
"."
] | cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42 | https://github.com/ph4r05/monero-serialize/blob/cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42/monero_serialize/xmrobj.py#L127-L155 | train |
ph4r05/monero-serialize | monero_serialize/xmrobj.py | dump_message_field | async def dump_message_field(obj, msg, field, field_archiver=None):
"""
Dumps a message field to the object. Field is defined by the message field specification.
:param obj:
:param msg:
:param field:
:param field_archiver:
:return:
"""
fname, ftype, params = field[0], field[1], fiel... | python | async def dump_message_field(obj, msg, field, field_archiver=None):
"""
Dumps a message field to the object. Field is defined by the message field specification.
:param obj:
:param msg:
:param field:
:param field_archiver:
:return:
"""
fname, ftype, params = field[0], field[1], fiel... | [
"async",
"def",
"dump_message_field",
"(",
"obj",
",",
"msg",
",",
"field",
",",
"field_archiver",
"=",
"None",
")",
":",
"fname",
",",
"ftype",
",",
"params",
"=",
"field",
"[",
"0",
"]",
",",
"field",
"[",
"1",
"]",
",",
"field",
"[",
"2",
":",
... | Dumps a message field to the object. Field is defined by the message field specification.
:param obj:
:param msg:
:param field:
:param field_archiver:
:return: | [
"Dumps",
"a",
"message",
"field",
"to",
"the",
"object",
".",
"Field",
"is",
"defined",
"by",
"the",
"message",
"field",
"specification",
"."
] | cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42 | https://github.com/ph4r05/monero-serialize/blob/cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42/monero_serialize/xmrobj.py#L158-L171 | train |
ph4r05/monero-serialize | monero_serialize/xmrobj.py | load_message_field | async def load_message_field(obj, msg, field, field_archiver=None):
"""
Loads message field from the object. Field is defined by the message field specification.
Returns loaded value, supports field reference.
:param reader:
:param msg:
:param field:
:param field_archiver:
:return:
... | python | async def load_message_field(obj, msg, field, field_archiver=None):
"""
Loads message field from the object. Field is defined by the message field specification.
Returns loaded value, supports field reference.
:param reader:
:param msg:
:param field:
:param field_archiver:
:return:
... | [
"async",
"def",
"load_message_field",
"(",
"obj",
",",
"msg",
",",
"field",
",",
"field_archiver",
"=",
"None",
")",
":",
"fname",
",",
"ftype",
",",
"params",
"=",
"field",
"[",
"0",
"]",
",",
"field",
"[",
"1",
"]",
",",
"field",
"[",
"2",
":",
... | Loads message field from the object. Field is defined by the message field specification.
Returns loaded value, supports field reference.
:param reader:
:param msg:
:param field:
:param field_archiver:
:return: | [
"Loads",
"message",
"field",
"from",
"the",
"object",
".",
"Field",
"is",
"defined",
"by",
"the",
"message",
"field",
"specification",
".",
"Returns",
"loaded",
"value",
"supports",
"field",
"reference",
"."
] | cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42 | https://github.com/ph4r05/monero-serialize/blob/cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42/monero_serialize/xmrobj.py#L174-L187 | train |
ph4r05/monero-serialize | monero_serialize/xmrobj.py | dump_message | async def dump_message(obj, msg, field_archiver=None):
"""
Dumps message to the object.
Returns message popo representation.
:param obj:
:param msg:
:param field_archiver:
:return:
"""
mtype = msg.__class__
fields = mtype.f_specs()
obj = collections.OrderedDict() if obj is ... | python | async def dump_message(obj, msg, field_archiver=None):
"""
Dumps message to the object.
Returns message popo representation.
:param obj:
:param msg:
:param field_archiver:
:return:
"""
mtype = msg.__class__
fields = mtype.f_specs()
obj = collections.OrderedDict() if obj is ... | [
"async",
"def",
"dump_message",
"(",
"obj",
",",
"msg",
",",
"field_archiver",
"=",
"None",
")",
":",
"mtype",
"=",
"msg",
".",
"__class__",
"fields",
"=",
"mtype",
".",
"f_specs",
"(",
")",
"obj",
"=",
"collections",
".",
"OrderedDict",
"(",
")",
"if"... | Dumps message to the object.
Returns message popo representation.
:param obj:
:param msg:
:param field_archiver:
:return: | [
"Dumps",
"message",
"to",
"the",
"object",
".",
"Returns",
"message",
"popo",
"representation",
"."
] | cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42 | https://github.com/ph4r05/monero-serialize/blob/cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42/monero_serialize/xmrobj.py#L190-L206 | train |
ph4r05/monero-serialize | monero_serialize/xmrobj.py | load_message | async def load_message(obj, msg_type, msg=None, field_archiver=None):
"""
Loads message if the given type from the object.
Supports reading directly to existing message.
:param obj:
:param msg_type:
:param msg:
:param field_archiver:
:return:
"""
msg = msg_type() if msg is None ... | python | async def load_message(obj, msg_type, msg=None, field_archiver=None):
"""
Loads message if the given type from the object.
Supports reading directly to existing message.
:param obj:
:param msg_type:
:param msg:
:param field_archiver:
:return:
"""
msg = msg_type() if msg is None ... | [
"async",
"def",
"load_message",
"(",
"obj",
",",
"msg_type",
",",
"msg",
"=",
"None",
",",
"field_archiver",
"=",
"None",
")",
":",
"msg",
"=",
"msg_type",
"(",
")",
"if",
"msg",
"is",
"None",
"else",
"msg",
"fields",
"=",
"msg_type",
".",
"f_specs",
... | Loads message if the given type from the object.
Supports reading directly to existing message.
:param obj:
:param msg_type:
:param msg:
:param field_archiver:
:return: | [
"Loads",
"message",
"if",
"the",
"given",
"type",
"from",
"the",
"object",
".",
"Supports",
"reading",
"directly",
"to",
"existing",
"message",
"."
] | cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42 | https://github.com/ph4r05/monero-serialize/blob/cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42/monero_serialize/xmrobj.py#L209-L226 | train |
ph4r05/monero-serialize | monero_serialize/xmrobj.py | dump_variant | async def dump_variant(obj, elem, elem_type=None, params=None, field_archiver=None):
"""
Transform variant to the popo object representation.
:param obj:
:param elem:
:param elem_type:
:param params:
:param field_archiver:
:return:
"""
field_archiver = field_archiver if field_ar... | python | async def dump_variant(obj, elem, elem_type=None, params=None, field_archiver=None):
"""
Transform variant to the popo object representation.
:param obj:
:param elem:
:param elem_type:
:param params:
:param field_archiver:
:return:
"""
field_archiver = field_archiver if field_ar... | [
"async",
"def",
"dump_variant",
"(",
"obj",
",",
"elem",
",",
"elem_type",
"=",
"None",
",",
"params",
"=",
"None",
",",
"field_archiver",
"=",
"None",
")",
":",
"field_archiver",
"=",
"field_archiver",
"if",
"field_archiver",
"else",
"dump_field",
"if",
"is... | Transform variant to the popo object representation.
:param obj:
:param elem:
:param elem_type:
:param params:
:param field_archiver:
:return: | [
"Transform",
"variant",
"to",
"the",
"popo",
"object",
"representation",
"."
] | cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42 | https://github.com/ph4r05/monero-serialize/blob/cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42/monero_serialize/xmrobj.py#L229-L250 | train |
ph4r05/monero-serialize | monero_serialize/xmrobj.py | dump_field | async def dump_field(obj, elem, elem_type, params=None):
"""
Dumps generic field to the popo object representation, according to the element specification.
General multiplexer.
:param obj:
:param elem:
:param elem_type:
:param params:
:return:
"""
if isinstance(elem, (int, bool)... | python | async def dump_field(obj, elem, elem_type, params=None):
"""
Dumps generic field to the popo object representation, according to the element specification.
General multiplexer.
:param obj:
:param elem:
:param elem_type:
:param params:
:return:
"""
if isinstance(elem, (int, bool)... | [
"async",
"def",
"dump_field",
"(",
"obj",
",",
"elem",
",",
"elem_type",
",",
"params",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"elem",
",",
"(",
"int",
",",
"bool",
")",
")",
"or",
"issubclass",
"(",
"elem_type",
",",
"x",
".",
"UVarintType"... | Dumps generic field to the popo object representation, according to the element specification.
General multiplexer.
:param obj:
:param elem:
:param elem_type:
:param params:
:return: | [
"Dumps",
"generic",
"field",
"to",
"the",
"popo",
"object",
"representation",
"according",
"to",
"the",
"element",
"specification",
".",
"General",
"multiplexer",
"."
] | cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42 | https://github.com/ph4r05/monero-serialize/blob/cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42/monero_serialize/xmrobj.py#L283-L313 | train |
ph4r05/monero-serialize | monero_serialize/xmrobj.py | load_field | async def load_field(obj, elem_type, params=None, elem=None):
"""
Loads a field from the reader, based on the field type specification. Demultiplexer.
:param obj:
:param elem_type:
:param params:
:param elem:
:return:
"""
if issubclass(elem_type, x.UVarintType) or issubclass(elem_ty... | python | async def load_field(obj, elem_type, params=None, elem=None):
"""
Loads a field from the reader, based on the field type specification. Demultiplexer.
:param obj:
:param elem_type:
:param params:
:param elem:
:return:
"""
if issubclass(elem_type, x.UVarintType) or issubclass(elem_ty... | [
"async",
"def",
"load_field",
"(",
"obj",
",",
"elem_type",
",",
"params",
"=",
"None",
",",
"elem",
"=",
"None",
")",
":",
"if",
"issubclass",
"(",
"elem_type",
",",
"x",
".",
"UVarintType",
")",
"or",
"issubclass",
"(",
"elem_type",
",",
"x",
".",
... | Loads a field from the reader, based on the field type specification. Demultiplexer.
:param obj:
:param elem_type:
:param params:
:param elem:
:return: | [
"Loads",
"a",
"field",
"from",
"the",
"reader",
"based",
"on",
"the",
"field",
"type",
"specification",
".",
"Demultiplexer",
"."
] | cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42 | https://github.com/ph4r05/monero-serialize/blob/cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42/monero_serialize/xmrobj.py#L316-L349 | train |
Julian/Seep | seep/core.py | instantiate | def instantiate(data, blueprint):
"""
Instantiate the given data using the blueprinter.
Arguments
---------
blueprint (collections.Mapping):
a blueprint (JSON Schema with Seep properties)
"""
Validator = jsonschema.validators.validator_for(blueprint)
blueprinter = ext... | python | def instantiate(data, blueprint):
"""
Instantiate the given data using the blueprinter.
Arguments
---------
blueprint (collections.Mapping):
a blueprint (JSON Schema with Seep properties)
"""
Validator = jsonschema.validators.validator_for(blueprint)
blueprinter = ext... | [
"def",
"instantiate",
"(",
"data",
",",
"blueprint",
")",
":",
"Validator",
"=",
"jsonschema",
".",
"validators",
".",
"validator_for",
"(",
"blueprint",
")",
"blueprinter",
"=",
"extend",
"(",
"Validator",
")",
"(",
"blueprint",
")",
"return",
"blueprinter",
... | Instantiate the given data using the blueprinter.
Arguments
---------
blueprint (collections.Mapping):
a blueprint (JSON Schema with Seep properties) | [
"Instantiate",
"the",
"given",
"data",
"using",
"the",
"blueprinter",
"."
] | 57b5f391d0e23afb7777293a9002125967a014ad | https://github.com/Julian/Seep/blob/57b5f391d0e23afb7777293a9002125967a014ad/seep/core.py#L35-L49 | train |
dbarsam/python-vsgen | vsgen/__main__.py | main | def main(argv=None):
"""
The entry point of the script.
"""
from vsgen import VSGSuite
from vsgen import VSGLogger
# Special case to use the sys.argv when main called without a list.
if argv is None:
argv = sys.argv
# Initialize the application logger
pylogger = VSGLogger()... | python | def main(argv=None):
"""
The entry point of the script.
"""
from vsgen import VSGSuite
from vsgen import VSGLogger
# Special case to use the sys.argv when main called without a list.
if argv is None:
argv = sys.argv
# Initialize the application logger
pylogger = VSGLogger()... | [
"def",
"main",
"(",
"argv",
"=",
"None",
")",
":",
"from",
"vsgen",
"import",
"VSGSuite",
"from",
"vsgen",
"import",
"VSGLogger",
"if",
"argv",
"is",
"None",
":",
"argv",
"=",
"sys",
".",
"argv",
"pylogger",
"=",
"VSGLogger",
"(",
")",
"args",
"=",
"... | The entry point of the script. | [
"The",
"entry",
"point",
"of",
"the",
"script",
"."
] | 640191bb018a1ff7d7b7a4982e0d3c1a423ba878 | https://github.com/dbarsam/python-vsgen/blob/640191bb018a1ff7d7b7a4982e0d3c1a423ba878/vsgen/__main__.py#L19-L37 | train |
ets-labs/python-domain-models | domain_models/models.py | DomainModelMetaClass.parse_fields | def parse_fields(attributes):
"""Parse model fields."""
return tuple(field.bind_name(name)
for name, field in six.iteritems(attributes)
if isinstance(field, fields.Field)) | python | def parse_fields(attributes):
"""Parse model fields."""
return tuple(field.bind_name(name)
for name, field in six.iteritems(attributes)
if isinstance(field, fields.Field)) | [
"def",
"parse_fields",
"(",
"attributes",
")",
":",
"return",
"tuple",
"(",
"field",
".",
"bind_name",
"(",
"name",
")",
"for",
"name",
",",
"field",
"in",
"six",
".",
"iteritems",
"(",
"attributes",
")",
"if",
"isinstance",
"(",
"field",
",",
"fields",
... | Parse model fields. | [
"Parse",
"model",
"fields",
"."
] | 7de1816ba0338f20fdb3e0f57fad0ffd5bea13f9 | https://github.com/ets-labs/python-domain-models/blob/7de1816ba0338f20fdb3e0f57fad0ffd5bea13f9/domain_models/models.py#L38-L42 | train |
ets-labs/python-domain-models | domain_models/models.py | DomainModelMetaClass.prepare_fields_attribute | def prepare_fields_attribute(attribute_name, attributes, class_name):
"""Prepare model fields attribute."""
attribute = attributes.get(attribute_name)
if not attribute:
attribute = tuple()
elif isinstance(attribute, std_collections.Iterable):
attribute = tuple(att... | python | def prepare_fields_attribute(attribute_name, attributes, class_name):
"""Prepare model fields attribute."""
attribute = attributes.get(attribute_name)
if not attribute:
attribute = tuple()
elif isinstance(attribute, std_collections.Iterable):
attribute = tuple(att... | [
"def",
"prepare_fields_attribute",
"(",
"attribute_name",
",",
"attributes",
",",
"class_name",
")",
":",
"attribute",
"=",
"attributes",
".",
"get",
"(",
"attribute_name",
")",
"if",
"not",
"attribute",
":",
"attribute",
"=",
"tuple",
"(",
")",
"elif",
"isins... | Prepare model fields attribute. | [
"Prepare",
"model",
"fields",
"attribute",
"."
] | 7de1816ba0338f20fdb3e0f57fad0ffd5bea13f9 | https://github.com/ets-labs/python-domain-models/blob/7de1816ba0338f20fdb3e0f57fad0ffd5bea13f9/domain_models/models.py#L50-L61 | train |
ets-labs/python-domain-models | domain_models/models.py | DomainModelMetaClass.bind_fields_to_model_cls | def bind_fields_to_model_cls(cls, model_fields):
"""Bind fields to model class."""
return dict(
(field.name, field.bind_model_cls(cls)) for field in model_fields) | python | def bind_fields_to_model_cls(cls, model_fields):
"""Bind fields to model class."""
return dict(
(field.name, field.bind_model_cls(cls)) for field in model_fields) | [
"def",
"bind_fields_to_model_cls",
"(",
"cls",
",",
"model_fields",
")",
":",
"return",
"dict",
"(",
"(",
"field",
".",
"name",
",",
"field",
".",
"bind_model_cls",
"(",
"cls",
")",
")",
"for",
"field",
"in",
"model_fields",
")"
] | Bind fields to model class. | [
"Bind",
"fields",
"to",
"model",
"class",
"."
] | 7de1816ba0338f20fdb3e0f57fad0ffd5bea13f9 | https://github.com/ets-labs/python-domain-models/blob/7de1816ba0338f20fdb3e0f57fad0ffd5bea13f9/domain_models/models.py#L64-L67 | train |
ets-labs/python-domain-models | domain_models/models.py | DomainModelMetaClass.bind_collection_to_model_cls | def bind_collection_to_model_cls(cls):
"""Bind collection to model's class.
If collection was not specialized in process of model's declaration,
subclass of collection will be created.
"""
cls.Collection = type('{0}.Collection'.format(cls.__name__),
... | python | def bind_collection_to_model_cls(cls):
"""Bind collection to model's class.
If collection was not specialized in process of model's declaration,
subclass of collection will be created.
"""
cls.Collection = type('{0}.Collection'.format(cls.__name__),
... | [
"def",
"bind_collection_to_model_cls",
"(",
"cls",
")",
":",
"cls",
".",
"Collection",
"=",
"type",
"(",
"'{0}.Collection'",
".",
"format",
"(",
"cls",
".",
"__name__",
")",
",",
"(",
"cls",
".",
"Collection",
",",
")",
",",
"{",
"'value_type'",
":",
"cl... | Bind collection to model's class.
If collection was not specialized in process of model's declaration,
subclass of collection will be created. | [
"Bind",
"collection",
"to",
"model",
"s",
"class",
"."
] | 7de1816ba0338f20fdb3e0f57fad0ffd5bea13f9 | https://github.com/ets-labs/python-domain-models/blob/7de1816ba0338f20fdb3e0f57fad0ffd5bea13f9/domain_models/models.py#L70-L79 | train |
jenisys/parse_type | tasks/release.py | checklist | def checklist(ctx):
"""Checklist for releasing this project."""
checklist = """PRE-RELEASE CHECKLIST:
[ ] Everything is checked in
[ ] All tests pass w/ tox
RELEASE CHECKLIST:
[{x1}] Bump version to new-version and tag repository (via bump_version)
[{x2}] Build packages (sdist, bdist_wheel via prepare)
[{x... | python | def checklist(ctx):
"""Checklist for releasing this project."""
checklist = """PRE-RELEASE CHECKLIST:
[ ] Everything is checked in
[ ] All tests pass w/ tox
RELEASE CHECKLIST:
[{x1}] Bump version to new-version and tag repository (via bump_version)
[{x2}] Build packages (sdist, bdist_wheel via prepare)
[{x... | [
"def",
"checklist",
"(",
"ctx",
")",
":",
"checklist",
"=",
"steps",
"=",
"dict",
"(",
"x1",
"=",
"None",
",",
"x2",
"=",
"None",
",",
"x3",
"=",
"None",
",",
"x4",
"=",
"None",
",",
"x5",
"=",
"None",
",",
"x6",
"=",
"None",
")",
"yesno_map",
... | Checklist for releasing this project. | [
"Checklist",
"for",
"releasing",
"this",
"project",
"."
] | 7cad3a67a5ca725cb786da31f656fd473084289f | https://github.com/jenisys/parse_type/blob/7cad3a67a5ca725cb786da31f656fd473084289f/tasks/release.py#L61-L84 | train |
jenisys/parse_type | tasks/release.py | build_packages | def build_packages(ctx, hide=False):
"""Build packages for this release."""
print("build_packages:")
ctx.run("python setup.py sdist bdist_wheel", echo=True, hide=hide) | python | def build_packages(ctx, hide=False):
"""Build packages for this release."""
print("build_packages:")
ctx.run("python setup.py sdist bdist_wheel", echo=True, hide=hide) | [
"def",
"build_packages",
"(",
"ctx",
",",
"hide",
"=",
"False",
")",
":",
"print",
"(",
"\"build_packages:\"",
")",
"ctx",
".",
"run",
"(",
"\"python setup.py sdist bdist_wheel\"",
",",
"echo",
"=",
"True",
",",
"hide",
"=",
"hide",
")"
] | Build packages for this release. | [
"Build",
"packages",
"for",
"this",
"release",
"."
] | 7cad3a67a5ca725cb786da31f656fd473084289f | https://github.com/jenisys/parse_type/blob/7cad3a67a5ca725cb786da31f656fd473084289f/tasks/release.py#L98-L101 | train |
useblocks/groundwork | groundwork/patterns/gw_threads_pattern.py | ThreadsListPlugin.register | def register(self, name, function, description=None):
"""
Register a new thread.
:param function: Function, which gets called for the new thread
:type function: function
:param name: Unique name of the thread for documentation purposes.
:param description: Short descript... | python | def register(self, name, function, description=None):
"""
Register a new thread.
:param function: Function, which gets called for the new thread
:type function: function
:param name: Unique name of the thread for documentation purposes.
:param description: Short descript... | [
"def",
"register",
"(",
"self",
",",
"name",
",",
"function",
",",
"description",
"=",
"None",
")",
":",
"return",
"self",
".",
"__app",
".",
"threads",
".",
"register",
"(",
"name",
",",
"function",
",",
"self",
".",
"_plugin",
",",
"description",
")"... | Register a new thread.
:param function: Function, which gets called for the new thread
:type function: function
:param name: Unique name of the thread for documentation purposes.
:param description: Short description of the thread | [
"Register",
"a",
"new",
"thread",
"."
] | d34fce43f54246ca4db0f7b89e450dcdc847c68c | https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/patterns/gw_threads_pattern.py#L60-L69 | train |
useblocks/groundwork | groundwork/patterns/gw_threads_pattern.py | ThreadsListApplication.unregister | def unregister(self, thread):
"""
Unregisters an existing thread, so that this thread is no longer available.
This function is mainly used during plugin deactivation.
:param thread: Name of the thread
"""
if thread not in self.threads.keys():
self.log.warnin... | python | def unregister(self, thread):
"""
Unregisters an existing thread, so that this thread is no longer available.
This function is mainly used during plugin deactivation.
:param thread: Name of the thread
"""
if thread not in self.threads.keys():
self.log.warnin... | [
"def",
"unregister",
"(",
"self",
",",
"thread",
")",
":",
"if",
"thread",
"not",
"in",
"self",
".",
"threads",
".",
"keys",
"(",
")",
":",
"self",
".",
"log",
".",
"warning",
"(",
"\"Can not unregister thread %s\"",
"%",
"thread",
")",
"else",
":",
"d... | Unregisters an existing thread, so that this thread is no longer available.
This function is mainly used during plugin deactivation.
:param thread: Name of the thread | [
"Unregisters",
"an",
"existing",
"thread",
"so",
"that",
"this",
"thread",
"is",
"no",
"longer",
"available",
"."
] | d34fce43f54246ca4db0f7b89e450dcdc847c68c | https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/patterns/gw_threads_pattern.py#L111-L123 | train |
useblocks/groundwork | groundwork/patterns/gw_threads_pattern.py | ThreadsListApplication.get | def get(self, thread=None, plugin=None):
"""
Get one or more threads.
:param thread: Name of the thread
:type thread: str
:param plugin: Plugin object, under which the thread was registered
:type plugin: GwBasePattern
"""
if plugin is not None:
... | python | def get(self, thread=None, plugin=None):
"""
Get one or more threads.
:param thread: Name of the thread
:type thread: str
:param plugin: Plugin object, under which the thread was registered
:type plugin: GwBasePattern
"""
if plugin is not None:
... | [
"def",
"get",
"(",
"self",
",",
"thread",
"=",
"None",
",",
"plugin",
"=",
"None",
")",
":",
"if",
"plugin",
"is",
"not",
"None",
":",
"if",
"thread",
"is",
"None",
":",
"threads_list",
"=",
"{",
"}",
"for",
"key",
"in",
"self",
".",
"threads",
"... | Get one or more threads.
:param thread: Name of the thread
:type thread: str
:param plugin: Plugin object, under which the thread was registered
:type plugin: GwBasePattern | [
"Get",
"one",
"or",
"more",
"threads",
"."
] | d34fce43f54246ca4db0f7b89e450dcdc847c68c | https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/patterns/gw_threads_pattern.py#L125-L156 | train |
eonpatapon/contrail-api-cli | contrail_api_cli/schema.py | create_schema_from_xsd_directory | def create_schema_from_xsd_directory(directory, version):
"""Create and fill the schema from a directory which contains xsd
files. It calls fill_schema_from_xsd_file for each xsd file
found.
"""
schema = Schema(version)
for f in _get_xsd_from_directory(directory):
logger.info("Loading s... | python | def create_schema_from_xsd_directory(directory, version):
"""Create and fill the schema from a directory which contains xsd
files. It calls fill_schema_from_xsd_file for each xsd file
found.
"""
schema = Schema(version)
for f in _get_xsd_from_directory(directory):
logger.info("Loading s... | [
"def",
"create_schema_from_xsd_directory",
"(",
"directory",
",",
"version",
")",
":",
"schema",
"=",
"Schema",
"(",
"version",
")",
"for",
"f",
"in",
"_get_xsd_from_directory",
"(",
"directory",
")",
":",
"logger",
".",
"info",
"(",
"\"Loading schema %s\"",
"%"... | Create and fill the schema from a directory which contains xsd
files. It calls fill_schema_from_xsd_file for each xsd file
found. | [
"Create",
"and",
"fill",
"the",
"schema",
"from",
"a",
"directory",
"which",
"contains",
"xsd",
"files",
".",
"It",
"calls",
"fill_schema_from_xsd_file",
"for",
"each",
"xsd",
"file",
"found",
"."
] | 1571bf523fa054f3d6bf83dba43a224fea173a73 | https://github.com/eonpatapon/contrail-api-cli/blob/1571bf523fa054f3d6bf83dba43a224fea173a73/contrail_api_cli/schema.py#L103-L113 | train |
eonpatapon/contrail-api-cli | contrail_api_cli/schema.py | fill_schema_from_xsd_file | def fill_schema_from_xsd_file(filename, schema):
"""From an xsd file, it fills the schema by creating needed
Resource. The generateds idl_parser is used to parse ifmap
statements in the xsd file.
"""
ifmap_statements = _parse_xsd_file(filename)
properties_all = []
for v in ifmap_statements... | python | def fill_schema_from_xsd_file(filename, schema):
"""From an xsd file, it fills the schema by creating needed
Resource. The generateds idl_parser is used to parse ifmap
statements in the xsd file.
"""
ifmap_statements = _parse_xsd_file(filename)
properties_all = []
for v in ifmap_statements... | [
"def",
"fill_schema_from_xsd_file",
"(",
"filename",
",",
"schema",
")",
":",
"ifmap_statements",
"=",
"_parse_xsd_file",
"(",
"filename",
")",
"properties_all",
"=",
"[",
"]",
"for",
"v",
"in",
"ifmap_statements",
".",
"values",
"(",
")",
":",
"if",
"(",
"i... | From an xsd file, it fills the schema by creating needed
Resource. The generateds idl_parser is used to parse ifmap
statements in the xsd file. | [
"From",
"an",
"xsd",
"file",
"it",
"fills",
"the",
"schema",
"by",
"creating",
"needed",
"Resource",
".",
"The",
"generateds",
"idl_parser",
"is",
"used",
"to",
"parse",
"ifmap",
"statements",
"in",
"the",
"xsd",
"file",
"."
] | 1571bf523fa054f3d6bf83dba43a224fea173a73 | https://github.com/eonpatapon/contrail-api-cli/blob/1571bf523fa054f3d6bf83dba43a224fea173a73/contrail_api_cli/schema.py#L116-L147 | train |
theiviaxx/python-perforce | perforce/models.py | split_ls | def split_ls(func):
"""Decorator to split files into manageable chunks as not to exceed the windows cmd limit
:param func: Function to call for each chunk
:type func: :py:class:Function
"""
@wraps(func)
def wrapper(self, files, silent=True, exclude_deleted=False):
if not isinstance(file... | python | def split_ls(func):
"""Decorator to split files into manageable chunks as not to exceed the windows cmd limit
:param func: Function to call for each chunk
:type func: :py:class:Function
"""
@wraps(func)
def wrapper(self, files, silent=True, exclude_deleted=False):
if not isinstance(file... | [
"def",
"split_ls",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"self",
",",
"files",
",",
"silent",
"=",
"True",
",",
"exclude_deleted",
"=",
"False",
")",
":",
"if",
"not",
"isinstance",
"(",
"files",
",",
"(",
"t... | Decorator to split files into manageable chunks as not to exceed the windows cmd limit
:param func: Function to call for each chunk
:type func: :py:class:Function | [
"Decorator",
"to",
"split",
"files",
"into",
"manageable",
"chunks",
"as",
"not",
"to",
"exceed",
"the",
"windows",
"cmd",
"limit"
] | 01a3b01fe5949126fa0097d9a8ad386887823b5a | https://github.com/theiviaxx/python-perforce/blob/01a3b01fe5949126fa0097d9a8ad386887823b5a/perforce/models.py#L69-L105 | train |
theiviaxx/python-perforce | perforce/models.py | Connection.__getVariables | def __getVariables(self):
"""Parses the P4 env vars using 'set p4'"""
try:
startupinfo = None
if os.name == 'nt':
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
output = subprocess.check_ou... | python | def __getVariables(self):
"""Parses the P4 env vars using 'set p4'"""
try:
startupinfo = None
if os.name == 'nt':
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
output = subprocess.check_ou... | [
"def",
"__getVariables",
"(",
"self",
")",
":",
"try",
":",
"startupinfo",
"=",
"None",
"if",
"os",
".",
"name",
"==",
"'nt'",
":",
"startupinfo",
"=",
"subprocess",
".",
"STARTUPINFO",
"(",
")",
"startupinfo",
".",
"dwFlags",
"|=",
"subprocess",
".",
"S... | Parses the P4 env vars using 'set p4 | [
"Parses",
"the",
"P4",
"env",
"vars",
"using",
"set",
"p4"
] | 01a3b01fe5949126fa0097d9a8ad386887823b5a | https://github.com/theiviaxx/python-perforce/blob/01a3b01fe5949126fa0097d9a8ad386887823b5a/perforce/models.py#L138-L166 | train |
theiviaxx/python-perforce | perforce/models.py | Connection.client | def client(self):
"""The client used in perforce queries"""
if isinstance(self._client, six.string_types):
self._client = Client(self._client, self)
return self._client | python | def client(self):
"""The client used in perforce queries"""
if isinstance(self._client, six.string_types):
self._client = Client(self._client, self)
return self._client | [
"def",
"client",
"(",
"self",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"_client",
",",
"six",
".",
"string_types",
")",
":",
"self",
".",
"_client",
"=",
"Client",
"(",
"self",
".",
"_client",
",",
"self",
")",
"return",
"self",
".",
"_client"... | The client used in perforce queries | [
"The",
"client",
"used",
"in",
"perforce",
"queries"
] | 01a3b01fe5949126fa0097d9a8ad386887823b5a | https://github.com/theiviaxx/python-perforce/blob/01a3b01fe5949126fa0097d9a8ad386887823b5a/perforce/models.py#L169-L174 | train |
theiviaxx/python-perforce | perforce/models.py | Connection.status | def status(self):
"""The status of the connection to perforce"""
try:
# -- Check client
res = self.run(['info'])
if res[0]['clientName'] == '*unknown*':
return ConnectionStatus.INVALID_CLIENT
# -- Trigger an auth error if not logged in
... | python | def status(self):
"""The status of the connection to perforce"""
try:
# -- Check client
res = self.run(['info'])
if res[0]['clientName'] == '*unknown*':
return ConnectionStatus.INVALID_CLIENT
# -- Trigger an auth error if not logged in
... | [
"def",
"status",
"(",
"self",
")",
":",
"try",
":",
"res",
"=",
"self",
".",
"run",
"(",
"[",
"'info'",
"]",
")",
"if",
"res",
"[",
"0",
"]",
"[",
"'clientName'",
"]",
"==",
"'*unknown*'",
":",
"return",
"ConnectionStatus",
".",
"INVALID_CLIENT",
"se... | The status of the connection to perforce | [
"The",
"status",
"of",
"the",
"connection",
"to",
"perforce"
] | 01a3b01fe5949126fa0097d9a8ad386887823b5a | https://github.com/theiviaxx/python-perforce/blob/01a3b01fe5949126fa0097d9a8ad386887823b5a/perforce/models.py#L201-L216 | train |
theiviaxx/python-perforce | perforce/models.py | Connection.run | def run(self, cmd, stdin=None, marshal_output=True, **kwargs):
"""Runs a p4 command and returns a list of dictionary objects
:param cmd: Command to run
:type cmd: list
:param stdin: Standard Input to send to the process
:type stdin: str
:param marshal_output: Whether or ... | python | def run(self, cmd, stdin=None, marshal_output=True, **kwargs):
"""Runs a p4 command and returns a list of dictionary objects
:param cmd: Command to run
:type cmd: list
:param stdin: Standard Input to send to the process
:type stdin: str
:param marshal_output: Whether or ... | [
"def",
"run",
"(",
"self",
",",
"cmd",
",",
"stdin",
"=",
"None",
",",
"marshal_output",
"=",
"True",
",",
"**",
"kwargs",
")",
":",
"records",
"=",
"[",
"]",
"args",
"=",
"[",
"self",
".",
"_executable",
",",
"\"-u\"",
",",
"self",
".",
"_user",
... | Runs a p4 command and returns a list of dictionary objects
:param cmd: Command to run
:type cmd: list
:param stdin: Standard Input to send to the process
:type stdin: str
:param marshal_output: Whether or not to marshal the output from the command
:type marshal_output: b... | [
"Runs",
"a",
"p4",
"command",
"and",
"returns",
"a",
"list",
"of",
"dictionary",
"objects"
] | 01a3b01fe5949126fa0097d9a8ad386887823b5a | https://github.com/theiviaxx/python-perforce/blob/01a3b01fe5949126fa0097d9a8ad386887823b5a/perforce/models.py#L218-L287 | train |
theiviaxx/python-perforce | perforce/models.py | Connection.findChangelist | def findChangelist(self, description=None):
"""Gets or creates a Changelist object with a description
:param description: The description to set or lookup
:type description: str
:returns: :class:`.Changelist`
"""
if description is None:
change = Default(self)... | python | def findChangelist(self, description=None):
"""Gets or creates a Changelist object with a description
:param description: The description to set or lookup
:type description: str
:returns: :class:`.Changelist`
"""
if description is None:
change = Default(self)... | [
"def",
"findChangelist",
"(",
"self",
",",
"description",
"=",
"None",
")",
":",
"if",
"description",
"is",
"None",
":",
"change",
"=",
"Default",
"(",
"self",
")",
"else",
":",
"if",
"isinstance",
"(",
"description",
",",
"six",
".",
"integer_types",
")... | Gets or creates a Changelist object with a description
:param description: The description to set or lookup
:type description: str
:returns: :class:`.Changelist` | [
"Gets",
"or",
"creates",
"a",
"Changelist",
"object",
"with",
"a",
"description"
] | 01a3b01fe5949126fa0097d9a8ad386887823b5a | https://github.com/theiviaxx/python-perforce/blob/01a3b01fe5949126fa0097d9a8ad386887823b5a/perforce/models.py#L320-L345 | train |
theiviaxx/python-perforce | perforce/models.py | Connection.add | def add(self, filename, change=None):
"""Adds a new file to a changelist
:param filename: File path to add
:type filename: str
:param change: Changelist to add the file to
:type change: int
:returns: :class:`.Revision`
"""
try:
if not self.can... | python | def add(self, filename, change=None):
"""Adds a new file to a changelist
:param filename: File path to add
:type filename: str
:param change: Changelist to add the file to
:type change: int
:returns: :class:`.Revision`
"""
try:
if not self.can... | [
"def",
"add",
"(",
"self",
",",
"filename",
",",
"change",
"=",
"None",
")",
":",
"try",
":",
"if",
"not",
"self",
".",
"canAdd",
"(",
"filename",
")",
":",
"raise",
"errors",
".",
"RevisionError",
"(",
"'File is not under client path'",
")",
"if",
"chan... | Adds a new file to a changelist
:param filename: File path to add
:type filename: str
:param change: Changelist to add the file to
:type change: int
:returns: :class:`.Revision` | [
"Adds",
"a",
"new",
"file",
"to",
"a",
"changelist"
] | 01a3b01fe5949126fa0097d9a8ad386887823b5a | https://github.com/theiviaxx/python-perforce/blob/01a3b01fe5949126fa0097d9a8ad386887823b5a/perforce/models.py#L347-L375 | train |
theiviaxx/python-perforce | perforce/models.py | Connection.canAdd | def canAdd(self, filename):
"""Determines if a filename can be added to the depot under the current client
:param filename: File path to add
:type filename: str
"""
try:
result = self.run(['add', '-n', '-t', 'text', filename])[0]
except errors.CommandError as... | python | def canAdd(self, filename):
"""Determines if a filename can be added to the depot under the current client
:param filename: File path to add
:type filename: str
"""
try:
result = self.run(['add', '-n', '-t', 'text', filename])[0]
except errors.CommandError as... | [
"def",
"canAdd",
"(",
"self",
",",
"filename",
")",
":",
"try",
":",
"result",
"=",
"self",
".",
"run",
"(",
"[",
"'add'",
",",
"'-n'",
",",
"'-t'",
",",
"'text'",
",",
"filename",
"]",
")",
"[",
"0",
"]",
"except",
"errors",
".",
"CommandError",
... | Determines if a filename can be added to the depot under the current client
:param filename: File path to add
:type filename: str | [
"Determines",
"if",
"a",
"filename",
"can",
"be",
"added",
"to",
"the",
"depot",
"under",
"the",
"current",
"client"
] | 01a3b01fe5949126fa0097d9a8ad386887823b5a | https://github.com/theiviaxx/python-perforce/blob/01a3b01fe5949126fa0097d9a8ad386887823b5a/perforce/models.py#L377-L394 | train |
theiviaxx/python-perforce | perforce/models.py | Changelist.query | def query(self, files=True):
"""Queries the depot to get the current status of the changelist"""
if self._change:
cl = str(self._change)
self._p4dict = {camel_case(k): v for k, v in six.iteritems(self._connection.run(['change', '-o', cl])[0])}
if files:
self.... | python | def query(self, files=True):
"""Queries the depot to get the current status of the changelist"""
if self._change:
cl = str(self._change)
self._p4dict = {camel_case(k): v for k, v in six.iteritems(self._connection.run(['change', '-o', cl])[0])}
if files:
self.... | [
"def",
"query",
"(",
"self",
",",
"files",
"=",
"True",
")",
":",
"if",
"self",
".",
"_change",
":",
"cl",
"=",
"str",
"(",
"self",
".",
"_change",
")",
"self",
".",
"_p4dict",
"=",
"{",
"camel_case",
"(",
"k",
")",
":",
"v",
"for",
"k",
",",
... | Queries the depot to get the current status of the changelist | [
"Queries",
"the",
"depot",
"to",
"get",
"the",
"current",
"status",
"of",
"the",
"changelist"
] | 01a3b01fe5949126fa0097d9a8ad386887823b5a | https://github.com/theiviaxx/python-perforce/blob/01a3b01fe5949126fa0097d9a8ad386887823b5a/perforce/models.py#L542-L560 | train |
theiviaxx/python-perforce | perforce/models.py | Changelist.remove | def remove(self, rev, permanent=False):
"""Removes a revision from this changelist
:param rev: Revision to remove
:type rev: :class:`.Revision`
:param permanent: Whether or not we need to set the changelist to default
:type permanent: bool
"""
if not isinstance(r... | python | def remove(self, rev, permanent=False):
"""Removes a revision from this changelist
:param rev: Revision to remove
:type rev: :class:`.Revision`
:param permanent: Whether or not we need to set the changelist to default
:type permanent: bool
"""
if not isinstance(r... | [
"def",
"remove",
"(",
"self",
",",
"rev",
",",
"permanent",
"=",
"False",
")",
":",
"if",
"not",
"isinstance",
"(",
"rev",
",",
"Revision",
")",
":",
"raise",
"TypeError",
"(",
"'argument needs to be an instance of Revision'",
")",
"if",
"rev",
"not",
"in",
... | Removes a revision from this changelist
:param rev: Revision to remove
:type rev: :class:`.Revision`
:param permanent: Whether or not we need to set the changelist to default
:type permanent: bool | [
"Removes",
"a",
"revision",
"from",
"this",
"changelist"
] | 01a3b01fe5949126fa0097d9a8ad386887823b5a | https://github.com/theiviaxx/python-perforce/blob/01a3b01fe5949126fa0097d9a8ad386887823b5a/perforce/models.py#L585-L601 | train |
theiviaxx/python-perforce | perforce/models.py | Changelist.revert | def revert(self, unchanged_only=False):
"""Revert all files in this changelist
:param unchanged_only: Only revert unchanged files
:type unchanged_only: bool
:raises: :class:`.ChangelistError`
"""
if self._reverted:
raise errors.ChangelistError('This changelis... | python | def revert(self, unchanged_only=False):
"""Revert all files in this changelist
:param unchanged_only: Only revert unchanged files
:type unchanged_only: bool
:raises: :class:`.ChangelistError`
"""
if self._reverted:
raise errors.ChangelistError('This changelis... | [
"def",
"revert",
"(",
"self",
",",
"unchanged_only",
"=",
"False",
")",
":",
"if",
"self",
".",
"_reverted",
":",
"raise",
"errors",
".",
"ChangelistError",
"(",
"'This changelist has been reverted'",
")",
"change",
"=",
"self",
".",
"_change",
"if",
"self",
... | Revert all files in this changelist
:param unchanged_only: Only revert unchanged files
:type unchanged_only: bool
:raises: :class:`.ChangelistError` | [
"Revert",
"all",
"files",
"in",
"this",
"changelist"
] | 01a3b01fe5949126fa0097d9a8ad386887823b5a | https://github.com/theiviaxx/python-perforce/blob/01a3b01fe5949126fa0097d9a8ad386887823b5a/perforce/models.py#L603-L628 | train |
theiviaxx/python-perforce | perforce/models.py | Changelist.submit | def submit(self):
"""Submits a chagelist to the depot"""
if self._dirty:
self.save()
self._connection.run(['submit', '-c', str(self._change)], marshal_output=False) | python | def submit(self):
"""Submits a chagelist to the depot"""
if self._dirty:
self.save()
self._connection.run(['submit', '-c', str(self._change)], marshal_output=False) | [
"def",
"submit",
"(",
"self",
")",
":",
"if",
"self",
".",
"_dirty",
":",
"self",
".",
"save",
"(",
")",
"self",
".",
"_connection",
".",
"run",
"(",
"[",
"'submit'",
",",
"'-c'",
",",
"str",
"(",
"self",
".",
"_change",
")",
"]",
",",
"marshal_o... | Submits a chagelist to the depot | [
"Submits",
"a",
"chagelist",
"to",
"the",
"depot"
] | 01a3b01fe5949126fa0097d9a8ad386887823b5a | https://github.com/theiviaxx/python-perforce/blob/01a3b01fe5949126fa0097d9a8ad386887823b5a/perforce/models.py#L635-L640 | train |
theiviaxx/python-perforce | perforce/models.py | Changelist.delete | def delete(self):
"""Reverts all files in this changelist then deletes the changelist from perforce"""
try:
self.revert()
except errors.ChangelistError:
pass
self._connection.run(['change', '-d', str(self._change)]) | python | def delete(self):
"""Reverts all files in this changelist then deletes the changelist from perforce"""
try:
self.revert()
except errors.ChangelistError:
pass
self._connection.run(['change', '-d', str(self._change)]) | [
"def",
"delete",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"revert",
"(",
")",
"except",
"errors",
".",
"ChangelistError",
":",
"pass",
"self",
".",
"_connection",
".",
"run",
"(",
"[",
"'change'",
",",
"'-d'",
",",
"str",
"(",
"self",
".",
"... | Reverts all files in this changelist then deletes the changelist from perforce | [
"Reverts",
"all",
"files",
"in",
"this",
"changelist",
"then",
"deletes",
"the",
"changelist",
"from",
"perforce"
] | 01a3b01fe5949126fa0097d9a8ad386887823b5a | https://github.com/theiviaxx/python-perforce/blob/01a3b01fe5949126fa0097d9a8ad386887823b5a/perforce/models.py#L642-L649 | train |
theiviaxx/python-perforce | perforce/models.py | Changelist.create | def create(description='<Created by Python>', connection=None):
"""Creates a new changelist
:param connection: Connection to use to create the changelist
:type connection: :class:`.Connection`
:param description: Description for new changelist
:type description: str
:ret... | python | def create(description='<Created by Python>', connection=None):
"""Creates a new changelist
:param connection: Connection to use to create the changelist
:type connection: :class:`.Connection`
:param description: Description for new changelist
:type description: str
:ret... | [
"def",
"create",
"(",
"description",
"=",
"'<Created by Python>'",
",",
"connection",
"=",
"None",
")",
":",
"connection",
"=",
"connection",
"or",
"Connection",
"(",
")",
"description",
"=",
"description",
".",
"replace",
"(",
"'\\n'",
",",
"'\\n\\t'",
")",
... | Creates a new changelist
:param connection: Connection to use to create the changelist
:type connection: :class:`.Connection`
:param description: Description for new changelist
:type description: str
:returns: :class:`.Changelist` | [
"Creates",
"a",
"new",
"changelist"
] | 01a3b01fe5949126fa0097d9a8ad386887823b5a | https://github.com/theiviaxx/python-perforce/blob/01a3b01fe5949126fa0097d9a8ad386887823b5a/perforce/models.py#L694-L708 | train |
theiviaxx/python-perforce | perforce/models.py | Revision.query | def query(self):
"""Runs an fstat for this file and repopulates the data"""
self._p4dict = self._connection.run(['fstat', '-m', '1', self._p4dict['depotFile']])[0]
self._head = HeadRevision(self._p4dict)
self._filename = self.depotFile | python | def query(self):
"""Runs an fstat for this file and repopulates the data"""
self._p4dict = self._connection.run(['fstat', '-m', '1', self._p4dict['depotFile']])[0]
self._head = HeadRevision(self._p4dict)
self._filename = self.depotFile | [
"def",
"query",
"(",
"self",
")",
":",
"self",
".",
"_p4dict",
"=",
"self",
".",
"_connection",
".",
"run",
"(",
"[",
"'fstat'",
",",
"'-m'",
",",
"'1'",
",",
"self",
".",
"_p4dict",
"[",
"'depotFile'",
"]",
"]",
")",
"[",
"0",
"]",
"self",
".",
... | Runs an fstat for this file and repopulates the data | [
"Runs",
"an",
"fstat",
"for",
"this",
"file",
"and",
"repopulates",
"the",
"data"
] | 01a3b01fe5949126fa0097d9a8ad386887823b5a | https://github.com/theiviaxx/python-perforce/blob/01a3b01fe5949126fa0097d9a8ad386887823b5a/perforce/models.py#L770-L776 | train |
theiviaxx/python-perforce | perforce/models.py | Revision.edit | def edit(self, changelist=0):
"""Checks out the file
:param changelist: Optional changelist to checkout the file into
:type changelist: :class:`.Changelist`
"""
command = 'reopen' if self.action in ('add', 'edit') else 'edit'
if int(changelist):
self._connect... | python | def edit(self, changelist=0):
"""Checks out the file
:param changelist: Optional changelist to checkout the file into
:type changelist: :class:`.Changelist`
"""
command = 'reopen' if self.action in ('add', 'edit') else 'edit'
if int(changelist):
self._connect... | [
"def",
"edit",
"(",
"self",
",",
"changelist",
"=",
"0",
")",
":",
"command",
"=",
"'reopen'",
"if",
"self",
".",
"action",
"in",
"(",
"'add'",
",",
"'edit'",
")",
"else",
"'edit'",
"if",
"int",
"(",
"changelist",
")",
":",
"self",
".",
"_connection"... | Checks out the file
:param changelist: Optional changelist to checkout the file into
:type changelist: :class:`.Changelist` | [
"Checks",
"out",
"the",
"file"
] | 01a3b01fe5949126fa0097d9a8ad386887823b5a | https://github.com/theiviaxx/python-perforce/blob/01a3b01fe5949126fa0097d9a8ad386887823b5a/perforce/models.py#L778-L790 | train |
theiviaxx/python-perforce | perforce/models.py | Revision.lock | def lock(self, lock=True, changelist=0):
"""Locks or unlocks the file
:param lock: Lock or unlock the file
:type lock: bool
:param changelist: Optional changelist to checkout the file into
:type changelist: :class:`.Changelist`
"""
cmd = 'lock' if lock else 'unl... | python | def lock(self, lock=True, changelist=0):
"""Locks or unlocks the file
:param lock: Lock or unlock the file
:type lock: bool
:param changelist: Optional changelist to checkout the file into
:type changelist: :class:`.Changelist`
"""
cmd = 'lock' if lock else 'unl... | [
"def",
"lock",
"(",
"self",
",",
"lock",
"=",
"True",
",",
"changelist",
"=",
"0",
")",
":",
"cmd",
"=",
"'lock'",
"if",
"lock",
"else",
"'unlock'",
"if",
"changelist",
":",
"self",
".",
"_connection",
".",
"run",
"(",
"[",
"cmd",
",",
"'-c'",
",",... | Locks or unlocks the file
:param lock: Lock or unlock the file
:type lock: bool
:param changelist: Optional changelist to checkout the file into
:type changelist: :class:`.Changelist` | [
"Locks",
"or",
"unlocks",
"the",
"file"
] | 01a3b01fe5949126fa0097d9a8ad386887823b5a | https://github.com/theiviaxx/python-perforce/blob/01a3b01fe5949126fa0097d9a8ad386887823b5a/perforce/models.py#L792-L807 | train |
theiviaxx/python-perforce | perforce/models.py | Revision.sync | def sync(self, force=False, safe=True, revision=0, changelist=0):
"""Syncs the file at the current revision
:param force: Force the file to sync
:type force: bool
:param safe: Don't sync files that were changed outside perforce
:type safe: bool
:param revision: Sync to a... | python | def sync(self, force=False, safe=True, revision=0, changelist=0):
"""Syncs the file at the current revision
:param force: Force the file to sync
:type force: bool
:param safe: Don't sync files that were changed outside perforce
:type safe: bool
:param revision: Sync to a... | [
"def",
"sync",
"(",
"self",
",",
"force",
"=",
"False",
",",
"safe",
"=",
"True",
",",
"revision",
"=",
"0",
",",
"changelist",
"=",
"0",
")",
":",
"cmd",
"=",
"[",
"'sync'",
"]",
"if",
"force",
":",
"cmd",
".",
"append",
"(",
"'-f'",
")",
"if"... | Syncs the file at the current revision
:param force: Force the file to sync
:type force: bool
:param safe: Don't sync files that were changed outside perforce
:type safe: bool
:param revision: Sync to a specific revision
:type revision: int
:param changelist: Cha... | [
"Syncs",
"the",
"file",
"at",
"the",
"current",
"revision"
] | 01a3b01fe5949126fa0097d9a8ad386887823b5a | https://github.com/theiviaxx/python-perforce/blob/01a3b01fe5949126fa0097d9a8ad386887823b5a/perforce/models.py#L809-L837 | train |
theiviaxx/python-perforce | perforce/models.py | Revision.revert | def revert(self, unchanged=False):
"""Reverts any file changes
:param unchanged: Only revert if the file is unchanged
:type unchanged: bool
"""
cmd = ['revert']
if unchanged:
cmd.append('-a')
wasadd = self.action == 'add'
cmd.append(self.dep... | python | def revert(self, unchanged=False):
"""Reverts any file changes
:param unchanged: Only revert if the file is unchanged
:type unchanged: bool
"""
cmd = ['revert']
if unchanged:
cmd.append('-a')
wasadd = self.action == 'add'
cmd.append(self.dep... | [
"def",
"revert",
"(",
"self",
",",
"unchanged",
"=",
"False",
")",
":",
"cmd",
"=",
"[",
"'revert'",
"]",
"if",
"unchanged",
":",
"cmd",
".",
"append",
"(",
"'-a'",
")",
"wasadd",
"=",
"self",
".",
"action",
"==",
"'add'",
"cmd",
".",
"append",
"("... | Reverts any file changes
:param unchanged: Only revert if the file is unchanged
:type unchanged: bool | [
"Reverts",
"any",
"file",
"changes"
] | 01a3b01fe5949126fa0097d9a8ad386887823b5a | https://github.com/theiviaxx/python-perforce/blob/01a3b01fe5949126fa0097d9a8ad386887823b5a/perforce/models.py#L839-L862 | train |
theiviaxx/python-perforce | perforce/models.py | Revision.shelve | def shelve(self, changelist=None):
"""Shelves the file if it is in a changelist
:param changelist: Changelist to add the move to
:type changelist: :class:`.Changelist`
"""
if changelist is None and self.changelist.description == 'default':
raise errors.ShelveError('U... | python | def shelve(self, changelist=None):
"""Shelves the file if it is in a changelist
:param changelist: Changelist to add the move to
:type changelist: :class:`.Changelist`
"""
if changelist is None and self.changelist.description == 'default':
raise errors.ShelveError('U... | [
"def",
"shelve",
"(",
"self",
",",
"changelist",
"=",
"None",
")",
":",
"if",
"changelist",
"is",
"None",
"and",
"self",
".",
"changelist",
".",
"description",
"==",
"'default'",
":",
"raise",
"errors",
".",
"ShelveError",
"(",
"'Unabled to shelve files in the... | Shelves the file if it is in a changelist
:param changelist: Changelist to add the move to
:type changelist: :class:`.Changelist` | [
"Shelves",
"the",
"file",
"if",
"it",
"is",
"in",
"a",
"changelist"
] | 01a3b01fe5949126fa0097d9a8ad386887823b5a | https://github.com/theiviaxx/python-perforce/blob/01a3b01fe5949126fa0097d9a8ad386887823b5a/perforce/models.py#L864-L881 | train |
theiviaxx/python-perforce | perforce/models.py | Revision.delete | def delete(self, changelist=0):
"""Marks the file for delete
:param changelist: Changelist to add the move to
:type changelist: :class:`.Changelist`
"""
cmd = ['delete']
if changelist:
cmd += ['-c', str(changelist)]
cmd.append(self.depotFile)
... | python | def delete(self, changelist=0):
"""Marks the file for delete
:param changelist: Changelist to add the move to
:type changelist: :class:`.Changelist`
"""
cmd = ['delete']
if changelist:
cmd += ['-c', str(changelist)]
cmd.append(self.depotFile)
... | [
"def",
"delete",
"(",
"self",
",",
"changelist",
"=",
"0",
")",
":",
"cmd",
"=",
"[",
"'delete'",
"]",
"if",
"changelist",
":",
"cmd",
"+=",
"[",
"'-c'",
",",
"str",
"(",
"changelist",
")",
"]",
"cmd",
".",
"append",
"(",
"self",
".",
"depotFile",
... | Marks the file for delete
:param changelist: Changelist to add the move to
:type changelist: :class:`.Changelist` | [
"Marks",
"the",
"file",
"for",
"delete"
] | 01a3b01fe5949126fa0097d9a8ad386887823b5a | https://github.com/theiviaxx/python-perforce/blob/01a3b01fe5949126fa0097d9a8ad386887823b5a/perforce/models.py#L909-L923 | train |
theiviaxx/python-perforce | perforce/models.py | Revision.hash | def hash(self):
"""The hash value of the current revision"""
if 'digest' not in self._p4dict:
self._p4dict = self._connection.run(['fstat', '-m', '1', '-Ol', self.depotFile])[0]
return self._p4dict['digest'] | python | def hash(self):
"""The hash value of the current revision"""
if 'digest' not in self._p4dict:
self._p4dict = self._connection.run(['fstat', '-m', '1', '-Ol', self.depotFile])[0]
return self._p4dict['digest'] | [
"def",
"hash",
"(",
"self",
")",
":",
"if",
"'digest'",
"not",
"in",
"self",
".",
"_p4dict",
":",
"self",
".",
"_p4dict",
"=",
"self",
".",
"_connection",
".",
"run",
"(",
"[",
"'fstat'",
",",
"'-m'",
",",
"'1'",
",",
"'-Ol'",
",",
"self",
".",
"... | The hash value of the current revision | [
"The",
"hash",
"value",
"of",
"the",
"current",
"revision"
] | 01a3b01fe5949126fa0097d9a8ad386887823b5a | https://github.com/theiviaxx/python-perforce/blob/01a3b01fe5949126fa0097d9a8ad386887823b5a/perforce/models.py#L926-L931 | train |
theiviaxx/python-perforce | perforce/models.py | Client.view | def view(self):
"""A list of view specs"""
spec = []
for k, v in six.iteritems(self._p4dict):
if k.startswith('view'):
match = RE_FILESPEC.search(v)
if match:
spec.append(FileSpec(v[:match.end() - 1], v[match.end():]))
retu... | python | def view(self):
"""A list of view specs"""
spec = []
for k, v in six.iteritems(self._p4dict):
if k.startswith('view'):
match = RE_FILESPEC.search(v)
if match:
spec.append(FileSpec(v[:match.end() - 1], v[match.end():]))
retu... | [
"def",
"view",
"(",
"self",
")",
":",
"spec",
"=",
"[",
"]",
"for",
"k",
",",
"v",
"in",
"six",
".",
"iteritems",
"(",
"self",
".",
"_p4dict",
")",
":",
"if",
"k",
".",
"startswith",
"(",
"'view'",
")",
":",
"match",
"=",
"RE_FILESPEC",
".",
"s... | A list of view specs | [
"A",
"list",
"of",
"view",
"specs"
] | 01a3b01fe5949126fa0097d9a8ad386887823b5a | https://github.com/theiviaxx/python-perforce/blob/01a3b01fe5949126fa0097d9a8ad386887823b5a/perforce/models.py#L1145-L1154 | train |
theiviaxx/python-perforce | perforce/models.py | Client.stream | def stream(self):
"""Which stream, if any, the client is under"""
stream = self._p4dict.get('stream')
if stream:
return Stream(stream, self._connection) | python | def stream(self):
"""Which stream, if any, the client is under"""
stream = self._p4dict.get('stream')
if stream:
return Stream(stream, self._connection) | [
"def",
"stream",
"(",
"self",
")",
":",
"stream",
"=",
"self",
".",
"_p4dict",
".",
"get",
"(",
"'stream'",
")",
"if",
"stream",
":",
"return",
"Stream",
"(",
"stream",
",",
"self",
".",
"_connection",
")"
] | Which stream, if any, the client is under | [
"Which",
"stream",
"if",
"any",
"the",
"client",
"is",
"under"
] | 01a3b01fe5949126fa0097d9a8ad386887823b5a | https://github.com/theiviaxx/python-perforce/blob/01a3b01fe5949126fa0097d9a8ad386887823b5a/perforce/models.py#L1167-L1171 | train |
ph4r05/monero-serialize | monero_serialize/xmrboost.py | Archive.set_version | async def set_version(self, tp, params, version=None, elem=None):
"""
Stores version to the stream if not stored yet
:param tp:
:param params:
:param version:
:param elem:
:return:
"""
self.registry.set_tr(None)
tw = TypeWrapper(tp, params... | python | async def set_version(self, tp, params, version=None, elem=None):
"""
Stores version to the stream if not stored yet
:param tp:
:param params:
:param version:
:param elem:
:return:
"""
self.registry.set_tr(None)
tw = TypeWrapper(tp, params... | [
"async",
"def",
"set_version",
"(",
"self",
",",
"tp",
",",
"params",
",",
"version",
"=",
"None",
",",
"elem",
"=",
"None",
")",
":",
"self",
".",
"registry",
".",
"set_tr",
"(",
"None",
")",
"tw",
"=",
"TypeWrapper",
"(",
"tp",
",",
"params",
")"... | Stores version to the stream if not stored yet
:param tp:
:param params:
:param version:
:param elem:
:return: | [
"Stores",
"version",
"to",
"the",
"stream",
"if",
"not",
"stored",
"yet"
] | cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42 | https://github.com/ph4r05/monero-serialize/blob/cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42/monero_serialize/xmrboost.py#L206-L230 | train |
ph4r05/monero-serialize | monero_serialize/xmrboost.py | Archive.version | async def version(self, tp, params, version=None, elem=None):
"""
Symmetric version management
:param tp:
:param params:
:param version:
:return:
"""
if self.writing:
return await self.set_version(tp, params, version, elem)
else:
... | python | async def version(self, tp, params, version=None, elem=None):
"""
Symmetric version management
:param tp:
:param params:
:param version:
:return:
"""
if self.writing:
return await self.set_version(tp, params, version, elem)
else:
... | [
"async",
"def",
"version",
"(",
"self",
",",
"tp",
",",
"params",
",",
"version",
"=",
"None",
",",
"elem",
"=",
"None",
")",
":",
"if",
"self",
".",
"writing",
":",
"return",
"await",
"self",
".",
"set_version",
"(",
"tp",
",",
"params",
",",
"ver... | Symmetric version management
:param tp:
:param params:
:param version:
:return: | [
"Symmetric",
"version",
"management"
] | cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42 | https://github.com/ph4r05/monero-serialize/blob/cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42/monero_serialize/xmrboost.py#L232-L244 | train |
ph4r05/monero-serialize | monero_serialize/xmrboost.py | Archive.root_message | async def root_message(self, msg, msg_type=None):
"""
Root-level message. First entry in the archive.
Archive headers processing
:return:
"""
await self.root()
await self.message(msg, msg_type) | python | async def root_message(self, msg, msg_type=None):
"""
Root-level message. First entry in the archive.
Archive headers processing
:return:
"""
await self.root()
await self.message(msg, msg_type) | [
"async",
"def",
"root_message",
"(",
"self",
",",
"msg",
",",
"msg_type",
"=",
"None",
")",
":",
"await",
"self",
".",
"root",
"(",
")",
"await",
"self",
".",
"message",
"(",
"msg",
",",
"msg_type",
")"
] | Root-level message. First entry in the archive.
Archive headers processing
:return: | [
"Root",
"-",
"level",
"message",
".",
"First",
"entry",
"in",
"the",
"archive",
".",
"Archive",
"headers",
"processing"
] | cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42 | https://github.com/ph4r05/monero-serialize/blob/cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42/monero_serialize/xmrboost.py#L675-L683 | train |
ph4r05/monero-serialize | monero_serialize/xmrboost.py | Archive.dump_message | async def dump_message(self, msg, msg_type=None):
"""
Dumps message to the writer.
:param msg:
:param msg_type:
:return:
"""
mtype = msg.__class__ if msg_type is None else msg_type
fields = mtype.f_specs()
for field in fields:
await se... | python | async def dump_message(self, msg, msg_type=None):
"""
Dumps message to the writer.
:param msg:
:param msg_type:
:return:
"""
mtype = msg.__class__ if msg_type is None else msg_type
fields = mtype.f_specs()
for field in fields:
await se... | [
"async",
"def",
"dump_message",
"(",
"self",
",",
"msg",
",",
"msg_type",
"=",
"None",
")",
":",
"mtype",
"=",
"msg",
".",
"__class__",
"if",
"msg_type",
"is",
"None",
"else",
"msg_type",
"fields",
"=",
"mtype",
".",
"f_specs",
"(",
")",
"for",
"field"... | Dumps message to the writer.
:param msg:
:param msg_type:
:return: | [
"Dumps",
"message",
"to",
"the",
"writer",
"."
] | cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42 | https://github.com/ph4r05/monero-serialize/blob/cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42/monero_serialize/xmrboost.py#L753-L764 | train |
ph4r05/monero-serialize | monero_serialize/xmrboost.py | Archive.load_message | async def load_message(self, msg_type, msg=None):
"""
Loads message if the given type from the reader.
Supports reading directly to existing message.
:param msg_type:
:param msg:
:return:
"""
msg = msg_type() if msg is None else msg
fields = msg_t... | python | async def load_message(self, msg_type, msg=None):
"""
Loads message if the given type from the reader.
Supports reading directly to existing message.
:param msg_type:
:param msg:
:return:
"""
msg = msg_type() if msg is None else msg
fields = msg_t... | [
"async",
"def",
"load_message",
"(",
"self",
",",
"msg_type",
",",
"msg",
"=",
"None",
")",
":",
"msg",
"=",
"msg_type",
"(",
")",
"if",
"msg",
"is",
"None",
"else",
"msg",
"fields",
"=",
"msg_type",
".",
"f_specs",
"(",
")",
"if",
"msg_type",
"else"... | Loads message if the given type from the reader.
Supports reading directly to existing message.
:param msg_type:
:param msg:
:return: | [
"Loads",
"message",
"if",
"the",
"given",
"type",
"from",
"the",
"reader",
".",
"Supports",
"reading",
"directly",
"to",
"existing",
"message",
"."
] | cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42 | https://github.com/ph4r05/monero-serialize/blob/cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42/monero_serialize/xmrboost.py#L766-L780 | train |
eonpatapon/contrail-api-cli | contrail_api_cli/client.py | contrail_error_handler | def contrail_error_handler(f):
"""Handle HTTP errors returned by the API server
"""
@wraps(f)
def wrapper(*args, **kwargs):
try:
return f(*args, **kwargs)
except HttpError as e:
# Replace message by details to provide a
# meaningful message
... | python | def contrail_error_handler(f):
"""Handle HTTP errors returned by the API server
"""
@wraps(f)
def wrapper(*args, **kwargs):
try:
return f(*args, **kwargs)
except HttpError as e:
# Replace message by details to provide a
# meaningful message
... | [
"def",
"contrail_error_handler",
"(",
"f",
")",
":",
"@",
"wraps",
"(",
"f",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"try",
":",
"return",
"f",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
"except",
"HttpError",
"as",... | Handle HTTP errors returned by the API server | [
"Handle",
"HTTP",
"errors",
"returned",
"by",
"the",
"API",
"server"
] | 1571bf523fa054f3d6bf83dba43a224fea173a73 | https://github.com/eonpatapon/contrail-api-cli/blob/1571bf523fa054f3d6bf83dba43a224fea173a73/contrail_api_cli/client.py#L15-L29 | train |
eonpatapon/contrail-api-cli | contrail_api_cli/client.py | SessionLoader.make | def make(self, host="localhost", port=8082, protocol="http", base_uri="", os_auth_type="http", **kwargs):
"""Initialize a session to Contrail API server
:param os_auth_type: auth plugin to use:
- http: basic HTTP authentification
- v2password: keystone v2 auth
- v3pa... | python | def make(self, host="localhost", port=8082, protocol="http", base_uri="", os_auth_type="http", **kwargs):
"""Initialize a session to Contrail API server
:param os_auth_type: auth plugin to use:
- http: basic HTTP authentification
- v2password: keystone v2 auth
- v3pa... | [
"def",
"make",
"(",
"self",
",",
"host",
"=",
"\"localhost\"",
",",
"port",
"=",
"8082",
",",
"protocol",
"=",
"\"http\"",
",",
"base_uri",
"=",
"\"\"",
",",
"os_auth_type",
"=",
"\"http\"",
",",
"**",
"kwargs",
")",
":",
"loader",
"=",
"loading",
".",... | Initialize a session to Contrail API server
:param os_auth_type: auth plugin to use:
- http: basic HTTP authentification
- v2password: keystone v2 auth
- v3password: keystone v3 auth
:type os_auth_type: str | [
"Initialize",
"a",
"session",
"to",
"Contrail",
"API",
"server"
] | 1571bf523fa054f3d6bf83dba43a224fea173a73 | https://github.com/eonpatapon/contrail-api-cli/blob/1571bf523fa054f3d6bf83dba43a224fea173a73/contrail_api_cli/client.py#L38-L57 | train |
eonpatapon/contrail-api-cli | contrail_api_cli/client.py | ContrailAPISession.post_json | def post_json(self, url, data, cls=None, **kwargs):
"""
POST data to the api-server
:param url: resource location (eg: "/type/uuid")
:type url: str
:param cls: JSONEncoder class
:type cls: JSONEncoder
"""
kwargs['data'] = to_json(data, cls=cls)
kw... | python | def post_json(self, url, data, cls=None, **kwargs):
"""
POST data to the api-server
:param url: resource location (eg: "/type/uuid")
:type url: str
:param cls: JSONEncoder class
:type cls: JSONEncoder
"""
kwargs['data'] = to_json(data, cls=cls)
kw... | [
"def",
"post_json",
"(",
"self",
",",
"url",
",",
"data",
",",
"cls",
"=",
"None",
",",
"**",
"kwargs",
")",
":",
"kwargs",
"[",
"'data'",
"]",
"=",
"to_json",
"(",
"data",
",",
"cls",
"=",
"cls",
")",
"kwargs",
"[",
"'headers'",
"]",
"=",
"self"... | POST data to the api-server
:param url: resource location (eg: "/type/uuid")
:type url: str
:param cls: JSONEncoder class
:type cls: JSONEncoder | [
"POST",
"data",
"to",
"the",
"api",
"-",
"server"
] | 1571bf523fa054f3d6bf83dba43a224fea173a73 | https://github.com/eonpatapon/contrail-api-cli/blob/1571bf523fa054f3d6bf83dba43a224fea173a73/contrail_api_cli/client.py#L136-L147 | train |
eonpatapon/contrail-api-cli | contrail_api_cli/client.py | ContrailAPISession.put_json | def put_json(self, url, data, cls=None, **kwargs):
"""
PUT data to the api-server
:param url: resource location (eg: "/type/uuid")
:type url: str
:param cls: JSONEncoder class
:type cls: JSONEncoder
"""
kwargs['data'] = to_json(data, cls=cls)
kwar... | python | def put_json(self, url, data, cls=None, **kwargs):
"""
PUT data to the api-server
:param url: resource location (eg: "/type/uuid")
:type url: str
:param cls: JSONEncoder class
:type cls: JSONEncoder
"""
kwargs['data'] = to_json(data, cls=cls)
kwar... | [
"def",
"put_json",
"(",
"self",
",",
"url",
",",
"data",
",",
"cls",
"=",
"None",
",",
"**",
"kwargs",
")",
":",
"kwargs",
"[",
"'data'",
"]",
"=",
"to_json",
"(",
"data",
",",
"cls",
"=",
"cls",
")",
"kwargs",
"[",
"'headers'",
"]",
"=",
"self",... | PUT data to the api-server
:param url: resource location (eg: "/type/uuid")
:type url: str
:param cls: JSONEncoder class
:type cls: JSONEncoder | [
"PUT",
"data",
"to",
"the",
"api",
"-",
"server"
] | 1571bf523fa054f3d6bf83dba43a224fea173a73 | https://github.com/eonpatapon/contrail-api-cli/blob/1571bf523fa054f3d6bf83dba43a224fea173a73/contrail_api_cli/client.py#L150-L161 | train |
eonpatapon/contrail-api-cli | contrail_api_cli/client.py | ContrailAPISession.fqname_to_id | def fqname_to_id(self, fq_name, type):
"""
Return uuid for fq_name
:param fq_name: resource fq name
:type fq_name: FQName
:param type: resource type
:type type: str
:rtype: UUIDv4 str
:raises HttpError: fq_name not found
"""
data = {
... | python | def fqname_to_id(self, fq_name, type):
"""
Return uuid for fq_name
:param fq_name: resource fq name
:type fq_name: FQName
:param type: resource type
:type type: str
:rtype: UUIDv4 str
:raises HttpError: fq_name not found
"""
data = {
... | [
"def",
"fqname_to_id",
"(",
"self",
",",
"fq_name",
",",
"type",
")",
":",
"data",
"=",
"{",
"\"type\"",
":",
"type",
",",
"\"fq_name\"",
":",
"list",
"(",
"fq_name",
")",
"}",
"return",
"self",
".",
"post_json",
"(",
"self",
".",
"make_url",
"(",
"\... | Return uuid for fq_name
:param fq_name: resource fq name
:type fq_name: FQName
:param type: resource type
:type type: str
:rtype: UUIDv4 str
:raises HttpError: fq_name not found | [
"Return",
"uuid",
"for",
"fq_name"
] | 1571bf523fa054f3d6bf83dba43a224fea173a73 | https://github.com/eonpatapon/contrail-api-cli/blob/1571bf523fa054f3d6bf83dba43a224fea173a73/contrail_api_cli/client.py#L163-L179 | train |
eonpatapon/contrail-api-cli | contrail_api_cli/client.py | ContrailAPISession.id_to_fqname | def id_to_fqname(self, uuid, type=None):
"""
Return fq_name and type for uuid
If `type` is provided check that uuid is actually
a resource of type `type`. Raise HttpError if it's
not the case.
:param uuid: resource uuid
:type uuid: UUIDv4 str
:param type... | python | def id_to_fqname(self, uuid, type=None):
"""
Return fq_name and type for uuid
If `type` is provided check that uuid is actually
a resource of type `type`. Raise HttpError if it's
not the case.
:param uuid: resource uuid
:type uuid: UUIDv4 str
:param type... | [
"def",
"id_to_fqname",
"(",
"self",
",",
"uuid",
",",
"type",
"=",
"None",
")",
":",
"data",
"=",
"{",
"\"uuid\"",
":",
"uuid",
"}",
"result",
"=",
"self",
".",
"post_json",
"(",
"self",
".",
"make_url",
"(",
"\"/id-to-fqname\"",
")",
",",
"data",
")... | Return fq_name and type for uuid
If `type` is provided check that uuid is actually
a resource of type `type`. Raise HttpError if it's
not the case.
:param uuid: resource uuid
:type uuid: UUIDv4 str
:param type: resource type
:type type: str
:rtype: dict... | [
"Return",
"fq_name",
"and",
"type",
"for",
"uuid"
] | 1571bf523fa054f3d6bf83dba43a224fea173a73 | https://github.com/eonpatapon/contrail-api-cli/blob/1571bf523fa054f3d6bf83dba43a224fea173a73/contrail_api_cli/client.py#L181-L204 | train |
eonpatapon/contrail-api-cli | contrail_api_cli/client.py | ContrailAPISession.add_kv_store | def add_kv_store(self, key, value):
"""Add a key-value store entry.
:param key: string
:param value: string
"""
data = {
'operation': 'STORE',
'key': key,
'value': value
}
return self.post(self.make_url("/useragent-kv"), data=t... | python | def add_kv_store(self, key, value):
"""Add a key-value store entry.
:param key: string
:param value: string
"""
data = {
'operation': 'STORE',
'key': key,
'value': value
}
return self.post(self.make_url("/useragent-kv"), data=t... | [
"def",
"add_kv_store",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"data",
"=",
"{",
"'operation'",
":",
"'STORE'",
",",
"'key'",
":",
"key",
",",
"'value'",
":",
"value",
"}",
"return",
"self",
".",
"post",
"(",
"self",
".",
"make_url",
"(",
... | Add a key-value store entry.
:param key: string
:param value: string | [
"Add",
"a",
"key",
"-",
"value",
"store",
"entry",
"."
] | 1571bf523fa054f3d6bf83dba43a224fea173a73 | https://github.com/eonpatapon/contrail-api-cli/blob/1571bf523fa054f3d6bf83dba43a224fea173a73/contrail_api_cli/client.py#L246-L258 | train |
eonpatapon/contrail-api-cli | contrail_api_cli/client.py | ContrailAPISession.remove_kv_store | def remove_kv_store(self, key):
"""Remove a key-value store entry.
:param key: string
"""
data = {
'operation': 'DELETE',
'key': key
}
return self.post(self.make_url("/useragent-kv"), data=to_json(data),
headers=self.defau... | python | def remove_kv_store(self, key):
"""Remove a key-value store entry.
:param key: string
"""
data = {
'operation': 'DELETE',
'key': key
}
return self.post(self.make_url("/useragent-kv"), data=to_json(data),
headers=self.defau... | [
"def",
"remove_kv_store",
"(",
"self",
",",
"key",
")",
":",
"data",
"=",
"{",
"'operation'",
":",
"'DELETE'",
",",
"'key'",
":",
"key",
"}",
"return",
"self",
".",
"post",
"(",
"self",
".",
"make_url",
"(",
"\"/useragent-kv\"",
")",
",",
"data",
"=",
... | Remove a key-value store entry.
:param key: string | [
"Remove",
"a",
"key",
"-",
"value",
"store",
"entry",
"."
] | 1571bf523fa054f3d6bf83dba43a224fea173a73 | https://github.com/eonpatapon/contrail-api-cli/blob/1571bf523fa054f3d6bf83dba43a224fea173a73/contrail_api_cli/client.py#L260-L270 | train |
go-macaroon-bakery/py-macaroon-bakery | macaroonbakery/bakery/_oven.py | canonical_ops | def canonical_ops(ops):
''' Returns the given operations array sorted with duplicates removed.
@param ops checker.Ops
@return: checker.Ops
'''
new_ops = sorted(set(ops), key=lambda x: (x.entity, x.action))
return new_ops | python | def canonical_ops(ops):
''' Returns the given operations array sorted with duplicates removed.
@param ops checker.Ops
@return: checker.Ops
'''
new_ops = sorted(set(ops), key=lambda x: (x.entity, x.action))
return new_ops | [
"def",
"canonical_ops",
"(",
"ops",
")",
":",
"new_ops",
"=",
"sorted",
"(",
"set",
"(",
"ops",
")",
",",
"key",
"=",
"lambda",
"x",
":",
"(",
"x",
".",
"entity",
",",
"x",
".",
"action",
")",
")",
"return",
"new_ops"
] | Returns the given operations array sorted with duplicates removed.
@param ops checker.Ops
@return: checker.Ops | [
"Returns",
"the",
"given",
"operations",
"array",
"sorted",
"with",
"duplicates",
"removed",
"."
] | 63ce1ef1dabe816eb8aaec48fbb46761c34ddf77 | https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/bakery/_oven.py#L269-L276 | train |
go-macaroon-bakery/py-macaroon-bakery | macaroonbakery/bakery/_oven.py | _macaroon_id_ops | def _macaroon_id_ops(ops):
'''Return operations suitable for serializing as part of a MacaroonId.
It assumes that ops has been canonicalized and that there's at least
one operation.
'''
id_ops = []
for entity, entity_ops in itertools.groupby(ops, lambda x: x.entity):
actions = map(lambd... | python | def _macaroon_id_ops(ops):
'''Return operations suitable for serializing as part of a MacaroonId.
It assumes that ops has been canonicalized and that there's at least
one operation.
'''
id_ops = []
for entity, entity_ops in itertools.groupby(ops, lambda x: x.entity):
actions = map(lambd... | [
"def",
"_macaroon_id_ops",
"(",
"ops",
")",
":",
"id_ops",
"=",
"[",
"]",
"for",
"entity",
",",
"entity_ops",
"in",
"itertools",
".",
"groupby",
"(",
"ops",
",",
"lambda",
"x",
":",
"x",
".",
"entity",
")",
":",
"actions",
"=",
"map",
"(",
"lambda",
... | Return operations suitable for serializing as part of a MacaroonId.
It assumes that ops has been canonicalized and that there's at least
one operation. | [
"Return",
"operations",
"suitable",
"for",
"serializing",
"as",
"part",
"of",
"a",
"MacaroonId",
"."
] | 63ce1ef1dabe816eb8aaec48fbb46761c34ddf77 | https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/bakery/_oven.py#L279-L289 | train |
go-macaroon-bakery/py-macaroon-bakery | macaroonbakery/bakery/_oven.py | Oven.macaroon | def macaroon(self, version, expiry, caveats, ops):
''' Takes a macaroon with the given version from the oven,
associates it with the given operations and attaches the given caveats.
There must be at least one operation specified.
The macaroon will expire at the given time - a time_before... | python | def macaroon(self, version, expiry, caveats, ops):
''' Takes a macaroon with the given version from the oven,
associates it with the given operations and attaches the given caveats.
There must be at least one operation specified.
The macaroon will expire at the given time - a time_before... | [
"def",
"macaroon",
"(",
"self",
",",
"version",
",",
"expiry",
",",
"caveats",
",",
"ops",
")",
":",
"if",
"len",
"(",
"ops",
")",
"==",
"0",
":",
"raise",
"ValueError",
"(",
"'cannot mint a macaroon associated '",
"'with no operations'",
")",
"ops",
"=",
... | Takes a macaroon with the given version from the oven,
associates it with the given operations and attaches the given caveats.
There must be at least one operation specified.
The macaroon will expire at the given time - a time_before first party
caveat will be added with that time.
... | [
"Takes",
"a",
"macaroon",
"with",
"the",
"given",
"version",
"from",
"the",
"oven",
"associates",
"it",
"with",
"the",
"given",
"operations",
"and",
"attaches",
"the",
"given",
"caveats",
".",
"There",
"must",
"be",
"at",
"least",
"one",
"operation",
"specif... | 63ce1ef1dabe816eb8aaec48fbb46761c34ddf77 | https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/bakery/_oven.py#L81-L117 | train |
go-macaroon-bakery/py-macaroon-bakery | macaroonbakery/bakery/_oven.py | Oven.ops_entity | def ops_entity(self, ops):
''' Returns a new multi-op entity name string that represents
all the given operations and caveats. It returns the same value
regardless of the ordering of the operations. It assumes that the
operations have been canonicalized and that there's at least one
... | python | def ops_entity(self, ops):
''' Returns a new multi-op entity name string that represents
all the given operations and caveats. It returns the same value
regardless of the ordering of the operations. It assumes that the
operations have been canonicalized and that there's at least one
... | [
"def",
"ops_entity",
"(",
"self",
",",
"ops",
")",
":",
"hash_entity",
"=",
"hashlib",
".",
"sha256",
"(",
")",
"for",
"op",
"in",
"ops",
":",
"hash_entity",
".",
"update",
"(",
"'{}\\n{}\\n'",
".",
"format",
"(",
"op",
".",
"action",
",",
"op",
".",... | Returns a new multi-op entity name string that represents
all the given operations and caveats. It returns the same value
regardless of the ordering of the operations. It assumes that the
operations have been canonicalized and that there's at least one
operation.
:param ops:
... | [
"Returns",
"a",
"new",
"multi",
"-",
"op",
"entity",
"name",
"string",
"that",
"represents",
"all",
"the",
"given",
"operations",
"and",
"caveats",
".",
"It",
"returns",
"the",
"same",
"value",
"regardless",
"of",
"the",
"ordering",
"of",
"the",
"operations"... | 63ce1ef1dabe816eb8aaec48fbb46761c34ddf77 | https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/bakery/_oven.py#L135-L151 | train |
go-macaroon-bakery/py-macaroon-bakery | macaroonbakery/bakery/_oven.py | Oven.macaroon_ops | def macaroon_ops(self, macaroons):
''' This method makes the oven satisfy the MacaroonOpStore protocol
required by the Checker class.
For macaroons minted with previous bakery versions, it always
returns a single LoginOp operation.
:param macaroons:
:return:
'''... | python | def macaroon_ops(self, macaroons):
''' This method makes the oven satisfy the MacaroonOpStore protocol
required by the Checker class.
For macaroons minted with previous bakery versions, it always
returns a single LoginOp operation.
:param macaroons:
:return:
'''... | [
"def",
"macaroon_ops",
"(",
"self",
",",
"macaroons",
")",
":",
"if",
"len",
"(",
"macaroons",
")",
"==",
"0",
":",
"raise",
"ValueError",
"(",
"'no macaroons provided'",
")",
"storage_id",
",",
"ops",
"=",
"_decode_macaroon_id",
"(",
"macaroons",
"[",
"0",
... | This method makes the oven satisfy the MacaroonOpStore protocol
required by the Checker class.
For macaroons minted with previous bakery versions, it always
returns a single LoginOp operation.
:param macaroons:
:return: | [
"This",
"method",
"makes",
"the",
"oven",
"satisfy",
"the",
"MacaroonOpStore",
"protocol",
"required",
"by",
"the",
"Checker",
"class",
"."
] | 63ce1ef1dabe816eb8aaec48fbb46761c34ddf77 | https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/bakery/_oven.py#L153-L204 | train |
ets-labs/python-domain-models | domain_models/collections.py | Collection.extend | def extend(self, iterable):
"""Extend the list by appending all the items in the given list."""
return super(Collection, self).extend(
self._ensure_iterable_is_valid(iterable)) | python | def extend(self, iterable):
"""Extend the list by appending all the items in the given list."""
return super(Collection, self).extend(
self._ensure_iterable_is_valid(iterable)) | [
"def",
"extend",
"(",
"self",
",",
"iterable",
")",
":",
"return",
"super",
"(",
"Collection",
",",
"self",
")",
".",
"extend",
"(",
"self",
".",
"_ensure_iterable_is_valid",
"(",
"iterable",
")",
")"
] | Extend the list by appending all the items in the given list. | [
"Extend",
"the",
"list",
"by",
"appending",
"all",
"the",
"items",
"in",
"the",
"given",
"list",
"."
] | 7de1816ba0338f20fdb3e0f57fad0ffd5bea13f9 | https://github.com/ets-labs/python-domain-models/blob/7de1816ba0338f20fdb3e0f57fad0ffd5bea13f9/domain_models/collections.py#L27-L30 | train |
ets-labs/python-domain-models | domain_models/collections.py | Collection.insert | def insert(self, index, value):
"""Insert an item at a given position."""
return super(Collection, self).insert(
index, self._ensure_value_is_valid(value)) | python | def insert(self, index, value):
"""Insert an item at a given position."""
return super(Collection, self).insert(
index, self._ensure_value_is_valid(value)) | [
"def",
"insert",
"(",
"self",
",",
"index",
",",
"value",
")",
":",
"return",
"super",
"(",
"Collection",
",",
"self",
")",
".",
"insert",
"(",
"index",
",",
"self",
".",
"_ensure_value_is_valid",
"(",
"value",
")",
")"
] | Insert an item at a given position. | [
"Insert",
"an",
"item",
"at",
"a",
"given",
"position",
"."
] | 7de1816ba0338f20fdb3e0f57fad0ffd5bea13f9 | https://github.com/ets-labs/python-domain-models/blob/7de1816ba0338f20fdb3e0f57fad0ffd5bea13f9/domain_models/collections.py#L32-L35 | train |
ets-labs/python-domain-models | domain_models/collections.py | Collection._ensure_value_is_valid | def _ensure_value_is_valid(self, value):
"""Ensure that value is a valid collection's value."""
if not isinstance(value, self.__class__.value_type):
raise TypeError('{0} is not valid collection value, instance '
'of {1} required'.format(
... | python | def _ensure_value_is_valid(self, value):
"""Ensure that value is a valid collection's value."""
if not isinstance(value, self.__class__.value_type):
raise TypeError('{0} is not valid collection value, instance '
'of {1} required'.format(
... | [
"def",
"_ensure_value_is_valid",
"(",
"self",
",",
"value",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"self",
".",
"__class__",
".",
"value_type",
")",
":",
"raise",
"TypeError",
"(",
"'{0} is not valid collection value, instance '",
"'of {1} required'... | Ensure that value is a valid collection's value. | [
"Ensure",
"that",
"value",
"is",
"a",
"valid",
"collection",
"s",
"value",
"."
] | 7de1816ba0338f20fdb3e0f57fad0ffd5bea13f9 | https://github.com/ets-labs/python-domain-models/blob/7de1816ba0338f20fdb3e0f57fad0ffd5bea13f9/domain_models/collections.py#L71-L77 | train |
ph4r05/monero-serialize | monero_serialize/core/message_types.py | container_elem_type | def container_elem_type(container_type, params):
"""
Returns container element type
:param container_type:
:param params:
:return:
"""
elem_type = params[0] if params else None
if elem_type is None:
elem_type = container_type.ELEM_TYPE
return elem_type | python | def container_elem_type(container_type, params):
"""
Returns container element type
:param container_type:
:param params:
:return:
"""
elem_type = params[0] if params else None
if elem_type is None:
elem_type = container_type.ELEM_TYPE
return elem_type | [
"def",
"container_elem_type",
"(",
"container_type",
",",
"params",
")",
":",
"elem_type",
"=",
"params",
"[",
"0",
"]",
"if",
"params",
"else",
"None",
"if",
"elem_type",
"is",
"None",
":",
"elem_type",
"=",
"container_type",
".",
"ELEM_TYPE",
"return",
"el... | Returns container element type
:param container_type:
:param params:
:return: | [
"Returns",
"container",
"element",
"type"
] | cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42 | https://github.com/ph4r05/monero-serialize/blob/cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42/monero_serialize/core/message_types.py#L153-L164 | train |
Phyks/libbmc | libbmc/doi.py | is_valid | def is_valid(doi):
"""
Check that a given DOI is a valid canonical DOI.
:param doi: The DOI to be checked.
:returns: Boolean indicating whether the DOI is valid or not.
>>> is_valid('10.1209/0295-5075/111/40005')
True
>>> is_valid('10.1016.12.31/nature.S0735-1097(98)2000/12/31/34:7-7')
... | python | def is_valid(doi):
"""
Check that a given DOI is a valid canonical DOI.
:param doi: The DOI to be checked.
:returns: Boolean indicating whether the DOI is valid or not.
>>> is_valid('10.1209/0295-5075/111/40005')
True
>>> is_valid('10.1016.12.31/nature.S0735-1097(98)2000/12/31/34:7-7')
... | [
"def",
"is_valid",
"(",
"doi",
")",
":",
"match",
"=",
"REGEX",
".",
"match",
"(",
"doi",
")",
"return",
"(",
"match",
"is",
"not",
"None",
")",
"and",
"(",
"match",
".",
"group",
"(",
"0",
")",
"==",
"doi",
")"
] | Check that a given DOI is a valid canonical DOI.
:param doi: The DOI to be checked.
:returns: Boolean indicating whether the DOI is valid or not.
>>> is_valid('10.1209/0295-5075/111/40005')
True
>>> is_valid('10.1016.12.31/nature.S0735-1097(98)2000/12/31/34:7-7')
True
>>> is_valid('10.10... | [
"Check",
"that",
"a",
"given",
"DOI",
"is",
"a",
"valid",
"canonical",
"DOI",
"."
] | 9ef1a29d2514157d1edd6c13ecbd61b07ae9315e | https://github.com/Phyks/libbmc/blob/9ef1a29d2514157d1edd6c13ecbd61b07ae9315e/libbmc/doi.py#L26-L58 | train |
Phyks/libbmc | libbmc/doi.py | get_oa_version | def get_oa_version(doi):
"""
Get an OA version for a given DOI.
.. note::
Uses beta.dissem.in API.
:param doi: A canonical DOI.
:returns: The URL of the OA version of the given DOI, or ``None``.
>>> get_oa_version('10.1209/0295-5075/111/40005')
'http://arxiv.org/abs/1506.06690'
... | python | def get_oa_version(doi):
"""
Get an OA version for a given DOI.
.. note::
Uses beta.dissem.in API.
:param doi: A canonical DOI.
:returns: The URL of the OA version of the given DOI, or ``None``.
>>> get_oa_version('10.1209/0295-5075/111/40005')
'http://arxiv.org/abs/1506.06690'
... | [
"def",
"get_oa_version",
"(",
"doi",
")",
":",
"try",
":",
"request",
"=",
"requests",
".",
"get",
"(",
"\"%s%s\"",
"%",
"(",
"DISSEMIN_API",
",",
"doi",
")",
")",
"request",
".",
"raise_for_status",
"(",
")",
"result",
"=",
"request",
".",
"json",
"("... | Get an OA version for a given DOI.
.. note::
Uses beta.dissem.in API.
:param doi: A canonical DOI.
:returns: The URL of the OA version of the given DOI, or ``None``.
>>> get_oa_version('10.1209/0295-5075/111/40005')
'http://arxiv.org/abs/1506.06690' | [
"Get",
"an",
"OA",
"version",
"for",
"a",
"given",
"DOI",
"."
] | 9ef1a29d2514157d1edd6c13ecbd61b07ae9315e | https://github.com/Phyks/libbmc/blob/9ef1a29d2514157d1edd6c13ecbd61b07ae9315e/libbmc/doi.py#L116-L137 | train |
Phyks/libbmc | libbmc/doi.py | get_oa_policy | def get_oa_policy(doi):
"""
Get OA policy for a given DOI.
.. note::
Uses beta.dissem.in API.
:param doi: A canonical DOI.
:returns: The OpenAccess policy for the associated publications, or \
``None`` if unknown.
>>> tmp = get_oa_policy('10.1209/0295-5075/111/40005'); (t... | python | def get_oa_policy(doi):
"""
Get OA policy for a given DOI.
.. note::
Uses beta.dissem.in API.
:param doi: A canonical DOI.
:returns: The OpenAccess policy for the associated publications, or \
``None`` if unknown.
>>> tmp = get_oa_policy('10.1209/0295-5075/111/40005'); (t... | [
"def",
"get_oa_policy",
"(",
"doi",
")",
":",
"try",
":",
"request",
"=",
"requests",
".",
"get",
"(",
"\"%s%s\"",
"%",
"(",
"DISSEMIN_API",
",",
"doi",
")",
")",
"request",
".",
"raise_for_status",
"(",
")",
"result",
"=",
"request",
".",
"json",
"(",... | Get OA policy for a given DOI.
.. note::
Uses beta.dissem.in API.
:param doi: A canonical DOI.
:returns: The OpenAccess policy for the associated publications, or \
``None`` if unknown.
>>> tmp = get_oa_policy('10.1209/0295-5075/111/40005'); (tmp["published"], tmp["preprint"], tm... | [
"Get",
"OA",
"policy",
"for",
"a",
"given",
"DOI",
"."
] | 9ef1a29d2514157d1edd6c13ecbd61b07ae9315e | https://github.com/Phyks/libbmc/blob/9ef1a29d2514157d1edd6c13ecbd61b07ae9315e/libbmc/doi.py#L140-L168 | train |
Phyks/libbmc | libbmc/doi.py | get_linked_version | def get_linked_version(doi):
"""
Get the original link behind the DOI.
:param doi: A canonical DOI.
:returns: The canonical URL behind the DOI, or ``None``.
>>> get_linked_version('10.1209/0295-5075/111/40005')
'http://stacks.iop.org/0295-5075/111/i=4/a=40005?key=crossref.9ad851948a976ecdf216d... | python | def get_linked_version(doi):
"""
Get the original link behind the DOI.
:param doi: A canonical DOI.
:returns: The canonical URL behind the DOI, or ``None``.
>>> get_linked_version('10.1209/0295-5075/111/40005')
'http://stacks.iop.org/0295-5075/111/i=4/a=40005?key=crossref.9ad851948a976ecdf216d... | [
"def",
"get_linked_version",
"(",
"doi",
")",
":",
"try",
":",
"request",
"=",
"requests",
".",
"head",
"(",
"to_url",
"(",
"doi",
")",
")",
"return",
"request",
".",
"headers",
".",
"get",
"(",
"\"location\"",
")",
"except",
"RequestException",
":",
"re... | Get the original link behind the DOI.
:param doi: A canonical DOI.
:returns: The canonical URL behind the DOI, or ``None``.
>>> get_linked_version('10.1209/0295-5075/111/40005')
'http://stacks.iop.org/0295-5075/111/i=4/a=40005?key=crossref.9ad851948a976ecdf216d4929b0b6f01' | [
"Get",
"the",
"original",
"link",
"behind",
"the",
"DOI",
"."
] | 9ef1a29d2514157d1edd6c13ecbd61b07ae9315e | https://github.com/Phyks/libbmc/blob/9ef1a29d2514157d1edd6c13ecbd61b07ae9315e/libbmc/doi.py#L171-L185 | train |
Phyks/libbmc | libbmc/doi.py | get_bibtex | def get_bibtex(doi):
"""
Get a BibTeX entry for a given DOI.
.. note::
Adapted from https://gist.github.com/jrsmith3/5513926.
:param doi: The canonical DOI to get BibTeX from.
:returns: A BibTeX string or ``None``.
>>> get_bibtex('10.1209/0295-5075/111/40005')
'@article{Verney_20... | python | def get_bibtex(doi):
"""
Get a BibTeX entry for a given DOI.
.. note::
Adapted from https://gist.github.com/jrsmith3/5513926.
:param doi: The canonical DOI to get BibTeX from.
:returns: A BibTeX string or ``None``.
>>> get_bibtex('10.1209/0295-5075/111/40005')
'@article{Verney_20... | [
"def",
"get_bibtex",
"(",
"doi",
")",
":",
"try",
":",
"request",
"=",
"requests",
".",
"get",
"(",
"to_url",
"(",
"doi",
")",
",",
"headers",
"=",
"{",
"\"accept\"",
":",
"\"application/x-bibtex\"",
"}",
")",
"request",
".",
"raise_for_status",
"(",
")"... | Get a BibTeX entry for a given DOI.
.. note::
Adapted from https://gist.github.com/jrsmith3/5513926.
:param doi: The canonical DOI to get BibTeX from.
:returns: A BibTeX string or ``None``.
>>> get_bibtex('10.1209/0295-5075/111/40005')
'@article{Verney_2015,\\n\\tdoi = {10.1209/0295-5075... | [
"Get",
"a",
"BibTeX",
"entry",
"for",
"a",
"given",
"DOI",
"."
] | 9ef1a29d2514157d1edd6c13ecbd61b07ae9315e | https://github.com/Phyks/libbmc/blob/9ef1a29d2514157d1edd6c13ecbd61b07ae9315e/libbmc/doi.py#L188-L209 | train |
useblocks/groundwork | groundwork/groundwork.py | App._configure_logging | def _configure_logging(self, logger_dict=None):
"""
Configures the logging module with a given dictionary, which in most cases was loaded from a configuration
file.
If no dictionary is provided, it falls back to a default configuration.
See `Python docs
<https://docs.py... | python | def _configure_logging(self, logger_dict=None):
"""
Configures the logging module with a given dictionary, which in most cases was loaded from a configuration
file.
If no dictionary is provided, it falls back to a default configuration.
See `Python docs
<https://docs.py... | [
"def",
"_configure_logging",
"(",
"self",
",",
"logger_dict",
"=",
"None",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"\"Configure logging\"",
")",
"for",
"handler",
"in",
"self",
".",
"log",
".",
"handlers",
":",
"self",
".",
"log",
".",
"removeHa... | Configures the logging module with a given dictionary, which in most cases was loaded from a configuration
file.
If no dictionary is provided, it falls back to a default configuration.
See `Python docs
<https://docs.python.org/3.5/library/logging.config.html#logging.config.dictConfig>`... | [
"Configures",
"the",
"logging",
"module",
"with",
"a",
"given",
"dictionary",
"which",
"in",
"most",
"cases",
"was",
"loaded",
"from",
"a",
"configuration",
"file",
"."
] | d34fce43f54246ca4db0f7b89e450dcdc847c68c | https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/groundwork.py#L92-L120 | train |
ph4r05/monero-serialize | monero_serialize/xmrserialize.py | Archive._dump_message_field | async def _dump_message_field(self, writer, msg, field, fvalue=None):
"""
Dumps a message field to the writer. Field is defined by the message field specification.
:param writer:
:param msg:
:param field:
:param fvalue:
:return:
"""
fname, ftype, ... | python | async def _dump_message_field(self, writer, msg, field, fvalue=None):
"""
Dumps a message field to the writer. Field is defined by the message field specification.
:param writer:
:param msg:
:param field:
:param fvalue:
:return:
"""
fname, ftype, ... | [
"async",
"def",
"_dump_message_field",
"(",
"self",
",",
"writer",
",",
"msg",
",",
"field",
",",
"fvalue",
"=",
"None",
")",
":",
"fname",
",",
"ftype",
",",
"params",
"=",
"field",
"[",
"0",
"]",
",",
"field",
"[",
"1",
"]",
",",
"field",
"[",
... | Dumps a message field to the writer. Field is defined by the message field specification.
:param writer:
:param msg:
:param field:
:param fvalue:
:return: | [
"Dumps",
"a",
"message",
"field",
"to",
"the",
"writer",
".",
"Field",
"is",
"defined",
"by",
"the",
"message",
"field",
"specification",
"."
] | cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42 | https://github.com/ph4r05/monero-serialize/blob/cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42/monero_serialize/xmrserialize.py#L659-L671 | train |
ph4r05/monero-serialize | monero_serialize/xmrserialize.py | Archive._load_message_field | async def _load_message_field(self, reader, msg, field):
"""
Loads message field from the reader. Field is defined by the message field specification.
Returns loaded value, supports field reference.
:param reader:
:param msg:
:param field:
:return:
"""
... | python | async def _load_message_field(self, reader, msg, field):
"""
Loads message field from the reader. Field is defined by the message field specification.
Returns loaded value, supports field reference.
:param reader:
:param msg:
:param field:
:return:
"""
... | [
"async",
"def",
"_load_message_field",
"(",
"self",
",",
"reader",
",",
"msg",
",",
"field",
")",
":",
"fname",
",",
"ftype",
",",
"params",
"=",
"field",
"[",
"0",
"]",
",",
"field",
"[",
"1",
"]",
",",
"field",
"[",
"2",
":",
"]",
"await",
"sel... | Loads message field from the reader. Field is defined by the message field specification.
Returns loaded value, supports field reference.
:param reader:
:param msg:
:param field:
:return: | [
"Loads",
"message",
"field",
"from",
"the",
"reader",
".",
"Field",
"is",
"defined",
"by",
"the",
"message",
"field",
"specification",
".",
"Returns",
"loaded",
"value",
"supports",
"field",
"reference",
"."
] | cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42 | https://github.com/ph4r05/monero-serialize/blob/cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42/monero_serialize/xmrserialize.py#L673-L684 | train |
dbarsam/python-vsgen | vsgen/util/timer.py | VSGTimer.start | def start(self, message):
"""
Manually starts timer with the message.
:param message: The display message.
"""
self._start = time.clock()
VSGLogger.info("{0:<20} - Started".format(message)) | python | def start(self, message):
"""
Manually starts timer with the message.
:param message: The display message.
"""
self._start = time.clock()
VSGLogger.info("{0:<20} - Started".format(message)) | [
"def",
"start",
"(",
"self",
",",
"message",
")",
":",
"self",
".",
"_start",
"=",
"time",
".",
"clock",
"(",
")",
"VSGLogger",
".",
"info",
"(",
"\"{0:<20} - Started\"",
".",
"format",
"(",
"message",
")",
")"
] | Manually starts timer with the message.
:param message: The display message. | [
"Manually",
"starts",
"timer",
"with",
"the",
"message",
"."
] | 640191bb018a1ff7d7b7a4982e0d3c1a423ba878 | https://github.com/dbarsam/python-vsgen/blob/640191bb018a1ff7d7b7a4982e0d3c1a423ba878/vsgen/util/timer.py#L47-L54 | train |
dbarsam/python-vsgen | vsgen/util/timer.py | VSGTimer.stop | def stop(self, message):
"""
Manually stops timer with the message.
:param message: The display message.
"""
self._stop = time.clock()
VSGLogger.info("{0:<20} - Finished [{1}s]".format(message, self.pprint(self._stop - self._start))) | python | def stop(self, message):
"""
Manually stops timer with the message.
:param message: The display message.
"""
self._stop = time.clock()
VSGLogger.info("{0:<20} - Finished [{1}s]".format(message, self.pprint(self._stop - self._start))) | [
"def",
"stop",
"(",
"self",
",",
"message",
")",
":",
"self",
".",
"_stop",
"=",
"time",
".",
"clock",
"(",
")",
"VSGLogger",
".",
"info",
"(",
"\"{0:<20} - Finished [{1}s]\"",
".",
"format",
"(",
"message",
",",
"self",
".",
"pprint",
"(",
"self",
"."... | Manually stops timer with the message.
:param message: The display message. | [
"Manually",
"stops",
"timer",
"with",
"the",
"message",
"."
] | 640191bb018a1ff7d7b7a4982e0d3c1a423ba878 | https://github.com/dbarsam/python-vsgen/blob/640191bb018a1ff7d7b7a4982e0d3c1a423ba878/vsgen/util/timer.py#L56-L63 | train |
Phyks/libbmc | libbmc/papers/identifiers.py | get_bibtex | def get_bibtex(identifier):
"""
Try to fetch BibTeX from a found identifier.
.. note::
Calls the functions in the respective identifiers module.
:param identifier: a tuple (type, identifier) with a valid type.
:returns: A BibTeX string or ``None`` if an error occurred.
# TODO: Should ... | python | def get_bibtex(identifier):
"""
Try to fetch BibTeX from a found identifier.
.. note::
Calls the functions in the respective identifiers module.
:param identifier: a tuple (type, identifier) with a valid type.
:returns: A BibTeX string or ``None`` if an error occurred.
# TODO: Should ... | [
"def",
"get_bibtex",
"(",
"identifier",
")",
":",
"identifier_type",
",",
"identifier_id",
"=",
"identifier",
"if",
"identifier_type",
"not",
"in",
"__valid_identifiers__",
":",
"return",
"None",
"module",
"=",
"sys",
".",
"modules",
".",
"get",
"(",
"\"libbmc.%... | Try to fetch BibTeX from a found identifier.
.. note::
Calls the functions in the respective identifiers module.
:param identifier: a tuple (type, identifier) with a valid type.
:returns: A BibTeX string or ``None`` if an error occurred.
# TODO: Should return a BiBTeX object? | [
"Try",
"to",
"fetch",
"BibTeX",
"from",
"a",
"found",
"identifier",
"."
] | 9ef1a29d2514157d1edd6c13ecbd61b07ae9315e | https://github.com/Phyks/libbmc/blob/9ef1a29d2514157d1edd6c13ecbd61b07ae9315e/libbmc/papers/identifiers.py#L72-L92 | train |
SandstoneHPC/sandstone-ide | sandstone/lib/handlers/rest.py | JSONHandler.initialize | def initialize(self,*args,**kwargs):
"""
Only try to parse as JSON if the JSON content type
header is set.
"""
super(JSONHandler,self).initialize(*args,**kwargs)
content_type = self.request.headers.get('Content-Type', '')
if 'application/json' in content_type.lowe... | python | def initialize(self,*args,**kwargs):
"""
Only try to parse as JSON if the JSON content type
header is set.
"""
super(JSONHandler,self).initialize(*args,**kwargs)
content_type = self.request.headers.get('Content-Type', '')
if 'application/json' in content_type.lowe... | [
"def",
"initialize",
"(",
"self",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"super",
"(",
"JSONHandler",
",",
"self",
")",
".",
"initialize",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
"content_type",
"=",
"self",
".",
"request",
".",
"header... | Only try to parse as JSON if the JSON content type
header is set. | [
"Only",
"try",
"to",
"parse",
"as",
"JSON",
"if",
"the",
"JSON",
"content",
"type",
"header",
"is",
"set",
"."
] | 7a47947fb07281c3e3018042863dc67e7e56dc04 | https://github.com/SandstoneHPC/sandstone-ide/blob/7a47947fb07281c3e3018042863dc67e7e56dc04/sandstone/lib/handlers/rest.py#L17-L25 | train |
Phyks/libbmc | libbmc/citations/bibtex.py | get_plaintext_citations | def get_plaintext_citations(bibtex):
"""
Parse a BibTeX file to get a clean list of plaintext citations.
:param bibtex: Either the path to the BibTeX file or the content of a \
BibTeX file.
:returns: A list of cleaned plaintext citations.
"""
parser = BibTexParser()
parser.cust... | python | def get_plaintext_citations(bibtex):
"""
Parse a BibTeX file to get a clean list of plaintext citations.
:param bibtex: Either the path to the BibTeX file or the content of a \
BibTeX file.
:returns: A list of cleaned plaintext citations.
"""
parser = BibTexParser()
parser.cust... | [
"def",
"get_plaintext_citations",
"(",
"bibtex",
")",
":",
"parser",
"=",
"BibTexParser",
"(",
")",
"parser",
".",
"customization",
"=",
"convert_to_unicode",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"bibtex",
")",
":",
"with",
"open",
"(",
"bibtex",
"... | Parse a BibTeX file to get a clean list of plaintext citations.
:param bibtex: Either the path to the BibTeX file or the content of a \
BibTeX file.
:returns: A list of cleaned plaintext citations. | [
"Parse",
"a",
"BibTeX",
"file",
"to",
"get",
"a",
"clean",
"list",
"of",
"plaintext",
"citations",
"."
] | 9ef1a29d2514157d1edd6c13ecbd61b07ae9315e | https://github.com/Phyks/libbmc/blob/9ef1a29d2514157d1edd6c13ecbd61b07ae9315e/libbmc/citations/bibtex.py#L36-L56 | train |
suurjaak/InputScope | inputscope/conf.py | init | def init(filename=ConfigPath):
"""Loads INI configuration into this module's attributes."""
section, parts = "DEFAULT", filename.rsplit(":", 1)
if len(parts) > 1 and os.path.isfile(parts[0]): filename, section = parts
if not os.path.isfile(filename): return
vardict, parser = globals(), config... | python | def init(filename=ConfigPath):
"""Loads INI configuration into this module's attributes."""
section, parts = "DEFAULT", filename.rsplit(":", 1)
if len(parts) > 1 and os.path.isfile(parts[0]): filename, section = parts
if not os.path.isfile(filename): return
vardict, parser = globals(), config... | [
"def",
"init",
"(",
"filename",
"=",
"ConfigPath",
")",
":",
"section",
",",
"parts",
"=",
"\"DEFAULT\"",
",",
"filename",
".",
"rsplit",
"(",
"\":\"",
",",
"1",
")",
"if",
"len",
"(",
"parts",
")",
">",
"1",
"and",
"os",
".",
"path",
".",
"isfile"... | Loads INI configuration into this module's attributes. | [
"Loads",
"INI",
"configuration",
"into",
"this",
"module",
"s",
"attributes",
"."
] | 245ff045163a1995e8cd5ac558d0a93024eb86eb | https://github.com/suurjaak/InputScope/blob/245ff045163a1995e8cd5ac558d0a93024eb86eb/inputscope/conf.py#L253-L270 | train |
suurjaak/InputScope | inputscope/conf.py | save | def save(filename=ConfigPath):
"""Saves this module's changed attributes to INI configuration."""
default_values = defaults()
parser = configparser.RawConfigParser()
parser.optionxform = str # Force case-sensitivity on names
try:
save_types = basestring, int, float, tuple, list, dict, ... | python | def save(filename=ConfigPath):
"""Saves this module's changed attributes to INI configuration."""
default_values = defaults()
parser = configparser.RawConfigParser()
parser.optionxform = str # Force case-sensitivity on names
try:
save_types = basestring, int, float, tuple, list, dict, ... | [
"def",
"save",
"(",
"filename",
"=",
"ConfigPath",
")",
":",
"default_values",
"=",
"defaults",
"(",
")",
"parser",
"=",
"configparser",
".",
"RawConfigParser",
"(",
")",
"parser",
".",
"optionxform",
"=",
"str",
"try",
":",
"save_types",
"=",
"basestring",
... | Saves this module's changed attributes to INI configuration. | [
"Saves",
"this",
"module",
"s",
"changed",
"attributes",
"to",
"INI",
"configuration",
"."
] | 245ff045163a1995e8cd5ac558d0a93024eb86eb | https://github.com/suurjaak/InputScope/blob/245ff045163a1995e8cd5ac558d0a93024eb86eb/inputscope/conf.py#L273-L294 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.