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
jahuth/litus
__init__.py
PDContainerList.param
def param(self,key,default=None): """for accessing global parameters""" if key in self.parameters: return self.parameters[key] return default
python
def param(self,key,default=None): """for accessing global parameters""" if key in self.parameters: return self.parameters[key] return default
[ "def", "param", "(", "self", ",", "key", ",", "default", "=", "None", ")", ":", "if", "key", "in", "self", ".", "parameters", ":", "return", "self", ".", "parameters", "[", "key", "]", "return", "default" ]
for accessing global parameters
[ "for", "accessing", "global", "parameters" ]
712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e
https://github.com/jahuth/litus/blob/712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e/__init__.py#L811-L815
train
jahuth/litus
__init__.py
Lists.generator
def generator(self,gen,*args,**kwargs): """ Use this function to enter and exit the context at the beginning and end of a generator. Example:: li = litus.Lists() for i in li.generator(range(100)): li.append(i) """ wit...
python
def generator(self,gen,*args,**kwargs): """ Use this function to enter and exit the context at the beginning and end of a generator. Example:: li = litus.Lists() for i in li.generator(range(100)): li.append(i) """ wit...
[ "def", "generator", "(", "self", ",", "gen", ",", "*", "args", ",", "**", "kwargs", ")", ":", "with", "self", "(", "*", "args", ",", "**", "kwargs", ")", ":", "for", "i", "in", "gen", ":", "yield", "i" ]
Use this function to enter and exit the context at the beginning and end of a generator. Example:: li = litus.Lists() for i in li.generator(range(100)): li.append(i)
[ "Use", "this", "function", "to", "enter", "and", "exit", "the", "context", "at", "the", "beginning", "and", "end", "of", "a", "generator", "." ]
712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e
https://github.com/jahuth/litus/blob/712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e/__init__.py#L962-L975
train
Loudr/pale
pale/arguments/url.py
URLArgument.validate_url
def validate_url(self, original_string): """Returns the original string if it was valid, raises an argument error if it's not. """ # nipped from stack overflow: http://stackoverflow.com/questions/827557/how-do-you-validate-a-url-with-a-regular-expression-in-python # I preferred ...
python
def validate_url(self, original_string): """Returns the original string if it was valid, raises an argument error if it's not. """ # nipped from stack overflow: http://stackoverflow.com/questions/827557/how-do-you-validate-a-url-with-a-regular-expression-in-python # I preferred ...
[ "def", "validate_url", "(", "self", ",", "original_string", ")", ":", "pieces", "=", "urlparse", ".", "urlparse", "(", "original_string", ")", "try", ":", "if", "self", ".", "path_only", ":", "assert", "not", "any", "(", "[", "pieces", ".", "scheme", ","...
Returns the original string if it was valid, raises an argument error if it's not.
[ "Returns", "the", "original", "string", "if", "it", "was", "valid", "raises", "an", "argument", "error", "if", "it", "s", "not", "." ]
dc002ee6032c856551143af222ff8f71ed9853fe
https://github.com/Loudr/pale/blob/dc002ee6032c856551143af222ff8f71ed9853fe/pale/arguments/url.py#L15-L37
train
alextricity25/dwell_in_you_richly
diyr/utils/bible.py
Bible.get_chapter
def get_chapter(self, book_name, book_chapter, cache_chapter = True): """ Returns a chapter of the bible, first checking to see if that chapter is on disk. If not, hen it attempts to fetch it from the internet. NOTE: This is public facing method. If the method signature changes,...
python
def get_chapter(self, book_name, book_chapter, cache_chapter = True): """ Returns a chapter of the bible, first checking to see if that chapter is on disk. If not, hen it attempts to fetch it from the internet. NOTE: This is public facing method. If the method signature changes,...
[ "def", "get_chapter", "(", "self", ",", "book_name", ",", "book_chapter", ",", "cache_chapter", "=", "True", ")", ":", "try", ":", "logging", ".", "debug", "(", "\"Attempting to read chapter from disk\"", ")", "verses_list", "=", "self", ".", "_get_ondisk_chapter"...
Returns a chapter of the bible, first checking to see if that chapter is on disk. If not, hen it attempts to fetch it from the internet. NOTE: This is public facing method. If the method signature changes, then it needs to be documented and backwards-compatablity nee...
[ "Returns", "a", "chapter", "of", "the", "bible", "first", "checking", "to", "see", "if", "that", "chapter", "is", "on", "disk", ".", "If", "not", "hen", "it", "attempts", "to", "fetch", "it", "from", "the", "internet", "." ]
e705e1bc4fc0b8d2aa25680dfc432762b361c783
https://github.com/alextricity25/dwell_in_you_richly/blob/e705e1bc4fc0b8d2aa25680dfc432762b361c783/diyr/utils/bible.py#L122-L141
train
alextricity25/dwell_in_you_richly
diyr/utils/bible.py
Bible.verse_lookup
def verse_lookup(self, book_name, book_chapter, verse, cache_chapter = True): """ Looks up a verse from online.recoveryversion.bible, then returns it. """ verses_list = self.get_chapter( book_name, str(book_chapter), cache_chapter = cache_chapter) ...
python
def verse_lookup(self, book_name, book_chapter, verse, cache_chapter = True): """ Looks up a verse from online.recoveryversion.bible, then returns it. """ verses_list = self.get_chapter( book_name, str(book_chapter), cache_chapter = cache_chapter) ...
[ "def", "verse_lookup", "(", "self", ",", "book_name", ",", "book_chapter", ",", "verse", ",", "cache_chapter", "=", "True", ")", ":", "verses_list", "=", "self", ".", "get_chapter", "(", "book_name", ",", "str", "(", "book_chapter", ")", ",", "cache_chapter"...
Looks up a verse from online.recoveryversion.bible, then returns it.
[ "Looks", "up", "a", "verse", "from", "online", ".", "recoveryversion", ".", "bible", "then", "returns", "it", "." ]
e705e1bc4fc0b8d2aa25680dfc432762b361c783
https://github.com/alextricity25/dwell_in_you_richly/blob/e705e1bc4fc0b8d2aa25680dfc432762b361c783/diyr/utils/bible.py#L230-L238
train
projectshift/shift-schema
shiftschema/ext/flask_wtf.py
WtfSchemaMixin.validate_on_submit
def validate_on_submit(self): """ Extend validate on submit to allow validation with schema """ # validate form valid = FlaskWtf.validate_on_submit(self) # return in case no schema or not submitted if not self._schema or not self.is_submitted(): return valid ...
python
def validate_on_submit(self): """ Extend validate on submit to allow validation with schema """ # validate form valid = FlaskWtf.validate_on_submit(self) # return in case no schema or not submitted if not self._schema or not self.is_submitted(): return valid ...
[ "def", "validate_on_submit", "(", "self", ")", ":", "valid", "=", "FlaskWtf", ".", "validate_on_submit", "(", "self", ")", "if", "not", "self", ".", "_schema", "or", "not", "self", ".", "is_submitted", "(", ")", ":", "return", "valid", "data", "=", "dict...
Extend validate on submit to allow validation with schema
[ "Extend", "validate", "on", "submit", "to", "allow", "validation", "with", "schema" ]
07787b540d3369bb37217ffbfbe629118edaf0eb
https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/ext/flask_wtf.py#L13-L35
train
projectshift/shift-schema
shiftschema/ext/flask_wtf.py
WtfSchemaMixin.set_errors
def set_errors(self, result): """ Populate field errors with errors from schema validation """ # todo: use wtf locale errors = result.get_messages() for property_name in errors: if not hasattr(self, property_name): continue # ignore errors for missing fields...
python
def set_errors(self, result): """ Populate field errors with errors from schema validation """ # todo: use wtf locale errors = result.get_messages() for property_name in errors: if not hasattr(self, property_name): continue # ignore errors for missing fields...
[ "def", "set_errors", "(", "self", ",", "result", ")", ":", "errors", "=", "result", ".", "get_messages", "(", ")", "for", "property_name", "in", "errors", ":", "if", "not", "hasattr", "(", "self", ",", "property_name", ")", ":", "continue", "prop_errors", ...
Populate field errors with errors from schema validation
[ "Populate", "field", "errors", "with", "errors", "from", "schema", "validation" ]
07787b540d3369bb37217ffbfbe629118edaf0eb
https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/ext/flask_wtf.py#L40-L56
train
mediawiki-utilities/python-mwpersistence
mwpersistence/utilities/diffs2persistence.py
diffs2persistence
def diffs2persistence(rev_docs, window_size=50, revert_radius=15, sunset=None, verbose=False): """ Processes a sorted and page-partitioned sequence of revision documents into and adds a 'persistence' field to them containing statistics about how each token "added" in the revision p...
python
def diffs2persistence(rev_docs, window_size=50, revert_radius=15, sunset=None, verbose=False): """ Processes a sorted and page-partitioned sequence of revision documents into and adds a 'persistence' field to them containing statistics about how each token "added" in the revision p...
[ "def", "diffs2persistence", "(", "rev_docs", ",", "window_size", "=", "50", ",", "revert_radius", "=", "15", ",", "sunset", "=", "None", ",", "verbose", "=", "False", ")", ":", "rev_docs", "=", "mwxml", ".", "utilities", ".", "normalize", "(", "rev_docs", ...
Processes a sorted and page-partitioned sequence of revision documents into and adds a 'persistence' field to them containing statistics about how each token "added" in the revision persisted through future revisions. :Parameters: rev_docs : `iterable` ( `dict` ) JSON documents of revis...
[ "Processes", "a", "sorted", "and", "page", "-", "partitioned", "sequence", "of", "revision", "documents", "into", "and", "adds", "a", "persistence", "field", "to", "them", "containing", "statistics", "about", "how", "each", "token", "added", "in", "the", "revi...
2b98847fb8acaca38b3cbf94bde3fd7e27d2b67d
https://github.com/mediawiki-utilities/python-mwpersistence/blob/2b98847fb8acaca38b3cbf94bde3fd7e27d2b67d/mwpersistence/utilities/diffs2persistence.py#L100-L197
train
a1ezzz/wasp-general
wasp_general/crypto/hash.py
WHash.generator
def generator(name): """ Return generator by its name :param name: name of hash-generator :return: WHashGeneratorProto class """ name = name.upper() if name not in WHash.__hash_map__.keys(): raise ValueError('Hash generator "%s" not available' % name) return WHash.__hash_map__[name]
python
def generator(name): """ Return generator by its name :param name: name of hash-generator :return: WHashGeneratorProto class """ name = name.upper() if name not in WHash.__hash_map__.keys(): raise ValueError('Hash generator "%s" not available' % name) return WHash.__hash_map__[name]
[ "def", "generator", "(", "name", ")", ":", "name", "=", "name", ".", "upper", "(", ")", "if", "name", "not", "in", "WHash", ".", "__hash_map__", ".", "keys", "(", ")", ":", "raise", "ValueError", "(", "'Hash generator \"%s\" not available'", "%", "name", ...
Return generator by its name :param name: name of hash-generator :return: WHashGeneratorProto class
[ "Return", "generator", "by", "its", "name" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/crypto/hash.py#L241-L251
train
a1ezzz/wasp-general
wasp_general/crypto/hash.py
WHash.generator_by_digest
def generator_by_digest(family, digest_size): """ Return generator by hash generator family name and digest size :param family: name of hash-generator family :return: WHashGeneratorProto class """ for generator_name in WHash.available_generators(family=family): generator = WHash.generator(generator_name)...
python
def generator_by_digest(family, digest_size): """ Return generator by hash generator family name and digest size :param family: name of hash-generator family :return: WHashGeneratorProto class """ for generator_name in WHash.available_generators(family=family): generator = WHash.generator(generator_name)...
[ "def", "generator_by_digest", "(", "family", ",", "digest_size", ")", ":", "for", "generator_name", "in", "WHash", ".", "available_generators", "(", "family", "=", "family", ")", ":", "generator", "=", "WHash", ".", "generator", "(", "generator_name", ")", "if...
Return generator by hash generator family name and digest size :param family: name of hash-generator family :return: WHashGeneratorProto class
[ "Return", "generator", "by", "hash", "generator", "family", "name", "and", "digest", "size" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/crypto/hash.py#L254-L265
train
a1ezzz/wasp-general
wasp_general/network/messenger/session.py
WMessengerOnionSessionFlow.sequence
def sequence(cls, *info): """ Useful method to generate iterator. It is generated by chaining the given info. If no info is specified, then None is returned :param info: iterator info sequence :return: WMessengerOnionSessionFlowProto.Iterator or None """ if len(info) == 0: return info = list(info) ...
python
def sequence(cls, *info): """ Useful method to generate iterator. It is generated by chaining the given info. If no info is specified, then None is returned :param info: iterator info sequence :return: WMessengerOnionSessionFlowProto.Iterator or None """ if len(info) == 0: return info = list(info) ...
[ "def", "sequence", "(", "cls", ",", "*", "info", ")", ":", "if", "len", "(", "info", ")", "==", "0", ":", "return", "info", "=", "list", "(", "info", ")", "info", ".", "reverse", "(", ")", "result", "=", "WMessengerOnionSessionFlowProto", ".", "Itera...
Useful method to generate iterator. It is generated by chaining the given info. If no info is specified, then None is returned :param info: iterator info sequence :return: WMessengerOnionSessionFlowProto.Iterator or None
[ "Useful", "method", "to", "generate", "iterator", ".", "It", "is", "generated", "by", "chaining", "the", "given", "info", ".", "If", "no", "info", "is", "specified", "then", "None", "is", "returned" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/messenger/session.py#L58-L80
train
a1ezzz/wasp-general
wasp_general/network/primitives.py
WMACAddress.from_string
def from_string(address): """ Return new object by the given MAC-address :param address: address to convert :return: WMACAddress """ str_address = None if WMACAddress.re_dash_format.match(address): str_address = "".join(address.split("-")) elif WMACAddress.re_colon_format.match(address): str_addre...
python
def from_string(address): """ Return new object by the given MAC-address :param address: address to convert :return: WMACAddress """ str_address = None if WMACAddress.re_dash_format.match(address): str_address = "".join(address.split("-")) elif WMACAddress.re_colon_format.match(address): str_addre...
[ "def", "from_string", "(", "address", ")", ":", "str_address", "=", "None", "if", "WMACAddress", ".", "re_dash_format", ".", "match", "(", "address", ")", ":", "str_address", "=", "\"\"", ".", "join", "(", "address", ".", "split", "(", "\"-\"", ")", ")",...
Return new object by the given MAC-address :param address: address to convert :return: WMACAddress
[ "Return", "new", "object", "by", "the", "given", "MAC", "-", "address" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/primitives.py#L87-L113
train
a1ezzz/wasp-general
wasp_general/network/primitives.py
WIPV4Address.from_string
def from_string(address): """ Parse string for IPv4 address :param address: address to parse :return: """ address = address.split('.') if len(address) != WIPV4Address.octet_count: raise ValueError('Invalid ip address: %s' % address) result = WIPV4Address() for i in range(WIPV4Address.octet_count): ...
python
def from_string(address): """ Parse string for IPv4 address :param address: address to parse :return: """ address = address.split('.') if len(address) != WIPV4Address.octet_count: raise ValueError('Invalid ip address: %s' % address) result = WIPV4Address() for i in range(WIPV4Address.octet_count): ...
[ "def", "from_string", "(", "address", ")", ":", "address", "=", "address", ".", "split", "(", "'.'", ")", "if", "len", "(", "address", ")", "!=", "WIPV4Address", ".", "octet_count", ":", "raise", "ValueError", "(", "'Invalid ip address: %s'", "%", "address",...
Parse string for IPv4 address :param address: address to parse :return:
[ "Parse", "string", "for", "IPv4", "address" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/primitives.py#L173-L186
train
a1ezzz/wasp-general
wasp_general/network/primitives.py
WIPV4Address.to_string
def to_string(address, dns_format=False): """ Convert address to string :param address: WIPV4Address to convert :param dns_format: whether to use arpa-format or not :return: """ if isinstance(address, WIPV4Address) is False: raise TypeError('Invalid address type') address = [str(int(x)) for x in addr...
python
def to_string(address, dns_format=False): """ Convert address to string :param address: WIPV4Address to convert :param dns_format: whether to use arpa-format or not :return: """ if isinstance(address, WIPV4Address) is False: raise TypeError('Invalid address type') address = [str(int(x)) for x in addr...
[ "def", "to_string", "(", "address", ",", "dns_format", "=", "False", ")", ":", "if", "isinstance", "(", "address", ",", "WIPV4Address", ")", "is", "False", ":", "raise", "TypeError", "(", "'Invalid address type'", ")", "address", "=", "[", "str", "(", "int...
Convert address to string :param address: WIPV4Address to convert :param dns_format: whether to use arpa-format or not :return:
[ "Convert", "address", "to", "string" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/primitives.py#L190-L204
train
a1ezzz/wasp-general
wasp_general/network/primitives.py
WNetworkIPV4.first_address
def first_address(self, skip_network_address=True): """ Return the first IP address of this network :param skip_network_address: this flag specifies whether this function returns address of the network \ or returns address that follows address of the network (address, that a host could have) :return: WIPV4Addr...
python
def first_address(self, skip_network_address=True): """ Return the first IP address of this network :param skip_network_address: this flag specifies whether this function returns address of the network \ or returns address that follows address of the network (address, that a host could have) :return: WIPV4Addr...
[ "def", "first_address", "(", "self", ",", "skip_network_address", "=", "True", ")", ":", "bin_address", "=", "self", ".", "__address", ".", "bin_address", "(", ")", "bin_address_length", "=", "len", "(", "bin_address", ")", "if", "self", ".", "__mask", ">", ...
Return the first IP address of this network :param skip_network_address: this flag specifies whether this function returns address of the network \ or returns address that follows address of the network (address, that a host could have) :return: WIPV4Address
[ "Return", "the", "first", "IP", "address", "of", "this", "network" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/primitives.py#L269-L287
train
a1ezzz/wasp-general
wasp_general/network/primitives.py
WNetworkIPV4.last_address
def last_address(self, skip_broadcast_address=True): """ Return the last IP address of this network :param skip_broadcast_address: this flag specifies whether to skip the very last address (that is \ usually used as broadcast address) or not. :return: WIPV4Address """ bin_address = self.__address.bin_addre...
python
def last_address(self, skip_broadcast_address=True): """ Return the last IP address of this network :param skip_broadcast_address: this flag specifies whether to skip the very last address (that is \ usually used as broadcast address) or not. :return: WIPV4Address """ bin_address = self.__address.bin_addre...
[ "def", "last_address", "(", "self", ",", "skip_broadcast_address", "=", "True", ")", ":", "bin_address", "=", "self", ".", "__address", ".", "bin_address", "(", ")", "bin_address_length", "=", "len", "(", "bin_address", ")", "if", "self", ".", "__mask", ">",...
Return the last IP address of this network :param skip_broadcast_address: this flag specifies whether to skip the very last address (that is \ usually used as broadcast address) or not. :return: WIPV4Address
[ "Return", "the", "last", "IP", "address", "of", "this", "network" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/primitives.py#L290-L308
train
a1ezzz/wasp-general
wasp_general/network/primitives.py
WNetworkIPV4.iterator
def iterator(self, skip_network_address=True, skip_broadcast_address=True): """ Return iterator, that can iterate over network addresses :param skip_network_address: same as skip_network_address in :meth:`.NetworkIPV4.first_address` method :param skip_broadcast_address: same as skip_broadcast_address in :meth:`....
python
def iterator(self, skip_network_address=True, skip_broadcast_address=True): """ Return iterator, that can iterate over network addresses :param skip_network_address: same as skip_network_address in :meth:`.NetworkIPV4.first_address` method :param skip_broadcast_address: same as skip_broadcast_address in :meth:`....
[ "def", "iterator", "(", "self", ",", "skip_network_address", "=", "True", ",", "skip_broadcast_address", "=", "True", ")", ":", "return", "WNetworkIPV4Iterator", "(", "self", ",", "skip_network_address", ",", "skip_broadcast_address", ")" ]
Return iterator, that can iterate over network addresses :param skip_network_address: same as skip_network_address in :meth:`.NetworkIPV4.first_address` method :param skip_broadcast_address: same as skip_broadcast_address in :meth:`.NetworkIPV4.last_address` \ method :return: NetworkIPV4Iterator
[ "Return", "iterator", "that", "can", "iterate", "over", "network", "addresses" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/primitives.py#L310-L318
train
a1ezzz/wasp-general
wasp_general/network/primitives.py
WFQDN.from_string
def from_string(address): """ Convert doted-written FQDN address to WFQDN object :param address: address to convert :return: WFQDN """ if len(address) == 0: return WFQDN() if address[-1] == '.': address = address[:-1] if len(address) > WFQDN.maximum_fqdn_length: raise ValueError('Invalid addre...
python
def from_string(address): """ Convert doted-written FQDN address to WFQDN object :param address: address to convert :return: WFQDN """ if len(address) == 0: return WFQDN() if address[-1] == '.': address = address[:-1] if len(address) > WFQDN.maximum_fqdn_length: raise ValueError('Invalid addre...
[ "def", "from_string", "(", "address", ")", ":", "if", "len", "(", "address", ")", "==", "0", ":", "return", "WFQDN", "(", ")", "if", "address", "[", "-", "1", "]", "==", "'.'", ":", "address", "=", "address", "[", ":", "-", "1", "]", "if", "len...
Convert doted-written FQDN address to WFQDN object :param address: address to convert :return: WFQDN
[ "Convert", "doted", "-", "written", "FQDN", "address", "to", "WFQDN", "object" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/primitives.py#L443-L465
train
a1ezzz/wasp-general
wasp_general/network/primitives.py
WFQDN.to_string
def to_string(address, leading_dot=False): """ Return doted-written address by the given WFQDN object :param address: address to convert :param leading_dot: whether this function place leading dot to the result or not :return: str """ if isinstance(address, WFQDN) is False: raise TypeError('Invalid typ...
python
def to_string(address, leading_dot=False): """ Return doted-written address by the given WFQDN object :param address: address to convert :param leading_dot: whether this function place leading dot to the result or not :return: str """ if isinstance(address, WFQDN) is False: raise TypeError('Invalid typ...
[ "def", "to_string", "(", "address", ",", "leading_dot", "=", "False", ")", ":", "if", "isinstance", "(", "address", ",", "WFQDN", ")", "is", "False", ":", "raise", "TypeError", "(", "'Invalid type for FQDN address'", ")", "result", "=", "'.'", ".", "join", ...
Return doted-written address by the given WFQDN object :param address: address to convert :param leading_dot: whether this function place leading dot to the result or not :return: str
[ "Return", "doted", "-", "written", "address", "by", "the", "given", "WFQDN", "object" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/primitives.py#L469-L481
train
olitheolix/qtmacs
qtmacs/base_applet.py
QtmacsApplet.qteReparent
def qteReparent(self, parent): """ Re-parent the applet. This is little more then calling Qt's native ``setParent()`` method but also updates the ``qteParentWindow`` handle. This method is usually called when the applet is added/removed from a splitter and thus requires ...
python
def qteReparent(self, parent): """ Re-parent the applet. This is little more then calling Qt's native ``setParent()`` method but also updates the ``qteParentWindow`` handle. This method is usually called when the applet is added/removed from a splitter and thus requires ...
[ "def", "qteReparent", "(", "self", ",", "parent", ")", ":", "self", ".", "setParent", "(", "parent", ")", "try", ":", "self", ".", "_qteAdmin", ".", "parentWindow", "=", "parent", ".", "qteParentWindow", "(", ")", "except", "AttributeError", ":", "self", ...
Re-parent the applet. This is little more then calling Qt's native ``setParent()`` method but also updates the ``qteParentWindow`` handle. This method is usually called when the applet is added/removed from a splitter and thus requires re-parenting. |Args| * ``parent``...
[ "Re", "-", "parent", "the", "applet", "." ]
36253b082b82590f183fe154b053eb3a1e741be2
https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/base_applet.py#L222-L257
train
olitheolix/qtmacs
qtmacs/base_applet.py
QtmacsApplet.qteAddWidget
def qteAddWidget(self, widgetObj: QtGui.QWidget, isFocusable: bool=True, widgetSignature: str=None, autoBind: bool=True): """ Augment the standard Qt ``widgetObj`` with Qtmacs specific fields. Example: from a programmers perspective there is no difference between:: ...
python
def qteAddWidget(self, widgetObj: QtGui.QWidget, isFocusable: bool=True, widgetSignature: str=None, autoBind: bool=True): """ Augment the standard Qt ``widgetObj`` with Qtmacs specific fields. Example: from a programmers perspective there is no difference between:: ...
[ "def", "qteAddWidget", "(", "self", ",", "widgetObj", ":", "QtGui", ".", "QWidget", ",", "isFocusable", ":", "bool", "=", "True", ",", "widgetSignature", ":", "str", "=", "None", ",", "autoBind", ":", "bool", "=", "True", ")", ":", "widgetObj", ".", "_...
Augment the standard Qt ``widgetObj`` with Qtmacs specific fields. Example: from a programmers perspective there is no difference between:: wid = QtGui.QTextEdit(self) and:: wid = self.qteAddWidget(QtGui.QTextEdit(self)) Both return a handle to a Qt widget (a...
[ "Augment", "the", "standard", "Qt", "widgetObj", "with", "Qtmacs", "specific", "fields", "." ]
36253b082b82590f183fe154b053eb3a1e741be2
https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/base_applet.py#L260-L383
train
olitheolix/qtmacs
qtmacs/base_applet.py
QtmacsApplet.qteSetAppletSignature
def qteSetAppletSignature(self, signature: str): """ Specify the applet signature. This signature is used by Qtmacs at run time to determine which macros are compatible with the apple. Macros have an identically called method so that Qtmacs can determine which macros are...
python
def qteSetAppletSignature(self, signature: str): """ Specify the applet signature. This signature is used by Qtmacs at run time to determine which macros are compatible with the apple. Macros have an identically called method so that Qtmacs can determine which macros are...
[ "def", "qteSetAppletSignature", "(", "self", ",", "signature", ":", "str", ")", ":", "if", "'*'", "in", "signature", ":", "raise", "QtmacsOtherError", "(", "'The applet signature must not contain \"*\"'", ")", "if", "signature", "==", "''", ":", "raise", "QtmacsOt...
Specify the applet signature. This signature is used by Qtmacs at run time to determine which macros are compatible with the apple. Macros have an identically called method so that Qtmacs can determine which macros are compatible with which applets. This method is typically call...
[ "Specify", "the", "applet", "signature", "." ]
36253b082b82590f183fe154b053eb3a1e741be2
https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/base_applet.py#L386-L425
train
olitheolix/qtmacs
qtmacs/base_applet.py
QtmacsApplet.qteAutoremoveDeletedWidgets
def qteAutoremoveDeletedWidgets(self): """ Remove all widgets from the internal widget list that do not exist anymore according to SIP. |Args| * **None** |Returns| * **None** |Raises| * **None** """ widget_list = self._qteAdmi...
python
def qteAutoremoveDeletedWidgets(self): """ Remove all widgets from the internal widget list that do not exist anymore according to SIP. |Args| * **None** |Returns| * **None** |Raises| * **None** """ widget_list = self._qteAdmi...
[ "def", "qteAutoremoveDeletedWidgets", "(", "self", ")", ":", "widget_list", "=", "self", ".", "_qteAdmin", ".", "widgetList", "deleted_widgets", "=", "[", "_", "for", "_", "in", "widget_list", "if", "sip", ".", "isdeleted", "(", "_", ")", "]", "for", "widg...
Remove all widgets from the internal widget list that do not exist anymore according to SIP. |Args| * **None** |Returns| * **None** |Raises| * **None**
[ "Remove", "all", "widgets", "from", "the", "internal", "widget", "list", "that", "do", "not", "exist", "anymore", "according", "to", "SIP", "." ]
36253b082b82590f183fe154b053eb3a1e741be2
https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/base_applet.py#L446-L466
train
olitheolix/qtmacs
qtmacs/base_applet.py
QtmacsApplet.qteSetWidgetFocusOrder
def qteSetWidgetFocusOrder(self, widList: tuple): """ Change the focus order of the widgets in this applet. This method re-arranges the internal (cyclic) widget list so that all widgets specified in ``widList`` will be focused in the given order. |Args| * ``wid...
python
def qteSetWidgetFocusOrder(self, widList: tuple): """ Change the focus order of the widgets in this applet. This method re-arranges the internal (cyclic) widget list so that all widgets specified in ``widList`` will be focused in the given order. |Args| * ``wid...
[ "def", "qteSetWidgetFocusOrder", "(", "self", ",", "widList", ":", "tuple", ")", ":", "if", "len", "(", "widList", ")", "<", "2", ":", "return", "self", ".", "qteAutoremoveDeletedWidgets", "(", ")", "widList", "=", "[", "_", "for", "_", "in", "widList", ...
Change the focus order of the widgets in this applet. This method re-arranges the internal (cyclic) widget list so that all widgets specified in ``widList`` will be focused in the given order. |Args| * ``widList`` (**tuple**): a tuple of widget objects. |Returns| ...
[ "Change", "the", "focus", "order", "of", "the", "widgets", "in", "this", "applet", "." ]
36253b082b82590f183fe154b053eb3a1e741be2
https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/base_applet.py#L469-L529
train
olitheolix/qtmacs
qtmacs/base_applet.py
QtmacsApplet.qteNextWidget
def qteNextWidget(self, numSkip: int=1, ofsWidget: QtGui.QWidget=None, skipVisible: bool=False, skipInvisible: bool=True, skipFocusable: bool=False, skipUnfocusable: bool=True): """ Return the next widget in cyclic order. If ``of...
python
def qteNextWidget(self, numSkip: int=1, ofsWidget: QtGui.QWidget=None, skipVisible: bool=False, skipInvisible: bool=True, skipFocusable: bool=False, skipUnfocusable: bool=True): """ Return the next widget in cyclic order. If ``of...
[ "def", "qteNextWidget", "(", "self", ",", "numSkip", ":", "int", "=", "1", ",", "ofsWidget", ":", "QtGui", ".", "QWidget", "=", "None", ",", "skipVisible", ":", "bool", "=", "False", ",", "skipInvisible", ":", "bool", "=", "True", ",", "skipFocusable", ...
Return the next widget in cyclic order. If ``ofsWidget`` is **None** then start counting at the currently active widget and return the applet ``numSkip`` items away in cyclic order in the internal widget list. If ``numSkip`` is positive traverse the applet list forwards, otherwi...
[ "Return", "the", "next", "widget", "in", "cyclic", "order", "." ]
36253b082b82590f183fe154b053eb3a1e741be2
https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/base_applet.py#L532-L638
train
olitheolix/qtmacs
qtmacs/base_applet.py
QtmacsApplet.qteMakeWidgetActive
def qteMakeWidgetActive(self, widgetObj: QtGui.QWidget): """ Give keyboard focus to ``widgetObj``. If ``widgetObj`` is **None** then the internal focus state is reset, but the focus manger will automatically activate the first available widget again. |Args| * `...
python
def qteMakeWidgetActive(self, widgetObj: QtGui.QWidget): """ Give keyboard focus to ``widgetObj``. If ``widgetObj`` is **None** then the internal focus state is reset, but the focus manger will automatically activate the first available widget again. |Args| * `...
[ "def", "qteMakeWidgetActive", "(", "self", ",", "widgetObj", ":", "QtGui", ".", "QWidget", ")", ":", "if", "widgetObj", "is", "None", ":", "self", ".", "_qteActiveWidget", "=", "None", "return", "if", "qteGetAppletFromWidget", "(", "widgetObj", ")", "is", "n...
Give keyboard focus to ``widgetObj``. If ``widgetObj`` is **None** then the internal focus state is reset, but the focus manger will automatically activate the first available widget again. |Args| * ``widgetObj`` (**QWidget**): the widget to focus on. |Returns| ...
[ "Give", "keyboard", "focus", "to", "widgetObj", "." ]
36253b082b82590f183fe154b053eb3a1e741be2
https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/base_applet.py#L641-L698
train
sublee/etc
etc/adapters/mock.py
split_key
def split_key(key): """Splits a node key.""" if key == KEY_SEP: return () key_chunks = tuple(key.strip(KEY_SEP).split(KEY_SEP)) if key_chunks[0].startswith(KEY_SEP): return (key_chunks[0][len(KEY_SEP):],) + key_chunks[1:] else: return key_chunks
python
def split_key(key): """Splits a node key.""" if key == KEY_SEP: return () key_chunks = tuple(key.strip(KEY_SEP).split(KEY_SEP)) if key_chunks[0].startswith(KEY_SEP): return (key_chunks[0][len(KEY_SEP):],) + key_chunks[1:] else: return key_chunks
[ "def", "split_key", "(", "key", ")", ":", "if", "key", "==", "KEY_SEP", ":", "return", "(", ")", "key_chunks", "=", "tuple", "(", "key", ".", "strip", "(", "KEY_SEP", ")", ".", "split", "(", "KEY_SEP", ")", ")", "if", "key_chunks", "[", "0", "]", ...
Splits a node key.
[ "Splits", "a", "node", "key", "." ]
f2be64604da5af0d7739cfacf36f55712f0fc5cb
https://github.com/sublee/etc/blob/f2be64604da5af0d7739cfacf36f55712f0fc5cb/etc/adapters/mock.py#L32-L40
train
sublee/etc
etc/adapters/mock.py
MockNode.set
def set(self, index, value=None, dir=False, ttl=None, expiration=None): """Updates the node data.""" if bool(dir) is (value is not None): raise TypeError('Choose one of value or directory') if (ttl is not None) is (expiration is None): raise TypeError('Both of ttl and exp...
python
def set(self, index, value=None, dir=False, ttl=None, expiration=None): """Updates the node data.""" if bool(dir) is (value is not None): raise TypeError('Choose one of value or directory') if (ttl is not None) is (expiration is None): raise TypeError('Both of ttl and exp...
[ "def", "set", "(", "self", ",", "index", ",", "value", "=", "None", ",", "dir", "=", "False", ",", "ttl", "=", "None", ",", "expiration", "=", "None", ")", ":", "if", "bool", "(", "dir", ")", "is", "(", "value", "is", "not", "None", ")", ":", ...
Updates the node data.
[ "Updates", "the", "node", "data", "." ]
f2be64604da5af0d7739cfacf36f55712f0fc5cb
https://github.com/sublee/etc/blob/f2be64604da5af0d7739cfacf36f55712f0fc5cb/etc/adapters/mock.py#L54-L66
train
sublee/etc
etc/adapters/mock.py
MockAdapter.make_result
def make_result(self, result_class, node=None, prev_node=None, remember=True, key_chunks=None, notify=True, **kwargs): """Makes an etcd result. If `remember` is ``True``, it keeps the result in the history and triggers events if waiting. `key_chunks` is the result of ...
python
def make_result(self, result_class, node=None, prev_node=None, remember=True, key_chunks=None, notify=True, **kwargs): """Makes an etcd result. If `remember` is ``True``, it keeps the result in the history and triggers events if waiting. `key_chunks` is the result of ...
[ "def", "make_result", "(", "self", ",", "result_class", ",", "node", "=", "None", ",", "prev_node", "=", "None", ",", "remember", "=", "True", ",", "key_chunks", "=", "None", ",", "notify", "=", "True", ",", "**", "kwargs", ")", ":", "def", "canonicali...
Makes an etcd result. If `remember` is ``True``, it keeps the result in the history and triggers events if waiting. `key_chunks` is the result of :func:`split_key` of the `node.key`. It is not required if `remember` is ``False``. Otherwise, it is optional but recommended to eliminate...
[ "Makes", "an", "etcd", "result", "." ]
f2be64604da5af0d7739cfacf36f55712f0fc5cb
https://github.com/sublee/etc/blob/f2be64604da5af0d7739cfacf36f55712f0fc5cb/etc/adapters/mock.py#L124-L161
train
haum/hms_base
hms_base/client.py
Client.connect
def connect(self, host='localhost'): """Connect to the server and set everything up. Args: host: hostname to connect to """ # Connect get_logger().info("Connecting to RabbitMQ server...") self._conn = pika.BlockingConnection( pika.ConnectionPa...
python
def connect(self, host='localhost'): """Connect to the server and set everything up. Args: host: hostname to connect to """ # Connect get_logger().info("Connecting to RabbitMQ server...") self._conn = pika.BlockingConnection( pika.ConnectionPa...
[ "def", "connect", "(", "self", ",", "host", "=", "'localhost'", ")", ":", "get_logger", "(", ")", ".", "info", "(", "\"Connecting to RabbitMQ server...\"", ")", "self", ".", "_conn", "=", "pika", ".", "BlockingConnection", "(", "pika", ".", "ConnectionParamete...
Connect to the server and set everything up. Args: host: hostname to connect to
[ "Connect", "to", "the", "server", "and", "set", "everything", "up", "." ]
7c0aed961b43cba043c703102e503cb40db81f58
https://github.com/haum/hms_base/blob/7c0aed961b43cba043c703102e503cb40db81f58/hms_base/client.py#L45-L106
train
haum/hms_base
hms_base/client.py
Client.publish
def publish(self, topic, dct): """Send a dict with internal routing key to the exchange. Args: topic: topic to publish the message to dct: dict object to send """ get_logger().info("Publishing message {} on routing key " "{}...".format(...
python
def publish(self, topic, dct): """Send a dict with internal routing key to the exchange. Args: topic: topic to publish the message to dct: dict object to send """ get_logger().info("Publishing message {} on routing key " "{}...".format(...
[ "def", "publish", "(", "self", ",", "topic", ",", "dct", ")", ":", "get_logger", "(", ")", ".", "info", "(", "\"Publishing message {} on routing key \"", "\"{}...\"", ".", "format", "(", "dct", ",", "topic", ")", ")", "self", ".", "_channel", ".", "basic_p...
Send a dict with internal routing key to the exchange. Args: topic: topic to publish the message to dct: dict object to send
[ "Send", "a", "dict", "with", "internal", "routing", "key", "to", "the", "exchange", "." ]
7c0aed961b43cba043c703102e503cb40db81f58
https://github.com/haum/hms_base/blob/7c0aed961b43cba043c703102e503cb40db81f58/hms_base/client.py#L108-L123
train
haum/hms_base
hms_base/client.py
Client._callback
def _callback(self, ch, method, properties, body): """Internal method that will be called when receiving message.""" get_logger().info("Message received! Calling listeners...") topic = method.routing_key dct = json.loads(body.decode('utf-8')) for listener in self.listeners: ...
python
def _callback(self, ch, method, properties, body): """Internal method that will be called when receiving message.""" get_logger().info("Message received! Calling listeners...") topic = method.routing_key dct = json.loads(body.decode('utf-8')) for listener in self.listeners: ...
[ "def", "_callback", "(", "self", ",", "ch", ",", "method", ",", "properties", ",", "body", ")", ":", "get_logger", "(", ")", ".", "info", "(", "\"Message received! Calling listeners...\"", ")", "topic", "=", "method", ".", "routing_key", "dct", "=", "json", ...
Internal method that will be called when receiving message.
[ "Internal", "method", "that", "will", "be", "called", "when", "receiving", "message", "." ]
7c0aed961b43cba043c703102e503cb40db81f58
https://github.com/haum/hms_base/blob/7c0aed961b43cba043c703102e503cb40db81f58/hms_base/client.py#L140-L149
train
haum/hms_base
hms_base/client.py
Client._handle_ping
def _handle_ping(client, topic, dct): """Internal method that will be called when receiving ping message.""" if dct['type'] == 'request': resp = { 'type': 'answer', 'name': client.name, 'source': dct } client.publish('p...
python
def _handle_ping(client, topic, dct): """Internal method that will be called when receiving ping message.""" if dct['type'] == 'request': resp = { 'type': 'answer', 'name': client.name, 'source': dct } client.publish('p...
[ "def", "_handle_ping", "(", "client", ",", "topic", ",", "dct", ")", ":", "if", "dct", "[", "'type'", "]", "==", "'request'", ":", "resp", "=", "{", "'type'", ":", "'answer'", ",", "'name'", ":", "client", ".", "name", ",", "'source'", ":", "dct", ...
Internal method that will be called when receiving ping message.
[ "Internal", "method", "that", "will", "be", "called", "when", "receiving", "ping", "message", "." ]
7c0aed961b43cba043c703102e503cb40db81f58
https://github.com/haum/hms_base/blob/7c0aed961b43cba043c703102e503cb40db81f58/hms_base/client.py#L153-L162
train
pmacosta/pexdoc
pexdoc/pcontracts.py
_create_argument_value_pairs
def _create_argument_value_pairs(func, *args, **kwargs): """ Create dictionary with argument names as keys and their passed values as values. An empty dictionary is returned if an error is detected, such as more arguments than in the function definition, argument(s) defined by position and keyword,...
python
def _create_argument_value_pairs(func, *args, **kwargs): """ Create dictionary with argument names as keys and their passed values as values. An empty dictionary is returned if an error is detected, such as more arguments than in the function definition, argument(s) defined by position and keyword,...
[ "def", "_create_argument_value_pairs", "(", "func", ",", "*", "args", ",", "**", "kwargs", ")", ":", "try", ":", "arg_dict", "=", "signature", "(", "func", ")", ".", "bind_partial", "(", "*", "args", ",", "**", "kwargs", ")", ".", "arguments", "except", ...
Create dictionary with argument names as keys and their passed values as values. An empty dictionary is returned if an error is detected, such as more arguments than in the function definition, argument(s) defined by position and keyword, etc.
[ "Create", "dictionary", "with", "argument", "names", "as", "keys", "and", "their", "passed", "values", "as", "values", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/pcontracts.py#L48-L69
train
pmacosta/pexdoc
pexdoc/pcontracts.py
_get_contract_exception_dict
def _get_contract_exception_dict(contract_msg): """Generate message for exception.""" # A pcontract-defined custom exception message is wrapped in a string # that starts with '[START CONTRACT MSG:' and ends with # '[STOP CONTRACT MSG]'. This is done to easily detect if an # exception raised is from ...
python
def _get_contract_exception_dict(contract_msg): """Generate message for exception.""" # A pcontract-defined custom exception message is wrapped in a string # that starts with '[START CONTRACT MSG:' and ends with # '[STOP CONTRACT MSG]'. This is done to easily detect if an # exception raised is from ...
[ "def", "_get_contract_exception_dict", "(", "contract_msg", ")", ":", "start_token", "=", "\"[START CONTRACT MSG: \"", "stop_token", "=", "\"[STOP CONTRACT MSG]\"", "if", "contract_msg", ".", "find", "(", "start_token", ")", "==", "-", "1", ":", "return", "{", "\"nu...
Generate message for exception.
[ "Generate", "message", "for", "exception", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/pcontracts.py#L134-L161
train
pmacosta/pexdoc
pexdoc/pcontracts.py
_get_custom_contract
def _get_custom_contract(param_contract): """Return True if parameter contract is a custom contract, False otherwise.""" if not isinstance(param_contract, str): return None for custom_contract in _CUSTOM_CONTRACTS: if re.search(r"\b{0}\b".format(custom_contract), param_contract): ...
python
def _get_custom_contract(param_contract): """Return True if parameter contract is a custom contract, False otherwise.""" if not isinstance(param_contract, str): return None for custom_contract in _CUSTOM_CONTRACTS: if re.search(r"\b{0}\b".format(custom_contract), param_contract): ...
[ "def", "_get_custom_contract", "(", "param_contract", ")", ":", "if", "not", "isinstance", "(", "param_contract", ",", "str", ")", ":", "return", "None", "for", "custom_contract", "in", "_CUSTOM_CONTRACTS", ":", "if", "re", ".", "search", "(", "r\"\\b{0}\\b\"", ...
Return True if parameter contract is a custom contract, False otherwise.
[ "Return", "True", "if", "parameter", "contract", "is", "a", "custom", "contract", "False", "otherwise", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/pcontracts.py#L164-L171
train
pmacosta/pexdoc
pexdoc/pcontracts.py
_get_replacement_token
def _get_replacement_token(msg): """Extract replacement token from exception message.""" return ( None if not re.search(r"\*\[[\w|\W]+\]\*", msg) else re.search(r"\*\[[\w|\W]+\]\*", msg).group()[2:-2] )
python
def _get_replacement_token(msg): """Extract replacement token from exception message.""" return ( None if not re.search(r"\*\[[\w|\W]+\]\*", msg) else re.search(r"\*\[[\w|\W]+\]\*", msg).group()[2:-2] )
[ "def", "_get_replacement_token", "(", "msg", ")", ":", "return", "(", "None", "if", "not", "re", ".", "search", "(", "r\"\\*\\[[\\w|\\W]+\\]\\*\"", ",", "msg", ")", "else", "re", ".", "search", "(", "r\"\\*\\[[\\w|\\W]+\\]\\*\"", ",", "msg", ")", ".", "group...
Extract replacement token from exception message.
[ "Extract", "replacement", "token", "from", "exception", "message", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/pcontracts.py#L304-L310
train
contains-io/typet
typet/objects.py
_get_type_name
def _get_type_name(type_): # type: (type) -> str """Return a displayable name for the type. Args: type_: A class object. Returns: A string value describing the class name that can be used in a natural language sentence. """ name = repr(type_) if name.startswith("<")...
python
def _get_type_name(type_): # type: (type) -> str """Return a displayable name for the type. Args: type_: A class object. Returns: A string value describing the class name that can be used in a natural language sentence. """ name = repr(type_) if name.startswith("<")...
[ "def", "_get_type_name", "(", "type_", ")", ":", "name", "=", "repr", "(", "type_", ")", "if", "name", ".", "startswith", "(", "\"<\"", ")", ":", "name", "=", "getattr", "(", "type_", ",", "\"__qualname__\"", ",", "getattr", "(", "type_", ",", "\"__nam...
Return a displayable name for the type. Args: type_: A class object. Returns: A string value describing the class name that can be used in a natural language sentence.
[ "Return", "a", "displayable", "name", "for", "the", "type", "." ]
ad5087c567af84db299eca186776e1cee228e442
https://github.com/contains-io/typet/blob/ad5087c567af84db299eca186776e1cee228e442/typet/objects.py#L46-L60
train
contains-io/typet
typet/objects.py
_get_class_frame_source
def _get_class_frame_source(class_name): # type: (str) -> Optional[str] """Return the source code for a class by checking the frame stack. This is necessary because it is not possible to get the source of a class being created by a metaclass directly. Args: class_name: The class to look fo...
python
def _get_class_frame_source(class_name): # type: (str) -> Optional[str] """Return the source code for a class by checking the frame stack. This is necessary because it is not possible to get the source of a class being created by a metaclass directly. Args: class_name: The class to look fo...
[ "def", "_get_class_frame_source", "(", "class_name", ")", ":", "for", "frame_info", "in", "inspect", ".", "stack", "(", ")", ":", "try", ":", "with", "open", "(", "frame_info", "[", "1", "]", ")", "as", "fp", ":", "src", "=", "\"\"", ".", "join", "("...
Return the source code for a class by checking the frame stack. This is necessary because it is not possible to get the source of a class being created by a metaclass directly. Args: class_name: The class to look for on the stack. Returns: The source code for the requested class if th...
[ "Return", "the", "source", "code", "for", "a", "class", "by", "checking", "the", "frame", "stack", "." ]
ad5087c567af84db299eca186776e1cee228e442
https://github.com/contains-io/typet/blob/ad5087c567af84db299eca186776e1cee228e442/typet/objects.py#L63-L107
train
contains-io/typet
typet/objects.py
_is_propertyable
def _is_propertyable( names, # type: List[str] attrs, # type: Dict[str, Any] annotations, # type: Dict[str, type] attr, # Dict[str, Any] ): # type: (...) -> bool """Determine if an attribute can be replaced with a property. Args: names: The complete list of all attribute names f...
python
def _is_propertyable( names, # type: List[str] attrs, # type: Dict[str, Any] annotations, # type: Dict[str, type] attr, # Dict[str, Any] ): # type: (...) -> bool """Determine if an attribute can be replaced with a property. Args: names: The complete list of all attribute names f...
[ "def", "_is_propertyable", "(", "names", ",", "attrs", ",", "annotations", ",", "attr", ",", ")", ":", "return", "(", "attr", "in", "annotations", "and", "not", "attr", ".", "startswith", "(", "\"_\"", ")", "and", "not", "attr", ".", "isupper", "(", ")...
Determine if an attribute can be replaced with a property. Args: names: The complete list of all attribute names for the class. attrs: The attribute dict returned by __prepare__. annotations: A mapping of all defined annotations for the class. attr: The attribute to test. Retur...
[ "Determine", "if", "an", "attribute", "can", "be", "replaced", "with", "a", "property", "." ]
ad5087c567af84db299eca186776e1cee228e442
https://github.com/contains-io/typet/blob/ad5087c567af84db299eca186776e1cee228e442/typet/objects.py#L110-L134
train
contains-io/typet
typet/objects.py
_create_typed_object_meta
def _create_typed_object_meta(get_fset): # type: (Callable[[str, str, Type[_T]], Callable[[_T], None]]) -> type """Create a metaclass for typed objects. Args: get_fset: A function that takes three parameters: the name of an attribute, the name of the private attribute that holds the ...
python
def _create_typed_object_meta(get_fset): # type: (Callable[[str, str, Type[_T]], Callable[[_T], None]]) -> type """Create a metaclass for typed objects. Args: get_fset: A function that takes three parameters: the name of an attribute, the name of the private attribute that holds the ...
[ "def", "_create_typed_object_meta", "(", "get_fset", ")", ":", "def", "_get_fget", "(", "attr", ",", "private_attr", ",", "type_", ")", ":", "def", "_fget", "(", "self", ")", ":", "try", ":", "return", "getattr", "(", "self", ",", "private_attr", ")", "e...
Create a metaclass for typed objects. Args: get_fset: A function that takes three parameters: the name of an attribute, the name of the private attribute that holds the property data, and a type. This function must an object method that accepts a value. Returns: ...
[ "Create", "a", "metaclass", "for", "typed", "objects", "." ]
ad5087c567af84db299eca186776e1cee228e442
https://github.com/contains-io/typet/blob/ad5087c567af84db299eca186776e1cee228e442/typet/objects.py#L137-L256
train
contains-io/typet
typet/objects.py
_AnnotatedObjectComparisonMixin._tp__get_typed_properties
def _tp__get_typed_properties(self): """Return a tuple of typed attrs that can be used for comparisons. Raises: NotImplementedError: Raised if this class was mixed into a class that was not created by _AnnotatedObjectMeta. """ try: return tuple(ge...
python
def _tp__get_typed_properties(self): """Return a tuple of typed attrs that can be used for comparisons. Raises: NotImplementedError: Raised if this class was mixed into a class that was not created by _AnnotatedObjectMeta. """ try: return tuple(ge...
[ "def", "_tp__get_typed_properties", "(", "self", ")", ":", "try", ":", "return", "tuple", "(", "getattr", "(", "self", ",", "p", ")", "for", "p", "in", "self", ".", "_tp__typed_properties", ")", "except", "AttributeError", ":", "raise", "NotImplementedError" ]
Return a tuple of typed attrs that can be used for comparisons. Raises: NotImplementedError: Raised if this class was mixed into a class that was not created by _AnnotatedObjectMeta.
[ "Return", "a", "tuple", "of", "typed", "attrs", "that", "can", "be", "used", "for", "comparisons", "." ]
ad5087c567af84db299eca186776e1cee228e442
https://github.com/contains-io/typet/blob/ad5087c567af84db299eca186776e1cee228e442/typet/objects.py#L398-L408
train
dmonroy/chilero
chilero/web/__init__.py
run
def run(cls, routes, *args, **kwargs): # pragma: no cover """ Run a web application. :param cls: Application class :param routes: list of routes :param args: additional arguments :param kwargs: additional keyword arguments :return: None """ app = init(cls, routes, *args, **kwargs) ...
python
def run(cls, routes, *args, **kwargs): # pragma: no cover """ Run a web application. :param cls: Application class :param routes: list of routes :param args: additional arguments :param kwargs: additional keyword arguments :return: None """ app = init(cls, routes, *args, **kwargs) ...
[ "def", "run", "(", "cls", ",", "routes", ",", "*", "args", ",", "**", "kwargs", ")", ":", "app", "=", "init", "(", "cls", ",", "routes", ",", "*", "args", ",", "**", "kwargs", ")", "HOST", "=", "os", ".", "getenv", "(", "'HOST'", ",", "'0.0.0.0...
Run a web application. :param cls: Application class :param routes: list of routes :param args: additional arguments :param kwargs: additional keyword arguments :return: None
[ "Run", "a", "web", "application", "." ]
8f1118a60cb7eab3f9ad31cb8a14b30bc102893d
https://github.com/dmonroy/chilero/blob/8f1118a60cb7eab3f9ad31cb8a14b30bc102893d/chilero/web/__init__.py#L25-L41
train
vecnet/vecnet.openmalaria
vecnet/openmalaria/scenario/entomology.py
Vectors.add
def add(self, vector, InterventionAnophelesParams=None): """ Add a vector to entomology section. vector is either ElementTree or xml snippet InterventionAnophelesParams is an anophelesParams section for every GVI, ITN and IRS intervention already defined in the scenario.xml ...
python
def add(self, vector, InterventionAnophelesParams=None): """ Add a vector to entomology section. vector is either ElementTree or xml snippet InterventionAnophelesParams is an anophelesParams section for every GVI, ITN and IRS intervention already defined in the scenario.xml ...
[ "def", "add", "(", "self", ",", "vector", ",", "InterventionAnophelesParams", "=", "None", ")", ":", "assert", "isinstance", "(", "vector", ",", "six", ".", "string_types", ")", "et", "=", "ElementTree", ".", "fromstring", "(", "vector", ")", "mosquito", "...
Add a vector to entomology section. vector is either ElementTree or xml snippet InterventionAnophelesParams is an anophelesParams section for every GVI, ITN and IRS intervention already defined in the scenario.xml
[ "Add", "a", "vector", "to", "entomology", "section", ".", "vector", "is", "either", "ElementTree", "or", "xml", "snippet" ]
795bc9d1b81a6c664f14879edda7a7c41188e95a
https://github.com/vecnet/vecnet.openmalaria/blob/795bc9d1b81a6c664f14879edda7a7c41188e95a/vecnet/openmalaria/scenario/entomology.py#L197-L222
train
pmacosta/pexdoc
pexdoc/exdoc.py
_format_msg
def _format_msg(text, width, indent=0, prefix=""): r""" Format exception message. Replace newline characters \n with ``\n``, ` with \` and then wrap text as needed """ text = repr(text).replace("`", "\\`").replace("\\n", " ``\\n`` ") sindent = " " * indent if not prefix else prefix wrap...
python
def _format_msg(text, width, indent=0, prefix=""): r""" Format exception message. Replace newline characters \n with ``\n``, ` with \` and then wrap text as needed """ text = repr(text).replace("`", "\\`").replace("\\n", " ``\\n`` ") sindent = " " * indent if not prefix else prefix wrap...
[ "def", "_format_msg", "(", "text", ",", "width", ",", "indent", "=", "0", ",", "prefix", "=", "\"\"", ")", ":", "r", "text", "=", "repr", "(", "text", ")", ".", "replace", "(", "\"`\"", ",", "\"\\\\`\"", ")", ".", "replace", "(", "\"\\\\n\"", ",", ...
r""" Format exception message. Replace newline characters \n with ``\n``, ` with \` and then wrap text as needed
[ "r", "Format", "exception", "message", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exdoc.py#L44-L55
train
pmacosta/pexdoc
pexdoc/exdoc.py
_validate_fname
def _validate_fname(fname, arg_name): """Validate that a string is a valid file name.""" if fname is not None: msg = "Argument `{0}` is not valid".format(arg_name) if (not isinstance(fname, str)) or (isinstance(fname, str) and ("\0" in fname)): raise RuntimeError(msg) try: ...
python
def _validate_fname(fname, arg_name): """Validate that a string is a valid file name.""" if fname is not None: msg = "Argument `{0}` is not valid".format(arg_name) if (not isinstance(fname, str)) or (isinstance(fname, str) and ("\0" in fname)): raise RuntimeError(msg) try: ...
[ "def", "_validate_fname", "(", "fname", ",", "arg_name", ")", ":", "if", "fname", "is", "not", "None", ":", "msg", "=", "\"Argument `{0}` is not valid\"", ".", "format", "(", "arg_name", ")", "if", "(", "not", "isinstance", "(", "fname", ",", "str", ")", ...
Validate that a string is a valid file name.
[ "Validate", "that", "a", "string", "is", "a", "valid", "file", "name", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exdoc.py#L58-L68
train
pmacosta/pexdoc
pexdoc/exdoc.py
ExDoc._build_ex_tree
def _build_ex_tree(self): """Construct exception tree from trace.""" # Load exception data into tree structure sep = self._exh_obj.callables_separator data = self._exh_obj.exceptions_db if not data: raise RuntimeError("Exceptions database is empty") # Add root...
python
def _build_ex_tree(self): """Construct exception tree from trace.""" # Load exception data into tree structure sep = self._exh_obj.callables_separator data = self._exh_obj.exceptions_db if not data: raise RuntimeError("Exceptions database is empty") # Add root...
[ "def", "_build_ex_tree", "(", "self", ")", ":", "sep", "=", "self", ".", "_exh_obj", ".", "callables_separator", "data", "=", "self", ".", "_exh_obj", ".", "exceptions_db", "if", "not", "data", ":", "raise", "RuntimeError", "(", "\"Exceptions database is empty\"...
Construct exception tree from trace.
[ "Construct", "exception", "tree", "from", "trace", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exdoc.py#L324-L354
train
pmacosta/pexdoc
pexdoc/exdoc.py
ExDoc._build_module_db
def _build_module_db(self): """ Build database of module callables sorted by line number. The database is a dictionary whose keys are module file names and whose values are lists of dictionaries containing name and line number of callables in that module """ tdic...
python
def _build_module_db(self): """ Build database of module callables sorted by line number. The database is a dictionary whose keys are module file names and whose values are lists of dictionaries containing name and line number of callables in that module """ tdic...
[ "def", "_build_module_db", "(", "self", ")", ":", "tdict", "=", "collections", ".", "defaultdict", "(", "lambda", ":", "[", "]", ")", "for", "callable_name", ",", "callable_dict", "in", "self", ".", "_exh_obj", ".", "callables_db", ".", "items", "(", ")", ...
Build database of module callables sorted by line number. The database is a dictionary whose keys are module file names and whose values are lists of dictionaries containing name and line number of callables in that module
[ "Build", "database", "of", "module", "callables", "sorted", "by", "line", "number", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exdoc.py#L356-L376
train
pmacosta/pexdoc
pexdoc/exdoc.py
ExDoc._process_exlist
def _process_exlist(self, exc, raised): """Remove raised info from exception message and create separate list for it.""" if (not raised) or (raised and exc.endswith("*")): return exc[:-1] if exc.endswith("*") else exc return None
python
def _process_exlist(self, exc, raised): """Remove raised info from exception message and create separate list for it.""" if (not raised) or (raised and exc.endswith("*")): return exc[:-1] if exc.endswith("*") else exc return None
[ "def", "_process_exlist", "(", "self", ",", "exc", ",", "raised", ")", ":", "if", "(", "not", "raised", ")", "or", "(", "raised", "and", "exc", ".", "endswith", "(", "\"*\"", ")", ")", ":", "return", "exc", "[", ":", "-", "1", "]", "if", "exc", ...
Remove raised info from exception message and create separate list for it.
[ "Remove", "raised", "info", "from", "exception", "message", "and", "create", "separate", "list", "for", "it", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exdoc.py#L391-L395
train
pmacosta/pexdoc
pexdoc/exdoc.py
ExDoc._set_depth
def _set_depth(self, depth): """Depth setter.""" if depth and ( (not isinstance(depth, int)) or (isinstance(depth, int) and (depth < 0)) ): raise RuntimeError("Argument `depth` is not valid") self._depth = depth
python
def _set_depth(self, depth): """Depth setter.""" if depth and ( (not isinstance(depth, int)) or (isinstance(depth, int) and (depth < 0)) ): raise RuntimeError("Argument `depth` is not valid") self._depth = depth
[ "def", "_set_depth", "(", "self", ",", "depth", ")", ":", "if", "depth", "and", "(", "(", "not", "isinstance", "(", "depth", ",", "int", ")", ")", "or", "(", "isinstance", "(", "depth", ",", "int", ")", "and", "(", "depth", "<", "0", ")", ")", ...
Depth setter.
[ "Depth", "setter", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exdoc.py#L397-L403
train
pmacosta/pexdoc
pexdoc/exdoc.py
ExDoc._set_exclude
def _set_exclude(self, exclude): """Exclude setter.""" if exclude and ( (not isinstance(exclude, list)) or ( isinstance(exclude, list) and any([not isinstance(item, str) for item in exclude]) ) ): raise RuntimeError(...
python
def _set_exclude(self, exclude): """Exclude setter.""" if exclude and ( (not isinstance(exclude, list)) or ( isinstance(exclude, list) and any([not isinstance(item, str) for item in exclude]) ) ): raise RuntimeError(...
[ "def", "_set_exclude", "(", "self", ",", "exclude", ")", ":", "if", "exclude", "and", "(", "(", "not", "isinstance", "(", "exclude", ",", "list", ")", ")", "or", "(", "isinstance", "(", "exclude", ",", "list", ")", "and", "any", "(", "[", "not", "i...
Exclude setter.
[ "Exclude", "setter", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exdoc.py#L405-L415
train
pmacosta/pexdoc
pexdoc/exdoc.py
ExDoc.get_sphinx_autodoc
def get_sphinx_autodoc( self, depth=None, exclude=None, width=72, error=False, raised=False, no_comment=False, ): r""" Return exception list in `reStructuredText`_ auto-determining callable name. :param depth: Hierarchy levels to inclu...
python
def get_sphinx_autodoc( self, depth=None, exclude=None, width=72, error=False, raised=False, no_comment=False, ): r""" Return exception list in `reStructuredText`_ auto-determining callable name. :param depth: Hierarchy levels to inclu...
[ "def", "get_sphinx_autodoc", "(", "self", ",", "depth", "=", "None", ",", "exclude", "=", "None", ",", "width", "=", "72", ",", "error", "=", "False", ",", "raised", "=", "False", ",", "no_comment", "=", "False", ",", ")", ":", "r", "frame", "=", "...
r""" Return exception list in `reStructuredText`_ auto-determining callable name. :param depth: Hierarchy levels to include in the exceptions list (overrides default **depth** argument; see :py:attr:`pexdoc.ExDoc.depth`). If None exceptions ...
[ "r", "Return", "exception", "list", "in", "reStructuredText", "_", "auto", "-", "determining", "callable", "name", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exdoc.py#L417-L503
train
a1ezzz/wasp-general
wasp_general/types/bytearray.py
WFixedSizeByteArray.resize
def resize(self, size): """ Grow this array to specified length. This array can't be shrinked :param size: new length :return: None """ if size < len(self): raise ValueError("Value is out of bound. Array can't be shrinked") current_size = self.__size for i in range(size - current_size): self.__arra...
python
def resize(self, size): """ Grow this array to specified length. This array can't be shrinked :param size: new length :return: None """ if size < len(self): raise ValueError("Value is out of bound. Array can't be shrinked") current_size = self.__size for i in range(size - current_size): self.__arra...
[ "def", "resize", "(", "self", ",", "size", ")", ":", "if", "size", "<", "len", "(", "self", ")", ":", "raise", "ValueError", "(", "\"Value is out of bound. Array can't be shrinked\"", ")", "current_size", "=", "self", ".", "__size", "for", "i", "in", "range"...
Grow this array to specified length. This array can't be shrinked :param size: new length :return: None
[ "Grow", "this", "array", "to", "specified", "length", ".", "This", "array", "can", "t", "be", "shrinked" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/types/bytearray.py#L83-L94
train
a1ezzz/wasp-general
wasp_general/types/bytearray.py
WFixedSizeByteArray.swipe
def swipe(self): """ Mirror current array value in reverse. Bytes that had greater index will have lesser index, and vice-versa. This method doesn't change this array. It creates a new one and return it as a result. :return: WFixedSizeByteArray """ result = WFixedSizeByteArray(len(self)) for i in range(len...
python
def swipe(self): """ Mirror current array value in reverse. Bytes that had greater index will have lesser index, and vice-versa. This method doesn't change this array. It creates a new one and return it as a result. :return: WFixedSizeByteArray """ result = WFixedSizeByteArray(len(self)) for i in range(len...
[ "def", "swipe", "(", "self", ")", ":", "result", "=", "WFixedSizeByteArray", "(", "len", "(", "self", ")", ")", "for", "i", "in", "range", "(", "len", "(", "self", ")", ")", ":", "result", "[", "len", "(", "self", ")", "-", "i", "-", "1", "]", ...
Mirror current array value in reverse. Bytes that had greater index will have lesser index, and vice-versa. This method doesn't change this array. It creates a new one and return it as a result. :return: WFixedSizeByteArray
[ "Mirror", "current", "array", "value", "in", "reverse", ".", "Bytes", "that", "had", "greater", "index", "will", "have", "lesser", "index", "and", "vice", "-", "versa", ".", "This", "method", "doesn", "t", "change", "this", "array", ".", "It", "creates", ...
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/types/bytearray.py#L140-L149
train
a1ezzz/wasp-general
wasp_general/mime.py
mime_type
def mime_type(filename): """ Guess mime type for the given file name Note: this implementation uses python_magic package which is not thread-safe, as a workaround global lock is used for the ability to work in threaded environment :param filename: file name to guess :return: str """ # TODO: write lock-free mim...
python
def mime_type(filename): """ Guess mime type for the given file name Note: this implementation uses python_magic package which is not thread-safe, as a workaround global lock is used for the ability to work in threaded environment :param filename: file name to guess :return: str """ # TODO: write lock-free mim...
[ "def", "mime_type", "(", "filename", ")", ":", "try", ":", "__mime_lock", ".", "acquire", "(", ")", "extension", "=", "filename", ".", "split", "(", "\".\"", ")", "extension", "=", "extension", "[", "len", "(", "extension", ")", "-", "1", "]", "if", ...
Guess mime type for the given file name Note: this implementation uses python_magic package which is not thread-safe, as a workaround global lock is used for the ability to work in threaded environment :param filename: file name to guess :return: str
[ "Guess", "mime", "type", "for", "the", "given", "file", "name" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/mime.py#L36-L65
train
Loudr/pale
pale/arguments/base.py
BaseArgument._validate_type
def _validate_type(self, item, name): """Validate the item against `allowed_types`.""" if item is None: # don't validate None items, since they'll be caught by the portion # of the validator responsible for handling `required`ness return if not isinstance(ite...
python
def _validate_type(self, item, name): """Validate the item against `allowed_types`.""" if item is None: # don't validate None items, since they'll be caught by the portion # of the validator responsible for handling `required`ness return if not isinstance(ite...
[ "def", "_validate_type", "(", "self", ",", "item", ",", "name", ")", ":", "if", "item", "is", "None", ":", "return", "if", "not", "isinstance", "(", "item", ",", "self", ".", "allowed_types", ")", ":", "item_class_name", "=", "item", ".", "__class__", ...
Validate the item against `allowed_types`.
[ "Validate", "the", "item", "against", "allowed_types", "." ]
dc002ee6032c856551143af222ff8f71ed9853fe
https://github.com/Loudr/pale/blob/dc002ee6032c856551143af222ff8f71ed9853fe/pale/arguments/base.py#L59-L70
train
Loudr/pale
pale/arguments/base.py
BaseArgument._validate_required
def _validate_required(self, item, name): """Validate that the item is present if it's required.""" if self.required is True and item is None: raise ArgumentError(name, "This argument is required.")
python
def _validate_required(self, item, name): """Validate that the item is present if it's required.""" if self.required is True and item is None: raise ArgumentError(name, "This argument is required.")
[ "def", "_validate_required", "(", "self", ",", "item", ",", "name", ")", ":", "if", "self", ".", "required", "is", "True", "and", "item", "is", "None", ":", "raise", "ArgumentError", "(", "name", ",", "\"This argument is required.\"", ")" ]
Validate that the item is present if it's required.
[ "Validate", "that", "the", "item", "is", "present", "if", "it", "s", "required", "." ]
dc002ee6032c856551143af222ff8f71ed9853fe
https://github.com/Loudr/pale/blob/dc002ee6032c856551143af222ff8f71ed9853fe/pale/arguments/base.py#L73-L76
train
Loudr/pale
pale/arguments/base.py
BaseArgument.doc_dict
def doc_dict(self): """Returns the documentation dictionary for this argument.""" doc = { 'type': self.__class__.__name__, 'description': self.description, 'default': self.default, 'required': self.required } if hasattr(self, 'details'): ...
python
def doc_dict(self): """Returns the documentation dictionary for this argument.""" doc = { 'type': self.__class__.__name__, 'description': self.description, 'default': self.default, 'required': self.required } if hasattr(self, 'details'): ...
[ "def", "doc_dict", "(", "self", ")", ":", "doc", "=", "{", "'type'", ":", "self", ".", "__class__", ".", "__name__", ",", "'description'", ":", "self", ".", "description", ",", "'default'", ":", "self", ".", "default", ",", "'required'", ":", "self", "...
Returns the documentation dictionary for this argument.
[ "Returns", "the", "documentation", "dictionary", "for", "this", "argument", "." ]
dc002ee6032c856551143af222ff8f71ed9853fe
https://github.com/Loudr/pale/blob/dc002ee6032c856551143af222ff8f71ed9853fe/pale/arguments/base.py#L79-L89
train
Loudr/pale
pale/arguments/base.py
ListArgument.validate_items
def validate_items(self, input_list): """Validates that items in the list are of the type specified. Returns the input list if it's valid, or raises an ArgumentError if it's not.""" output_list = [] for item in input_list: valid = self.list_item_type.validate(item, s...
python
def validate_items(self, input_list): """Validates that items in the list are of the type specified. Returns the input list if it's valid, or raises an ArgumentError if it's not.""" output_list = [] for item in input_list: valid = self.list_item_type.validate(item, s...
[ "def", "validate_items", "(", "self", ",", "input_list", ")", ":", "output_list", "=", "[", "]", "for", "item", "in", "input_list", ":", "valid", "=", "self", ".", "list_item_type", ".", "validate", "(", "item", ",", "self", ".", "item_name", ")", "outpu...
Validates that items in the list are of the type specified. Returns the input list if it's valid, or raises an ArgumentError if it's not.
[ "Validates", "that", "items", "in", "the", "list", "are", "of", "the", "type", "specified", "." ]
dc002ee6032c856551143af222ff8f71ed9853fe
https://github.com/Loudr/pale/blob/dc002ee6032c856551143af222ff8f71ed9853fe/pale/arguments/base.py#L114-L128
train
F483/apigen
apigen/apigen.py
Definition.startserver
def startserver(self, hostname="localhost", port=8080, daemon=False, handle_sigint=True): """Start json-rpc service.""" if daemon: print("Sorry daemon server not supported just yet.") # TODO start as daemon similar to bitcoind else: print("...
python
def startserver(self, hostname="localhost", port=8080, daemon=False, handle_sigint=True): """Start json-rpc service.""" if daemon: print("Sorry daemon server not supported just yet.") # TODO start as daemon similar to bitcoind else: print("...
[ "def", "startserver", "(", "self", ",", "hostname", "=", "\"localhost\"", ",", "port", "=", "8080", ",", "daemon", "=", "False", ",", "handle_sigint", "=", "True", ")", ":", "if", "daemon", ":", "print", "(", "\"Sorry daemon server not supported just yet.\"", ...
Start json-rpc service.
[ "Start", "json", "-", "rpc", "service", "." ]
f05ce1509030764721cc3393410fa12b609e88f2
https://github.com/F483/apigen/blob/f05ce1509030764721cc3393410fa12b609e88f2/apigen/apigen.py#L118-L138
train
dfujim/bdata
bdata/bdata.py
bdata._get_asym_hel
def _get_asym_hel(self,d): """ Find the asymmetry of each helicity. """ # get data 1+ 2+ 1- 2- d0 = d[0]; d1 = d[2]; d2 = d[1]; d3 = d[3] # pre-calcs denom1 = d0+d1; denom2 = d2+d3 # check for div by zero denom1[den...
python
def _get_asym_hel(self,d): """ Find the asymmetry of each helicity. """ # get data 1+ 2+ 1- 2- d0 = d[0]; d1 = d[2]; d2 = d[1]; d3 = d[3] # pre-calcs denom1 = d0+d1; denom2 = d2+d3 # check for div by zero denom1[den...
[ "def", "_get_asym_hel", "(", "self", ",", "d", ")", ":", "d0", "=", "d", "[", "0", "]", "d1", "=", "d", "[", "2", "]", "d2", "=", "d", "[", "1", "]", "d3", "=", "d", "[", "3", "]", "denom1", "=", "d0", "+", "d1", "denom2", "=", "d2", "+...
Find the asymmetry of each helicity.
[ "Find", "the", "asymmetry", "of", "each", "helicity", "." ]
86af7b091e5cc167d2b9a3146953da347cc38614
https://github.com/dfujim/bdata/blob/86af7b091e5cc167d2b9a3146953da347cc38614/bdata/bdata.py#L545-L577
train
dfujim/bdata
bdata/bdata.py
bdata._get_asym_comb
def _get_asym_comb(self,d): """ Find the combined asymmetry for slr runs. Elegant 4-counter method. """ # get data d0 = d[0]; d1 = d[2]; d2 = d[1]; d3 = d[3] # pre-calcs r_denom = d0*d3 r_denom[r_denom==0] = np.nan r = np.sqrt((d1...
python
def _get_asym_comb(self,d): """ Find the combined asymmetry for slr runs. Elegant 4-counter method. """ # get data d0 = d[0]; d1 = d[2]; d2 = d[1]; d3 = d[3] # pre-calcs r_denom = d0*d3 r_denom[r_denom==0] = np.nan r = np.sqrt((d1...
[ "def", "_get_asym_comb", "(", "self", ",", "d", ")", ":", "d0", "=", "d", "[", "0", "]", "d1", "=", "d", "[", "2", "]", "d2", "=", "d", "[", "1", "]", "d3", "=", "d", "[", "3", "]", "r_denom", "=", "d0", "*", "d3", "r_denom", "[", "r_deno...
Find the combined asymmetry for slr runs. Elegant 4-counter method.
[ "Find", "the", "combined", "asymmetry", "for", "slr", "runs", ".", "Elegant", "4", "-", "counter", "method", "." ]
86af7b091e5cc167d2b9a3146953da347cc38614
https://github.com/dfujim/bdata/blob/86af7b091e5cc167d2b9a3146953da347cc38614/bdata/bdata.py#L580-L610
train
dfujim/bdata
bdata/bdata.py
bdata._get_1f_sum_scans
def _get_1f_sum_scans(self,d,freq): """ Sum counts in each frequency bin over 1f scans. """ # combine scans: values with same frequency unique_freq = np.unique(freq) sum_scans = [[] for i in range(len(d))] for f in unique_freq: ...
python
def _get_1f_sum_scans(self,d,freq): """ Sum counts in each frequency bin over 1f scans. """ # combine scans: values with same frequency unique_freq = np.unique(freq) sum_scans = [[] for i in range(len(d))] for f in unique_freq: ...
[ "def", "_get_1f_sum_scans", "(", "self", ",", "d", ",", "freq", ")", ":", "unique_freq", "=", "np", ".", "unique", "(", "freq", ")", "sum_scans", "=", "[", "[", "]", "for", "i", "in", "range", "(", "len", "(", "d", ")", ")", "]", "for", "f", "i...
Sum counts in each frequency bin over 1f scans.
[ "Sum", "counts", "in", "each", "frequency", "bin", "over", "1f", "scans", "." ]
86af7b091e5cc167d2b9a3146953da347cc38614
https://github.com/dfujim/bdata/blob/86af7b091e5cc167d2b9a3146953da347cc38614/bdata/bdata.py#L672-L687
train
dfujim/bdata
bdata/bdata.py
bdata.get_pulse_s
def get_pulse_s(self): """Get pulse duration in seconds, for pulsed measurements.""" try: dwelltime = self.ppg.dwelltime.mean beam_on = self.ppg.beam_on.mean except AttributeError: raise AttributeError("Missing logged ppg parameter: dwelltime "+\ ...
python
def get_pulse_s(self): """Get pulse duration in seconds, for pulsed measurements.""" try: dwelltime = self.ppg.dwelltime.mean beam_on = self.ppg.beam_on.mean except AttributeError: raise AttributeError("Missing logged ppg parameter: dwelltime "+\ ...
[ "def", "get_pulse_s", "(", "self", ")", ":", "try", ":", "dwelltime", "=", "self", ".", "ppg", ".", "dwelltime", ".", "mean", "beam_on", "=", "self", ".", "ppg", ".", "beam_on", ".", "mean", "except", "AttributeError", ":", "raise", "AttributeError", "("...
Get pulse duration in seconds, for pulsed measurements.
[ "Get", "pulse", "duration", "in", "seconds", "for", "pulsed", "measurements", "." ]
86af7b091e5cc167d2b9a3146953da347cc38614
https://github.com/dfujim/bdata/blob/86af7b091e5cc167d2b9a3146953da347cc38614/bdata/bdata.py#L1334-L1343
train
Loudr/pale
pale/__init__.py
extract_endpoints
def extract_endpoints(api_module): """Return the endpoints from an API implementation module. The results returned by this are used to populate your HTTP layer's route handler, as well as by the documentation generator. """ if not hasattr(api_module, 'endpoints'): raise ValueError(("pale.ex...
python
def extract_endpoints(api_module): """Return the endpoints from an API implementation module. The results returned by this are used to populate your HTTP layer's route handler, as well as by the documentation generator. """ if not hasattr(api_module, 'endpoints'): raise ValueError(("pale.ex...
[ "def", "extract_endpoints", "(", "api_module", ")", ":", "if", "not", "hasattr", "(", "api_module", ",", "'endpoints'", ")", ":", "raise", "ValueError", "(", "(", "\"pale.extract_endpoints expected the passed in \"", "\"api_module to have an `endpoints` attribute, but it didn...
Return the endpoints from an API implementation module. The results returned by this are used to populate your HTTP layer's route handler, as well as by the documentation generator.
[ "Return", "the", "endpoints", "from", "an", "API", "implementation", "module", "." ]
dc002ee6032c856551143af222ff8f71ed9853fe
https://github.com/Loudr/pale/blob/dc002ee6032c856551143af222ff8f71ed9853fe/pale/__init__.py#L44-L74
train
Loudr/pale
pale/__init__.py
extract_resources
def extract_resources(api_module): """Return the resources from an API implementation module. The results returned here are used to generate documentation. They aren't currently used for anything in production. """ endpoints = extract_endpoints(api_module) resource_classes = [ e._returns.__cla...
python
def extract_resources(api_module): """Return the resources from an API implementation module. The results returned here are used to generate documentation. They aren't currently used for anything in production. """ endpoints = extract_endpoints(api_module) resource_classes = [ e._returns.__cla...
[ "def", "extract_resources", "(", "api_module", ")", ":", "endpoints", "=", "extract_endpoints", "(", "api_module", ")", "resource_classes", "=", "[", "e", ".", "_returns", ".", "__class__", "for", "e", "in", "endpoints", "]", "return", "list", "(", "set", "(...
Return the resources from an API implementation module. The results returned here are used to generate documentation. They aren't currently used for anything in production.
[ "Return", "the", "resources", "from", "an", "API", "implementation", "module", "." ]
dc002ee6032c856551143af222ff8f71ed9853fe
https://github.com/Loudr/pale/blob/dc002ee6032c856551143af222ff8f71ed9853fe/pale/__init__.py#L76-L85
train
weijia/djangoautoconf
djangoautoconf/django_adv_zip_template_loader.py
Loader.load_template_source
def load_template_source(self, template_name, template_dirs=None): """Template loader that loads templates from zipped modules.""" #Get every app's folder log.error("Calling zip loader") for folder in app_template_dirs: if ".zip/" in folder.replace("\\", "/"): ...
python
def load_template_source(self, template_name, template_dirs=None): """Template loader that loads templates from zipped modules.""" #Get every app's folder log.error("Calling zip loader") for folder in app_template_dirs: if ".zip/" in folder.replace("\\", "/"): ...
[ "def", "load_template_source", "(", "self", ",", "template_name", ",", "template_dirs", "=", "None", ")", ":", "log", ".", "error", "(", "\"Calling zip loader\"", ")", "for", "folder", "in", "app_template_dirs", ":", "if", "\".zip/\"", "in", "folder", ".", "re...
Template loader that loads templates from zipped modules.
[ "Template", "loader", "that", "loads", "templates", "from", "zipped", "modules", "." ]
b7dbda2287ed8cb9de6d02cb3abaaa1c36b1ced0
https://github.com/weijia/djangoautoconf/blob/b7dbda2287ed8cb9de6d02cb3abaaa1c36b1ced0/djangoautoconf/django_adv_zip_template_loader.py#L44-L71
train
olitheolix/qtmacs
qtmacs/logging_handler.py
QtmacsLoggingHandler.fetch
def fetch(self, start=None, stop=None): """ Fetch log records and return them as a list. |Args| * ``start`` (**int**): non-negative index of the first log record to return. * ``stop`` (**int**): non-negative index of the last log record to return. ...
python
def fetch(self, start=None, stop=None): """ Fetch log records and return them as a list. |Args| * ``start`` (**int**): non-negative index of the first log record to return. * ``stop`` (**int**): non-negative index of the last log record to return. ...
[ "def", "fetch", "(", "self", ",", "start", "=", "None", ",", "stop", "=", "None", ")", ":", "if", "not", "start", ":", "start", "=", "0", "if", "not", "stop", ":", "stop", "=", "len", "(", "self", ".", "log", ")", "if", "start", "<", "0", ":"...
Fetch log records and return them as a list. |Args| * ``start`` (**int**): non-negative index of the first log record to return. * ``stop`` (**int**): non-negative index of the last log record to return. |Returns| * **list**: list of log records (see ``lo...
[ "Fetch", "log", "records", "and", "return", "them", "as", "a", "list", "." ]
36253b082b82590f183fe154b053eb3a1e741be2
https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/logging_handler.py#L127-L165
train
Loudr/pale
pale/adapters/flask.py
bind_blueprint
def bind_blueprint(pale_api_module, flask_blueprint): """Binds an implemented pale API module to a Flask Blueprint.""" if not isinstance(flask_blueprint, Blueprint): raise TypeError(("pale.flask_adapter.bind_blueprint expected the " "passed in flask_blueprint to be an instance ...
python
def bind_blueprint(pale_api_module, flask_blueprint): """Binds an implemented pale API module to a Flask Blueprint.""" if not isinstance(flask_blueprint, Blueprint): raise TypeError(("pale.flask_adapter.bind_blueprint expected the " "passed in flask_blueprint to be an instance ...
[ "def", "bind_blueprint", "(", "pale_api_module", ",", "flask_blueprint", ")", ":", "if", "not", "isinstance", "(", "flask_blueprint", ",", "Blueprint", ")", ":", "raise", "TypeError", "(", "(", "\"pale.flask_adapter.bind_blueprint expected the \"", "\"passed in flask_blue...
Binds an implemented pale API module to a Flask Blueprint.
[ "Binds", "an", "implemented", "pale", "API", "module", "to", "a", "Flask", "Blueprint", "." ]
dc002ee6032c856551143af222ff8f71ed9853fe
https://github.com/Loudr/pale/blob/dc002ee6032c856551143af222ff8f71ed9853fe/pale/adapters/flask.py#L29-L58
train
a1ezzz/wasp-general
wasp_general/network/web/cookies.py
WHTTPCookie.cookie_name_check
def cookie_name_check(cookie_name): """ Check cookie name for validity. Return True if name is valid :param cookie_name: name to check :return: bool """ cookie_match = WHTTPCookie.cookie_name_non_compliance_re.match(cookie_name.encode('us-ascii')) return len(cookie_name) > 0 and cookie_match is None
python
def cookie_name_check(cookie_name): """ Check cookie name for validity. Return True if name is valid :param cookie_name: name to check :return: bool """ cookie_match = WHTTPCookie.cookie_name_non_compliance_re.match(cookie_name.encode('us-ascii')) return len(cookie_name) > 0 and cookie_match is None
[ "def", "cookie_name_check", "(", "cookie_name", ")", ":", "cookie_match", "=", "WHTTPCookie", ".", "cookie_name_non_compliance_re", ".", "match", "(", "cookie_name", ".", "encode", "(", "'us-ascii'", ")", ")", "return", "len", "(", "cookie_name", ")", ">", "0", ...
Check cookie name for validity. Return True if name is valid :param cookie_name: name to check :return: bool
[ "Check", "cookie", "name", "for", "validity", ".", "Return", "True", "if", "name", "is", "valid" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/web/cookies.py#L66-L73
train
a1ezzz/wasp-general
wasp_general/network/web/cookies.py
WHTTPCookie.cookie_attr_value_check
def cookie_attr_value_check(attr_name, attr_value): """ Check cookie attribute value for validity. Return True if value is valid :param attr_name: attribute name to check :param attr_value: attribute value to check :return: bool """ attr_value.encode('us-ascii') return WHTTPCookie.cookie_attr_value_compl...
python
def cookie_attr_value_check(attr_name, attr_value): """ Check cookie attribute value for validity. Return True if value is valid :param attr_name: attribute name to check :param attr_value: attribute value to check :return: bool """ attr_value.encode('us-ascii') return WHTTPCookie.cookie_attr_value_compl...
[ "def", "cookie_attr_value_check", "(", "attr_name", ",", "attr_value", ")", ":", "attr_value", ".", "encode", "(", "'us-ascii'", ")", "return", "WHTTPCookie", ".", "cookie_attr_value_compliance", "[", "attr_name", "]", ".", "match", "(", "attr_value", ")", "is", ...
Check cookie attribute value for validity. Return True if value is valid :param attr_name: attribute name to check :param attr_value: attribute value to check :return: bool
[ "Check", "cookie", "attribute", "value", "for", "validity", ".", "Return", "True", "if", "value", "is", "valid" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/web/cookies.py#L85-L93
train
a1ezzz/wasp-general
wasp_general/network/web/cookies.py
WHTTPCookie.__attr_name
def __attr_name(self, name): """ Return suitable and valid attribute name. This method replaces dash char to underscore. If name is invalid ValueError exception is raised :param name: cookie attribute name :return: str """ if name not in self.cookie_attr_value_compliance.keys(): suggested_name = name.re...
python
def __attr_name(self, name): """ Return suitable and valid attribute name. This method replaces dash char to underscore. If name is invalid ValueError exception is raised :param name: cookie attribute name :return: str """ if name not in self.cookie_attr_value_compliance.keys(): suggested_name = name.re...
[ "def", "__attr_name", "(", "self", ",", "name", ")", ":", "if", "name", "not", "in", "self", ".", "cookie_attr_value_compliance", ".", "keys", "(", ")", ":", "suggested_name", "=", "name", ".", "replace", "(", "'_'", ",", "'-'", ")", ".", "lower", "(",...
Return suitable and valid attribute name. This method replaces dash char to underscore. If name is invalid ValueError exception is raised :param name: cookie attribute name :return: str
[ "Return", "suitable", "and", "valid", "attribute", "name", ".", "This", "method", "replaces", "dash", "char", "to", "underscore", ".", "If", "name", "is", "invalid", "ValueError", "exception", "is", "raised" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/web/cookies.py#L145-L157
train
a1ezzz/wasp-general
wasp_general/network/web/cookies.py
WHTTPCookieJar.remove_cookie
def remove_cookie(self, cookie_name): """ Remove cookie by its name :param cookie_name: cookie name :return: """ if self.__ro_flag: raise RuntimeError('Read-only cookie-jar changing attempt') if cookie_name in self.__cookies.keys(): self.__cookies.pop(cookie_name)
python
def remove_cookie(self, cookie_name): """ Remove cookie by its name :param cookie_name: cookie name :return: """ if self.__ro_flag: raise RuntimeError('Read-only cookie-jar changing attempt') if cookie_name in self.__cookies.keys(): self.__cookies.pop(cookie_name)
[ "def", "remove_cookie", "(", "self", ",", "cookie_name", ")", ":", "if", "self", ".", "__ro_flag", ":", "raise", "RuntimeError", "(", "'Read-only cookie-jar changing attempt'", ")", "if", "cookie_name", "in", "self", ".", "__cookies", ".", "keys", "(", ")", ":...
Remove cookie by its name :param cookie_name: cookie name :return:
[ "Remove", "cookie", "by", "its", "name" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/web/cookies.py#L254-L263
train
a1ezzz/wasp-general
wasp_general/network/web/cookies.py
WHTTPCookieJar.ro
def ro(self): """ Return read-only copy :return: WHTTPCookieJar """ ro_jar = WHTTPCookieJar() for cookie in self.__cookies.values(): ro_jar.add_cookie(cookie.ro()) ro_jar.__ro_flag = True return ro_jar
python
def ro(self): """ Return read-only copy :return: WHTTPCookieJar """ ro_jar = WHTTPCookieJar() for cookie in self.__cookies.values(): ro_jar.add_cookie(cookie.ro()) ro_jar.__ro_flag = True return ro_jar
[ "def", "ro", "(", "self", ")", ":", "ro_jar", "=", "WHTTPCookieJar", "(", ")", "for", "cookie", "in", "self", ".", "__cookies", ".", "values", "(", ")", ":", "ro_jar", ".", "add_cookie", "(", "cookie", ".", "ro", "(", ")", ")", "ro_jar", ".", "__ro...
Return read-only copy :return: WHTTPCookieJar
[ "Return", "read", "-", "only", "copy" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/web/cookies.py#L282-L291
train
a1ezzz/wasp-general
wasp_general/network/web/cookies.py
WHTTPCookieJar.import_simple_cookie
def import_simple_cookie(cls, simple_cookie): """ Create cookie jar from SimpleCookie object :param simple_cookie: cookies to import :return: WHTTPCookieJar """ cookie_jar = WHTTPCookieJar() for cookie_name in simple_cookie.keys(): cookie_attrs = {} for attr_name in WHTTPCookie.cookie_attr_value_comp...
python
def import_simple_cookie(cls, simple_cookie): """ Create cookie jar from SimpleCookie object :param simple_cookie: cookies to import :return: WHTTPCookieJar """ cookie_jar = WHTTPCookieJar() for cookie_name in simple_cookie.keys(): cookie_attrs = {} for attr_name in WHTTPCookie.cookie_attr_value_comp...
[ "def", "import_simple_cookie", "(", "cls", ",", "simple_cookie", ")", ":", "cookie_jar", "=", "WHTTPCookieJar", "(", ")", "for", "cookie_name", "in", "simple_cookie", ".", "keys", "(", ")", ":", "cookie_attrs", "=", "{", "}", "for", "attr_name", "in", "WHTTP...
Create cookie jar from SimpleCookie object :param simple_cookie: cookies to import :return: WHTTPCookieJar
[ "Create", "cookie", "jar", "from", "SimpleCookie", "object" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/web/cookies.py#L295-L312
train
vecnet/vecnet.openmalaria
vecnet/openmalaria/helpers.py
is_prime
def is_prime(n): """ Check if n is a prime number """ if n % 2 == 0 and n > 2: return False return all(n % i for i in range(3, int(math.sqrt(n)) + 1, 2))
python
def is_prime(n): """ Check if n is a prime number """ if n % 2 == 0 and n > 2: return False return all(n % i for i in range(3, int(math.sqrt(n)) + 1, 2))
[ "def", "is_prime", "(", "n", ")", ":", "if", "n", "%", "2", "==", "0", "and", "n", ">", "2", ":", "return", "False", "return", "all", "(", "n", "%", "i", "for", "i", "in", "range", "(", "3", ",", "int", "(", "math", ".", "sqrt", "(", "n", ...
Check if n is a prime number
[ "Check", "if", "n", "is", "a", "prime", "number" ]
795bc9d1b81a6c664f14879edda7a7c41188e95a
https://github.com/vecnet/vecnet.openmalaria/blob/795bc9d1b81a6c664f14879edda7a7c41188e95a/vecnet/openmalaria/helpers.py#L15-L21
train
olitheolix/qtmacs
qtmacs/applets/richeditor.py
RichEditor.loadFile
def loadFile(self, fileName): """ Display the file associated with the appletID. """ # Assign QFile object with the current name. self.file = QtCore.QFile(fileName) if self.file.exists(): self.qteText.append(open(fileName).read()) else: ms...
python
def loadFile(self, fileName): """ Display the file associated with the appletID. """ # Assign QFile object with the current name. self.file = QtCore.QFile(fileName) if self.file.exists(): self.qteText.append(open(fileName).read()) else: ms...
[ "def", "loadFile", "(", "self", ",", "fileName", ")", ":", "self", ".", "file", "=", "QtCore", ".", "QFile", "(", "fileName", ")", "if", "self", ".", "file", ".", "exists", "(", ")", ":", "self", ".", "qteText", ".", "append", "(", "open", "(", "...
Display the file associated with the appletID.
[ "Display", "the", "file", "associated", "with", "the", "appletID", "." ]
36253b082b82590f183fe154b053eb3a1e741be2
https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/applets/richeditor.py#L67-L78
train
jreese/ent
ent/ent.py
Ent._encode
def _encode(self): """Generate a recursive JSON representation of the ent.""" obj = {k: v for k, v in self.__dict__.items() if not k.startswith('_') and type(v) in SAFE_TYPES} obj.update({k: v._encode() for k, v in self.__dict__.items() if isinstance(v, Ent)}) ...
python
def _encode(self): """Generate a recursive JSON representation of the ent.""" obj = {k: v for k, v in self.__dict__.items() if not k.startswith('_') and type(v) in SAFE_TYPES} obj.update({k: v._encode() for k, v in self.__dict__.items() if isinstance(v, Ent)}) ...
[ "def", "_encode", "(", "self", ")", ":", "obj", "=", "{", "k", ":", "v", "for", "k", ",", "v", "in", "self", ".", "__dict__", ".", "items", "(", ")", "if", "not", "k", ".", "startswith", "(", "'_'", ")", "and", "type", "(", "v", ")", "in", ...
Generate a recursive JSON representation of the ent.
[ "Generate", "a", "recursive", "JSON", "representation", "of", "the", "ent", "." ]
65f7c6498536c551ee1fdb43c3c429f24aa0f755
https://github.com/jreese/ent/blob/65f7c6498536c551ee1fdb43c3c429f24aa0f755/ent/ent.py#L81-L87
train
jreese/ent
ent/ent.py
Ent.merge
def merge(cls, *args, **kwargs): """Create a new Ent from one or more existing Ents. Keys in the later Ent objects will overwrite the keys of the previous Ents. Later keys of different type than in earlier Ents will be bravely ignored. The following keyword arguments are recogn...
python
def merge(cls, *args, **kwargs): """Create a new Ent from one or more existing Ents. Keys in the later Ent objects will overwrite the keys of the previous Ents. Later keys of different type than in earlier Ents will be bravely ignored. The following keyword arguments are recogn...
[ "def", "merge", "(", "cls", ",", "*", "args", ",", "**", "kwargs", ")", ":", "newkeys", "=", "bool", "(", "kwargs", ".", "get", "(", "'newkeys'", ",", "False", ")", ")", "ignore", "=", "kwargs", ".", "get", "(", "'ignore'", ",", "list", "(", ")",...
Create a new Ent from one or more existing Ents. Keys in the later Ent objects will overwrite the keys of the previous Ents. Later keys of different type than in earlier Ents will be bravely ignored. The following keyword arguments are recognized: newkeys: boolean value to det...
[ "Create", "a", "new", "Ent", "from", "one", "or", "more", "existing", "Ents", ".", "Keys", "in", "the", "later", "Ent", "objects", "will", "overwrite", "the", "keys", "of", "the", "previous", "Ents", ".", "Later", "keys", "of", "different", "type", "than...
65f7c6498536c551ee1fdb43c3c429f24aa0f755
https://github.com/jreese/ent/blob/65f7c6498536c551ee1fdb43c3c429f24aa0f755/ent/ent.py#L133-L176
train
jreese/ent
ent/ent.py
Ent.diff
def diff(cls, *args, **kwargs): """Create a new Ent representing the differences in two or more existing Ents. Keys in the later Ents with values that differ from the earlier Ents will be present in the final Ent with the latest value seen for that key. Later keys of different type tha...
python
def diff(cls, *args, **kwargs): """Create a new Ent representing the differences in two or more existing Ents. Keys in the later Ents with values that differ from the earlier Ents will be present in the final Ent with the latest value seen for that key. Later keys of different type tha...
[ "def", "diff", "(", "cls", ",", "*", "args", ",", "**", "kwargs", ")", ":", "newkeys", "=", "bool", "(", "kwargs", ".", "get", "(", "'newkeys'", ",", "False", ")", ")", "ignore", "=", "kwargs", ".", "get", "(", "'ignore'", ",", "list", "(", ")", ...
Create a new Ent representing the differences in two or more existing Ents. Keys in the later Ents with values that differ from the earlier Ents will be present in the final Ent with the latest value seen for that key. Later keys of different type than in earlier Ents will be bravely i...
[ "Create", "a", "new", "Ent", "representing", "the", "differences", "in", "two", "or", "more", "existing", "Ents", ".", "Keys", "in", "the", "later", "Ents", "with", "values", "that", "differ", "from", "the", "earlier", "Ents", "will", "be", "present", "in"...
65f7c6498536c551ee1fdb43c3c429f24aa0f755
https://github.com/jreese/ent/blob/65f7c6498536c551ee1fdb43c3c429f24aa0f755/ent/ent.py#L179-L226
train
jreese/ent
ent/ent.py
Ent.subclasses
def subclasses(cls): """Return a set of all Ent subclasses, recursively.""" seen = set() queue = set([cls]) while queue: c = queue.pop() seen.add(c) sc = c.__subclasses__() for c in sc: if c not in seen: ...
python
def subclasses(cls): """Return a set of all Ent subclasses, recursively.""" seen = set() queue = set([cls]) while queue: c = queue.pop() seen.add(c) sc = c.__subclasses__() for c in sc: if c not in seen: ...
[ "def", "subclasses", "(", "cls", ")", ":", "seen", "=", "set", "(", ")", "queue", "=", "set", "(", "[", "cls", "]", ")", "while", "queue", ":", "c", "=", "queue", ".", "pop", "(", ")", "seen", ".", "add", "(", "c", ")", "sc", "=", "c", ".",...
Return a set of all Ent subclasses, recursively.
[ "Return", "a", "set", "of", "all", "Ent", "subclasses", "recursively", "." ]
65f7c6498536c551ee1fdb43c3c429f24aa0f755
https://github.com/jreese/ent/blob/65f7c6498536c551ee1fdb43c3c429f24aa0f755/ent/ent.py#L229-L244
train
atl/py-smartdc
smartdc/datacenter.py
DataCenter.base_url
def base_url(self): """Protocol + hostname""" if self.location in self.known_locations: return self.known_locations[self.location] elif '.' in self.location or self.location == 'localhost': return 'https://' + self.location else: return 'https://' + se...
python
def base_url(self): """Protocol + hostname""" if self.location in self.known_locations: return self.known_locations[self.location] elif '.' in self.location or self.location == 'localhost': return 'https://' + self.location else: return 'https://' + se...
[ "def", "base_url", "(", "self", ")", ":", "if", "self", ".", "location", "in", "self", ".", "known_locations", ":", "return", "self", ".", "known_locations", "[", "self", ".", "location", "]", "elif", "'.'", "in", "self", ".", "location", "or", "self", ...
Protocol + hostname
[ "Protocol", "+", "hostname" ]
cc5cd5910e19004cc46e376ce035affe28fc798e
https://github.com/atl/py-smartdc/blob/cc5cd5910e19004cc46e376ce035affe28fc798e/smartdc/datacenter.py#L201-L208
train
pmacosta/pexdoc
pexdoc/exh.py
_build_exclusion_list
def _build_exclusion_list(exclude): """Build file names list of modules to exclude from exception handling.""" mod_files = [] if exclude: for mod in exclude: mdir = None mod_file = None for token in mod.split("."): try: mfile, m...
python
def _build_exclusion_list(exclude): """Build file names list of modules to exclude from exception handling.""" mod_files = [] if exclude: for mod in exclude: mdir = None mod_file = None for token in mod.split("."): try: mfile, m...
[ "def", "_build_exclusion_list", "(", "exclude", ")", ":", "mod_files", "=", "[", "]", "if", "exclude", ":", "for", "mod", "in", "exclude", ":", "mdir", "=", "None", "mod_file", "=", "None", "for", "token", "in", "mod", ".", "split", "(", "\".\"", ")", ...
Build file names list of modules to exclude from exception handling.
[ "Build", "file", "names", "list", "of", "modules", "to", "exclude", "from", "exception", "handling", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exh.py#L42-L60
train
pmacosta/pexdoc
pexdoc/exh.py
_invalid_frame
def _invalid_frame(fobj): """Select valid stack frame to process.""" fin = fobj.f_code.co_filename invalid_module = any([fin.endswith(item) for item in _INVALID_MODULES_LIST]) return invalid_module or (not os.path.isfile(fin))
python
def _invalid_frame(fobj): """Select valid stack frame to process.""" fin = fobj.f_code.co_filename invalid_module = any([fin.endswith(item) for item in _INVALID_MODULES_LIST]) return invalid_module or (not os.path.isfile(fin))
[ "def", "_invalid_frame", "(", "fobj", ")", ":", "fin", "=", "fobj", ".", "f_code", ".", "co_filename", "invalid_module", "=", "any", "(", "[", "fin", ".", "endswith", "(", "item", ")", "for", "item", "in", "_INVALID_MODULES_LIST", "]", ")", "return", "in...
Select valid stack frame to process.
[ "Select", "valid", "stack", "frame", "to", "process", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exh.py#L63-L67
train
pmacosta/pexdoc
pexdoc/exh.py
_sorted_keys_items
def _sorted_keys_items(dobj): """Return dictionary items sorted by key.""" keys = sorted(dobj.keys()) for key in keys: yield key, dobj[key]
python
def _sorted_keys_items(dobj): """Return dictionary items sorted by key.""" keys = sorted(dobj.keys()) for key in keys: yield key, dobj[key]
[ "def", "_sorted_keys_items", "(", "dobj", ")", ":", "keys", "=", "sorted", "(", "dobj", ".", "keys", "(", ")", ")", "for", "key", "in", "keys", ":", "yield", "key", ",", "dobj", "[", "key", "]" ]
Return dictionary items sorted by key.
[ "Return", "dictionary", "items", "sorted", "by", "key", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exh.py#L150-L154
train
pmacosta/pexdoc
pexdoc/exh.py
addex
def addex(extype, exmsg, condition=None, edata=None): r""" Add an exception in the global exception handler. :param extype: Exception type; *must* be derived from the `Exception <https://docs.python.org/2/library/exceptions.html# exceptions.Exception>`_ class :type...
python
def addex(extype, exmsg, condition=None, edata=None): r""" Add an exception in the global exception handler. :param extype: Exception type; *must* be derived from the `Exception <https://docs.python.org/2/library/exceptions.html# exceptions.Exception>`_ class :type...
[ "def", "addex", "(", "extype", ",", "exmsg", ",", "condition", "=", "None", ",", "edata", "=", "None", ")", ":", "r", "return", "_ExObj", "(", "extype", ",", "exmsg", ",", "condition", ",", "edata", ")", ".", "craise" ]
r""" Add an exception in the global exception handler. :param extype: Exception type; *must* be derived from the `Exception <https://docs.python.org/2/library/exceptions.html# exceptions.Exception>`_ class :type extype: Exception type object, i.e. RuntimeError, TypeEr...
[ "r", "Add", "an", "exception", "in", "the", "global", "exception", "handler", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exh.py#L157-L207
train
pmacosta/pexdoc
pexdoc/exh.py
addai
def addai(argname, condition=None): r""" Add an "AI" exception in the global exception handler. An "AI" exception is of the type :code:`RuntimeError('Argument \`*[argname]*\` is not valid')` where :code:`*[argname]*` is the value of the **argname** argument :param argname: Argument name :t...
python
def addai(argname, condition=None): r""" Add an "AI" exception in the global exception handler. An "AI" exception is of the type :code:`RuntimeError('Argument \`*[argname]*\` is not valid')` where :code:`*[argname]*` is the value of the **argname** argument :param argname: Argument name :t...
[ "def", "addai", "(", "argname", ",", "condition", "=", "None", ")", ":", "r", "if", "not", "isinstance", "(", "argname", ",", "str", ")", ":", "raise", "RuntimeError", "(", "\"Argument `argname` is not valid\"", ")", "if", "(", "condition", "is", "not", "N...
r""" Add an "AI" exception in the global exception handler. An "AI" exception is of the type :code:`RuntimeError('Argument \`*[argname]*\` is not valid')` where :code:`*[argname]*` is the value of the **argname** argument :param argname: Argument name :type argname: string :param conditi...
[ "r", "Add", "an", "AI", "exception", "in", "the", "global", "exception", "handler", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exh.py#L210-L239
train
pmacosta/pexdoc
pexdoc/exh.py
get_or_create_exh_obj
def get_or_create_exh_obj(full_cname=False, exclude=None, callables_fname=None): r""" Return global exception handler if set, otherwise create a new one and return it. :param full_cname: Flag that indicates whether fully qualified function/method/class property names are obtained for...
python
def get_or_create_exh_obj(full_cname=False, exclude=None, callables_fname=None): r""" Return global exception handler if set, otherwise create a new one and return it. :param full_cname: Flag that indicates whether fully qualified function/method/class property names are obtained for...
[ "def", "get_or_create_exh_obj", "(", "full_cname", "=", "False", ",", "exclude", "=", "None", ",", "callables_fname", "=", "None", ")", ":", "r", "if", "not", "hasattr", "(", "__builtin__", ",", "\"_EXH\"", ")", ":", "set_exh_obj", "(", "ExHandle", "(", "f...
r""" Return global exception handler if set, otherwise create a new one and return it. :param full_cname: Flag that indicates whether fully qualified function/method/class property names are obtained for functions/methods/class properties that use the ...
[ "r", "Return", "global", "exception", "handler", "if", "set", "otherwise", "create", "a", "new", "one", "and", "return", "it", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exh.py#L260-L305
train
pmacosta/pexdoc
pexdoc/exh.py
ExHandle._flatten_ex_dict
def _flatten_ex_dict(self): """Flatten structure of exceptions dictionary.""" odict = {} for _, fdict in self._ex_dict.items(): for (extype, exmsg), value in fdict.items(): key = value["name"] odict[key] = copy.deepcopy(value) del odict...
python
def _flatten_ex_dict(self): """Flatten structure of exceptions dictionary.""" odict = {} for _, fdict in self._ex_dict.items(): for (extype, exmsg), value in fdict.items(): key = value["name"] odict[key] = copy.deepcopy(value) del odict...
[ "def", "_flatten_ex_dict", "(", "self", ")", ":", "odict", "=", "{", "}", "for", "_", ",", "fdict", "in", "self", ".", "_ex_dict", ".", "items", "(", ")", ":", "for", "(", "extype", ",", "exmsg", ")", ",", "value", "in", "fdict", ".", "items", "(...
Flatten structure of exceptions dictionary.
[ "Flatten", "structure", "of", "exceptions", "dictionary", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exh.py#L804-L814
train
pmacosta/pexdoc
pexdoc/exh.py
ExHandle._format_msg
def _format_msg(self, msg, edata): """Substitute parameters in exception message.""" edata = edata if isinstance(edata, list) else [edata] for fdict in edata: if "*[{token}]*".format(token=fdict["field"]) not in msg: raise RuntimeError( "Field {tok...
python
def _format_msg(self, msg, edata): """Substitute parameters in exception message.""" edata = edata if isinstance(edata, list) else [edata] for fdict in edata: if "*[{token}]*".format(token=fdict["field"]) not in msg: raise RuntimeError( "Field {tok...
[ "def", "_format_msg", "(", "self", ",", "msg", ",", "edata", ")", ":", "edata", "=", "edata", "if", "isinstance", "(", "edata", ",", "list", ")", "else", "[", "edata", "]", "for", "fdict", "in", "edata", ":", "if", "\"*[{token}]*\"", ".", "format", "...
Substitute parameters in exception message.
[ "Substitute", "parameters", "in", "exception", "message", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exh.py#L816-L829
train
pmacosta/pexdoc
pexdoc/exh.py
ExHandle._get_exceptions_db
def _get_exceptions_db(self): """Return a list of dictionaries suitable to be used with ptrie module.""" template = "{extype} ({exmsg}){raised}" if not self._full_cname: # When full callable name is not used the calling path is # irrelevant and there is no function associ...
python
def _get_exceptions_db(self): """Return a list of dictionaries suitable to be used with ptrie module.""" template = "{extype} ({exmsg}){raised}" if not self._full_cname: # When full callable name is not used the calling path is # irrelevant and there is no function associ...
[ "def", "_get_exceptions_db", "(", "self", ")", ":", "template", "=", "\"{extype} ({exmsg}){raised}\"", "if", "not", "self", ".", "_full_cname", ":", "ret", "=", "[", "]", "for", "_", ",", "fdict", "in", "self", ".", "_ex_dict", ".", "items", "(", ")", ":...
Return a list of dictionaries suitable to be used with ptrie module.
[ "Return", "a", "list", "of", "dictionaries", "suitable", "to", "be", "used", "with", "ptrie", "module", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exh.py#L1025-L1063
train
pmacosta/pexdoc
pexdoc/exh.py
ExHandle._get_ex_data
def _get_ex_data(self): """Return hierarchical function name.""" func_id, func_name = self._get_callable_path() if self._full_cname: func_name = self.encode_call(func_name) return func_id, func_name
python
def _get_ex_data(self): """Return hierarchical function name.""" func_id, func_name = self._get_callable_path() if self._full_cname: func_name = self.encode_call(func_name) return func_id, func_name
[ "def", "_get_ex_data", "(", "self", ")", ":", "func_id", ",", "func_name", "=", "self", ".", "_get_callable_path", "(", ")", "if", "self", ".", "_full_cname", ":", "func_name", "=", "self", ".", "encode_call", "(", "func_name", ")", "return", "func_id", ",...
Return hierarchical function name.
[ "Return", "hierarchical", "function", "name", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exh.py#L1065-L1070
train
pmacosta/pexdoc
pexdoc/exh.py
ExHandle._property_search
def _property_search(self, fobj): """Return full name if object is a class property, otherwise return None.""" # Get class object scontext = fobj.f_locals.get("self", None) class_obj = scontext.__class__ if scontext is not None else None if not class_obj: del fobj, sc...
python
def _property_search(self, fobj): """Return full name if object is a class property, otherwise return None.""" # Get class object scontext = fobj.f_locals.get("self", None) class_obj = scontext.__class__ if scontext is not None else None if not class_obj: del fobj, sc...
[ "def", "_property_search", "(", "self", ",", "fobj", ")", ":", "scontext", "=", "fobj", ".", "f_locals", ".", "get", "(", "\"self\"", ",", "None", ")", "class_obj", "=", "scontext", ".", "__class__", "if", "scontext", "is", "not", "None", "else", "None",...
Return full name if object is a class property, otherwise return None.
[ "Return", "full", "name", "if", "object", "is", "a", "class", "property", "otherwise", "return", "None", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exh.py#L1072-L1129
train
pmacosta/pexdoc
pexdoc/exh.py
ExHandle._raise_exception
def _raise_exception(self, eobj, edata=None): """Raise exception by name.""" _, _, tbobj = sys.exc_info() if edata: emsg = self._format_msg(eobj["msg"], edata) _rwtb(eobj["type"], emsg, tbobj) else: _rwtb(eobj["type"], eobj["msg"], tbobj)
python
def _raise_exception(self, eobj, edata=None): """Raise exception by name.""" _, _, tbobj = sys.exc_info() if edata: emsg = self._format_msg(eobj["msg"], edata) _rwtb(eobj["type"], emsg, tbobj) else: _rwtb(eobj["type"], eobj["msg"], tbobj)
[ "def", "_raise_exception", "(", "self", ",", "eobj", ",", "edata", "=", "None", ")", ":", "_", ",", "_", ",", "tbobj", "=", "sys", ".", "exc_info", "(", ")", "if", "edata", ":", "emsg", "=", "self", ".", "_format_msg", "(", "eobj", "[", "\"msg\"", ...
Raise exception by name.
[ "Raise", "exception", "by", "name", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exh.py#L1131-L1138
train
pmacosta/pexdoc
pexdoc/exh.py
ExHandle._unwrap_obj
def _unwrap_obj(self, fobj, fun): """Unwrap decorators.""" try: prev_func_obj, next_func_obj = ( fobj.f_globals[fun], getattr(fobj.f_globals[fun], "__wrapped__", None), ) while next_func_obj: prev_func_obj, next_func_obj...
python
def _unwrap_obj(self, fobj, fun): """Unwrap decorators.""" try: prev_func_obj, next_func_obj = ( fobj.f_globals[fun], getattr(fobj.f_globals[fun], "__wrapped__", None), ) while next_func_obj: prev_func_obj, next_func_obj...
[ "def", "_unwrap_obj", "(", "self", ",", "fobj", ",", "fun", ")", ":", "try", ":", "prev_func_obj", ",", "next_func_obj", "=", "(", "fobj", ".", "f_globals", "[", "fun", "]", ",", "getattr", "(", "fobj", ".", "f_globals", "[", "fun", "]", ",", "\"__wr...
Unwrap decorators.
[ "Unwrap", "decorators", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exh.py#L1140-L1158
train
pmacosta/pexdoc
pexdoc/exh.py
ExHandle._validate_edata
def _validate_edata(self, edata): """Validate edata argument of raise_exception_if method.""" # pylint: disable=R0916 if edata is None: return True if not (isinstance(edata, dict) or _isiterable(edata)): return False edata = [edata] if isinstance(edata, di...
python
def _validate_edata(self, edata): """Validate edata argument of raise_exception_if method.""" # pylint: disable=R0916 if edata is None: return True if not (isinstance(edata, dict) or _isiterable(edata)): return False edata = [edata] if isinstance(edata, di...
[ "def", "_validate_edata", "(", "self", ",", "edata", ")", ":", "if", "edata", "is", "None", ":", "return", "True", "if", "not", "(", "isinstance", "(", "edata", ",", "dict", ")", "or", "_isiterable", "(", "edata", ")", ")", ":", "return", "False", "e...
Validate edata argument of raise_exception_if method.
[ "Validate", "edata", "argument", "of", "raise_exception_if", "method", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exh.py#L1160-L1178
train
pmacosta/pexdoc
pexdoc/exh.py
ExHandle.add_exception
def add_exception(self, exname, extype, exmsg): r""" Add an exception to the handler. :param exname: Exception name; has to be unique within the namespace, duplicates are eliminated :type exname: non-numeric string :param extype: Exception type; *must* b...
python
def add_exception(self, exname, extype, exmsg): r""" Add an exception to the handler. :param exname: Exception name; has to be unique within the namespace, duplicates are eliminated :type exname: non-numeric string :param extype: Exception type; *must* b...
[ "def", "add_exception", "(", "self", ",", "exname", ",", "extype", ",", "exmsg", ")", ":", "r", "if", "not", "isinstance", "(", "exname", ",", "str", ")", ":", "raise", "RuntimeError", "(", "\"Argument `exname` is not valid\"", ")", "number", "=", "True", ...
r""" Add an exception to the handler. :param exname: Exception name; has to be unique within the namespace, duplicates are eliminated :type exname: non-numeric string :param extype: Exception type; *must* be derived from the `Exception <ht...
[ "r", "Add", "an", "exception", "to", "the", "handler", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exh.py#L1180-L1259
train
pmacosta/pexdoc
pexdoc/exh.py
ExHandle.decode_call
def decode_call(self, call): """ Replace callable tokens with callable names. :param call: Encoded callable name :type call: string :rtype: string """ # Callable name is None when callable is part of exclude list if call is None: return Non...
python
def decode_call(self, call): """ Replace callable tokens with callable names. :param call: Encoded callable name :type call: string :rtype: string """ # Callable name is None when callable is part of exclude list if call is None: return Non...
[ "def", "decode_call", "(", "self", ",", "call", ")", ":", "if", "call", "is", "None", ":", "return", "None", "itokens", "=", "call", ".", "split", "(", "self", ".", "_callables_separator", ")", "odict", "=", "{", "}", "for", "key", ",", "value", "in"...
Replace callable tokens with callable names. :param call: Encoded callable name :type call: string :rtype: string
[ "Replace", "callable", "tokens", "with", "callable", "names", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exh.py#L1261-L1278
train
pmacosta/pexdoc
pexdoc/exh.py
ExHandle.encode_call
def encode_call(self, call): """ Replace callables with tokens to reduce object memory footprint. A callable token is an integer that denotes the order in which the callable was encountered by the encoder, i.e. the first callable encoded is assigned token 0, the second callable ...
python
def encode_call(self, call): """ Replace callables with tokens to reduce object memory footprint. A callable token is an integer that denotes the order in which the callable was encountered by the encoder, i.e. the first callable encoded is assigned token 0, the second callable ...
[ "def", "encode_call", "(", "self", ",", "call", ")", ":", "if", "call", "is", "None", ":", "return", "None", "itokens", "=", "call", ".", "split", "(", "self", ".", "_callables_separator", ")", "otokens", "=", "[", "]", "for", "itoken", "in", "itokens"...
Replace callables with tokens to reduce object memory footprint. A callable token is an integer that denotes the order in which the callable was encountered by the encoder, i.e. the first callable encoded is assigned token 0, the second callable encoded is assigned token 1, etc. ...
[ "Replace", "callables", "with", "tokens", "to", "reduce", "object", "memory", "footprint", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/exh.py#L1280-L1305
train
Loudr/pale
pale/endpoint.py
PaleDefaultJSONEncoder.default
def default(self, obj): """Default JSON encoding.""" try: if isinstance(obj, datetime.datetime): # do the datetime thing, or encoded = arrow.get(obj).isoformat() else: # try the normal encoder encoded = json.JSONEnc...
python
def default(self, obj): """Default JSON encoding.""" try: if isinstance(obj, datetime.datetime): # do the datetime thing, or encoded = arrow.get(obj).isoformat() else: # try the normal encoder encoded = json.JSONEnc...
[ "def", "default", "(", "self", ",", "obj", ")", ":", "try", ":", "if", "isinstance", "(", "obj", ",", "datetime", ".", "datetime", ")", ":", "encoded", "=", "arrow", ".", "get", "(", "obj", ")", ".", "isoformat", "(", ")", "else", ":", "encoded", ...
Default JSON encoding.
[ "Default", "JSON", "encoding", "." ]
dc002ee6032c856551143af222ff8f71ed9853fe
https://github.com/Loudr/pale/blob/dc002ee6032c856551143af222ff8f71ed9853fe/pale/endpoint.py#L36-L52
train