repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
MycroftAI/mycroft-skills-manager
msm/mycroft_skills_manager.py
MycroftSkillsManager.list
def list(self): """ Load a list of SkillEntry objects from both local and remote skills It is necessary to load both local and remote skills at the same time to correctly associate local skills with the name in the repo and remote skills with any custom path that they ...
python
def list(self): """ Load a list of SkillEntry objects from both local and remote skills It is necessary to load both local and remote skills at the same time to correctly associate local skills with the name in the repo and remote skills with any custom path that they ...
[ "def", "list", "(", "self", ")", ":", "try", ":", "self", ".", "repo", ".", "update", "(", ")", "except", "GitException", "as", "e", ":", "if", "not", "isdir", "(", "self", ".", "repo", ".", "path", ")", ":", "raise", "LOG", ".", "warning", "(", ...
Load a list of SkillEntry objects from both local and remote skills It is necessary to load both local and remote skills at the same time to correctly associate local skills with the name in the repo and remote skills with any custom path that they have been downloaded to
[ "Load", "a", "list", "of", "SkillEntry", "objects", "from", "both", "local", "and", "remote", "skills" ]
train
https://github.com/MycroftAI/mycroft-skills-manager/blob/5acef240de42e8ceae2e82bc7492ffee33288b00/msm/mycroft_skills_manager.py#L297-L330
MycroftAI/mycroft-skills-manager
msm/mycroft_skills_manager.py
MycroftSkillsManager.find_skill
def find_skill(self, param, author=None, skills=None): # type: (str, str, List[SkillEntry]) -> SkillEntry """Find skill by name or url""" if param.startswith('https://') or param.startswith('http://'): repo_id = SkillEntry.extract_repo_id(param) for skill in self.list(): ...
python
def find_skill(self, param, author=None, skills=None): # type: (str, str, List[SkillEntry]) -> SkillEntry """Find skill by name or url""" if param.startswith('https://') or param.startswith('http://'): repo_id = SkillEntry.extract_repo_id(param) for skill in self.list(): ...
[ "def", "find_skill", "(", "self", ",", "param", ",", "author", "=", "None", ",", "skills", "=", "None", ")", ":", "# type: (str, str, List[SkillEntry]) -> SkillEntry", "if", "param", ".", "startswith", "(", "'https://'", ")", "or", "param", ".", "startswith", ...
Find skill by name or url
[ "Find", "skill", "by", "name", "or", "url" ]
train
https://github.com/MycroftAI/mycroft-skills-manager/blob/5acef240de42e8ceae2e82bc7492ffee33288b00/msm/mycroft_skills_manager.py#L332-L362
twisted/vertex
vertex/ptcp.py
iterchunks
def iterchunks(data, chunksize): """iterate chunks of data """ offt = 0 while offt < len(data): yield data[offt:offt+chunksize] offt += chunksize
python
def iterchunks(data, chunksize): """iterate chunks of data """ offt = 0 while offt < len(data): yield data[offt:offt+chunksize] offt += chunksize
[ "def", "iterchunks", "(", "data", ",", "chunksize", ")", ":", "offt", "=", "0", "while", "offt", "<", "len", "(", "data", ")", ":", "yield", "data", "[", "offt", ":", "offt", "+", "chunksize", "]", "offt", "+=", "chunksize" ]
iterate chunks of data
[ "iterate", "chunks", "of", "data" ]
train
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/ptcp.py#L231-L237
twisted/vertex
vertex/ptcp.py
segmentAcceptable
def segmentAcceptable(RCV_NXT, RCV_WND, SEG_SEQ, SEG_LEN): """ An acceptable segment: RFC 793 page 26. """ if SEG_LEN == 0 and RCV_WND == 0: return SEG_SEQ == RCV_NXT if SEG_LEN == 0 and RCV_WND > 0: return ((RCV_NXT <= SEG_SEQ) and (SEG_SEQ < RCV_NXT + RCV_WND)) if SEG_LEN > 0 a...
python
def segmentAcceptable(RCV_NXT, RCV_WND, SEG_SEQ, SEG_LEN): """ An acceptable segment: RFC 793 page 26. """ if SEG_LEN == 0 and RCV_WND == 0: return SEG_SEQ == RCV_NXT if SEG_LEN == 0 and RCV_WND > 0: return ((RCV_NXT <= SEG_SEQ) and (SEG_SEQ < RCV_NXT + RCV_WND)) if SEG_LEN > 0 a...
[ "def", "segmentAcceptable", "(", "RCV_NXT", ",", "RCV_WND", ",", "SEG_SEQ", ",", "SEG_LEN", ")", ":", "if", "SEG_LEN", "==", "0", "and", "RCV_WND", "==", "0", ":", "return", "SEG_SEQ", "==", "RCV_NXT", "if", "SEG_LEN", "==", "0", "and", "RCV_WND", ">", ...
An acceptable segment: RFC 793 page 26.
[ "An", "acceptable", "segment", ":", "RFC", "793", "page", "26", "." ]
train
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/ptcp.py#L249-L264
twisted/vertex
vertex/ptcp.py
PTCPPacket.mustRetransmit
def mustRetransmit(self): """ Check to see if this packet must be retransmitted until it was received. Packets which contain a connection-state changing flag (SYN or FIN) or a non-zero amount of data can be retransmitted. """ if self.syn or self.fin or self.dlen:...
python
def mustRetransmit(self): """ Check to see if this packet must be retransmitted until it was received. Packets which contain a connection-state changing flag (SYN or FIN) or a non-zero amount of data can be retransmitted. """ if self.syn or self.fin or self.dlen:...
[ "def", "mustRetransmit", "(", "self", ")", ":", "if", "self", ".", "syn", "or", "self", ".", "fin", "or", "self", ".", "dlen", ":", "return", "True", "return", "False" ]
Check to see if this packet must be retransmitted until it was received. Packets which contain a connection-state changing flag (SYN or FIN) or a non-zero amount of data can be retransmitted.
[ "Check", "to", "see", "if", "this", "packet", "must", "be", "retransmitted", "until", "it", "was", "received", "." ]
train
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/ptcp.py#L186-L196
twisted/vertex
vertex/ptcp.py
PTCPConnection.ackSoon
def ackSoon(self): """ Emit an acknowledgement packet soon. """ if self._ackTimer is None: def originateAck(): self._ackTimer = None self.originate(ack=True) self._ackTimer = reactor.callLater(0.1, originateAck) else: ...
python
def ackSoon(self): """ Emit an acknowledgement packet soon. """ if self._ackTimer is None: def originateAck(): self._ackTimer = None self.originate(ack=True) self._ackTimer = reactor.callLater(0.1, originateAck) else: ...
[ "def", "ackSoon", "(", "self", ")", ":", "if", "self", ".", "_ackTimer", "is", "None", ":", "def", "originateAck", "(", ")", ":", "self", ".", "_ackTimer", "=", "None", "self", ".", "originate", "(", "ack", "=", "True", ")", "self", ".", "_ackTimer",...
Emit an acknowledgement packet soon.
[ "Emit", "an", "acknowledgement", "packet", "soon", "." ]
train
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/ptcp.py#L638-L648
twisted/vertex
vertex/ptcp.py
PTCPConnection.originate
def originate(self, data='', syn=False, ack=False, fin=False, rst=False): """ Create a packet, enqueue it to be sent, and return it. """ if self._ackTimer is not None: self._ackTimer.cancel() self._ackTimer = None if syn: # We really should be ...
python
def originate(self, data='', syn=False, ack=False, fin=False, rst=False): """ Create a packet, enqueue it to be sent, and return it. """ if self._ackTimer is not None: self._ackTimer.cancel() self._ackTimer = None if syn: # We really should be ...
[ "def", "originate", "(", "self", ",", "data", "=", "''", ",", "syn", "=", "False", ",", "ack", "=", "False", ",", "fin", "=", "False", ",", "rst", "=", "False", ")", ":", "if", "self", ".", "_ackTimer", "is", "not", "None", ":", "self", ".", "_...
Create a packet, enqueue it to be sent, and return it.
[ "Create", "a", "packet", "enqueue", "it", "to", "be", "sent", "and", "return", "it", "." ]
train
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/ptcp.py#L650-L695
twisted/vertex
vertex/ptcp.py
PTCPConnection.connectionJustEstablished
def connectionJustEstablished(self): """ We sent out SYN, they acknowledged it. Congratulations, you have a new baby connection. """ assert not self.disconnecting assert not self.disconnected try: p = self.factory.buildProtocol(PTCPAddress( ...
python
def connectionJustEstablished(self): """ We sent out SYN, they acknowledged it. Congratulations, you have a new baby connection. """ assert not self.disconnecting assert not self.disconnected try: p = self.factory.buildProtocol(PTCPAddress( ...
[ "def", "connectionJustEstablished", "(", "self", ")", ":", "assert", "not", "self", ".", "disconnecting", "assert", "not", "self", ".", "disconnected", "try", ":", "p", "=", "self", ".", "factory", ".", "buildProtocol", "(", "PTCPAddress", "(", "self", ".", ...
We sent out SYN, they acknowledged it. Congratulations, you have a new baby connection.
[ "We", "sent", "out", "SYN", "they", "acknowledged", "it", ".", "Congratulations", "you", "have", "a", "new", "baby", "connection", "." ]
train
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/ptcp.py#L745-L761
twisted/vertex
vertex/ptcp.py
PTCP.connect
def connect(self, factory, host, port, pseudoPort=1): """ Attempt to establish a new connection via PTCP to the given remote address. @param factory: A L{ClientFactory} which will be used to create an L{IProtocol} provider if the connection is successfully set up...
python
def connect(self, factory, host, port, pseudoPort=1): """ Attempt to establish a new connection via PTCP to the given remote address. @param factory: A L{ClientFactory} which will be used to create an L{IProtocol} provider if the connection is successfully set up...
[ "def", "connect", "(", "self", ",", "factory", ",", "host", ",", "port", ",", "pseudoPort", "=", "1", ")", ":", "sourcePseudoPort", "=", "genConnID", "(", ")", "%", "MAX_PSEUDO_PORT", "conn", "=", "self", ".", "_connections", "[", "(", "pseudoPort", ",",...
Attempt to establish a new connection via PTCP to the given remote address. @param factory: A L{ClientFactory} which will be used to create an L{IProtocol} provider if the connection is successfully set up, or which will have failure callbacks invoked on it otherwise...
[ "Attempt", "to", "establish", "a", "new", "connection", "via", "PTCP", "to", "the", "given", "remote", "address", "." ]
train
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/ptcp.py#L871-L901
twisted/vertex
vertex/ptcp.py
PTCP._finalCleanup
def _finalCleanup(self): """ Clean up all of our connections by issuing application-level close and stop notifications, sending hail-mary final FIN packets (which may not reach the other end, but nevertheless can be useful) when possible. """ for conn in self._connections...
python
def _finalCleanup(self): """ Clean up all of our connections by issuing application-level close and stop notifications, sending hail-mary final FIN packets (which may not reach the other end, but nevertheless can be useful) when possible. """ for conn in self._connections...
[ "def", "_finalCleanup", "(", "self", ")", ":", "for", "conn", "in", "self", ".", "_connections", ".", "values", "(", ")", ":", "conn", ".", "releaseConnectionResources", "(", ")", "assert", "not", "self", ".", "_connections" ]
Clean up all of our connections by issuing application-level close and stop notifications, sending hail-mary final FIN packets (which may not reach the other end, but nevertheless can be useful) when possible.
[ "Clean", "up", "all", "of", "our", "connections", "by", "issuing", "application", "-", "level", "close", "and", "stop", "notifications", "sending", "hail", "-", "mary", "final", "FIN", "packets", "(", "which", "may", "not", "reach", "the", "other", "end", ...
train
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/ptcp.py#L915-L923
twisted/vertex
vertex/ptcp.py
PTCP.waitForAllConnectionsToClose
def waitForAllConnectionsToClose(self): """ Wait for all currently-open connections to enter the 'CLOSED' state. Currently this is only usable from test fixtures. """ if not self._connections: return self._stop() return self._allConnectionsClosed.deferred().ad...
python
def waitForAllConnectionsToClose(self): """ Wait for all currently-open connections to enter the 'CLOSED' state. Currently this is only usable from test fixtures. """ if not self._connections: return self._stop() return self._allConnectionsClosed.deferred().ad...
[ "def", "waitForAllConnectionsToClose", "(", "self", ")", ":", "if", "not", "self", ".", "_connections", ":", "return", "self", ".", "_stop", "(", ")", "return", "self", ".", "_allConnectionsClosed", ".", "deferred", "(", ")", ".", "addBoth", "(", "self", "...
Wait for all currently-open connections to enter the 'CLOSED' state. Currently this is only usable from test fixtures.
[ "Wait", "for", "all", "currently", "-", "open", "connections", "to", "enter", "the", "CLOSED", "state", ".", "Currently", "this", "is", "only", "usable", "from", "test", "fixtures", "." ]
train
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/ptcp.py#L986-L993
twisted/vertex
vertex/amputil.py
_argumentForLoader
def _argumentForLoader(loaderClass): """ Create an AMP argument for (de-)serializing instances of C{loaderClass}. @param loaderClass: A type object with a L{load} class method that takes some bytes and returns an instance of itself, and a L{dump} instance method that returns some bytes. ...
python
def _argumentForLoader(loaderClass): """ Create an AMP argument for (de-)serializing instances of C{loaderClass}. @param loaderClass: A type object with a L{load} class method that takes some bytes and returns an instance of itself, and a L{dump} instance method that returns some bytes. ...
[ "def", "_argumentForLoader", "(", "loaderClass", ")", ":", "def", "decorator", "(", "argClass", ")", ":", "class", "LoadableArgument", "(", "String", ")", ":", "def", "toString", "(", "self", ",", "arg", ")", ":", "assert", "isinstance", "(", "arg", ",", ...
Create an AMP argument for (de-)serializing instances of C{loaderClass}. @param loaderClass: A type object with a L{load} class method that takes some bytes and returns an instance of itself, and a L{dump} instance method that returns some bytes. @return: a class decorator which decorates an A...
[ "Create", "an", "AMP", "argument", "for", "(", "de", "-", ")", "serializing", "instances", "of", "C", "{", "loaderClass", "}", "." ]
train
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/amputil.py#L93-L117
twisted/vertex
vertex/amputil.py
HostPort.fromString
def fromString(self, inStr): """ Convert the given bytes into a C{(host, port)} tuple. @param inStr: bytes in the format C{host:port} @type inStr: L{bytes} @return: a C{(host, port)} tuple @rtype: 2-L{tuple} of L{bytes}, L{int} """ host, sPort = inStr.sp...
python
def fromString(self, inStr): """ Convert the given bytes into a C{(host, port)} tuple. @param inStr: bytes in the format C{host:port} @type inStr: L{bytes} @return: a C{(host, port)} tuple @rtype: 2-L{tuple} of L{bytes}, L{int} """ host, sPort = inStr.sp...
[ "def", "fromString", "(", "self", ",", "inStr", ")", ":", "host", ",", "sPort", "=", "inStr", ".", "split", "(", "\":\"", ")", "return", "(", "host", ",", "int", "(", "sPort", ")", ")" ]
Convert the given bytes into a C{(host, port)} tuple. @param inStr: bytes in the format C{host:port} @type inStr: L{bytes} @return: a C{(host, port)} tuple @rtype: 2-L{tuple} of L{bytes}, L{int}
[ "Convert", "the", "given", "bytes", "into", "a", "C", "{", "(", "host", "port", ")", "}", "tuple", "." ]
train
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/amputil.py#L78-L89
twisted/vertex
vertex/q2qstandalone.py
StandaloneQ2Q.setup_Q2Q
def setup_Q2Q(self, path, q2qPortnum=q2q.port, inboundTCPPortnum=q2q.port+1, publicIP=None ): """Set up a Q2Q service. """ store = DirectoryCertificateAndUserStore(path) # store.addPrivateCertificate("kazekage") ...
python
def setup_Q2Q(self, path, q2qPortnum=q2q.port, inboundTCPPortnum=q2q.port+1, publicIP=None ): """Set up a Q2Q service. """ store = DirectoryCertificateAndUserStore(path) # store.addPrivateCertificate("kazekage") ...
[ "def", "setup_Q2Q", "(", "self", ",", "path", ",", "q2qPortnum", "=", "q2q", ".", "port", ",", "inboundTCPPortnum", "=", "q2q", ".", "port", "+", "1", ",", "publicIP", "=", "None", ")", ":", "store", "=", "DirectoryCertificateAndUserStore", "(", "path", ...
Set up a Q2Q service.
[ "Set", "up", "a", "Q2Q", "service", "." ]
train
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/q2qstandalone.py#L145-L163
bkircher/python-rpm-spec
pyrpm/spec.py
replace_macros
def replace_macros(string, spec=None): """Replace all macros in given string with corresponding values. For example: a string '%{name}-%{version}.tar.gz' will be transformed to 'foo-2.0.tar.gz'. :param string A string containing macros that you want to be replaced :param spec An optional spec file. If...
python
def replace_macros(string, spec=None): """Replace all macros in given string with corresponding values. For example: a string '%{name}-%{version}.tar.gz' will be transformed to 'foo-2.0.tar.gz'. :param string A string containing macros that you want to be replaced :param spec An optional spec file. If...
[ "def", "replace_macros", "(", "string", ",", "spec", "=", "None", ")", ":", "if", "spec", ":", "assert", "isinstance", "(", "spec", ",", "Spec", ")", "def", "_is_conditional", "(", "macro", ":", "str", ")", "->", "bool", ":", "return", "macro", ".", ...
Replace all macros in given string with corresponding values. For example: a string '%{name}-%{version}.tar.gz' will be transformed to 'foo-2.0.tar.gz'. :param string A string containing macros that you want to be replaced :param spec An optional spec file. If given, definitions in that spec file will...
[ "Replace", "all", "macros", "in", "given", "string", "with", "corresponding", "values", "." ]
train
https://github.com/bkircher/python-rpm-spec/blob/ed0e5180967c87b6d6514ad27f0a8c66c9be4d1c/pyrpm/spec.py#L362-L423
bkircher/python-rpm-spec
pyrpm/spec.py
_Tag.update
def update(self, spec_obj, context, match_obj, line): """Update given spec object and parse context and return them again. :param spec_obj: An instance of Spec class :param context: The parse context :param match_obj: The re.match object :param line: The original line :r...
python
def update(self, spec_obj, context, match_obj, line): """Update given spec object and parse context and return them again. :param spec_obj: An instance of Spec class :param context: The parse context :param match_obj: The re.match object :param line: The original line :r...
[ "def", "update", "(", "self", ",", "spec_obj", ",", "context", ",", "match_obj", ",", "line", ")", ":", "assert", "spec_obj", "assert", "context", "assert", "match_obj", "assert", "line", "return", "self", ".", "update_impl", "(", "spec_obj", ",", "context",...
Update given spec object and parse context and return them again. :param spec_obj: An instance of Spec class :param context: The parse context :param match_obj: The re.match object :param line: The original line :return: Given updated Spec instance and parse context dictionary.
[ "Update", "given", "spec", "object", "and", "parse", "context", "and", "return", "them", "again", "." ]
train
https://github.com/bkircher/python-rpm-spec/blob/ed0e5180967c87b6d6514ad27f0a8c66c9be4d1c/pyrpm/spec.py#L28-L43
bkircher/python-rpm-spec
pyrpm/spec.py
Spec.packages_dict
def packages_dict(self): """All packages in this RPM spec as a dictionary. You can access the individual packages by their package name, e.g., git_spec.packages_dict['git-doc'] """ assert self.packages return dict(zip([package.name for package in self.packages], self.p...
python
def packages_dict(self): """All packages in this RPM spec as a dictionary. You can access the individual packages by their package name, e.g., git_spec.packages_dict['git-doc'] """ assert self.packages return dict(zip([package.name for package in self.packages], self.p...
[ "def", "packages_dict", "(", "self", ")", ":", "assert", "self", ".", "packages", "return", "dict", "(", "zip", "(", "[", "package", ".", "name", "for", "package", "in", "self", ".", "packages", "]", ",", "self", ".", "packages", ")", ")" ]
All packages in this RPM spec as a dictionary. You can access the individual packages by their package name, e.g., git_spec.packages_dict['git-doc']
[ "All", "packages", "in", "this", "RPM", "spec", "as", "a", "dictionary", "." ]
train
https://github.com/bkircher/python-rpm-spec/blob/ed0e5180967c87b6d6514ad27f0a8c66c9be4d1c/pyrpm/spec.py#L321-L330
bkircher/python-rpm-spec
pyrpm/spec.py
Spec.from_file
def from_file(filename): """Creates a new Spec object from a given file. :param filename: The path to the spec file. :return: A new Spec object. """ spec = Spec() with open(filename, "r", encoding="utf-8") as f: parse_context = {"current_subpackage": None} ...
python
def from_file(filename): """Creates a new Spec object from a given file. :param filename: The path to the spec file. :return: A new Spec object. """ spec = Spec() with open(filename, "r", encoding="utf-8") as f: parse_context = {"current_subpackage": None} ...
[ "def", "from_file", "(", "filename", ")", ":", "spec", "=", "Spec", "(", ")", "with", "open", "(", "filename", ",", "\"r\"", ",", "encoding", "=", "\"utf-8\"", ")", "as", "f", ":", "parse_context", "=", "{", "\"current_subpackage\"", ":", "None", "}", ...
Creates a new Spec object from a given file. :param filename: The path to the spec file. :return: A new Spec object.
[ "Creates", "a", "new", "Spec", "object", "from", "a", "given", "file", "." ]
train
https://github.com/bkircher/python-rpm-spec/blob/ed0e5180967c87b6d6514ad27f0a8c66c9be4d1c/pyrpm/spec.py#L333-L345
bkircher/python-rpm-spec
pyrpm/spec.py
Spec.from_string
def from_string(string: str): """Creates a new Spec object from a given string. :param string: The contents of a spec file. :return: A new Spec object. """ spec = Spec() parse_context = {"current_subpackage": None} for line in string.splitlines(): sp...
python
def from_string(string: str): """Creates a new Spec object from a given string. :param string: The contents of a spec file. :return: A new Spec object. """ spec = Spec() parse_context = {"current_subpackage": None} for line in string.splitlines(): sp...
[ "def", "from_string", "(", "string", ":", "str", ")", ":", "spec", "=", "Spec", "(", ")", "parse_context", "=", "{", "\"current_subpackage\"", ":", "None", "}", "for", "line", "in", "string", ".", "splitlines", "(", ")", ":", "spec", ",", "parse_context"...
Creates a new Spec object from a given string. :param string: The contents of a spec file. :return: A new Spec object.
[ "Creates", "a", "new", "Spec", "object", "from", "a", "given", "string", "." ]
train
https://github.com/bkircher/python-rpm-spec/blob/ed0e5180967c87b6d6514ad27f0a8c66c9be4d1c/pyrpm/spec.py#L348-L359
mikeboers/Flask-ACL
flask_acl/core.py
parse_acl
def parse_acl(acl_iter): """Parse a string, or list of ACE definitions, into usable ACEs.""" if isinstance(acl_iter, basestring): acl_iter = [acl_iter] for chunk in acl_iter: if isinstance(chunk, basestring): chunk = chunk.splitlines() chunk = [re.sub(r'#.+', '', l...
python
def parse_acl(acl_iter): """Parse a string, or list of ACE definitions, into usable ACEs.""" if isinstance(acl_iter, basestring): acl_iter = [acl_iter] for chunk in acl_iter: if isinstance(chunk, basestring): chunk = chunk.splitlines() chunk = [re.sub(r'#.+', '', l...
[ "def", "parse_acl", "(", "acl_iter", ")", ":", "if", "isinstance", "(", "acl_iter", ",", "basestring", ")", ":", "acl_iter", "=", "[", "acl_iter", "]", "for", "chunk", "in", "acl_iter", ":", "if", "isinstance", "(", "chunk", ",", "basestring", ")", ":", ...
Parse a string, or list of ACE definitions, into usable ACEs.
[ "Parse", "a", "string", "or", "list", "of", "ACE", "definitions", "into", "usable", "ACEs", "." ]
train
https://github.com/mikeboers/Flask-ACL/blob/7339b89f96ad8686d1526e25c138244ad912e12d/flask_acl/core.py#L8-L33
mikeboers/Flask-ACL
flask_acl/core.py
iter_object_acl
def iter_object_acl(root): """Child-first discovery of ACEs for an object. Walks the ACL graph via ``__acl_bases__`` and yields the ACEs parsed from ``__acl__`` on each object. """ for obj in iter_object_graph(root): for ace in parse_acl(getattr(obj, '__acl__', ())): yield ace
python
def iter_object_acl(root): """Child-first discovery of ACEs for an object. Walks the ACL graph via ``__acl_bases__`` and yields the ACEs parsed from ``__acl__`` on each object. """ for obj in iter_object_graph(root): for ace in parse_acl(getattr(obj, '__acl__', ())): yield ace
[ "def", "iter_object_acl", "(", "root", ")", ":", "for", "obj", "in", "iter_object_graph", "(", "root", ")", ":", "for", "ace", "in", "parse_acl", "(", "getattr", "(", "obj", ",", "'__acl__'", ",", "(", ")", ")", ")", ":", "yield", "ace" ]
Child-first discovery of ACEs for an object. Walks the ACL graph via ``__acl_bases__`` and yields the ACEs parsed from ``__acl__`` on each object.
[ "Child", "-", "first", "discovery", "of", "ACEs", "for", "an", "object", "." ]
train
https://github.com/mikeboers/Flask-ACL/blob/7339b89f96ad8686d1526e25c138244ad912e12d/flask_acl/core.py#L48-L58
mikeboers/Flask-ACL
flask_acl/core.py
get_object_context
def get_object_context(root): """Depth-first discovery of authentication context for an object. Walks the ACL graph via ``__acl_bases__`` and merges the ``__acl_context__`` attributes. """ context = {} for obj in iter_object_graph(root, parents_first=True): context.update(getattr(obj,...
python
def get_object_context(root): """Depth-first discovery of authentication context for an object. Walks the ACL graph via ``__acl_bases__`` and merges the ``__acl_context__`` attributes. """ context = {} for obj in iter_object_graph(root, parents_first=True): context.update(getattr(obj,...
[ "def", "get_object_context", "(", "root", ")", ":", "context", "=", "{", "}", "for", "obj", "in", "iter_object_graph", "(", "root", ",", "parents_first", "=", "True", ")", ":", "context", ".", "update", "(", "getattr", "(", "obj", ",", "'__acl_context__'",...
Depth-first discovery of authentication context for an object. Walks the ACL graph via ``__acl_bases__`` and merges the ``__acl_context__`` attributes.
[ "Depth", "-", "first", "discovery", "of", "authentication", "context", "for", "an", "object", "." ]
train
https://github.com/mikeboers/Flask-ACL/blob/7339b89f96ad8686d1526e25c138244ad912e12d/flask_acl/core.py#L61-L72
MycroftAI/mycroft-skills-manager
msm/skills_data.py
load_skills_data
def load_skills_data() -> dict: """Contains info on how skills should be updated""" skills_data_file = expanduser('~/.mycroft/skills.json') if isfile(skills_data_file): try: with open(skills_data_file) as f: return json.load(f) except json.JSONDecodeError: ...
python
def load_skills_data() -> dict: """Contains info on how skills should be updated""" skills_data_file = expanduser('~/.mycroft/skills.json') if isfile(skills_data_file): try: with open(skills_data_file) as f: return json.load(f) except json.JSONDecodeError: ...
[ "def", "load_skills_data", "(", ")", "->", "dict", ":", "skills_data_file", "=", "expanduser", "(", "'~/.mycroft/skills.json'", ")", "if", "isfile", "(", "skills_data_file", ")", ":", "try", ":", "with", "open", "(", "skills_data_file", ")", "as", "f", ":", ...
Contains info on how skills should be updated
[ "Contains", "info", "on", "how", "skills", "should", "be", "updated" ]
train
https://github.com/MycroftAI/mycroft-skills-manager/blob/5acef240de42e8ceae2e82bc7492ffee33288b00/msm/skills_data.py#L9-L19
MycroftAI/mycroft-skills-manager
msm/skills_data.py
get_skill_entry
def get_skill_entry(name, skills_data) -> dict: """ Find a skill entry in the skills_data and returns it. """ for e in skills_data.get('skills', []): if e.get('name') == name: return e return {}
python
def get_skill_entry(name, skills_data) -> dict: """ Find a skill entry in the skills_data and returns it. """ for e in skills_data.get('skills', []): if e.get('name') == name: return e return {}
[ "def", "get_skill_entry", "(", "name", ",", "skills_data", ")", "->", "dict", ":", "for", "e", "in", "skills_data", ".", "get", "(", "'skills'", ",", "[", "]", ")", ":", "if", "e", ".", "get", "(", "'name'", ")", "==", "name", ":", "return", "e", ...
Find a skill entry in the skills_data and returns it.
[ "Find", "a", "skill", "entry", "in", "the", "skills_data", "and", "returns", "it", "." ]
train
https://github.com/MycroftAI/mycroft-skills-manager/blob/5acef240de42e8ceae2e82bc7492ffee33288b00/msm/skills_data.py#L28-L33
Hundemeier/sacn
sacn/receiving/receiver_thread.py
receiverThread.is_legal_sequence
def is_legal_sequence(self, packet: DataPacket) -> bool: """ Check if the Sequence number of the DataPacket is legal. For more information see page 17 of http://tsp.esta.org/tsp/documents/docs/E1-31-2016.pdf. :param packet: the packet to check :return: true if the sequence is leg...
python
def is_legal_sequence(self, packet: DataPacket) -> bool: """ Check if the Sequence number of the DataPacket is legal. For more information see page 17 of http://tsp.esta.org/tsp/documents/docs/E1-31-2016.pdf. :param packet: the packet to check :return: true if the sequence is leg...
[ "def", "is_legal_sequence", "(", "self", ",", "packet", ":", "DataPacket", ")", "->", "bool", ":", "# if the sequence of the packet is smaller than the last received sequence, return false", "# therefore calculate the difference between the two values:", "try", ":", "# try, because s...
Check if the Sequence number of the DataPacket is legal. For more information see page 17 of http://tsp.esta.org/tsp/documents/docs/E1-31-2016.pdf. :param packet: the packet to check :return: true if the sequence is legal. False if the sequence number is bad
[ "Check", "if", "the", "Sequence", "number", "of", "the", "DataPacket", "is", "legal", ".", "For", "more", "information", "see", "page", "17", "of", "http", ":", "//", "tsp", ".", "esta", ".", "org", "/", "tsp", "/", "documents", "/", "docs", "/", "E1...
train
https://github.com/Hundemeier/sacn/blob/f08bf3d7554a1ed2870f23a9e0e7b89a4a509231/sacn/receiving/receiver_thread.py#L109-L127
Hundemeier/sacn
sacn/receiving/receiver_thread.py
receiverThread.is_legal_priority
def is_legal_priority(self, packet: DataPacket): """ Check if the given packet has high enough priority for the stored values for the packet's universe. :param packet: the packet to check :return: returns True if the priority is good. Otherwise False """ # check if the pa...
python
def is_legal_priority(self, packet: DataPacket): """ Check if the given packet has high enough priority for the stored values for the packet's universe. :param packet: the packet to check :return: returns True if the priority is good. Otherwise False """ # check if the pa...
[ "def", "is_legal_priority", "(", "self", ",", "packet", ":", "DataPacket", ")", ":", "# check if the packet's priority is high enough to get processed", "if", "packet", ".", "universe", "not", "in", "self", ".", "callbacks", ".", "keys", "(", ")", "or", "packet", ...
Check if the given packet has high enough priority for the stored values for the packet's universe. :param packet: the packet to check :return: returns True if the priority is good. Otherwise False
[ "Check", "if", "the", "given", "packet", "has", "high", "enough", "priority", "for", "the", "stored", "values", "for", "the", "packet", "s", "universe", ".", ":", "param", "packet", ":", "the", "packet", "to", "check", ":", "return", ":", "returns", "Tru...
train
https://github.com/Hundemeier/sacn/blob/f08bf3d7554a1ed2870f23a9e0e7b89a4a509231/sacn/receiving/receiver_thread.py#L129-L140
twisted/vertex
vertex/depserv.py
DependencyService.deploy
def deploy(Class, name=None, uid=None, gid=None, **kw): """ Create an application with the give name, uid, and gid. The application has one child service, an instance of Class configured based on the additional keyword arguments passed. The application is not persistable. ...
python
def deploy(Class, name=None, uid=None, gid=None, **kw): """ Create an application with the give name, uid, and gid. The application has one child service, an instance of Class configured based on the additional keyword arguments passed. The application is not persistable. ...
[ "def", "deploy", "(", "Class", ",", "name", "=", "None", ",", "uid", "=", "None", ",", "gid", "=", "None", ",", "*", "*", "kw", ")", ":", "svc", "=", "Class", "(", "*", "*", "kw", ")", "if", "name", "is", "None", ":", "name", "=", "Class", ...
Create an application with the give name, uid, and gid. The application has one child service, an instance of Class configured based on the additional keyword arguments passed. The application is not persistable. @param Class: @param name: @param uid: @param gi...
[ "Create", "an", "application", "with", "the", "give", "name", "uid", "and", "gid", "." ]
train
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/depserv.py#L148-L176
twisted/vertex
vertex/depserv.py
DependencyService.addServer
def addServer(self, normalPort, sslPort, f, name): """ Add a TCP and an SSL server. Name them `name` and `name`+'s'. @param normalPort: @param sslPort: @param f: @param name: """ tcp = internet.TCPServer(normalPort, f) tcp.setName(name) se...
python
def addServer(self, normalPort, sslPort, f, name): """ Add a TCP and an SSL server. Name them `name` and `name`+'s'. @param normalPort: @param sslPort: @param f: @param name: """ tcp = internet.TCPServer(normalPort, f) tcp.setName(name) se...
[ "def", "addServer", "(", "self", ",", "normalPort", ",", "sslPort", ",", "f", ",", "name", ")", ":", "tcp", "=", "internet", ".", "TCPServer", "(", "normalPort", ",", "f", ")", "tcp", ".", "setName", "(", "name", ")", "self", ".", "servers", ".", "...
Add a TCP and an SSL server. Name them `name` and `name`+'s'. @param normalPort: @param sslPort: @param f: @param name:
[ "Add", "a", "TCP", "and", "an", "SSL", "server", ".", "Name", "them", "name", "and", "name", "+", "s", "." ]
train
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/depserv.py#L189-L204
twisted/vertex
vertex/q2q.py
Q2Q._identify
def _identify(self, subject): """ Implementation of L{Identify}. """ ourPrivateCert = self.service.certificateStorage.getPrivateCertificate( str(subject) ) ourCA = Certificate(ourPrivateCert.original) return dict(certificate=ourCA)
python
def _identify(self, subject): """ Implementation of L{Identify}. """ ourPrivateCert = self.service.certificateStorage.getPrivateCertificate( str(subject) ) ourCA = Certificate(ourPrivateCert.original) return dict(certificate=ourCA)
[ "def", "_identify", "(", "self", ",", "subject", ")", ":", "ourPrivateCert", "=", "self", ".", "service", ".", "certificateStorage", ".", "getPrivateCertificate", "(", "str", "(", "subject", ")", ")", "ourCA", "=", "Certificate", "(", "ourPrivateCert", ".", ...
Implementation of L{Identify}.
[ "Implementation", "of", "L", "{", "Identify", "}", "." ]
train
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/q2q.py#L743-L751
twisted/vertex
vertex/q2q.py
Q2Q.verifyCertificateAllowed
def verifyCertificateAllowed(self, ourAddress, theirAddress): """ Check that the cert currently in use by this transport is valid to claim that the connection offers authorization for this host speaking for C{ourAddress}, ...
python
def verifyCertificateAllowed(self, ourAddress, theirAddress): """ Check that the cert currently in use by this transport is valid to claim that the connection offers authorization for this host speaking for C{ourAddress}, ...
[ "def", "verifyCertificateAllowed", "(", "self", ",", "ourAddress", ",", "theirAddress", ")", ":", "# XXX TODO: Somehow, it's got to be possible for a single cluster to", "# internally claim to be agents of any other host when issuing a", "# CONNECT; in other words, we always implicitly trust...
Check that the cert currently in use by this transport is valid to claim that the connection offers authorization for this host speaking for C{ourAddress}, to a host speaking for C{theirAddress}. The remote host (the one claiming to use theirAddress) may have a certificate which is issu...
[ "Check", "that", "the", "cert", "currently", "in", "use", "by", "this", "transport", "is", "valid", "to", "claim", "that", "the", "connection", "offers", "authorization", "for", "this", "host", "speaking", "for", "C", "{", "ourAddress", "}", "to", "a", "ho...
train
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/q2q.py#L754-L903
twisted/vertex
vertex/q2q.py
Q2Q._listen
def _listen(self, protocols, From, description): """ Implementation of L{Listen}. """ # The peer is coming from a client-side representation of the user # described by 'From', and talking *to* a server-side representation of # the user described by 'From'. self.ve...
python
def _listen(self, protocols, From, description): """ Implementation of L{Listen}. """ # The peer is coming from a client-side representation of the user # described by 'From', and talking *to* a server-side representation of # the user described by 'From'. self.ve...
[ "def", "_listen", "(", "self", ",", "protocols", ",", "From", ",", "description", ")", ":", "# The peer is coming from a client-side representation of the user", "# described by 'From', and talking *to* a server-side representation of", "# the user described by 'From'.", "self", ".",...
Implementation of L{Listen}.
[ "Implementation", "of", "L", "{", "Listen", "}", "." ]
train
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/q2q.py#L907-L927
twisted/vertex
vertex/q2q.py
Q2Q._inbound
def _inbound(self, From, to, protocol, udp_source=None): """ Implementation of L{Inbound}. """ # Verify stuff! self.verifyCertificateAllowed(to, From) return self.service.verifyHook(From, to, protocol ).addCallback(self._inboundimpl...
python
def _inbound(self, From, to, protocol, udp_source=None): """ Implementation of L{Inbound}. """ # Verify stuff! self.verifyCertificateAllowed(to, From) return self.service.verifyHook(From, to, protocol ).addCallback(self._inboundimpl...
[ "def", "_inbound", "(", "self", ",", "From", ",", "to", ",", "protocol", ",", "udp_source", "=", "None", ")", ":", "# Verify stuff!", "self", ".", "verifyCertificateAllowed", "(", "to", ",", "From", ")", "return", "self", ".", "service", ".", "verifyHook",...
Implementation of L{Inbound}.
[ "Implementation", "of", "L", "{", "Inbound", "}", "." ]
train
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/q2q.py#L931-L944
twisted/vertex
vertex/q2q.py
Q2Q._write
def _write(self, body, id): """ Respond to a WRITE command, sending some data over a virtual channel created by VIRTUAL. The answer is simply an acknowledgement, as it is simply meant to note that the write went through without errors. An occurrence of I{Write} on the wire, tog...
python
def _write(self, body, id): """ Respond to a WRITE command, sending some data over a virtual channel created by VIRTUAL. The answer is simply an acknowledgement, as it is simply meant to note that the write went through without errors. An occurrence of I{Write} on the wire, tog...
[ "def", "_write", "(", "self", ",", "body", ",", "id", ")", ":", "if", "id", "not", "in", "self", ".", "connections", ":", "raise", "error", ".", "ConnectionDone", "(", ")", "connection", "=", "self", ".", "connections", "[", "id", "]", "connection", ...
Respond to a WRITE command, sending some data over a virtual channel created by VIRTUAL. The answer is simply an acknowledgement, as it is simply meant to note that the write went through without errors. An occurrence of I{Write} on the wire, together with the response generated by thi...
[ "Respond", "to", "a", "WRITE", "command", "sending", "some", "data", "over", "a", "virtual", "channel", "created", "by", "VIRTUAL", ".", "The", "answer", "is", "simply", "an", "acknowledgement", "as", "it", "is", "simply", "meant", "to", "note", "that", "t...
train
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/q2q.py#L1134-L1158
twisted/vertex
vertex/q2q.py
Q2Q._close
def _close(self, id): """ Respond to a CLOSE command, dumping some data onto the stream. As with WRITE, this returns an empty acknowledgement. An occurrence of I{Close} on the wire, together with the response generated by this method, might have this apperance:: C:...
python
def _close(self, id): """ Respond to a CLOSE command, dumping some data onto the stream. As with WRITE, this returns an empty acknowledgement. An occurrence of I{Close} on the wire, together with the response generated by this method, might have this apperance:: C:...
[ "def", "_close", "(", "self", ",", "id", ")", ":", "# The connection is removed from the mapping by connectionLost.", "connection", "=", "self", ".", "connections", "[", "id", "]", "connection", ".", "connectionLost", "(", "Failure", "(", "CONNECTION_DONE", ")", ")"...
Respond to a CLOSE command, dumping some data onto the stream. As with WRITE, this returns an empty acknowledgement. An occurrence of I{Close} on the wire, together with the response generated by this method, might have this apperance:: C: -Command: Close C: -Ask: 1 ...
[ "Respond", "to", "a", "CLOSE", "command", "dumping", "some", "data", "onto", "the", "stream", ".", "As", "with", "WRITE", "this", "returns", "an", "empty", "acknowledgement", "." ]
train
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/q2q.py#L1162-L1181
twisted/vertex
vertex/q2q.py
Q2Q._sign
def _sign(self, certificate_request, password): """ Respond to a request to sign a CSR for a user or agent located within our domain. """ if self.service.portal is None: raise BadCertificateRequest("This agent cannot sign certificates.") subj = certificate_re...
python
def _sign(self, certificate_request, password): """ Respond to a request to sign a CSR for a user or agent located within our domain. """ if self.service.portal is None: raise BadCertificateRequest("This agent cannot sign certificates.") subj = certificate_re...
[ "def", "_sign", "(", "self", ",", "certificate_request", ",", "password", ")", ":", "if", "self", ".", "service", ".", "portal", "is", "None", ":", "raise", "BadCertificateRequest", "(", "\"This agent cannot sign certificates.\"", ")", "subj", "=", "certificate_re...
Respond to a request to sign a CSR for a user or agent located within our domain.
[ "Respond", "to", "a", "request", "to", "sign", "a", "CSR", "for", "a", "user", "or", "agent", "located", "within", "our", "domain", "." ]
train
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/q2q.py#L1185-L1221
twisted/vertex
vertex/q2q.py
Q2Q._secure
def _secure(self, to, From, authorize): """ Response to a SECURE command, starting TLS when necessary, and using a certificate identified by the I{To} header. An occurrence of I{Secure} on the wire, together with the response generated by this method, might have the following ap...
python
def _secure(self, to, From, authorize): """ Response to a SECURE command, starting TLS when necessary, and using a certificate identified by the I{To} header. An occurrence of I{Secure} on the wire, together with the response generated by this method, might have the following ap...
[ "def", "_secure", "(", "self", ",", "to", ",", "From", ",", "authorize", ")", ":", "if", "self", ".", "hostCertificate", "is", "not", "None", ":", "raise", "RuntimeError", "(", "\"Re-encrypting already encrypted connection\"", ")", "CS", "=", "self", ".", "s...
Response to a SECURE command, starting TLS when necessary, and using a certificate identified by the I{To} header. An occurrence of I{Secure} on the wire, together with the response generated by this method, might have the following appearance:: C: -Command: Secure C: -...
[ "Response", "to", "a", "SECURE", "command", "starting", "TLS", "when", "necessary", "and", "using", "a", "certificate", "identified", "by", "the", "I", "{", "To", "}", "header", "." ]
train
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/q2q.py#L1225-L1268
twisted/vertex
vertex/q2q.py
Q2Q._retrieveRemoteCertificate
def _retrieveRemoteCertificate(self, From, port=port): """ The entire conversation, starting with TCP handshake and ending at disconnect, to retrieve a foreign domain's certificate for the first time. """ CS = self.service.certificateStorage host = str(From.domain...
python
def _retrieveRemoteCertificate(self, From, port=port): """ The entire conversation, starting with TCP handshake and ending at disconnect, to retrieve a foreign domain's certificate for the first time. """ CS = self.service.certificateStorage host = str(From.domain...
[ "def", "_retrieveRemoteCertificate", "(", "self", ",", "From", ",", "port", "=", "port", ")", ":", "CS", "=", "self", ".", "service", ".", "certificateStorage", "host", "=", "str", "(", "From", ".", "domainAddress", "(", ")", ")", "p", "=", "AMP", "(",...
The entire conversation, starting with TCP handshake and ending at disconnect, to retrieve a foreign domain's certificate for the first time.
[ "The", "entire", "conversation", "starting", "with", "TCP", "handshake", "and", "ending", "at", "disconnect", "to", "retrieve", "a", "foreign", "domain", "s", "certificate", "for", "the", "first", "time", "." ]
train
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/q2q.py#L1298-L1335
twisted/vertex
vertex/q2q.py
Q2Q.secure
def secure(self, fromAddress, toAddress, fromCertificate, foreignCertificateAuthority=None, authorize=True): """ Return a Deferred which fires True when this connection has been secured as a channel between fromAddress (locally) and toAddress (remotely). ...
python
def secure(self, fromAddress, toAddress, fromCertificate, foreignCertificateAuthority=None, authorize=True): """ Return a Deferred which fires True when this connection has been secured as a channel between fromAddress (locally) and toAddress (remotely). ...
[ "def", "secure", "(", "self", ",", "fromAddress", ",", "toAddress", ",", "fromCertificate", ",", "foreignCertificateAuthority", "=", "None", ",", "authorize", "=", "True", ")", ":", "if", "self", ".", "hostCertificate", "is", "not", "None", ":", "raise", "Ru...
Return a Deferred which fires True when this connection has been secured as a channel between fromAddress (locally) and toAddress (remotely). Raises an error if this is not possible.
[ "Return", "a", "Deferred", "which", "fires", "True", "when", "this", "connection", "has", "been", "secured", "as", "a", "channel", "between", "fromAddress", "(", "locally", ")", "and", "toAddress", "(", "remotely", ")", ".", "Raises", "an", "error", "if", ...
train
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/q2q.py#L1338-L1362
twisted/vertex
vertex/q2q.py
Q2Q.connect
def connect(self, From, to, protocolName, clientFactory, chooser): """ Issue an INBOUND command, creating a virtual connection to the peer, given identifying information about the endpoint to connect to, and a protocol factory. @param clientFactor...
python
def connect(self, From, to, protocolName, clientFactory, chooser): """ Issue an INBOUND command, creating a virtual connection to the peer, given identifying information about the endpoint to connect to, and a protocol factory. @param clientFactor...
[ "def", "connect", "(", "self", ",", "From", ",", "to", ",", "protocolName", ",", "clientFactory", ",", "chooser", ")", ":", "publicIP", "=", "self", ".", "_determinePublicIP", "(", ")", "A", "=", "dict", "(", "From", "=", "From", ",", "to", "=", "to"...
Issue an INBOUND command, creating a virtual connection to the peer, given identifying information about the endpoint to connect to, and a protocol factory. @param clientFactory: a *Client* ProtocolFactory instance which will generate a protocol upon connect. @return: a Deferre...
[ "Issue", "an", "INBOUND", "command", "creating", "a", "virtual", "connection", "to", "the", "peer", "given", "identifying", "information", "about", "the", "endpoint", "to", "connect", "to", "and", "a", "protocol", "factory", "." ]
train
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/q2q.py#L1440-L1515
twisted/vertex
vertex/q2q.py
Q2QBootstrap.whoami
def whoami(self): """ Return a Deferred which fires with a 2-tuple of (dotted quad ip, port number). """ def cbWhoAmI(result): return result['address'] return self.callRemote(WhoAmI).addCallback(cbWhoAmI)
python
def whoami(self): """ Return a Deferred which fires with a 2-tuple of (dotted quad ip, port number). """ def cbWhoAmI(result): return result['address'] return self.callRemote(WhoAmI).addCallback(cbWhoAmI)
[ "def", "whoami", "(", "self", ")", ":", "def", "cbWhoAmI", "(", "result", ")", ":", "return", "result", "[", "'address'", "]", "return", "self", ".", "callRemote", "(", "WhoAmI", ")", ".", "addCallback", "(", "cbWhoAmI", ")" ]
Return a Deferred which fires with a 2-tuple of (dotted quad ip, port number).
[ "Return", "a", "Deferred", "which", "fires", "with", "a", "2", "-", "tuple", "of", "(", "dotted", "quad", "ip", "port", "number", ")", "." ]
train
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/q2q.py#L1633-L1640
twisted/vertex
vertex/q2q.py
DefaultCertificateStore.requestAvatarId
def requestAvatarId(self, credentials): """ Return the ID associated with these credentials. @param credentials: something which implements one of the interfaces in self.credentialInterfaces. @return: a Deferred which will fire a string which identifies an avatar, an em...
python
def requestAvatarId(self, credentials): """ Return the ID associated with these credentials. @param credentials: something which implements one of the interfaces in self.credentialInterfaces. @return: a Deferred which will fire a string which identifies an avatar, an em...
[ "def", "requestAvatarId", "(", "self", ",", "credentials", ")", ":", "username", ",", "domain", "=", "credentials", ".", "username", ".", "split", "(", "\"@\"", ")", "key", "=", "self", ".", "users", ".", "key", "(", "domain", ",", "username", ")", "if...
Return the ID associated with these credentials. @param credentials: something which implements one of the interfaces in self.credentialInterfaces. @return: a Deferred which will fire a string which identifies an avatar, an empty tuple to specify an authenticated anonymous user ...
[ "Return", "the", "ID", "associated", "with", "these", "credentials", "." ]
train
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/q2q.py#L1910-L1935
twisted/vertex
vertex/q2q.py
DefaultCertificateStore.addPrivateCertificate
def addPrivateCertificate(self, subjectName, existingCertificate=None): """ Add a PrivateCertificate object to this store for this subjectName. If existingCertificate is None, add a new self-signed certificate. """ if existingCertificate is None: assert '@' not in su...
python
def addPrivateCertificate(self, subjectName, existingCertificate=None): """ Add a PrivateCertificate object to this store for this subjectName. If existingCertificate is None, add a new self-signed certificate. """ if existingCertificate is None: assert '@' not in su...
[ "def", "addPrivateCertificate", "(", "self", ",", "subjectName", ",", "existingCertificate", "=", "None", ")", ":", "if", "existingCertificate", "is", "None", ":", "assert", "'@'", "not", "in", "subjectName", ",", "\"Don't self-sign user certs!\"", "mainDN", "=", ...
Add a PrivateCertificate object to this store for this subjectName. If existingCertificate is None, add a new self-signed certificate.
[ "Add", "a", "PrivateCertificate", "object", "to", "this", "store", "for", "this", "subjectName", "." ]
train
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/q2q.py#L1979-L1998
twisted/vertex
vertex/q2q.py
Q2QService.iterconnections
def iterconnections(self): """ Iterator of all connections associated with this service, whether cached or not. For testing purposes only. """ return itertools.chain( self.secureConnectionCache.cachedConnections.itervalues(), iter(self.subConnections), ...
python
def iterconnections(self): """ Iterator of all connections associated with this service, whether cached or not. For testing purposes only. """ return itertools.chain( self.secureConnectionCache.cachedConnections.itervalues(), iter(self.subConnections), ...
[ "def", "iterconnections", "(", "self", ")", ":", "return", "itertools", ".", "chain", "(", "self", ".", "secureConnectionCache", ".", "cachedConnections", ".", "itervalues", "(", ")", ",", "iter", "(", "self", ".", "subConnections", ")", ",", "(", "self", ...
Iterator of all connections associated with this service, whether cached or not. For testing purposes only.
[ "Iterator", "of", "all", "connections", "associated", "with", "this", "service", "whether", "cached", "or", "not", ".", "For", "testing", "purposes", "only", "." ]
train
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/q2q.py#L2242-L2250
twisted/vertex
vertex/q2q.py
Q2QService.listenQ2Q
def listenQ2Q(self, fromAddress, protocolsToFactories, serverDescription): """ Right now this is really only useful in the client implementation, since it is transient. protocolFactoryFactory is used for persistent listeners. """ myDomain = fromAddress.domainAddress() ...
python
def listenQ2Q(self, fromAddress, protocolsToFactories, serverDescription): """ Right now this is really only useful in the client implementation, since it is transient. protocolFactoryFactory is used for persistent listeners. """ myDomain = fromAddress.domainAddress() ...
[ "def", "listenQ2Q", "(", "self", ",", "fromAddress", ",", "protocolsToFactories", ",", "serverDescription", ")", ":", "myDomain", "=", "fromAddress", ".", "domainAddress", "(", ")", "D", "=", "self", ".", "getSecureConnection", "(", "fromAddress", ",", "myDomain...
Right now this is really only useful in the client implementation, since it is transient. protocolFactoryFactory is used for persistent listeners.
[ "Right", "now", "this", "is", "really", "only", "useful", "in", "the", "client", "implementation", "since", "it", "is", "transient", ".", "protocolFactoryFactory", "is", "used", "for", "persistent", "listeners", "." ]
train
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/q2q.py#L2341-L2383
twisted/vertex
vertex/q2q.py
Q2QService.requestCertificateForAddress
def requestCertificateForAddress(self, fromAddress, sharedSecret): """ Connect to the authoritative server for the domain part of the given address and obtain a certificate signed by the root certificate for that domain, then store that certificate in my local certificate storage...
python
def requestCertificateForAddress(self, fromAddress, sharedSecret): """ Connect to the authoritative server for the domain part of the given address and obtain a certificate signed by the root certificate for that domain, then store that certificate in my local certificate storage...
[ "def", "requestCertificateForAddress", "(", "self", ",", "fromAddress", ",", "sharedSecret", ")", ":", "kp", "=", "KeyPair", ".", "generate", "(", ")", "subject", "=", "DistinguishedName", "(", "commonName", "=", "str", "(", "fromAddress", ")", ")", "reqobj", ...
Connect to the authoritative server for the domain part of the given address and obtain a certificate signed by the root certificate for that domain, then store that certificate in my local certificate storage. @param fromAddress: an address that this service is authorized to use, ...
[ "Connect", "to", "the", "authoritative", "server", "for", "the", "domain", "part", "of", "the", "given", "address", "and", "obtain", "a", "certificate", "signed", "by", "the", "root", "certificate", "for", "that", "domain", "then", "store", "that", "certificat...
train
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/q2q.py#L2386-L2432
twisted/vertex
vertex/q2q.py
Q2QService.mapListener
def mapListener(self, to, From, protocolName, protocolFactory, isClient=False): """ Returns 2-tuple of (expiryTime, listenerID) """ listenerID = self._nextConnectionID(From, to) call = reactor.callLater(120, self.unmapListener, ...
python
def mapListener(self, to, From, protocolName, protocolFactory, isClient=False): """ Returns 2-tuple of (expiryTime, listenerID) """ listenerID = self._nextConnectionID(From, to) call = reactor.callLater(120, self.unmapListener, ...
[ "def", "mapListener", "(", "self", ",", "to", ",", "From", ",", "protocolName", ",", "protocolFactory", ",", "isClient", "=", "False", ")", ":", "listenerID", "=", "self", ".", "_nextConnectionID", "(", "From", ",", "to", ")", "call", "=", "reactor", "."...
Returns 2-tuple of (expiryTime, listenerID)
[ "Returns", "2", "-", "tuple", "of", "(", "expiryTime", "listenerID", ")" ]
train
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/q2q.py#L2452-L2468
twisted/vertex
vertex/q2q.py
Q2QService.lookupListener
def lookupListener(self, listenID): """ (internal) Retrieve a waiting connection by its connection identifier, passing in the transport to be used to connect the waiting protocol factory to. """ if listenID in self.inboundConnections: # Make the connection? ...
python
def lookupListener(self, listenID): """ (internal) Retrieve a waiting connection by its connection identifier, passing in the transport to be used to connect the waiting protocol factory to. """ if listenID in self.inboundConnections: # Make the connection? ...
[ "def", "lookupListener", "(", "self", ",", "listenID", ")", ":", "if", "listenID", "in", "self", ".", "inboundConnections", ":", "# Make the connection?", "cwait", ",", "call", "=", "self", ".", "inboundConnections", ".", "pop", "(", "listenID", ")", "# _Conne...
(internal) Retrieve a waiting connection by its connection identifier, passing in the transport to be used to connect the waiting protocol factory to.
[ "(", "internal", ")" ]
train
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/q2q.py#L2475-L2487
twisted/vertex
vertex/q2q.py
Q2QService.getLocalFactories
def getLocalFactories(self, From, to, protocolName): """ Returns a list of 2-tuples of (protocolFactory, description) to handle this from/to/protocolName @param From: @param to: @param protocolName: @return: """ result = [] x = self.loca...
python
def getLocalFactories(self, From, to, protocolName): """ Returns a list of 2-tuples of (protocolFactory, description) to handle this from/to/protocolName @param From: @param to: @param protocolName: @return: """ result = [] x = self.loca...
[ "def", "getLocalFactories", "(", "self", ",", "From", ",", "to", ",", "protocolName", ")", ":", "result", "=", "[", "]", "x", "=", "self", ".", "localFactoriesMapping", ".", "get", "(", "(", "to", ",", "protocolName", ")", ",", "(", ")", ")", "result...
Returns a list of 2-tuples of (protocolFactory, description) to handle this from/to/protocolName @param From: @param to: @param protocolName: @return:
[ "Returns", "a", "list", "of", "2", "-", "tuples", "of", "(", "protocolFactory", "description", ")", "to", "handle", "this", "from", "/", "to", "/", "protocolName" ]
train
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/q2q.py#L2491-L2508
twisted/vertex
vertex/q2q.py
Q2QService.connectQ2Q
def connectQ2Q(self, fromAddress, toAddress, protocolName, protocolFactory, usePrivateCertificate=None, fakeFromDomain=None, chooser=None): """ Connect a named protocol factory from a resource@domain to a resource@domain. This is analagous to someth...
python
def connectQ2Q(self, fromAddress, toAddress, protocolName, protocolFactory, usePrivateCertificate=None, fakeFromDomain=None, chooser=None): """ Connect a named protocol factory from a resource@domain to a resource@domain. This is analagous to someth...
[ "def", "connectQ2Q", "(", "self", ",", "fromAddress", ",", "toAddress", ",", "protocolName", ",", "protocolFactory", ",", "usePrivateCertificate", "=", "None", ",", "fakeFromDomain", "=", "None", ",", "chooser", "=", "None", ")", ":", "if", "chooser", "is", ...
Connect a named protocol factory from a resource@domain to a resource@domain. This is analagous to something like connectTCP, in that it creates a connection-oriented transport for each connection, except instead of specifying your credentials with an application-level (username, ...
[ "Connect", "a", "named", "protocol", "factory", "from", "a", "resource@domain", "to", "a", "resource@domain", "." ]
train
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/q2q.py#L2565-L2661
twisted/vertex
vertex/q2q.py
Q2QService.getSecureConnection
def getSecureConnection(self, fromAddress, toAddress, port=port, usePrivateCertificate=None, authorize=True): """ Establish or retrieven an already-established L{Q2Q}-protocol connection from C{fromAddress} to I{the q2q proxy provider} for ...
python
def getSecureConnection(self, fromAddress, toAddress, port=port, usePrivateCertificate=None, authorize=True): """ Establish or retrieven an already-established L{Q2Q}-protocol connection from C{fromAddress} to I{the q2q proxy provider} for ...
[ "def", "getSecureConnection", "(", "self", ",", "fromAddress", ",", "toAddress", ",", "port", "=", "port", ",", "usePrivateCertificate", "=", "None", ",", "authorize", "=", "True", ")", ":", "# Secure connections using users as clients will have to be established", "# u...
Establish or retrieven an already-established L{Q2Q}-protocol connection from C{fromAddress} to I{the q2q proxy provider} for C{toAddress}; i.e. the entity responsible for the I{domain party only} of C{toAddress}. The connection is "from" C{fromAddress} in the sense that it will use a ...
[ "Establish", "or", "retrieven", "an", "already", "-", "established", "L", "{", "Q2Q", "}", "-", "protocol", "connection", "from", "C", "{", "fromAddress", "}", "to", "I", "{", "the", "q2q", "proxy", "provider", "}", "for", "C", "{", "toAddress", "}", "...
train
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/q2q.py#L2664-L2812
MycroftAI/mycroft-skills-manager
msm/skill_entry.py
_backup_previous_version
def _backup_previous_version(func: Callable = None): """Private decorator to back up previous skill folder""" @wraps(func) def wrapper(self, *args, **kwargs): self.old_path = None if self.is_local: self.old_path = join(gettempdir(), self.name) if exists(self.old_path...
python
def _backup_previous_version(func: Callable = None): """Private decorator to back up previous skill folder""" @wraps(func) def wrapper(self, *args, **kwargs): self.old_path = None if self.is_local: self.old_path = join(gettempdir(), self.name) if exists(self.old_path...
[ "def", "_backup_previous_version", "(", "func", ":", "Callable", "=", "None", ")", ":", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "old_path", "=", "None", "if", ...
Private decorator to back up previous skill folder
[ "Private", "decorator", "to", "back", "up", "previous", "skill", "folder" ]
train
https://github.com/MycroftAI/mycroft-skills-manager/blob/5acef240de42e8ceae2e82bc7492ffee33288b00/msm/skill_entry.py#L69-L96
MycroftAI/mycroft-skills-manager
msm/skill_entry.py
SkillEntry.attach
def attach(self, remote_entry): """Attach a remote entry to a local entry""" self.name = remote_entry.name self.sha = remote_entry.sha self.url = remote_entry.url self.author = remote_entry.author return self
python
def attach(self, remote_entry): """Attach a remote entry to a local entry""" self.name = remote_entry.name self.sha = remote_entry.sha self.url = remote_entry.url self.author = remote_entry.author return self
[ "def", "attach", "(", "self", ",", "remote_entry", ")", ":", "self", ".", "name", "=", "remote_entry", ".", "name", "self", ".", "sha", "=", "remote_entry", ".", "sha", "self", ".", "url", "=", "remote_entry", ".", "url", "self", ".", "author", "=", ...
Attach a remote entry to a local entry
[ "Attach", "a", "remote", "entry", "to", "a", "local", "entry" ]
train
https://github.com/MycroftAI/mycroft-skills-manager/blob/5acef240de42e8ceae2e82bc7492ffee33288b00/msm/skill_entry.py#L136-L142
mikeboers/Flask-ACL
flask_acl/permission.py
parse_permission_set
def parse_permission_set(input): """Lookup a permission set name in the defined permissions. Requires a Flask app context. """ # Priority goes to the user's parsers. if isinstance(input, basestring): for func in current_acl_manager.permission_set_parsers: res = func(input) ...
python
def parse_permission_set(input): """Lookup a permission set name in the defined permissions. Requires a Flask app context. """ # Priority goes to the user's parsers. if isinstance(input, basestring): for func in current_acl_manager.permission_set_parsers: res = func(input) ...
[ "def", "parse_permission_set", "(", "input", ")", ":", "# Priority goes to the user's parsers.", "if", "isinstance", "(", "input", ",", "basestring", ")", ":", "for", "func", "in", "current_acl_manager", ".", "permission_set_parsers", ":", "res", "=", "func", "(", ...
Lookup a permission set name in the defined permissions. Requires a Flask app context.
[ "Lookup", "a", "permission", "set", "name", "in", "the", "defined", "permissions", "." ]
train
https://github.com/mikeboers/Flask-ACL/blob/7339b89f96ad8686d1526e25c138244ad912e12d/flask_acl/permission.py#L21-L42
mikeboers/Flask-ACL
flask_acl/permission.py
is_permission_in_set
def is_permission_in_set(perm, perm_set): """Test if a permission is in the given set. :param perm: The permission object to check for. :param perm_set: The set to check in. If a ``str``, the permission is checked for equality. If a container, the permission is looked for in the set. If a f...
python
def is_permission_in_set(perm, perm_set): """Test if a permission is in the given set. :param perm: The permission object to check for. :param perm_set: The set to check in. If a ``str``, the permission is checked for equality. If a container, the permission is looked for in the set. If a f...
[ "def", "is_permission_in_set", "(", "perm", ",", "perm_set", ")", ":", "if", "isinstance", "(", "perm_set", ",", "basestring", ")", ":", "return", "perm", "==", "perm_set", "elif", "isinstance", "(", "perm_set", ",", "Container", ")", ":", "return", "perm", ...
Test if a permission is in the given set. :param perm: The permission object to check for. :param perm_set: The set to check in. If a ``str``, the permission is checked for equality. If a container, the permission is looked for in the set. If a function, the permission is passed to the "set".
[ "Test", "if", "a", "permission", "is", "in", "the", "given", "set", "." ]
train
https://github.com/mikeboers/Flask-ACL/blob/7339b89f96ad8686d1526e25c138244ad912e12d/flask_acl/permission.py#L45-L62
Hundemeier/sacn
sacn/messages/universe_discovery.py
convert_raw_data_to_universes
def convert_raw_data_to_universes(raw_data) -> tuple: """ converts the raw data to a readable universes tuple. The raw_data is scanned from index 0 and has to have 16-bit numbers with high byte first. The data is converted from the start to the beginning! :param raw_data: the raw data to convert :re...
python
def convert_raw_data_to_universes(raw_data) -> tuple: """ converts the raw data to a readable universes tuple. The raw_data is scanned from index 0 and has to have 16-bit numbers with high byte first. The data is converted from the start to the beginning! :param raw_data: the raw data to convert :re...
[ "def", "convert_raw_data_to_universes", "(", "raw_data", ")", "->", "tuple", ":", "if", "len", "(", "raw_data", ")", "%", "2", "!=", "0", ":", "raise", "TypeError", "(", "'The given data has not a length that is a multiple of 2!'", ")", "rtrnList", "=", "[", "]", ...
converts the raw data to a readable universes tuple. The raw_data is scanned from index 0 and has to have 16-bit numbers with high byte first. The data is converted from the start to the beginning! :param raw_data: the raw data to convert :return: tuple full with 16-bit numbers
[ "converts", "the", "raw", "data", "to", "a", "readable", "universes", "tuple", ".", "The", "raw_data", "is", "scanned", "from", "index", "0", "and", "has", "to", "have", "16", "-", "bit", "numbers", "with", "high", "byte", "first", ".", "The", "data", ...
train
https://github.com/Hundemeier/sacn/blob/f08bf3d7554a1ed2870f23a9e0e7b89a4a509231/sacn/messages/universe_discovery.py#L131-L143
Hundemeier/sacn
sacn/messages/universe_discovery.py
UniverseDiscoveryPacket.make_multiple_uni_disc_packets
def make_multiple_uni_disc_packets(cid: tuple, sourceName: str, universes: list) -> List['UniverseDiscoveryPacket']: """ Creates a list with universe discovery packets based on the given data. It creates automatically enough packets for the given universes list. :param cid: the cid to us...
python
def make_multiple_uni_disc_packets(cid: tuple, sourceName: str, universes: list) -> List['UniverseDiscoveryPacket']: """ Creates a list with universe discovery packets based on the given data. It creates automatically enough packets for the given universes list. :param cid: the cid to us...
[ "def", "make_multiple_uni_disc_packets", "(", "cid", ":", "tuple", ",", "sourceName", ":", "str", ",", "universes", ":", "list", ")", "->", "List", "[", "'UniverseDiscoveryPacket'", "]", ":", "tmpList", "=", "[", "]", "if", "len", "(", "universes", ")", "%...
Creates a list with universe discovery packets based on the given data. It creates automatically enough packets for the given universes list. :param cid: the cid to use in all packets :param sourceName: the source name to use in all packets :param universes: the universes. Can be longer ...
[ "Creates", "a", "list", "with", "universe", "discovery", "packets", "based", "on", "the", "given", "data", ".", "It", "creates", "automatically", "enough", "packets", "for", "the", "given", "universes", "list", ".", ":", "param", "cid", ":", "the", "cid", ...
train
https://github.com/Hundemeier/sacn/blob/f08bf3d7554a1ed2870f23a9e0e7b89a4a509231/sacn/messages/universe_discovery.py#L102-L128
MattBroach/DjangoRestMultipleModels
drf_multiple_model/pagination.py
MultipleModelLimitOffsetPagination.paginate_queryset
def paginate_queryset(self, queryset, request, view=None): """ adds `max_count` as a running tally of the largest table size. Used for calculating next/previous links later """ result = super(MultipleModelLimitOffsetPagination, self).paginate_queryset(queryset, request, view) ...
python
def paginate_queryset(self, queryset, request, view=None): """ adds `max_count` as a running tally of the largest table size. Used for calculating next/previous links later """ result = super(MultipleModelLimitOffsetPagination, self).paginate_queryset(queryset, request, view) ...
[ "def", "paginate_queryset", "(", "self", ",", "queryset", ",", "request", ",", "view", "=", "None", ")", ":", "result", "=", "super", "(", "MultipleModelLimitOffsetPagination", ",", "self", ")", ".", "paginate_queryset", "(", "queryset", ",", "request", ",", ...
adds `max_count` as a running tally of the largest table size. Used for calculating next/previous links later
[ "adds", "max_count", "as", "a", "running", "tally", "of", "the", "largest", "table", "size", ".", "Used", "for", "calculating", "next", "/", "previous", "links", "later" ]
train
https://github.com/MattBroach/DjangoRestMultipleModels/blob/893969ed38d614a5e2f060e560824fa7c5c49cfd/drf_multiple_model/pagination.py#L13-L31
MattBroach/DjangoRestMultipleModels
drf_multiple_model/pagination.py
MultipleModelLimitOffsetPagination.format_response
def format_response(self, data): """ replaces the `count` (the last queryset count) with the running `max_count` variable, to ensure accurate link calculation """ self.count = self.max_count return OrderedDict([ ('highest_count', self.max_count), ...
python
def format_response(self, data): """ replaces the `count` (the last queryset count) with the running `max_count` variable, to ensure accurate link calculation """ self.count = self.max_count return OrderedDict([ ('highest_count', self.max_count), ...
[ "def", "format_response", "(", "self", ",", "data", ")", ":", "self", ".", "count", "=", "self", ".", "max_count", "return", "OrderedDict", "(", "[", "(", "'highest_count'", ",", "self", ".", "max_count", ")", ",", "(", "'overall_total'", ",", "self", "....
replaces the `count` (the last queryset count) with the running `max_count` variable, to ensure accurate link calculation
[ "replaces", "the", "count", "(", "the", "last", "queryset", "count", ")", "with", "the", "running", "max_count", "variable", "to", "ensure", "accurate", "link", "calculation" ]
train
https://github.com/MattBroach/DjangoRestMultipleModels/blob/893969ed38d614a5e2f060e560824fa7c5c49cfd/drf_multiple_model/pagination.py#L33-L46
MattBroach/DjangoRestMultipleModels
drf_multiple_model/mixins.py
BaseMultipleModelMixin.check_query_data
def check_query_data(self, query_data): """ All items in a `querylist` must at least have `queryset` key and a `serializer_class` key. Any querylist item lacking both those keys will raise a ValidationError """ for key in self.required_keys: if key not in quer...
python
def check_query_data(self, query_data): """ All items in a `querylist` must at least have `queryset` key and a `serializer_class` key. Any querylist item lacking both those keys will raise a ValidationError """ for key in self.required_keys: if key not in quer...
[ "def", "check_query_data", "(", "self", ",", "query_data", ")", ":", "for", "key", "in", "self", ".", "required_keys", ":", "if", "key", "not", "in", "query_data", ":", "raise", "ValidationError", "(", "'All items in the {} querylist attribute should contain a '", "...
All items in a `querylist` must at least have `queryset` key and a `serializer_class` key. Any querylist item lacking both those keys will raise a ValidationError
[ "All", "items", "in", "a", "querylist", "must", "at", "least", "have", "queryset", "key", "and", "a", "serializer_class", "key", ".", "Any", "querylist", "item", "lacking", "both", "those", "keys", "will", "raise", "a", "ValidationError" ]
train
https://github.com/MattBroach/DjangoRestMultipleModels/blob/893969ed38d614a5e2f060e560824fa7c5c49cfd/drf_multiple_model/mixins.py#L30-L41
MattBroach/DjangoRestMultipleModels
drf_multiple_model/mixins.py
BaseMultipleModelMixin.load_queryset
def load_queryset(self, query_data, request, *args, **kwargs): """ Fetches the queryset and runs any necessary filtering, both built-in rest_framework filters and custom filters passed into the querylist """ queryset = query_data.get('queryset', []) if isinstance...
python
def load_queryset(self, query_data, request, *args, **kwargs): """ Fetches the queryset and runs any necessary filtering, both built-in rest_framework filters and custom filters passed into the querylist """ queryset = query_data.get('queryset', []) if isinstance...
[ "def", "load_queryset", "(", "self", ",", "query_data", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "queryset", "=", "query_data", ".", "get", "(", "'queryset'", ",", "[", "]", ")", "if", "isinstance", "(", "queryset", ",", "...
Fetches the queryset and runs any necessary filtering, both built-in rest_framework filters and custom filters passed into the querylist
[ "Fetches", "the", "queryset", "and", "runs", "any", "necessary", "filtering", "both", "built", "-", "in", "rest_framework", "filters", "and", "custom", "filters", "passed", "into", "the", "querylist" ]
train
https://github.com/MattBroach/DjangoRestMultipleModels/blob/893969ed38d614a5e2f060e560824fa7c5c49cfd/drf_multiple_model/mixins.py#L43-L66
MattBroach/DjangoRestMultipleModels
drf_multiple_model/mixins.py
BaseMultipleModelMixin.get_empty_results
def get_empty_results(self): """ Because the base result type is different depending on the return structure (e.g. list for flat, dict for object), `get_result_type` initials the `results` variable to the proper type """ assert self.result_type is not None, ( ...
python
def get_empty_results(self): """ Because the base result type is different depending on the return structure (e.g. list for flat, dict for object), `get_result_type` initials the `results` variable to the proper type """ assert self.result_type is not None, ( ...
[ "def", "get_empty_results", "(", "self", ")", ":", "assert", "self", ".", "result_type", "is", "not", "None", ",", "(", "'{} must specify a `result_type` value or overwrite the '", "'`get_empty_result` method.'", ".", "format", "(", "self", ".", "__class__", ".", "__n...
Because the base result type is different depending on the return structure (e.g. list for flat, dict for object), `get_result_type` initials the `results` variable to the proper type
[ "Because", "the", "base", "result", "type", "is", "different", "depending", "on", "the", "return", "structure", "(", "e", ".", "g", ".", "list", "for", "flat", "dict", "for", "object", ")", "get_result_type", "initials", "the", "results", "variable", "to", ...
train
https://github.com/MattBroach/DjangoRestMultipleModels/blob/893969ed38d614a5e2f060e560824fa7c5c49cfd/drf_multiple_model/mixins.py#L68-L79
MattBroach/DjangoRestMultipleModels
drf_multiple_model/mixins.py
BaseMultipleModelMixin.add_to_results
def add_to_results(self, data, label, results): """ responsible for updating the running `results` variable with the data from this queryset/serializer combo """ raise NotImplementedError( '{} must specify how to add data to the running results tally ' 'by...
python
def add_to_results(self, data, label, results): """ responsible for updating the running `results` variable with the data from this queryset/serializer combo """ raise NotImplementedError( '{} must specify how to add data to the running results tally ' 'by...
[ "def", "add_to_results", "(", "self", ",", "data", ",", "label", ",", "results", ")", ":", "raise", "NotImplementedError", "(", "'{} must specify how to add data to the running results tally '", "'by overriding the `add_to_results` method.'", ".", "format", "(", "self", "."...
responsible for updating the running `results` variable with the data from this queryset/serializer combo
[ "responsible", "for", "updating", "the", "running", "results", "variable", "with", "the", "data", "from", "this", "queryset", "/", "serializer", "combo" ]
train
https://github.com/MattBroach/DjangoRestMultipleModels/blob/893969ed38d614a5e2f060e560824fa7c5c49cfd/drf_multiple_model/mixins.py#L81-L91
MattBroach/DjangoRestMultipleModels
drf_multiple_model/mixins.py
FlatMultipleModelMixin.initial
def initial(self, request, *args, **kwargs): """ Overrides DRF's `initial` in order to set the `_sorting_field` from corresponding property in view. Protected property is required in order to support overriding of `sorting_field` via `@property`, we do this after original `initial` has b...
python
def initial(self, request, *args, **kwargs): """ Overrides DRF's `initial` in order to set the `_sorting_field` from corresponding property in view. Protected property is required in order to support overriding of `sorting_field` via `@property`, we do this after original `initial` has b...
[ "def", "initial", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "super", "(", "FlatMultipleModelMixin", ",", "self", ")", ".", "initial", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", "assert", ...
Overrides DRF's `initial` in order to set the `_sorting_field` from corresponding property in view. Protected property is required in order to support overriding of `sorting_field` via `@property`, we do this after original `initial` has been ran in order to make sure that view has all its properties se...
[ "Overrides", "DRF", "s", "initial", "in", "order", "to", "set", "the", "_sorting_field", "from", "corresponding", "property", "in", "view", ".", "Protected", "property", "is", "required", "in", "order", "to", "support", "overriding", "of", "sorting_field", "via"...
train
https://github.com/MattBroach/DjangoRestMultipleModels/blob/893969ed38d614a5e2f060e560824fa7c5c49cfd/drf_multiple_model/mixins.py#L178-L194
MattBroach/DjangoRestMultipleModels
drf_multiple_model/mixins.py
FlatMultipleModelMixin.add_to_results
def add_to_results(self, data, label, results): """ Adds the label to the results, as needed, then appends the data to the running results tab """ for datum in data: if label is not None: datum.update({'type': label}) results.append(datum)...
python
def add_to_results(self, data, label, results): """ Adds the label to the results, as needed, then appends the data to the running results tab """ for datum in data: if label is not None: datum.update({'type': label}) results.append(datum)...
[ "def", "add_to_results", "(", "self", ",", "data", ",", "label", ",", "results", ")", ":", "for", "datum", "in", "data", ":", "if", "label", "is", "not", "None", ":", "datum", ".", "update", "(", "{", "'type'", ":", "label", "}", ")", "results", "....
Adds the label to the results, as needed, then appends the data to the running results tab
[ "Adds", "the", "label", "to", "the", "results", "as", "needed", "then", "appends", "the", "data", "to", "the", "running", "results", "tab" ]
train
https://github.com/MattBroach/DjangoRestMultipleModels/blob/893969ed38d614a5e2f060e560824fa7c5c49cfd/drf_multiple_model/mixins.py#L209-L220
MattBroach/DjangoRestMultipleModels
drf_multiple_model/mixins.py
FlatMultipleModelMixin.format_results
def format_results(self, results, request): """ Prepares sorting parameters, and sorts results, if(as) necessary """ self.prepare_sorting_fields() if self._sorting_fields: results = self.sort_results(results) if request.accepted_renderer.format == 'html': ...
python
def format_results(self, results, request): """ Prepares sorting parameters, and sorts results, if(as) necessary """ self.prepare_sorting_fields() if self._sorting_fields: results = self.sort_results(results) if request.accepted_renderer.format == 'html': ...
[ "def", "format_results", "(", "self", ",", "results", ",", "request", ")", ":", "self", ".", "prepare_sorting_fields", "(", ")", "if", "self", ".", "_sorting_fields", ":", "results", "=", "self", ".", "sort_results", "(", "results", ")", "if", "request", "...
Prepares sorting parameters, and sorts results, if(as) necessary
[ "Prepares", "sorting", "parameters", "and", "sorts", "results", "if", "(", "as", ")", "necessary" ]
train
https://github.com/MattBroach/DjangoRestMultipleModels/blob/893969ed38d614a5e2f060e560824fa7c5c49cfd/drf_multiple_model/mixins.py#L222-L234
MattBroach/DjangoRestMultipleModels
drf_multiple_model/mixins.py
FlatMultipleModelMixin._sort_by
def _sort_by(self, datum, param, path=None): """ Key function that is used for results sorting. This is passed as argument to `sorted()` """ if not path: path = [] try: if '__' in param: root, new_param = param.split('__') p...
python
def _sort_by(self, datum, param, path=None): """ Key function that is used for results sorting. This is passed as argument to `sorted()` """ if not path: path = [] try: if '__' in param: root, new_param = param.split('__') p...
[ "def", "_sort_by", "(", "self", ",", "datum", ",", "param", ",", "path", "=", "None", ")", ":", "if", "not", "path", ":", "path", "=", "[", "]", "try", ":", "if", "'__'", "in", "param", ":", "root", ",", "new_param", "=", "param", ".", "split", ...
Key function that is used for results sorting. This is passed as argument to `sorted()`
[ "Key", "function", "that", "is", "used", "for", "results", "sorting", ".", "This", "is", "passed", "as", "argument", "to", "sorted", "()" ]
train
https://github.com/MattBroach/DjangoRestMultipleModels/blob/893969ed38d614a5e2f060e560824fa7c5c49cfd/drf_multiple_model/mixins.py#L236-L257
MattBroach/DjangoRestMultipleModels
drf_multiple_model/mixins.py
FlatMultipleModelMixin.prepare_sorting_fields
def prepare_sorting_fields(self): """ Determine sorting direction and sorting field based on request query parameters and sorting options of self """ if self.sorting_parameter_name in self.request.query_params: # Extract sorting parameter from query string ...
python
def prepare_sorting_fields(self): """ Determine sorting direction and sorting field based on request query parameters and sorting options of self """ if self.sorting_parameter_name in self.request.query_params: # Extract sorting parameter from query string ...
[ "def", "prepare_sorting_fields", "(", "self", ")", ":", "if", "self", ".", "sorting_parameter_name", "in", "self", ".", "request", ".", "query_params", ":", "# Extract sorting parameter from query string", "self", ".", "_sorting_fields", "=", "[", "_", ".", "strip",...
Determine sorting direction and sorting field based on request query parameters and sorting options of self
[ "Determine", "sorting", "direction", "and", "sorting", "field", "based", "on", "request", "query", "parameters", "and", "sorting", "options", "of", "self" ]
train
https://github.com/MattBroach/DjangoRestMultipleModels/blob/893969ed38d614a5e2f060e560824fa7c5c49cfd/drf_multiple_model/mixins.py#L259-L275
MattBroach/DjangoRestMultipleModels
drf_multiple_model/mixins.py
ObjectMultipleModelMixin.get_label
def get_label(self, queryset, query_data): """ Gets option label for each datum. Can be used for type identification of individual serialized objects """ if query_data.get('label', False): return query_data['label'] try: return queryset.model.__na...
python
def get_label(self, queryset, query_data): """ Gets option label for each datum. Can be used for type identification of individual serialized objects """ if query_data.get('label', False): return query_data['label'] try: return queryset.model.__na...
[ "def", "get_label", "(", "self", ",", "queryset", ",", "query_data", ")", ":", "if", "query_data", ".", "get", "(", "'label'", ",", "False", ")", ":", "return", "query_data", "[", "'label'", "]", "try", ":", "return", "queryset", ".", "model", ".", "__...
Gets option label for each datum. Can be used for type identification of individual serialized objects
[ "Gets", "option", "label", "for", "each", "datum", ".", "Can", "be", "used", "for", "type", "identification", "of", "individual", "serialized", "objects" ]
train
https://github.com/MattBroach/DjangoRestMultipleModels/blob/893969ed38d614a5e2f060e560824fa7c5c49cfd/drf_multiple_model/mixins.py#L324-L335
python-useful-helpers/threaded
setup.py
_extension
def _extension(modpath: str) -> setuptools.Extension: """Make setuptools.Extension.""" return setuptools.Extension(modpath, [modpath.replace(".", "/") + ".py"])
python
def _extension(modpath: str) -> setuptools.Extension: """Make setuptools.Extension.""" return setuptools.Extension(modpath, [modpath.replace(".", "/") + ".py"])
[ "def", "_extension", "(", "modpath", ":", "str", ")", "->", "setuptools", ".", "Extension", ":", "return", "setuptools", ".", "Extension", "(", "modpath", ",", "[", "modpath", ".", "replace", "(", "\".\"", ",", "\"/\"", ")", "+", "\".py\"", "]", ")" ]
Make setuptools.Extension.
[ "Make", "setuptools", ".", "Extension", "." ]
train
https://github.com/python-useful-helpers/threaded/blob/c1aa5a631ab3e2904b915ed6c6a8be03a9673a1a/setup.py#L53-L55
python-useful-helpers/threaded
setup.py
AllowFailRepair.build_extension
def build_extension(self, ext): """build_extension. :raises BuildFailed: cythonize impossible """ try: build_ext.build_ext.build_extension(self, ext) except ( distutils.errors.CCompilerError, distutils.errors.DistutilsExecError, di...
python
def build_extension(self, ext): """build_extension. :raises BuildFailed: cythonize impossible """ try: build_ext.build_ext.build_extension(self, ext) except ( distutils.errors.CCompilerError, distutils.errors.DistutilsExecError, di...
[ "def", "build_extension", "(", "self", ",", "ext", ")", ":", "try", ":", "build_ext", ".", "build_ext", ".", "build_extension", "(", "self", ",", "ext", ")", "except", "(", "distutils", ".", "errors", ".", "CCompilerError", ",", "distutils", ".", "errors",...
build_extension. :raises BuildFailed: cythonize impossible
[ "build_extension", "." ]
train
https://github.com/python-useful-helpers/threaded/blob/c1aa5a631ab3e2904b915ed6c6a8be03a9673a1a/setup.py#L115-L128
alfredodeza/remoto
remoto/process.py
extend_env
def extend_env(conn, arguments): """ get the remote environment's env so we can explicitly add the path without wiping out everything """ # retrieve the remote environment variables for the host try: result = conn.gateway.remote_exec("import os; channel.send(os.environ.copy())") ...
python
def extend_env(conn, arguments): """ get the remote environment's env so we can explicitly add the path without wiping out everything """ # retrieve the remote environment variables for the host try: result = conn.gateway.remote_exec("import os; channel.send(os.environ.copy())") ...
[ "def", "extend_env", "(", "conn", ",", "arguments", ")", ":", "# retrieve the remote environment variables for the host", "try", ":", "result", "=", "conn", ".", "gateway", ".", "remote_exec", "(", "\"import os; channel.send(os.environ.copy())\"", ")", "env", "=", "resu...
get the remote environment's env so we can explicitly add the path without wiping out everything
[ "get", "the", "remote", "environment", "s", "env", "so", "we", "can", "explicitly", "add", "the", "path", "without", "wiping", "out", "everything" ]
train
https://github.com/alfredodeza/remoto/blob/b7625e571a4b6c83f9589a1e9ad07354e42bf0d3/remoto/process.py#L77-L98
alfredodeza/remoto
remoto/process.py
run
def run(conn, command, exit=False, timeout=None, **kw): """ A real-time-logging implementation of a remote subprocess.Popen call where a command is just executed on the remote end and no other handling is done. :param conn: A connection oject :param command: The command to pass in to the remote sub...
python
def run(conn, command, exit=False, timeout=None, **kw): """ A real-time-logging implementation of a remote subprocess.Popen call where a command is just executed on the remote end and no other handling is done. :param conn: A connection oject :param command: The command to pass in to the remote sub...
[ "def", "run", "(", "conn", ",", "command", ",", "exit", "=", "False", ",", "timeout", "=", "None", ",", "*", "*", "kw", ")", ":", "stop_on_error", "=", "kw", ".", "pop", "(", "'stop_on_error'", ",", "True", ")", "if", "not", "kw", ".", "get", "("...
A real-time-logging implementation of a remote subprocess.Popen call where a command is just executed on the remote end and no other handling is done. :param conn: A connection oject :param command: The command to pass in to the remote subprocess.Popen :param exit: If this call should close the connect...
[ "A", "real", "-", "time", "-", "logging", "implementation", "of", "a", "remote", "subprocess", ".", "Popen", "call", "where", "a", "command", "is", "just", "executed", "on", "the", "remote", "end", "and", "no", "other", "handling", "is", "done", "." ]
train
https://github.com/alfredodeza/remoto/blob/b7625e571a4b6c83f9589a1e9ad07354e42bf0d3/remoto/process.py#L101-L138
alfredodeza/remoto
remoto/process.py
check
def check(conn, command, exit=False, timeout=None, **kw): """ Execute a remote command with ``subprocess.Popen`` but report back the results in a tuple with three items: stdout, stderr, and exit status. This helper function *does not* provide any logging as it is the caller's responsibility to do s...
python
def check(conn, command, exit=False, timeout=None, **kw): """ Execute a remote command with ``subprocess.Popen`` but report back the results in a tuple with three items: stdout, stderr, and exit status. This helper function *does not* provide any logging as it is the caller's responsibility to do s...
[ "def", "check", "(", "conn", ",", "command", ",", "exit", "=", "False", ",", "timeout", "=", "None", ",", "*", "*", "kw", ")", ":", "command", "=", "conn", ".", "cmd", "(", "command", ")", "stop_on_error", "=", "kw", ".", "pop", "(", "'stop_on_erro...
Execute a remote command with ``subprocess.Popen`` but report back the results in a tuple with three items: stdout, stderr, and exit status. This helper function *does not* provide any logging as it is the caller's responsibility to do so.
[ "Execute", "a", "remote", "command", "with", "subprocess", ".", "Popen", "but", "report", "back", "the", "results", "in", "a", "tuple", "with", "three", "items", ":", "stdout", "stderr", "and", "exit", "status", "." ]
train
https://github.com/alfredodeza/remoto/blob/b7625e571a4b6c83f9589a1e9ad07354e42bf0d3/remoto/process.py#L167-L213
TadLeonard/tfatool
tfatool/sync.py
up_down_by_arrival
def up_down_by_arrival(*filters, local_dir=".", remote_dir=DEFAULT_REMOTE_DIR): """Monitors a local directory and a remote FlashAir directory and generates sets of new files to be uploaded or downloaded. Sets to upload are generated in a tuple like (Direction.up, {...}), while dow...
python
def up_down_by_arrival(*filters, local_dir=".", remote_dir=DEFAULT_REMOTE_DIR): """Monitors a local directory and a remote FlashAir directory and generates sets of new files to be uploaded or downloaded. Sets to upload are generated in a tuple like (Direction.up, {...}), while dow...
[ "def", "up_down_by_arrival", "(", "*", "filters", ",", "local_dir", "=", "\".\"", ",", "remote_dir", "=", "DEFAULT_REMOTE_DIR", ")", ":", "local_monitor", "=", "watch_local_files", "(", "*", "filters", ",", "local_dir", "=", "local_dir", ")", "remote_monitor", "...
Monitors a local directory and a remote FlashAir directory and generates sets of new files to be uploaded or downloaded. Sets to upload are generated in a tuple like (Direction.up, {...}), while download sets to download are generated in a tuple like (Direction.down, {...}). The generator yields bef...
[ "Monitors", "a", "local", "directory", "and", "a", "remote", "FlashAir", "directory", "and", "generates", "sets", "of", "new", "files", "to", "be", "uploaded", "or", "downloaded", ".", "Sets", "to", "upload", "are", "generated", "in", "a", "tuple", "like", ...
train
https://github.com/TadLeonard/tfatool/blob/12da2807b5fb538c5317ef255d846b32ceb174d0/tfatool/sync.py#L83-L115
TadLeonard/tfatool
tfatool/sync.py
up_by_arrival
def up_by_arrival(*filters, local_dir=".", remote_dir=DEFAULT_REMOTE_DIR): """Monitors a local directory and generates sets of new files to be uploaded to FlashAir. Sets to upload are generated in a tuple like (Direction.up, {...}). The generator yields before each upload actually takes place.""" lo...
python
def up_by_arrival(*filters, local_dir=".", remote_dir=DEFAULT_REMOTE_DIR): """Monitors a local directory and generates sets of new files to be uploaded to FlashAir. Sets to upload are generated in a tuple like (Direction.up, {...}). The generator yields before each upload actually takes place.""" lo...
[ "def", "up_by_arrival", "(", "*", "filters", ",", "local_dir", "=", "\".\"", ",", "remote_dir", "=", "DEFAULT_REMOTE_DIR", ")", ":", "local_monitor", "=", "watch_local_files", "(", "*", "filters", ",", "local_dir", "=", "local_dir", ")", "_", ",", "file_set", ...
Monitors a local directory and generates sets of new files to be uploaded to FlashAir. Sets to upload are generated in a tuple like (Direction.up, {...}). The generator yields before each upload actually takes place.
[ "Monitors", "a", "local", "directory", "and", "generates", "sets", "of", "new", "files", "to", "be", "uploaded", "to", "FlashAir", ".", "Sets", "to", "upload", "are", "generated", "in", "a", "tuple", "like", "(", "Direction", ".", "up", "{", "...", "}", ...
train
https://github.com/TadLeonard/tfatool/blob/12da2807b5fb538c5317ef255d846b32ceb174d0/tfatool/sync.py#L118-L131
TadLeonard/tfatool
tfatool/sync.py
down_by_arrival
def down_by_arrival(*filters, local_dir=".", remote_dir=DEFAULT_REMOTE_DIR): """Monitors a remote FlashAir directory and generates sets of new files to be downloaded from FlashAir. Sets to download are generated in a tuple like (Direction.down, {...}). The generator yields AFTER each download actually t...
python
def down_by_arrival(*filters, local_dir=".", remote_dir=DEFAULT_REMOTE_DIR): """Monitors a remote FlashAir directory and generates sets of new files to be downloaded from FlashAir. Sets to download are generated in a tuple like (Direction.down, {...}). The generator yields AFTER each download actually t...
[ "def", "down_by_arrival", "(", "*", "filters", ",", "local_dir", "=", "\".\"", ",", "remote_dir", "=", "DEFAULT_REMOTE_DIR", ")", ":", "remote_monitor", "=", "watch_remote_files", "(", "*", "filters", ",", "remote_dir", "=", "remote_dir", ")", "_", ",", "file_...
Monitors a remote FlashAir directory and generates sets of new files to be downloaded from FlashAir. Sets to download are generated in a tuple like (Direction.down, {...}). The generator yields AFTER each download actually takes place.
[ "Monitors", "a", "remote", "FlashAir", "directory", "and", "generates", "sets", "of", "new", "files", "to", "be", "downloaded", "from", "FlashAir", ".", "Sets", "to", "download", "are", "generated", "in", "a", "tuple", "like", "(", "Direction", ".", "down", ...
train
https://github.com/TadLeonard/tfatool/blob/12da2807b5fb538c5317ef255d846b32ceb174d0/tfatool/sync.py#L134-L147
TadLeonard/tfatool
tfatool/sync.py
down_by_time
def down_by_time(*filters, remote_dir=DEFAULT_REMOTE_DIR, local_dir=".", count=1): """Sync most recent file by date, time attribues""" files = command.list_files(*filters, remote_dir=remote_dir) most_recent = sorted(files, key=lambda f: f.datetime) to_sync = most_recent[-count:] _notify_sync(Directi...
python
def down_by_time(*filters, remote_dir=DEFAULT_REMOTE_DIR, local_dir=".", count=1): """Sync most recent file by date, time attribues""" files = command.list_files(*filters, remote_dir=remote_dir) most_recent = sorted(files, key=lambda f: f.datetime) to_sync = most_recent[-count:] _notify_sync(Directi...
[ "def", "down_by_time", "(", "*", "filters", ",", "remote_dir", "=", "DEFAULT_REMOTE_DIR", ",", "local_dir", "=", "\".\"", ",", "count", "=", "1", ")", ":", "files", "=", "command", ".", "list_files", "(", "*", "filters", ",", "remote_dir", "=", "remote_dir...
Sync most recent file by date, time attribues
[ "Sync", "most", "recent", "file", "by", "date", "time", "attribues" ]
train
https://github.com/TadLeonard/tfatool/blob/12da2807b5fb538c5317ef255d846b32ceb174d0/tfatool/sync.py#L164-L170
TadLeonard/tfatool
tfatool/sync.py
down_by_name
def down_by_name(*filters, remote_dir=DEFAULT_REMOTE_DIR, local_dir=".", count=1): """Sync files whose filename attribute is highest in alphanumeric order""" files = command.list_files(*filters, remote_dir=remote_dir) greatest = sorted(files, key=lambda f: f.filename) to_sync = greatest[-count:] _no...
python
def down_by_name(*filters, remote_dir=DEFAULT_REMOTE_DIR, local_dir=".", count=1): """Sync files whose filename attribute is highest in alphanumeric order""" files = command.list_files(*filters, remote_dir=remote_dir) greatest = sorted(files, key=lambda f: f.filename) to_sync = greatest[-count:] _no...
[ "def", "down_by_name", "(", "*", "filters", ",", "remote_dir", "=", "DEFAULT_REMOTE_DIR", ",", "local_dir", "=", "\".\"", ",", "count", "=", "1", ")", ":", "files", "=", "command", ".", "list_files", "(", "*", "filters", ",", "remote_dir", "=", "remote_dir...
Sync files whose filename attribute is highest in alphanumeric order
[ "Sync", "files", "whose", "filename", "attribute", "is", "highest", "in", "alphanumeric", "order" ]
train
https://github.com/TadLeonard/tfatool/blob/12da2807b5fb538c5317ef255d846b32ceb174d0/tfatool/sync.py#L173-L179
TadLeonard/tfatool
tfatool/sync.py
_write_file_safely
def _write_file_safely(local_path, fileinfo, response): """attempts to stream a remote file into a local file object, removes the local file if it's interrupted by any error""" try: _write_file(local_path, fileinfo, response) except BaseException as e: logger.warning("{} interrupted writ...
python
def _write_file_safely(local_path, fileinfo, response): """attempts to stream a remote file into a local file object, removes the local file if it's interrupted by any error""" try: _write_file(local_path, fileinfo, response) except BaseException as e: logger.warning("{} interrupted writ...
[ "def", "_write_file_safely", "(", "local_path", ",", "fileinfo", ",", "response", ")", ":", "try", ":", "_write_file", "(", "local_path", ",", "fileinfo", ",", "response", ")", "except", "BaseException", "as", "e", ":", "logger", ".", "warning", "(", "\"{} i...
attempts to stream a remote file into a local file object, removes the local file if it's interrupted by any error
[ "attempts", "to", "stream", "a", "remote", "file", "into", "a", "local", "file", "object", "removes", "the", "local", "file", "if", "it", "s", "interrupted", "by", "any", "error" ]
train
https://github.com/TadLeonard/tfatool/blob/12da2807b5fb538c5317ef255d846b32ceb174d0/tfatool/sync.py#L215-L225
TadLeonard/tfatool
tfatool/sync.py
up_by_files
def up_by_files(to_sync, remote_dir=DEFAULT_REMOTE_DIR, remote_files=None): """Sync a given list of local files to `remote_dir` dir""" if remote_files is None: remote_files = command.map_files_raw(remote_dir=remote_dir) for local_file in to_sync: _sync_local_file(local_file, remote_dir, remo...
python
def up_by_files(to_sync, remote_dir=DEFAULT_REMOTE_DIR, remote_files=None): """Sync a given list of local files to `remote_dir` dir""" if remote_files is None: remote_files = command.map_files_raw(remote_dir=remote_dir) for local_file in to_sync: _sync_local_file(local_file, remote_dir, remo...
[ "def", "up_by_files", "(", "to_sync", ",", "remote_dir", "=", "DEFAULT_REMOTE_DIR", ",", "remote_files", "=", "None", ")", ":", "if", "remote_files", "is", "None", ":", "remote_files", "=", "command", ".", "map_files_raw", "(", "remote_dir", "=", "remote_dir", ...
Sync a given list of local files to `remote_dir` dir
[ "Sync", "a", "given", "list", "of", "local", "files", "to", "remote_dir", "dir" ]
train
https://github.com/TadLeonard/tfatool/blob/12da2807b5fb538c5317ef255d846b32ceb174d0/tfatool/sync.py#L289-L294
TadLeonard/tfatool
tfatool/sync.py
up_by_time
def up_by_time(*filters, local_dir=".", remote_dir=DEFAULT_REMOTE_DIR, count=1): """Sync most recent file by date, time attribues""" remote_files = command.map_files_raw(remote_dir=remote_dir) local_files = list_local_files(*filters, local_dir=local_dir) most_recent = sorted(local_files, key=lambda f: f...
python
def up_by_time(*filters, local_dir=".", remote_dir=DEFAULT_REMOTE_DIR, count=1): """Sync most recent file by date, time attribues""" remote_files = command.map_files_raw(remote_dir=remote_dir) local_files = list_local_files(*filters, local_dir=local_dir) most_recent = sorted(local_files, key=lambda f: f...
[ "def", "up_by_time", "(", "*", "filters", ",", "local_dir", "=", "\".\"", ",", "remote_dir", "=", "DEFAULT_REMOTE_DIR", ",", "count", "=", "1", ")", ":", "remote_files", "=", "command", ".", "map_files_raw", "(", "remote_dir", "=", "remote_dir", ")", "local_...
Sync most recent file by date, time attribues
[ "Sync", "most", "recent", "file", "by", "date", "time", "attribues" ]
train
https://github.com/TadLeonard/tfatool/blob/12da2807b5fb538c5317ef255d846b32ceb174d0/tfatool/sync.py#L297-L304
TadLeonard/tfatool
tfatool/sync.py
up_by_name
def up_by_name(*filters, local_dir=".", remote_dir=DEFAULT_REMOTE_DIR, count=1): """Sync files whose filename attribute is highest in alphanumeric order""" remote_files = command.map_files_raw(remote_dir=remote_dir) local_files = list_local_files(*filters, local_dir=local_dir) greatest = sorted(local_fi...
python
def up_by_name(*filters, local_dir=".", remote_dir=DEFAULT_REMOTE_DIR, count=1): """Sync files whose filename attribute is highest in alphanumeric order""" remote_files = command.map_files_raw(remote_dir=remote_dir) local_files = list_local_files(*filters, local_dir=local_dir) greatest = sorted(local_fi...
[ "def", "up_by_name", "(", "*", "filters", ",", "local_dir", "=", "\".\"", ",", "remote_dir", "=", "DEFAULT_REMOTE_DIR", ",", "count", "=", "1", ")", ":", "remote_files", "=", "command", ".", "map_files_raw", "(", "remote_dir", "=", "remote_dir", ")", "local_...
Sync files whose filename attribute is highest in alphanumeric order
[ "Sync", "files", "whose", "filename", "attribute", "is", "highest", "in", "alphanumeric", "order" ]
train
https://github.com/TadLeonard/tfatool/blob/12da2807b5fb538c5317ef255d846b32ceb174d0/tfatool/sync.py#L307-L314
TadLeonard/tfatool
tfatool/sync.py
_upload_file_safely
def _upload_file_safely(fileinfo, remote_dir): """attempts to upload a local file to FlashAir, tries to remove the remote file if interrupted by any error""" try: upload.upload_file(fileinfo.path, remote_dir=remote_dir) except BaseException as e: logger.warning("{} interrupted writing {}...
python
def _upload_file_safely(fileinfo, remote_dir): """attempts to upload a local file to FlashAir, tries to remove the remote file if interrupted by any error""" try: upload.upload_file(fileinfo.path, remote_dir=remote_dir) except BaseException as e: logger.warning("{} interrupted writing {}...
[ "def", "_upload_file_safely", "(", "fileinfo", ",", "remote_dir", ")", ":", "try", ":", "upload", ".", "upload_file", "(", "fileinfo", ".", "path", ",", "remote_dir", "=", "remote_dir", ")", "except", "BaseException", "as", "e", ":", "logger", ".", "warning"...
attempts to upload a local file to FlashAir, tries to remove the remote file if interrupted by any error
[ "attempts", "to", "upload", "a", "local", "file", "to", "FlashAir", "tries", "to", "remove", "the", "remote", "file", "if", "interrupted", "by", "any", "error" ]
train
https://github.com/TadLeonard/tfatool/blob/12da2807b5fb538c5317ef255d846b32ceb174d0/tfatool/sync.py#L344-L354
alfredodeza/remoto
remoto/file_sync.py
rsync
def rsync(hosts, source, destination, logger=None, sudo=False): """ Grabs the hosts (or single host), creates the connection object for each and set the rsync execnet engine to push the files. It assumes that all of the destinations for the different hosts is the same. This deviates from what execn...
python
def rsync(hosts, source, destination, logger=None, sudo=False): """ Grabs the hosts (or single host), creates the connection object for each and set the rsync execnet engine to push the files. It assumes that all of the destinations for the different hosts is the same. This deviates from what execn...
[ "def", "rsync", "(", "hosts", ",", "source", ",", "destination", ",", "logger", "=", "None", ",", "sudo", "=", "False", ")", ":", "logger", "=", "logger", "or", "basic_remote_logger", "(", ")", "sync", "=", "_RSync", "(", "source", ",", "logger", "=", ...
Grabs the hosts (or single host), creates the connection object for each and set the rsync execnet engine to push the files. It assumes that all of the destinations for the different hosts is the same. This deviates from what execnet does because it has the flexibility to push to different locations.
[ "Grabs", "the", "hosts", "(", "or", "single", "host", ")", "creates", "the", "connection", "object", "for", "each", "and", "set", "the", "rsync", "execnet", "engine", "to", "push", "the", "files", "." ]
train
https://github.com/alfredodeza/remoto/blob/b7625e571a4b6c83f9589a1e9ad07354e42bf0d3/remoto/file_sync.py#L21-L45
ApproxEng/approxeng.input
src/python/approxeng/input/__init__.py
map_into_range
def map_into_range(low, high, raw_value): """ Map an input function into an output value, clamping such that the magnitude of the output is at most 1.0 :param low: The value in the input range corresponding to zero. :param high: The value in the input range corresponding to 1.0 or -1.0,...
python
def map_into_range(low, high, raw_value): """ Map an input function into an output value, clamping such that the magnitude of the output is at most 1.0 :param low: The value in the input range corresponding to zero. :param high: The value in the input range corresponding to 1.0 or -1.0,...
[ "def", "map_into_range", "(", "low", ",", "high", ",", "raw_value", ")", ":", "value", "=", "float", "(", "raw_value", ")", "if", "low", "<", "high", ":", "if", "value", "<", "low", ":", "return", "0", "elif", "value", ">", "high", ":", "return", "...
Map an input function into an output value, clamping such that the magnitude of the output is at most 1.0 :param low: The value in the input range corresponding to zero. :param high: The value in the input range corresponding to 1.0 or -1.0, depending on whether this is higher or lower than the...
[ "Map", "an", "input", "function", "into", "an", "output", "value", "clamping", "such", "that", "the", "magnitude", "of", "the", "output", "is", "at", "most", "1", ".", "0" ]
train
https://github.com/ApproxEng/approxeng.input/blob/0cdf8eed6bfd26ca3b20b4478f352787f60ae8ef/src/python/approxeng/input/__init__.py#L12-L37
ApproxEng/approxeng.input
src/python/approxeng/input/__init__.py
map_single_axis
def map_single_axis(low, high, dead_zone, hot_zone, value): """ Apply dead and hot zones before mapping a value to a range. The dead and hot zones are both expressed as the proportion of the axis range which should be regarded as 0.0 or 1.0 (or -1.0 depending on cardinality) respectively, so for example...
python
def map_single_axis(low, high, dead_zone, hot_zone, value): """ Apply dead and hot zones before mapping a value to a range. The dead and hot zones are both expressed as the proportion of the axis range which should be regarded as 0.0 or 1.0 (or -1.0 depending on cardinality) respectively, so for example...
[ "def", "map_single_axis", "(", "low", ",", "high", ",", "dead_zone", ",", "hot_zone", ",", "value", ")", ":", "input_range", "=", "high", "-", "low", "corrected_low", "=", "low", "+", "input_range", "*", "dead_zone", "corrected_high", "=", "high", "-", "in...
Apply dead and hot zones before mapping a value to a range. The dead and hot zones are both expressed as the proportion of the axis range which should be regarded as 0.0 or 1.0 (or -1.0 depending on cardinality) respectively, so for example setting dead zone to 0.2 means the first 20% of the range of the axis w...
[ "Apply", "dead", "and", "hot", "zones", "before", "mapping", "a", "value", "to", "a", "range", ".", "The", "dead", "and", "hot", "zones", "are", "both", "expressed", "as", "the", "proportion", "of", "the", "axis", "range", "which", "should", "be", "regar...
train
https://github.com/ApproxEng/approxeng.input/blob/0cdf8eed6bfd26ca3b20b4478f352787f60ae8ef/src/python/approxeng/input/__init__.py#L40-L72
ApproxEng/approxeng.input
src/python/approxeng/input/__init__.py
map_dual_axis
def map_dual_axis(low, high, centre, dead_zone, hot_zone, value): """ Map an axis with a central dead zone and hot zones at each end to a range from -1.0 to 1.0. This in effect uses two calls to map_single_axis, choosing whether to use centre and low, or centre and high as the low and high values in tha...
python
def map_dual_axis(low, high, centre, dead_zone, hot_zone, value): """ Map an axis with a central dead zone and hot zones at each end to a range from -1.0 to 1.0. This in effect uses two calls to map_single_axis, choosing whether to use centre and low, or centre and high as the low and high values in tha...
[ "def", "map_dual_axis", "(", "low", ",", "high", ",", "centre", ",", "dead_zone", ",", "hot_zone", ",", "value", ")", ":", "if", "value", "<=", "centre", ":", "return", "map_single_axis", "(", "centre", ",", "low", ",", "dead_zone", ",", "hot_zone", ",",...
Map an axis with a central dead zone and hot zones at each end to a range from -1.0 to 1.0. This in effect uses two calls to map_single_axis, choosing whether to use centre and low, or centre and high as the low and high values in that call based on which side of the centre value the input value falls. This is ...
[ "Map", "an", "axis", "with", "a", "central", "dead", "zone", "and", "hot", "zones", "at", "each", "end", "to", "a", "range", "from", "-", "1", ".", "0", "to", "1", ".", "0", ".", "This", "in", "effect", "uses", "two", "calls", "to", "map_single_axi...
train
https://github.com/ApproxEng/approxeng.input/blob/0cdf8eed6bfd26ca3b20b4478f352787f60ae8ef/src/python/approxeng/input/__init__.py#L75-L104
ApproxEng/approxeng.input
src/python/approxeng/input/__init__.py
Controller.register_button_handler
def register_button_handler(self, button_handler, button_sname: str): """ Register a handler function which will be called when a button is pressed :param button_handler: A function which will be called when any of the specified buttons are pressed. The function is calle...
python
def register_button_handler(self, button_handler, button_sname: str): """ Register a handler function which will be called when a button is pressed :param button_handler: A function which will be called when any of the specified buttons are pressed. The function is calle...
[ "def", "register_button_handler", "(", "self", ",", "button_handler", ",", "button_sname", ":", "str", ")", ":", "return", "self", ".", "buttons", ".", "register_button_handler", "(", "button_handler", ",", "self", ".", "buttons", "[", "button_sname", "]", ")" ]
Register a handler function which will be called when a button is pressed :param button_handler: A function which will be called when any of the specified buttons are pressed. The function is called with the Button that was pressed as the sole argument. :param button_sname: ...
[ "Register", "a", "handler", "function", "which", "will", "be", "called", "when", "a", "button", "is", "pressed" ]
train
https://github.com/ApproxEng/approxeng.input/blob/0cdf8eed6bfd26ca3b20b4478f352787f60ae8ef/src/python/approxeng/input/__init__.py#L301-L313
ApproxEng/approxeng.input
src/python/approxeng/input/__init__.py
Axes.axis_updated
def axis_updated(self, event: InputEvent, prefix=None): """ Called to process an absolute axis event from evdev, this is called internally by the controller implementations :internal: :param event: The evdev event to process :param prefix: If present, a ...
python
def axis_updated(self, event: InputEvent, prefix=None): """ Called to process an absolute axis event from evdev, this is called internally by the controller implementations :internal: :param event: The evdev event to process :param prefix: If present, a ...
[ "def", "axis_updated", "(", "self", ",", "event", ":", "InputEvent", ",", "prefix", "=", "None", ")", ":", "if", "prefix", "is", "not", "None", ":", "axis", "=", "self", ".", "axes_by_code", ".", "get", "(", "prefix", "+", "str", "(", "event", ".", ...
Called to process an absolute axis event from evdev, this is called internally by the controller implementations :internal: :param event: The evdev event to process :param prefix: If present, a named prefix that should be applied to the event code when searching for the...
[ "Called", "to", "process", "an", "absolute", "axis", "event", "from", "evdev", "this", "is", "called", "internally", "by", "the", "controller", "implementations" ]
train
https://github.com/ApproxEng/approxeng.input/blob/0cdf8eed6bfd26ca3b20b4478f352787f60ae8ef/src/python/approxeng/input/__init__.py#L338-L356
ApproxEng/approxeng.input
src/python/approxeng/input/__init__.py
Axes.set_axis_centres
def set_axis_centres(self, *args): """ Sets the centre points for each axis to the current value for that axis. This centre value is used when computing the value for the axis and is subtracted before applying any scaling. This will only be applied to CentredAxis instances """ ...
python
def set_axis_centres(self, *args): """ Sets the centre points for each axis to the current value for that axis. This centre value is used when computing the value for the axis and is subtracted before applying any scaling. This will only be applied to CentredAxis instances """ ...
[ "def", "set_axis_centres", "(", "self", ",", "*", "args", ")", ":", "for", "axis", "in", "self", ".", "axes_by_code", ".", "values", "(", ")", ":", "if", "isinstance", "(", "axis", ",", "CentredAxis", ")", ":", "axis", ".", "centre", "=", "axis", "."...
Sets the centre points for each axis to the current value for that axis. This centre value is used when computing the value for the axis and is subtracted before applying any scaling. This will only be applied to CentredAxis instances
[ "Sets", "the", "centre", "points", "for", "each", "axis", "to", "the", "current", "value", "for", "that", "axis", ".", "This", "centre", "value", "is", "used", "when", "computing", "the", "value", "for", "the", "axis", "and", "is", "subtracted", "before", ...
train
https://github.com/ApproxEng/approxeng.input/blob/0cdf8eed6bfd26ca3b20b4478f352787f60ae8ef/src/python/approxeng/input/__init__.py#L358-L366
ApproxEng/approxeng.input
src/python/approxeng/input/__init__.py
Axes.names
def names(self) -> [str]: """ The snames of all axis objects """ return sorted([name for name in self.axes_by_sname.keys() if name is not ''])
python
def names(self) -> [str]: """ The snames of all axis objects """ return sorted([name for name in self.axes_by_sname.keys() if name is not ''])
[ "def", "names", "(", "self", ")", "->", "[", "str", "]", ":", "return", "sorted", "(", "[", "name", "for", "name", "in", "self", ".", "axes_by_sname", ".", "keys", "(", ")", "if", "name", "is", "not", "''", "]", ")" ]
The snames of all axis objects
[ "The", "snames", "of", "all", "axis", "objects" ]
train
https://github.com/ApproxEng/approxeng.input/blob/0cdf8eed6bfd26ca3b20b4478f352787f60ae8ef/src/python/approxeng/input/__init__.py#L379-L383
ApproxEng/approxeng.input
src/python/approxeng/input/__init__.py
TriggerAxis._input_to_raw_value
def _input_to_raw_value(self, value: int) -> float: """ Convert the value read from evdev to a 0.0 to 1.0 range. :internal: :param value: a value ranging from the defined minimum to the defined maximum value. :return: 0.0 at minimum, 1.0 at maximum, line...
python
def _input_to_raw_value(self, value: int) -> float: """ Convert the value read from evdev to a 0.0 to 1.0 range. :internal: :param value: a value ranging from the defined minimum to the defined maximum value. :return: 0.0 at minimum, 1.0 at maximum, line...
[ "def", "_input_to_raw_value", "(", "self", ",", "value", ":", "int", ")", "->", "float", ":", "return", "(", "float", "(", "value", ")", "-", "self", ".", "min_raw_value", ")", "/", "self", ".", "max_raw_value" ]
Convert the value read from evdev to a 0.0 to 1.0 range. :internal: :param value: a value ranging from the defined minimum to the defined maximum value. :return: 0.0 at minimum, 1.0 at maximum, linearly interpolating between those two points.
[ "Convert", "the", "value", "read", "from", "evdev", "to", "a", "0", ".", "0", "to", "1", ".", "0", "range", "." ]
train
https://github.com/ApproxEng/approxeng.input/blob/0cdf8eed6bfd26ca3b20b4478f352787f60ae8ef/src/python/approxeng/input/__init__.py#L513-L524
ApproxEng/approxeng.input
src/python/approxeng/input/__init__.py
TriggerAxis.value
def value(self) -> float: """ Get a centre-compensated, scaled, value for the axis, taking any dead-zone into account. The value will scale from 0.0 at the edge of the dead-zone to 1.0 (positive) at the extreme position of the trigger or the edge of the hot zone, if defined as other than...
python
def value(self) -> float: """ Get a centre-compensated, scaled, value for the axis, taking any dead-zone into account. The value will scale from 0.0 at the edge of the dead-zone to 1.0 (positive) at the extreme position of the trigger or the edge of the hot zone, if defined as other than...
[ "def", "value", "(", "self", ")", "->", "float", ":", "return", "map_single_axis", "(", "self", ".", "min", ",", "self", ".", "max", ",", "self", ".", "dead_zone", ",", "self", ".", "hot_zone", ",", "self", ".", "__value", ")" ]
Get a centre-compensated, scaled, value for the axis, taking any dead-zone into account. The value will scale from 0.0 at the edge of the dead-zone to 1.0 (positive) at the extreme position of the trigger or the edge of the hot zone, if defined as other than 1.0. :return: a float va...
[ "Get", "a", "centre", "-", "compensated", "scaled", "value", "for", "the", "axis", "taking", "any", "dead", "-", "zone", "into", "account", ".", "The", "value", "will", "scale", "from", "0", ".", "0", "at", "the", "edge", "of", "the", "dead", "-", "z...
train
https://github.com/ApproxEng/approxeng.input/blob/0cdf8eed6bfd26ca3b20b4478f352787f60ae8ef/src/python/approxeng/input/__init__.py#L536-L545
ApproxEng/approxeng.input
src/python/approxeng/input/__init__.py
TriggerAxis.receive_device_value
def receive_device_value(self, raw_value: int): """ Set a new value, called from within the joystick implementation class when parsing the event queue. :param raw_value: the raw value from the joystick hardware :internal: """ new_value = self._input_to_raw_value(raw_val...
python
def receive_device_value(self, raw_value: int): """ Set a new value, called from within the joystick implementation class when parsing the event queue. :param raw_value: the raw value from the joystick hardware :internal: """ new_value = self._input_to_raw_value(raw_val...
[ "def", "receive_device_value", "(", "self", ",", "raw_value", ":", "int", ")", ":", "new_value", "=", "self", ".", "_input_to_raw_value", "(", "raw_value", ")", "if", "self", ".", "button", "is", "not", "None", ":", "if", "new_value", ">", "(", "self", "...
Set a new value, called from within the joystick implementation class when parsing the event queue. :param raw_value: the raw value from the joystick hardware :internal:
[ "Set", "a", "new", "value", "called", "from", "within", "the", "joystick", "implementation", "class", "when", "parsing", "the", "event", "queue", "." ]
train
https://github.com/ApproxEng/approxeng.input/blob/0cdf8eed6bfd26ca3b20b4478f352787f60ae8ef/src/python/approxeng/input/__init__.py#L556-L574
ApproxEng/approxeng.input
src/python/approxeng/input/__init__.py
CentredAxis.value
def value(self) -> float: """ Get a centre-compensated, scaled, value for the axis, taking any dead-zone into account. The value will scale from 0.0 at the edge of the dead-zone to 1.0 (positive) or -1.0 (negative) at the extreme position of the controller or the edge of the hot zone, if...
python
def value(self) -> float: """ Get a centre-compensated, scaled, value for the axis, taking any dead-zone into account. The value will scale from 0.0 at the edge of the dead-zone to 1.0 (positive) or -1.0 (negative) at the extreme position of the controller or the edge of the hot zone, if...
[ "def", "value", "(", "self", ")", "->", "float", ":", "mapped_value", "=", "map_dual_axis", "(", "self", ".", "min", ",", "self", ".", "max", ",", "self", ".", "centre", ",", "self", ".", "dead_zone", ",", "self", ".", "hot_zone", ",", "self", ".", ...
Get a centre-compensated, scaled, value for the axis, taking any dead-zone into account. The value will scale from 0.0 at the edge of the dead-zone to 1.0 (positive) or -1.0 (negative) at the extreme position of the controller or the edge of the hot zone, if defined as other than 1.0. The axis will auto...
[ "Get", "a", "centre", "-", "compensated", "scaled", "value", "for", "the", "axis", "taking", "any", "dead", "-", "zone", "into", "account", ".", "The", "value", "will", "scale", "from", "0", ".", "0", "at", "the", "edge", "of", "the", "dead", "-", "z...
train
https://github.com/ApproxEng/approxeng.input/blob/0cdf8eed6bfd26ca3b20b4478f352787f60ae8ef/src/python/approxeng/input/__init__.py#L703-L718
ApproxEng/approxeng.input
src/python/approxeng/input/__init__.py
CentredAxis.receive_device_value
def receive_device_value(self, raw_value: int): """ Set a new value, called from within the joystick implementation class when parsing the event queue. :param raw_value: the raw value from the joystick hardware :internal: """ new_value = self._input_to_raw_value(raw_va...
python
def receive_device_value(self, raw_value: int): """ Set a new value, called from within the joystick implementation class when parsing the event queue. :param raw_value: the raw value from the joystick hardware :internal: """ new_value = self._input_to_raw_value(raw_va...
[ "def", "receive_device_value", "(", "self", ",", "raw_value", ":", "int", ")", ":", "new_value", "=", "self", ".", "_input_to_raw_value", "(", "raw_value", ")", "self", ".", "__value", "=", "new_value", "if", "new_value", ">", "self", ".", "max", ":", "sel...
Set a new value, called from within the joystick implementation class when parsing the event queue. :param raw_value: the raw value from the joystick hardware :internal:
[ "Set", "a", "new", "value", "called", "from", "within", "the", "joystick", "implementation", "class", "when", "parsing", "the", "event", "queue", "." ]
train
https://github.com/ApproxEng/approxeng.input/blob/0cdf8eed6bfd26ca3b20b4478f352787f60ae8ef/src/python/approxeng/input/__init__.py#L731-L745
ApproxEng/approxeng.input
src/python/approxeng/input/__init__.py
Buttons.button_pressed
def button_pressed(self, key_code, prefix=None): """ Called from the controller classes to update the state of this button manager when a button is pressed. :internal: :param key_code: The code specified when populating Button instances :param prefix: Ap...
python
def button_pressed(self, key_code, prefix=None): """ Called from the controller classes to update the state of this button manager when a button is pressed. :internal: :param key_code: The code specified when populating Button instances :param prefix: Ap...
[ "def", "button_pressed", "(", "self", ",", "key_code", ",", "prefix", "=", "None", ")", ":", "if", "prefix", "is", "not", "None", ":", "state", "=", "self", ".", "buttons_by_code", ".", "get", "(", "prefix", "+", "str", "(", "key_code", ")", ")", "el...
Called from the controller classes to update the state of this button manager when a button is pressed. :internal: :param key_code: The code specified when populating Button instances :param prefix: Applied to key code if present
[ "Called", "from", "the", "controller", "classes", "to", "update", "the", "state", "of", "this", "button", "manager", "when", "a", "button", "is", "pressed", "." ]
train
https://github.com/ApproxEng/approxeng.input/blob/0cdf8eed6bfd26ca3b20b4478f352787f60ae8ef/src/python/approxeng/input/__init__.py#L879-L901
ApproxEng/approxeng.input
src/python/approxeng/input/__init__.py
Buttons.button_released
def button_released(self, key_code, prefix=None): """ Called from the controller classes to update the state of this button manager when a button is released. :internal: :param key_code: The code specified when populating Button instance :param prefix: A...
python
def button_released(self, key_code, prefix=None): """ Called from the controller classes to update the state of this button manager when a button is released. :internal: :param key_code: The code specified when populating Button instance :param prefix: A...
[ "def", "button_released", "(", "self", ",", "key_code", ",", "prefix", "=", "None", ")", ":", "if", "prefix", "is", "not", "None", ":", "state", "=", "self", ".", "buttons_by_code", ".", "get", "(", "prefix", "+", "str", "(", "key_code", ")", ")", "e...
Called from the controller classes to update the state of this button manager when a button is released. :internal: :param key_code: The code specified when populating Button instance :param prefix: Applied to key code if present
[ "Called", "from", "the", "controller", "classes", "to", "update", "the", "state", "of", "this", "button", "manager", "when", "a", "button", "is", "released", "." ]
train
https://github.com/ApproxEng/approxeng.input/blob/0cdf8eed6bfd26ca3b20b4478f352787f60ae8ef/src/python/approxeng/input/__init__.py#L903-L920
ApproxEng/approxeng.input
src/python/approxeng/input/__init__.py
Buttons.check_presses
def check_presses(self): """ Return the set of Buttons which have been pressed since this call was last made, clearing it as we do. :return: A ButtonPresses instance which contains buttons which were pressed since this call was last made. """ pressed = [] for...
python
def check_presses(self): """ Return the set of Buttons which have been pressed since this call was last made, clearing it as we do. :return: A ButtonPresses instance which contains buttons which were pressed since this call was last made. """ pressed = [] for...
[ "def", "check_presses", "(", "self", ")", ":", "pressed", "=", "[", "]", "for", "button", ",", "state", "in", "self", ".", "buttons", ".", "items", "(", ")", ":", "if", "state", ".", "was_pressed_since_last_check", ":", "pressed", ".", "append", "(", "...
Return the set of Buttons which have been pressed since this call was last made, clearing it as we do. :return: A ButtonPresses instance which contains buttons which were pressed since this call was last made.
[ "Return", "the", "set", "of", "Buttons", "which", "have", "been", "pressed", "since", "this", "call", "was", "last", "made", "clearing", "it", "as", "we", "do", "." ]
train
https://github.com/ApproxEng/approxeng.input/blob/0cdf8eed6bfd26ca3b20b4478f352787f60ae8ef/src/python/approxeng/input/__init__.py#L945-L958
ApproxEng/approxeng.input
src/python/approxeng/input/__init__.py
Buttons.held
def held(self, sname): """ Determines whether a button is currently held, identifying it by standard name :param sname: The standard name of the button :return: None if the button is not held down, or is not available, otherwise the number of seconds as a floatin...
python
def held(self, sname): """ Determines whether a button is currently held, identifying it by standard name :param sname: The standard name of the button :return: None if the button is not held down, or is not available, otherwise the number of seconds as a floatin...
[ "def", "held", "(", "self", ",", "sname", ")", ":", "state", "=", "self", ".", "buttons_by_sname", ".", "get", "(", "sname", ")", "if", "state", "is", "not", "None", ":", "if", "state", ".", "is_pressed", "and", "state", ".", "last_pressed", "is", "n...
Determines whether a button is currently held, identifying it by standard name :param sname: The standard name of the button :return: None if the button is not held down, or is not available, otherwise the number of seconds as a floating point value since it was pres...
[ "Determines", "whether", "a", "button", "is", "currently", "held", "identifying", "it", "by", "standard", "name" ]
train
https://github.com/ApproxEng/approxeng.input/blob/0cdf8eed6bfd26ca3b20b4478f352787f60ae8ef/src/python/approxeng/input/__init__.py#L960-L974