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
Samsung/cotopaxi
d19178b1235017257fec20d0a41edc918de55574
cotopaxi/dtls_utils.py
python
scrap_dtls_response
(resp_packet)
return parsed_response
Parse response packet and scraps DTLS response from stdout.
Parse response packet and scraps DTLS response from stdout.
[ "Parse", "response", "packet", "and", "scraps", "DTLS", "response", "from", "stdout", "." ]
def scrap_dtls_response(resp_packet): """Parse response packet and scraps DTLS response from stdout.""" save_stdout, sys.stdout = sys.stdout, StringIO() resp_packet.show() parsed_response = sys.stdout.getvalue() sys.stdout = save_stdout parsed_response = ( "len(parsed_response): {}\n".format(len(parsed_response)) + parsed_response ) return parsed_response
[ "def", "scrap_dtls_response", "(", "resp_packet", ")", ":", "save_stdout", ",", "sys", ".", "stdout", "=", "sys", ".", "stdout", ",", "StringIO", "(", ")", "resp_packet", ".", "show", "(", ")", "parsed_response", "=", "sys", ".", "stdout", ".", "getvalue",...
https://github.com/Samsung/cotopaxi/blob/d19178b1235017257fec20d0a41edc918de55574/cotopaxi/dtls_utils.py#L155-L164
tp4a/teleport
1fafd34f1f775d2cf80ea4af6e44468d8e0b24ad
server/www/packages/packages-linux/x64/PIL/ImageFilter.py
python
Color3DLUT.__repr__
(self)
return "<{}>".format(" ".join(r))
[]
def __repr__(self): r = [ "{} from {}".format(self.__class__.__name__, self.table.__class__.__name__), "size={:d}x{:d}x{:d}".format(*self.size), "channels={:d}".format(self.channels), ] if self.mode: r.append("target_mode={}".format(self.mode)) return "<{}>".format(" ".join(r))
[ "def", "__repr__", "(", "self", ")", ":", "r", "=", "[", "\"{} from {}\"", ".", "format", "(", "self", ".", "__class__", ".", "__name__", ",", "self", ".", "table", ".", "__class__", ".", "__name__", ")", ",", "\"size={:d}x{:d}x{:d}\"", ".", "format", "(...
https://github.com/tp4a/teleport/blob/1fafd34f1f775d2cf80ea4af6e44468d8e0b24ad/server/www/packages/packages-linux/x64/PIL/ImageFilter.py#L514-L522
zhl2008/awd-platform
0416b31abea29743387b10b3914581fbe8e7da5e
web_flaskbb/Python-2.7.9/Lib/distutils/command/build_ext.py
python
build_ext.build_extension
(self, ext)
[]
def build_extension(self, ext): sources = ext.sources if sources is None or type(sources) not in (ListType, TupleType): raise DistutilsSetupError, \ ("in 'ext_modules' option (extension '%s'), " + "'sources' must be present and must be " + "a list of source filenames") % ext.name sources = list(sources) ext_path = self.get_ext_fullpath(ext.name) depends = sources + ext.depends if not (self.force or newer_group(depends, ext_path, 'newer')): log.debug("skipping '%s' extension (up-to-date)", ext.name) return else: log.info("building '%s' extension", ext.name) # First, scan the sources for SWIG definition files (.i), run # SWIG on 'em to create .c files, and modify the sources list # accordingly. sources = self.swig_sources(sources, ext) # Next, compile the source code to object files. # XXX not honouring 'define_macros' or 'undef_macros' -- the # CCompiler API needs to change to accommodate this, and I # want to do one thing at a time! # Two possible sources for extra compiler arguments: # - 'extra_compile_args' in Extension object # - CFLAGS environment variable (not particularly # elegant, but people seem to expect it and I # guess it's useful) # The environment variable should take precedence, and # any sensible compiler will give precedence to later # command line args. Hence we combine them in order: extra_args = ext.extra_compile_args or [] macros = ext.define_macros[:] for undef in ext.undef_macros: macros.append((undef,)) objects = self.compiler.compile(sources, output_dir=self.build_temp, macros=macros, include_dirs=ext.include_dirs, debug=self.debug, extra_postargs=extra_args, depends=ext.depends) # XXX -- this is a Vile HACK! # # The setup.py script for Python on Unix needs to be able to # get this list so it can perform all the clean up needed to # avoid keeping object files around when cleaning out a failed # build of an extension module. Since Distutils does not # track dependencies, we have to get rid of intermediates to # ensure all the intermediates will be properly re-built. # self._built_objects = objects[:] # Now link the object files together into a "shared object" -- # of course, first we have to figure out all the other things # that go into the mix. if ext.extra_objects: objects.extend(ext.extra_objects) extra_args = ext.extra_link_args or [] # Detect target language, if not provided language = ext.language or self.compiler.detect_language(sources) self.compiler.link_shared_object( objects, ext_path, libraries=self.get_libraries(ext), library_dirs=ext.library_dirs, runtime_library_dirs=ext.runtime_library_dirs, extra_postargs=extra_args, export_symbols=self.get_export_symbols(ext), debug=self.debug, build_temp=self.build_temp, target_lang=language)
[ "def", "build_extension", "(", "self", ",", "ext", ")", ":", "sources", "=", "ext", ".", "sources", "if", "sources", "is", "None", "or", "type", "(", "sources", ")", "not", "in", "(", "ListType", ",", "TupleType", ")", ":", "raise", "DistutilsSetupError"...
https://github.com/zhl2008/awd-platform/blob/0416b31abea29743387b10b3914581fbe8e7da5e/web_flaskbb/Python-2.7.9/Lib/distutils/command/build_ext.py#L448-L528
dhtech/swboot
b741e8f90f3941a7619e12addf337bed1d299204
http/server.py
python
BaseHTTPRequestHandler.send_header
(self, keyword, value)
Send a MIME header to the headers buffer.
Send a MIME header to the headers buffer.
[ "Send", "a", "MIME", "header", "to", "the", "headers", "buffer", "." ]
def send_header(self, keyword, value): """Send a MIME header to the headers buffer.""" if self.request_version != 'HTTP/0.9': if not hasattr(self, '_headers_buffer'): self._headers_buffer = [] self._headers_buffer.append( ("%s: %s\r\n" % (keyword, value)).encode('latin-1', 'strict')) if keyword.lower() == 'connection': if value.lower() == 'close': self.close_connection = True elif value.lower() == 'keep-alive': self.close_connection = False
[ "def", "send_header", "(", "self", ",", "keyword", ",", "value", ")", ":", "if", "self", ".", "request_version", "!=", "'HTTP/0.9'", ":", "if", "not", "hasattr", "(", "self", ",", "'_headers_buffer'", ")", ":", "self", ".", "_headers_buffer", "=", "[", "...
https://github.com/dhtech/swboot/blob/b741e8f90f3941a7619e12addf337bed1d299204/http/server.py#L510-L522
jython/jython3
def4f8ec47cb7a9c799ea4c745f12badf92c5769
Lib/socketserver.py
python
BaseServer.serve_forever
(self, poll_interval=0.5)
Handle one request at a time until shutdown. Polls for shutdown every poll_interval seconds. Ignores self.timeout. If you need to do periodic tasks, do them in another thread.
Handle one request at a time until shutdown.
[ "Handle", "one", "request", "at", "a", "time", "until", "shutdown", "." ]
def serve_forever(self, poll_interval=0.5): """Handle one request at a time until shutdown. Polls for shutdown every poll_interval seconds. Ignores self.timeout. If you need to do periodic tasks, do them in another thread. """ self.__is_shut_down.clear() try: while not self.__shutdown_request: # XXX: Consider using another file descriptor or # connecting to the socket to wake this up instead of # polling. Polling reduces our responsiveness to a # shutdown request and wastes cpu at all other times. r, w, e = _eintr_retry(select.select, [self], [], [], poll_interval) if self in r: self._handle_request_noblock() finally: self.__shutdown_request = False self.__is_shut_down.set()
[ "def", "serve_forever", "(", "self", ",", "poll_interval", "=", "0.5", ")", ":", "self", ".", "__is_shut_down", ".", "clear", "(", ")", "try", ":", "while", "not", "self", ".", "__shutdown_request", ":", "# XXX: Consider using another file descriptor or", "# conne...
https://github.com/jython/jython3/blob/def4f8ec47cb7a9c799ea4c745f12badf92c5769/Lib/socketserver.py#L221-L241
FrancoisSchnell/GPicSync
07d7c4b7da44e4e6665abb94bbb9ef6da0e779d1
src/geoexif.py
python
GeoExif.readLatLong
(self)
return latlong
read latitude AND longitude at the same time
read latitude AND longitude at the same time
[ "read", "latitude", "AND", "longitude", "at", "the", "same", "time" ]
def readLatLong(self): """read latitude AND longitude at the same time""" result=os.popen('%s -n -GPSLatitude -GPSLatitudeRef \ -GPSLongitude -GPSLongitudeRef "%s" ' \ % (self.exifcmd, self.picPath)).read().split("\n") print (result) if len(result)>=4: result[0]=result[0].split(":")[1].strip() try: latDecimal=result[0].split(".")[1][0:] except: latDecimal="0" result[0]=result[0].split(".")[0]+"."+latDecimal result[1]=result[1].split(":")[1].strip() result[2]=result[2].split(":")[1].strip() try: longDecimal=result[2].split(".")[1][0:] except: longDecimal="0" result[2]=result[2].split(".")[0]+"."+longDecimal result[3]=result[3].split(":")[1].strip() latlong= result[1]+result[0]+" "+result[3]+result[2] else: latlong=None print (latlong) return latlong
[ "def", "readLatLong", "(", "self", ")", ":", "result", "=", "os", ".", "popen", "(", "'%s -n -GPSLatitude -GPSLatitudeRef \\\n -GPSLongitude -GPSLongitudeRef \"%s\" '", "%", "(", "self", ".", "exifcmd", ",", "self", ".", "picPath", ")", ")", ".", "read", ...
https://github.com/FrancoisSchnell/GPicSync/blob/07d7c4b7da44e4e6665abb94bbb9ef6da0e779d1/src/geoexif.py#L102-L127
google/tangent
6533e83af09de7345d1b438512679992f080dcc9
tangent/reverse_ad.py
python
ReverseAD.visit_With
(self, node)
Deal with the special with insert_grad_of(x) statement.
Deal with the special with insert_grad_of(x) statement.
[ "Deal", "with", "the", "special", "with", "insert_grad_of", "(", "x", ")", "statement", "." ]
def visit_With(self, node): """Deal with the special with insert_grad_of(x) statement.""" if ast_.is_insert_grad_of_statement(node): primal = [] adjoint = node.body if isinstance(adjoint[0], gast.With): _, adjoint = self.visit(adjoint[0]) node.body[0] = comments.add_comment(node.body[0], 'Inserted code') # Rename the gradients replacements = {} for item in node.items: if (not isinstance(item.context_expr.args[0], gast.Name) or not isinstance(item.optional_vars, gast.Name)): raise ValueError replacements[item.optional_vars.id] = create.create_grad( item.context_expr.args[0], self.namer) template.ReplaceTransformer(replacements).visit(node) return primal, adjoint else: return node, []
[ "def", "visit_With", "(", "self", ",", "node", ")", ":", "if", "ast_", ".", "is_insert_grad_of_statement", "(", "node", ")", ":", "primal", "=", "[", "]", "adjoint", "=", "node", ".", "body", "if", "isinstance", "(", "adjoint", "[", "0", "]", ",", "g...
https://github.com/google/tangent/blob/6533e83af09de7345d1b438512679992f080dcc9/tangent/reverse_ad.py#L376-L395
jython/frozen-mirror
b8d7aa4cee50c0c0fe2f4b235dd62922dd0f3f99
lib-python/2.7/pydoc.py
python
classname
(object, modname)
return name
Get a class name and qualify it with a module name if necessary.
Get a class name and qualify it with a module name if necessary.
[ "Get", "a", "class", "name", "and", "qualify", "it", "with", "a", "module", "name", "if", "necessary", "." ]
def classname(object, modname): """Get a class name and qualify it with a module name if necessary.""" name = object.__name__ if object.__module__ != modname: name = object.__module__ + '.' + name return name
[ "def", "classname", "(", "object", ",", "modname", ")", ":", "name", "=", "object", ".", "__name__", "if", "object", ".", "__module__", "!=", "modname", ":", "name", "=", "object", ".", "__module__", "+", "'.'", "+", "name", "return", "name" ]
https://github.com/jython/frozen-mirror/blob/b8d7aa4cee50c0c0fe2f4b235dd62922dd0f3f99/lib-python/2.7/pydoc.py#L95-L100
aws/serverless-application-model
ab6943a340a3f489af62b8c70c1366242b2887fe
samtranslator/model/preferences/deployment_preference_collection.py
python
DeploymentPreferenceCollection.add
(self, logical_id, deployment_preference_dict)
Add this deployment preference to the collection :raise ValueError if an existing logical id already exists in the _resource_preferences :param logical_id: logical id of the resource where this deployment preference applies :param deployment_preference_dict: the input SAM template deployment preference mapping
Add this deployment preference to the collection
[ "Add", "this", "deployment", "preference", "to", "the", "collection" ]
def add(self, logical_id, deployment_preference_dict): """ Add this deployment preference to the collection :raise ValueError if an existing logical id already exists in the _resource_preferences :param logical_id: logical id of the resource where this deployment preference applies :param deployment_preference_dict: the input SAM template deployment preference mapping """ if logical_id in self._resource_preferences: raise ValueError( "logical_id {logical_id} previously added to this deployment_preference_collection".format( logical_id=logical_id ) ) self._resource_preferences[logical_id] = DeploymentPreference.from_dict(logical_id, deployment_preference_dict)
[ "def", "add", "(", "self", ",", "logical_id", ",", "deployment_preference_dict", ")", ":", "if", "logical_id", "in", "self", ".", "_resource_preferences", ":", "raise", "ValueError", "(", "\"logical_id {logical_id} previously added to this deployment_preference_collection\"",...
https://github.com/aws/serverless-application-model/blob/ab6943a340a3f489af62b8c70c1366242b2887fe/samtranslator/model/preferences/deployment_preference_collection.py#L51-L66
deepgully/me
f7ad65edc2fe435310c6676bc2e322cfe5d4c8f0
libs/alembic/config.py
python
Config.get_template_directory
(self)
return os.path.join(package_dir, 'templates')
Return the directory where Alembic setup templates are found. This method is used by the alembic ``init`` and ``list_templates`` commands.
Return the directory where Alembic setup templates are found.
[ "Return", "the", "directory", "where", "Alembic", "setup", "templates", "are", "found", "." ]
def get_template_directory(self): """Return the directory where Alembic setup templates are found. This method is used by the alembic ``init`` and ``list_templates`` commands. """ return os.path.join(package_dir, 'templates')
[ "def", "get_template_directory", "(", "self", ")", ":", "return", "os", ".", "path", ".", "join", "(", "package_dir", ",", "'templates'", ")" ]
https://github.com/deepgully/me/blob/f7ad65edc2fe435310c6676bc2e322cfe5d4c8f0/libs/alembic/config.py#L100-L107
openshift/openshift-tools
1188778e728a6e4781acf728123e5b356380fe6f
openshift/installer/vendored/openshift-ansible-3.11.28-1/roles/lib_openshift/library/oc_image.py
python
OCImage.get
(self)
return results
return a image by name
return a image by name
[ "return", "a", "image", "by", "name" ]
def get(self): '''return a image by name ''' results = self._get('imagestream', self.image_name) results['exists'] = False if results['returncode'] == 0 and results['results'][0]: results['exists'] = True if results['returncode'] != 0 and '"{}" not found'.format(self.image_name) in results['stderr']: results['returncode'] = 0 return results
[ "def", "get", "(", "self", ")", ":", "results", "=", "self", ".", "_get", "(", "'imagestream'", ",", "self", ".", "image_name", ")", "results", "[", "'exists'", "]", "=", "False", "if", "results", "[", "'returncode'", "]", "==", "0", "and", "results", ...
https://github.com/openshift/openshift-tools/blob/1188778e728a6e4781acf728123e5b356380fe6f/openshift/installer/vendored/openshift-ansible-3.11.28-1/roles/lib_openshift/library/oc_image.py#L1486-L1496
threat9/routersploit
3fd394637f5566c4cf6369eecae08c4d27f93cda
routersploit/core/exploit/utils.py
python
iter_modules
(modules_directory: str = MODULES_DIR)
Iterates over valid modules :param str modules_directory: path to modules directory :return list: list of found modules
Iterates over valid modules
[ "Iterates", "over", "valid", "modules" ]
def iter_modules(modules_directory: str = MODULES_DIR) -> list: """ Iterates over valid modules :param str modules_directory: path to modules directory :return list: list of found modules """ modules = index_modules(modules_directory) modules = map(lambda x: "".join(["routersploit.modules.", x]), modules) for path in modules: yield import_exploit(path)
[ "def", "iter_modules", "(", "modules_directory", ":", "str", "=", "MODULES_DIR", ")", "->", "list", ":", "modules", "=", "index_modules", "(", "modules_directory", ")", "modules", "=", "map", "(", "lambda", "x", ":", "\"\"", ".", "join", "(", "[", "\"route...
https://github.com/threat9/routersploit/blob/3fd394637f5566c4cf6369eecae08c4d27f93cda/routersploit/core/exploit/utils.py#L128-L138
open-io/oio-sds
16041950b6056a55d5ce7ca77795defe6dfa6c61
oio/xcute/server.py
python
XcuteServer._get_job_id
(self, req)
return job_id
Fetch job ID from request query string.
Fetch job ID from request query string.
[ "Fetch", "job", "ID", "from", "request", "query", "string", "." ]
def _get_job_id(self, req): """Fetch job ID from request query string.""" job_id = req.args.get('id') if not job_id: raise HTTPBadRequest('Missing job ID') return job_id
[ "def", "_get_job_id", "(", "self", ",", "req", ")", ":", "job_id", "=", "req", ".", "args", ".", "get", "(", "'id'", ")", "if", "not", "job_id", ":", "raise", "HTTPBadRequest", "(", "'Missing job ID'", ")", "return", "job_id" ]
https://github.com/open-io/oio-sds/blob/16041950b6056a55d5ce7ca77795defe6dfa6c61/oio/xcute/server.py#L123-L128
Chaosthebot/Chaos
0cfbb85ab52654967909aef54eff3a0e62b641bd
twitter_api/__init__.py
python
API_TWITTER.GetApi
(self)
return self.__api
[]
def GetApi(self): return self.__api
[ "def", "GetApi", "(", "self", ")", ":", "return", "self", ".", "__api" ]
https://github.com/Chaosthebot/Chaos/blob/0cfbb85ab52654967909aef54eff3a0e62b641bd/twitter_api/__init__.py#L16-L17
pyRiemann/pyRiemann
30c2cd7204d19f1a60d3b7945dfd8ee3c46a8df8
pyriemann/utils/ajd.py
python
uwedge
(X, init=None, eps=1e-7, n_iter_max=100)
return W_est, D
Approximate joint diagonalization algorithm UWEDGE. Uniformly Weighted Exhaustive Diagonalization using Gauss iteration (U-WEDGE). Implementation of the AJD algorithm by Tichavsky and Yeredor [1]_ [2]_. This is a translation from the matlab code provided by the authors. Parameters ---------- X : ndarray, shape (n_trials, n_channels, n_channels) A set of covariance matrices to diagonalize init: None | ndarray, shape (n_channels, n_channels) (default None) Initialization for the diagonalizer. eps : float (default 1e-7) tolerance for stoping criterion. n_iter_max : int (default 1000) The maximum number of iteration to reach convergence. Returns ------- V : ndarray, shape (n_channels, n_channels) the diagonalizer D : ndarray, shape (n_trials, n_channels, n_channels) the set of quasi diagonal matrices Notes ----- .. versionadded:: 0.2.4 See Also -------- rjd ajd_pham References ---------- .. [1] P. Tichavsky, A. Yeredor and J. Nielsen, "A Fast Approximate Joint Diagonalization Algorithm Using a Criterion with a Block Diagonal Weight Matrix", ICASSP 2008, Las Vegas .. [2] P. Tichavsky and A. Yeredor, "Fast Approximate Joint Diagonalization Incorporating Weight Matrices" IEEE Transactions of Signal Processing, 2009.
Approximate joint diagonalization algorithm UWEDGE.
[ "Approximate", "joint", "diagonalization", "algorithm", "UWEDGE", "." ]
def uwedge(X, init=None, eps=1e-7, n_iter_max=100): """Approximate joint diagonalization algorithm UWEDGE. Uniformly Weighted Exhaustive Diagonalization using Gauss iteration (U-WEDGE). Implementation of the AJD algorithm by Tichavsky and Yeredor [1]_ [2]_. This is a translation from the matlab code provided by the authors. Parameters ---------- X : ndarray, shape (n_trials, n_channels, n_channels) A set of covariance matrices to diagonalize init: None | ndarray, shape (n_channels, n_channels) (default None) Initialization for the diagonalizer. eps : float (default 1e-7) tolerance for stoping criterion. n_iter_max : int (default 1000) The maximum number of iteration to reach convergence. Returns ------- V : ndarray, shape (n_channels, n_channels) the diagonalizer D : ndarray, shape (n_trials, n_channels, n_channels) the set of quasi diagonal matrices Notes ----- .. versionadded:: 0.2.4 See Also -------- rjd ajd_pham References ---------- .. [1] P. Tichavsky, A. Yeredor and J. Nielsen, "A Fast Approximate Joint Diagonalization Algorithm Using a Criterion with a Block Diagonal Weight Matrix", ICASSP 2008, Las Vegas .. [2] P. Tichavsky and A. Yeredor, "Fast Approximate Joint Diagonalization Incorporating Weight Matrices" IEEE Transactions of Signal Processing, 2009. """ L, d, _ = X.shape # reshape input matrix M = np.concatenate(X, 0).T # init variables d, Md = M.shape iteration = 0 improve = 10 if init is None: E, H = np.linalg.eig(M[:, 0:d]) W_est = np.dot(np.diag(1. / np.sqrt(np.abs(E))), H.T) else: W_est = init Ms = np.array(M) Rs = np.zeros((d, L)) for k in range(L): ini = k*d Il = np.arange(ini, ini + d) M[:, Il] = 0.5*(M[:, Il] + M[:, Il].T) Ms[:, Il] = np.dot(np.dot(W_est, M[:, Il]), W_est.T) Rs[:, k] = np.diag(Ms[:, Il]) crit = np.sum(Ms**2) - np.sum(Rs**2) while (improve > eps) & (iteration < n_iter_max): B = np.dot(Rs, Rs.T) C1 = np.zeros((d, d)) for i in range(d): C1[:, i] = np.sum(Ms[:, i:Md:d]*Rs, axis=1) D0 = B*B.T - np.outer(np.diag(B), np.diag(B)) A0 = (C1 * B - np.dot(np.diag(np.diag(B)), C1.T)) / (D0 + np.eye(d)) A0 += np.eye(d) W_est = np.linalg.solve(A0, W_est) Raux = np.dot(np.dot(W_est, M[:, 0:d]), W_est.T) aux = 1./np.sqrt(np.abs(np.diag(Raux))) W_est = np.dot(np.diag(aux), W_est) for k in range(L): ini = k*d Il = np.arange(ini, ini + d) Ms[:, Il] = np.dot(np.dot(W_est, M[:, Il]), W_est.T) Rs[:, k] = np.diag(Ms[:, Il]) crit_new = np.sum(Ms**2) - np.sum(Rs**2) improve = np.abs(crit_new - crit) crit = crit_new iteration += 1 D = np.reshape(Ms, (d, L, d)).transpose(1, 0, 2) return W_est, D
[ "def", "uwedge", "(", "X", ",", "init", "=", "None", ",", "eps", "=", "1e-7", ",", "n_iter_max", "=", "100", ")", ":", "L", ",", "d", ",", "_", "=", "X", ".", "shape", "# reshape input matrix", "M", "=", "np", ".", "concatenate", "(", "X", ",", ...
https://github.com/pyRiemann/pyRiemann/blob/30c2cd7204d19f1a60d3b7945dfd8ee3c46a8df8/pyriemann/utils/ajd.py#L204-L303
securesystemslab/zippy
ff0e84ac99442c2c55fe1d285332cfd4e185e089
zippy/lib-python/3/xml/sax/xmlreader.py
python
AttributesImpl.getType
(self, name)
return "CDATA"
[]
def getType(self, name): return "CDATA"
[ "def", "getType", "(", "self", ",", "name", ")", ":", "return", "\"CDATA\"" ]
https://github.com/securesystemslab/zippy/blob/ff0e84ac99442c2c55fe1d285332cfd4e185e089/zippy/lib-python/3/xml/sax/xmlreader.py#L287-L288
OpenEndedGroup/Field
4f7c8edfb01bb0ccc927b78d3c500f018a4ae37c
Contents/lib/python/logging/__init__.py
python
info
(msg, *args, **kwargs)
Log a message with severity 'INFO' on the root logger.
Log a message with severity 'INFO' on the root logger.
[ "Log", "a", "message", "with", "severity", "INFO", "on", "the", "root", "logger", "." ]
def info(msg, *args, **kwargs): """ Log a message with severity 'INFO' on the root logger. """ if len(root.handlers) == 0: basicConfig() apply(root.info, (msg,)+args, kwargs)
[ "def", "info", "(", "msg", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "len", "(", "root", ".", "handlers", ")", "==", "0", ":", "basicConfig", "(", ")", "apply", "(", "root", ".", "info", ",", "(", "msg", ",", ")", "+", "args"...
https://github.com/OpenEndedGroup/Field/blob/4f7c8edfb01bb0ccc927b78d3c500f018a4ae37c/Contents/lib/python/logging/__init__.py#L1313-L1319
landlab/landlab
a5dd80b8ebfd03d1ba87ef6c4368c409485f222c
landlab/grid/voronoi.py
python
simple_poly_area
(x, y)
return 0.5 * abs(sum(x[:-1] * y[1:] - x[1:] * y[:-1]) + x[-1] * y[0] - x[0] * y[-1])
Calculates and returns the area of a 2-D simple polygon. Input vertices must be in sequence (clockwise or counterclockwise). *x* and *y* are arrays that give the x- and y-axis coordinates of the polygon's vertices. Parameters ---------- x : ndarray x-coordinates of of polygon vertices. y : ndarray y-coordinates of of polygon vertices. Returns ------- out : float Area of the polygon Examples -------- >>> import numpy as np >>> from landlab.grid.voronoi import simple_poly_area >>> x = np.array([3., 1., 1., 3.]) >>> y = np.array([1.5, 1.5, 0.5, 0.5]) >>> simple_poly_area(x, y) 2.0 If the input coordinate arrays are 2D, calculate the area of each polygon. Note that when used in this mode, all polygons must have the same number of vertices, and polygon vertices are listed column-by-column. >>> x = np.array([[ 3., 1., 1., 3.], ... [-2., -2., -1., -1.]]).T >>> y = np.array([[1.5, 1.5, 0.5, 0.5], ... [ 0., 1., 2., 0.]]).T >>> simple_poly_area(x, y) array([ 2. , 1.5])
Calculates and returns the area of a 2-D simple polygon.
[ "Calculates", "and", "returns", "the", "area", "of", "a", "2", "-", "D", "simple", "polygon", "." ]
def simple_poly_area(x, y): """Calculates and returns the area of a 2-D simple polygon. Input vertices must be in sequence (clockwise or counterclockwise). *x* and *y* are arrays that give the x- and y-axis coordinates of the polygon's vertices. Parameters ---------- x : ndarray x-coordinates of of polygon vertices. y : ndarray y-coordinates of of polygon vertices. Returns ------- out : float Area of the polygon Examples -------- >>> import numpy as np >>> from landlab.grid.voronoi import simple_poly_area >>> x = np.array([3., 1., 1., 3.]) >>> y = np.array([1.5, 1.5, 0.5, 0.5]) >>> simple_poly_area(x, y) 2.0 If the input coordinate arrays are 2D, calculate the area of each polygon. Note that when used in this mode, all polygons must have the same number of vertices, and polygon vertices are listed column-by-column. >>> x = np.array([[ 3., 1., 1., 3.], ... [-2., -2., -1., -1.]]).T >>> y = np.array([[1.5, 1.5, 0.5, 0.5], ... [ 0., 1., 2., 0.]]).T >>> simple_poly_area(x, y) array([ 2. , 1.5]) """ # For short arrays (less than about 100 elements) it seems that the # Python sum is faster than the numpy sum. Likewise for the Python # built-in abs. return 0.5 * abs(sum(x[:-1] * y[1:] - x[1:] * y[:-1]) + x[-1] * y[0] - x[0] * y[-1])
[ "def", "simple_poly_area", "(", "x", ",", "y", ")", ":", "# For short arrays (less than about 100 elements) it seems that the", "# Python sum is faster than the numpy sum. Likewise for the Python", "# built-in abs.", "return", "0.5", "*", "abs", "(", "sum", "(", "x", "[", ":"...
https://github.com/landlab/landlab/blob/a5dd80b8ebfd03d1ba87ef6c4368c409485f222c/landlab/grid/voronoi.py#L15-L57
lovelylain/pyctp
fd304de4b50c4ddc31a4190b1caaeb5dec66bc5d
option/ctp/ApiStruct.py
python
OptionInstrMarginAdjust.__init__
(self, InstrumentID='', InvestorRange=IR_All, BrokerID='', InvestorID='', SShortMarginRatioByMoney=0.0, SShortMarginRatioByVolume=0.0, HShortMarginRatioByMoney=0.0, HShortMarginRatioByVolume=0.0, AShortMarginRatioByMoney=0.0, AShortMarginRatioByVolume=0.0, IsRelative=0, ExchangeID='')
[]
def __init__(self, InstrumentID='', InvestorRange=IR_All, BrokerID='', InvestorID='', SShortMarginRatioByMoney=0.0, SShortMarginRatioByVolume=0.0, HShortMarginRatioByMoney=0.0, HShortMarginRatioByVolume=0.0, AShortMarginRatioByMoney=0.0, AShortMarginRatioByVolume=0.0, IsRelative=0, ExchangeID=''): self.InstrumentID = '' #合约代码, char[31] self.InvestorRange = '' #投资者范围, char self.BrokerID = '' #经纪公司代码, char[11] self.InvestorID = '' #投资者代码, char[13] self.SShortMarginRatioByMoney = 'Ratio' #投机空头保证金调整系数, double self.SShortMarginRatioByVolume = 'Money' #投机空头保证金调整系数, double self.HShortMarginRatioByMoney = 'Ratio' #保值空头保证金调整系数, double self.HShortMarginRatioByVolume = 'Money' #保值空头保证金调整系数, double self.AShortMarginRatioByMoney = 'Ratio' #套利空头保证金调整系数, double self.AShortMarginRatioByVolume = 'Money' #套利空头保证金调整系数, double self.IsRelative = 'Bool' #是否跟随交易所收取, int self.ExchangeID = ''
[ "def", "__init__", "(", "self", ",", "InstrumentID", "=", "''", ",", "InvestorRange", "=", "IR_All", ",", "BrokerID", "=", "''", ",", "InvestorID", "=", "''", ",", "SShortMarginRatioByMoney", "=", "0.0", ",", "SShortMarginRatioByVolume", "=", "0.0", ",", "HS...
https://github.com/lovelylain/pyctp/blob/fd304de4b50c4ddc31a4190b1caaeb5dec66bc5d/option/ctp/ApiStruct.py#L3299-L3311
collinsctk/PyQYT
7af3673955f94ff1b2df2f94220cd2dab2e252af
ExtentionPackages/scapy/layers/l2.py
python
arpcachepoison
(target, victim, interval=60)
Poison target's cache with (your MAC,victim's IP) couple arpcachepoison(target, victim, [interval=60]) -> None
Poison target's cache with (your MAC,victim's IP) couple arpcachepoison(target, victim, [interval=60]) -> None
[ "Poison", "target", "s", "cache", "with", "(", "your", "MAC", "victim", "s", "IP", ")", "couple", "arpcachepoison", "(", "target", "victim", "[", "interval", "=", "60", "]", ")", "-", ">", "None" ]
def arpcachepoison(target, victim, interval=60): """Poison target's cache with (your MAC,victim's IP) couple arpcachepoison(target, victim, [interval=60]) -> None """ tmac = getmacbyip(target) p = Ether(dst=tmac)/ARP(op="who-has", psrc=victim, pdst=target) try: while 1: sendp(p, iface_hint=target) if conf.verb > 1: os.write(1,b".") time.sleep(interval) except KeyboardInterrupt: pass
[ "def", "arpcachepoison", "(", "target", ",", "victim", ",", "interval", "=", "60", ")", ":", "tmac", "=", "getmacbyip", "(", "target", ")", "p", "=", "Ether", "(", "dst", "=", "tmac", ")", "/", "ARP", "(", "op", "=", "\"who-has\"", ",", "psrc", "="...
https://github.com/collinsctk/PyQYT/blob/7af3673955f94ff1b2df2f94220cd2dab2e252af/ExtentionPackages/scapy/layers/l2.py#L438-L451
jh0ker/mau_mau_bot
4021c1483e8bf0bc3f8c08fac6200345a15e6631
utils.py
python
error
(bot, update, error)
Simple error handler
Simple error handler
[ "Simple", "error", "handler" ]
def error(bot, update, error): """Simple error handler""" logger.exception(error)
[ "def", "error", "(", "bot", ",", "update", ",", "error", ")", ":", "logger", ".", "exception", "(", "error", ")" ]
https://github.com/jh0ker/mau_mau_bot/blob/4021c1483e8bf0bc3f8c08fac6200345a15e6631/utils.py#L80-L82
wistbean/learn_python3_spider
73c873f4845f4385f097e5057407d03dd37a117b
stackoverflow/venv/lib/python3.6/site-packages/twisted/mail/relay.py
python
ESMTPRelayer.__init__
(self, messagePaths, *args, **kw)
@type messagePaths: L{list} of L{bytes} @param messagePaths: The base filename for each message to be relayed. @type args: 3-L{tuple} of (0) L{bytes}, (1) L{None} or L{ClientContextFactory <twisted.internet.ssl.ClientContextFactory>}, (2) L{bytes} or 4-L{tuple} of (0) L{bytes}, (1) L{None} or L{ClientContextFactory <twisted.internet.ssl.ClientContextFactory>}, (2) L{bytes}, (3) L{int} @param args: Positional arguments for L{ESMTPClient.__init__} @type kw: L{dict} @param kw: Keyword arguments for L{ESMTPClient.__init__}
@type messagePaths: L{list} of L{bytes} @param messagePaths: The base filename for each message to be relayed.
[ "@type", "messagePaths", ":", "L", "{", "list", "}", "of", "L", "{", "bytes", "}", "@param", "messagePaths", ":", "The", "base", "filename", "for", "each", "message", "to", "be", "relayed", "." ]
def __init__(self, messagePaths, *args, **kw): """ @type messagePaths: L{list} of L{bytes} @param messagePaths: The base filename for each message to be relayed. @type args: 3-L{tuple} of (0) L{bytes}, (1) L{None} or L{ClientContextFactory <twisted.internet.ssl.ClientContextFactory>}, (2) L{bytes} or 4-L{tuple} of (0) L{bytes}, (1) L{None} or L{ClientContextFactory <twisted.internet.ssl.ClientContextFactory>}, (2) L{bytes}, (3) L{int} @param args: Positional arguments for L{ESMTPClient.__init__} @type kw: L{dict} @param kw: Keyword arguments for L{ESMTPClient.__init__} """ smtp.ESMTPClient.__init__(self, *args, **kw) self.loadMessages(messagePaths)
[ "def", "__init__", "(", "self", ",", "messagePaths", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "smtp", ".", "ESMTPClient", ".", "__init__", "(", "self", ",", "*", "args", ",", "*", "*", "kw", ")", "self", ".", "loadMessages", "(", "messagePa...
https://github.com/wistbean/learn_python3_spider/blob/73c873f4845f4385f097e5057407d03dd37a117b/stackoverflow/venv/lib/python3.6/site-packages/twisted/mail/relay.py#L162-L180
kamalkraj/ALBERT-TF2.0
8d0cc211361e81a648bf846d8ec84225273db0e4
tokenization.py
python
_is_whitespace
(char)
return False
Checks whether `chars` is a whitespace character.
Checks whether `chars` is a whitespace character.
[ "Checks", "whether", "chars", "is", "a", "whitespace", "character", "." ]
def _is_whitespace(char): """Checks whether `chars` is a whitespace character.""" # \t, \n, and \r are technically control characters but we treat them # as whitespace since they are generally considered as such. if char == " " or char == "\t" or char == "\n" or char == "\r": return True cat = unicodedata.category(char) if cat == "Zs": return True return False
[ "def", "_is_whitespace", "(", "char", ")", ":", "# \\t, \\n, and \\r are technically control characters but we treat them", "# as whitespace since they are generally considered as such.", "if", "char", "==", "\" \"", "or", "char", "==", "\"\\t\"", "or", "char", "==", "\"\\n\"",...
https://github.com/kamalkraj/ALBERT-TF2.0/blob/8d0cc211361e81a648bf846d8ec84225273db0e4/tokenization.py#L462-L471
Tencent/GAutomator
0ac9f849d1ca2c59760a91c5c94d3db375a380cd
GAutomatorIos/build/lib/ga2/engine/unityEngine.py
python
UnityEngine.get_element_text
(self, element)
return ret
获取GameObject文字信息 NGUI控件则获取UILable、UIInput、GUIText组件上的文字信息 UGUI控件则获取Text、GUIText组件上的问题信息 :param element: 查找到的GameObject :Usage: >>>element=engine.find_element('/Canvas/Panel/Button') >>>text=engine.get_element_text(element) :return:文字内容 :raises WeTestInvaildArg,WeTestRuntimeError
获取GameObject文字信息 NGUI控件则获取UILable、UIInput、GUIText组件上的文字信息 UGUI控件则获取Text、GUIText组件上的问题信息 :param element: 查找到的GameObject
[ "获取GameObject文字信息", "NGUI控件则获取UILable、UIInput、GUIText组件上的文字信息", "UGUI控件则获取Text、GUIText组件上的问题信息", ":", "param", "element", ":", "查找到的GameObject" ]
def get_element_text(self, element): """ 获取GameObject文字信息 NGUI控件则获取UILable、UIInput、GUIText组件上的文字信息 UGUI控件则获取Text、GUIText组件上的问题信息 :param element: 查找到的GameObject :Usage: >>>element=engine.find_element('/Canvas/Panel/Button') >>>text=engine.get_element_text(element) :return:文字内容 :raises WeTestInvaildArg,WeTestRuntimeError """ if element is None: raise WeTestInvaildArg("Invalid Instance") ret = self.socket.send_command(Commands.GET_ELEMENT_TEXT, element.instance) return ret
[ "def", "get_element_text", "(", "self", ",", "element", ")", ":", "if", "element", "is", "None", ":", "raise", "WeTestInvaildArg", "(", "\"Invalid Instance\"", ")", "ret", "=", "self", ".", "socket", ".", "send_command", "(", "Commands", ".", "GET_ELEMENT_TEXT...
https://github.com/Tencent/GAutomator/blob/0ac9f849d1ca2c59760a91c5c94d3db375a380cd/GAutomatorIos/build/lib/ga2/engine/unityEngine.py#L126-L142
pypa/pip
7f8a6844037fb7255cfd0d34ff8e8cf44f2598d4
src/pip/_vendor/rich/markup.py
python
escape
( markup: str, _escape: _EscapeSubMethod = re.compile(r"(\\*)(\[[a-z#\/].*?\])").sub )
return markup
Escapes text so that it won't be interpreted as markup. Args: markup (str): Content to be inserted in to markup. Returns: str: Markup with square brackets escaped.
Escapes text so that it won't be interpreted as markup.
[ "Escapes", "text", "so", "that", "it", "won", "t", "be", "interpreted", "as", "markup", "." ]
def escape( markup: str, _escape: _EscapeSubMethod = re.compile(r"(\\*)(\[[a-z#\/].*?\])").sub ) -> str: """Escapes text so that it won't be interpreted as markup. Args: markup (str): Content to be inserted in to markup. Returns: str: Markup with square brackets escaped. """ def escape_backslashes(match: Match[str]) -> str: """Called by re.sub replace matches.""" backslashes, text = match.groups() return f"{backslashes}{backslashes}\\{text}" markup = _escape(escape_backslashes, markup) return markup
[ "def", "escape", "(", "markup", ":", "str", ",", "_escape", ":", "_EscapeSubMethod", "=", "re", ".", "compile", "(", "r\"(\\\\*)(\\[[a-z#\\/].*?\\])\"", ")", ".", "sub", ")", "->", "str", ":", "def", "escape_backslashes", "(", "match", ":", "Match", "[", "...
https://github.com/pypa/pip/blob/7f8a6844037fb7255cfd0d34ff8e8cf44f2598d4/src/pip/_vendor/rich/markup.py#L49-L67
inducer/pycuda
9f3b898ec0846e2a4dff5077d4403ea03b1fccf9
pycuda/driver.py
python
Out.post_call
(self, stream)
[]
def post_call(self, stream): if stream is not None: memcpy_dtoh(self.array, self.get_device_alloc()) else: memcpy_dtoh(self.array, self.get_device_alloc())
[ "def", "post_call", "(", "self", ",", "stream", ")", ":", "if", "stream", "is", "not", "None", ":", "memcpy_dtoh", "(", "self", ".", "array", ",", "self", ".", "get_device_alloc", "(", ")", ")", "else", ":", "memcpy_dtoh", "(", "self", ".", "array", ...
https://github.com/inducer/pycuda/blob/9f3b898ec0846e2a4dff5077d4403ea03b1fccf9/pycuda/driver.py#L151-L155
DetectionTeamUCAS/RetinaNet_Tensorflow_Rotation
ee5e8b6a1ac9fa51dfa5b9a5c40a663927b2ac53
data/io/read_tfrecord.py
python
read_and_prepocess_single_img
(filename_queue, shortside_len, is_training)
return img_name, img, gtboxes_and_label, num_objects
[]
def read_and_prepocess_single_img(filename_queue, shortside_len, is_training): img_name, img, gtboxes_and_label, num_objects = read_single_example_and_decode(filename_queue) img = tf.cast(img, tf.float32) if is_training: img, gtboxes_and_label = image_preprocess.short_side_resize(img_tensor=img, gtboxes_and_label=gtboxes_and_label, target_shortside_len=shortside_len, length_limitation=cfgs.IMG_MAX_LENGTH) img, gtboxes_and_label = image_preprocess.random_flip_left_right(img_tensor=img, gtboxes_and_label=gtboxes_and_label) else: img, gtboxes_and_label = image_preprocess.short_side_resize(img_tensor=img, gtboxes_and_label=gtboxes_and_label, target_shortside_len=shortside_len, length_limitation=cfgs.IMG_MAX_LENGTH) if cfgs.NET_NAME in ['resnet152_v1d', 'resnet101_v1d', 'resnet50_v1d']: img = img / 255 - tf.constant([[cfgs.PIXEL_MEAN_]]) else: img = img - tf.constant([[cfgs.PIXEL_MEAN]]) # sub pixel mean at last return img_name, img, gtboxes_and_label, num_objects
[ "def", "read_and_prepocess_single_img", "(", "filename_queue", ",", "shortside_len", ",", "is_training", ")", ":", "img_name", ",", "img", ",", "gtboxes_and_label", ",", "num_objects", "=", "read_single_example_and_decode", "(", "filename_queue", ")", "img", "=", "tf"...
https://github.com/DetectionTeamUCAS/RetinaNet_Tensorflow_Rotation/blob/ee5e8b6a1ac9fa51dfa5b9a5c40a663927b2ac53/data/io/read_tfrecord.py#L46-L67
pjkundert/cpppo
4c217b6c06b88bede3888cc5ea2731f271a95086
server/network.py
python
bench
( server_func, client_func, client_count, server_kwds=None, client_kwds=None, client_max=10, server_join_timeout=1.0 )
Bench-test the server_func (with optional keyword args from server_kwds) as a process; will fail if one already bound to port. Creates a thread pool (default 10) of client_func. Each client is supplied a unique number argument, and the supplied client_kwds as keywords, and should return 0 on success, !0 on failure. Both threading.Thread and multiprocessing.Process work fine for running a bench server. However, Thread needs to use the out-of-band means to force server_main termination (since we can't terminate a Thread). This is implemented as a container (eg. dict-based cpppo.apidict) containing a done signal.
Bench-test the server_func (with optional keyword args from server_kwds) as a process; will fail if one already bound to port. Creates a thread pool (default 10) of client_func. Each client is supplied a unique number argument, and the supplied client_kwds as keywords, and should return 0 on success, !0 on failure.
[ "Bench", "-", "test", "the", "server_func", "(", "with", "optional", "keyword", "args", "from", "server_kwds", ")", "as", "a", "process", ";", "will", "fail", "if", "one", "already", "bound", "to", "port", ".", "Creates", "a", "thread", "pool", "(", "def...
def bench( server_func, client_func, client_count, server_kwds=None, client_kwds=None, client_max=10, server_join_timeout=1.0 ): """Bench-test the server_func (with optional keyword args from server_kwds) as a process; will fail if one already bound to port. Creates a thread pool (default 10) of client_func. Each client is supplied a unique number argument, and the supplied client_kwds as keywords, and should return 0 on success, !0 on failure. Both threading.Thread and multiprocessing.Process work fine for running a bench server. However, Thread needs to use the out-of-band means to force server_main termination (since we can't terminate a Thread). This is implemented as a container (eg. dict-based cpppo.apidict) containing a done signal. """ # Either multiprocessing.Process or threading.Thread will work as Process for the Server from multiprocessing import Process #from threading import Thread as Process # Only multiprocessing.pool.ThreadPool works, as we cannot serialize some client API objects from multiprocessing.pool import ThreadPool as Pool #from multiprocessing.dummy import Pool #from multiprocessing import Pool log.normal( "Server %r startup...", misc.function_name( server_func )) server = Process( target=server_func, kwargs=server_kwds or {} ) server.daemon = True server.start() time.sleep( .25 ) try: log.normal( "Client %r tests begin, over %d clients (up to %d simultaneously)", misc.function_name( client_func ), client_count, client_max ) pool = Pool( processes=client_max ) # Use list comprehension instead of generator, to force start of all asyncs! asyncs = [ pool.apply_async( client_func, args=(i,), kwds=client_kwds or {} ) for i in range( client_count )] log.normal( "Client %r started %d times in Pool; harvesting results", misc.function_name( client_func ), client_count ) successes = 0 for a in asyncs: try: result = a.get() successes += 1 if not result else 0 if result: log.warning( "Client failed w/ non-0 result: %s", result ) except Exception as exc: log.exception( "Client failed w/ Exception: %s", exc ) failures = client_count - successes log.normal( "Client %r tests done: %d/%d succeeded (%d failures)", misc.function_name( client_func ), successes, client_count, failures ) return failures finally: # Shut down server; use 'server.control.done = true' to stop server, if # available in server_kwds. If this doesn't work, we can try terminate control = server_kwds.get( 'server', {} ).get( 'control', {} ) if server_kwds else {} if 'done' in control: log.normal( "Server %r done signalled", misc.function_name( server_func )) control['done'] = True # only useful for threading.Thread; Process cannot see this if hasattr( server, 'terminate' ): log.normal( "Server %r done via .terminate()", misc.function_name( server_func )) server.terminate() # only if using multiprocessing.Process(); Thread doesn't have server.join( timeout=server_join_timeout ) if server.is_alive(): log.warning( "Server %r remains running...", misc.function_name( server_func )) else: log.normal( "Server %r stopped.", misc.function_name( server_func ))
[ "def", "bench", "(", "server_func", ",", "client_func", ",", "client_count", ",", "server_kwds", "=", "None", ",", "client_kwds", "=", "None", ",", "client_max", "=", "10", ",", "server_join_timeout", "=", "1.0", ")", ":", "# Either multiprocessing.Process or thre...
https://github.com/pjkundert/cpppo/blob/4c217b6c06b88bede3888cc5ea2731f271a95086/server/network.py#L429-L497
deepmind/dm_control
806a10e896e7c887635328bfa8352604ad0fedae
dm_control/locomotion/props/target_sphere.py
python
TargetSphere.geom
(self)
return self._geom
[]
def geom(self): return self._geom
[ "def", "geom", "(", "self", ")", ":", "return", "self", ".", "_geom" ]
https://github.com/deepmind/dm_control/blob/806a10e896e7c887635328bfa8352604ad0fedae/dm_control/locomotion/props/target_sphere.py#L68-L69
openshift/openshift-tools
1188778e728a6e4781acf728123e5b356380fe6f
openshift/installer/vendored/openshift-ansible-3.9.14-1/roles/lib_utils/src/class/yedit.py
python
Yedit.append
(self, path, value)
return (True, self.yaml_dict)
append value to a list
append value to a list
[ "append", "value", "to", "a", "list" ]
def append(self, path, value): '''append value to a list''' try: entry = Yedit.get_entry(self.yaml_dict, path, self.separator) except KeyError: entry = None if entry is None: self.put(path, []) entry = Yedit.get_entry(self.yaml_dict, path, self.separator) if not isinstance(entry, list): return (False, self.yaml_dict) # AUDIT:maybe-no-member makes sense due to loading data from # a serialized format. # pylint: disable=maybe-no-member entry.append(value) return (True, self.yaml_dict)
[ "def", "append", "(", "self", ",", "path", ",", "value", ")", ":", "try", ":", "entry", "=", "Yedit", ".", "get_entry", "(", "self", ".", "yaml_dict", ",", "path", ",", "self", ".", "separator", ")", "except", "KeyError", ":", "entry", "=", "None", ...
https://github.com/openshift/openshift-tools/blob/1188778e728a6e4781acf728123e5b356380fe6f/openshift/installer/vendored/openshift-ansible-3.9.14-1/roles/lib_utils/src/class/yedit.py#L392-L409
arizvisa/ida-minsc
8627a60f047b5e55d3efeecde332039cd1a16eea
base/structure.py
python
member_t.__unicode__
(self)
return u"<member '{:s}' index={:d} offset={:-#x} size={:+#x}{:s}>{:s}".format(utils.string.escape(name, '\''), self.index, self.offset, self.size, " typeinfo='{:s}'".format(typeinfo) if len("{:s}".format(typeinfo)) else '', " // {!s}".format(utils.string.repr(tag) if '\n' in comment else utils.string.to(comment)) if comment else '')
Render the current member in a readable format.
Render the current member in a readable format.
[ "Render", "the", "current", "member", "in", "a", "readable", "format", "." ]
def __unicode__(self): '''Render the current member in a readable format.''' id, name, typ, comment, tag, typeinfo = self.id, self.fullname, self.type, self.comment or '', self.tag(), "{!s}".format(self.typeinfo.dstr()).replace(' *', '*') return u"<member '{:s}' index={:d} offset={:-#x} size={:+#x}{:s}>{:s}".format(utils.string.escape(name, '\''), self.index, self.offset, self.size, " typeinfo='{:s}'".format(typeinfo) if len("{:s}".format(typeinfo)) else '', " // {!s}".format(utils.string.repr(tag) if '\n' in comment else utils.string.to(comment)) if comment else '')
[ "def", "__unicode__", "(", "self", ")", ":", "id", ",", "name", ",", "typ", ",", "comment", ",", "tag", ",", "typeinfo", "=", "self", ".", "id", ",", "self", ".", "fullname", ",", "self", ".", "type", ",", "self", ".", "comment", "or", "''", ",",...
https://github.com/arizvisa/ida-minsc/blob/8627a60f047b5e55d3efeecde332039cd1a16eea/base/structure.py#L2267-L2270
mittagessen/kraken
9882ba0743797a2d5b0a7b562fcc7235e87323da
kraken/lib/codec.py
python
PytorchCodec.merge
(self, codec: 'PytorchCodec')
return PytorchCodec(c2l_cand, self.strict), set(rm_labels)
Transforms this codec (c1) into another (c2) reusing as many labels as possible. The resulting codec is able to encode the same code point sequences while not necessarily having the same labels for them as c2. Retains matching character -> label mappings from both codecs, removes mappings not c2, and adds mappings not in c1. Compound labels in c2 for code point sequences not in c1 containing labels also in use in c1 are added as separate labels. Args: codec (kraken.lib.codec.PytorchCodec): Returns: A merged codec and a list of labels that were removed from the original codec.
Transforms this codec (c1) into another (c2) reusing as many labels as possible.
[ "Transforms", "this", "codec", "(", "c1", ")", "into", "another", "(", "c2", ")", "reusing", "as", "many", "labels", "as", "possible", "." ]
def merge(self, codec: 'PytorchCodec') -> Tuple['PytorchCodec', Set]: """ Transforms this codec (c1) into another (c2) reusing as many labels as possible. The resulting codec is able to encode the same code point sequences while not necessarily having the same labels for them as c2. Retains matching character -> label mappings from both codecs, removes mappings not c2, and adds mappings not in c1. Compound labels in c2 for code point sequences not in c1 containing labels also in use in c1 are added as separate labels. Args: codec (kraken.lib.codec.PytorchCodec): Returns: A merged codec and a list of labels that were removed from the original codec. """ # find character sequences not encodable (exact match) by new codec. # get labels for these sequences as deletion candidates rm_candidates = {cseq: enc for cseq, enc in self.c2l.items() if cseq not in codec.c2l} c2l_cand = self.c2l.copy() for x in rm_candidates.keys(): c2l_cand.pop(x) # remove labels from candidate list that are in use for other decodings rm_labels = [label for v in rm_candidates.values() for label in v] for v in c2l_cand.values(): for label in rm_labels: if label in v: rm_labels.remove(label) # iteratively remove labels, decrementing subsequent labels to close # (new) holes in the codec. offset_rm_labels = [v-idx for idx, v in enumerate(sorted(set(rm_labels)))] for rlabel in offset_rm_labels: c2l_cand = {k: [label-1 if label > rlabel else label for label in v] for k, v in c2l_cand.items()} # add mappings not in original codec add_list = {cseq: enc for cseq, enc in codec.c2l.items() if cseq not in self.c2l} # renumber start_idx = max((0,) + tuple(label for v in c2l_cand.values() for label in v)) + 1 add_labels = {k: v for v, k in enumerate(sorted(set(label for v in add_list.values() for label in v)), start_idx)} for k, v in add_list.items(): c2l_cand[k] = [add_labels[label] for label in v] return PytorchCodec(c2l_cand, self.strict), set(rm_labels)
[ "def", "merge", "(", "self", ",", "codec", ":", "'PytorchCodec'", ")", "->", "Tuple", "[", "'PytorchCodec'", ",", "Set", "]", ":", "# find character sequences not encodable (exact match) by new codec.", "# get labels for these sequences as deletion candidates", "rm_candidates",...
https://github.com/mittagessen/kraken/blob/9882ba0743797a2d5b0a7b562fcc7235e87323da/kraken/lib/codec.py#L173-L216
google/grr
8ad8a4d2c5a93c92729206b7771af19d92d4f915
grr/core/grr_response_core/lib/rdfvalues/structs.py
python
ProtoType.__init__
(self, field_number=None, required=False, labels=None, set_default_on_access=None, **kwargs)
[]
def __init__(self, field_number=None, required=False, labels=None, set_default_on_access=None, **kwargs): super().__init__(**kwargs) # TODO: Without this type hint, pytype thinks that field_number # is always None. self.field_number = field_number # type: int self.required = required if set_default_on_access is not None: self.set_default_on_access = set_default_on_access self.labels = labels or [] if self.field_number is None: raise type_info.TypeValueError("No valid field number specified.") self.CalculateTags()
[ "def", "__init__", "(", "self", ",", "field_number", "=", "None", ",", "required", "=", "False", ",", "labels", "=", "None", ",", "set_default_on_access", "=", "None", ",", "*", "*", "kwargs", ")", ":", "super", "(", ")", ".", "__init__", "(", "*", "...
https://github.com/google/grr/blob/8ad8a4d2c5a93c92729206b7771af19d92d4f915/grr/core/grr_response_core/lib/rdfvalues/structs.py#L187-L205
P1sec/pycrate
d12bbccf1df8c9c7891a26967a9d2635610ec5b8
pycrate_core/elt.py
python
Sequence.clear
(self)
Clear the content of self Args: None Returns: None
Clear the content of self Args: None Returns: None
[ "Clear", "the", "content", "of", "self", "Args", ":", "None", "Returns", ":", "None" ]
def clear(self): """Clear the content of self Args: None Returns: None """ if python_version < 3: del self._content[:] else: self._content.clear()
[ "def", "clear", "(", "self", ")", ":", "if", "python_version", "<", "3", ":", "del", "self", ".", "_content", "[", ":", "]", "else", ":", "self", ".", "_content", ".", "clear", "(", ")" ]
https://github.com/P1sec/pycrate/blob/d12bbccf1df8c9c7891a26967a9d2635610ec5b8/pycrate_core/elt.py#L3961-L3973
git-cola/git-cola
b48b8028e0c3baf47faf7b074b9773737358163d
cola/widgets/branch.py
python
TreeEntry.__init__
(self, basename, refname, children)
[]
def __init__(self, basename, refname, children): self.basename = basename self.refname = refname self.children = children
[ "def", "__init__", "(", "self", ",", "basename", ",", "refname", ",", "children", ")", ":", "self", ".", "basename", "=", "basename", "self", ".", "refname", "=", "refname", "self", ".", "children", "=", "children" ]
https://github.com/git-cola/git-cola/blob/b48b8028e0c3baf47faf7b074b9773737358163d/cola/widgets/branch.py#L504-L507
JetBrains/python-skeletons
95ad24b666e475998e5d1cc02ed53a2188036167
__builtin__.py
python
locals
()
return {}
Update and return a dictionary containing the current scope's local variables. :rtype: dict[string, unknown]
Update and return a dictionary containing the current scope's local variables.
[ "Update", "and", "return", "a", "dictionary", "containing", "the", "current", "scope", "s", "local", "variables", "." ]
def locals(): """Update and return a dictionary containing the current scope's local variables. :rtype: dict[string, unknown] """ return {}
[ "def", "locals", "(", ")", ":", "return", "{", "}" ]
https://github.com/JetBrains/python-skeletons/blob/95ad24b666e475998e5d1cc02ed53a2188036167/__builtin__.py#L192-L198
lensacom/sparkit-learn
0498502107c1f7dcf33cda0cdb6f5ba4b42524b7
splearn/feature_selection/variance_threshold.py
python
SparkVarianceThreshold.transform
(self, Z)
return Z.transform(mapper, column='X')
Reduce X to the selected features. Parameters ---------- X : array of shape [n_samples, n_features] The input samples. Returns ------- X_r : array of shape [n_samples, n_selected_features] The input samples with only the selected features.
Reduce X to the selected features.
[ "Reduce", "X", "to", "the", "selected", "features", "." ]
def transform(self, Z): """Reduce X to the selected features. Parameters ---------- X : array of shape [n_samples, n_features] The input samples. Returns ------- X_r : array of shape [n_samples, n_selected_features] The input samples with only the selected features. """ X = Z[:, 'X'] if isinstance(Z, DictRDD) else Z check_rdd(X, (np.ndarray, sp.spmatrix)) mapper = self.broadcast( super(SparkVarianceThreshold, self).transform, Z.context) return Z.transform(mapper, column='X')
[ "def", "transform", "(", "self", ",", "Z", ")", ":", "X", "=", "Z", "[", ":", ",", "'X'", "]", "if", "isinstance", "(", "Z", ",", "DictRDD", ")", "else", "Z", "check_rdd", "(", "X", ",", "(", "np", ".", "ndarray", ",", "sp", ".", "spmatrix", ...
https://github.com/lensacom/sparkit-learn/blob/0498502107c1f7dcf33cda0cdb6f5ba4b42524b7/splearn/feature_selection/variance_threshold.py#L95-L113
TensorLab/tensorfx
98a91b1d9e657f9444b6140712a5dedcdd906acf
src/data/_ds_csv.py
python
CsvDataSource.path
(self)
return self._path
Retrives the path represented by the DataSource.
Retrives the path represented by the DataSource.
[ "Retrives", "the", "path", "represented", "by", "the", "DataSource", "." ]
def path(self): """Retrives the path represented by the DataSource. """ return self._path
[ "def", "path", "(", "self", ")", ":", "return", "self", ".", "_path" ]
https://github.com/TensorLab/tensorfx/blob/98a91b1d9e657f9444b6140712a5dedcdd906acf/src/data/_ds_csv.py#L75-L78
kornia/kornia
b12d6611b1c41d47b2c93675f0ea344b5314a688
kornia/metrics/mean_iou.py
python
mean_iou_bbox
(boxes_1: torch.Tensor, boxes_2: torch.Tensor)
return intersection / union
Compute the IoU of the cartisian product of two sets of boxes. Each box in each set shall be (x1, y1, x2, y2). Args: boxes_1: a tensor of bounding boxes in :math:`(B1, 4)`. boxes_2: a tensor of bounding boxes in :math:`(B2, 4)`. Returns: a tensor in dimensions :math:`(B1, B2)`, representing the intersection of each of the boxes in set 1 with respect to each of the boxes in set 2. Example: >>> boxes_1 = torch.tensor([[40, 40, 60, 60], [30, 40, 50, 60]]) >>> boxes_2 = torch.tensor([[40, 50, 60, 70], [30, 40, 40, 50]]) >>> mean_iou_bbox(boxes_1, boxes_2) tensor([[0.3333, 0.0000], [0.1429, 0.2500]])
Compute the IoU of the cartisian product of two sets of boxes.
[ "Compute", "the", "IoU", "of", "the", "cartisian", "product", "of", "two", "sets", "of", "boxes", "." ]
def mean_iou_bbox(boxes_1: torch.Tensor, boxes_2: torch.Tensor) -> torch.Tensor: """Compute the IoU of the cartisian product of two sets of boxes. Each box in each set shall be (x1, y1, x2, y2). Args: boxes_1: a tensor of bounding boxes in :math:`(B1, 4)`. boxes_2: a tensor of bounding boxes in :math:`(B2, 4)`. Returns: a tensor in dimensions :math:`(B1, B2)`, representing the intersection of each of the boxes in set 1 with respect to each of the boxes in set 2. Example: >>> boxes_1 = torch.tensor([[40, 40, 60, 60], [30, 40, 50, 60]]) >>> boxes_2 = torch.tensor([[40, 50, 60, 70], [30, 40, 40, 50]]) >>> mean_iou_bbox(boxes_1, boxes_2) tensor([[0.3333, 0.0000], [0.1429, 0.2500]]) """ # TODO: support more box types. e.g. xywh, if not (((boxes_1[:, 2] - boxes_1[:, 0]) > 0).all() or ((boxes_1[:, 3] - boxes_1[:, 1]) > 0).all()): raise AssertionError("Boxes_1 does not follow (x1, y1, x2, y2) format.") if not (((boxes_2[:, 2] - boxes_2[:, 0]) > 0).all() or ((boxes_2[:, 3] - boxes_2[:, 1]) > 0).all()): raise AssertionError("Boxes_2 does not follow (x1, y1, x2, y2) format.") # find intersection lower_bounds = torch.max(boxes_1[:, :2].unsqueeze(1), boxes_2[:, :2].unsqueeze(0)) # (n1, n2, 2) upper_bounds = torch.min(boxes_1[:, 2:].unsqueeze(1), boxes_2[:, 2:].unsqueeze(0)) # (n1, n2, 2) intersection_dims = torch.clamp(upper_bounds - lower_bounds, min=0) # (n1, n2, 2) intersection = intersection_dims[:, :, 0] * intersection_dims[:, :, 1] # (n1, n2) # Find areas of each box in both sets areas_set_1 = (boxes_1[:, 2] - boxes_1[:, 0]) * (boxes_1[:, 3] - boxes_1[:, 1]) # (n1) areas_set_2 = (boxes_2[:, 2] - boxes_2[:, 0]) * (boxes_2[:, 3] - boxes_2[:, 1]) # (n2) # Find the union # PyTorch auto-broadcasts singleton dimensions union = areas_set_1.unsqueeze(1) + areas_set_2.unsqueeze(0) - intersection # (n1, n2) return intersection / union
[ "def", "mean_iou_bbox", "(", "boxes_1", ":", "torch", ".", "Tensor", ",", "boxes_2", ":", "torch", ".", "Tensor", ")", "->", "torch", ".", "Tensor", ":", "# TODO: support more box types. e.g. xywh,", "if", "not", "(", "(", "(", "boxes_1", "[", ":", ",", "2...
https://github.com/kornia/kornia/blob/b12d6611b1c41d47b2c93675f0ea344b5314a688/kornia/metrics/mean_iou.py#L63-L102
google/clusterfuzz
f358af24f414daa17a3649b143e71ea71871ef59
src/clusterfuzz/_internal/bot/tasks/regression_task.py
python
_testcase_reproduces_in_revision
(testcase, testcase_file_path, job_type, revision, should_log=True, min_revision=None, max_revision=None)
return result.is_crash()
Test to see if a test case reproduces in the specified revision.
Test to see if a test case reproduces in the specified revision.
[ "Test", "to", "see", "if", "a", "test", "case", "reproduces", "in", "the", "specified", "revision", "." ]
def _testcase_reproduces_in_revision(testcase, testcase_file_path, job_type, revision, should_log=True, min_revision=None, max_revision=None): """Test to see if a test case reproduces in the specified revision.""" if should_log: log_message = 'Testing r%d' % revision if min_revision is not None and max_revision is not None: log_message += ' (current range %d:%d)' % (min_revision, max_revision) testcase = data_handler.get_testcase_by_id(testcase.key.id()) data_handler.update_testcase_comment(testcase, data_types.TaskState.WIP, log_message) build_manager.setup_build(revision) if not build_manager.check_app_path(): raise errors.BuildSetupError(revision, job_type) if testcase_manager.check_for_bad_build(job_type, revision): log_message = 'Bad build at r%d. Skipping' % revision testcase = data_handler.get_testcase_by_id(testcase.key.id()) data_handler.update_testcase_comment(testcase, data_types.TaskState.WIP, log_message) raise errors.BadBuildError(revision, job_type) test_timeout = environment.get_value('TEST_TIMEOUT', 10) result = testcase_manager.test_for_crash_with_retries( testcase, testcase_file_path, test_timeout, http_flag=testcase.http_flag) return result.is_crash()
[ "def", "_testcase_reproduces_in_revision", "(", "testcase", ",", "testcase_file_path", ",", "job_type", ",", "revision", ",", "should_log", "=", "True", ",", "min_revision", "=", "None", ",", "max_revision", "=", "None", ")", ":", "if", "should_log", ":", "log_m...
https://github.com/google/clusterfuzz/blob/f358af24f414daa17a3649b143e71ea71871ef59/src/clusterfuzz/_internal/bot/tasks/regression_task.py#L86-L117
foolwood/deepmask-pytorch
97b02aa29ce39b9e43144c89937dbead2a99adcc
tools/train.py
python
BinaryMeter.reset
(self)
[]
def reset(self): self.acc = 0 self.n = 0
[ "def", "reset", "(", "self", ")", ":", "self", ".", "acc", "=", "0", "self", ".", "n", "=", "0" ]
https://github.com/foolwood/deepmask-pytorch/blob/97b02aa29ce39b9e43144c89937dbead2a99adcc/tools/train.py#L103-L105
IronLanguages/ironpython3
7a7bb2a872eeab0d1009fc8a6e24dca43f65b693
Src/StdLib/Lib/inspect.py
python
stack
(context=1)
return getouterframes(sys._getframe(1), context)
Return a list of records for the stack above the caller's frame.
Return a list of records for the stack above the caller's frame.
[ "Return", "a", "list", "of", "records", "for", "the", "stack", "above", "the", "caller", "s", "frame", "." ]
def stack(context=1): """Return a list of records for the stack above the caller's frame.""" return getouterframes(sys._getframe(1), context)
[ "def", "stack", "(", "context", "=", "1", ")", ":", "return", "getouterframes", "(", "sys", ".", "_getframe", "(", "1", ")", ",", "context", ")" ]
https://github.com/IronLanguages/ironpython3/blob/7a7bb2a872eeab0d1009fc8a6e24dca43f65b693/Src/StdLib/Lib/inspect.py#L1346-L1348
google-research/albert
932b41f0319fbef7efd069d5ff545e3358574e19
modeling.py
python
einsum_via_matmul
(input_tensor, w, num_inner_dims)
return ret
Implements einsum via matmul and reshape ops. Args: input_tensor: float Tensor of shape [<batch_dims>, <inner_dims>]. w: float Tensor of shape [<inner_dims>, <outer_dims>]. num_inner_dims: int. number of dimensions to use for inner products. Returns: float Tensor of shape [<batch_dims>, <outer_dims>].
Implements einsum via matmul and reshape ops.
[ "Implements", "einsum", "via", "matmul", "and", "reshape", "ops", "." ]
def einsum_via_matmul(input_tensor, w, num_inner_dims): """Implements einsum via matmul and reshape ops. Args: input_tensor: float Tensor of shape [<batch_dims>, <inner_dims>]. w: float Tensor of shape [<inner_dims>, <outer_dims>]. num_inner_dims: int. number of dimensions to use for inner products. Returns: float Tensor of shape [<batch_dims>, <outer_dims>]. """ input_shape = get_shape_list(input_tensor) w_shape = get_shape_list(w) batch_dims = input_shape[: -num_inner_dims] inner_dims = input_shape[-num_inner_dims:] outer_dims = w_shape[num_inner_dims:] inner_dim = np.prod(inner_dims) outer_dim = np.prod(outer_dims) if num_inner_dims > 1: input_tensor = tf.reshape(input_tensor, batch_dims + [inner_dim]) if len(w_shape) > 2: w = tf.reshape(w, [inner_dim, outer_dim]) ret = tf.matmul(input_tensor, w) if len(outer_dims) > 1: ret = tf.reshape(ret, batch_dims + outer_dims) return ret
[ "def", "einsum_via_matmul", "(", "input_tensor", ",", "w", ",", "num_inner_dims", ")", ":", "input_shape", "=", "get_shape_list", "(", "input_tensor", ")", "w_shape", "=", "get_shape_list", "(", "w", ")", "batch_dims", "=", "input_shape", "[", ":", "-", "num_i...
https://github.com/google-research/albert/blob/932b41f0319fbef7efd069d5ff545e3358574e19/modeling.py#L632-L657
jgagneastro/coffeegrindsize
22661ebd21831dba4cf32bfc6ba59fe3d49f879c
App/venv/lib/python3.7/site-packages/pip/_vendor/distlib/locators.py
python
DependencyFinder.__init__
(self, locator=None)
Initialise an instance, using the specified locator to locate distributions.
Initialise an instance, using the specified locator to locate distributions.
[ "Initialise", "an", "instance", "using", "the", "specified", "locator", "to", "locate", "distributions", "." ]
def __init__(self, locator=None): """ Initialise an instance, using the specified locator to locate distributions. """ self.locator = locator or default_locator self.scheme = get_scheme(self.locator.scheme)
[ "def", "__init__", "(", "self", ",", "locator", "=", "None", ")", ":", "self", ".", "locator", "=", "locator", "or", "default_locator", "self", ".", "scheme", "=", "get_scheme", "(", "self", ".", "locator", ".", "scheme", ")" ]
https://github.com/jgagneastro/coffeegrindsize/blob/22661ebd21831dba4cf32bfc6ba59fe3d49f879c/App/venv/lib/python3.7/site-packages/pip/_vendor/distlib/locators.py#L1066-L1072
triaquae/triaquae
bbabf736b3ba56a0c6498e7f04e16c13b8b8f2b9
TriAquae/models/Ubuntu_12/pyasn1/type/univ.py
python
SequenceAndSetBase.setDefaultComponents
(self)
[]
def setDefaultComponents(self): if self._componentTypeLen == self._componentValuesSet: return idx = self._componentTypeLen while idx: idx = idx - 1 if self._componentType[idx].isDefaulted: if self.getComponentByPosition(idx) is None: self.setComponentByPosition(idx) elif not self._componentType[idx].isOptional: if self.getComponentByPosition(idx) is None: raise error.PyAsn1Error( 'Uninitialized component #%s at %r' % (idx, self) )
[ "def", "setDefaultComponents", "(", "self", ")", ":", "if", "self", ".", "_componentTypeLen", "==", "self", ".", "_componentValuesSet", ":", "return", "idx", "=", "self", ".", "_componentTypeLen", "while", "idx", ":", "idx", "=", "idx", "-", "1", "if", "se...
https://github.com/triaquae/triaquae/blob/bbabf736b3ba56a0c6498e7f04e16c13b8b8f2b9/TriAquae/models/Ubuntu_12/pyasn1/type/univ.py#L806-L819
IBM/lale
b4d6829c143a4735b06083a0e6c70d2cca244162
lale/type_checking.py
python
_validate_subschema
( sub: JSON_TYPE, sup: JSON_TYPE, sub_name="sub", sup_name="super" )
[]
def _validate_subschema( sub: JSON_TYPE, sup: JSON_TYPE, sub_name="sub", sup_name="super" ): if not is_subschema(sub, sup): raise SubschemaError(sub, sup, sub_name, sup_name)
[ "def", "_validate_subschema", "(", "sub", ":", "JSON_TYPE", ",", "sup", ":", "JSON_TYPE", ",", "sub_name", "=", "\"sub\"", ",", "sup_name", "=", "\"super\"", ")", ":", "if", "not", "is_subschema", "(", "sub", ",", "sup", ")", ":", "raise", "SubschemaError"...
https://github.com/IBM/lale/blob/b4d6829c143a4735b06083a0e6c70d2cca244162/lale/type_checking.py#L250-L254
gitpython-developers/GitPython
fac603789d66c0fd7c26e75debb41b06136c5026
git/index/base.py
python
IndexFile._delete_entries_cache
(self)
Safely clear the entries cache so it can be recreated
Safely clear the entries cache so it can be recreated
[ "Safely", "clear", "the", "entries", "cache", "so", "it", "can", "be", "recreated" ]
def _delete_entries_cache(self) -> None: """Safely clear the entries cache so it can be recreated""" try: del(self.entries) except AttributeError: # fails in python 2.6.5 with this exception pass
[ "def", "_delete_entries_cache", "(", "self", ")", "->", "None", ":", "try", ":", "del", "(", "self", ".", "entries", ")", "except", "AttributeError", ":", "# fails in python 2.6.5 with this exception", "pass" ]
https://github.com/gitpython-developers/GitPython/blob/fac603789d66c0fd7c26e75debb41b06136c5026/git/index/base.py#L158-L164
mesalock-linux/mesapy
ed546d59a21b36feb93e2309d5c6b75aa0ad95c9
lib-python/2.7/lib2to3/pgen2/grammar.py
python
Grammar.report
(self)
Dump the grammar tables to standard output, for debugging.
Dump the grammar tables to standard output, for debugging.
[ "Dump", "the", "grammar", "tables", "to", "standard", "output", "for", "debugging", "." ]
def report(self): """Dump the grammar tables to standard output, for debugging.""" from pprint import pprint print "s2n" pprint(self.symbol2number) print "n2s" pprint(self.number2symbol) print "states" pprint(self.states) print "dfas" pprint(self.dfas) print "labels" pprint(self.labels) print "start", self.start
[ "def", "report", "(", "self", ")", ":", "from", "pprint", "import", "pprint", "print", "\"s2n\"", "pprint", "(", "self", ".", "symbol2number", ")", "print", "\"n2s\"", "pprint", "(", "self", ".", "number2symbol", ")", "print", "\"states\"", "pprint", "(", ...
https://github.com/mesalock-linux/mesapy/blob/ed546d59a21b36feb93e2309d5c6b75aa0ad95c9/lib-python/2.7/lib2to3/pgen2/grammar.py#L125-L138
SciTools/iris
a12d0b15bab3377b23a148e891270b13a0419c38
lib/iris/_merge.py
python
_is_dependent
(dependent, independent, positions, function_mapping=None)
return valid
Determine whether there exists a one-to-one functional relationship between the independent candidate dimension/s and the dependent candidate dimension. Args: * dependent: A candidate dimension that requires to be functionally dependent on all the independent candidate dimensions. * independent: A list of candidate dimension/s that require to act as the independent variables in a functional relationship. * positions: A list containing a dictionary of candidate dimension key to scalar value pairs for each source-cube. Kwargs: * function_mapping: A dictionary that enumerates a valid functional relationship between the dependent candidate dimension and the independent candidate dimension/s. Returns: Boolean.
Determine whether there exists a one-to-one functional relationship between the independent candidate dimension/s and the dependent candidate dimension.
[ "Determine", "whether", "there", "exists", "a", "one", "-", "to", "-", "one", "functional", "relationship", "between", "the", "independent", "candidate", "dimension", "/", "s", "and", "the", "dependent", "candidate", "dimension", "." ]
def _is_dependent(dependent, independent, positions, function_mapping=None): """ Determine whether there exists a one-to-one functional relationship between the independent candidate dimension/s and the dependent candidate dimension. Args: * dependent: A candidate dimension that requires to be functionally dependent on all the independent candidate dimensions. * independent: A list of candidate dimension/s that require to act as the independent variables in a functional relationship. * positions: A list containing a dictionary of candidate dimension key to scalar value pairs for each source-cube. Kwargs: * function_mapping: A dictionary that enumerates a valid functional relationship between the dependent candidate dimension and the independent candidate dimension/s. Returns: Boolean. """ valid = True relation = {} if isinstance(function_mapping, dict): relation = function_mapping for position in positions: item = tuple([position[name] for name in independent]) if item in relation: if position[dependent] != relation[item]: valid = False break else: relation[item] = position[dependent] return valid
[ "def", "_is_dependent", "(", "dependent", ",", "independent", ",", "positions", ",", "function_mapping", "=", "None", ")", ":", "valid", "=", "True", "relation", "=", "{", "}", "if", "isinstance", "(", "function_mapping", ",", "dict", ")", ":", "relation", ...
https://github.com/SciTools/iris/blob/a12d0b15bab3377b23a148e891270b13a0419c38/lib/iris/_merge.py#L783-L830
fortharris/Pcode
147962d160a834c219e12cb456abc130826468e4
pyflakes/checker.py
python
Checker.deferAssignment
(self, callable)
Schedule an assignment handler to be called just after deferred function handlers.
Schedule an assignment handler to be called just after deferred function handlers.
[ "Schedule", "an", "assignment", "handler", "to", "be", "called", "just", "after", "deferred", "function", "handlers", "." ]
def deferAssignment(self, callable): """ Schedule an assignment handler to be called just after deferred function handlers. """ self._deferredAssignments.append((callable, self.scopeStack[:], self.offset))
[ "def", "deferAssignment", "(", "self", ",", "callable", ")", ":", "self", ".", "_deferredAssignments", ".", "append", "(", "(", "callable", ",", "self", ".", "scopeStack", "[", ":", "]", ",", "self", ".", "offset", ")", ")" ]
https://github.com/fortharris/Pcode/blob/147962d160a834c219e12cb456abc130826468e4/pyflakes/checker.py#L318-L323
chromium/web-page-replay
472351e1122bb1beb936952c7e75ae58bf8a69f1
platformsettings.py
python
_BasePlatformSettings.timer
(self)
return time.time()
Return the current time in seconds as a floating point number.
Return the current time in seconds as a floating point number.
[ "Return", "the", "current", "time", "in", "seconds", "as", "a", "floating", "point", "number", "." ]
def timer(self): """Return the current time in seconds as a floating point number.""" return time.time()
[ "def", "timer", "(", "self", ")", ":", "return", "time", ".", "time", "(", ")" ]
https://github.com/chromium/web-page-replay/blob/472351e1122bb1beb936952c7e75ae58bf8a69f1/platformsettings.py#L169-L171
leo-editor/leo-editor
383d6776d135ef17d73d935a2f0ecb3ac0e99494
leo/commands/editCommands.py
python
EditCommandsClass.whatLine
(self, event)
Print the line number of the line containing the cursor.
Print the line number of the line containing the cursor.
[ "Print", "the", "line", "number", "of", "the", "line", "containing", "the", "cursor", "." ]
def whatLine(self, event): """Print the line number of the line containing the cursor.""" k = self.c.k w = self.editWidget(event) if w: s = w.getAllText() i = w.getInsertPoint() row, col = g.convertPythonIndexToRowCol(s, i) k.keyboardQuit() k.setStatusLabel(f"Line {row}")
[ "def", "whatLine", "(", "self", ",", "event", ")", ":", "k", "=", "self", ".", "c", ".", "k", "w", "=", "self", ".", "editWidget", "(", "event", ")", "if", "w", ":", "s", "=", "w", ".", "getAllText", "(", ")", "i", "=", "w", ".", "getInsertPo...
https://github.com/leo-editor/leo-editor/blob/383d6776d135ef17d73d935a2f0ecb3ac0e99494/leo/commands/editCommands.py#L1290-L1299
qhduan/just_another_seq2seq
ac9be1b1599c05e0802824afa8a351dcb9ba936e
rnn_crf.py
python
RNNCRF.build_single_cell
(self, n_hidden, use_residual)
return cell
构建一个单独的rnn cell Args: n_hidden: 隐藏层神经元数量 use_residual: 是否使用residual wrapper
构建一个单独的rnn cell Args: n_hidden: 隐藏层神经元数量 use_residual: 是否使用residual wrapper
[ "构建一个单独的rnn", "cell", "Args", ":", "n_hidden", ":", "隐藏层神经元数量", "use_residual", ":", "是否使用residual", "wrapper" ]
def build_single_cell(self, n_hidden, use_residual): """构建一个单独的rnn cell Args: n_hidden: 隐藏层神经元数量 use_residual: 是否使用residual wrapper """ cell_type = LSTMCell if self.cell_type.lower() == 'gru': cell_type = GRUCell cell = cell_type(n_hidden) if self.use_dropout: cell = DropoutWrapper( cell, dtype=tf.float32, output_keep_prob=self.keep_prob_placeholder, seed=self.seed ) if use_residual: cell = ResidualWrapper(cell) return cell
[ "def", "build_single_cell", "(", "self", ",", "n_hidden", ",", "use_residual", ")", ":", "cell_type", "=", "LSTMCell", "if", "self", ".", "cell_type", ".", "lower", "(", ")", "==", "'gru'", ":", "cell_type", "=", "GRUCell", "cell", "=", "cell_type", "(", ...
https://github.com/qhduan/just_another_seq2seq/blob/ac9be1b1599c05e0802824afa8a351dcb9ba936e/rnn_crf.py#L247-L268
dropbox/dropbox-sdk-python
015437429be224732990041164a21a0501235db1
dropbox/sharing.py
python
SetAccessInheritanceError.get_access_error
(self)
return self._value
Unable to access shared folder. Only call this if :meth:`is_access_error` is true. :rtype: SharedFolderAccessError
Unable to access shared folder.
[ "Unable", "to", "access", "shared", "folder", "." ]
def get_access_error(self): """ Unable to access shared folder. Only call this if :meth:`is_access_error` is true. :rtype: SharedFolderAccessError """ if not self.is_access_error(): raise AttributeError("tag 'access_error' not set") return self._value
[ "def", "get_access_error", "(", "self", ")", ":", "if", "not", "self", ".", "is_access_error", "(", ")", ":", "raise", "AttributeError", "(", "\"tag 'access_error' not set\"", ")", "return", "self", ".", "_value" ]
https://github.com/dropbox/dropbox-sdk-python/blob/015437429be224732990041164a21a0501235db1/dropbox/sharing.py#L7835-L7845
phantomcyber/playbooks
9e850ecc44cb98c5dde53784744213a1ed5799bd
ssh_endpoint_investigate.py
python
on_start
(container)
return
[]
def on_start(container): phantom.debug('on_start() called') # call 'get_jira_key' block get_jira_key(container=container) return
[ "def", "on_start", "(", "container", ")", ":", "phantom", ".", "debug", "(", "'on_start() called'", ")", "# call 'get_jira_key' block", "get_jira_key", "(", "container", "=", "container", ")", "return" ]
https://github.com/phantomcyber/playbooks/blob/9e850ecc44cb98c5dde53784744213a1ed5799bd/ssh_endpoint_investigate.py#L8-L14
open-telemetry/opentelemetry-python
f5d872050204685b5ef831d02ec593956820ebe6
exporter/opentelemetry-exporter-jaeger-thrift/src/opentelemetry/exporter/jaeger/thrift/gen/agent/Agent.py
python
Client.emitZipkinBatch
(self, spans)
Parameters: - spans
Parameters: - spans
[ "Parameters", ":", "-", "spans" ]
def emitZipkinBatch(self, spans): """ Parameters: - spans """ self.send_emitZipkinBatch(spans)
[ "def", "emitZipkinBatch", "(", "self", ",", "spans", ")", ":", "self", ".", "send_emitZipkinBatch", "(", "spans", ")" ]
https://github.com/open-telemetry/opentelemetry-python/blob/f5d872050204685b5ef831d02ec593956820ebe6/exporter/opentelemetry-exporter-jaeger-thrift/src/opentelemetry/exporter/jaeger/thrift/gen/agent/Agent.py#L41-L46
zhl2008/awd-platform
0416b31abea29743387b10b3914581fbe8e7da5e
web_flaskbb/flaskbb/utils/search.py
python
ForumWhoosheer.delete_forum
(cls, writer, forum)
[]
def delete_forum(cls, writer, forum): writer.delete_by_term('forum_id', forum.id)
[ "def", "delete_forum", "(", "cls", ",", "writer", ",", "forum", ")", ":", "writer", ".", "delete_by_term", "(", "'forum_id'", ",", "forum", ".", "id", ")" ]
https://github.com/zhl2008/awd-platform/blob/0416b31abea29743387b10b3914581fbe8e7da5e/web_flaskbb/flaskbb/utils/search.py#L116-L117
joaoventura/pylibui
2e74db787bfea533f3ae465670963daedcaec344
pylibui/libui/box.py
python
uiNewVerticalBox
()
return clibui.uiNewVerticalBox()
Returns a vertical box. :return: uiBox
Returns a vertical box.
[ "Returns", "a", "vertical", "box", "." ]
def uiNewVerticalBox(): """ Returns a vertical box. :return: uiBox """ # Set return type clibui.uiNewVerticalBox.restype = ctypes.POINTER(uiBox) return clibui.uiNewVerticalBox()
[ "def", "uiNewVerticalBox", "(", ")", ":", "# Set return type", "clibui", ".", "uiNewVerticalBox", ".", "restype", "=", "ctypes", ".", "POINTER", "(", "uiBox", ")", "return", "clibui", ".", "uiNewVerticalBox", "(", ")" ]
https://github.com/joaoventura/pylibui/blob/2e74db787bfea533f3ae465670963daedcaec344/pylibui/libui/box.py#L94-L104
bravoserver/bravo
7be5d792871a8447499911fa1502c6a7c1437dc3
bravo/beta/factory.py
python
BravoFactory.teardown_protocol
(self, protocol)
Do internal bookkeeping on behalf of a protocol which has been disconnected. Did you know that "bookkeeping" is one of the few words in English which has three pairs of double letters in a row?
Do internal bookkeeping on behalf of a protocol which has been disconnected.
[ "Do", "internal", "bookkeeping", "on", "behalf", "of", "a", "protocol", "which", "has", "been", "disconnected", "." ]
def teardown_protocol(self, protocol): """ Do internal bookkeeping on behalf of a protocol which has been disconnected. Did you know that "bookkeeping" is one of the few words in English which has three pairs of double letters in a row? """ username = protocol.username host = protocol.host if username in self.protocols: del self.protocols[username] self.connectedIPs[host] -= 1
[ "def", "teardown_protocol", "(", "self", ",", "protocol", ")", ":", "username", "=", "protocol", ".", "username", "host", "=", "protocol", ".", "host", "if", "username", "in", "self", ".", "protocols", ":", "del", "self", ".", "protocols", "[", "username",...
https://github.com/bravoserver/bravo/blob/7be5d792871a8447499911fa1502c6a7c1437dc3/bravo/beta/factory.py#L191-L206
buke/GreenOdoo
3d8c55d426fb41fdb3f2f5a1533cfe05983ba1df
runtime/python/lib/python2.7/rfc822.py
python
parsedate_tz
(data)
return (yy, mm, dd, thh, tmm, tss, 0, 1, 0, tzoffset)
Convert a date string to a time tuple. Accounts for military timezones.
Convert a date string to a time tuple.
[ "Convert", "a", "date", "string", "to", "a", "time", "tuple", "." ]
def parsedate_tz(data): """Convert a date string to a time tuple. Accounts for military timezones. """ if not data: return None data = data.split() if data[0][-1] in (',', '.') or data[0].lower() in _daynames: # There's a dayname here. Skip it del data[0] else: # no space after the "weekday,"? i = data[0].rfind(',') if i >= 0: data[0] = data[0][i+1:] if len(data) == 3: # RFC 850 date, deprecated stuff = data[0].split('-') if len(stuff) == 3: data = stuff + data[1:] if len(data) == 4: s = data[3] i = s.find('+') if i > 0: data[3:] = [s[:i], s[i+1:]] else: data.append('') # Dummy tz if len(data) < 5: return None data = data[:5] [dd, mm, yy, tm, tz] = data mm = mm.lower() if not mm in _monthnames: dd, mm = mm, dd.lower() if not mm in _monthnames: return None mm = _monthnames.index(mm)+1 if mm > 12: mm = mm - 12 if dd[-1] == ',': dd = dd[:-1] i = yy.find(':') if i > 0: yy, tm = tm, yy if yy[-1] == ',': yy = yy[:-1] if not yy[0].isdigit(): yy, tz = tz, yy if tm[-1] == ',': tm = tm[:-1] tm = tm.split(':') if len(tm) == 2: [thh, tmm] = tm tss = '0' elif len(tm) == 3: [thh, tmm, tss] = tm else: return None try: yy = int(yy) dd = int(dd) thh = int(thh) tmm = int(tmm) tss = int(tss) except ValueError: return None tzoffset = None tz = tz.upper() if tz in _timezones: tzoffset = _timezones[tz] else: try: tzoffset = int(tz) except ValueError: pass # Convert a timezone offset into seconds ; -0500 -> -18000 if tzoffset: if tzoffset < 0: tzsign = -1 tzoffset = -tzoffset else: tzsign = 1 tzoffset = tzsign * ( (tzoffset//100)*3600 + (tzoffset % 100)*60) return (yy, mm, dd, thh, tmm, tss, 0, 1, 0, tzoffset)
[ "def", "parsedate_tz", "(", "data", ")", ":", "if", "not", "data", ":", "return", "None", "data", "=", "data", ".", "split", "(", ")", "if", "data", "[", "0", "]", "[", "-", "1", "]", "in", "(", "','", ",", "'.'", ")", "or", "data", "[", "0",...
https://github.com/buke/GreenOdoo/blob/3d8c55d426fb41fdb3f2f5a1533cfe05983ba1df/runtime/python/lib/python2.7/rfc822.py#L850-L932
oracle/graalpython
577e02da9755d916056184ec441c26e00b70145c
graalpython/lib-python/3/mailbox.py
python
_PartialFile.__init__
(self, f, start=None, stop=None)
Initialize a _PartialFile.
Initialize a _PartialFile.
[ "Initialize", "a", "_PartialFile", "." ]
def __init__(self, f, start=None, stop=None): """Initialize a _PartialFile.""" _ProxyFile.__init__(self, f, start) self._start = start self._stop = stop
[ "def", "__init__", "(", "self", ",", "f", ",", "start", "=", "None", ",", "stop", "=", "None", ")", ":", "_ProxyFile", ".", "__init__", "(", "self", ",", "f", ",", "start", ")", "self", ".", "_start", "=", "start", "self", ".", "_stop", "=", "sto...
https://github.com/oracle/graalpython/blob/577e02da9755d916056184ec441c26e00b70145c/graalpython/lib-python/3/mailbox.py#L2022-L2026
buke/GreenOdoo
3d8c55d426fb41fdb3f2f5a1533cfe05983ba1df
runtime/python/lib/python2.7/site-packages/PIL/ImageOps.py
python
fit
(image, size, method=Image.NEAREST, bleed=0.0, centering=(0.5, 0.5))
return out.resize(size, method)
This method returns a sized and cropped version of the image, cropped to the aspect ratio and size that you request.
This method returns a sized and cropped version of the image, cropped to the aspect ratio and size that you request.
[ "This", "method", "returns", "a", "sized", "and", "cropped", "version", "of", "the", "image", "cropped", "to", "the", "aspect", "ratio", "and", "size", "that", "you", "request", "." ]
def fit(image, size, method=Image.NEAREST, bleed=0.0, centering=(0.5, 0.5)): """ This method returns a sized and cropped version of the image, cropped to the aspect ratio and size that you request. """ # by Kevin Cazabon, Feb 17/2000 # kevin@cazabon.com # http://www.cazabon.com # ensure inputs are valid if type(centering) != type([]): centering = [centering[0], centering[1]] if centering[0] > 1.0 or centering[0] < 0.0: centering [0] = 0.50 if centering[1] > 1.0 or centering[1] < 0.0: centering[1] = 0.50 if bleed > 0.49999 or bleed < 0.0: bleed = 0.0 # calculate the area to use for resizing and cropping, subtracting # the 'bleed' around the edges # number of pixels to trim off on Top and Bottom, Left and Right bleedPixels = ( int((float(bleed) * float(image.size[0])) + 0.5), int((float(bleed) * float(image.size[1])) + 0.5) ) liveArea = ( bleedPixels[0], bleedPixels[1], image.size[0] - bleedPixels[0] - 1, image.size[1] - bleedPixels[1] - 1 ) liveSize = (liveArea[2] - liveArea[0], liveArea[3] - liveArea[1]) # calculate the aspect ratio of the liveArea liveAreaAspectRatio = float(liveSize[0])/float(liveSize[1]) # calculate the aspect ratio of the output image aspectRatio = float(size[0]) / float(size[1]) # figure out if the sides or top/bottom will be cropped off if liveAreaAspectRatio >= aspectRatio: # liveArea is wider than what's needed, crop the sides cropWidth = int((aspectRatio * float(liveSize[1])) + 0.5) cropHeight = liveSize[1] else: # liveArea is taller than what's needed, crop the top and bottom cropWidth = liveSize[0] cropHeight = int((float(liveSize[0])/aspectRatio) + 0.5) # make the crop leftSide = int(liveArea[0] + (float(liveSize[0]-cropWidth) * centering[0])) if leftSide < 0: leftSide = 0 topSide = int(liveArea[1] + (float(liveSize[1]-cropHeight) * centering[1])) if topSide < 0: topSide = 0 out = image.crop( (leftSide, topSide, leftSide + cropWidth, topSide + cropHeight) ) # resize the image and return it return out.resize(size, method)
[ "def", "fit", "(", "image", ",", "size", ",", "method", "=", "Image", ".", "NEAREST", ",", "bleed", "=", "0.0", ",", "centering", "=", "(", "0.5", ",", "0.5", ")", ")", ":", "# by Kevin Cazabon, Feb 17/2000", "# kevin@cazabon.com", "# http://www.cazabon.com", ...
https://github.com/buke/GreenOdoo/blob/3d8c55d426fb41fdb3f2f5a1533cfe05983ba1df/runtime/python/lib/python2.7/site-packages/PIL/ImageOps.py#L266-L333
theotherp/nzbhydra
4b03d7f769384b97dfc60dade4806c0fc987514e
libs/werkzeug/debug/tbtools.py
python
Traceback.paste
(self)
return { 'url': resp['html_url'], 'id': resp['id'] }
Create a paste and return the paste id.
Create a paste and return the paste id.
[ "Create", "a", "paste", "and", "return", "the", "paste", "id", "." ]
def paste(self): """Create a paste and return the paste id.""" data = json.dumps({ 'description': 'Werkzeug Internal Server Error', 'public': False, 'files': { 'traceback.txt': { 'content': self.plaintext } } }).encode('utf-8') try: from urllib2 import urlopen except ImportError: from urllib.request import urlopen rv = urlopen('https://api.github.com/gists', data=data) resp = json.loads(rv.read().decode('utf-8')) rv.close() return { 'url': resp['html_url'], 'id': resp['id'] }
[ "def", "paste", "(", "self", ")", ":", "data", "=", "json", ".", "dumps", "(", "{", "'description'", ":", "'Werkzeug Internal Server Error'", ",", "'public'", ":", "False", ",", "'files'", ":", "{", "'traceback.txt'", ":", "{", "'content'", ":", "self", "....
https://github.com/theotherp/nzbhydra/blob/4b03d7f769384b97dfc60dade4806c0fc987514e/libs/werkzeug/debug/tbtools.py#L276-L297
OctoPrint/OctoPrint
4b12b0e6f06c3abfb31b1840a0605e2de8e911d2
src/octoprint/vendor/zeroconf.py
python
DNSIncoming.read_utf
(self, offset, length)
return text_type(self.data[offset : offset + length], "utf-8", "replace")
Reads a UTF-8 string of a given length from the packet
Reads a UTF-8 string of a given length from the packet
[ "Reads", "a", "UTF", "-", "8", "string", "of", "a", "given", "length", "from", "the", "packet" ]
def read_utf(self, offset, length): """Reads a UTF-8 string of a given length from the packet""" return text_type(self.data[offset : offset + length], "utf-8", "replace")
[ "def", "read_utf", "(", "self", ",", "offset", ",", "length", ")", ":", "return", "text_type", "(", "self", ".", "data", "[", "offset", ":", "offset", "+", "length", "]", ",", "\"utf-8\"", ",", "\"replace\"", ")" ]
https://github.com/OctoPrint/OctoPrint/blob/4b12b0e6f06c3abfb31b1840a0605e2de8e911d2/src/octoprint/vendor/zeroconf.py#L765-L767
microsoft/azure-devops-python-api
451cade4c475482792cbe9e522c1fee32393139e
azure-devops/azure/devops/v5_1/gallery/gallery_client.py
python
GalleryClient.get_certificate
(self, publisher_name, extension_name, version=None, **kwargs)
return self._client.stream_download(response, callback=callback)
GetCertificate. [Preview API] :param str publisher_name: :param str extension_name: :param str version: :rtype: object
GetCertificate. [Preview API] :param str publisher_name: :param str extension_name: :param str version: :rtype: object
[ "GetCertificate", ".", "[", "Preview", "API", "]", ":", "param", "str", "publisher_name", ":", ":", "param", "str", "extension_name", ":", ":", "param", "str", "version", ":", ":", "rtype", ":", "object" ]
def get_certificate(self, publisher_name, extension_name, version=None, **kwargs): """GetCertificate. [Preview API] :param str publisher_name: :param str extension_name: :param str version: :rtype: object """ route_values = {} if publisher_name is not None: route_values['publisherName'] = self._serialize.url('publisher_name', publisher_name, 'str') if extension_name is not None: route_values['extensionName'] = self._serialize.url('extension_name', extension_name, 'str') if version is not None: route_values['version'] = self._serialize.url('version', version, 'str') response = self._send(http_method='GET', location_id='e905ad6a-3f1f-4d08-9f6d-7d357ff8b7d0', version='5.1-preview.1', route_values=route_values, accept_media_type='application/octet-stream') if "callback" in kwargs: callback = kwargs["callback"] else: callback = None return self._client.stream_download(response, callback=callback)
[ "def", "get_certificate", "(", "self", ",", "publisher_name", ",", "extension_name", ",", "version", "=", "None", ",", "*", "*", "kwargs", ")", ":", "route_values", "=", "{", "}", "if", "publisher_name", "is", "not", "None", ":", "route_values", "[", "'pub...
https://github.com/microsoft/azure-devops-python-api/blob/451cade4c475482792cbe9e522c1fee32393139e/azure-devops/azure/devops/v5_1/gallery/gallery_client.py#L397-L421
ilastik/ilastik
6acd2c554bc517e9c8ddad3623a7aaa2e6970c28
lazyflow/stype.py
python
SlotType.isConfigured
(self)
return False
Slot types must implement this method. it should analyse the .meta property of the slot and return wether the neccessary meta information is available.
Slot types must implement this method.
[ "Slot", "types", "must", "implement", "this", "method", "." ]
def isConfigured(self): """ Slot types must implement this method. it should analyse the .meta property of the slot and return wether the neccessary meta information is available. """ return False
[ "def", "isConfigured", "(", "self", ")", ":", "return", "False" ]
https://github.com/ilastik/ilastik/blob/6acd2c554bc517e9c8ddad3623a7aaa2e6970c28/lazyflow/stype.py#L73-L81
jason9693/MusicTransformer-tensorflow2.0
f7c06c0cb2e9cdddcbf6db779cb39cd650282778
custom/callback.py
python
MTFitCallback.__init__
(self, save_path)
[]
def __init__(self, save_path): super(MTFitCallback, self).__init__() self.save_path = save_path
[ "def", "__init__", "(", "self", ",", "save_path", ")", ":", "super", "(", "MTFitCallback", ",", "self", ")", ".", "__init__", "(", ")", "self", ".", "save_path", "=", "save_path" ]
https://github.com/jason9693/MusicTransformer-tensorflow2.0/blob/f7c06c0cb2e9cdddcbf6db779cb39cd650282778/custom/callback.py#L10-L12
jupyter/qtconsole
631ab02bc59b89747adcab3d11aed4a9788d3027
qtconsole/comms.py
python
CommManager.unregister_target
(self, target_name, f)
return self.targets.pop(target_name)
Unregister a callable registered with register_target
Unregister a callable registered with register_target
[ "Unregister", "a", "callable", "registered", "with", "register_target" ]
def unregister_target(self, target_name, f): """Unregister a callable registered with register_target""" return self.targets.pop(target_name)
[ "def", "unregister_target", "(", "self", ",", "target_name", ",", "f", ")", ":", "return", "self", ".", "targets", ".", "pop", "(", "target_name", ")" ]
https://github.com/jupyter/qtconsole/blob/631ab02bc59b89747adcab3d11aed4a9788d3027/qtconsole/comms.py#L83-L85
home-assistant/supervisor
69c2517d5211b483fdfe968b0a2b36b672ee7ab2
supervisor/api/ingress.py
python
_response_header
(response: aiohttp.ClientResponse)
return headers
Create response header.
Create response header.
[ "Create", "response", "header", "." ]
def _response_header(response: aiohttp.ClientResponse) -> dict[str, str]: """Create response header.""" headers = {} for name, value in response.headers.items(): if name in ( hdrs.TRANSFER_ENCODING, hdrs.CONTENT_LENGTH, hdrs.CONTENT_TYPE, hdrs.CONTENT_ENCODING, ): continue headers[name] = value return headers
[ "def", "_response_header", "(", "response", ":", "aiohttp", ".", "ClientResponse", ")", "->", "dict", "[", "str", ",", "str", "]", ":", "headers", "=", "{", "}", "for", "name", ",", "value", "in", "response", ".", "headers", ".", "items", "(", ")", "...
https://github.com/home-assistant/supervisor/blob/69c2517d5211b483fdfe968b0a2b36b672ee7ab2/supervisor/api/ingress.py#L251-L265
spulec/moto
a688c0032596a7dfef122b69a08f2bec3be2e481
moto/core/models.py
python
patch_client
(client)
Explicitly patch a boto3-client
Explicitly patch a boto3-client
[ "Explicitly", "patch", "a", "boto3", "-", "client" ]
def patch_client(client): """ Explicitly patch a boto3-client """ """ Adding the botocore_stubber to the BUILTIN_HANDLERS, as above, will mock everything as long as the import ordering is correct - user: start mock_service decorator - system: imports core.model - system: adds the stubber to the BUILTIN_HANDLERS - user: create a boto3 client - which will use the BUILTIN_HANDLERS But, if for whatever reason the imports are wrong and the client is created first, it doesn't know about our stub yet This method can be used to tell a client that it needs to be mocked, and append the botocore_stubber after creation :param client: :return: """ if isinstance(client, botocore.client.BaseClient): client.meta.events.register("before-send", botocore_stubber) else: raise Exception(f"Argument {client} should be of type boto3.client")
[ "def", "patch_client", "(", "client", ")", ":", "\"\"\"\n Adding the botocore_stubber to the BUILTIN_HANDLERS, as above, will mock everything as long as the import ordering is correct\n - user: start mock_service decorator\n - system: imports core.model\n - system: adds the stubber to t...
https://github.com/spulec/moto/blob/a688c0032596a7dfef122b69a08f2bec3be2e481/moto/core/models.py#L417-L436
TencentCloud/tencentcloud-sdk-python
3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2
tencentcloud/lighthouse/v20200324/models.py
python
ResetInstanceRequest.__init__
(self)
r""" :param InstanceId: 实例 ID。可通过[DescribeInstances](https://cloud.tencent.com/document/api/1207/47573)接口返回值中的InstanceId获取。 :type InstanceId: str :param BlueprintId: 镜像 ID。可通过[DescribeBlueprints](https://cloud.tencent.com/document/product/1207/47689)接口返回值中的BlueprintId获取。 :type BlueprintId: str
r""" :param InstanceId: 实例 ID。可通过[DescribeInstances](https://cloud.tencent.com/document/api/1207/47573)接口返回值中的InstanceId获取。 :type InstanceId: str :param BlueprintId: 镜像 ID。可通过[DescribeBlueprints](https://cloud.tencent.com/document/product/1207/47689)接口返回值中的BlueprintId获取。 :type BlueprintId: str
[ "r", ":", "param", "InstanceId", ":", "实例", "ID。可通过", "[", "DescribeInstances", "]", "(", "https", ":", "//", "cloud", ".", "tencent", ".", "com", "/", "document", "/", "api", "/", "1207", "/", "47573", ")", "接口返回值中的InstanceId获取。", ":", "type", "Instance...
def __init__(self): r""" :param InstanceId: 实例 ID。可通过[DescribeInstances](https://cloud.tencent.com/document/api/1207/47573)接口返回值中的InstanceId获取。 :type InstanceId: str :param BlueprintId: 镜像 ID。可通过[DescribeBlueprints](https://cloud.tencent.com/document/product/1207/47689)接口返回值中的BlueprintId获取。 :type BlueprintId: str """ self.InstanceId = None self.BlueprintId = None
[ "def", "__init__", "(", "self", ")", ":", "self", ".", "InstanceId", "=", "None", "self", ".", "BlueprintId", "=", "None" ]
https://github.com/TencentCloud/tencentcloud-sdk-python/blob/3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2/tencentcloud/lighthouse/v20200324/models.py#L4715-L4723
rlworkgroup/garage
b4abe07f0fa9bac2cb70e4a3e315c2e7e5b08507
src/garage/examples/tf/te_ppo_point.py
python
circle
(r, n)
Generate n points on a circle of radius r. Args: r (float): Radius of the circle. n (int): Number of points to generate. Yields: tuple(float, float): Coordinate of a point.
Generate n points on a circle of radius r.
[ "Generate", "n", "points", "on", "a", "circle", "of", "radius", "r", "." ]
def circle(r, n): """Generate n points on a circle of radius r. Args: r (float): Radius of the circle. n (int): Number of points to generate. Yields: tuple(float, float): Coordinate of a point. """ for t in np.arange(0, 2 * np.pi, 2 * np.pi / n): yield r * np.sin(t), r * np.cos(t)
[ "def", "circle", "(", "r", ",", "n", ")", ":", "for", "t", "in", "np", ".", "arange", "(", "0", ",", "2", "*", "np", ".", "pi", ",", "2", "*", "np", ".", "pi", "/", "n", ")", ":", "yield", "r", "*", "np", ".", "sin", "(", "t", ")", ",...
https://github.com/rlworkgroup/garage/blob/b4abe07f0fa9bac2cb70e4a3e315c2e7e5b08507/src/garage/examples/tf/te_ppo_point.py#L21-L33
ales-tsurko/cells
4cf7e395cd433762bea70cdc863a346f3a6fe1d0
packaging/macos/python/lib/python3.7/nntplib.py
python
_NNTPBase.group
(self, name)
return resp, int(count), int(first), int(last), name
Process a GROUP command. Argument: - group: the group name Returns: - resp: server response if successful - count: number of articles - first: first article number - last: last article number - name: the group name
Process a GROUP command. Argument: - group: the group name Returns: - resp: server response if successful - count: number of articles - first: first article number - last: last article number - name: the group name
[ "Process", "a", "GROUP", "command", ".", "Argument", ":", "-", "group", ":", "the", "group", "name", "Returns", ":", "-", "resp", ":", "server", "response", "if", "successful", "-", "count", ":", "number", "of", "articles", "-", "first", ":", "first", ...
def group(self, name): """Process a GROUP command. Argument: - group: the group name Returns: - resp: server response if successful - count: number of articles - first: first article number - last: last article number - name: the group name """ resp = self._shortcmd('GROUP ' + name) if not resp.startswith('211'): raise NNTPReplyError(resp) words = resp.split() count = first = last = 0 n = len(words) if n > 1: count = words[1] if n > 2: first = words[2] if n > 3: last = words[3] if n > 4: name = words[4].lower() return resp, int(count), int(first), int(last), name
[ "def", "group", "(", "self", ",", "name", ")", ":", "resp", "=", "self", ".", "_shortcmd", "(", "'GROUP '", "+", "name", ")", "if", "not", "resp", ".", "startswith", "(", "'211'", ")", ":", "raise", "NNTPReplyError", "(", "resp", ")", "words", "=", ...
https://github.com/ales-tsurko/cells/blob/4cf7e395cd433762bea70cdc863a346f3a6fe1d0/packaging/macos/python/lib/python3.7/nntplib.py#L651-L675
sfepy/sfepy
02ec7bb2ab39ee1dfe1eb4cd509f0ffb7dcc8b25
sfepy/discrete/fem/fields_base.py
python
VolumeField.average_qp_to_vertices
(self, data_qp, integral)
return data_vertex
Average data given in quadrature points in region elements into region vertices. .. math:: u_n = \sum_e (u_{e,avg} * volume_e) / \sum_e volume_e = \sum_e \int_{volume_e} u / \sum volume_e
Average data given in quadrature points in region elements into region vertices.
[ "Average", "data", "given", "in", "quadrature", "points", "in", "region", "elements", "into", "region", "vertices", "." ]
def average_qp_to_vertices(self, data_qp, integral): """ Average data given in quadrature points in region elements into region vertices. .. math:: u_n = \sum_e (u_{e,avg} * volume_e) / \sum_e volume_e = \sum_e \int_{volume_e} u / \sum volume_e """ region = self.region n_cells = region.get_n_cells() if n_cells != data_qp.shape[0]: msg = 'incomatible shape! (%d == %d)' % (n_cells, data_qp.shape[0]) raise ValueError(msg) n_vertex = self.n_vertex_dof nc = data_qp.shape[2] nod_vol = nm.zeros((n_vertex,), dtype=nm.float64) data_vertex = nm.zeros((n_vertex, nc), dtype=nm.float64) vg = self.get_mapping(self.region, integral, 'volume')[0] volume = nm.squeeze(vg.volume) iels = self.region.get_cells() data_e = nm.zeros((volume.shape[0], 1, nc, 1), dtype=nm.float64) vg.integrate(data_e, data_qp[iels]) ir = nm.arange(nc, dtype=nm.int32) conn = self.econn[:, :self.gel.n_vertex] for ii, cc in enumerate(conn): # Assumes unique nodes in cc! ind2, ind1 = nm.meshgrid(ir, cc) data_vertex[ind1,ind2] += data_e[iels[ii],0,:,0] nod_vol[cc] += volume[ii] data_vertex /= nod_vol[:,nm.newaxis] return data_vertex
[ "def", "average_qp_to_vertices", "(", "self", ",", "data_qp", ",", "integral", ")", ":", "region", "=", "self", ".", "region", "n_cells", "=", "region", ".", "get_n_cells", "(", ")", "if", "n_cells", "!=", "data_qp", ".", "shape", "[", "0", "]", ":", "...
https://github.com/sfepy/sfepy/blob/02ec7bb2ab39ee1dfe1eb4cd509f0ffb7dcc8b25/sfepy/discrete/fem/fields_base.py#L1279-L1321
angr/angr
4b04d56ace135018083d36d9083805be8146688b
angr/angrdb/serializers/comments.py
python
CommentsSerializer.load
(session, db_kb, kb)
return comments
:param session: :param DbKnowledgeBase db_kb: :param KnowledgeBase kb: :return:
[]
def load(session, db_kb, kb): # pylint:disable=unused-argument """ :param session: :param DbKnowledgeBase db_kb: :param KnowledgeBase kb: :return: """ db_comments = db_kb.comments comments = Comments(kb) for db_comment in db_comments: comments[db_comment.addr] = db_comment.comment return comments
[ "def", "load", "(", "session", ",", "db_kb", ",", "kb", ")", ":", "# pylint:disable=unused-argument", "db_comments", "=", "db_kb", ".", "comments", "comments", "=", "Comments", "(", "kb", ")", "for", "db_comment", "in", "db_comments", ":", "comments", "[", "...
https://github.com/angr/angr/blob/4b04d56ace135018083d36d9083805be8146688b/angr/angrdb/serializers/comments.py#L41-L56
openstack/cinder
23494a6d6c51451688191e1847a458f1d3cdcaa5
cinder/volume/drivers/dell_emc/sc/storagecenter_api.py
python
SCApi.get_volume
(self, provider_id)
return result
Returns the scvolume associated with provider_id. :param provider_id: This is the instanceId :return: Dell SCVolume object.
Returns the scvolume associated with provider_id.
[ "Returns", "the", "scvolume", "associated", "with", "provider_id", "." ]
def get_volume(self, provider_id): """Returns the scvolume associated with provider_id. :param provider_id: This is the instanceId :return: Dell SCVolume object. """ result = None if provider_id: r = self.client.get('StorageCenter/ScVolume/%s' % provider_id) if self._check_result(r): result = self._get_json(r) return result
[ "def", "get_volume", "(", "self", ",", "provider_id", ")", ":", "result", "=", "None", "if", "provider_id", ":", "r", "=", "self", ".", "client", ".", "get", "(", "'StorageCenter/ScVolume/%s'", "%", "provider_id", ")", "if", "self", ".", "_check_result", "...
https://github.com/openstack/cinder/blob/23494a6d6c51451688191e1847a458f1d3cdcaa5/cinder/volume/drivers/dell_emc/sc/storagecenter_api.py#L1319-L1330
databricks/databricks-cli
6c429d4f581fc99f54cbf9239879434310037cc7
databricks_cli/configure/provider.py
python
set_config_provider
(provider)
Sets a DatabricksConfigProvider that will be used for all future calls to get_config(), used by the Databricks CLI code to discover the user's credentials.
Sets a DatabricksConfigProvider that will be used for all future calls to get_config(), used by the Databricks CLI code to discover the user's credentials.
[ "Sets", "a", "DatabricksConfigProvider", "that", "will", "be", "used", "for", "all", "future", "calls", "to", "get_config", "()", "used", "by", "the", "Databricks", "CLI", "code", "to", "discover", "the", "user", "s", "credentials", "." ]
def set_config_provider(provider): """ Sets a DatabricksConfigProvider that will be used for all future calls to get_config(), used by the Databricks CLI code to discover the user's credentials. """ global _config_provider if provider and not isinstance(provider, DatabricksConfigProvider): raise Exception('Must be instance of DatabricksConfigProvider: %s' % _config_provider) _config_provider = provider
[ "def", "set_config_provider", "(", "provider", ")", ":", "global", "_config_provider", "if", "provider", "and", "not", "isinstance", "(", "provider", ",", "DatabricksConfigProvider", ")", ":", "raise", "Exception", "(", "'Must be instance of DatabricksConfigProvider: %s'"...
https://github.com/databricks/databricks-cli/blob/6c429d4f581fc99f54cbf9239879434310037cc7/databricks_cli/configure/provider.py#L154-L162
getsentry/sentry
83b1f25aac3e08075e0e2495bc29efaf35aca18a
src/sentry/plugins/base/v2.py
python
IPlugin2.get_conf_title
(self)
return self.conf_title or self.get_title()
Returns a string representing the title to be shown on the configuration page.
Returns a string representing the title to be shown on the configuration page.
[ "Returns", "a", "string", "representing", "the", "title", "to", "be", "shown", "on", "the", "configuration", "page", "." ]
def get_conf_title(self): """ Returns a string representing the title to be shown on the configuration page. """ return self.conf_title or self.get_title()
[ "def", "get_conf_title", "(", "self", ")", ":", "return", "self", ".", "conf_title", "or", "self", ".", "get_title", "(", ")" ]
https://github.com/getsentry/sentry/blob/83b1f25aac3e08075e0e2495bc29efaf35aca18a/src/sentry/plugins/base/v2.py#L209-L213
Azure/azure-devops-cli-extension
11334cd55806bef0b99c3bee5a438eed71e44037
azure-devops/azext_devops/devops_sdk/v5_0/work/work_client.py
python
WorkClient.get_backlog
(self, team_context, id)
return self._deserialize('BacklogLevelConfiguration', response)
GetBacklog. [Preview API] Get a backlog level :param :class:`<TeamContext> <azure.devops.v5_0.work.models.TeamContext>` team_context: The team context for the operation :param str id: The id of the backlog level :rtype: :class:`<BacklogLevelConfiguration> <azure.devops.v5_0.work.models.BacklogLevelConfiguration>`
GetBacklog. [Preview API] Get a backlog level :param :class:`<TeamContext> <azure.devops.v5_0.work.models.TeamContext>` team_context: The team context for the operation :param str id: The id of the backlog level :rtype: :class:`<BacklogLevelConfiguration> <azure.devops.v5_0.work.models.BacklogLevelConfiguration>`
[ "GetBacklog", ".", "[", "Preview", "API", "]", "Get", "a", "backlog", "level", ":", "param", ":", "class", ":", "<TeamContext", ">", "<azure", ".", "devops", ".", "v5_0", ".", "work", ".", "models", ".", "TeamContext", ">", "team_context", ":", "The", ...
def get_backlog(self, team_context, id): """GetBacklog. [Preview API] Get a backlog level :param :class:`<TeamContext> <azure.devops.v5_0.work.models.TeamContext>` team_context: The team context for the operation :param str id: The id of the backlog level :rtype: :class:`<BacklogLevelConfiguration> <azure.devops.v5_0.work.models.BacklogLevelConfiguration>` """ project = None team = None if team_context is not None: if team_context.project_id: project = team_context.project_id else: project = team_context.project if team_context.team_id: team = team_context.team_id else: team = team_context.team route_values = {} if project is not None: route_values['project'] = self._serialize.url('project', project, 'string') if team is not None: route_values['team'] = self._serialize.url('team', team, 'string') if id is not None: route_values['id'] = self._serialize.url('id', id, 'str') response = self._send(http_method='GET', location_id='a93726f9-7867-4e38-b4f2-0bfafc2f6a94', version='5.0-preview.1', route_values=route_values) return self._deserialize('BacklogLevelConfiguration', response)
[ "def", "get_backlog", "(", "self", ",", "team_context", ",", "id", ")", ":", "project", "=", "None", "team", "=", "None", "if", "team_context", "is", "not", "None", ":", "if", "team_context", ".", "project_id", ":", "project", "=", "team_context", ".", "...
https://github.com/Azure/azure-devops-cli-extension/blob/11334cd55806bef0b99c3bee5a438eed71e44037/azure-devops/azext_devops/devops_sdk/v5_0/work/work_client.py#L89-L119
wxWidgets/Phoenix
b2199e299a6ca6d866aa6f3d0888499136ead9d6
wx/lib/agw/buttonpanel.py
python
ButtonInfo.GetStatus
(self)
return self._status
Returns the :class:`ButtonInfo` status. :return: A string containing the :class:`ButtonInfo` status (one of "Pressed", "Hover", "Normal", "Toggled", "Disabled").
Returns the :class:`ButtonInfo` status.
[ "Returns", "the", ":", "class", ":", "ButtonInfo", "status", "." ]
def GetStatus(self): """ Returns the :class:`ButtonInfo` status. :return: A string containing the :class:`ButtonInfo` status (one of "Pressed", "Hover", "Normal", "Toggled", "Disabled"). """ return self._status
[ "def", "GetStatus", "(", "self", ")", ":", "return", "self", ".", "_status" ]
https://github.com/wxWidgets/Phoenix/blob/b2199e299a6ca6d866aa6f3d0888499136ead9d6/wx/lib/agw/buttonpanel.py#L1533-L1541
Tencent/bk-bcs-saas
2b437bf2f5fd5ce2078f7787c3a12df609f7679d
bcs-app/backend/resources/namespace/client.py
python
Namespace.get_or_create_cc_namespace
(self, name: str, username: str)
return self._create_namespace(username, name)
尝试在 PaaSCC 中查询指定命名空间,若不存在则创建 :param name: 命名空间名称 :param username: 操作者 :return: Namespace 信息
尝试在 PaaSCC 中查询指定命名空间,若不存在则创建
[ "尝试在", "PaaSCC", "中查询指定命名空间,若不存在则创建" ]
def get_or_create_cc_namespace(self, name: str, username: str) -> Dict: """ 尝试在 PaaSCC 中查询指定命名空间,若不存在则创建 :param name: 命名空间名称 :param username: 操作者 :return: Namespace 信息 """ # 假定cc中有,集群中也存在 cc_namespaces = get_namespaces_by_cluster_id( self.ctx_cluster.context.auth.access_token, self.ctx_cluster.project_id, self.ctx_cluster.id ) for ns in cc_namespaces: if ns["name"] == name: return self._extract_namespace_info(ns) return self._create_namespace(username, name)
[ "def", "get_or_create_cc_namespace", "(", "self", ",", "name", ":", "str", ",", "username", ":", "str", ")", "->", "Dict", ":", "# 假定cc中有,集群中也存在", "cc_namespaces", "=", "get_namespaces_by_cluster_id", "(", "self", ".", "ctx_cluster", ".", "context", ".", "auth",...
https://github.com/Tencent/bk-bcs-saas/blob/2b437bf2f5fd5ce2078f7787c3a12df609f7679d/bcs-app/backend/resources/namespace/client.py#L27-L43
pyansys/pymapdl
c07291fc062b359abf0e92b95a92d753a95ef3d7
ansys/mapdl/core/inline_functions/selection_queries.py
python
_NextSelectedEntityQueries.arnext
(self, a: int)
return self._run_query(f"ARNEXT({a})", integer=True)
Returns next selected area with a number greater than `a`. Returns the next highest area number after the supplied area number `a`, from the current selection. If no 'next selected' area exists (or if the supplied area number does not exist in the selection) `0` is returned. Parameters ---------- a : int Area number Returns ------- int Area number Examples -------- Here we create 9 areas from 11 nodes and find the next selected area for each. For the last area there are no other areas with a higher number, so 0 is returned. >>> from ansys.mapdl.core import launch_mapdl >>> mapdl = launch_mapdl() >>> mapdl.prep7() >>> q = mapdl.queries >>> farpoint = mapdl.k(999, 0, 10, 0) >>> kps = [mapdl.k(i+1, i, 0, 0) for i in range(10)] >>> areas = [mapdl.a(i, i+1, farpoint) for i in kps[:-1]] >>> next_selected_areas = [q.arnext(j) for j in areas] >>> next_selected_areas [2, 3, 4, 5, 6, 7, 8, 9, 0]
Returns next selected area with a number greater than `a`.
[ "Returns", "next", "selected", "area", "with", "a", "number", "greater", "than", "a", "." ]
def arnext(self, a: int) -> int: """Returns next selected area with a number greater than `a`. Returns the next highest area number after the supplied area number `a`, from the current selection. If no 'next selected' area exists (or if the supplied area number does not exist in the selection) `0` is returned. Parameters ---------- a : int Area number Returns ------- int Area number Examples -------- Here we create 9 areas from 11 nodes and find the next selected area for each. For the last area there are no other areas with a higher number, so 0 is returned. >>> from ansys.mapdl.core import launch_mapdl >>> mapdl = launch_mapdl() >>> mapdl.prep7() >>> q = mapdl.queries >>> farpoint = mapdl.k(999, 0, 10, 0) >>> kps = [mapdl.k(i+1, i, 0, 0) for i in range(10)] >>> areas = [mapdl.a(i, i+1, farpoint) for i in kps[:-1]] >>> next_selected_areas = [q.arnext(j) for j in areas] >>> next_selected_areas [2, 3, 4, 5, 6, 7, 8, 9, 0] """ return self._run_query(f"ARNEXT({a})", integer=True)
[ "def", "arnext", "(", "self", ",", "a", ":", "int", ")", "->", "int", ":", "return", "self", ".", "_run_query", "(", "f\"ARNEXT({a})\"", ",", "integer", "=", "True", ")" ]
https://github.com/pyansys/pymapdl/blob/c07291fc062b359abf0e92b95a92d753a95ef3d7/ansys/mapdl/core/inline_functions/selection_queries.py#L459-L496
brython-dev/brython
9cba5fb7f43a9b52fff13e89b403e02a1dfaa5f3
www/src/Lib/stat.py
python
S_ISBLK
(mode)
return S_IFMT(mode) == S_IFBLK
Return True if mode is from a block special device file.
Return True if mode is from a block special device file.
[ "Return", "True", "if", "mode", "is", "from", "a", "block", "special", "device", "file", "." ]
def S_ISBLK(mode): """Return True if mode is from a block special device file.""" return S_IFMT(mode) == S_IFBLK
[ "def", "S_ISBLK", "(", "mode", ")", ":", "return", "S_IFMT", "(", "mode", ")", "==", "S_IFBLK" ]
https://github.com/brython-dev/brython/blob/9cba5fb7f43a9b52fff13e89b403e02a1dfaa5f3/www/src/Lib/stat.py#L58-L60
securesystemslab/zippy
ff0e84ac99442c2c55fe1d285332cfd4e185e089
zippy/benchmarks/src/benchmarks/sympy-bench.py
python
test_basic
()
[]
def test_basic(): assert list(unify(a, x, {})) == [{x: a}] assert list(unify(a, x, {x: 10})) == [] assert list(unify(1, x, {})) == [{x: 1}] assert list(unify(a, a, {})) == [{}] assert list(unify((w, x), (y, z), {})) == [{w: y, x: z}] assert list(unify(x, (a, b), {})) == [{x: (a, b)}] assert list(unify((a, b), (x, x), {})) == [] assert list(unify((y, z), (x, x), {}))!= [] assert list(unify((a, (b, c)), (a, (x, y)), {})) == [{x: b, y: c}]
[ "def", "test_basic", "(", ")", ":", "assert", "list", "(", "unify", "(", "a", ",", "x", ",", "{", "}", ")", ")", "==", "[", "{", "x", ":", "a", "}", "]", "assert", "list", "(", "unify", "(", "a", ",", "x", ",", "{", "x", ":", "10", "}", ...
https://github.com/securesystemslab/zippy/blob/ff0e84ac99442c2c55fe1d285332cfd4e185e089/zippy/benchmarks/src/benchmarks/sympy-bench.py#L26-L36
darrellsilver/norc
7736899cbe27c8db6dcbf1e04d7fd4eb4a8f8a9d
core/models/schedules.py
python
CronSchedule.pretty_name
(self)
return self.encoding
Returns the pretty (predefined) name for this schedule.
Returns the pretty (predefined) name for this schedule.
[ "Returns", "the", "pretty", "(", "predefined", ")", "name", "for", "this", "schedule", "." ]
def pretty_name(self): """Returns the pretty (predefined) name for this schedule.""" searchs = { r'o\*d\*w\*h\*m(\d+),(\d+)s\d+': 'HALFHOURLY', r'o\*d\*w\*h\*m\d+s\d+': 'HOURLY', r'o\*d\*w\*h\d+m\d+s\d+': 'DAILY', r'o\*d\*w\d+h\d+m\d+s\d+': 'WEEKLY', r'o\*d\d+w\*h\d+m\d+s\d+': 'MONTHLY', } for regex, name in searchs.items(): m = re.match(regex, self.encoding) if m: # A check just for HALFHOURLY. mins = map(int, m.groups()) if m.groups() and abs(mins[0] - mins[1]) != 30: continue return name # If no pretty name, just return the encoding. return self.encoding
[ "def", "pretty_name", "(", "self", ")", ":", "searchs", "=", "{", "r'o\\*d\\*w\\*h\\*m(\\d+),(\\d+)s\\d+'", ":", "'HALFHOURLY'", ",", "r'o\\*d\\*w\\*h\\*m\\d+s\\d+'", ":", "'HOURLY'", ",", "r'o\\*d\\*w\\*h\\d+m\\d+s\\d+'", ":", "'DAILY'", ",", "r'o\\*d\\*w\\d+h\\d+m\\d+s\\d...
https://github.com/darrellsilver/norc/blob/7736899cbe27c8db6dcbf1e04d7fd4eb4a8f8a9d/core/models/schedules.py#L356-L374
retentioneering/retentioneering-tools
71aa4c5c8297e61773d1ba576b3cd7cef5cecdb3
retentioneering/core/core_functions/_legacy_functions.py
python
core_event_distribution
(self, core_events, index_col=None, event_col=None, thresh=None, plotting=True, use_greater=True, **kwargs)
return self._obj[self._obj[self._index_col()].isin(f)].reset_index(drop=True)
[]
def core_event_distribution(self, core_events, index_col=None, event_col=None, thresh=None, plotting=True, use_greater=True, **kwargs): self._init_cols(locals()) if type(core_events) == str: core_events = [core_events] self._obj['is_core_event'] = self._obj[self._event_col()].isin(core_events) rates = self._obj.groupby(self._index_col()).is_core_event.mean() if plotting: plot.core_event_dist(rates, thresh, **kwargs) if use_greater: f = set(rates[rates >= thresh].index.values) else: f = set(rates[rates < thresh].index.values) return self._obj[self._obj[self._index_col()].isin(f)].reset_index(drop=True)
[ "def", "core_event_distribution", "(", "self", ",", "core_events", ",", "index_col", "=", "None", ",", "event_col", "=", "None", ",", "thresh", "=", "None", ",", "plotting", "=", "True", ",", "use_greater", "=", "True", ",", "*", "*", "kwargs", ")", ":",...
https://github.com/retentioneering/retentioneering-tools/blob/71aa4c5c8297e61773d1ba576b3cd7cef5cecdb3/retentioneering/core/core_functions/_legacy_functions.py#L589-L602
cobbler/cobbler
eed8cdca3e970c8aa1d199e80b8c8f19b3f940cc
cobbler/utils.py
python
get_mtab
(mtab="/etc/mtab", vfstype: bool = False)
return mtab_map
Get the list of mtab entries. If a custom mtab should be read then the location can be overridden via a parameter. :param mtab: The location of the mtab. Argument can be omitted if the mtab is at its default location. :param vfstype: If this is True, then all filesystems which are nfs are returned. Otherwise this returns all mtab entries. :return: The list of requested mtab entries.
Get the list of mtab entries. If a custom mtab should be read then the location can be overridden via a parameter.
[ "Get", "the", "list", "of", "mtab", "entries", ".", "If", "a", "custom", "mtab", "should", "be", "read", "then", "the", "location", "can", "be", "overridden", "via", "a", "parameter", "." ]
def get_mtab(mtab="/etc/mtab", vfstype: bool = False) -> list: """ Get the list of mtab entries. If a custom mtab should be read then the location can be overridden via a parameter. :param mtab: The location of the mtab. Argument can be omitted if the mtab is at its default location. :param vfstype: If this is True, then all filesystems which are nfs are returned. Otherwise this returns all mtab entries. :return: The list of requested mtab entries. """ global mtab_mtime, mtab_map mtab_stat = os.stat(mtab) if mtab_stat.st_mtime != mtab_mtime: '''cache is stale ... refresh''' mtab_mtime = mtab_stat.st_mtime mtab_map = __cache_mtab__(mtab) # was a specific fstype requested? if vfstype: mtab_type_map = [] for ent in mtab_map: if ent.mnt_type == "nfs": mtab_type_map.append(ent) return mtab_type_map return mtab_map
[ "def", "get_mtab", "(", "mtab", "=", "\"/etc/mtab\"", ",", "vfstype", ":", "bool", "=", "False", ")", "->", "list", ":", "global", "mtab_mtime", ",", "mtab_map", "mtab_stat", "=", "os", ".", "stat", "(", "mtab", ")", "if", "mtab_stat", ".", "st_mtime", ...
https://github.com/cobbler/cobbler/blob/eed8cdca3e970c8aa1d199e80b8c8f19b3f940cc/cobbler/utils.py#L1459-L1484
TencentCloud/tencentcloud-sdk-python
3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2
tencentcloud/cwp/v20180228/models.py
python
DescribeAssetWebFrameListResponse.__init__
(self)
r""" :param Total: 记录总数 :type Total: int :param WebFrames: 列表 注意:此字段可能返回 null,表示取不到有效值。 :type WebFrames: list of AssetWebFrameBaseInfo :param RequestId: 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。 :type RequestId: str
r""" :param Total: 记录总数 :type Total: int :param WebFrames: 列表 注意:此字段可能返回 null,表示取不到有效值。 :type WebFrames: list of AssetWebFrameBaseInfo :param RequestId: 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。 :type RequestId: str
[ "r", ":", "param", "Total", ":", "记录总数", ":", "type", "Total", ":", "int", ":", "param", "WebFrames", ":", "列表", "注意:此字段可能返回", "null,表示取不到有效值。", ":", "type", "WebFrames", ":", "list", "of", "AssetWebFrameBaseInfo", ":", "param", "RequestId", ":", "唯一请求", "...
def __init__(self): r""" :param Total: 记录总数 :type Total: int :param WebFrames: 列表 注意:此字段可能返回 null,表示取不到有效值。 :type WebFrames: list of AssetWebFrameBaseInfo :param RequestId: 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。 :type RequestId: str """ self.Total = None self.WebFrames = None self.RequestId = None
[ "def", "__init__", "(", "self", ")", ":", "self", ".", "Total", "=", "None", "self", ".", "WebFrames", "=", "None", "self", ".", "RequestId", "=", "None" ]
https://github.com/TencentCloud/tencentcloud-sdk-python/blob/3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2/tencentcloud/cwp/v20180228/models.py#L6611-L6623
williamSYSU/TextGAN-PyTorch
891635af6845edfee382de147faa4fc00c7e90eb
metrics/nll.py
python
NLL.reset
(self, model=None, data_loader=None, label_i=None, leak_dis=None)
[]
def reset(self, model=None, data_loader=None, label_i=None, leak_dis=None): self.model = model self.data_loader = data_loader self.label_i = label_i self.leak_dis = leak_dis
[ "def", "reset", "(", "self", ",", "model", "=", "None", ",", "data_loader", "=", "None", ",", "label_i", "=", "None", ",", "leak_dis", "=", "None", ")", ":", "self", ".", "model", "=", "model", "self", ".", "data_loader", "=", "data_loader", "self", ...
https://github.com/williamSYSU/TextGAN-PyTorch/blob/891635af6845edfee382de147faa4fc00c7e90eb/metrics/nll.py#L43-L47
yorikvanhavre/BIM_Workbench
1114096d1f6abe15ce93c6ca8fed568f52765753
archobjects/wall.py
python
Wall.onChanged
(self, obj, prop)
This method is activated when a property changes.
This method is activated when a property changes.
[ "This", "method", "is", "activated", "when", "a", "property", "changes", "." ]
def onChanged(self, obj, prop): """This method is activated when a property changes. """ super(Wall, self).onChanged(obj, prop) if prop == "Material" and hasattr(obj, "Material"): if obj.Material and utils.get_type(obj.Material) == 'MultiMaterial': obj.Width = App.Units.Quantity(str(sum(obj.Material.Thicknesses))+"mm") if prop == "Placement" and hasattr(obj, "Placement"): # TODO: recompute only if end is set # Recompute wall joinings self.recompute_ends(obj) for t_name in obj.IncomingTJoins: t = App.ActiveDocument.getObject(t_name) t.Proxy.recompute_ends(t) if prop == "Width" and hasattr(obj, "Width") and hasattr(obj, "IncomingTJoins") and hasattr(obj, "Openings"): obj.Proxy.recompute_ends(obj) for t_name in obj.IncomingTJoins: t = App.ActiveDocument.getObject(t_name) t.Proxy.recompute_ends(t) for opening in obj.Openings: if not hasattr(opening, "HostThickness"): continue opening.HostThickness = obj.Width # WALL JOIN ENDS properties if (hasattr(obj, "JoinFirstEndTo") and hasattr(obj, "JoinLastEndTo") and hasattr(obj, "JoinFirstEnd") and hasattr(obj, "JoinLastEnd")): if prop == "JoinFirstEndTo" and obj.JoinFirstEnd: self.recompute_end(obj, 0) elif prop == "JoinLastEndTo" and obj.JoinLastEnd: self.recompute_end(obj, 1) if (prop == "AxisFirstPointX" or prop == "AxisLastPointX") and ( hasattr(obj, "AxisFirstPointX") and hasattr(obj, "AxisLastPointX")): #if obj.AxisFirstPointX.x > obj.AxisLastPointX.x: circular # obj.AxisFirstPointX, obj.AxisLastPointX = obj.AxisLastPointX, obj.AxisFirstPointX if hasattr(obj, "Length"): obj.Length = abs(obj.AxisLastPointX - obj.AxisFirstPointX) # CHILDREN properties: remember to first assign basegeometry and then add the object to the group if prop == "BaseGeometry" and hasattr(obj, "BaseGeometry"): pass # AXIS properties: align wall to an external edge if prop == "AxisLink" and hasattr(obj, "AxisLink"): self.align_axis_to_edge(obj, obj.AxisLink) # Group property: an object is added or removed from the wall if prop == "Group" and hasattr(obj, "Group") and hasattr(obj, "BaseGeometry") and hasattr(obj, "Subtractions"): self.group_changed(obj)
[ "def", "onChanged", "(", "self", ",", "obj", ",", "prop", ")", ":", "super", "(", "Wall", ",", "self", ")", ".", "onChanged", "(", "obj", ",", "prop", ")", "if", "prop", "==", "\"Material\"", "and", "hasattr", "(", "obj", ",", "\"Material\"", ")", ...
https://github.com/yorikvanhavre/BIM_Workbench/blob/1114096d1f6abe15ce93c6ca8fed568f52765753/archobjects/wall.py#L225-L280
we1h0/SecurityManageFramwork
e706461bdf5e2bc78e9fc59c66904b95e81e331e
RBAC/templatetags/custom_tag.py
python
get_structure_data
(request)
return menu_data
处理菜单结构
处理菜单结构
[ "处理菜单结构" ]
def get_structure_data(request): """处理菜单结构""" menu = request.session[settings.SESSION_MENU_KEY] all_menu = menu[settings.ALL_MENU_KEY] permission_url = menu[settings.PERMISSION_MENU_KEY] all_menu_dict = {} for item in all_menu: item['children'] = [] all_menu_dict[item['id']] = item for url in permission_url: # 添加显示状态 # 将url添加到菜单下 all_menu_dict[url['menu_id']]['url'] = url['url'] all_menu_dict[url['menu_id']]['status'] = True # 显示菜单:url 的菜单及上层菜单 status: true pid = url['menu_id'] while pid: all_menu_dict[pid]['status'] = True pid = all_menu_dict[pid]['parent_id'] # 整理菜单层级结构:没有parent_id 的为根菜单, 并将有parent_id 的菜单项加入其父项的chidren内 menu_data = [] for i in all_menu_dict: if 'status' in all_menu_dict[i].keys(): if all_menu_dict[i]['parent_id']: pid = all_menu_dict[i]['parent_id'] parent_menu = all_menu_dict[pid] parent_menu['children'].append(all_menu_dict[i]) else: menu_data.append(all_menu_dict[i]) return menu_data
[ "def", "get_structure_data", "(", "request", ")", ":", "menu", "=", "request", ".", "session", "[", "settings", ".", "SESSION_MENU_KEY", "]", "all_menu", "=", "menu", "[", "settings", ".", "ALL_MENU_KEY", "]", "permission_url", "=", "menu", "[", "settings", ...
https://github.com/we1h0/SecurityManageFramwork/blob/e706461bdf5e2bc78e9fc59c66904b95e81e331e/RBAC/templatetags/custom_tag.py#L16-L49
kkroening/ffmpeg-python
f3079726fae7b7b71e4175f79c5eeaddc1d205fb
ffmpeg/nodes.py
python
OutputStream.__init__
(self, upstream_node, upstream_label, upstream_selector=None)
[]
def __init__(self, upstream_node, upstream_label, upstream_selector=None): super(OutputStream, self).__init__( upstream_node, upstream_label, {OutputNode, GlobalNode, MergeOutputsNode}, upstream_selector=upstream_selector, )
[ "def", "__init__", "(", "self", ",", "upstream_node", ",", "upstream_label", ",", "upstream_selector", "=", "None", ")", ":", "super", "(", "OutputStream", ",", "self", ")", ".", "__init__", "(", "upstream_node", ",", "upstream_label", ",", "{", "OutputNode", ...
https://github.com/kkroening/ffmpeg-python/blob/f3079726fae7b7b71e4175f79c5eeaddc1d205fb/ffmpeg/nodes.py#L323-L329
MVIG-SJTU/AlphaPose
bcfbc997526bcac464d116356ac2efea9483ff68
alphapose/utils/bbox.py
python
bbox_xywh_to_xyxy
(xywh)
Convert bounding boxes from format (x, y, w, h) to (xmin, ymin, xmax, ymax) Parameters ---------- xywh : list, tuple or numpy.ndarray The bbox in format (x, y, w, h). If numpy.ndarray is provided, we expect multiple bounding boxes with shape `(N, 4)`. Returns ------- tuple or numpy.ndarray The converted bboxes in format (xmin, ymin, xmax, ymax). If input is numpy.ndarray, return is numpy.ndarray correspondingly.
Convert bounding boxes from format (x, y, w, h) to (xmin, ymin, xmax, ymax)
[ "Convert", "bounding", "boxes", "from", "format", "(", "x", "y", "w", "h", ")", "to", "(", "xmin", "ymin", "xmax", "ymax", ")" ]
def bbox_xywh_to_xyxy(xywh): """Convert bounding boxes from format (x, y, w, h) to (xmin, ymin, xmax, ymax) Parameters ---------- xywh : list, tuple or numpy.ndarray The bbox in format (x, y, w, h). If numpy.ndarray is provided, we expect multiple bounding boxes with shape `(N, 4)`. Returns ------- tuple or numpy.ndarray The converted bboxes in format (xmin, ymin, xmax, ymax). If input is numpy.ndarray, return is numpy.ndarray correspondingly. """ if isinstance(xywh, (tuple, list)): if not len(xywh) == 4: raise IndexError( "Bounding boxes must have 4 elements, given {}".format(len(xywh))) w, h = np.maximum(xywh[2] - 1, 0), np.maximum(xywh[3] - 1, 0) return (xywh[0], xywh[1], xywh[0] + w, xywh[1] + h) elif isinstance(xywh, np.ndarray): if not xywh.size % 4 == 0: raise IndexError( "Bounding boxes must have n * 4 elements, given {}".format(xywh.shape)) xyxy = np.hstack((xywh[:, :2], xywh[:, :2] + np.maximum(0, xywh[:, 2:4] - 1))) return xyxy else: raise TypeError( 'Expect input xywh a list, tuple or numpy.ndarray, given {}'.format(type(xywh)))
[ "def", "bbox_xywh_to_xyxy", "(", "xywh", ")", ":", "if", "isinstance", "(", "xywh", ",", "(", "tuple", ",", "list", ")", ")", ":", "if", "not", "len", "(", "xywh", ")", "==", "4", ":", "raise", "IndexError", "(", "\"Bounding boxes must have 4 elements, giv...
https://github.com/MVIG-SJTU/AlphaPose/blob/bcfbc997526bcac464d116356ac2efea9483ff68/alphapose/utils/bbox.py#L40-L71
bendmorris/static-python
2e0f8c4d7ed5b359dc7d8a75b6fb37e6b6c5c473
Lib/uu.py
python
test
()
uuencode/uudecode main program
uuencode/uudecode main program
[ "uuencode", "/", "uudecode", "main", "program" ]
def test(): """uuencode/uudecode main program""" import optparse parser = optparse.OptionParser(usage='usage: %prog [-d] [-t] [input [output]]') parser.add_option('-d', '--decode', dest='decode', help='Decode (instead of encode)?', default=False, action='store_true') parser.add_option('-t', '--text', dest='text', help='data is text, encoded format unix-compatible text?', default=False, action='store_true') (options, args) = parser.parse_args() if len(args) > 2: parser.error('incorrect number of arguments') sys.exit(1) # Use the binary streams underlying stdin/stdout input = sys.stdin.buffer output = sys.stdout.buffer if len(args) > 0: input = args[0] if len(args) > 1: output = args[1] if options.decode: if options.text: if isinstance(output, str): output = open(output, 'wb') else: print(sys.argv[0], ': cannot do -t to stdout') sys.exit(1) decode(input, output) else: if options.text: if isinstance(input, str): input = open(input, 'rb') else: print(sys.argv[0], ': cannot do -t from stdin') sys.exit(1) encode(input, output)
[ "def", "test", "(", ")", ":", "import", "optparse", "parser", "=", "optparse", ".", "OptionParser", "(", "usage", "=", "'usage: %prog [-d] [-t] [input [output]]'", ")", "parser", ".", "add_option", "(", "'-d'", ",", "'--decode'", ",", "dest", "=", "'decode'", ...
https://github.com/bendmorris/static-python/blob/2e0f8c4d7ed5b359dc7d8a75b6fb37e6b6c5c473/Lib/uu.py#L160-L196
gramps-project/gramps
04d4651a43eb210192f40a9f8c2bad8ee8fa3753
gramps/cli/clidbman.py
python
CLIDbManager.break_lock
(self, dbpath)
Breaks the lock on a database
Breaks the lock on a database
[ "Breaks", "the", "lock", "on", "a", "database" ]
def break_lock(self, dbpath): """ Breaks the lock on a database """ if os.path.exists(os.path.join(dbpath, "lock")): os.unlink(os.path.join(dbpath, "lock"))
[ "def", "break_lock", "(", "self", ",", "dbpath", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "os", ".", "path", ".", "join", "(", "dbpath", ",", "\"lock\"", ")", ")", ":", "os", ".", "unlink", "(", "os", ".", "path", ".", "join", "("...
https://github.com/gramps-project/gramps/blob/04d4651a43eb210192f40a9f8c2bad8ee8fa3753/gramps/cli/clidbman.py#L454-L459
pyside/pyside2-setup
d526f801ced4687d5413907a93dedcd782ef72fa
tools/qtpy2cpp_lib/formatter.py
python
format_literal
(node)
return ''
Returns the value of number/string literals
Returns the value of number/string literals
[ "Returns", "the", "value", "of", "number", "/", "string", "literals" ]
def format_literal(node): """Returns the value of number/string literals""" if isinstance(node, ast.Num): return str(node.n) if isinstance(node, ast.Str): # Fixme: escaping return f'"{node.s}"' return ''
[ "def", "format_literal", "(", "node", ")", ":", "if", "isinstance", "(", "node", ",", "ast", ".", "Num", ")", ":", "return", "str", "(", "node", ".", "n", ")", "if", "isinstance", "(", "node", ",", "ast", ".", "Str", ")", ":", "# Fixme: escaping", ...
https://github.com/pyside/pyside2-setup/blob/d526f801ced4687d5413907a93dedcd782ef72fa/tools/qtpy2cpp_lib/formatter.py#L111-L118
redis/redis-py
0affa0ed3f3cbcb6dec29b34a580f769f69ae9f7
redis/commands/sentinel.py
python
SentinelCommands.sentinel_remove
(self, name)
return self.execute_command("SENTINEL REMOVE", name)
Remove a master from Sentinel's monitoring
Remove a master from Sentinel's monitoring
[ "Remove", "a", "master", "from", "Sentinel", "s", "monitoring" ]
def sentinel_remove(self, name): "Remove a master from Sentinel's monitoring" return self.execute_command("SENTINEL REMOVE", name)
[ "def", "sentinel_remove", "(", "self", ",", "name", ")", ":", "return", "self", ".", "execute_command", "(", "\"SENTINEL REMOVE\"", ",", "name", ")" ]
https://github.com/redis/redis-py/blob/0affa0ed3f3cbcb6dec29b34a580f769f69ae9f7/redis/commands/sentinel.py#L30-L32
noxrepo/pox
5f82461e01f8822bd7336603b361bff4ffbd2380
pox/openflow/spanning_tree.py
python
_calc_spanning_tree
()
return tree
Calculates the actual spanning tree Returns it as dictionary where the keys are DPID1, and the values are tuples of (DPID2, port-num), where port-num is the port on DPID1 connecting to DPID2.
Calculates the actual spanning tree
[ "Calculates", "the", "actual", "spanning", "tree" ]
def _calc_spanning_tree (): """ Calculates the actual spanning tree Returns it as dictionary where the keys are DPID1, and the values are tuples of (DPID2, port-num), where port-num is the port on DPID1 connecting to DPID2. """ def flip (link): return Discovery.Link(link[2],link[3], link[0],link[1]) adj = defaultdict(lambda:defaultdict(lambda:[])) switches = set() # Add all links and switches for l in core.openflow_discovery.adjacency: adj[l.dpid1][l.dpid2].append(l) switches.add(l.dpid1) switches.add(l.dpid2) # Cull links -- we want a single symmetric link connecting nodes for s1 in switches: for s2 in switches: if s2 not in adj[s1]: continue if not isinstance(adj[s1][s2], list): continue assert s1 is not s2 good = False for l in adj[s1][s2]: if flip(l) in core.openflow_discovery.adjacency: # This is a good one adj[s1][s2] = l.port1 adj[s2][s1] = l.port2 good = True break if not good: del adj[s1][s2] if s1 in adj[s2]: # Delete the other way too del adj[s2][s1] q = [] more = set(switches) done = set() tree = defaultdict(set) while True: q = sorted(list(more)) + q more.clear() if len(q) == 0: break v = q.pop(False) if v in done: continue done.add(v) for w,p in adj[v].items(): if w in tree: continue more.add(w) tree[v].add((w,p)) tree[w].add((v,adj[w][v])) if False: log.debug("*** SPANNING TREE ***") for sw,ports in tree.items(): #print " ", dpidToStr(sw), ":", sorted(list(ports)) #print " ", sw, ":", [l[0] for l in sorted(list(ports))] log.debug((" %i : " % sw) + " ".join([str(l[0]) for l in sorted(list(ports))])) log.debug("*********************") return tree
[ "def", "_calc_spanning_tree", "(", ")", ":", "def", "flip", "(", "link", ")", ":", "return", "Discovery", ".", "Link", "(", "link", "[", "2", "]", ",", "link", "[", "3", "]", ",", "link", "[", "0", "]", ",", "link", "[", "1", "]", ")", "adj", ...
https://github.com/noxrepo/pox/blob/5f82461e01f8822bd7336603b361bff4ffbd2380/pox/openflow/spanning_tree.py#L47-L117
uqfoundation/multiprocess
028cc73f02655e6451d92e5147d19d8c10aebe50
py3.8/multiprocess/connection.py
python
Listener.close
(self)
Close the bound socket or named pipe of `self`.
Close the bound socket or named pipe of `self`.
[ "Close", "the", "bound", "socket", "or", "named", "pipe", "of", "self", "." ]
def close(self): ''' Close the bound socket or named pipe of `self`. ''' listener = self._listener if listener is not None: self._listener = None listener.close()
[ "def", "close", "(", "self", ")", ":", "listener", "=", "self", ".", "_listener", "if", "listener", "is", "not", "None", ":", "self", ".", "_listener", "=", "None", "listener", ".", "close", "(", ")" ]
https://github.com/uqfoundation/multiprocess/blob/028cc73f02655e6451d92e5147d19d8c10aebe50/py3.8/multiprocess/connection.py#L472-L479
demisto/content
5c664a65b992ac8ca90ac3f11b1b2cdf11ee9b07
Packs/GSuiteAdmin/Integrations/GSuiteAdmin/GSuiteAdmin.py
python
user_alias_add_command
(client, args: Dict[str, Any])
return CommandResults( outputs_prefix=OUTPUT_PREFIX['ADD_ALIAS'], outputs_key_field=['id', 'alias'], outputs=outputs, readable_output=readable_output, raw_response=response )
Adds an alias. :param client: client object which is used to get response from api :param args: command arguments. :return: CommandResults object with context and human-readable.
Adds an alias.
[ "Adds", "an", "alias", "." ]
def user_alias_add_command(client, args: Dict[str, Any]) -> CommandResults: """ Adds an alias. :param client: client object which is used to get response from api :param args: command arguments. :return: CommandResults object with context and human-readable. """ user_key = args.get('user_key', '') user_key = urllib.parse.quote(user_key) # type: ignore alias = args.get('alias', '') admin_email = ADMIN_EMAIL body = {'alias': alias} body = GSuiteClient.remove_empty_entities(body) client.set_authorized_http(scopes=COMMAND_SCOPES['USER_ALIAS_ADD'], subject=admin_email) response = client.http_request(url_suffix=URL_SUFFIX['USER_ALIAS'].format(user_key), body=body, method='POST') outputs = prepare_output_user_alias_add(response) readable_output = HR_MESSAGES['ALIAS_ADD_SUCCESS'].format(alias, args.get('user_key', '')) return CommandResults( outputs_prefix=OUTPUT_PREFIX['ADD_ALIAS'], outputs_key_field=['id', 'alias'], outputs=outputs, readable_output=readable_output, raw_response=response )
[ "def", "user_alias_add_command", "(", "client", ",", "args", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "CommandResults", ":", "user_key", "=", "args", ".", "get", "(", "'user_key'", ",", "''", ")", "user_key", "=", "urllib", ".", "parse", "....
https://github.com/demisto/content/blob/5c664a65b992ac8ca90ac3f11b1b2cdf11ee9b07/Packs/GSuiteAdmin/Integrations/GSuiteAdmin/GSuiteAdmin.py#L633-L663