nwo
stringlengths
5
106
sha
stringlengths
40
40
path
stringlengths
4
174
language
stringclasses
1 value
identifier
stringlengths
1
140
parameters
stringlengths
0
87.7k
argument_list
stringclasses
1 value
return_statement
stringlengths
0
426k
docstring
stringlengths
0
64.3k
docstring_summary
stringlengths
0
26.3k
docstring_tokens
list
function
stringlengths
18
4.83M
function_tokens
list
url
stringlengths
83
304
openstack/neutron
fb229fb527ac8b95526412f7762d90826ac41428
neutron/api/rpc/agentnotifiers/utils.py
python
retry
(func, max_attempts)
return _call_with_retry(max_attempts)(func)
Adds the retry logic to original function and returns a partial. The returned partial can be called with the same arguments as the original function.
Adds the retry logic to original function and returns a partial.
[ "Adds", "the", "retry", "logic", "to", "original", "function", "and", "returns", "a", "partial", "." ]
def retry(func, max_attempts): """Adds the retry logic to original function and returns a partial. The returned partial can be called with the same arguments as the original function. """ return _call_with_retry(max_attempts)(func)
[ "def", "retry", "(", "func", ",", "max_attempts", ")", ":", "return", "_call_with_retry", "(", "max_attempts", ")", "(", "func", ")" ]
https://github.com/openstack/neutron/blob/fb229fb527ac8b95526412f7762d90826ac41428/neutron/api/rpc/agentnotifiers/utils.py#L54-L60
kbandla/ImmunityDebugger
2abc03fb15c8f3ed0914e1175c4d8933977c73e3
1.74/PyCommands/mike.py
python
packet_analyzer.extended_packet_sniff
(self, regs)
This is for the WSA* family of socket functions where we have to do more pointer manipulation and there's a bit more work involved in getting the packets.
This is for the WSA* family of socket functions where we have to do more pointer manipulation and there's a bit more work involved in getting the packets.
[ "This", "is", "for", "the", "WSA", "*", "family", "of", "socket", "functions", "where", "we", "have", "to", "do", "more", "pointer", "manipulation", "and", "there", "s", "a", "bit", "more", "work", "involved", "in", "getting", "the", "packets", "." ]
def extended_packet_sniff(self, regs): ''' This is for the WSA* family of socket functions where we have to do more pointer manipulation and there's a bit more work involved in getting the packets. ''' (payload_ptr, recv_ptr, type, function_name) = self.imm.getKnowledge("%08x" % regs['EIP']) # This is an [out] pointer that let's us know how much data was # received on a socket (non-overlapped) length = self.imm.readMemory(recv_ptr, 4) length = struct.unpack("l", length) try: # Network apps are chatty, we don't want to grab garbage packets if length[0] > 1: counter = 0 payload = "" bin_payload = "" # Get the raw packet payload and the length of the bytes raw_payload = self.imm.readMemory(payload_ptr, int(length[0])) pack_len = str(int(length[0]))+"c" if raw_payload is not None: final_payload = struct.unpack(pack_len, raw_payload) # Iterate through the unpacked string, only outputting printable # ascii characters, output the standard dots if non-printable while counter < int(length[0]): if ord(final_payload[counter]) >= 32 and ord(final_payload[counter]) <= 126: payload += final_payload[counter] else: payload += "." bin_payload += "%02x" % ord(final_payload[counter]) counter += 1 # Build the list thats table-friendly log_items = [function_name, type, "%d" % int(length[0]), bin_payload[:512], payload[:512]] # Add the packet to the knowledgebase self.imm.addKnowledge("binary_packet", bin_payload, force_add=0x1) self.imm.addKnowledge("ascii_packet", payload, force_add=0x1) self.imm.addKnowledge("packet_length", int(length[0]),force_add=0x1) # Get a handle to the window and add the items, along with the related # address, this is sweet cause you can double-click on a packet and # see in the disassembly where it was sent/received :) cap_win = self.imm.getKnowledge("cap_win") cap_win.add(regs['EIP'], log_items) #self.imm.disableBreakpoint(regs['EIP']) except: return False
[ "def", "extended_packet_sniff", "(", "self", ",", "regs", ")", ":", "(", "payload_ptr", ",", "recv_ptr", ",", "type", ",", "function_name", ")", "=", "self", ".", "imm", ".", "getKnowledge", "(", "\"%08x\"", "%", "regs", "[", "'EIP'", "]", ")", "# This i...
https://github.com/kbandla/ImmunityDebugger/blob/2abc03fb15c8f3ed0914e1175c4d8933977c73e3/1.74/PyCommands/mike.py#L499-L556
log2timeline/dfvfs
4ca7bf06b15cdc000297a7122a065f0ca71de544
dfvfs/file_io/tsk_partition_file_io.py
python
TSKPartitionFile._Open
(self, mode='rb')
Opens the file-like object defined by path specification. Args: mode (Optional[str]): file access mode. Raises: AccessError: if the access to open the file was denied. IOError: if the file-like object could not be opened. OSError: if the file-like object could not be opened. PathSpecError: if the path specification is incorrect.
Opens the file-like object defined by path specification.
[ "Opens", "the", "file", "-", "like", "object", "defined", "by", "path", "specification", "." ]
def _Open(self, mode='rb'): """Opens the file-like object defined by path specification. Args: mode (Optional[str]): file access mode. Raises: AccessError: if the access to open the file was denied. IOError: if the file-like object could not be opened. OSError: if the file-like object could not be opened. PathSpecError: if the path specification is incorrect. """ if not self._path_spec.HasParent(): raise errors.PathSpecError( 'Unsupported path specification without parent.') self._file_system = resolver.Resolver.OpenFileSystem( self._path_spec, resolver_context=self._resolver_context) tsk_volume = self._file_system.GetTSKVolume() tsk_vs, _ = tsk_partition.GetTSKVsPartByPathSpec( tsk_volume, self._path_spec) if tsk_vs is None: raise errors.PathSpecError( 'Unable to retrieve TSK volume system part from path ' 'specification.') range_offset = tsk_partition.TSKVsPartGetStartSector(tsk_vs) range_size = tsk_partition.TSKVsPartGetNumberOfSectors(tsk_vs) if range_offset is None or range_size is None: raise errors.PathSpecError( 'Unable to retrieve TSK volume system part data range from path ' 'specification.') bytes_per_sector = tsk_partition.TSKVolumeGetBytesPerSector(tsk_volume) range_offset *= bytes_per_sector range_size *= bytes_per_sector self._SetRange(range_offset, range_size) self._file_object = resolver.Resolver.OpenFileObject( self._path_spec.parent, resolver_context=self._resolver_context)
[ "def", "_Open", "(", "self", ",", "mode", "=", "'rb'", ")", ":", "if", "not", "self", ".", "_path_spec", ".", "HasParent", "(", ")", ":", "raise", "errors", ".", "PathSpecError", "(", "'Unsupported path specification without parent.'", ")", "self", ".", "_fi...
https://github.com/log2timeline/dfvfs/blob/4ca7bf06b15cdc000297a7122a065f0ca71de544/dfvfs/file_io/tsk_partition_file_io.py#L27-L68
gentoo/portage
e5be73709b1a42b40380fd336f9381452b01a723
lib/portage/util/_dyn_libs/LinkageMapELF.py
python
LinkageMapELF.listBrokenBinaries
(self, debug=False)
return rValue
Find binaries and their needed sonames, which have no providers. @param debug: Boolean to enable debug output @type debug: Boolean @rtype: dict (example: {'/usr/bin/foo': set(['libbar.so'])}) @return: The return value is an object -> set-of-sonames mapping, where object is a broken binary and the set consists of sonames needed by object that have no corresponding libraries to fulfill the dependency.
Find binaries and their needed sonames, which have no providers.
[ "Find", "binaries", "and", "their", "needed", "sonames", "which", "have", "no", "providers", "." ]
def listBrokenBinaries(self, debug=False): """ Find binaries and their needed sonames, which have no providers. @param debug: Boolean to enable debug output @type debug: Boolean @rtype: dict (example: {'/usr/bin/foo': set(['libbar.so'])}) @return: The return value is an object -> set-of-sonames mapping, where object is a broken binary and the set consists of sonames needed by object that have no corresponding libraries to fulfill the dependency. """ os = _os_merge class _LibraryCache: """ Caches properties associated with paths. The purpose of this class is to prevent multiple instances of _ObjectKey for the same paths. """ def __init__(cache_self): cache_self.cache = {} def get(cache_self, obj): """ Caches and returns properties associated with an object. @param obj: absolute path (can be symlink) @type obj: string (example: '/usr/lib/libfoo.so') @rtype: 4-tuple with types (string or None, string or None, 2-tuple, Boolean) @return: 4-tuple with the following components: 1. arch as a string or None if it does not exist, 2. soname as a string or None if it does not exist, 3. obj_key as 2-tuple, 4. Boolean representing whether the object exists. (example: ('libfoo.so.1', (123L, 456L), True)) """ if obj in cache_self.cache: return cache_self.cache[obj] obj_key = self._obj_key(obj) # Check that the library exists on the filesystem. if obj_key.file_exists(): # Get the arch and soname from LinkageMap._obj_properties if # it exists. Otherwise, None. obj_props = self._obj_properties.get(obj_key) if obj_props is None: arch = None soname = None else: arch = obj_props.arch soname = obj_props.soname return cache_self.cache.setdefault( obj, (arch, soname, obj_key, True) ) return cache_self.cache.setdefault(obj, (None, None, obj_key, False)) rValue = {} cache = _LibraryCache() providers = self.listProviders() # Iterate over all obj_keys and their providers. for obj_key, sonames in providers.items(): obj_props = self._obj_properties[obj_key] arch = obj_props.arch path = obj_props.runpaths objs = obj_props.alt_paths path = path.union(self._defpath) # Iterate over each needed soname and the set of library paths that # fulfill the soname to determine if the dependency is broken. for soname, libraries in sonames.items(): # validLibraries is used to store libraries, which satisfy soname, # so if no valid libraries are found, the soname is not satisfied # for obj_key. If unsatisfied, objects associated with obj_key # must be emerged. validLibraries = set() # It could be the case that the library to satisfy the soname is # not in the obj's runpath, but a symlink to the library is (eg # libnvidia-tls.so.1 in nvidia-drivers). Also, since LinkageMap # does not catalog symlinks, broken or missing symlinks may go # unnoticed. As a result of these cases, check that a file with # the same name as the soname exists in obj's runpath. # XXX If we catalog symlinks in LinkageMap, this could be improved. for directory in path: cachedArch, cachedSoname, cachedKey, cachedExists = cache.get( os.path.join(directory, soname) ) # Check that this library provides the needed soname. Doing # this, however, will cause consumers of libraries missing # sonames to be unnecessarily emerged. (eg libmix.so) if cachedSoname == soname and cachedArch == arch: validLibraries.add(cachedKey) if debug and cachedKey not in set( map(self._obj_key_cache.get, libraries) ): # XXX This is most often due to soname symlinks not in # a library's directory. We could catalog symlinks in # LinkageMap to avoid checking for this edge case here. writemsg_level( _("Found provider outside of findProviders:") + ( " %s -> %s %s\n" % ( os.path.join(directory, soname), self._obj_properties[cachedKey].alt_paths, libraries, ) ), level=logging.DEBUG, noiselevel=-1, ) # A valid library has been found, so there is no need to # continue. break if ( debug and cachedArch == arch and cachedKey in self._obj_properties ): writemsg_level( ( _( "Broken symlink or missing/bad soname: " + "%(dir_soname)s -> %(cachedKey)s " + "with soname %(cachedSoname)s but expecting %(soname)s" ) % { "dir_soname": os.path.join(directory, soname), "cachedKey": self._obj_properties[cachedKey], "cachedSoname": cachedSoname, "soname": soname, } ) + "\n", level=logging.DEBUG, noiselevel=-1, ) # This conditional checks if there are no libraries to satisfy the # soname (empty set). if not validLibraries: for obj in objs: rValue.setdefault(obj, set()).add(soname) # If no valid libraries have been found by this point, then # there are no files named with the soname within obj's runpath, # but if there are libraries (from the providers mapping), it is # likely that soname symlinks or the actual libraries are # missing or broken. Thus those libraries are added to rValue # in order to emerge corrupt library packages. for lib in libraries: rValue.setdefault(lib, set()).add(soname) if debug: if not os.path.isfile(lib): writemsg_level( _("Missing library:") + " %s\n" % (lib,), level=logging.DEBUG, noiselevel=-1, ) else: writemsg_level( _("Possibly missing symlink:") + "%s\n" % (os.path.join(os.path.dirname(lib), soname)), level=logging.DEBUG, noiselevel=-1, ) return rValue
[ "def", "listBrokenBinaries", "(", "self", ",", "debug", "=", "False", ")", ":", "os", "=", "_os_merge", "class", "_LibraryCache", ":", "\"\"\"\n Caches properties associated with paths.\n\n The purpose of this class is to prevent multiple instances of\n ...
https://github.com/gentoo/portage/blob/e5be73709b1a42b40380fd336f9381452b01a723/lib/portage/util/_dyn_libs/LinkageMapELF.py#L505-L677
SickChill/SickChill
01020f3636d01535f60b83464d8127ea0efabfc7
sickchill/oldbeard/scene_exceptions.py
python
get_scene_exception_by_name_multiple
(show_name)
return [(None, None)]
Given a show name, return the indexerid of the exception, None if no exception is present.
Given a show name, return the indexerid of the exception, None if no exception is present.
[ "Given", "a", "show", "name", "return", "the", "indexerid", "of", "the", "exception", "None", "if", "no", "exception", "is", "present", "." ]
def get_scene_exception_by_name_multiple(show_name): """ Given a show name, return the indexerid of the exception, None if no exception is present. """ # try the obvious case first cache_db_con = db.DBConnection("cache.db") exception_result = cache_db_con.select("SELECT indexer_id, season FROM scene_exceptions WHERE LOWER(show_name) = ? ORDER BY season", [show_name.lower()]) if exception_result: return [(int(x["indexer_id"]), int(x["season"])) for x in exception_result] out = [] all_exception_results = cache_db_con.select("SELECT show_name, indexer_id, season FROM scene_exceptions") for cur_exception in all_exception_results: cur_exception_name = cur_exception["show_name"] cur_indexer_id = int(cur_exception["indexer_id"]) if show_name.lower() in (cur_exception_name.lower(), sickchill.oldbeard.helpers.sanitizeSceneName(cur_exception_name).lower().replace(".", " ")): logger.debug("Scene exception lookup got indexer id {0}, using that".format(cur_indexer_id)) out.append((cur_indexer_id, int(cur_exception["season"]))) if out: return out return [(None, None)]
[ "def", "get_scene_exception_by_name_multiple", "(", "show_name", ")", ":", "# try the obvious case first", "cache_db_con", "=", "db", ".", "DBConnection", "(", "\"cache.db\"", ")", "exception_result", "=", "cache_db_con", ".", "select", "(", "\"SELECT indexer_id, season FRO...
https://github.com/SickChill/SickChill/blob/01020f3636d01535f60b83464d8127ea0efabfc7/sickchill/oldbeard/scene_exceptions.py#L141-L170
midgetspy/Sick-Beard
171a607e41b7347a74cc815f6ecce7968d9acccf
lib/pythontwitter/__init__.py
python
List.GetUri
(self)
return self._uri
Get the uri of this list. Returns: The uri of this list
Get the uri of this list.
[ "Get", "the", "uri", "of", "this", "list", "." ]
def GetUri(self): '''Get the uri of this list. Returns: The uri of this list ''' return self._uri
[ "def", "GetUri", "(", "self", ")", ":", "return", "self", ".", "_uri" ]
https://github.com/midgetspy/Sick-Beard/blob/171a607e41b7347a74cc815f6ecce7968d9acccf/lib/pythontwitter/__init__.py#L1672-L1678
WerWolv/EdiZon_CheatsConfigsAndScripts
d16d36c7509c01dca770f402babd83ff2e9ae6e7
Scripts/lib/python3.5/_pyio.py
python
BufferedIOBase.readinto
(self, b)
return self._readinto(b, read1=False)
Read bytes into a pre-allocated bytes-like object b. Like read(), this may issue multiple reads to the underlying raw stream, unless the latter is 'interactive'. Returns an int representing the number of bytes read (0 for EOF). Raises BlockingIOError if the underlying raw stream has no data at the moment.
Read bytes into a pre-allocated bytes-like object b.
[ "Read", "bytes", "into", "a", "pre", "-", "allocated", "bytes", "-", "like", "object", "b", "." ]
def readinto(self, b): """Read bytes into a pre-allocated bytes-like object b. Like read(), this may issue multiple reads to the underlying raw stream, unless the latter is 'interactive'. Returns an int representing the number of bytes read (0 for EOF). Raises BlockingIOError if the underlying raw stream has no data at the moment. """ return self._readinto(b, read1=False)
[ "def", "readinto", "(", "self", ",", "b", ")", ":", "return", "self", ".", "_readinto", "(", "b", ",", "read1", "=", "False", ")" ]
https://github.com/WerWolv/EdiZon_CheatsConfigsAndScripts/blob/d16d36c7509c01dca770f402babd83ff2e9ae6e7/Scripts/lib/python3.5/_pyio.py#L663-L675
spack/spack
675210bd8bd1c5d32ad1cc83d898fb43b569ed74
lib/spack/spack/environment/environment.py
python
_equiv_list
(first, second)
return all(yaml_equivalent(f, s) for f, s in zip(first, second))
Returns whether two spack yaml lists are equivalent, including overrides
Returns whether two spack yaml lists are equivalent, including overrides
[ "Returns", "whether", "two", "spack", "yaml", "lists", "are", "equivalent", "including", "overrides" ]
def _equiv_list(first, second): """Returns whether two spack yaml lists are equivalent, including overrides """ if len(first) != len(second): return False return all(yaml_equivalent(f, s) for f, s in zip(first, second))
[ "def", "_equiv_list", "(", "first", ",", "second", ")", ":", "if", "len", "(", "first", ")", "!=", "len", "(", "second", ")", ":", "return", "False", "return", "all", "(", "yaml_equivalent", "(", "f", ",", "s", ")", "for", "f", ",", "s", "in", "z...
https://github.com/spack/spack/blob/675210bd8bd1c5d32ad1cc83d898fb43b569ed74/lib/spack/spack/environment/environment.py#L1971-L1976
openshift/openshift-tools
1188778e728a6e4781acf728123e5b356380fe6f
openshift/installer/vendored/openshift-ansible-3.10.0-0.29.0/roles/lib_vendored_deps/library/oc_route.py
python
Yedit.get_entry
(data, key, sep='.')
return data
Get an item from a dictionary with key notation a.b.c d = {'a': {'b': 'c'}}} key = a.b return c
Get an item from a dictionary with key notation a.b.c d = {'a': {'b': 'c'}}} key = a.b return c
[ "Get", "an", "item", "from", "a", "dictionary", "with", "key", "notation", "a", ".", "b", ".", "c", "d", "=", "{", "a", ":", "{", "b", ":", "c", "}}}", "key", "=", "a", ".", "b", "return", "c" ]
def get_entry(data, key, sep='.'): ''' Get an item from a dictionary with key notation a.b.c d = {'a': {'b': 'c'}}} key = a.b return c ''' if key == '': pass elif (not (key and Yedit.valid_key(key, sep)) and isinstance(data, (list, dict))): return None key_indexes = Yedit.parse_key(key, sep) for arr_ind, dict_key in key_indexes: if dict_key and isinstance(data, dict): data = data.get(dict_key) elif (arr_ind and isinstance(data, list) and int(arr_ind) <= len(data) - 1): data = data[int(arr_ind)] else: return None return data
[ "def", "get_entry", "(", "data", ",", "key", ",", "sep", "=", "'.'", ")", ":", "if", "key", "==", "''", ":", "pass", "elif", "(", "not", "(", "key", "and", "Yedit", ".", "valid_key", "(", "key", ",", "sep", ")", ")", "and", "isinstance", "(", "...
https://github.com/openshift/openshift-tools/blob/1188778e728a6e4781acf728123e5b356380fe6f/openshift/installer/vendored/openshift-ansible-3.10.0-0.29.0/roles/lib_vendored_deps/library/oc_route.py#L374-L396
yktoo/indicator-sound-switcher
c802d964e1c7b063ece973197cb92f7a76c34c1b
lib/indicator_sound_switcher/indicator.py
python
SoundSwitcherIndicator.on_refresh
(self, *args)
Signal handler: Refresh item clicked.
Signal handler: Refresh item clicked.
[ "Signal", "handler", ":", "Refresh", "item", "clicked", "." ]
def on_refresh(self, *args): """Signal handler: Refresh item clicked.""" logging.debug('.on_refresh()') self.keyboard_manager.bind_keys(self.config) self.menu_setup() self.update_all_pa_items()
[ "def", "on_refresh", "(", "self", ",", "*", "args", ")", ":", "logging", ".", "debug", "(", "'.on_refresh()'", ")", "self", ".", "keyboard_manager", ".", "bind_keys", "(", "self", ".", "config", ")", "self", ".", "menu_setup", "(", ")", "self", ".", "u...
https://github.com/yktoo/indicator-sound-switcher/blob/c802d964e1c7b063ece973197cb92f7a76c34c1b/lib/indicator_sound_switcher/indicator.py#L214-L219
pybrain/pybrain
dcdf32ba1805490cefbc0bdeb227260d304fdb42
pybrain/structure/modules/kohonen.py
python
KohonenMap._backwardImplementation
(self, outerr, inerr, outbuf, inbuf)
trains the kohonen map in unsupervised manner, moving the closest neuron and its neighbours closer to the input pattern.
trains the kohonen map in unsupervised manner, moving the closest neuron and its neighbours closer to the input pattern.
[ "trains", "the", "kohonen", "map", "in", "unsupervised", "manner", "moving", "the", "closest", "neuron", "and", "its", "neighbours", "closer", "to", "the", "input", "pattern", "." ]
def _backwardImplementation(self, outerr, inerr, outbuf, inbuf): """ trains the kohonen map in unsupervised manner, moving the closest neuron and its neighbours closer to the input pattern. """ # calculate neighbourhood and limit to edge of matrix n = floor(self.neighbours) self.neighbours *= self.neighbourdecay tl = (self.winner - n) br = (self.winner + n + 1) tl[tl < 0] = 0 br[br > self.nNeurons + 1] = self.nNeurons + 1 # calculate distance matrix tempm = 1 - sum(abs(self.distmatrix - self.winner.reshape(1, 1, 2)), 2) / self.nNeurons tempm[tempm < 0] = 0 distm = zeros((self.nNeurons, self.nNeurons, self.nInput)) for i in range(self.nInput): distm[:, :, i] = tempm distm[:, :, i] = tempm self.neurons[tl[0]:br[0], tl[1]:br[1]] -= self.learningrate * self.difference[tl[0]:br[0], tl[1]:br[1]] * distm[tl[0]:br[0], tl[1]:br[1]]
[ "def", "_backwardImplementation", "(", "self", ",", "outerr", ",", "inerr", ",", "outbuf", ",", "inbuf", ")", ":", "# calculate neighbourhood and limit to edge of matrix", "n", "=", "floor", "(", "self", ".", "neighbours", ")", "self", ".", "neighbours", "*=", "...
https://github.com/pybrain/pybrain/blob/dcdf32ba1805490cefbc0bdeb227260d304fdb42/pybrain/structure/modules/kohonen.py#L56-L76
oauthlib/oauthlib
553850bc85dfd408be0dae9884b4a0aefda8e579
oauthlib/oauth1/rfc5849/request_validator.py
python
RequestValidator.validate_requested_realms
(self, client_key, realms, request)
Validates that the client may request access to the realm. :param client_key: The client/consumer key. :param realms: The list of realms that client is requesting access to. :param request: OAuthlib request. :type request: oauthlib.common.Request :returns: True or False This method is invoked when obtaining a request token and should tie a realm to the request token and after user authorization this realm restriction should transfer to the access token. This method is used by * RequestTokenEndpoint
Validates that the client may request access to the realm.
[ "Validates", "that", "the", "client", "may", "request", "access", "to", "the", "realm", "." ]
def validate_requested_realms(self, client_key, realms, request): """Validates that the client may request access to the realm. :param client_key: The client/consumer key. :param realms: The list of realms that client is requesting access to. :param request: OAuthlib request. :type request: oauthlib.common.Request :returns: True or False This method is invoked when obtaining a request token and should tie a realm to the request token and after user authorization this realm restriction should transfer to the access token. This method is used by * RequestTokenEndpoint """ raise self._subclass_must_implement("validate_requested_realms")
[ "def", "validate_requested_realms", "(", "self", ",", "client_key", ",", "realms", ",", "request", ")", ":", "raise", "self", ".", "_subclass_must_implement", "(", "\"validate_requested_realms\"", ")" ]
https://github.com/oauthlib/oauthlib/blob/553850bc85dfd408be0dae9884b4a0aefda8e579/oauthlib/oauth1/rfc5849/request_validator.py#L656-L673
ctxis/canape
5f0e03424577296bcc60c2008a60a98ec5307e4b
CANAPE.Scripting/Lib/calendar.py
python
TextCalendar.formatweekday
(self, day, width)
return names[day][:width].center(width)
Returns a formatted week day name.
Returns a formatted week day name.
[ "Returns", "a", "formatted", "week", "day", "name", "." ]
def formatweekday(self, day, width): """ Returns a formatted week day name. """ if width >= 9: names = day_name else: names = day_abbr return names[day][:width].center(width)
[ "def", "formatweekday", "(", "self", ",", "day", ",", "width", ")", ":", "if", "width", ">=", "9", ":", "names", "=", "day_name", "else", ":", "names", "=", "day_abbr", "return", "names", "[", "day", "]", "[", ":", "width", "]", ".", "center", "(",...
https://github.com/ctxis/canape/blob/5f0e03424577296bcc60c2008a60a98ec5307e4b/CANAPE.Scripting/Lib/calendar.py#L283-L291
asciidisco/plugin.video.netflix
ceb2638a9676f5839250dadfd079b9e4e4bdd759
resources/lib/KodiHelper.py
python
KodiHelper.build_user_sub_listing
(self, video_list_ids, type, action, build_url, widget_display=False)
return True
Builds the video lists screen for user subfolders (genres & recommendations) Parameters ---------- video_list_ids : :obj:`dict` of :obj:`str` List of video lists type : :obj:`str` List type (genre or recommendation) action : :obj:`str` Action paramter to build the subsequent routes build_url : :obj:`fn` Function to build the subsequent routes Returns ------- bool List could be build
Builds the video lists screen for user subfolders (genres & recommendations)
[ "Builds", "the", "video", "lists", "screen", "for", "user", "subfolders", "(", "genres", "&", "recommendations", ")" ]
def build_user_sub_listing(self, video_list_ids, type, action, build_url, widget_display=False): """ Builds the video lists screen for user subfolders (genres & recommendations) Parameters ---------- video_list_ids : :obj:`dict` of :obj:`str` List of video lists type : :obj:`str` List type (genre or recommendation) action : :obj:`str` Action paramter to build the subsequent routes build_url : :obj:`fn` Function to build the subsequent routes Returns ------- bool List could be build """ for video_list_id in video_list_ids: li = xbmcgui.ListItem( label=video_list_ids[video_list_id]['displayName']) li.setArt( {'fanart_image' : self.default_fanart, 'icon' : self.default_fanart}) url = build_url({'action': action, 'video_list_id': video_list_id}) xbmcplugin.addDirectoryItem( handle=self.plugin_handle, url=url, listitem=li, isFolder=True) xbmcplugin.addSortMethod( handle=self.plugin_handle, sortMethod=xbmcplugin.SORT_METHOD_LABEL) xbmcplugin.setContent( handle=self.plugin_handle, content=CONTENT_FOLDER) xbmcplugin.endOfDirectory(self.plugin_handle) if not widget_display: self.set_custom_view(VIEW_FOLDER) return True
[ "def", "build_user_sub_listing", "(", "self", ",", "video_list_ids", ",", "type", ",", "action", ",", "build_url", ",", "widget_display", "=", "False", ")", ":", "for", "video_list_id", "in", "video_list_ids", ":", "li", "=", "xbmcgui", ".", "ListItem", "(", ...
https://github.com/asciidisco/plugin.video.netflix/blob/ceb2638a9676f5839250dadfd079b9e4e4bdd759/resources/lib/KodiHelper.py#L733-L781
MDudek-ICS/TRISIS-TRITON-HATMAN
15a00af7fd1040f0430729d024427601f84886a1
decompiled_code/library/inspect.py
python
cleandoc
(doc)
return
Clean up indentation from docstrings. Any whitespace that can be uniformly removed from the second line onwards is removed.
Clean up indentation from docstrings. Any whitespace that can be uniformly removed from the second line onwards is removed.
[ "Clean", "up", "indentation", "from", "docstrings", ".", "Any", "whitespace", "that", "can", "be", "uniformly", "removed", "from", "the", "second", "line", "onwards", "is", "removed", "." ]
def cleandoc(doc): """Clean up indentation from docstrings. Any whitespace that can be uniformly removed from the second line onwards is removed.""" try: lines = string.split(string.expandtabs(doc), '\n') except UnicodeError: return margin = sys.maxint for line in lines[1:]: content = len(string.lstrip(line)) if content: indent = len(line) - content margin = min(margin, indent) if lines: lines[0] = lines[0].lstrip() if margin < sys.maxint: for i in range(1, len(lines)): lines[i] = lines[i][margin:] while lines and not lines[-1]: lines.pop() while lines and not lines[0]: lines.pop(0) return string.join(lines, '\n') return
[ "def", "cleandoc", "(", "doc", ")", ":", "try", ":", "lines", "=", "string", ".", "split", "(", "string", ".", "expandtabs", "(", "doc", ")", ",", "'\\n'", ")", "except", "UnicodeError", ":", "return", "margin", "=", "sys", ".", "maxint", "for", "lin...
https://github.com/MDudek-ICS/TRISIS-TRITON-HATMAN/blob/15a00af7fd1040f0430729d024427601f84886a1/decompiled_code/library/inspect.py#L368-L398
python/cpython
e13cdca0f5224ec4e23bdd04bb3120506964bc8b
Lib/logging/__init__.py
python
Handler.format
(self, record)
return fmt.format(record)
Format the specified record. If a formatter is set, use it. Otherwise, use the default formatter for the module.
Format the specified record.
[ "Format", "the", "specified", "record", "." ]
def format(self, record): """ Format the specified record. If a formatter is set, use it. Otherwise, use the default formatter for the module. """ if self.formatter: fmt = self.formatter else: fmt = _defaultFormatter return fmt.format(record)
[ "def", "format", "(", "self", ",", "record", ")", ":", "if", "self", ".", "formatter", ":", "fmt", "=", "self", ".", "formatter", "else", ":", "fmt", "=", "_defaultFormatter", "return", "fmt", ".", "format", "(", "record", ")" ]
https://github.com/python/cpython/blob/e13cdca0f5224ec4e23bdd04bb3120506964bc8b/Lib/logging/__init__.py#L936-L947
mozillazg/pypy
2ff5cd960c075c991389f842c6d59e71cf0cb7d0
lib-python/2.7/lib-tk/Tkinter.py
python
PhotoImage.copy
(self)
return destImage
Return a new PhotoImage with the same image as this widget.
Return a new PhotoImage with the same image as this widget.
[ "Return", "a", "new", "PhotoImage", "with", "the", "same", "image", "as", "this", "widget", "." ]
def copy(self): """Return a new PhotoImage with the same image as this widget.""" destImage = PhotoImage(master=self.tk) self.tk.call(destImage, 'copy', self.name) return destImage
[ "def", "copy", "(", "self", ")", ":", "destImage", "=", "PhotoImage", "(", "master", "=", "self", ".", "tk", ")", "self", ".", "tk", ".", "call", "(", "destImage", ",", "'copy'", ",", "self", ".", "name", ")", "return", "destImage" ]
https://github.com/mozillazg/pypy/blob/2ff5cd960c075c991389f842c6d59e71cf0cb7d0/lib-python/2.7/lib-tk/Tkinter.py#L3388-L3392
graalvm/mx
29c0debab406352df3af246be2f8973be5db69ae
mx_benchmark.py
python
Vm.name
(self)
Returns the unique name of the Java VM (e.g. server, client, or jvmci).
Returns the unique name of the Java VM (e.g. server, client, or jvmci).
[ "Returns", "the", "unique", "name", "of", "the", "Java", "VM", "(", "e", ".", "g", ".", "server", "client", "or", "jvmci", ")", "." ]
def name(self): """Returns the unique name of the Java VM (e.g. server, client, or jvmci).""" raise NotImplementedError()
[ "def", "name", "(", "self", ")", ":", "raise", "NotImplementedError", "(", ")" ]
https://github.com/graalvm/mx/blob/29c0debab406352df3af246be2f8973be5db69ae/mx_benchmark.py#L1525-L1527
ucfopen/canvasapi
3f1a71e23c86a49dbaa6e84f6c0e81c297b86e36
canvasapi/user.py
python
User.get_migration_systems
(self, **kwargs)
return PaginatedList( Migrator, self._requester, "GET", "users/{}/content_migrations/migrators".format(self.id), _kwargs=combine_kwargs(**kwargs), )
Return a list of migration systems. :calls: `GET /api/v1/users/:user_id/content_migrations/migrators \ <https://canvas.instructure.com/doc/api/content_migrations.html#method.content_migrations.available_migrators>`_ :rtype: :class:`canvasapi.paginated_list.PaginatedList` of :class:`canvasapi.content_migration.Migrator`
Return a list of migration systems.
[ "Return", "a", "list", "of", "migration", "systems", "." ]
def get_migration_systems(self, **kwargs): """ Return a list of migration systems. :calls: `GET /api/v1/users/:user_id/content_migrations/migrators \ <https://canvas.instructure.com/doc/api/content_migrations.html#method.content_migrations.available_migrators>`_ :rtype: :class:`canvasapi.paginated_list.PaginatedList` of :class:`canvasapi.content_migration.Migrator` """ from canvasapi.content_migration import Migrator return PaginatedList( Migrator, self._requester, "GET", "users/{}/content_migrations/migrators".format(self.id), _kwargs=combine_kwargs(**kwargs), )
[ "def", "get_migration_systems", "(", "self", ",", "*", "*", "kwargs", ")", ":", "from", "canvasapi", ".", "content_migration", "import", "Migrator", "return", "PaginatedList", "(", "Migrator", ",", "self", ".", "_requester", ",", "\"GET\"", ",", "\"users/{}/cont...
https://github.com/ucfopen/canvasapi/blob/3f1a71e23c86a49dbaa6e84f6c0e81c297b86e36/canvasapi/user.py#L655-L673
kennethreitz-archive/requests3
69eb662703b40db58fdc6c095d0fe130c56649bb
requests3/http_utils.py
python
is_valid_cidr
(string_network: str)
return True
Very simple check of the cidr format in no_proxy variable. :rtype: bool
Very simple check of the cidr format in no_proxy variable.
[ "Very", "simple", "check", "of", "the", "cidr", "format", "in", "no_proxy", "variable", "." ]
def is_valid_cidr(string_network: str) -> bool: """ Very simple check of the cidr format in no_proxy variable. :rtype: bool """ if string_network.count("/") == 1: try: mask = int(string_network.split("/")[1]) except ValueError: return False if mask < 1 or mask > 32: return False try: socket.inet_aton(string_network.split("/")[0]) except socket.error: return False else: return False return True
[ "def", "is_valid_cidr", "(", "string_network", ":", "str", ")", "->", "bool", ":", "if", "string_network", ".", "count", "(", "\"/\"", ")", "==", "1", ":", "try", ":", "mask", "=", "int", "(", "string_network", ".", "split", "(", "\"/\"", ")", "[", "...
https://github.com/kennethreitz-archive/requests3/blob/69eb662703b40db58fdc6c095d0fe130c56649bb/requests3/http_utils.py#L597-L620
alibaba/iOSSecAudit
f94ed3254263f3382f374e3f05afae8a1fe79f20
lib/iosCertTrustManager.py
python
Encoder._emit_length_short
(self, length)
Emit the short length form (< 128 octets).
Emit the short length form (< 128 octets).
[ "Emit", "the", "short", "length", "form", "(", "<", "128", "octets", ")", "." ]
def _emit_length_short(self, length): """Emit the short length form (< 128 octets).""" assert length < 128 self._emit(chr(length))
[ "def", "_emit_length_short", "(", "self", ",", "length", ")", ":", "assert", "length", "<", "128", "self", ".", "_emit", "(", "chr", "(", "length", ")", ")" ]
https://github.com/alibaba/iOSSecAudit/blob/f94ed3254263f3382f374e3f05afae8a1fe79f20/lib/iosCertTrustManager.py#L168-L171
holzschu/Carnets
44effb10ddfc6aa5c8b0687582a724ba82c6b547
Library/lib/python3.7/site-packages/sympy/geometry/line.py
python
LinearEntity.intersection
(self, other)
return other.intersection(self)
The intersection with another geometrical entity. Parameters ========== o : Point or LinearEntity Returns ======= intersection : list of geometrical entities See Also ======== sympy.geometry.point.Point Examples ======== >>> from sympy import Point, Line, Segment >>> p1, p2, p3 = Point(0, 0), Point(1, 1), Point(7, 7) >>> l1 = Line(p1, p2) >>> l1.intersection(p3) [Point2D(7, 7)] >>> p4, p5 = Point(5, 0), Point(0, 3) >>> l2 = Line(p4, p5) >>> l1.intersection(l2) [Point2D(15/8, 15/8)] >>> p6, p7 = Point(0, 5), Point(2, 6) >>> s1 = Segment(p6, p7) >>> l1.intersection(s1) [] >>> from sympy import Point3D, Line3D, Segment3D >>> p1, p2, p3 = Point3D(0, 0, 0), Point3D(1, 1, 1), Point3D(7, 7, 7) >>> l1 = Line3D(p1, p2) >>> l1.intersection(p3) [Point3D(7, 7, 7)] >>> l1 = Line3D(Point3D(4,19,12), Point3D(5,25,17)) >>> l2 = Line3D(Point3D(-3, -15, -19), direction_ratio=[2,8,8]) >>> l1.intersection(l2) [Point3D(1, 1, -3)] >>> p6, p7 = Point3D(0, 5, 2), Point3D(2, 6, 3) >>> s1 = Segment3D(p6, p7) >>> l1.intersection(s1) []
The intersection with another geometrical entity.
[ "The", "intersection", "with", "another", "geometrical", "entity", "." ]
def intersection(self, other): """The intersection with another geometrical entity. Parameters ========== o : Point or LinearEntity Returns ======= intersection : list of geometrical entities See Also ======== sympy.geometry.point.Point Examples ======== >>> from sympy import Point, Line, Segment >>> p1, p2, p3 = Point(0, 0), Point(1, 1), Point(7, 7) >>> l1 = Line(p1, p2) >>> l1.intersection(p3) [Point2D(7, 7)] >>> p4, p5 = Point(5, 0), Point(0, 3) >>> l2 = Line(p4, p5) >>> l1.intersection(l2) [Point2D(15/8, 15/8)] >>> p6, p7 = Point(0, 5), Point(2, 6) >>> s1 = Segment(p6, p7) >>> l1.intersection(s1) [] >>> from sympy import Point3D, Line3D, Segment3D >>> p1, p2, p3 = Point3D(0, 0, 0), Point3D(1, 1, 1), Point3D(7, 7, 7) >>> l1 = Line3D(p1, p2) >>> l1.intersection(p3) [Point3D(7, 7, 7)] >>> l1 = Line3D(Point3D(4,19,12), Point3D(5,25,17)) >>> l2 = Line3D(Point3D(-3, -15, -19), direction_ratio=[2,8,8]) >>> l1.intersection(l2) [Point3D(1, 1, -3)] >>> p6, p7 = Point3D(0, 5, 2), Point3D(2, 6, 3) >>> s1 = Segment3D(p6, p7) >>> l1.intersection(s1) [] """ def intersect_parallel_rays(ray1, ray2): if ray1.direction.dot(ray2.direction) > 0: # rays point in the same direction # so return the one that is "in front" return [ray2] if ray1._span_test(ray2.p1) >= 0 else [ray1] else: # rays point in opposite directions st = ray1._span_test(ray2.p1) if st < 0: return [] elif st == 0: return [ray2.p1] return [Segment(ray1.p1, ray2.p1)] def intersect_parallel_ray_and_segment(ray, seg): st1, st2 = ray._span_test(seg.p1), ray._span_test(seg.p2) if st1 < 0 and st2 < 0: return [] elif st1 >= 0 and st2 >= 0: return [seg] elif st1 >= 0: # st2 < 0: return [Segment(ray.p1, seg.p1)] elif st2 >= 0: # st1 < 0: return [Segment(ray.p1, seg.p2)] def intersect_parallel_segments(seg1, seg2): if seg1.contains(seg2): return [seg2] if seg2.contains(seg1): return [seg1] # direct the segments so they're oriented the same way if seg1.direction.dot(seg2.direction) < 0: seg2 = Segment(seg2.p2, seg2.p1) # order the segments so seg1 is "behind" seg2 if seg1._span_test(seg2.p1) < 0: seg1, seg2 = seg2, seg1 if seg2._span_test(seg1.p2) < 0: return [] return [Segment(seg2.p1, seg1.p2)] if not isinstance(other, GeometryEntity): other = Point(other, dim=self.ambient_dimension) if other.is_Point: if self.contains(other): return [other] else: return [] elif isinstance(other, LinearEntity): # break into cases based on whether # the lines are parallel, non-parallel intersecting, or skew pts = Point._normalize_dimension(self.p1, self.p2, other.p1, other.p2) rank = Point.affine_rank(*pts) if rank == 1: # we're collinear if isinstance(self, Line): return [other] if isinstance(other, Line): return [self] if isinstance(self, Ray) and isinstance(other, Ray): return intersect_parallel_rays(self, other) if isinstance(self, Ray) and isinstance(other, Segment): return intersect_parallel_ray_and_segment(self, other) if isinstance(self, Segment) and isinstance(other, Ray): return intersect_parallel_ray_and_segment(other, self) if isinstance(self, Segment) and isinstance(other, Segment): return intersect_parallel_segments(self, other) elif rank == 2: # we're in the same plane l1 = Line(*pts[:2]) l2 = Line(*pts[2:]) # check to see if we're parallel. If we are, we can't # be intersecting, since the collinear case was already # handled if l1.direction.is_scalar_multiple(l2.direction): return [] # find the intersection as if everything were lines # by solving the equation t*d + p1 == s*d' + p1' m = Matrix([l1.direction, -l2.direction]).transpose() v = Matrix([l2.p1 - l1.p1]).transpose() # we cannot use m.solve(v) because that only works for square matrices m_rref, pivots = m.col_insert(2, v).rref(simplify=True) # rank == 2 ensures we have 2 pivots, but let's check anyway if len(pivots) != 2: raise GeometryError("Failed when solving Mx=b when M={} and b={}".format(m, v)) coeff = m_rref[0, 2] line_intersection = l1.direction*coeff + self.p1 # if we're both lines, we can skip a containment check if isinstance(self, Line) and isinstance(other, Line): return [line_intersection] if ((isinstance(self, Line) or self.contains(line_intersection)) and other.contains(line_intersection)): return [line_intersection] return [] else: # we're skew return [] return other.intersection(self)
[ "def", "intersection", "(", "self", ",", "other", ")", ":", "def", "intersect_parallel_rays", "(", "ray1", ",", "ray2", ")", ":", "if", "ray1", ".", "direction", ".", "dot", "(", "ray2", ".", "direction", ")", ">", "0", ":", "# rays point in the same direc...
https://github.com/holzschu/Carnets/blob/44effb10ddfc6aa5c8b0687582a724ba82c6b547/Library/lib/python3.7/site-packages/sympy/geometry/line.py#L390-L545
Rapptz/RoboDanny
1fb95d76d1b7685e2e2ff950e11cddfc96efbfec
cogs/mod.py
python
Mod.embeds
(self, ctx, search=100)
Removes messages that have embeds in them.
Removes messages that have embeds in them.
[ "Removes", "messages", "that", "have", "embeds", "in", "them", "." ]
async def embeds(self, ctx, search=100): """Removes messages that have embeds in them.""" await self.do_removal(ctx, search, lambda e: len(e.embeds))
[ "async", "def", "embeds", "(", "self", ",", "ctx", ",", "search", "=", "100", ")", ":", "await", "self", ".", "do_removal", "(", "ctx", ",", "search", ",", "lambda", "e", ":", "len", "(", "e", ".", "embeds", ")", ")" ]
https://github.com/Rapptz/RoboDanny/blob/1fb95d76d1b7685e2e2ff950e11cddfc96efbfec/cogs/mod.py#L1237-L1239
pypa/pipenv
b21baade71a86ab3ee1429f71fbc14d4f95fb75d
pipenv/patched/notpip/_vendor/requests/utils.py
python
get_environ_proxies
(url, no_proxy=None)
Return a dict of environment proxies. :rtype: dict
Return a dict of environment proxies.
[ "Return", "a", "dict", "of", "environment", "proxies", "." ]
def get_environ_proxies(url, no_proxy=None): """ Return a dict of environment proxies. :rtype: dict """ if should_bypass_proxies(url, no_proxy=no_proxy): return {} else: return getproxies()
[ "def", "get_environ_proxies", "(", "url", ",", "no_proxy", "=", "None", ")", ":", "if", "should_bypass_proxies", "(", "url", ",", "no_proxy", "=", "no_proxy", ")", ":", "return", "{", "}", "else", ":", "return", "getproxies", "(", ")" ]
https://github.com/pypa/pipenv/blob/b21baade71a86ab3ee1429f71fbc14d4f95fb75d/pipenv/patched/notpip/_vendor/requests/utils.py#L791-L800
caiiiac/Machine-Learning-with-Python
1a26c4467da41ca4ebc3d5bd789ea942ef79422f
MachineLearning/venv/lib/python3.5/site-packages/pandas/core/groupby.py
python
GroupBy.expanding
(self, *args, **kwargs)
return ExpandingGroupby(self, *args, **kwargs)
Return an expanding grouper, providing expanding functionaility per group
Return an expanding grouper, providing expanding functionaility per group
[ "Return", "an", "expanding", "grouper", "providing", "expanding", "functionaility", "per", "group" ]
def expanding(self, *args, **kwargs): """ Return an expanding grouper, providing expanding functionaility per group """ from pandas.core.window import ExpandingGroupby return ExpandingGroupby(self, *args, **kwargs)
[ "def", "expanding", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "from", "pandas", ".", "core", ".", "window", "import", "ExpandingGroupby", "return", "ExpandingGroupby", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")" ...
https://github.com/caiiiac/Machine-Learning-with-Python/blob/1a26c4467da41ca4ebc3d5bd789ea942ef79422f/MachineLearning/venv/lib/python3.5/site-packages/pandas/core/groupby.py#L1247-L1254
rembo10/headphones
b3199605be1ebc83a7a8feab6b1e99b64014187c
lib/argparse.py
python
HelpFormatter._fill_text
(self, text, width, indent)
return _textwrap.fill(text, width, initial_indent=indent, subsequent_indent=indent)
[]
def _fill_text(self, text, width, indent): text = self._whitespace_matcher.sub(' ', text).strip() return _textwrap.fill(text, width, initial_indent=indent, subsequent_indent=indent)
[ "def", "_fill_text", "(", "self", ",", "text", ",", "width", ",", "indent", ")", ":", "text", "=", "self", ".", "_whitespace_matcher", ".", "sub", "(", "' '", ",", "text", ")", ".", "strip", "(", ")", "return", "_textwrap", ".", "fill", "(", "text", ...
https://github.com/rembo10/headphones/blob/b3199605be1ebc83a7a8feab6b1e99b64014187c/lib/argparse.py#L621-L624
gkrizek/bash-lambda-layer
703b0ade8174022d44779d823172ab7ac33a5505
bin/docutils/parsers/rst/states.py
python
Body.anonymous
(self, match, context, next_state)
return [], next_state, []
Anonymous hyperlink targets.
Anonymous hyperlink targets.
[ "Anonymous", "hyperlink", "targets", "." ]
def anonymous(self, match, context, next_state): """Anonymous hyperlink targets.""" nodelist, blank_finish = self.anonymous_target(match) self.parent += nodelist self.explicit_list(blank_finish) return [], next_state, []
[ "def", "anonymous", "(", "self", ",", "match", ",", "context", ",", "next_state", ")", ":", "nodelist", ",", "blank_finish", "=", "self", ".", "anonymous_target", "(", "match", ")", "self", ".", "parent", "+=", "nodelist", "self", ".", "explicit_list", "("...
https://github.com/gkrizek/bash-lambda-layer/blob/703b0ade8174022d44779d823172ab7ac33a5505/bin/docutils/parsers/rst/states.py#L2363-L2368
robinhood/faust
01b4c0ad8390221db71751d80001b0fd879291e2
faust/agents/actor.py
python
Actor.on_isolated_partition_assigned
(self, tp: TP)
Call when an isolated partition is being assigned.
Call when an isolated partition is being assigned.
[ "Call", "when", "an", "isolated", "partition", "is", "being", "assigned", "." ]
async def on_isolated_partition_assigned(self, tp: TP) -> None: """Call when an isolated partition is being assigned.""" self.log.dev('Actor was assigned to %r', tp)
[ "async", "def", "on_isolated_partition_assigned", "(", "self", ",", "tp", ":", "TP", ")", "->", "None", ":", "self", ".", "log", ".", "dev", "(", "'Actor was assigned to %r'", ",", "tp", ")" ]
https://github.com/robinhood/faust/blob/01b4c0ad8390221db71751d80001b0fd879291e2/faust/agents/actor.py#L56-L58
mitshel/sopds
30a401de34f15468fcb366b70e7c0b5a8b6ee8e8
opds_catalog/zipf.py
python
_ZipDecrypter._GenerateCRCTable
()
return table
Generate a CRC-32 table. ZIP encryption uses the CRC32 one-byte primitive for scrambling some internal keys. We noticed that a direct implementation is faster than relying on binascii.crc32().
Generate a CRC-32 table.
[ "Generate", "a", "CRC", "-", "32", "table", "." ]
def _GenerateCRCTable(): """Generate a CRC-32 table. ZIP encryption uses the CRC32 one-byte primitive for scrambling some internal keys. We noticed that a direct implementation is faster than relying on binascii.crc32(). """ poly = 0xedb88320 table = [0] * 256 for i in range(256): crc = i for j in range(8): if crc & 1: crc = ((crc >> 1) & 0x7FFFFFFF) ^ poly else: crc = ((crc >> 1) & 0x7FFFFFFF) table[i] = crc return table
[ "def", "_GenerateCRCTable", "(", ")", ":", "poly", "=", "0xedb88320", "table", "=", "[", "0", "]", "*", "256", "for", "i", "in", "range", "(", "256", ")", ":", "crc", "=", "i", "for", "j", "in", "range", "(", "8", ")", ":", "if", "crc", "&", ...
https://github.com/mitshel/sopds/blob/30a401de34f15468fcb366b70e7c0b5a8b6ee8e8/opds_catalog/zipf.py#L461-L478
bhoov/exbert
d27b6236aa51b185f7d3fed904f25cabe3baeb1a
server/spacyface/spacyface/utils/f.py
python
pick
(keys:Union[List, Set], obj:Dict)
return {k: obj[k] for k in keys}
Return a NEW object containing `keys` from the original `obj`
Return a NEW object containing `keys` from the original `obj`
[ "Return", "a", "NEW", "object", "containing", "keys", "from", "the", "original", "obj" ]
def pick(keys:Union[List, Set], obj:Dict) -> Dict: """ Return a NEW object containing `keys` from the original `obj` """ return {k: obj[k] for k in keys}
[ "def", "pick", "(", "keys", ":", "Union", "[", "List", ",", "Set", "]", ",", "obj", ":", "Dict", ")", "->", "Dict", ":", "return", "{", "k", ":", "obj", "[", "k", "]", "for", "k", "in", "keys", "}" ]
https://github.com/bhoov/exbert/blob/d27b6236aa51b185f7d3fed904f25cabe3baeb1a/server/spacyface/spacyface/utils/f.py#L62-L64
CATIA-Systems/FMPy
fde192346c36eb69dbaca60a96e80cdc8ef37b89
fmpy/cross_check/__init__.py
python
validate_signal
(t, y, t_ref, y_ref, t_start, t_stop, num=1000, dx=21, dy=0.1)
return t_band, y_min, y_max, i_out
Validate a signal y(t) against a reference signal y_ref(t_ref) by creating a band around y_ref and finding the values in y outside the band Parameters: t time of the signal y values of the signal t_ref time of the reference signal y_ref values of the reference signal t_start start time of the band t_stop stop time of the band num number of samples for the band dx horizontal tolerance in samples dy relative vertical tolerance Returns: t_band time values of the band y_min lower limit of the band y_max upper limit of the band i_out indices of the outliers in y
Validate a signal y(t) against a reference signal y_ref(t_ref) by creating a band around y_ref and finding the values in y outside the band
[ "Validate", "a", "signal", "y", "(", "t", ")", "against", "a", "reference", "signal", "y_ref", "(", "t_ref", ")", "by", "creating", "a", "band", "around", "y_ref", "and", "finding", "the", "values", "in", "y", "outside", "the", "band" ]
def validate_signal(t, y, t_ref, y_ref, t_start, t_stop, num=1000, dx=21, dy=0.1): """ Validate a signal y(t) against a reference signal y_ref(t_ref) by creating a band around y_ref and finding the values in y outside the band Parameters: t time of the signal y values of the signal t_ref time of the reference signal y_ref values of the reference signal t_start start time of the band t_stop stop time of the band num number of samples for the band dx horizontal tolerance in samples dy relative vertical tolerance Returns: t_band time values of the band y_min lower limit of the band y_max upper limit of the band i_out indices of the outliers in y """ import numpy as np from scipy.ndimage.filters import maximum_filter1d, minimum_filter1d # re-sample the reference signal into a uniform grid t_band = np.linspace(start=t_start, stop=t_stop, num=num) # sort out the duplicate samples before the interpolation m = np.concatenate(([True], np.diff(t_ref) > 0)) y_band = np.interp(x=t_band, xp=t_ref[m], fp=y_ref[m]) y_band_min = np.min(y_band) y_band_max = np.max(y_band) # calculate the width of the band if y_band_min == y_band_max: w = 0.5 if y_band_min == 0 else np.abs(y_band_min) * dy else: w = (y_band_max - y_band_min) * dy # calculate the lower and upper limits y_min = minimum_filter1d(input=y_band, size=dx) - w y_max = maximum_filter1d(input=y_band, size=dx) + w # find outliers y_min_i = np.interp(x=t, xp=t_band, fp=y_min) y_max_i = np.interp(x=t, xp=t_band, fp=y_max) i_out = np.logical_or(y < y_min_i, y > y_max_i) # do not count outliers outside the t_ref i_out = np.logical_and(i_out, t >= t_start) i_out = np.logical_and(i_out, t <= t_stop) return t_band, y_min, y_max, i_out
[ "def", "validate_signal", "(", "t", ",", "y", ",", "t_ref", ",", "y_ref", ",", "t_start", ",", "t_stop", ",", "num", "=", "1000", ",", "dx", "=", "21", ",", "dy", "=", "0.1", ")", ":", "import", "numpy", "as", "np", "from", "scipy", ".", "ndimage...
https://github.com/CATIA-Systems/FMPy/blob/fde192346c36eb69dbaca60a96e80cdc8ef37b89/fmpy/cross_check/__init__.py#L87-L144
EventGhost/EventGhost
177be516849e74970d2e13cda82244be09f277ce
plugins/System/__init__.py
python
MuteOn.Configure
(self, deviceId=0)
if eg.WindowsVersion >= 'Vista': deviceCtrl.SetValue(0) deviceCtrl.Enable(False)
if eg.WindowsVersion >= 'Vista': deviceCtrl.SetValue(0) deviceCtrl.Enable(False)
[ "if", "eg", ".", "WindowsVersion", ">", "=", "Vista", ":", "deviceCtrl", ".", "SetValue", "(", "0", ")", "deviceCtrl", ".", "Enable", "(", "False", ")" ]
def Configure(self, deviceId=0): deviceId = SoundMixer.GetDeviceId(deviceId) panel = eg.ConfigPanel() deviceCtrl = panel.Choice( deviceId + 1, choices=SoundMixer.GetMixerDevices(True) ) """if eg.WindowsVersion >= 'Vista': deviceCtrl.SetValue(0) deviceCtrl.Enable(False)""" #panel.AddLine("Device:", deviceCtrl) panel.AddLine(self.plugin.text.device, deviceCtrl) while panel.Affirmed(): panel.SetResult(deviceCtrl.GetStringSelection())
[ "def", "Configure", "(", "self", ",", "deviceId", "=", "0", ")", ":", "deviceId", "=", "SoundMixer", ".", "GetDeviceId", "(", "deviceId", ")", "panel", "=", "eg", ".", "ConfigPanel", "(", ")", "deviceCtrl", "=", "panel", ".", "Choice", "(", "deviceId", ...
https://github.com/EventGhost/EventGhost/blob/177be516849e74970d2e13cda82244be09f277ce/plugins/System/__init__.py#L1974-L1986
edfungus/Crouton
ada98b3930192938a48909072b45cb84b945f875
clients/python_clients/cf_demo_client/cf_env/lib/python2.7/site-packages/jinja2/debug.py
python
ProcessedTraceback.standard_exc_info
(self)
return self.exc_type, self.exc_value, tb
Standard python exc_info for re-raising
Standard python exc_info for re-raising
[ "Standard", "python", "exc_info", "for", "re", "-", "raising" ]
def standard_exc_info(self): """Standard python exc_info for re-raising""" tb = self.frames[0] # the frame will be an actual traceback (or transparent proxy) if # we are on pypy or a python implementation with support for tproxy if type(tb) is not TracebackType: tb = tb.tb return self.exc_type, self.exc_value, tb
[ "def", "standard_exc_info", "(", "self", ")", ":", "tb", "=", "self", ".", "frames", "[", "0", "]", "# the frame will be an actual traceback (or transparent proxy) if", "# we are on pypy or a python implementation with support for tproxy", "if", "type", "(", "tb", ")", "is"...
https://github.com/edfungus/Crouton/blob/ada98b3930192938a48909072b45cb84b945f875/clients/python_clients/cf_demo_client/cf_env/lib/python2.7/site-packages/jinja2/debug.py#L122-L129
rossant/ipymd
d87c9ebc59d67fe78b0139ee00e0e5307682e303
ipymd/utils/utils.py
python
_flatten_links
(cells)
return [_flatten_links_cell(cell) for cell in cells]
Replace hypertext links by simple URL text.
Replace hypertext links by simple URL text.
[ "Replace", "hypertext", "links", "by", "simple", "URL", "text", "." ]
def _flatten_links(cells): """Replace hypertext links by simple URL text.""" return [_flatten_links_cell(cell) for cell in cells]
[ "def", "_flatten_links", "(", "cells", ")", ":", "return", "[", "_flatten_links_cell", "(", "cell", ")", "for", "cell", "in", "cells", "]" ]
https://github.com/rossant/ipymd/blob/d87c9ebc59d67fe78b0139ee00e0e5307682e303/ipymd/utils/utils.py#L86-L88
UCL-INGI/INGInious
60f10cb4c375ce207471043e76bd813220b95399
inginious/frontend/pages/tasks.py
python
TaskPageStaticDownload.GET
(self, courseid, taskid, path)
GET request
GET request
[ "GET", "request" ]
def GET(self, courseid, taskid, path): # pylint: disable=arguments-differ """ GET request """ try: course = self.course_factory.get_course(courseid) if not self.user_manager.course_is_open_to_user(course): return handle_course_unavailable(self.app.get_homepath(), self.template_helper, self.user_manager, course) path_norm = posixpath.normpath(urllib.parse.unquote(path)) if taskid == "$common": public_folder = course.get_fs().from_subfolder("$common").from_subfolder("public") else: task = course.get_task(taskid) if not self.user_manager.task_is_visible_by_user(task): # ignore LTI check here return self.template_helper.render("task_unavailable.html") public_folder = task.get_fs().from_subfolder("public") (method, mimetype_or_none, file_or_url) = public_folder.distribute(path_norm, False) if method == "local": return Response(response=file_or_url, content_type=mimetype_or_none) elif method == "url": return redirect(file_or_url) else: raise NotFound() except TaskNotFoundException: raise NotFound() except HTTPException as error_or_redirect: raise error_or_redirect
[ "def", "GET", "(", "self", ",", "courseid", ",", "taskid", ",", "path", ")", ":", "# pylint: disable=arguments-differ", "try", ":", "course", "=", "self", ".", "course_factory", ".", "get_course", "(", "courseid", ")", "if", "not", "self", ".", "user_manager...
https://github.com/UCL-INGI/INGInious/blob/60f10cb4c375ce207471043e76bd813220b95399/inginious/frontend/pages/tasks.py#L398-L427
jamesoff/simplemonitor
3b324d7bb28058e924b823aeddfaf361f943e78e
simplemonitor/Monitors/monitor.py
python
Monitor.reset_dependencies
(self)
Reset the monitor's dependency list back to default.
Reset the monitor's dependency list back to default.
[ "Reset", "the", "monitor", "s", "dependency", "list", "back", "to", "default", "." ]
def reset_dependencies(self) -> None: """Reset the monitor's dependency list back to default.""" self._deps = copy.copy(self._dependencies)
[ "def", "reset_dependencies", "(", "self", ")", "->", "None", ":", "self", ".", "_deps", "=", "copy", ".", "copy", "(", "self", ".", "_dependencies", ")" ]
https://github.com/jamesoff/simplemonitor/blob/3b324d7bb28058e924b823aeddfaf361f943e78e/simplemonitor/Monitors/monitor.py#L191-L193
Tautulli/Tautulli
2410eb33805aaac4bd1c5dad0f71e4f15afaf742
lib/mako/pyparser.py
python
ParseFunc.__init__
(self, listener, **exception_kwargs)
[]
def __init__(self, listener, **exception_kwargs): self.listener = listener self.exception_kwargs = exception_kwargs
[ "def", "__init__", "(", "self", ",", "listener", ",", "*", "*", "exception_kwargs", ")", ":", "self", ".", "listener", "=", "listener", "self", ".", "exception_kwargs", "=", "exception_kwargs" ]
https://github.com/Tautulli/Tautulli/blob/2410eb33805aaac4bd1c5dad0f71e4f15afaf742/lib/mako/pyparser.py#L207-L209
openmc-dev/openmc
0cf7d9283786677e324bfbdd0984a54d1c86dacc
openmc/deplete/abc.py
python
FissionYieldHelper.generate_tallies
(materials, mat_indexes)
Construct tallies necessary for computing fission yields Called during the operator set up phase prior to depleting. Not necessary for subclasses to implement Parameters ---------- materials : iterable of C-API materials Materials to be used in :class:`openmc.lib.MaterialFilter` mat_indexes : iterable of int Indices of tallied materials that will have their fission yields computed by this helper. Necessary as the :class:`openmc.deplete.Operator` that uses this helper may only burn a subset of all materials when running in parallel mode.
Construct tallies necessary for computing fission yields
[ "Construct", "tallies", "necessary", "for", "computing", "fission", "yields" ]
def generate_tallies(materials, mat_indexes): """Construct tallies necessary for computing fission yields Called during the operator set up phase prior to depleting. Not necessary for subclasses to implement Parameters ---------- materials : iterable of C-API materials Materials to be used in :class:`openmc.lib.MaterialFilter` mat_indexes : iterable of int Indices of tallied materials that will have their fission yields computed by this helper. Necessary as the :class:`openmc.deplete.Operator` that uses this helper may only burn a subset of all materials when running in parallel mode. """
[ "def", "generate_tallies", "(", "materials", ",", "mat_indexes", ")", ":" ]
https://github.com/openmc-dev/openmc/blob/0cf7d9283786677e324bfbdd0984a54d1c86dacc/openmc/deplete/abc.py#L450-L466
LexPredict/lexpredict-contraxsuite
1d5a2540d31f8f3f1adc442cfa13a7c007319899
sdk/python/sdk/openapi_client/model/inline_response4041.py
python
InlineResponse4041._from_openapi_data
(cls, details, *args, **kwargs)
return self
InlineResponse4041 - a model defined in OpenAPI Args: details (str): Keyword Args: _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. Defaults to True _path_to_item (tuple/list): This is a list of keys or values to drill down to the model in received_data when deserializing a response _spec_property_naming (bool): True if the variable names in the input data are serialized names, as specified in the OpenAPI document. False if the variable names in the input data are pythonic names, e.g. snake case (default) _configuration (Configuration): the instance to use when deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. _visited_composed_classes (tuple): This stores a tuple of classes that we have traveled through so that if we see that class again we will not use its discriminator again. When traveling through a discriminator, the composed schema that is is traveled through is added to this set. For example if Animal has a discriminator petType and we pass in "Dog", and the class Dog allOf includes Animal, we move through Animal once using the discriminator, and pick Dog. Then in Dog, we will make an instance of the Animal class but this time we won't travel through its discriminator because we passed in _visited_composed_classes = (Animal,)
InlineResponse4041 - a model defined in OpenAPI
[ "InlineResponse4041", "-", "a", "model", "defined", "in", "OpenAPI" ]
def _from_openapi_data(cls, details, *args, **kwargs): # noqa: E501 """InlineResponse4041 - a model defined in OpenAPI Args: details (str): Keyword Args: _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. Defaults to True _path_to_item (tuple/list): This is a list of keys or values to drill down to the model in received_data when deserializing a response _spec_property_naming (bool): True if the variable names in the input data are serialized names, as specified in the OpenAPI document. False if the variable names in the input data are pythonic names, e.g. snake case (default) _configuration (Configuration): the instance to use when deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. _visited_composed_classes (tuple): This stores a tuple of classes that we have traveled through so that if we see that class again we will not use its discriminator again. When traveling through a discriminator, the composed schema that is is traveled through is added to this set. For example if Animal has a discriminator petType and we pass in "Dog", and the class Dog allOf includes Animal, we move through Animal once using the discriminator, and pick Dog. Then in Dog, we will make an instance of the Animal class but this time we won't travel through its discriminator because we passed in _visited_composed_classes = (Animal,) """ _check_type = kwargs.pop('_check_type', True) _spec_property_naming = kwargs.pop('_spec_property_naming', False) _path_to_item = kwargs.pop('_path_to_item', ()) _configuration = kwargs.pop('_configuration', None) _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) self = super(OpenApiModel, cls).__new__(cls) if args: raise ApiTypeError( "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, ), path_to_item=_path_to_item, valid_classes=(self.__class__,), ) self._data_store = {} self._check_type = _check_type self._spec_property_naming = _spec_property_naming self._path_to_item = _path_to_item self._configuration = _configuration self._visited_composed_classes = _visited_composed_classes + (self.__class__,) self.details = details for var_name, var_value in kwargs.items(): if var_name not in self.attribute_map and \ self._configuration is not None and \ self._configuration.discard_unknown_keys and \ self.additional_properties_type is None: # discard variable. continue setattr(self, var_name, var_value) return self
[ "def", "_from_openapi_data", "(", "cls", ",", "details", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# noqa: E501", "_check_type", "=", "kwargs", ".", "pop", "(", "'_check_type'", ",", "True", ")", "_spec_property_naming", "=", "kwargs", ".", "po...
https://github.com/LexPredict/lexpredict-contraxsuite/blob/1d5a2540d31f8f3f1adc442cfa13a7c007319899/sdk/python/sdk/openapi_client/model/inline_response4041.py#L103-L176
robcarver17/pysystemtrade
b0385705b7135c52d39cb6d2400feece881bcca9
sysproduction/update_multiple_adjusted_prices.py
python
get_dict_of_new_prices_and_contractid
( instrument_code: str, contract_date_dict: setOfNamedContracts, data: dataBlob )
return new_prices_dict
:param instrument_code: str :param contract_list: dict of 'yyyymmdd' str, keynames 'CARRY, PRICE, FORWARD' :param data: :return: dict of futures contract prices for each contract, plus contract id column
[]
def get_dict_of_new_prices_and_contractid( instrument_code: str, contract_date_dict: setOfNamedContracts, data: dataBlob ) -> dictFuturesNamedContractFinalPricesWithContractID: """ :param instrument_code: str :param contract_list: dict of 'yyyymmdd' str, keynames 'CARRY, PRICE, FORWARD' :param data: :return: dict of futures contract prices for each contract, plus contract id column """ diag_prices = diagPrices(data) # get prices for relevant contracts, return as dict labelled with column # for contractids relevant_contract_prices = dict() for key, contract_date_str in contract_date_dict.items(): contract = futuresContract(instrument_code, contract_date_str) price_series = diag_prices.get_prices_for_contract_object(contract) relevant_contract_prices[key] = price_series.return_final_prices() relevant_contract_prices = dictNamedFuturesContractFinalPrices( relevant_contract_prices ) new_prices_dict = ( dictFuturesNamedContractFinalPricesWithContractID.create_from_two_dicts( relevant_contract_prices, contract_date_dict ) ) return new_prices_dict
[ "def", "get_dict_of_new_prices_and_contractid", "(", "instrument_code", ":", "str", ",", "contract_date_dict", ":", "setOfNamedContracts", ",", "data", ":", "dataBlob", ")", "->", "dictFuturesNamedContractFinalPricesWithContractID", ":", "diag_prices", "=", "diagPrices", "(...
https://github.com/robcarver17/pysystemtrade/blob/b0385705b7135c52d39cb6d2400feece881bcca9/sysproduction/update_multiple_adjusted_prices.py#L171-L200
arthurdejong/python-stdnum
02dec52602ae0709b940b781fc1fcebfde7340b7
stdnum/issn.py
python
is_valid
(number)
Check if the number provided is a valid ISSN.
Check if the number provided is a valid ISSN.
[ "Check", "if", "the", "number", "provided", "is", "a", "valid", "ISSN", "." ]
def is_valid(number): """Check if the number provided is a valid ISSN.""" try: return bool(validate(number)) except ValidationError: return False
[ "def", "is_valid", "(", "number", ")", ":", "try", ":", "return", "bool", "(", "validate", "(", "number", ")", ")", "except", "ValidationError", ":", "return", "False" ]
https://github.com/arthurdejong/python-stdnum/blob/02dec52602ae0709b940b781fc1fcebfde7340b7/stdnum/issn.py#L84-L89
OpenMDAO/OpenMDAO-Framework
f2e37b7de3edeaaeb2d251b375917adec059db9b
openmdao.util/src/openmdao/util/stream.py
python
Stream.write_float
(self, value, fmt='%.16g', sep='', full_record=False)
Writes a float. value: float Value to be written. fmt: string Format to use when writing as text. sep: string Appended to stream after writing `value`. full_record: bool If True, then write surrounding recordmarks. Only meaningful if `unformatted`.
Writes a float.
[ "Writes", "a", "float", "." ]
def write_float(self, value, fmt='%.16g', sep='', full_record=False): """ Writes a float. value: float Value to be written. fmt: string Format to use when writing as text. sep: string Appended to stream after writing `value`. full_record: bool If True, then write surrounding recordmarks. Only meaningful if `unformatted`. """ if self.binary: if full_record and self.unformatted: self.write_recordmark(self.reclen_floats(1)) fmt = '>' if self.big_endian else '<' fmt += 'f' if self.single_precision else 'd' self.file.write(struct.pack(fmt, value)) if full_record and self.unformatted: self.write_recordmark(self.reclen_floats(1)) else: self.file.write(fmt % value) if full_record: self.file.write('\n') elif sep: self.file.write(sep)
[ "def", "write_float", "(", "self", ",", "value", ",", "fmt", "=", "'%.16g'", ",", "sep", "=", "''", ",", "full_record", "=", "False", ")", ":", "if", "self", ".", "binary", ":", "if", "full_record", "and", "self", ".", "unformatted", ":", "self", "."...
https://github.com/OpenMDAO/OpenMDAO-Framework/blob/f2e37b7de3edeaaeb2d251b375917adec059db9b/openmdao.util/src/openmdao/util/stream.py#L329-L361
autotest/autotest
4614ae5f550cc888267b9a419e4b90deb54f8fae
client/shared/data_dir.py
python
get_test_providers_dir
()
return TEST_PROVIDERS_DIR
Return the base test providers dir (at the moment, test-providers.d).
Return the base test providers dir (at the moment, test-providers.d).
[ "Return", "the", "base", "test", "providers", "dir", "(", "at", "the", "moment", "test", "-", "providers", ".", "d", ")", "." ]
def get_test_providers_dir(): """ Return the base test providers dir (at the moment, test-providers.d). """ if not os.path.isdir(TEST_PROVIDERS_DOWNLOAD_DIR): os.makedirs(TEST_PROVIDERS_DOWNLOAD_DIR) return TEST_PROVIDERS_DIR
[ "def", "get_test_providers_dir", "(", ")", ":", "if", "not", "os", ".", "path", ".", "isdir", "(", "TEST_PROVIDERS_DOWNLOAD_DIR", ")", ":", "os", ".", "makedirs", "(", "TEST_PROVIDERS_DOWNLOAD_DIR", ")", "return", "TEST_PROVIDERS_DIR" ]
https://github.com/autotest/autotest/blob/4614ae5f550cc888267b9a419e4b90deb54f8fae/client/shared/data_dir.py#L211-L217
sunpy/sunpy
528579df0a4c938c133bd08971ba75c131b189a7
sunpy/map/sources/sdo.py
python
HMISynopticMap.is_datasource_for
(cls, data, header, **kwargs)
return (str(header.get('TELESCOP', '')).endswith('HMI') and str(header.get('CONTENT', '')) == 'Carrington Synoptic Chart Of Br Field')
Determines if header corresponds to an HMI synoptic map.
Determines if header corresponds to an HMI synoptic map.
[ "Determines", "if", "header", "corresponds", "to", "an", "HMI", "synoptic", "map", "." ]
def is_datasource_for(cls, data, header, **kwargs): """ Determines if header corresponds to an HMI synoptic map. """ return (str(header.get('TELESCOP', '')).endswith('HMI') and str(header.get('CONTENT', '')) == 'Carrington Synoptic Chart Of Br Field')
[ "def", "is_datasource_for", "(", "cls", ",", "data", ",", "header", ",", "*", "*", "kwargs", ")", ":", "return", "(", "str", "(", "header", ".", "get", "(", "'TELESCOP'", ",", "''", ")", ")", ".", "endswith", "(", "'HMI'", ")", "and", "str", "(", ...
https://github.com/sunpy/sunpy/blob/528579df0a4c938c133bd08971ba75c131b189a7/sunpy/map/sources/sdo.py#L203-L209
SickChill/SickChill
01020f3636d01535f60b83464d8127ea0efabfc7
sickchill/oldbeard/helpers.py
python
indentXML
(elem, level=0)
Does our pretty printing, makes Matt very happy
Does our pretty printing, makes Matt very happy
[ "Does", "our", "pretty", "printing", "makes", "Matt", "very", "happy" ]
def indentXML(elem, level=0): """ Does our pretty printing, makes Matt very happy """ i = "\n" + level * " " if elem: if not elem.text or not elem.text.strip(): elem.text = i + " " if not elem.tail or not elem.tail.strip(): elem.tail = i for elem in elem: indentXML(elem, level + 1) if not elem.tail or not elem.tail.strip(): elem.tail = i else: if level and (not elem.tail or not elem.tail.strip()): elem.tail = i
[ "def", "indentXML", "(", "elem", ",", "level", "=", "0", ")", ":", "i", "=", "\"\\n\"", "+", "level", "*", "\" \"", "if", "elem", ":", "if", "not", "elem", ".", "text", "or", "not", "elem", ".", "text", ".", "strip", "(", ")", ":", "elem", "."...
https://github.com/SickChill/SickChill/blob/01020f3636d01535f60b83464d8127ea0efabfc7/sickchill/oldbeard/helpers.py#L97-L113
Chia-Network/chia-blockchain
34d44c1324ae634a0896f7b02eaa2802af9526cd
chia/util/file_keyring.py
python
FileKeyring.set_password
(self, service: str, user: str, passphrase: str)
Store the passphrase to the keyring data using the name specified by the 'user' parameter. Will force a write to keyring.yaml on success.
Store the passphrase to the keyring data using the name specified by the 'user' parameter. Will force a write to keyring.yaml on success.
[ "Store", "the", "passphrase", "to", "the", "keyring", "data", "using", "the", "name", "specified", "by", "the", "user", "parameter", ".", "Will", "force", "a", "write", "to", "keyring", ".", "yaml", "on", "success", "." ]
def set_password(self, service: str, user: str, passphrase: str): """ Store the passphrase to the keyring data using the name specified by the 'user' parameter. Will force a write to keyring.yaml on success. """ with acquire_writer_lock(lock_path=self.keyring_lock_path): self._inner_set_password(service, user, passphrase)
[ "def", "set_password", "(", "self", ",", "service", ":", "str", ",", "user", ":", "str", ",", "passphrase", ":", "str", ")", ":", "with", "acquire_writer_lock", "(", "lock_path", "=", "self", ".", "keyring_lock_path", ")", ":", "self", ".", "_inner_set_pas...
https://github.com/Chia-Network/chia-blockchain/blob/34d44c1324ae634a0896f7b02eaa2802af9526cd/chia/util/file_keyring.py#L258-L264
home-assistant/supervisor
69c2517d5211b483fdfe968b0a2b36b672ee7ab2
supervisor/resolution/evaluate.py
python
ResolutionEvaluation.evaluate_system
(self)
Evaluate the system.
Evaluate the system.
[ "Evaluate", "the", "system", "." ]
async def evaluate_system(self) -> None: """Evaluate the system.""" _LOGGER.info("Starting system evaluation with state %s", self.sys_core.state) for evaluation in self.all_evaluations: try: await evaluation() except Exception as err: # pylint: disable=broad-except _LOGGER.warning( "Error during processing %s: %s", evaluation.reason, err ) self.sys_capture_exception(err) if any(reason in self.sys_resolution.unsupported for reason in UNHEALTHY): self.sys_resolution.unhealthy = UnhealthyReason.DOCKER _LOGGER.info("System evaluation complete")
[ "async", "def", "evaluate_system", "(", "self", ")", "->", "None", ":", "_LOGGER", ".", "info", "(", "\"Starting system evaluation with state %s\"", ",", "self", ".", "sys_core", ".", "state", ")", "for", "evaluation", "in", "self", ".", "all_evaluations", ":", ...
https://github.com/home-assistant/supervisor/blob/69c2517d5211b483fdfe968b0a2b36b672ee7ab2/supervisor/resolution/evaluate.py#L51-L67
declare-lab/conv-emotion
0c9dcb9cc5234a7ca8cf6af81aabe28ef3814d0e
emotion-cause-extraction/RoBERTa Baseline/simpletransformers/conv_ai/conv_ai_model.py
python
ConvAIModel.build_input_from_segments
(self, persona, history, reply, tokenizer, lm_labels=False, with_eos=True)
return instance
Build a sequence of input from 3 segments: persona, history and last reply.
Build a sequence of input from 3 segments: persona, history and last reply.
[ "Build", "a", "sequence", "of", "input", "from", "3", "segments", ":", "persona", "history", "and", "last", "reply", "." ]
def build_input_from_segments(self, persona, history, reply, tokenizer, lm_labels=False, with_eos=True): """ Build a sequence of input from 3 segments: persona, history and last reply. """ bos, eos, speaker1, speaker2 = tokenizer.convert_tokens_to_ids(SPECIAL_TOKENS[:-1]) sequence = [[bos] + list(chain(*persona))] + history + [reply + ([eos] if with_eos else [])] sequence = [sequence[0]] + [ [speaker2 if (len(sequence) - i) % 2 else speaker1] + s for i, s in enumerate(sequence[1:]) ] instance = {} instance["input_ids"] = list(chain(*sequence)) instance["token_type_ids"] = [speaker2 if i % 2 else speaker1 for i, s in enumerate(sequence) for _ in s] instance["mc_token_ids"] = len(instance["input_ids"]) - 1 instance["lm_labels"] = [-100] * len(instance["input_ids"]) if lm_labels: instance["lm_labels"] = ([-100] * sum(len(s) for s in sequence[:-1])) + [-100] + sequence[-1][1:] return instance
[ "def", "build_input_from_segments", "(", "self", ",", "persona", ",", "history", ",", "reply", ",", "tokenizer", ",", "lm_labels", "=", "False", ",", "with_eos", "=", "True", ")", ":", "bos", ",", "eos", ",", "speaker1", ",", "speaker2", "=", "tokenizer", ...
https://github.com/declare-lab/conv-emotion/blob/0c9dcb9cc5234a7ca8cf6af81aabe28ef3814d0e/emotion-cause-extraction/RoBERTa Baseline/simpletransformers/conv_ai/conv_ai_model.py#L944-L958
plotly/plotly.py
cfad7862594b35965c0e000813bd7805e8494a5b
packages/python/plotly/plotly/graph_objs/densitymapbox/_colorbar.py
python
ColorBar.tickformatstopdefaults
(self)
return self["tickformatstopdefaults"]
When used in a template (as layout.template.data.densitymapbox. colorbar.tickformatstopdefaults), sets the default property values to use for elements of densitymapbox.colorbar.tickformatstops The 'tickformatstopdefaults' property is an instance of Tickformatstop that may be specified as: - An instance of :class:`plotly.graph_objs.densitymapbox.colorbar.Tickformatstop` - A dict of string/value properties that will be passed to the Tickformatstop constructor Supported dict properties: Returns ------- plotly.graph_objs.densitymapbox.colorbar.Tickformatstop
When used in a template (as layout.template.data.densitymapbox. colorbar.tickformatstopdefaults), sets the default property values to use for elements of densitymapbox.colorbar.tickformatstops The 'tickformatstopdefaults' property is an instance of Tickformatstop that may be specified as: - An instance of :class:`plotly.graph_objs.densitymapbox.colorbar.Tickformatstop` - A dict of string/value properties that will be passed to the Tickformatstop constructor Supported dict properties:
[ "When", "used", "in", "a", "template", "(", "as", "layout", ".", "template", ".", "data", ".", "densitymapbox", ".", "colorbar", ".", "tickformatstopdefaults", ")", "sets", "the", "default", "property", "values", "to", "use", "for", "elements", "of", "densit...
def tickformatstopdefaults(self): """ When used in a template (as layout.template.data.densitymapbox. colorbar.tickformatstopdefaults), sets the default property values to use for elements of densitymapbox.colorbar.tickformatstops The 'tickformatstopdefaults' property is an instance of Tickformatstop that may be specified as: - An instance of :class:`plotly.graph_objs.densitymapbox.colorbar.Tickformatstop` - A dict of string/value properties that will be passed to the Tickformatstop constructor Supported dict properties: Returns ------- plotly.graph_objs.densitymapbox.colorbar.Tickformatstop """ return self["tickformatstopdefaults"]
[ "def", "tickformatstopdefaults", "(", "self", ")", ":", "return", "self", "[", "\"tickformatstopdefaults\"", "]" ]
https://github.com/plotly/plotly.py/blob/cfad7862594b35965c0e000813bd7805e8494a5b/packages/python/plotly/plotly/graph_objs/densitymapbox/_colorbar.py#L851-L870
meejah/txtorcon
7da6ad6f91c395951be1b4e7e1011baa2f7a689f
txtorcon/circuit.py
python
Circuit.when_built
(self)
return self._when_built.when_fired()
Returns a Deferred that is callback()'d (with this Circuit instance) when this circuit hits BUILT. If it's already BUILT when this is called, you get an already-successful Deferred; otherwise, the state must change to BUILT. If the circuit will never hit BUILT (e.g. it is abandoned by Tor before it gets to BUILT) you will receive an errback
Returns a Deferred that is callback()'d (with this Circuit instance) when this circuit hits BUILT.
[ "Returns", "a", "Deferred", "that", "is", "callback", "()", "d", "(", "with", "this", "Circuit", "instance", ")", "when", "this", "circuit", "hits", "BUILT", "." ]
def when_built(self): """ Returns a Deferred that is callback()'d (with this Circuit instance) when this circuit hits BUILT. If it's already BUILT when this is called, you get an already-successful Deferred; otherwise, the state must change to BUILT. If the circuit will never hit BUILT (e.g. it is abandoned by Tor before it gets to BUILT) you will receive an errback """ # XXX note to self: we never do an errback; fix this behavior if self.state == 'BUILT': return defer.succeed(self) return self._when_built.when_fired()
[ "def", "when_built", "(", "self", ")", ":", "# XXX note to self: we never do an errback; fix this behavior", "if", "self", ".", "state", "==", "'BUILT'", ":", "return", "defer", ".", "succeed", "(", "self", ")", "return", "self", ".", "_when_built", ".", "when_fir...
https://github.com/meejah/txtorcon/blob/7da6ad6f91c395951be1b4e7e1011baa2f7a689f/txtorcon/circuit.py#L241-L256
home-assistant/core
265ebd17a3f17ed8dc1e9bdede03ac8e323f1ab1
homeassistant/components/bbox/device_tracker.py
python
BboxDeviceScanner.scan_devices
(self)
return [device.mac for device in self.last_results]
Scan for new devices and return a list with found device IDs.
Scan for new devices and return a list with found device IDs.
[ "Scan", "for", "new", "devices", "and", "return", "a", "list", "with", "found", "device", "IDs", "." ]
def scan_devices(self): """Scan for new devices and return a list with found device IDs.""" self._update_info() return [device.mac for device in self.last_results]
[ "def", "scan_devices", "(", "self", ")", ":", "self", ".", "_update_info", "(", ")", "return", "[", "device", ".", "mac", "for", "device", "in", "self", ".", "last_results", "]" ]
https://github.com/home-assistant/core/blob/265ebd17a3f17ed8dc1e9bdede03ac8e323f1ab1/homeassistant/components/bbox/device_tracker.py#L58-L62
ioflo/ioflo
177ac656d7c4ff801aebb0d8b401db365a5248ce
ioflo/aid/odicting.py
python
odict.__delitem__
(self, key)
del x[y]
del x[y]
[ "del", "x", "[", "y", "]" ]
def __delitem__(self, key): """ del x[y] """ dict.__delitem__(self, key) self._keys.remove(key)
[ "def", "__delitem__", "(", "self", ",", "key", ")", ":", "dict", ".", "__delitem__", "(", "self", ",", "key", ")", "self", ".", "_keys", ".", "remove", "(", "key", ")" ]
https://github.com/ioflo/ioflo/blob/177ac656d7c4ff801aebb0d8b401db365a5248ce/ioflo/aid/odicting.py#L80-L83
TencentCloud/tencentcloud-sdk-python
3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2
tencentcloud/tdmq/v20200217/tdmq_client.py
python
TdmqClient.DeleteRocketMQGroup
(self, request)
删除RocketMQ消费组 :param request: Request instance for DeleteRocketMQGroup. :type request: :class:`tencentcloud.tdmq.v20200217.models.DeleteRocketMQGroupRequest` :rtype: :class:`tencentcloud.tdmq.v20200217.models.DeleteRocketMQGroupResponse`
删除RocketMQ消费组
[ "删除RocketMQ消费组" ]
def DeleteRocketMQGroup(self, request): """删除RocketMQ消费组 :param request: Request instance for DeleteRocketMQGroup. :type request: :class:`tencentcloud.tdmq.v20200217.models.DeleteRocketMQGroupRequest` :rtype: :class:`tencentcloud.tdmq.v20200217.models.DeleteRocketMQGroupResponse` """ try: params = request._serialize() body = self.call("DeleteRocketMQGroup", params) response = json.loads(body) if "Error" not in response["Response"]: model = models.DeleteRocketMQGroupResponse() model._deserialize(response["Response"]) return model else: code = response["Response"]["Error"]["Code"] message = response["Response"]["Error"]["Message"] reqid = response["Response"]["RequestId"] raise TencentCloudSDKException(code, message, reqid) except Exception as e: if isinstance(e, TencentCloudSDKException): raise else: raise TencentCloudSDKException(e.message, e.message)
[ "def", "DeleteRocketMQGroup", "(", "self", ",", "request", ")", ":", "try", ":", "params", "=", "request", ".", "_serialize", "(", ")", "body", "=", "self", ".", "call", "(", "\"DeleteRocketMQGroup\"", ",", "params", ")", "response", "=", "json", ".", "l...
https://github.com/TencentCloud/tencentcloud-sdk-python/blob/3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2/tencentcloud/tdmq/v20200217/tdmq_client.py#L953-L978
jgagneastro/coffeegrindsize
22661ebd21831dba4cf32bfc6ba59fe3d49f879c
App/venv/lib/python3.7/site-packages/pip/_vendor/requests/models.py
python
Response.json
(self, **kwargs)
return complexjson.loads(self.text, **kwargs)
r"""Returns the json-encoded content of a response, if any. :param \*\*kwargs: Optional arguments that ``json.loads`` takes. :raises ValueError: If the response body does not contain valid json.
r"""Returns the json-encoded content of a response, if any.
[ "r", "Returns", "the", "json", "-", "encoded", "content", "of", "a", "response", "if", "any", "." ]
def json(self, **kwargs): r"""Returns the json-encoded content of a response, if any. :param \*\*kwargs: Optional arguments that ``json.loads`` takes. :raises ValueError: If the response body does not contain valid json. """ if not self.encoding and self.content and len(self.content) > 3: # No encoding set. JSON RFC 4627 section 3 states we should expect # UTF-8, -16 or -32. Detect which one to use; If the detection or # decoding fails, fall back to `self.text` (using chardet to make # a best guess). encoding = guess_json_utf(self.content) if encoding is not None: try: return complexjson.loads( self.content.decode(encoding), **kwargs ) except UnicodeDecodeError: # Wrong UTF codec detected; usually because it's not UTF-8 # but some other 8-bit codec. This is an RFC violation, # and the server didn't bother to tell us what codec *was* # used. pass return complexjson.loads(self.text, **kwargs)
[ "def", "json", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".", "encoding", "and", "self", ".", "content", "and", "len", "(", "self", ".", "content", ")", ">", "3", ":", "# No encoding set. JSON RFC 4627 section 3 states we should ex...
https://github.com/jgagneastro/coffeegrindsize/blob/22661ebd21831dba4cf32bfc6ba59fe3d49f879c/App/venv/lib/python3.7/site-packages/pip/_vendor/requests/models.py#L873-L897
GoSecure/pyrdp
abd8b8762b6d7fd0e49d4a927b529f892b412743
pyrdp/parser/rdp/orders/primary.py
python
FastGlyph.__str__
(self)
return f'<FastGlyph Cache={self.cacheId}:{self.cacheIndex} New={self.glyph != None}>'
[]
def __str__(self): return f'<FastGlyph Cache={self.cacheId}:{self.cacheIndex} New={self.glyph != None}>'
[ "def", "__str__", "(", "self", ")", ":", "return", "f'<FastGlyph Cache={self.cacheId}:{self.cacheIndex} New={self.glyph != None}>'" ]
https://github.com/GoSecure/pyrdp/blob/abd8b8762b6d7fd0e49d4a927b529f892b412743/pyrdp/parser/rdp/orders/primary.py#L1081-L1082
kevoreilly/CAPEv2
6cf79c33264624b3604d4cd432cde2a6b4536de6
lib/cuckoo/common/abstracts.py
python
Signature.check_argument_call
(self, call, pattern, name=None, api=None, category=None, regex=False, all=False, ignorecase=False)
return False
Checks for a specific argument of an invoked API. @param call: API call information. @param pattern: string or expression to check for. @param name: optional filter for the argument name. @param api: optional filter for the API function name. @param category: optional filter for a category name. @param regex: boolean representing if the pattern is a regular expression or not and therefore should be compiled. @param all: boolean representing if all results should be returned in a set or not @param ignorecase: boolean representing whether the search is case-insensitive or not @return: depending on the value of param 'all', either a set of matched items or the first matched item
Checks for a specific argument of an invoked API.
[ "Checks", "for", "a", "specific", "argument", "of", "an", "invoked", "API", "." ]
def check_argument_call(self, call, pattern, name=None, api=None, category=None, regex=False, all=False, ignorecase=False): """Checks for a specific argument of an invoked API. @param call: API call information. @param pattern: string or expression to check for. @param name: optional filter for the argument name. @param api: optional filter for the API function name. @param category: optional filter for a category name. @param regex: boolean representing if the pattern is a regular expression or not and therefore should be compiled. @param all: boolean representing if all results should be returned in a set or not @param ignorecase: boolean representing whether the search is case-insensitive or not @return: depending on the value of param 'all', either a set of matched items or the first matched item """ if all: retset = set() # Check if there's an API name filter. if api: if call["api"] != api: return False # Check if there's a category filter. if category: if call["category"] != category: return False # Loop through arguments. for argument in call["arguments"]: # Check if there's an argument name filter. if name: if argument["name"] != name: continue # Check if the argument value matches. ret = self._check_value(pattern=pattern, subject=argument["value"], regex=regex, all=all, ignorecase=ignorecase) if ret: if all: retset.update(ret) else: return argument["value"] if all and len(retset) > 0: return retset return False
[ "def", "check_argument_call", "(", "self", ",", "call", ",", "pattern", ",", "name", "=", "None", ",", "api", "=", "None", ",", "category", "=", "None", ",", "regex", "=", "False", ",", "all", "=", "False", ",", "ignorecase", "=", "False", ")", ":", ...
https://github.com/kevoreilly/CAPEv2/blob/6cf79c33264624b3604d4cd432cde2a6b4536de6/lib/cuckoo/common/abstracts.py#L1201-L1248
saltstack/salt
fae5bc757ad0f1716483ce7ae180b451545c2058
salt/ext/tornado/http1connection.py
python
HTTP1Connection.finish
(self)
Implements `.HTTPConnection.finish`.
Implements `.HTTPConnection.finish`.
[ "Implements", ".", "HTTPConnection", ".", "finish", "." ]
def finish(self): """Implements `.HTTPConnection.finish`.""" if (self._expected_content_remaining is not None and self._expected_content_remaining != 0 and not self.stream.closed()): self.stream.close() raise httputil.HTTPOutputError( "Tried to write %d bytes less than Content-Length" % self._expected_content_remaining) if self._chunking_output: if not self.stream.closed(): self._pending_write = self.stream.write(b"0\r\n\r\n") self._pending_write.add_done_callback(self._on_write_complete) self._write_finished = True # If the app finished the request while we're still reading, # divert any remaining data away from the delegate and # close the connection when we're done sending our response. # Closing the connection is the only way to avoid reading the # whole input body. if not self._read_finished: self._disconnect_on_finish = True # No more data is coming, so instruct TCP to send any remaining # data immediately instead of waiting for a full packet or ack. self.stream.set_nodelay(True) if self._pending_write is None: self._finish_request(None) else: self._pending_write.add_done_callback(self._finish_request)
[ "def", "finish", "(", "self", ")", ":", "if", "(", "self", ".", "_expected_content_remaining", "is", "not", "None", "and", "self", ".", "_expected_content_remaining", "!=", "0", "and", "not", "self", ".", "stream", ".", "closed", "(", ")", ")", ":", "sel...
https://github.com/saltstack/salt/blob/fae5bc757ad0f1716483ce7ae180b451545c2058/salt/ext/tornado/http1connection.py#L442-L469
Source-Python-Dev-Team/Source.Python
d0ffd8ccbd1e9923c9bc44936f20613c1c76b7fb
addons/source-python/Python3/pickletools.py
python
read_floatnl
(f)
return float(s)
r""" >>> import io >>> read_floatnl(io.BytesIO(b"-1.25\n6")) -1.25
r""" >>> import io >>> read_floatnl(io.BytesIO(b"-1.25\n6")) -1.25
[ "r", ">>>", "import", "io", ">>>", "read_floatnl", "(", "io", ".", "BytesIO", "(", "b", "-", "1", ".", "25", "\\", "n6", "))", "-", "1", ".", "25" ]
def read_floatnl(f): r""" >>> import io >>> read_floatnl(io.BytesIO(b"-1.25\n6")) -1.25 """ s = read_stringnl(f, decode=False, stripquotes=False) return float(s)
[ "def", "read_floatnl", "(", "f", ")", ":", "s", "=", "read_stringnl", "(", "f", ",", "decode", "=", "False", ",", "stripquotes", "=", "False", ")", "return", "float", "(", "s", ")" ]
https://github.com/Source-Python-Dev-Team/Source.Python/blob/d0ffd8ccbd1e9923c9bc44936f20613c1c76b7fb/addons/source-python/Python3/pickletools.py#L807-L814
huggingface/transformers
623b4f7c63f60cce917677ee704d6c93ee960b4b
src/transformers/models/tapas/tokenization_tapas.py
python
TapasTokenizer._get_table_values
(self, table, num_columns, num_rows, num_tokens)
Iterates over partial table and returns token, column and row indexes.
Iterates over partial table and returns token, column and row indexes.
[ "Iterates", "over", "partial", "table", "and", "returns", "token", "column", "and", "row", "indexes", "." ]
def _get_table_values(self, table, num_columns, num_rows, num_tokens) -> Generator[TableValue, None, None]: """Iterates over partial table and returns token, column and row indexes.""" for tc in table.selected_tokens: # First row is header row. if tc.row_index >= num_rows + 1: continue if tc.column_index >= num_columns: continue cell = table.rows[tc.row_index][tc.column_index] token = cell[tc.token_index] word_begin_index = tc.token_index # Don't add partial words. Find the starting word piece and check if it # fits in the token budget. while word_begin_index >= 0 and _is_inner_wordpiece(cell[word_begin_index]): word_begin_index -= 1 if word_begin_index >= num_tokens: continue yield TableValue(token, tc.column_index + 1, tc.row_index)
[ "def", "_get_table_values", "(", "self", ",", "table", ",", "num_columns", ",", "num_rows", ",", "num_tokens", ")", "->", "Generator", "[", "TableValue", ",", "None", ",", "None", "]", ":", "for", "tc", "in", "table", ".", "selected_tokens", ":", "# First ...
https://github.com/huggingface/transformers/blob/623b4f7c63f60cce917677ee704d6c93ee960b4b/src/transformers/models/tapas/tokenization_tapas.py#L1378-L1395
splunk/splunk-ansible
dea9c71ffb58db113a6841e508595b89a7c57151
inventory/environ.py
python
parseUrl
(url, vars_scope)
return "{}://{}:{}".format(scheme, hostname, port)
Parses role URL to handle non-default schemes, ports, etc.
Parses role URL to handle non-default schemes, ports, etc.
[ "Parses", "role", "URL", "to", "handle", "non", "-", "default", "schemes", "ports", "etc", "." ]
def parseUrl(url, vars_scope): """ Parses role URL to handle non-default schemes, ports, etc. """ if not url: return "" scheme = vars_scope.get("cert_prefix", "https") port = vars_scope["splunk"].get("svc_port", 8089) parsed = urlparse(url) # If netloc exists, we should consider the url provided well-formatted w/ scheme provided if parsed.netloc: # Strip auth info, if it exists netloc = parsed.netloc.split("@", 1)[-1] if ":" not in netloc: return "{}://{}:{}".format(parsed.scheme, netloc, port) return "{}://{}".format(parsed.scheme, netloc) # Strip auth info, if it exists parsed = url.split("@", 1)[-1] # Strip path, if it exists parsed = parsed.split("/", 1)[0] # Extract hostname and port parsed = parsed.split(":", 1) hostname = parsed[0] if len(parsed) == 2: port = parsed[1] return "{}://{}:{}".format(scheme, hostname, port)
[ "def", "parseUrl", "(", "url", ",", "vars_scope", ")", ":", "if", "not", "url", ":", "return", "\"\"", "scheme", "=", "vars_scope", ".", "get", "(", "\"cert_prefix\"", ",", "\"https\"", ")", "port", "=", "vars_scope", "[", "\"splunk\"", "]", ".", "get", ...
https://github.com/splunk/splunk-ansible/blob/dea9c71ffb58db113a6841e508595b89a7c57151/inventory/environ.py#L619-L644
johnzero7/XNALaraMesh
8d01dadec08ccda9558c3faf292fc214dfcd8102
import_obj.py
python
create_nurbs
(context_nurbs, vert_loc, new_objects)
Add nurbs object to blender, only support one type at the moment
Add nurbs object to blender, only support one type at the moment
[ "Add", "nurbs", "object", "to", "blender", "only", "support", "one", "type", "at", "the", "moment" ]
def create_nurbs(context_nurbs, vert_loc, new_objects): """ Add nurbs object to blender, only support one type at the moment """ deg = context_nurbs.get(b'deg', (3,)) curv_range = context_nurbs.get(b'curv_range') curv_idx = context_nurbs.get(b'curv_idx', []) parm_u = context_nurbs.get(b'parm_u', []) parm_v = context_nurbs.get(b'parm_v', []) name = context_nurbs.get(b'name', b'ObjNurb') cstype = context_nurbs.get(b'cstype') if cstype is None: print('\tWarning, cstype not found') return if cstype != b'bspline': print('\tWarning, cstype is not supported (only bspline)') return if not curv_idx: print('\tWarning, curv argument empty or not set') return if len(deg) > 1 or parm_v: print('\tWarning, surfaces not supported') return cu = bpy.data.curves.new(name.decode('utf-8', "replace"), 'CURVE') cu.dimensions = '3D' nu = cu.splines.new('NURBS') nu.points.add(len(curv_idx) - 1) # a point is added to start with nu.points.foreach_set("co", [co_axis for vt_idx in curv_idx for co_axis in (vert_loc[vt_idx] + (1.0,))]) nu.order_u = deg[0] + 1 # get for endpoint flag from the weighting if curv_range and len(parm_u) > deg[0] + 1: do_endpoints = True for i in range(deg[0] + 1): if abs(parm_u[i] - curv_range[0]) > 0.0001: do_endpoints = False break if abs(parm_u[-(i + 1)] - curv_range[1]) > 0.0001: do_endpoints = False break else: do_endpoints = False if do_endpoints: nu.use_endpoint_u = True # close ''' do_closed = False if len(parm_u) > deg[0]+1: for i in xrange(deg[0]+1): # print curv_idx[i], curv_idx[-(i+1)] if curv_idx[i]==curv_idx[-(i+1)]: do_closed = True break if do_closed: nu.use_cyclic_u = True ''' ob = bpy.data.objects.new(name.decode('utf-8', "replace"), cu) new_objects.append(ob)
[ "def", "create_nurbs", "(", "context_nurbs", ",", "vert_loc", ",", "new_objects", ")", ":", "deg", "=", "context_nurbs", ".", "get", "(", "b'deg'", ",", "(", "3", ",", ")", ")", "curv_range", "=", "context_nurbs", ".", "get", "(", "b'curv_range'", ")", "...
https://github.com/johnzero7/XNALaraMesh/blob/8d01dadec08ccda9558c3faf292fc214dfcd8102/import_obj.py#L956-L1026
pwnieexpress/pwn_plug_sources
1a23324f5dc2c3de20f9c810269b6a29b2758cad
src/fimap/xgoogle/BeautifulSoup.py
python
PageElement.previousGenerator
(self)
[]
def previousGenerator(self): i = self while i: i = i.previous yield i
[ "def", "previousGenerator", "(", "self", ")", ":", "i", "=", "self", "while", "i", ":", "i", "=", "i", ".", "previous", "yield", "i" ]
https://github.com/pwnieexpress/pwn_plug_sources/blob/1a23324f5dc2c3de20f9c810269b6a29b2758cad/src/fimap/xgoogle/BeautifulSoup.py#L351-L355
minio/minio-py
b3ba3bf99fe6b9ff2b28855550d6ab5345c134e3
minio/xml.py
python
findtext
(element, name, strict=False)
return element.text or ""
Namespace aware ElementTree.Element.findtext() with strict flag raises ValueError if element name not exist.
Namespace aware ElementTree.Element.findtext() with strict flag raises ValueError if element name not exist.
[ "Namespace", "aware", "ElementTree", ".", "Element", ".", "findtext", "()", "with", "strict", "flag", "raises", "ValueError", "if", "element", "name", "not", "exist", "." ]
def findtext(element, name, strict=False): """ Namespace aware ElementTree.Element.findtext() with strict flag raises ValueError if element name not exist. """ element = find(element, name) if element is None: if strict: raise ValueError(f"XML element <{name}> not found") return None return element.text or ""
[ "def", "findtext", "(", "element", ",", "name", ",", "strict", "=", "False", ")", ":", "element", "=", "find", "(", "element", ",", "name", ")", "if", "element", "is", "None", ":", "if", "strict", ":", "raise", "ValueError", "(", "f\"XML element <{name}>...
https://github.com/minio/minio-py/blob/b3ba3bf99fe6b9ff2b28855550d6ab5345c134e3/minio/xml.py#L70-L80
csababarta/ntdsxtract
7fa1c8c28cbbf97a42bef40f20009dba85e4c25f
framework/addrspace.py
python
HiveFileAddressSpace.is_valid_address
(self, vaddr)
return self.base.is_valid_address(paddr)
[]
def is_valid_address(self, vaddr): paddr = self.vtop(vaddr) if not paddr: return False return self.base.is_valid_address(paddr)
[ "def", "is_valid_address", "(", "self", ",", "vaddr", ")", ":", "paddr", "=", "self", ".", "vtop", "(", "vaddr", ")", "if", "not", "paddr", ":", "return", "False", "return", "self", ".", "base", ".", "is_valid_address", "(", "paddr", ")" ]
https://github.com/csababarta/ntdsxtract/blob/7fa1c8c28cbbf97a42bef40f20009dba85e4c25f/framework/addrspace.py#L138-L141
securesystemslab/zippy
ff0e84ac99442c2c55fe1d285332cfd4e185e089
zippy/benchmarks/src/benchmarks/sympy/sympy/combinatorics/permutations.py
python
Permutation.transpositions
(self)
return res
Return the permutation decomposed into a list of transpositions. It is always possible to express a permutation as the product of transpositions, see [1] Examples ======== >>> from sympy.combinatorics.permutations import Permutation >>> p = Permutation([[1, 2, 3], [0, 4, 5, 6, 7]]) >>> t = p.transpositions() >>> t [(0, 7), (0, 6), (0, 5), (0, 4), (1, 3), (1, 2)] >>> print(''.join(str(c) for c in t)) (0, 7)(0, 6)(0, 5)(0, 4)(1, 3)(1, 2) >>> Permutation.rmul(*[Permutation([ti], size=p.size) for ti in t]) == p True References ========== 1. http://en.wikipedia.org/wiki/Transposition_%28mathematics%29#Properties
Return the permutation decomposed into a list of transpositions.
[ "Return", "the", "permutation", "decomposed", "into", "a", "list", "of", "transpositions", "." ]
def transpositions(self): """ Return the permutation decomposed into a list of transpositions. It is always possible to express a permutation as the product of transpositions, see [1] Examples ======== >>> from sympy.combinatorics.permutations import Permutation >>> p = Permutation([[1, 2, 3], [0, 4, 5, 6, 7]]) >>> t = p.transpositions() >>> t [(0, 7), (0, 6), (0, 5), (0, 4), (1, 3), (1, 2)] >>> print(''.join(str(c) for c in t)) (0, 7)(0, 6)(0, 5)(0, 4)(1, 3)(1, 2) >>> Permutation.rmul(*[Permutation([ti], size=p.size) for ti in t]) == p True References ========== 1. http://en.wikipedia.org/wiki/Transposition_%28mathematics%29#Properties """ a = self.cyclic_form res = [] for x in a: nx = len(x) if nx == 2: res.append(tuple(x)) elif nx > 2: first = x[0] for y in x[nx - 1:0:-1]: res.append((first, y)) return res
[ "def", "transpositions", "(", "self", ")", ":", "a", "=", "self", ".", "cyclic_form", "res", "=", "[", "]", "for", "x", "in", "a", ":", "nx", "=", "len", "(", "x", ")", "if", "nx", "==", "2", ":", "res", ".", "append", "(", "tuple", "(", "x",...
https://github.com/securesystemslab/zippy/blob/ff0e84ac99442c2c55fe1d285332cfd4e185e089/zippy/benchmarks/src/benchmarks/sympy/sympy/combinatorics/permutations.py#L1392-L1428
cisco/mindmeld
809c36112e9ea8019fe29d54d136ca14eb4fd8db
mindmeld/models/helpers.py
python
ingest_dynamic_gazetteer
(resource, dynamic_resource=None, text_preparation_pipeline=None)
return workspace_resource
Ingests dynamic gazetteers from the app and adds them to the resource Args: resource (dict): The original resource dynamic_resource (dict, optional): The dynamic resource that needs to be ingested text_preparation_pipeline (TextPreparationPipeline): For text tokenization and normalization Returns: (dict): A new resource with the ingested dynamic resource
Ingests dynamic gazetteers from the app and adds them to the resource
[ "Ingests", "dynamic", "gazetteers", "from", "the", "app", "and", "adds", "them", "to", "the", "resource" ]
def ingest_dynamic_gazetteer(resource, dynamic_resource=None, text_preparation_pipeline=None): """Ingests dynamic gazetteers from the app and adds them to the resource Args: resource (dict): The original resource dynamic_resource (dict, optional): The dynamic resource that needs to be ingested text_preparation_pipeline (TextPreparationPipeline): For text tokenization and normalization Returns: (dict): A new resource with the ingested dynamic resource """ if not dynamic_resource or GAZETTEER_RSC not in dynamic_resource: return resource text_preparation_pipeline = ( text_preparation_pipeline or TextPreparationPipelineFactory.create_default_text_preparation_pipeline() ) workspace_resource = merge_gazetteer_resource( resource, dynamic_resource, text_preparation_pipeline ) return workspace_resource
[ "def", "ingest_dynamic_gazetteer", "(", "resource", ",", "dynamic_resource", "=", "None", ",", "text_preparation_pipeline", "=", "None", ")", ":", "if", "not", "dynamic_resource", "or", "GAZETTEER_RSC", "not", "in", "dynamic_resource", ":", "return", "resource", "te...
https://github.com/cisco/mindmeld/blob/809c36112e9ea8019fe29d54d136ca14eb4fd8db/mindmeld/models/helpers.py#L483-L503
AnalogJ/lexicon
c7bedfed6ed34c96950954933b07ca3ce081d0e5
lexicon/providers/zonomi.py
python
provider_parser
(subparser)
Configure provider parser for Zonomi
Configure provider parser for Zonomi
[ "Configure", "provider", "parser", "for", "Zonomi" ]
def provider_parser(subparser): """Configure provider parser for Zonomi""" subparser.add_argument("--auth-token", help="specify token for authentication") subparser.add_argument( "--auth-entrypoint", help="use Zonomi or Rimuhosting API", choices=["zonomi", "rimuhosting"], )
[ "def", "provider_parser", "(", "subparser", ")", ":", "subparser", ".", "add_argument", "(", "\"--auth-token\"", ",", "help", "=", "\"specify token for authentication\"", ")", "subparser", ".", "add_argument", "(", "\"--auth-entrypoint\"", ",", "help", "=", "\"use Zon...
https://github.com/AnalogJ/lexicon/blob/c7bedfed6ed34c96950954933b07ca3ce081d0e5/lexicon/providers/zonomi.py#L38-L45
AndroBugs/AndroBugs_Framework
7fd3a2cb1cf65a9af10b7ed2129701d4451493fe
tools/modified/androguard/core/bytecodes/dvm.py
python
Instruction31c.get_string
(self)
return get_kind(self.cm, self.get_kind(), self.BBBBBBBB)
Return the string associated to the 'kind' argument :rtype: string
Return the string associated to the 'kind' argument
[ "Return", "the", "string", "associated", "to", "the", "kind", "argument" ]
def get_string(self): """ Return the string associated to the 'kind' argument :rtype: string """ return get_kind(self.cm, self.get_kind(), self.BBBBBBBB)
[ "def", "get_string", "(", "self", ")", ":", "return", "get_kind", "(", "self", ".", "cm", ",", "self", ".", "get_kind", "(", ")", ",", "self", ".", "BBBBBBBB", ")" ]
https://github.com/AndroBugs/AndroBugs_Framework/blob/7fd3a2cb1cf65a9af10b7ed2129701d4451493fe/tools/modified/androguard/core/bytecodes/dvm.py#L4726-L4732
blampe/IbPy
cba912d2ecc669b0bf2980357ea7942e49c0825e
ib/ext/ScannerSubscription.py
python
ScannerSubscription.couponRateBelow_0
(self, r)
generated source for method couponRateBelow_0
generated source for method couponRateBelow_0
[ "generated", "source", "for", "method", "couponRateBelow_0" ]
def couponRateBelow_0(self, r): """ generated source for method couponRateBelow_0 """ self.m_couponRateBelow = r
[ "def", "couponRateBelow_0", "(", "self", ",", "r", ")", ":", "self", ".", "m_couponRateBelow", "=", "r" ]
https://github.com/blampe/IbPy/blob/cba912d2ecc669b0bf2980357ea7942e49c0825e/ib/ext/ScannerSubscription.py#L230-L232
ukBaz/python-bluezero
e6b4e96342de6c66571a6660d711c018f8c6b470
bluezero/microbit.py
python
Microbit.accelerometer
(self)
return tools.bytes_to_xyz(accel_bytes)
Read the values of the accelerometer on the microbit :return: return a list in the order of x, y & z
Read the values of the accelerometer on the microbit
[ "Read", "the", "values", "of", "the", "accelerometer", "on", "the", "microbit" ]
def accelerometer(self): """ Read the values of the accelerometer on the microbit :return: return a list in the order of x, y & z """ # [16, 0, 64, 0, 32, 252] # x=0.16, y=0.024, z=-0.992 accel_bytes = self._accel_data.value return tools.bytes_to_xyz(accel_bytes)
[ "def", "accelerometer", "(", "self", ")", ":", "# [16, 0, 64, 0, 32, 252]", "# x=0.16, y=0.024, z=-0.992", "accel_bytes", "=", "self", ".", "_accel_data", ".", "value", "return", "tools", ".", "bytes_to_xyz", "(", "accel_bytes", ")" ]
https://github.com/ukBaz/python-bluezero/blob/e6b4e96342de6c66571a6660d711c018f8c6b470/bluezero/microbit.py#L382-L392
lad1337/XDM
0c1b7009fe00f06f102a6f67c793478f515e7efe
site-packages/babel/plural.py
python
_unary_compiler
(tmpl)
return lambda self, x: tmpl % self.compile(x)
Compiler factory for the `_Compiler`.
Compiler factory for the `_Compiler`.
[ "Compiler", "factory", "for", "the", "_Compiler", "." ]
def _unary_compiler(tmpl): """Compiler factory for the `_Compiler`.""" return lambda self, x: tmpl % self.compile(x)
[ "def", "_unary_compiler", "(", "tmpl", ")", ":", "return", "lambda", "self", ",", "x", ":", "tmpl", "%", "self", ".", "compile", "(", "x", ")" ]
https://github.com/lad1337/XDM/blob/0c1b7009fe00f06f102a6f67c793478f515e7efe/site-packages/babel/plural.py#L389-L391
Fallen-Breath/MCDReforged
fdb1d2520b35f916123f265dbd94603981bb2b0c
mcdreforged/command/builder/nodes/arguments.py
python
TextNode.at_min_length
(self, min_length)
return self
[]
def at_min_length(self, min_length) -> 'TextNode': self.__min_length = min_length return self
[ "def", "at_min_length", "(", "self", ",", "min_length", ")", "->", "'TextNode'", ":", "self", ".", "__min_length", "=", "min_length", "return", "self" ]
https://github.com/Fallen-Breath/MCDReforged/blob/fdb1d2520b35f916123f265dbd94603981bb2b0c/mcdreforged/command/builder/nodes/arguments.py#L89-L91
HenriWahl/Nagstamon
16549c6860b51a93141d84881c6ad28c35d8581e
Nagstamon/Servers/Thruk.py
python
ThrukServer.open_monitor
(self, host, service='')
open monitor from tablewidget context menu
open monitor from tablewidget context menu
[ "open", "monitor", "from", "tablewidget", "context", "menu" ]
def open_monitor(self, host, service=''): ''' open monitor from tablewidget context menu ''' # only type is important so do not care of service '' in case of host monitor if service == '': url = self.monitor_cgi_url + '/extinfo.cgi?type=1&' + urllib.parse.urlencode( { 'host': host }) else: url = self.monitor_cgi_url + '/extinfo.cgi?type=2&' + urllib.parse.urlencode( { 'host': host, 'service': self.hosts[host].services[ service ].real_name }) if conf.debug_mode: self.Debug(server=self.get_name(), host=host, service=service, debug='Open host/service monitor web page {0}'.format(url)) webbrowser_open(url)
[ "def", "open_monitor", "(", "self", ",", "host", ",", "service", "=", "''", ")", ":", "# only type is important so do not care of service '' in case of host monitor", "if", "service", "==", "''", ":", "url", "=", "self", ".", "monitor_cgi_url", "+", "'/extinfo.cgi?typ...
https://github.com/HenriWahl/Nagstamon/blob/16549c6860b51a93141d84881c6ad28c35d8581e/Nagstamon/Servers/Thruk.py#L139-L152
andresriancho/w3af
cd22e5252243a87aaa6d0ddea47cf58dacfe00a9
w3af/core/controllers/core_helpers/status.py
python
CoreStatus.get_grep_output_speed
(self)
return 0 if gc is None else gc.in_queue.get_output_rpm()
[]
def get_grep_output_speed(self): gc = self._w3af_core.strategy.get_grep_consumer() return 0 if gc is None else gc.in_queue.get_output_rpm()
[ "def", "get_grep_output_speed", "(", "self", ")", ":", "gc", "=", "self", ".", "_w3af_core", ".", "strategy", ".", "get_grep_consumer", "(", ")", "return", "0", "if", "gc", "is", "None", "else", "gc", ".", "in_queue", ".", "get_output_rpm", "(", ")" ]
https://github.com/andresriancho/w3af/blob/cd22e5252243a87aaa6d0ddea47cf58dacfe00a9/w3af/core/controllers/core_helpers/status.py#L289-L291
uclatommy/tweetfeels
6ad8ebf64cef73c0b932614b7780e6c67902333f
tweetfeels/tweetlistener.py
python
TweetListener.reconnect_wait
(self, pattern)
Calculates an appropriate waiting time prior to attempting reconnect. :param pattern: The type of reconnect waiting pattern dependent on type of error or disconnect.
Calculates an appropriate waiting time prior to attempting reconnect.
[ "Calculates", "an", "appropriate", "waiting", "time", "prior", "to", "attempting", "reconnect", "." ]
def reconnect_wait(self, pattern): """ Calculates an appropriate waiting time prior to attempting reconnect. :param pattern: The type of reconnect waiting pattern dependent on type of error or disconnect. """ if pattern == 'linear': time.sleep(self._waited) self._waited += 1 elif pattern == 'exponential': time.sleep(self._waited) self._waited *= 2
[ "def", "reconnect_wait", "(", "self", ",", "pattern", ")", ":", "if", "pattern", "==", "'linear'", ":", "time", ".", "sleep", "(", "self", ".", "_waited", ")", "self", ".", "_waited", "+=", "1", "elif", "pattern", "==", "'exponential'", ":", "time", "....
https://github.com/uclatommy/tweetfeels/blob/6ad8ebf64cef73c0b932614b7780e6c67902333f/tweetfeels/tweetlistener.py#L129-L141
numenta/numenta-apps
02903b0062c89c2c259b533eea2df6e8bb44eaf3
nta.utils/nta/utils/amqp/synchronous_amqp_client.py
python
SynchronousAmqpClient._makeConsumerMessage
(cls, haighaMessage, ackImpl, nackImpl)
return amqp_messages.ConsumerMessage( body=cls._decodeMessageBody(haighaMessage.body), properties=cls._makeBasicProperties(haighaMessage.properties), methodInfo=methodInfo, ackImpl=ackImpl, nackImpl=nackImpl)
Make ConsumerMessage from haigha message received via Basic.Deliver :param haigha.message.Message haighaMessage: haigha message received via Basic.Deliver :param ackImpl: callable for acking the message that has the following signature: ackImpl(deliveryTag, multiple=False); or None :param nackImpl: callable for nacking the message that has the following signature: nackImpl(deliveryTag, requeue); or None :rtype: ConsumerMessage
Make ConsumerMessage from haigha message received via Basic.Deliver
[ "Make", "ConsumerMessage", "from", "haigha", "message", "received", "via", "Basic", ".", "Deliver" ]
def _makeConsumerMessage(cls, haighaMessage, ackImpl, nackImpl): """Make ConsumerMessage from haigha message received via Basic.Deliver :param haigha.message.Message haighaMessage: haigha message received via Basic.Deliver :param ackImpl: callable for acking the message that has the following signature: ackImpl(deliveryTag, multiple=False); or None :param nackImpl: callable for nacking the message that has the following signature: nackImpl(deliveryTag, requeue); or None :rtype: ConsumerMessage """ info = haighaMessage.delivery_info methodInfo = amqp_messages.MessageDeliveryInfo( consumerTag=info["consumer_tag"], deliveryTag=info["delivery_tag"], redelivered=bool(info["redelivered"]), exchange=info["exchange"], routingKey=info["routing_key"] ) return amqp_messages.ConsumerMessage( body=cls._decodeMessageBody(haighaMessage.body), properties=cls._makeBasicProperties(haighaMessage.properties), methodInfo=methodInfo, ackImpl=ackImpl, nackImpl=nackImpl)
[ "def", "_makeConsumerMessage", "(", "cls", ",", "haighaMessage", ",", "ackImpl", ",", "nackImpl", ")", ":", "info", "=", "haighaMessage", ".", "delivery_info", "methodInfo", "=", "amqp_messages", ".", "MessageDeliveryInfo", "(", "consumerTag", "=", "info", "[", ...
https://github.com/numenta/numenta-apps/blob/02903b0062c89c2c259b533eea2df6e8bb44eaf3/nta.utils/nta/utils/amqp/synchronous_amqp_client.py#L1006-L1033
securesystemslab/zippy
ff0e84ac99442c2c55fe1d285332cfd4e185e089
zippy/benchmarks/src/benchmarks/python-chess-0.1.0/chess/__init__.py
python
Bitboard.piece_at
(self, square)
Gets the piece at the given square.
Gets the piece at the given square.
[ "Gets", "the", "piece", "at", "the", "given", "square", "." ]
def piece_at(self, square): """Gets the piece at the given square.""" mask = BB_SQUARES[square] color = int(bool(self.occupied_co[BLACK] & mask)) if mask & self.pawns: return Piece(PAWN, color) elif mask & self.knights: return Piece(KNIGHT, color) elif mask & self.bishops: return Piece(BISHOP, color) elif mask & self.rooks: return Piece(ROOK, color) elif mask & self.queens: return Piece(QUEEN, color) elif mask & self.kings: return Piece(KING, color)
[ "def", "piece_at", "(", "self", ",", "square", ")", ":", "mask", "=", "BB_SQUARES", "[", "square", "]", "color", "=", "int", "(", "bool", "(", "self", ".", "occupied_co", "[", "BLACK", "]", "&", "mask", ")", ")", "if", "mask", "&", "self", ".", "...
https://github.com/securesystemslab/zippy/blob/ff0e84ac99442c2c55fe1d285332cfd4e185e089/zippy/benchmarks/src/benchmarks/python-chess-0.1.0/chess/__init__.py#L941-L957
holzschu/Carnets
44effb10ddfc6aa5c8b0687582a724ba82c6b547
Library/lib/python3.7/site-packages/ipython_genutils/path.py
python
filefind
(filename, path_dirs=None)
Find a file by looking through a sequence of paths. This iterates through a sequence of paths looking for a file and returns the full, absolute path of the first occurence of the file. If no set of path dirs is given, the filename is tested as is, after running through :func:`expandvars` and :func:`expanduser`. Thus a simple call:: filefind('myfile.txt') will find the file in the current working dir, but:: filefind('~/myfile.txt') Will find the file in the users home directory. This function does not automatically try any paths, such as the cwd or the user's home directory. Parameters ---------- filename : str The filename to look for. path_dirs : str, None or sequence of str The sequence of paths to look for the file in. If None, the filename need to be absolute or be in the cwd. If a string, the string is put into a sequence and the searched. If a sequence, walk through each element and join with ``filename``, calling :func:`expandvars` and :func:`expanduser` before testing for existence. Returns ------- Raises :exc:`IOError` or returns absolute path to file.
Find a file by looking through a sequence of paths.
[ "Find", "a", "file", "by", "looking", "through", "a", "sequence", "of", "paths", "." ]
def filefind(filename, path_dirs=None): """Find a file by looking through a sequence of paths. This iterates through a sequence of paths looking for a file and returns the full, absolute path of the first occurence of the file. If no set of path dirs is given, the filename is tested as is, after running through :func:`expandvars` and :func:`expanduser`. Thus a simple call:: filefind('myfile.txt') will find the file in the current working dir, but:: filefind('~/myfile.txt') Will find the file in the users home directory. This function does not automatically try any paths, such as the cwd or the user's home directory. Parameters ---------- filename : str The filename to look for. path_dirs : str, None or sequence of str The sequence of paths to look for the file in. If None, the filename need to be absolute or be in the cwd. If a string, the string is put into a sequence and the searched. If a sequence, walk through each element and join with ``filename``, calling :func:`expandvars` and :func:`expanduser` before testing for existence. Returns ------- Raises :exc:`IOError` or returns absolute path to file. """ # If paths are quoted, abspath gets confused, strip them... filename = filename.strip('"').strip("'") # If the input is an absolute path, just check it exists if os.path.isabs(filename) and os.path.isfile(filename): return filename if path_dirs is None: path_dirs = ("",) elif isinstance(path_dirs, py3compat.string_types): path_dirs = (path_dirs,) for path in path_dirs: if path == '.': path = py3compat.getcwd() testname = expand_path(os.path.join(path, filename)) if os.path.isfile(testname): return os.path.abspath(testname) raise IOError("File %r does not exist in any of the search paths: %r" % (filename, path_dirs) )
[ "def", "filefind", "(", "filename", ",", "path_dirs", "=", "None", ")", ":", "# If paths are quoted, abspath gets confused, strip them...", "filename", "=", "filename", ".", "strip", "(", "'\"'", ")", ".", "strip", "(", "\"'\"", ")", "# If the input is an absolute pat...
https://github.com/holzschu/Carnets/blob/44effb10ddfc6aa5c8b0687582a724ba82c6b547/Library/lib/python3.7/site-packages/ipython_genutils/path.py#L21-L72
paulwinex/pw_MultiScriptEditor
e447e99f87cb07e238baf693b7e124e50efdbc51
multi_script_editor/managers/nuke/main.py
python
value
(knob, default)
return ''
value(knob, default) -> string. The value function returns the current value of a knob. The knob argument is a string referring to a knob and default is an optional default value to be returned in case of an error. Unlike knob(), this will evaluate animation at the current frame, and expand brackets and dollar signs in string knobs.
value(knob, default) -> string.
[ "value", "(", "knob", "default", ")", "-", ">", "string", "." ]
def value(knob, default): """value(knob, default) -> string. The value function returns the current value of a knob. The knob argument is a string referring to a knob and default is an optional default value to be returned in case of an error. Unlike knob(), this will evaluate animation at the current frame, and expand brackets and dollar signs in string knobs.""" return ''
[ "def", "value", "(", "knob", ",", "default", ")", ":", "return", "''" ]
https://github.com/paulwinex/pw_MultiScriptEditor/blob/e447e99f87cb07e238baf693b7e124e50efdbc51/multi_script_editor/managers/nuke/main.py#L6319-L6323
Map-A-Droid/MAD
81375b5c9ccc5ca3161eb487aa81469d40ded221
mapadroid/worker/WorkerBase.py
python
WorkerBase._wait_pogo_start_delay
(self)
[]
def _wait_pogo_start_delay(self): delay_count: int = 0 pogo_start_delay: int = self.get_devicesettings_value("post_pogo_start_delay", 60) self.logger.info('Waiting for pogo start: {} seconds', pogo_start_delay) while delay_count <= pogo_start_delay: if not self._mapping_manager.routemanager_present(self._routemanager_name) \ or self._stop_worker_event.is_set(): self.logger.error("Killed while waiting for pogo start") raise InternalStopWorkerException time.sleep(1) delay_count += 1
[ "def", "_wait_pogo_start_delay", "(", "self", ")", ":", "delay_count", ":", "int", "=", "0", "pogo_start_delay", ":", "int", "=", "self", ".", "get_devicesettings_value", "(", "\"post_pogo_start_delay\"", ",", "60", ")", "self", ".", "logger", ".", "info", "("...
https://github.com/Map-A-Droid/MAD/blob/81375b5c9ccc5ca3161eb487aa81469d40ded221/mapadroid/worker/WorkerBase.py#L955-L966
rowliny/DiffHelper
ab3a96f58f9579d0023aed9ebd785f4edf26f8af
Tool/SitePackages/pycodestyle.py
python
Checker.check_logical
(self)
Build a line from tokens and run all logical checks on it.
Build a line from tokens and run all logical checks on it.
[ "Build", "a", "line", "from", "tokens", "and", "run", "all", "logical", "checks", "on", "it", "." ]
def check_logical(self): """Build a line from tokens and run all logical checks on it.""" self.report.increment_logical_line() mapping = self.build_tokens_line() if not mapping: return mapping_offsets = [offset for offset, _ in mapping] (start_row, start_col) = mapping[0][1] start_line = self.lines[start_row - 1] self.indent_level = expand_indent(start_line[:start_col]) if self.blank_before < self.blank_lines: self.blank_before = self.blank_lines if self.verbose >= 2: print(self.logical_line[:80].rstrip()) for name, check, argument_names in self._logical_checks: if self.verbose >= 4: print(' ' + name) self.init_checker_state(name, argument_names) for offset, text in self.run_check(check, argument_names) or (): if not isinstance(offset, tuple): # As mappings are ordered, bisecting is a fast way # to find a given offset in them. token_offset, pos = mapping[bisect.bisect_left( mapping_offsets, offset)] offset = (pos[0], pos[1] + offset - token_offset) self.report_error(offset[0], offset[1], text, check) if self.logical_line: self.previous_indent_level = self.indent_level self.previous_logical = self.logical_line if not self.indent_level: self.previous_unindented_logical_line = self.logical_line self.blank_lines = 0 self.tokens = []
[ "def", "check_logical", "(", "self", ")", ":", "self", ".", "report", ".", "increment_logical_line", "(", ")", "mapping", "=", "self", ".", "build_tokens_line", "(", ")", "if", "not", "mapping", ":", "return", "mapping_offsets", "=", "[", "offset", "for", ...
https://github.com/rowliny/DiffHelper/blob/ab3a96f58f9579d0023aed9ebd785f4edf26f8af/Tool/SitePackages/pycodestyle.py#L2085-L2118
Jenyay/outwiker
50530cf7b3f71480bb075b2829bc0669773b835b
plugins/htmlheads/htmlheads/controller.py
python
Controller.destroy
(self)
Вызывается при отключении плагина
Вызывается при отключении плагина
[ "Вызывается", "при", "отключении", "плагина" ]
def destroy(self): """ Вызывается при отключении плагина """ self._application.onWikiParserPrepare -= self.__onWikiParserPrepare self._destroy_guicontroller()
[ "def", "destroy", "(", "self", ")", ":", "self", ".", "_application", ".", "onWikiParserPrepare", "-=", "self", ".", "__onWikiParserPrepare", "self", ".", "_destroy_guicontroller", "(", ")" ]
https://github.com/Jenyay/outwiker/blob/50530cf7b3f71480bb075b2829bc0669773b835b/plugins/htmlheads/htmlheads/controller.py#L79-L84
F8LEFT/DecLLVM
d38e45e3d0dd35634adae1d0cf7f96f3bd96e74c
python/idaapi.py
python
argloc_t._set_biggest
(self, *args)
return _idaapi.argloc_t__set_biggest(self, *args)
_set_biggest(self, ct, data)
_set_biggest(self, ct, data)
[ "_set_biggest", "(", "self", "ct", "data", ")" ]
def _set_biggest(self, *args): """ _set_biggest(self, ct, data) """ return _idaapi.argloc_t__set_biggest(self, *args)
[ "def", "_set_biggest", "(", "self", ",", "*", "args", ")", ":", "return", "_idaapi", ".", "argloc_t__set_biggest", "(", "self", ",", "*", "args", ")" ]
https://github.com/F8LEFT/DecLLVM/blob/d38e45e3d0dd35634adae1d0cf7f96f3bd96e74c/python/idaapi.py#L29086-L29090
taowen/es-monitor
c4deceb4964857f495d13bfaf2d92f36734c9e1c
es_sql/sqlparse/sql_select.py
python
get_indices
(index_pattern, from_datetime=None, to_datetime=None)
[]
def get_indices(index_pattern, from_datetime=None, to_datetime=None): if from_datetime: prefix, delimiter, datetime_pattern = index_pattern.partition('%') if not delimiter: raise Exception('missing datetime pattern in %s' % index_pattern) datetime_pattern = '%' + datetime_pattern if to_datetime: from_datetime = try_strptime(from_datetime, datetime_pattern) to_datetime = try_strptime(to_datetime, datetime_pattern) step = None if '%S' in datetime_pattern: step = datetime.timedelta(seconds=1) elif '%M' in datetime_pattern: step = datetime.timedelta(minutes=1) elif '%H' in datetime_pattern: step = datetime.timedelta(hours=1) elif '%d' in datetime_pattern: step = datetime.timedelta(days=1) else: raise Exception('can not guess the step') the_datetime = from_datetime indices = [] while the_datetime <= to_datetime: indices.append(the_datetime.strftime(index_pattern)) the_datetime += step return indices else: the_datetime = try_strptime(from_datetime, datetime_pattern) return [the_datetime.strftime(index_pattern)] else: return [index_pattern]
[ "def", "get_indices", "(", "index_pattern", ",", "from_datetime", "=", "None", ",", "to_datetime", "=", "None", ")", ":", "if", "from_datetime", ":", "prefix", ",", "delimiter", ",", "datetime_pattern", "=", "index_pattern", ".", "partition", "(", "'%'", ")", ...
https://github.com/taowen/es-monitor/blob/c4deceb4964857f495d13bfaf2d92f36734c9e1c/es_sql/sqlparse/sql_select.py#L289-L319
sunnyxiaohu/R-C3D.pytorch
e8731af7b95f1dc934f6604f9c09e3c4ead74db5
lib/tf_model_zoo/inceptionresnetv2/pytorch_load.py
python
inceptionresnetv2
(pretrained=True)
return model
r"""InceptionResnetV2 model architecture from the `"InceptionV4, Inception-ResNet..." <https://arxiv.org/abs/1602.07261>`_ paper. Args: pretrained ('string'): If True, returns a model pre-trained on ImageNet
r"""InceptionResnetV2 model architecture from the `"InceptionV4, Inception-ResNet..." <https://arxiv.org/abs/1602.07261>`_ paper.
[ "r", "InceptionResnetV2", "model", "architecture", "from", "the", "InceptionV4", "Inception", "-", "ResNet", "...", "<https", ":", "//", "arxiv", ".", "org", "/", "abs", "/", "1602", ".", "07261", ">", "_", "paper", "." ]
def inceptionresnetv2(pretrained=True): r"""InceptionResnetV2 model architecture from the `"InceptionV4, Inception-ResNet..." <https://arxiv.org/abs/1602.07261>`_ paper. Args: pretrained ('string'): If True, returns a model pre-trained on ImageNet """ model = InceptionResnetV2() if pretrained: model.load_state_dict(model_zoo.load_url(model_urls['imagenet'])) return model
[ "def", "inceptionresnetv2", "(", "pretrained", "=", "True", ")", ":", "model", "=", "InceptionResnetV2", "(", ")", "if", "pretrained", ":", "model", ".", "load_state_dict", "(", "model_zoo", ".", "load_url", "(", "model_urls", "[", "'imagenet'", "]", ")", ")...
https://github.com/sunnyxiaohu/R-C3D.pytorch/blob/e8731af7b95f1dc934f6604f9c09e3c4ead74db5/lib/tf_model_zoo/inceptionresnetv2/pytorch_load.py#L285-L295
google-research/language
61fa7260ac7d690d11ef72ca863e45a37c0bdc80
language/xsp/model/common_layers.py
python
ff_layer
(x, hidden_size, output_size, nonlinearity=tf.nn.relu)
return x
Single hidden-layer feed-forward network. Args: x: <float>[batch_size, length, input_size] hidden_size: Integer number of dimensions for hidden layer. output_size: Integer number of dimensions for output. nonlinearity: Function to use for non-linearity. Returns: <float>[batch_size, length, output_size]
Single hidden-layer feed-forward network.
[ "Single", "hidden", "-", "layer", "feed", "-", "forward", "network", "." ]
def ff_layer(x, hidden_size, output_size, nonlinearity=tf.nn.relu): """Single hidden-layer feed-forward network. Args: x: <float>[batch_size, length, input_size] hidden_size: Integer number of dimensions for hidden layer. output_size: Integer number of dimensions for output. nonlinearity: Function to use for non-linearity. Returns: <float>[batch_size, length, output_size] """ x = linear_transform(x, hidden_size, "ffn_1", bias=True) x = nonlinearity(x) x = linear_transform(x, output_size, "ffn_2", bias=True) return x
[ "def", "ff_layer", "(", "x", ",", "hidden_size", ",", "output_size", ",", "nonlinearity", "=", "tf", ".", "nn", ".", "relu", ")", ":", "x", "=", "linear_transform", "(", "x", ",", "hidden_size", ",", "\"ffn_1\"", ",", "bias", "=", "True", ")", "x", "...
https://github.com/google-research/language/blob/61fa7260ac7d690d11ef72ca863e45a37c0bdc80/language/xsp/model/common_layers.py#L384-L399
mgear-dev/mgear
06ddc26c5adb5eab07ca470c7fafa77404c8a1de
scripts/mgear/maya/shifter/component/eye_01/__init__.py
python
Component.addOperators
(self)
Create operators and set the relations for the component rig Apply operators, constraints, expressions to the hierarchy. In order to keep the code clean and easier to debug, we shouldn't create any new object in this method.
Create operators and set the relations for the component rig
[ "Create", "operators", "and", "set", "the", "relations", "for", "the", "component", "rig" ]
def addOperators(self): """Create operators and set the relations for the component rig Apply operators, constraints, expressions to the hierarchy. In order to keep the code clean and easier to debug, we shouldn't create any new object in this method. """ upvDir = self.settings["upVectorDirection"] if upvDir == 0: upvVec = [1, 0, 0] elif upvDir == 1: upvVec = [0, 1, 0] else: upvVec = [0, 0, 1] applyop.aimCns( self.eye_npo, self.eyeIK_ctl, "zy", 2, upvVec, self.root, False) pm.scaleConstraint( self.eyeOver_ctl, self.eye_npo, maintainOffset=False) pm.pointConstraint( self.eyeOver_ctl, self.eye_npo, maintainOffset=False)
[ "def", "addOperators", "(", "self", ")", ":", "upvDir", "=", "self", ".", "settings", "[", "\"upVectorDirection\"", "]", "if", "upvDir", "==", "0", ":", "upvVec", "=", "[", "1", ",", "0", ",", "0", "]", "elif", "upvDir", "==", "1", ":", "upvVec", "...
https://github.com/mgear-dev/mgear/blob/06ddc26c5adb5eab07ca470c7fafa77404c8a1de/scripts/mgear/maya/shifter/component/eye_01/__init__.py#L90-L113
linkedin/python-avro-json-serializer
445f5150e8f85ea5f9a063406686116a98ae802e
avro_json_serializer/__init__.py
python
AvroJsonBase._process_array
(self, schema, datum)
return list(map(process, datum))
Array is (de)serialized into array. Every element is processed recursively according to `items` schema. :param schema: Avro schema of `datum` :param datum: Data to serialize :return: serialized array (list)
Array is (de)serialized into array. Every element is processed recursively according to `items` schema. :param schema: Avro schema of `datum` :param datum: Data to serialize :return: serialized array (list)
[ "Array", "is", "(", "de", ")", "serialized", "into", "array", ".", "Every", "element", "is", "processed", "recursively", "according", "to", "items", "schema", ".", ":", "param", "schema", ":", "Avro", "schema", "of", "datum", ":", "param", "datum", ":", ...
def _process_array(self, schema, datum): """ Array is (de)serialized into array. Every element is processed recursively according to `items` schema. :param schema: Avro schema of `datum` :param datum: Data to serialize :return: serialized array (list) """ if datum is None: raise AvroTypeException(schema, datum) process = functools.partial(self._process_data, schema.items) return list(map(process, datum))
[ "def", "_process_array", "(", "self", ",", "schema", ",", "datum", ")", ":", "if", "datum", "is", "None", ":", "raise", "AvroTypeException", "(", "schema", ",", "datum", ")", "process", "=", "functools", ".", "partial", "(", "self", ".", "_process_data", ...
https://github.com/linkedin/python-avro-json-serializer/blob/445f5150e8f85ea5f9a063406686116a98ae802e/avro_json_serializer/__init__.py#L87-L98
gwpy/gwpy
82becd78d166a32985cb657a54d0d39f6a207739
gwpy/spectrogram/spectrogram.py
python
Spectrogram.from_spectra
(cls, *spectra, **kwargs)
return Spectrogram(data, **kwargs)
Build a new `Spectrogram` from a list of spectra. Parameters ---------- *spectra any number of `~gwpy.frequencyseries.FrequencySeries` series dt : `float`, `~astropy.units.Quantity`, optional stride between given spectra Returns ------- Spectrogram a new `Spectrogram` from a vertical stacking of the spectra The new object takes the metadata from the first given `~gwpy.frequencyseries.FrequencySeries` if not given explicitly Notes ----- Each `~gwpy.frequencyseries.FrequencySeries` passed to this constructor must be the same length.
Build a new `Spectrogram` from a list of spectra.
[ "Build", "a", "new", "Spectrogram", "from", "a", "list", "of", "spectra", "." ]
def from_spectra(cls, *spectra, **kwargs): """Build a new `Spectrogram` from a list of spectra. Parameters ---------- *spectra any number of `~gwpy.frequencyseries.FrequencySeries` series dt : `float`, `~astropy.units.Quantity`, optional stride between given spectra Returns ------- Spectrogram a new `Spectrogram` from a vertical stacking of the spectra The new object takes the metadata from the first given `~gwpy.frequencyseries.FrequencySeries` if not given explicitly Notes ----- Each `~gwpy.frequencyseries.FrequencySeries` passed to this constructor must be the same length. """ data = numpy.vstack([s.value for s in spectra]) spec1 = list(spectra)[0] if not all(s.f0 == spec1.f0 for s in spectra): raise ValueError("Cannot stack spectra with different f0") if not all(s.df == spec1.df for s in spectra): raise ValueError("Cannot stack spectra with different df") kwargs.setdefault('name', spec1.name) kwargs.setdefault('channel', spec1.channel) kwargs.setdefault('epoch', spec1.epoch) kwargs.setdefault('f0', spec1.f0) kwargs.setdefault('df', spec1.df) kwargs.setdefault('unit', spec1.unit) if not ('dt' in kwargs or 'times' in kwargs): try: kwargs.setdefault('dt', spectra[1].epoch.gps - spec1.epoch.gps) except (AttributeError, IndexError): raise ValueError("Cannot determine dt (time-spacing) for " "Spectrogram from inputs") return Spectrogram(data, **kwargs)
[ "def", "from_spectra", "(", "cls", ",", "*", "spectra", ",", "*", "*", "kwargs", ")", ":", "data", "=", "numpy", ".", "vstack", "(", "[", "s", ".", "value", "for", "s", "in", "spectra", "]", ")", "spec1", "=", "list", "(", "spectra", ")", "[", ...
https://github.com/gwpy/gwpy/blob/82becd78d166a32985cb657a54d0d39f6a207739/gwpy/spectrogram/spectrogram.py#L357-L397
IBM/lale
b4d6829c143a4735b06083a0e6c70d2cca244162
lale/type_checking.py
python
_get_args_schema
(fun)
return result
[]
def _get_args_schema(fun): sig = inspect.signature(fun) result = {"type": "object", "properties": {}} required = [] additional_properties = False for name, param in sig.parameters.items(): ignored_kinds = [ inspect.Parameter.VAR_POSITIONAL, inspect.Parameter.VAR_KEYWORD, ] if name != "self": if param.kind in ignored_kinds: additional_properties = True else: if param.default == inspect.Parameter.empty: param_schema = {"laleType": "Any"} required.append(name) else: param_schema = {"default": param.default} result["properties"][name] = param_schema if not additional_properties: result["additionalProperties"] = False if len(required) > 0: result["required"] = required return result
[ "def", "_get_args_schema", "(", "fun", ")", ":", "sig", "=", "inspect", ".", "signature", "(", "fun", ")", "result", "=", "{", "\"type\"", ":", "\"object\"", ",", "\"properties\"", ":", "{", "}", "}", "required", "=", "[", "]", "additional_properties", "...
https://github.com/IBM/lale/blob/b4d6829c143a4735b06083a0e6c70d2cca244162/lale/type_checking.py#L375-L399
twilio/twilio-python
6e1e811ea57a1edfadd5161ace87397c563f6915
twilio/rest/taskrouter/v1/workspace/task_channel.py
python
TaskChannelContext.update
(self, friendly_name=values.unset, channel_optimized_routing=values.unset)
return TaskChannelInstance( self._version, payload, workspace_sid=self._solution['workspace_sid'], sid=self._solution['sid'], )
Update the TaskChannelInstance :param unicode friendly_name: A string to describe the Task Channel resource :param bool channel_optimized_routing: Whether the TaskChannel should prioritize Workers that have been idle :returns: The updated TaskChannelInstance :rtype: twilio.rest.taskrouter.v1.workspace.task_channel.TaskChannelInstance
Update the TaskChannelInstance
[ "Update", "the", "TaskChannelInstance" ]
def update(self, friendly_name=values.unset, channel_optimized_routing=values.unset): """ Update the TaskChannelInstance :param unicode friendly_name: A string to describe the Task Channel resource :param bool channel_optimized_routing: Whether the TaskChannel should prioritize Workers that have been idle :returns: The updated TaskChannelInstance :rtype: twilio.rest.taskrouter.v1.workspace.task_channel.TaskChannelInstance """ data = values.of({ 'FriendlyName': friendly_name, 'ChannelOptimizedRouting': channel_optimized_routing, }) payload = self._version.update(method='POST', uri=self._uri, data=data, ) return TaskChannelInstance( self._version, payload, workspace_sid=self._solution['workspace_sid'], sid=self._solution['sid'], )
[ "def", "update", "(", "self", ",", "friendly_name", "=", "values", ".", "unset", ",", "channel_optimized_routing", "=", "values", ".", "unset", ")", ":", "data", "=", "values", ".", "of", "(", "{", "'FriendlyName'", ":", "friendly_name", ",", "'ChannelOptimi...
https://github.com/twilio/twilio-python/blob/6e1e811ea57a1edfadd5161ace87397c563f6915/twilio/rest/taskrouter/v1/workspace/task_channel.py#L240-L263
makerbot/ReplicatorG
d6f2b07785a5a5f1e172fb87cb4303b17c575d5d
skein_engines/skeinforge-47/fabmetheus_utilities/geometry/creation/lineation.py
python
getInradius
(defaultInradius, elementNode)
return getComplexByMultiplierPrefix(elementNode, 2.0, 'size', defaultInradius)
Get inradius.
Get inradius.
[ "Get", "inradius", "." ]
def getInradius(defaultInradius, elementNode): 'Get inradius.' defaultInradius = getComplexByPrefixes(elementNode, ['demisize', 'inradius'], defaultInradius) return getComplexByMultiplierPrefix(elementNode, 2.0, 'size', defaultInradius)
[ "def", "getInradius", "(", "defaultInradius", ",", "elementNode", ")", ":", "defaultInradius", "=", "getComplexByPrefixes", "(", "elementNode", ",", "[", "'demisize'", ",", "'inradius'", "]", ",", "defaultInradius", ")", "return", "getComplexByMultiplierPrefix", "(", ...
https://github.com/makerbot/ReplicatorG/blob/d6f2b07785a5a5f1e172fb87cb4303b17c575d5d/skein_engines/skeinforge-47/fabmetheus_utilities/geometry/creation/lineation.py#L143-L146
cool-RR/python_toolbox
cb9ef64b48f1d03275484d707dc5079b6701ad0c
python_toolbox/temp_file_tools.py
python
create_temp_folder
(*, prefix=tempfile.template, suffix='', parent_folder=None, chmod=None)
Context manager that creates a temporary folder and deletes it after usage. After the suite finishes, the temporary folder and all its files and subfolders will be deleted. Example: with create_temp_folder() as temp_folder: # We have a temporary folder! assert temp_folder.is_dir() # We can create files in it: (temp_folder / 'my_file').open('w') # The suite is finished, now it's all cleaned: assert not temp_folder.exists() Use the `prefix` and `suffix` string arguments to dictate a prefix and/or a suffix to the temporary folder's name in the filesystem. If you'd like to set the permissions of the temporary folder, pass them to the optional `chmod` argument, like this: create_temp_folder(chmod=0o550)
Context manager that creates a temporary folder and deletes it after usage.
[ "Context", "manager", "that", "creates", "a", "temporary", "folder", "and", "deletes", "it", "after", "usage", "." ]
def create_temp_folder(*, prefix=tempfile.template, suffix='', parent_folder=None, chmod=None): ''' Context manager that creates a temporary folder and deletes it after usage. After the suite finishes, the temporary folder and all its files and subfolders will be deleted. Example: with create_temp_folder() as temp_folder: # We have a temporary folder! assert temp_folder.is_dir() # We can create files in it: (temp_folder / 'my_file').open('w') # The suite is finished, now it's all cleaned: assert not temp_folder.exists() Use the `prefix` and `suffix` string arguments to dictate a prefix and/or a suffix to the temporary folder's name in the filesystem. If you'd like to set the permissions of the temporary folder, pass them to the optional `chmod` argument, like this: create_temp_folder(chmod=0o550) ''' temp_folder = pathlib.Path(tempfile.mkdtemp(prefix=prefix, suffix=suffix, dir=parent_folder)) try: if chmod is not None: temp_folder.chmod(chmod) yield temp_folder finally: shutil.rmtree(str(temp_folder))
[ "def", "create_temp_folder", "(", "*", ",", "prefix", "=", "tempfile", ".", "template", ",", "suffix", "=", "''", ",", "parent_folder", "=", "None", ",", "chmod", "=", "None", ")", ":", "temp_folder", "=", "pathlib", ".", "Path", "(", "tempfile", ".", ...
https://github.com/cool-RR/python_toolbox/blob/cb9ef64b48f1d03275484d707dc5079b6701ad0c/python_toolbox/temp_file_tools.py#L16-L53
MITRECND/WhoDat
9c2a3265c6437f2f82f23abc1deaaaa86b947d38
pydat/backend/pydat/core/query_parser.py
python
PyDatParser.p_daterange_range
(self, t)
daterange : WORD COLON DATE COLON DATE
daterange : WORD COLON DATE COLON DATE
[ "daterange", ":", "WORD", "COLON", "DATE", "COLON", "DATE" ]
def p_daterange_range(self, t): 'daterange : WORD COLON DATE COLON DATE' try: start = datetime.datetime.strptime(t[3], '%Y-%m-%d') end = (datetime.datetime.strptime(t[5], '%Y-%m-%d') + datetime.timedelta(1, 0)) except Exception: raise ValueError("Invalid Date Range") if end < start: raise ValueError("End date less than start date") t[0] = self.create_daterange_query(t[1], start, end)
[ "def", "p_daterange_range", "(", "self", ",", "t", ")", ":", "try", ":", "start", "=", "datetime", ".", "datetime", ".", "strptime", "(", "t", "[", "3", "]", ",", "'%Y-%m-%d'", ")", "end", "=", "(", "datetime", ".", "datetime", ".", "strptime", "(", ...
https://github.com/MITRECND/WhoDat/blob/9c2a3265c6437f2f82f23abc1deaaaa86b947d38/pydat/backend/pydat/core/query_parser.py#L605-L618
PaddlePaddle/PaddleX
2bab73f81ab54e328204e7871e6ae4a82e719f5d
static/paddlex/cv/models/ppyolo.py
python
PPYOLO.evaluate
(self, eval_dataset, batch_size=1, epoch_id=None, metric=None, return_details=False)
return evaluate_metrics
评估。 Args: eval_dataset (paddlex.datasets): 验证数据读取器。 batch_size (int): 验证数据批大小。默认为1。 epoch_id (int): 当前评估模型所在的训练轮数。 metric (bool): 训练过程中评估的方式,取值范围为['COCO', 'VOC']。默认为None, 根据用户传入的Dataset自动选择,如为VOCDetection,则metric为'VOC'; 如为COCODetection,则metric为'COCO'。 return_details (bool): 是否返回详细信息。 Returns: tuple (metrics, eval_details) | dict (metrics): 当return_details为True时,返回(metrics, eval_details), 当return_details为False时,返回metrics。metrics为dict,包含关键字:'bbox_mmap'或者’bbox_map‘, 分别表示平均准确率平均值在各个IoU阈值下的结果取平均值的结果(mmAP)、平均准确率平均值(mAP)。 eval_details为dict,包含bbox和gt两个关键字。其中关键字bbox的键值是一个列表,列表中每个元素代表一个预测结果, 一个预测结果是一个由图像id,预测框类别id, 预测框坐标,预测框得分组成的列表。而关键字gt的键值是真实标注框的相关信息。
评估。
[ "评估。" ]
def evaluate(self, eval_dataset, batch_size=1, epoch_id=None, metric=None, return_details=False): """评估。 Args: eval_dataset (paddlex.datasets): 验证数据读取器。 batch_size (int): 验证数据批大小。默认为1。 epoch_id (int): 当前评估模型所在的训练轮数。 metric (bool): 训练过程中评估的方式,取值范围为['COCO', 'VOC']。默认为None, 根据用户传入的Dataset自动选择,如为VOCDetection,则metric为'VOC'; 如为COCODetection,则metric为'COCO'。 return_details (bool): 是否返回详细信息。 Returns: tuple (metrics, eval_details) | dict (metrics): 当return_details为True时,返回(metrics, eval_details), 当return_details为False时,返回metrics。metrics为dict,包含关键字:'bbox_mmap'或者’bbox_map‘, 分别表示平均准确率平均值在各个IoU阈值下的结果取平均值的结果(mmAP)、平均准确率平均值(mAP)。 eval_details为dict,包含bbox和gt两个关键字。其中关键字bbox的键值是一个列表,列表中每个元素代表一个预测结果, 一个预测结果是一个由图像id,预测框类别id, 预测框坐标,预测框得分组成的列表。而关键字gt的键值是真实标注框的相关信息。 """ input_channel = getattr(self, 'input_channel', 3) arrange_transforms( model_type=self.model_type, class_name=self.__class__.__name__, transforms=eval_dataset.transforms, mode='eval', input_channel=input_channel) if metric is None: if hasattr(self, 'metric') and self.metric is not None: metric = self.metric else: if isinstance(eval_dataset, paddlex.datasets.CocoDetection): metric = 'COCO' elif isinstance(eval_dataset, paddlex.datasets.VOCDetection): metric = 'VOC' else: raise Exception( "eval_dataset should be datasets.VOCDetection or datasets.COCODetection." ) assert metric in ['COCO', 'VOC'], "Metric only support 'VOC' or 'COCO'" total_steps = math.ceil(eval_dataset.num_samples * 1.0 / batch_size) results = list() data_generator = eval_dataset.generator( batch_size=batch_size, drop_last=False) logging.info( "Start to evaluating(total_samples={}, total_steps={})...".format( eval_dataset.num_samples, total_steps)) for step, data in tqdm.tqdm( enumerate(data_generator()), total=total_steps): images = np.array([d[0] for d in data]) im_sizes = np.array([d[1] for d in data]) feed_data = {'image': images, 'im_size': im_sizes} with fluid.scope_guard(self.scope): outputs = self.exe.run( self.test_prog, feed=[feed_data], fetch_list=list(self.test_outputs.values()), return_numpy=False) res = { 'bbox': (np.array(outputs[0]), outputs[0].recursive_sequence_lengths()) } res_id = [np.array([d[2]]) for d in data] res['im_id'] = (res_id, []) if metric == 'VOC': res_gt_box = [d[3].reshape(-1, 4) for d in data] res_gt_label = [d[4].reshape(-1, 1) for d in data] res_is_difficult = [d[5].reshape(-1, 1) for d in data] res_id = [np.array([d[2]]) for d in data] res['gt_box'] = (res_gt_box, []) res['gt_label'] = (res_gt_label, []) res['is_difficult'] = (res_is_difficult, []) results.append(res) logging.debug("[EVAL] Epoch={}, Step={}/{}".format(epoch_id, step + 1, total_steps)) box_ap_stats, eval_details = eval_results( results, metric, eval_dataset.coco_gt, with_background=False) evaluate_metrics = OrderedDict( zip(['bbox_mmap' if metric == 'COCO' else 'bbox_map'], box_ap_stats)) if return_details: return evaluate_metrics, eval_details return evaluate_metrics
[ "def", "evaluate", "(", "self", ",", "eval_dataset", ",", "batch_size", "=", "1", ",", "epoch_id", "=", "None", ",", "metric", "=", "None", ",", "return_details", "=", "False", ")", ":", "input_channel", "=", "getattr", "(", "self", ",", "'input_channel'",...
https://github.com/PaddlePaddle/PaddleX/blob/2bab73f81ab54e328204e7871e6ae4a82e719f5d/static/paddlex/cv/models/ppyolo.py#L368-L456
zhl2008/awd-platform
0416b31abea29743387b10b3914581fbe8e7da5e
web_hxb2/lib/python3.5/site-packages/wagtail/wagtailsearch/backends/elasticsearch.py
python
ElasticsearchSearchBackend.add
(self, obj)
[]
def add(self, obj): self.get_index_for_model(type(obj)).add_item(obj)
[ "def", "add", "(", "self", ",", "obj", ")", ":", "self", ".", "get_index_for_model", "(", "type", "(", "obj", ")", ")", ".", "add_item", "(", "obj", ")" ]
https://github.com/zhl2008/awd-platform/blob/0416b31abea29743387b10b3914581fbe8e7da5e/web_hxb2/lib/python3.5/site-packages/wagtail/wagtailsearch/backends/elasticsearch.py#L805-L806
securesystemslab/zippy
ff0e84ac99442c2c55fe1d285332cfd4e185e089
zippy/benchmarks/src/benchmarks/sympy/sympy/combinatorics/partitions.py
python
IntegerPartition.as_dict
(self)
return self._dict
Return the partition as a dictionary whose keys are the partition integers and the values are the multiplicity of that integer. Examples ======== >>> from sympy.combinatorics.partitions import IntegerPartition >>> IntegerPartition([1]*3 + [2] + [3]*4).as_dict() {1: 3, 2: 1, 3: 4}
Return the partition as a dictionary whose keys are the partition integers and the values are the multiplicity of that integer.
[ "Return", "the", "partition", "as", "a", "dictionary", "whose", "keys", "are", "the", "partition", "integers", "and", "the", "values", "are", "the", "multiplicity", "of", "that", "integer", "." ]
def as_dict(self): """Return the partition as a dictionary whose keys are the partition integers and the values are the multiplicity of that integer. Examples ======== >>> from sympy.combinatorics.partitions import IntegerPartition >>> IntegerPartition([1]*3 + [2] + [3]*4).as_dict() {1: 3, 2: 1, 3: 4} """ if self._dict is None: groups = group(self.partition, multiple=False) self._keys = [g[0] for g in groups] self._dict = dict(groups) return self._dict
[ "def", "as_dict", "(", "self", ")", ":", "if", "self", ".", "_dict", "is", "None", ":", "groups", "=", "group", "(", "self", ".", "partition", ",", "multiple", "=", "False", ")", "self", ".", "_keys", "=", "[", "g", "[", "0", "]", "for", "g", "...
https://github.com/securesystemslab/zippy/blob/ff0e84ac99442c2c55fe1d285332cfd4e185e089/zippy/benchmarks/src/benchmarks/sympy/sympy/combinatorics/partitions.py#L443-L459
fukuball/fuku-ml
0da15ad7af76adf344b5a6b3f3dbabbbab3446b0
FukuML/KernelLogisticRegression.py
python
KernelLogisticRegression.__init__
(self)
init
init
[ "init" ]
def __init__(self): """init""" self.status = 'empty' self.train_X = [] self.train_Y = [] self.W = [] self.data_num = 0 self.data_demension = 0 self.test_X = [] self.test_Y = [] self.feature_transform_mode = '' self.feature_transform_degree = 1 self.feed_mode = 'batch' self.step_eta = 0.126 self.updates = 2000 self.lambda_p = 0.0001 self.svm_kernel = 'soft_gaussian_kernel' self.zeta = 0 self.gamma = 1 self.Q = 1 self.C = 0.1 self.beta = []
[ "def", "__init__", "(", "self", ")", ":", "self", ".", "status", "=", "'empty'", "self", ".", "train_X", "=", "[", "]", "self", ".", "train_Y", "=", "[", "]", "self", ".", "W", "=", "[", "]", "self", ".", "data_num", "=", "0", "self", ".", "dat...
https://github.com/fukuball/fuku-ml/blob/0da15ad7af76adf344b5a6b3f3dbabbbab3446b0/FukuML/KernelLogisticRegression.py#L13-L37
1012598167/flask_mongodb_game
60c7e0351586656ec38f851592886338e50b4110
python_flask/venv/Lib/site-packages/gridfs/__init__.py
python
GridFS.get
(self, file_id, session=None)
return gout
Get a file from GridFS by ``"_id"``. Returns an instance of :class:`~gridfs.grid_file.GridOut`, which provides a file-like interface for reading. :Parameters: - `file_id`: ``"_id"`` of the file to get - `session` (optional): a :class:`~pymongo.client_session.ClientSession` .. versionchanged:: 3.6 Added ``session`` parameter.
Get a file from GridFS by ``"_id"``.
[ "Get", "a", "file", "from", "GridFS", "by", "_id", "." ]
def get(self, file_id, session=None): """Get a file from GridFS by ``"_id"``. Returns an instance of :class:`~gridfs.grid_file.GridOut`, which provides a file-like interface for reading. :Parameters: - `file_id`: ``"_id"`` of the file to get - `session` (optional): a :class:`~pymongo.client_session.ClientSession` .. versionchanged:: 3.6 Added ``session`` parameter. """ gout = GridOut(self.__collection, file_id, session=session) # Raise NoFile now, instead of on first attribute access. gout._ensure_file() return gout
[ "def", "get", "(", "self", ",", "file_id", ",", "session", "=", "None", ")", ":", "gout", "=", "GridOut", "(", "self", ".", "__collection", ",", "file_id", ",", "session", "=", "session", ")", "# Raise NoFile now, instead of on first attribute access.", "gout", ...
https://github.com/1012598167/flask_mongodb_game/blob/60c7e0351586656ec38f851592886338e50b4110/python_flask/venv/Lib/site-packages/gridfs/__init__.py#L136-L154
ProjectQ-Framework/ProjectQ
0d32c1610ba4e9aefd7f19eb52dadb4fbe5f9005
projectq/backends/_sim/_pysim.py
python
Simulator.set_wavefunction
(self, wavefunction, ordering)
Set wavefunction and qubit ordering. Args: wavefunction (list[complex]): Array of complex amplitudes describing the wavefunction (must be normalized). ordering (list): List of ids describing the new ordering of qubits (i.e., the ordering of the provided wavefunction).
Set wavefunction and qubit ordering.
[ "Set", "wavefunction", "and", "qubit", "ordering", "." ]
def set_wavefunction(self, wavefunction, ordering): """ Set wavefunction and qubit ordering. Args: wavefunction (list[complex]): Array of complex amplitudes describing the wavefunction (must be normalized). ordering (list): List of ids describing the new ordering of qubits (i.e., the ordering of the provided wavefunction). """ # wavefunction contains 2^n values for n qubits if len(wavefunction) != (1 << len(ordering)): # pragma: no cover raise ValueError('The wavefunction must contain 2^n elements!') # all qubits must have been allocated before if not all(qubit_id in self._map for qubit_id in ordering) or len(self._map) != len(ordering): raise RuntimeError( "set_wavefunction(): Invalid mapping provided. Please make sure all qubits have been " "allocated previously (call eng.flush())." ) self._state = _np.array(wavefunction, dtype=_np.complex128) self._map = {ordering[i]: i for i in range(len(ordering))}
[ "def", "set_wavefunction", "(", "self", ",", "wavefunction", ",", "ordering", ")", ":", "# wavefunction contains 2^n values for n qubits", "if", "len", "(", "wavefunction", ")", "!=", "(", "1", "<<", "len", "(", "ordering", ")", ")", ":", "# pragma: no cover", "...
https://github.com/ProjectQ-Framework/ProjectQ/blob/0d32c1610ba4e9aefd7f19eb52dadb4fbe5f9005/projectq/backends/_sim/_pysim.py#L436-L457