repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
3 values
summary
stringlengths
4
350
TkTech/Jawa
jawa/attributes/code.py
CodeAttribute.disassemble
def disassemble(self, *, transforms=None) -> Iterator[Instruction]: """ Disassembles this method, yielding an iterable of :class:`~jawa.util.bytecode.Instruction` objects. """ if transforms is None: if self.cf.classloader: transforms = self.cf.classloa...
python
def disassemble(self, *, transforms=None) -> Iterator[Instruction]: """ Disassembles this method, yielding an iterable of :class:`~jawa.util.bytecode.Instruction` objects. """ if transforms is None: if self.cf.classloader: transforms = self.cf.classloa...
[ "def", "disassemble", "(", "self", ",", "*", ",", "transforms", "=", "None", ")", "->", "Iterator", "[", "Instruction", "]", ":", "if", "transforms", "is", "None", ":", "if", "self", ".", "cf", ".", "classloader", ":", "transforms", "=", "self", ".", ...
Disassembles this method, yielding an iterable of :class:`~jawa.util.bytecode.Instruction` objects.
[ "Disassembles", "this", "method", "yielding", "an", "iterable", "of", ":", "class", ":", "~jawa", ".", "util", ".", "bytecode", ".", "Instruction", "objects", "." ]
94c8424e699029ac33fbc0e866fff0ecb2742289
https://github.com/TkTech/Jawa/blob/94c8424e699029ac33fbc0e866fff0ecb2742289/jawa/attributes/code.py#L123-L141
train
Disassemble this method yielding an iterable of Instructions.
jaapz/cast
cast.py
_volume_command
def _volume_command(ramp, volume): """ Set the value if a volume level is provided, else print the current volume level. """ if volume is not None: ramp.set_volume(float(volume)) else: print ramp.volume
python
def _volume_command(ramp, volume): """ Set the value if a volume level is provided, else print the current volume level. """ if volume is not None: ramp.set_volume(float(volume)) else: print ramp.volume
[ "def", "_volume_command", "(", "ramp", ",", "volume", ")", ":", "if", "volume", "is", "not", "None", ":", "ramp", ".", "set_volume", "(", "float", "(", "volume", ")", ")", "else", ":", "print", "ramp", ".", "volume" ]
Set the value if a volume level is provided, else print the current volume level.
[ "Set", "the", "value", "if", "a", "volume", "level", "is", "provided", "else", "print", "the", "current", "volume", "level", "." ]
1c451b11b7c9ce1c65d53ae1f4d2e44969676a1b
https://github.com/jaapz/cast/blob/1c451b11b7c9ce1c65d53ae1f4d2e44969676a1b/cast.py#L39-L45
train
Set or print the current ramp s volume level.
jaapz/cast
cast.py
_status_command
def _status_command(cast, ramp): """ Build a nice status message and print it to stdout. """ if ramp.is_playing: play_symbol = u'\u25B6' else: play_symbol = u'\u2759\u2759' print u' %s %s by %s from %s via %s, %s of %s' % ( play_symbol, ramp.title, ramp.artist, ...
python
def _status_command(cast, ramp): """ Build a nice status message and print it to stdout. """ if ramp.is_playing: play_symbol = u'\u25B6' else: play_symbol = u'\u2759\u2759' print u' %s %s by %s from %s via %s, %s of %s' % ( play_symbol, ramp.title, ramp.artist, ...
[ "def", "_status_command", "(", "cast", ",", "ramp", ")", ":", "if", "ramp", ".", "is_playing", ":", "play_symbol", "=", "u'\\u25B6'", "else", ":", "play_symbol", "=", "u'\\u2759\\u2759'", "print", "u' %s %s by %s from %s via %s, %s of %s'", "%", "(", "play_symbol", ...
Build a nice status message and print it to stdout.
[ "Build", "a", "nice", "status", "message", "and", "print", "it", "to", "stdout", "." ]
1c451b11b7c9ce1c65d53ae1f4d2e44969676a1b
https://github.com/jaapz/cast/blob/1c451b11b7c9ce1c65d53ae1f4d2e44969676a1b/cast.py#L48-L63
train
Build a nice status message and print it to stdout.
jaapz/cast
cast.py
main
def main(): """ Read the options given on the command line and do the required actions. This method is used in the entry_point `cast`. """ opts = docopt(__doc__, version="cast 0.1") cast = pychromecast.PyChromecast(CHROMECAST_HOST) ramp = cast.get_protocol(pychromecast.PROTOCOL_RAMP) # Wa...
python
def main(): """ Read the options given on the command line and do the required actions. This method is used in the entry_point `cast`. """ opts = docopt(__doc__, version="cast 0.1") cast = pychromecast.PyChromecast(CHROMECAST_HOST) ramp = cast.get_protocol(pychromecast.PROTOCOL_RAMP) # Wa...
[ "def", "main", "(", ")", ":", "opts", "=", "docopt", "(", "__doc__", ",", "version", "=", "\"cast 0.1\"", ")", "cast", "=", "pychromecast", ".", "PyChromecast", "(", "CHROMECAST_HOST", ")", "ramp", "=", "cast", ".", "get_protocol", "(", "pychromecast", "."...
Read the options given on the command line and do the required actions. This method is used in the entry_point `cast`.
[ "Read", "the", "options", "given", "on", "the", "command", "line", "and", "do", "the", "required", "actions", "." ]
1c451b11b7c9ce1c65d53ae1f4d2e44969676a1b
https://github.com/jaapz/cast/blob/1c451b11b7c9ce1c65d53ae1f4d2e44969676a1b/cast.py#L66-L101
train
Main entry point for the Chromecast command line interface.
JarryShaw/f2format
src/lib/tokenize.py
untokenize
def untokenize(iterable): """Transform tokens back into Python source code. It returns a bytes object, encoded using the ENCODING token, which is the first token sequence output by tokenize. Each element returned by the iterable must be a token sequence with at least two elements, a token number an...
python
def untokenize(iterable): """Transform tokens back into Python source code. It returns a bytes object, encoded using the ENCODING token, which is the first token sequence output by tokenize. Each element returned by the iterable must be a token sequence with at least two elements, a token number an...
[ "def", "untokenize", "(", "iterable", ")", ":", "ut", "=", "Untokenizer", "(", ")", "out", "=", "ut", ".", "untokenize", "(", "iterable", ")", "if", "ut", ".", "encoding", "is", "not", "None", ":", "out", "=", "out", ".", "encode", "(", "ut", ".", ...
Transform tokens back into Python source code. It returns a bytes object, encoded using the ENCODING token, which is the first token sequence output by tokenize. Each element returned by the iterable must be a token sequence with at least two elements, a token number and token value. If only two t...
[ "Transform", "tokens", "back", "into", "Python", "source", "code", ".", "It", "returns", "a", "bytes", "object", "encoded", "using", "the", "ENCODING", "token", "which", "is", "the", "first", "token", "sequence", "output", "by", "tokenize", "." ]
a144250268247ce0a98d734a26d53faadff7a6f8
https://github.com/JarryShaw/f2format/blob/a144250268247ce0a98d734a26d53faadff7a6f8/src/lib/tokenize.py#L312-L336
train
Transform tokens back into Python source code.
JarryShaw/f2format
src/lib/tokenize.py
tokenize
def tokenize(readline): """ The tokenize() generator requires one argument, readline, which must be a callable object which provides the same interface as the readline() method of built-in file objects. Each call to the function should return one line of input as bytes. Alternatively, readline ...
python
def tokenize(readline): """ The tokenize() generator requires one argument, readline, which must be a callable object which provides the same interface as the readline() method of built-in file objects. Each call to the function should return one line of input as bytes. Alternatively, readline ...
[ "def", "tokenize", "(", "readline", ")", ":", "# This import is here to avoid problems when the itertools module is not", "# built yet and tokenize is imported.", "from", "itertools", "import", "chain", ",", "repeat", "encoding", ",", "consumed", "=", "detect_encoding", "(", ...
The tokenize() generator requires one argument, readline, which must be a callable object which provides the same interface as the readline() method of built-in file objects. Each call to the function should return one line of input as bytes. Alternatively, readline can be a callable function terminat...
[ "The", "tokenize", "()", "generator", "requires", "one", "argument", "readline", "which", "must", "be", "a", "callable", "object", "which", "provides", "the", "same", "interface", "as", "the", "readline", "()", "method", "of", "built", "-", "in", "file", "ob...
a144250268247ce0a98d734a26d53faadff7a6f8
https://github.com/JarryShaw/f2format/blob/a144250268247ce0a98d734a26d53faadff7a6f8/src/lib/tokenize.py#L459-L484
train
Tokenize a line of text into a sequence of tokens.
piotr-rusin/spam-lists
spam_lists/clients.py
get_powers_of_2
def get_powers_of_2(_sum): """Get powers of 2 that sum up to the given number. This function transforms given integer to a binary string. A reversed value limited to digits of binary number is extracted from it, and each of its characters is enumerated. Each digit is tested for not being 0. If the...
python
def get_powers_of_2(_sum): """Get powers of 2 that sum up to the given number. This function transforms given integer to a binary string. A reversed value limited to digits of binary number is extracted from it, and each of its characters is enumerated. Each digit is tested for not being 0. If the...
[ "def", "get_powers_of_2", "(", "_sum", ")", ":", "return", "[", "2", "**", "y", "for", "y", ",", "x", "in", "enumerate", "(", "bin", "(", "_sum", ")", "[", ":", "1", ":", "-", "1", "]", ")", "if", "int", "(", "x", ")", "]" ]
Get powers of 2 that sum up to the given number. This function transforms given integer to a binary string. A reversed value limited to digits of binary number is extracted from it, and each of its characters is enumerated. Each digit is tested for not being 0. If the test passes, the index associ...
[ "Get", "powers", "of", "2", "that", "sum", "up", "to", "the", "given", "number", "." ]
fd616e8761b28f3eaa503fee5e45f7748e8f88f2
https://github.com/piotr-rusin/spam-lists/blob/fd616e8761b28f3eaa503fee5e45f7748e8f88f2/spam_lists/clients.py#L101-L115
train
Get powers of 2 that sum up to the given number.
piotr-rusin/spam-lists
spam_lists/clients.py
DNSBL._query
def _query(self, host_object): """Query the DNSBL service for given value. :param host_object: an object representing host, created by self._host_factory :returns: an instance of dns.resolver.Answer for given value if it is listed. Otherwise, it returns None. """ ...
python
def _query(self, host_object): """Query the DNSBL service for given value. :param host_object: an object representing host, created by self._host_factory :returns: an instance of dns.resolver.Answer for given value if it is listed. Otherwise, it returns None. """ ...
[ "def", "_query", "(", "self", ",", "host_object", ")", ":", "host_to_query", "=", "host_object", ".", "relative_domain", "query_name", "=", "host_to_query", ".", "derelativize", "(", "self", ".", "_query_suffix", ")", "try", ":", "return", "query", "(", "query...
Query the DNSBL service for given value. :param host_object: an object representing host, created by self._host_factory :returns: an instance of dns.resolver.Answer for given value if it is listed. Otherwise, it returns None.
[ "Query", "the", "DNSBL", "service", "for", "given", "value", "." ]
fd616e8761b28f3eaa503fee5e45f7748e8f88f2
https://github.com/piotr-rusin/spam-lists/blob/fd616e8761b28f3eaa503fee5e45f7748e8f88f2/spam_lists/clients.py#L59-L72
train
Query the DNSBL service for given value.
piotr-rusin/spam-lists
spam_lists/clients.py
HpHosts._query
def _query(self, host_object, classification=False): """Query the client for data of given host. :param host_object: an object representing a host value :param classification: if True: hpHosts is queried also for classification for given host, if listed :returns: content of resp...
python
def _query(self, host_object, classification=False): """Query the client for data of given host. :param host_object: an object representing a host value :param classification: if True: hpHosts is queried also for classification for given host, if listed :returns: content of resp...
[ "def", "_query", "(", "self", ",", "host_object", ",", "classification", "=", "False", ")", ":", "template", "=", "'http://verify.hosts-file.net/?v={}&s={}'", "url", "=", "template", ".", "format", "(", "self", ".", "app_id", ",", "host_object", ".", "to_unicode...
Query the client for data of given host. :param host_object: an object representing a host value :param classification: if True: hpHosts is queried also for classification for given host, if listed :returns: content of response to GET request to hpHosts for data on the given hos...
[ "Query", "the", "client", "for", "data", "of", "given", "host", "." ]
fd616e8761b28f3eaa503fee5e45f7748e8f88f2
https://github.com/piotr-rusin/spam-lists/blob/fd616e8761b28f3eaa503fee5e45f7748e8f88f2/spam_lists/clients.py#L146-L158
train
Query the client for data of a given host.
piotr-rusin/spam-lists
spam_lists/clients.py
GoogleSafeBrowsing._request_address
def _request_address(self): """Get address of a POST request to the service.""" if not self._request_address_val: template = ( 'https://sb-ssl.google.com/safebrowsing/api/lookup' '?client={0}&key={1}&appver={2}&pver={3}' ) self._request...
python
def _request_address(self): """Get address of a POST request to the service.""" if not self._request_address_val: template = ( 'https://sb-ssl.google.com/safebrowsing/api/lookup' '?client={0}&key={1}&appver={2}&pver={3}' ) self._request...
[ "def", "_request_address", "(", "self", ")", ":", "if", "not", "self", ".", "_request_address_val", ":", "template", "=", "(", "'https://sb-ssl.google.com/safebrowsing/api/lookup'", "'?client={0}&key={1}&appver={2}&pver={3}'", ")", "self", ".", "_request_address_val", "=", ...
Get address of a POST request to the service.
[ "Get", "address", "of", "a", "POST", "request", "to", "the", "service", "." ]
fd616e8761b28f3eaa503fee5e45f7748e8f88f2
https://github.com/piotr-rusin/spam-lists/blob/fd616e8761b28f3eaa503fee5e45f7748e8f88f2/spam_lists/clients.py#L192-L205
train
Get address of a POST request to the service.
piotr-rusin/spam-lists
spam_lists/clients.py
GoogleSafeBrowsing._query_once
def _query_once(self, urls): """Perform a single POST request using lookup API. :param urls: a sequence of URLs to put in request body :returns: a response object :raises UnathorizedAPIKeyError: when the API key for this instance is not valid :raises HTTPError: if the HT...
python
def _query_once(self, urls): """Perform a single POST request using lookup API. :param urls: a sequence of URLs to put in request body :returns: a response object :raises UnathorizedAPIKeyError: when the API key for this instance is not valid :raises HTTPError: if the HT...
[ "def", "_query_once", "(", "self", ",", "urls", ")", ":", "request_body", "=", "'{}\\n{}'", ".", "format", "(", "len", "(", "urls", ")", ",", "'\\n'", ".", "join", "(", "urls", ")", ")", "response", "=", "post", "(", "self", ".", "_request_address", ...
Perform a single POST request using lookup API. :param urls: a sequence of URLs to put in request body :returns: a response object :raises UnathorizedAPIKeyError: when the API key for this instance is not valid :raises HTTPError: if the HTTPError was raised for a HTTP code ...
[ "Perform", "a", "single", "POST", "request", "using", "lookup", "API", "." ]
fd616e8761b28f3eaa503fee5e45f7748e8f88f2
https://github.com/piotr-rusin/spam-lists/blob/fd616e8761b28f3eaa503fee5e45f7748e8f88f2/spam_lists/clients.py#L207-L227
train
Perform a single POST request using lookup API.
piotr-rusin/spam-lists
spam_lists/clients.py
GoogleSafeBrowsing._query
def _query(self, urls): """Test URLs for being listed by the service. :param urls: a sequence of URLs to be tested :returns: a tuple containing chunk of URLs and a response pertaining to them if the code of response was 200, which means at least one of the queried URLs is match...
python
def _query(self, urls): """Test URLs for being listed by the service. :param urls: a sequence of URLs to be tested :returns: a tuple containing chunk of URLs and a response pertaining to them if the code of response was 200, which means at least one of the queried URLs is match...
[ "def", "_query", "(", "self", ",", "urls", ")", ":", "urls", "=", "list", "(", "set", "(", "urls", ")", ")", "for", "i", "in", "range", "(", "0", ",", "len", "(", "urls", ")", ",", "self", ".", "max_urls_per_request", ")", ":", "chunk", "=", "u...
Test URLs for being listed by the service. :param urls: a sequence of URLs to be tested :returns: a tuple containing chunk of URLs and a response pertaining to them if the code of response was 200, which means at least one of the queried URLs is matched in either the phishing, ...
[ "Test", "URLs", "for", "being", "listed", "by", "the", "service", "." ]
fd616e8761b28f3eaa503fee5e45f7748e8f88f2
https://github.com/piotr-rusin/spam-lists/blob/fd616e8761b28f3eaa503fee5e45f7748e8f88f2/spam_lists/clients.py#L229-L243
train
Test URLs for being listed by the service.
piotr-rusin/spam-lists
spam_lists/clients.py
GoogleSafeBrowsing._get_match_and_classification
def _get_match_and_classification(self, urls): """Get classification for all matching URLs. :param urls: a sequence of URLs to test :return: a tuple containing matching URL and classification string pertaining to it """ for url_list, response in self._query(urls): ...
python
def _get_match_and_classification(self, urls): """Get classification for all matching URLs. :param urls: a sequence of URLs to test :return: a tuple containing matching URL and classification string pertaining to it """ for url_list, response in self._query(urls): ...
[ "def", "_get_match_and_classification", "(", "self", ",", "urls", ")", ":", "for", "url_list", ",", "response", "in", "self", ".", "_query", "(", "urls", ")", ":", "classification_set", "=", "response", ".", "text", ".", "splitlines", "(", ")", "for", "url...
Get classification for all matching URLs. :param urls: a sequence of URLs to test :return: a tuple containing matching URL and classification string pertaining to it
[ "Get", "classification", "for", "all", "matching", "URLs", "." ]
fd616e8761b28f3eaa503fee5e45f7748e8f88f2
https://github.com/piotr-rusin/spam-lists/blob/fd616e8761b28f3eaa503fee5e45f7748e8f88f2/spam_lists/clients.py#L256-L267
train
Get classification for all matching URLs.
piotr-rusin/spam-lists
spam_lists/clients.py
GoogleSafeBrowsing.lookup_matching
def lookup_matching(self, urls): """Get items for all listed URLs. :param urls: a sequence of URLs to be tested :returns: objects representing listed URLs :raises InvalidURLError: if there are any invalid URLs in the sequence """ for url, _class in self._get_matc...
python
def lookup_matching(self, urls): """Get items for all listed URLs. :param urls: a sequence of URLs to be tested :returns: objects representing listed URLs :raises InvalidURLError: if there are any invalid URLs in the sequence """ for url, _class in self._get_matc...
[ "def", "lookup_matching", "(", "self", ",", "urls", ")", ":", "for", "url", ",", "_class", "in", "self", ".", "_get_match_and_classification", "(", "urls", ")", ":", "classification", "=", "set", "(", "_class", ".", "split", "(", "','", ")", ")", "yield"...
Get items for all listed URLs. :param urls: a sequence of URLs to be tested :returns: objects representing listed URLs :raises InvalidURLError: if there are any invalid URLs in the sequence
[ "Get", "items", "for", "all", "listed", "URLs", "." ]
fd616e8761b28f3eaa503fee5e45f7748e8f88f2
https://github.com/piotr-rusin/spam-lists/blob/fd616e8761b28f3eaa503fee5e45f7748e8f88f2/spam_lists/clients.py#L270-L280
train
Get items for all listed URLs.
mardix/pylot
pylot/__init__.py
Pylot.init
def init(cls, flask_or_import_name, directory=None, config=None): """ Allow to register all subclasses of Pylot So we call it once initiating :param flask_or_import_name: Flask instance or import name -> __name__ :param directory: The directory containing your project's Views, Te...
python
def init(cls, flask_or_import_name, directory=None, config=None): """ Allow to register all subclasses of Pylot So we call it once initiating :param flask_or_import_name: Flask instance or import name -> __name__ :param directory: The directory containing your project's Views, Te...
[ "def", "init", "(", "cls", ",", "flask_or_import_name", ",", "directory", "=", "None", ",", "config", "=", "None", ")", ":", "if", "isinstance", "(", "flask_or_import_name", ",", "Flask", ")", ":", "app", "=", "flask_or_import_name", "else", ":", "app", "=...
Allow to register all subclasses of Pylot So we call it once initiating :param flask_or_import_name: Flask instance or import name -> __name__ :param directory: The directory containing your project's Views, Templates and Static :param config: string of config object. ie: "app.config.Dev...
[ "Allow", "to", "register", "all", "subclasses", "of", "Pylot", "So", "we", "call", "it", "once", "initiating", ":", "param", "flask_or_import_name", ":", "Flask", "instance", "or", "import", "name", "-", ">", "__name__", ":", "param", "directory", ":", "The"...
506a33a56ebdfc0925b94015e8cf98ccb16a143c
https://github.com/mardix/pylot/blob/506a33a56ebdfc0925b94015e8cf98ccb16a143c/pylot/__init__.py#L70-L101
train
Initialize the Pylot s base application.
mardix/pylot
pylot/__init__.py
Pylot.bind_
def bind_(cls, kls): """ To bind application that needs the 'app' object to init :param app: callable function that will receive 'Flask.app' as first arg """ if not hasattr(kls, "__call__"): raise TypeError("From Pylot.bind_: '%s' is not callable" % kls) cls._...
python
def bind_(cls, kls): """ To bind application that needs the 'app' object to init :param app: callable function that will receive 'Flask.app' as first arg """ if not hasattr(kls, "__call__"): raise TypeError("From Pylot.bind_: '%s' is not callable" % kls) cls._...
[ "def", "bind_", "(", "cls", ",", "kls", ")", ":", "if", "not", "hasattr", "(", "kls", ",", "\"__call__\"", ")", ":", "raise", "TypeError", "(", "\"From Pylot.bind_: '%s' is not callable\"", "%", "kls", ")", "cls", ".", "_bind", ".", "add", "(", "kls", ")...
To bind application that needs the 'app' object to init :param app: callable function that will receive 'Flask.app' as first arg
[ "To", "bind", "application", "that", "needs", "the", "app", "object", "to", "init", ":", "param", "app", ":", "callable", "function", "that", "will", "receive", "Flask", ".", "app", "as", "first", "arg" ]
506a33a56ebdfc0925b94015e8cf98ccb16a143c
https://github.com/mardix/pylot/blob/506a33a56ebdfc0925b94015e8cf98ccb16a143c/pylot/__init__.py#L104-L112
train
Bind a class to a set of unique names.
mardix/pylot
pylot/__init__.py
Pylot.extends_
def extends_(cls, kls): """ A view decorator to extend another view class or function to itself It will inherit all its methods and propeties and use them on itself -- EXAMPLES -- class Index(Pylot): pass index = Index() ::-> As decorator on classe...
python
def extends_(cls, kls): """ A view decorator to extend another view class or function to itself It will inherit all its methods and propeties and use them on itself -- EXAMPLES -- class Index(Pylot): pass index = Index() ::-> As decorator on classe...
[ "def", "extends_", "(", "cls", ",", "kls", ")", ":", "if", "inspect", ".", "isclass", "(", "kls", ")", ":", "for", "_name", ",", "_val", "in", "kls", ".", "__dict__", ".", "items", "(", ")", ":", "if", "not", "_name", ".", "startswith", "(", "\"_...
A view decorator to extend another view class or function to itself It will inherit all its methods and propeties and use them on itself -- EXAMPLES -- class Index(Pylot): pass index = Index() ::-> As decorator on classes :: @index.extends_ class A...
[ "A", "view", "decorator", "to", "extend", "another", "view", "class", "or", "function", "to", "itself", "It", "will", "inherit", "all", "its", "methods", "and", "propeties", "and", "use", "them", "on", "itself" ]
506a33a56ebdfc0925b94015e8cf98ccb16a143c
https://github.com/mardix/pylot/blob/506a33a56ebdfc0925b94015e8cf98ccb16a143c/pylot/__init__.py#L115-L150
train
A view decorator to extend another view class or function to itself
mardix/pylot
pylot/__init__.py
Pylot.config_
def config_(cls, key, default=None): """ Shortcut to access the config in your class :param key: The key to access :param default: The default value when None :returns mixed: """ return cls._app.config.get(key, default)
python
def config_(cls, key, default=None): """ Shortcut to access the config in your class :param key: The key to access :param default: The default value when None :returns mixed: """ return cls._app.config.get(key, default)
[ "def", "config_", "(", "cls", ",", "key", ",", "default", "=", "None", ")", ":", "return", "cls", ".", "_app", ".", "config", ".", "get", "(", "key", ",", "default", ")" ]
Shortcut to access the config in your class :param key: The key to access :param default: The default value when None :returns mixed:
[ "Shortcut", "to", "access", "the", "config", "in", "your", "class", ":", "param", "key", ":", "The", "key", "to", "access", ":", "param", "default", ":", "The", "default", "value", "when", "None", ":", "returns", "mixed", ":" ]
506a33a56ebdfc0925b94015e8cf98ccb16a143c
https://github.com/mardix/pylot/blob/506a33a56ebdfc0925b94015e8cf98ccb16a143c/pylot/__init__.py#L161-L168
train
Shortcut to access the config in your class
mardix/pylot
pylot/__init__.py
Pylot.meta_
def meta_(cls, **kwargs): """ Meta allows you to add meta data to site :params **kwargs: meta keys we're expecting: title (str) description (str) url (str) (Will pick it up by itself if not set) image (str) site_name (str) (but...
python
def meta_(cls, **kwargs): """ Meta allows you to add meta data to site :params **kwargs: meta keys we're expecting: title (str) description (str) url (str) (Will pick it up by itself if not set) image (str) site_name (str) (but...
[ "def", "meta_", "(", "cls", ",", "*", "*", "kwargs", ")", ":", "_name_", "=", "\"META\"", "meta_data", "=", "cls", ".", "_context", ".", "get", "(", "_name_", ",", "{", "}", ")", "for", "k", ",", "v", "in", "kwargs", ".", "items", "(", ")", ":"...
Meta allows you to add meta data to site :params **kwargs: meta keys we're expecting: title (str) description (str) url (str) (Will pick it up by itself if not set) image (str) site_name (str) (but can pick it up from config file) ...
[ "Meta", "allows", "you", "to", "add", "meta", "data", "to", "site", ":", "params", "**", "kwargs", ":" ]
506a33a56ebdfc0925b94015e8cf98ccb16a143c
https://github.com/mardix/pylot/blob/506a33a56ebdfc0925b94015e8cf98ccb16a143c/pylot/__init__.py#L171-L207
train
Meta allows you to add meta data to a site.
mardix/pylot
pylot/__init__.py
Pylot.render
def render(cls, data={}, view_template=None, layout=None, **kwargs): """ To render data to the associate template file of the action view :param data: The context data to pass to the template :param view_template: The file template to use. By default it will map the classname/action.html...
python
def render(cls, data={}, view_template=None, layout=None, **kwargs): """ To render data to the associate template file of the action view :param data: The context data to pass to the template :param view_template: The file template to use. By default it will map the classname/action.html...
[ "def", "render", "(", "cls", ",", "data", "=", "{", "}", ",", "view_template", "=", "None", ",", "layout", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "not", "view_template", ":", "stack", "=", "inspect", ".", "stack", "(", ")", "[", "1...
To render data to the associate template file of the action view :param data: The context data to pass to the template :param view_template: The file template to use. By default it will map the classname/action.html :param layout: The body layout, must contain {% include __view_template__ %}
[ "To", "render", "data", "to", "the", "associate", "template", "file", "of", "the", "action", "view", ":", "param", "data", ":", "The", "context", "data", "to", "pass", "to", "the", "template", ":", "param", "view_template", ":", "The", "file", "template", ...
506a33a56ebdfc0925b94015e8cf98ccb16a143c
https://github.com/mardix/pylot/blob/506a33a56ebdfc0925b94015e8cf98ccb16a143c/pylot/__init__.py#L224-L249
train
Render the template file of the action with the given data.
mardix/pylot
pylot/__init__.py
Mailer.send
def send(self, to, subject, body, reply_to=None, **kwargs): """ Send simple message """ if self.provider == "SES": self.mail.send(to=to, subject=subject, body=body, reply_to=reply_to, ...
python
def send(self, to, subject, body, reply_to=None, **kwargs): """ Send simple message """ if self.provider == "SES": self.mail.send(to=to, subject=subject, body=body, reply_to=reply_to, ...
[ "def", "send", "(", "self", ",", "to", ",", "subject", ",", "body", ",", "reply_to", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "provider", "==", "\"SES\"", ":", "self", ".", "mail", ".", "send", "(", "to", "=", "to", ",...
Send simple message
[ "Send", "simple", "message" ]
506a33a56ebdfc0925b94015e8cf98ccb16a143c
https://github.com/mardix/pylot/blob/506a33a56ebdfc0925b94015e8cf98ccb16a143c/pylot/__init__.py#L275-L288
train
Send a message to the specified to list.
mardix/pylot
pylot/__init__.py
Mailer.send_template
def send_template(self, template, to, reply_to=None, **context): """ Send Template message """ if self.provider == "SES": self.mail.send_template(template=template, to=to, reply_to=reply_to, **context) elif self.provider == "FLASK-MAIL": ses_mail = ses_mai...
python
def send_template(self, template, to, reply_to=None, **context): """ Send Template message """ if self.provider == "SES": self.mail.send_template(template=template, to=to, reply_to=reply_to, **context) elif self.provider == "FLASK-MAIL": ses_mail = ses_mai...
[ "def", "send_template", "(", "self", ",", "template", ",", "to", ",", "reply_to", "=", "None", ",", "*", "*", "context", ")", ":", "if", "self", ".", "provider", "==", "\"SES\"", ":", "self", ".", "mail", ".", "send_template", "(", "template", "=", "...
Send Template message
[ "Send", "Template", "message" ]
506a33a56ebdfc0925b94015e8cf98ccb16a143c
https://github.com/mardix/pylot/blob/506a33a56ebdfc0925b94015e8cf98ccb16a143c/pylot/__init__.py#L290-L306
train
Send a template to the specified to list.
jim-easterbrook/pyctools
src/pyctools/components/io/rawfilereader.py
RawFileReader.file_reader
def file_reader(self): """Generator process to read file""" self.update_config() path = self.config['path'] fourcc = self.metadata.get('fourcc') xlen, ylen = self.metadata.image_size() # set bits per pixel and component dimensions if fourcc in ('BGR[24]',): ...
python
def file_reader(self): """Generator process to read file""" self.update_config() path = self.config['path'] fourcc = self.metadata.get('fourcc') xlen, ylen = self.metadata.image_size() # set bits per pixel and component dimensions if fourcc in ('BGR[24]',): ...
[ "def", "file_reader", "(", "self", ")", ":", "self", ".", "update_config", "(", ")", "path", "=", "self", ".", "config", "[", "'path'", "]", "fourcc", "=", "self", ".", "metadata", ".", "get", "(", "'fourcc'", ")", "xlen", ",", "ylen", "=", "self", ...
Generator process to read file
[ "Generator", "process", "to", "read", "file" ]
2a958665326892f45f249bebe62c2c23f306732b
https://github.com/jim-easterbrook/pyctools/blob/2a958665326892f45f249bebe62c2c23f306732b/src/pyctools/components/io/rawfilereader.py#L106-L230
train
Generator process to read a single file from disk
astraw38/lint
lint/utils/general.py
cd_ctx
def cd_ctx(directory): """ Context manager. Stores current dir, then changes to given directory. At the end it changes back. :param directory: :return: """ prevdir = os.path.abspath(os.curdir) if os.path.isdir(directory): os.chdir(directory) yield os.chdir(prevdir)
python
def cd_ctx(directory): """ Context manager. Stores current dir, then changes to given directory. At the end it changes back. :param directory: :return: """ prevdir = os.path.abspath(os.curdir) if os.path.isdir(directory): os.chdir(directory) yield os.chdir(prevdir)
[ "def", "cd_ctx", "(", "directory", ")", ":", "prevdir", "=", "os", ".", "path", ".", "abspath", "(", "os", ".", "curdir", ")", "if", "os", ".", "path", ".", "isdir", "(", "directory", ")", ":", "os", ".", "chdir", "(", "directory", ")", "yield", ...
Context manager. Stores current dir, then changes to given directory. At the end it changes back. :param directory: :return:
[ "Context", "manager", ".", "Stores", "current", "dir", "then", "changes", "to", "given", "directory", ".", "At", "the", "end", "it", "changes", "back", ".", ":", "param", "directory", ":", ":", "return", ":" ]
162ceefcb812f07d18544aaa887b9ec4f102cfb1
https://github.com/astraw38/lint/blob/162ceefcb812f07d18544aaa887b9ec4f102cfb1/lint/utils/general.py#L12-L23
train
Context manager. Stores current dir then changes to given directory.
astraw38/lint
lint/utils/general.py
dump_to_console
def dump_to_console(pylint_data): """ Displays pylint data to the console. :param pylint_data: :return: """ for key, value in list(pylint_data.items()): if key not in ('errors', 'total', 'scores', 'average') and len(value) > 0: print("\n*********** {}".format(key)) ...
python
def dump_to_console(pylint_data): """ Displays pylint data to the console. :param pylint_data: :return: """ for key, value in list(pylint_data.items()): if key not in ('errors', 'total', 'scores', 'average') and len(value) > 0: print("\n*********** {}".format(key)) ...
[ "def", "dump_to_console", "(", "pylint_data", ")", ":", "for", "key", ",", "value", "in", "list", "(", "pylint_data", ".", "items", "(", ")", ")", ":", "if", "key", "not", "in", "(", "'errors'", ",", "'total'", ",", "'scores'", ",", "'average'", ")", ...
Displays pylint data to the console. :param pylint_data: :return:
[ "Displays", "pylint", "data", "to", "the", "console", "." ]
162ceefcb812f07d18544aaa887b9ec4f102cfb1
https://github.com/astraw38/lint/blob/162ceefcb812f07d18544aaa887b9ec4f102cfb1/lint/utils/general.py#L26-L39
train
Prints the pylint data to the console.
astraw38/lint
lint/utils/general.py
post_to_gerrit
def post_to_gerrit(commit, score=0, message='', user='lunatest', gerrit=None): """ Post the data to gerrit. This right now is a stub, as I'll need to write the code to post up to gerrit. :param commit: Commit ID of the review. :param message: Message to accompany the review score. :param user: ...
python
def post_to_gerrit(commit, score=0, message='', user='lunatest', gerrit=None): """ Post the data to gerrit. This right now is a stub, as I'll need to write the code to post up to gerrit. :param commit: Commit ID of the review. :param message: Message to accompany the review score. :param user: ...
[ "def", "post_to_gerrit", "(", "commit", ",", "score", "=", "0", ",", "message", "=", "''", ",", "user", "=", "'lunatest'", ",", "gerrit", "=", "None", ")", ":", "# ssh -p 29418 review.example.com gerrit review --code-review +1 <commit_id>", "if", "score", ">", "0"...
Post the data to gerrit. This right now is a stub, as I'll need to write the code to post up to gerrit. :param commit: Commit ID of the review. :param message: Message to accompany the review score. :param user: SSH User for posting to gerrit. :param gerrit: Hostname of the gerrit server. :para...
[ "Post", "the", "data", "to", "gerrit", ".", "This", "right", "now", "is", "a", "stub", "as", "I", "ll", "need", "to", "write", "the", "code", "to", "post", "up", "to", "gerrit", "." ]
162ceefcb812f07d18544aaa887b9ec4f102cfb1
https://github.com/astraw38/lint/blob/162ceefcb812f07d18544aaa887b9ec4f102cfb1/lint/utils/general.py#L42-L72
train
Post the data to Gerrit.
astraw38/lint
lint/utils/general.py
sort_by_type
def sort_by_type(file_list): """ Sorts a list of files into types. :param file_list: List of file paths. :return: {extension: [<list of file paths with that extension>]} """ ret_dict = defaultdict(list) for filepath in file_list: _, ext = os.path.splitext(filepath) ret_dict[...
python
def sort_by_type(file_list): """ Sorts a list of files into types. :param file_list: List of file paths. :return: {extension: [<list of file paths with that extension>]} """ ret_dict = defaultdict(list) for filepath in file_list: _, ext = os.path.splitext(filepath) ret_dict[...
[ "def", "sort_by_type", "(", "file_list", ")", ":", "ret_dict", "=", "defaultdict", "(", "list", ")", "for", "filepath", "in", "file_list", ":", "_", ",", "ext", "=", "os", ".", "path", ".", "splitext", "(", "filepath", ")", "ret_dict", "[", "ext", ".",...
Sorts a list of files into types. :param file_list: List of file paths. :return: {extension: [<list of file paths with that extension>]}
[ "Sorts", "a", "list", "of", "files", "into", "types", "." ]
162ceefcb812f07d18544aaa887b9ec4f102cfb1
https://github.com/astraw38/lint/blob/162ceefcb812f07d18544aaa887b9ec4f102cfb1/lint/utils/general.py#L75-L87
train
Sort a list of files into types.
wimglenn/advent-of-code-data
aocd/models.py
Puzzle._get_answer
def _get_answer(self, part): """ Note: Answers are only revealed after a correct submission. If you've have not already solved the puzzle, AocdError will be raised. """ answer_fname = getattr(self, "answer_{}_fname".format(part)) if os.path.isfile(answer_fname): ...
python
def _get_answer(self, part): """ Note: Answers are only revealed after a correct submission. If you've have not already solved the puzzle, AocdError will be raised. """ answer_fname = getattr(self, "answer_{}_fname".format(part)) if os.path.isfile(answer_fname): ...
[ "def", "_get_answer", "(", "self", ",", "part", ")", ":", "answer_fname", "=", "getattr", "(", "self", ",", "\"answer_{}_fname\"", ".", "format", "(", "part", ")", ")", "if", "os", ".", "path", ".", "isfile", "(", "answer_fname", ")", ":", "with", "ope...
Note: Answers are only revealed after a correct submission. If you've have not already solved the puzzle, AocdError will be raised.
[ "Note", ":", "Answers", "are", "only", "revealed", "after", "a", "correct", "submission", ".", "If", "you", "ve", "have", "not", "already", "solved", "the", "puzzle", "AocdError", "will", "be", "raised", "." ]
a3856459d225840f2b6919659fc65aa7a6a74533
https://github.com/wimglenn/advent-of-code-data/blob/a3856459d225840f2b6919659fc65aa7a6a74533/aocd/models.py#L283-L312
train
Get the answer from the puzzle page.
astraw38/lint
lint/utils/git_utils.py
checkout
def checkout(repository, target): """ Check out target into the current directory. Target can be a branch, review Id, or commit. :param repository: Current git repository. :param target: Review ID, commit, branch. :return: Return the most recent commit ID (top of the git log). """ # git...
python
def checkout(repository, target): """ Check out target into the current directory. Target can be a branch, review Id, or commit. :param repository: Current git repository. :param target: Review ID, commit, branch. :return: Return the most recent commit ID (top of the git log). """ # git...
[ "def", "checkout", "(", "repository", ",", "target", ")", ":", "# git fetch <remote> refs/changes/<review_id>", "#git checkout FETCH_HEAD", "repository", ".", "git", ".", "fetch", "(", "[", "next", "(", "iter", "(", "repository", ".", "remotes", ")", ")", ",", "...
Check out target into the current directory. Target can be a branch, review Id, or commit. :param repository: Current git repository. :param target: Review ID, commit, branch. :return: Return the most recent commit ID (top of the git log).
[ "Check", "out", "target", "into", "the", "current", "directory", ".", "Target", "can", "be", "a", "branch", "review", "Id", "or", "commit", "." ]
162ceefcb812f07d18544aaa887b9ec4f102cfb1
https://github.com/astraw38/lint/blob/162ceefcb812f07d18544aaa887b9ec4f102cfb1/lint/utils/git_utils.py#L6-L19
train
Check out target into the current directory.
astraw38/lint
lint/utils/git_utils.py
get_files_changed
def get_files_changed(repository, review_id): """ Get a list of files changed compared to the given review. Compares against current directory. :param repository: Git repository. Used to get remote. - By default uses first remote in list. :param review_id: Gerrit review ID. :return: List ...
python
def get_files_changed(repository, review_id): """ Get a list of files changed compared to the given review. Compares against current directory. :param repository: Git repository. Used to get remote. - By default uses first remote in list. :param review_id: Gerrit review ID. :return: List ...
[ "def", "get_files_changed", "(", "repository", ",", "review_id", ")", ":", "repository", ".", "git", ".", "fetch", "(", "[", "next", "(", "iter", "(", "repository", ".", "remotes", ")", ")", ",", "review_id", "]", ")", "files_changed", "=", "repository", ...
Get a list of files changed compared to the given review. Compares against current directory. :param repository: Git repository. Used to get remote. - By default uses first remote in list. :param review_id: Gerrit review ID. :return: List of file paths relative to current directory.
[ "Get", "a", "list", "of", "files", "changed", "compared", "to", "the", "given", "review", ".", "Compares", "against", "current", "directory", "." ]
162ceefcb812f07d18544aaa887b9ec4f102cfb1
https://github.com/astraw38/lint/blob/162ceefcb812f07d18544aaa887b9ec4f102cfb1/lint/utils/git_utils.py#L22-L38
train
Get a list of files changed compared to the given review.
jim-easterbrook/pyctools
src/pyctools/core/compound.py
Compound.connect
def connect(self, output_name, input_method): """Connect an output to any callable object. :param str output_name: the output to connect. Must be one of the ``'self'`` outputs in the ``linkages`` parameter. :param callable input_method: the thread-safe callable to invoke ...
python
def connect(self, output_name, input_method): """Connect an output to any callable object. :param str output_name: the output to connect. Must be one of the ``'self'`` outputs in the ``linkages`` parameter. :param callable input_method: the thread-safe callable to invoke ...
[ "def", "connect", "(", "self", ",", "output_name", ",", "input_method", ")", ":", "src", ",", "outbox", "=", "self", ".", "_compound_outputs", "[", "output_name", "]", "self", ".", "_compound_children", "[", "src", "]", ".", "connect", "(", "outbox", ",", ...
Connect an output to any callable object. :param str output_name: the output to connect. Must be one of the ``'self'`` outputs in the ``linkages`` parameter. :param callable input_method: the thread-safe callable to invoke when :py:meth:`send` is called.
[ "Connect", "an", "output", "to", "any", "callable", "object", "." ]
2a958665326892f45f249bebe62c2c23f306732b
https://github.com/jim-easterbrook/pyctools/blob/2a958665326892f45f249bebe62c2c23f306732b/src/pyctools/core/compound.py#L165-L176
train
Connect an output to any callable object.
jim-easterbrook/pyctools
src/pyctools/core/compound.py
Compound.bind
def bind(self, source, dest, destmeth): """Guild compatible version of :py:meth:`connect`. This allows Pyctools compound components to be used in `Guild <https://github.com/sparkslabs/guild>`_ pipelines. """ self.connect(source, getattr(dest, destmeth))
python
def bind(self, source, dest, destmeth): """Guild compatible version of :py:meth:`connect`. This allows Pyctools compound components to be used in `Guild <https://github.com/sparkslabs/guild>`_ pipelines. """ self.connect(source, getattr(dest, destmeth))
[ "def", "bind", "(", "self", ",", "source", ",", "dest", ",", "destmeth", ")", ":", "self", ".", "connect", "(", "source", ",", "getattr", "(", "dest", ",", "destmeth", ")", ")" ]
Guild compatible version of :py:meth:`connect`. This allows Pyctools compound components to be used in `Guild <https://github.com/sparkslabs/guild>`_ pipelines.
[ "Guild", "compatible", "version", "of", ":", "py", ":", "meth", ":", "connect", "." ]
2a958665326892f45f249bebe62c2c23f306732b
https://github.com/jim-easterbrook/pyctools/blob/2a958665326892f45f249bebe62c2c23f306732b/src/pyctools/core/compound.py#L178-L185
train
Bind source to dest.
jim-easterbrook/pyctools
src/pyctools/core/compound.py
Compound.set_config
def set_config(self, config): """See :py:meth:`pyctools.core.config.ConfigMixin.set_config`.""" self.config.update(config) if self.config_map: for child_name in self.config_map: child_config = self._compound_children[child_name].get_config() for parent...
python
def set_config(self, config): """See :py:meth:`pyctools.core.config.ConfigMixin.set_config`.""" self.config.update(config) if self.config_map: for child_name in self.config_map: child_config = self._compound_children[child_name].get_config() for parent...
[ "def", "set_config", "(", "self", ",", "config", ")", ":", "self", ".", "config", ".", "update", "(", "config", ")", "if", "self", ".", "config_map", ":", "for", "child_name", "in", "self", ".", "config_map", ":", "child_config", "=", "self", ".", "_co...
See :py:meth:`pyctools.core.config.ConfigMixin.set_config`.
[ "See", ":", "py", ":", "meth", ":", "pyctools", ".", "core", ".", "config", ".", "ConfigMixin", ".", "set_config", "." ]
2a958665326892f45f249bebe62c2c23f306732b
https://github.com/jim-easterbrook/pyctools/blob/2a958665326892f45f249bebe62c2c23f306732b/src/pyctools/core/compound.py#L191-L202
train
Update the config of the current object.
jim-easterbrook/pyctools
src/pyctools/core/compound.py
Compound.start
def start(self): """Start the component running.""" for name, child in self._compound_children.items(): self.logger.debug('start %s (%s)', name, child.__class__.__name__) child.start()
python
def start(self): """Start the component running.""" for name, child in self._compound_children.items(): self.logger.debug('start %s (%s)', name, child.__class__.__name__) child.start()
[ "def", "start", "(", "self", ")", ":", "for", "name", ",", "child", "in", "self", ".", "_compound_children", ".", "items", "(", ")", ":", "self", ".", "logger", ".", "debug", "(", "'start %s (%s)'", ",", "name", ",", "child", ".", "__class__", ".", "...
Start the component running.
[ "Start", "the", "component", "running", "." ]
2a958665326892f45f249bebe62c2c23f306732b
https://github.com/jim-easterbrook/pyctools/blob/2a958665326892f45f249bebe62c2c23f306732b/src/pyctools/core/compound.py#L209-L213
train
Start the component running.
jim-easterbrook/pyctools
src/pyctools/core/compound.py
Compound.join
def join(self, end_comps=False): """Wait for the compound component's children to stop running. :param bool end_comps: only wait for the components that end a pipeline. This is useful for complex graphs where it is normal for some components not to terminate. """ ...
python
def join(self, end_comps=False): """Wait for the compound component's children to stop running. :param bool end_comps: only wait for the components that end a pipeline. This is useful for complex graphs where it is normal for some components not to terminate. """ ...
[ "def", "join", "(", "self", ",", "end_comps", "=", "False", ")", ":", "for", "name", ",", "child", "in", "self", ".", "_compound_children", ".", "items", "(", ")", ":", "if", "end_comps", "and", "not", "child", ".", "is_pipe_end", "(", ")", ":", "con...
Wait for the compound component's children to stop running. :param bool end_comps: only wait for the components that end a pipeline. This is useful for complex graphs where it is normal for some components not to terminate.
[ "Wait", "for", "the", "compound", "component", "s", "children", "to", "stop", "running", "." ]
2a958665326892f45f249bebe62c2c23f306732b
https://github.com/jim-easterbrook/pyctools/blob/2a958665326892f45f249bebe62c2c23f306732b/src/pyctools/core/compound.py#L221-L233
train
Wait for the compound component s children to stop running.
jim-easterbrook/pyctools
src/pyctools/core/compound.py
Compound.input_connections
def input_connections(self, name): """Yield ordered list of connections to one child. Each result is a ((component, output), (component, input)) tuple. :param string name: the component whose input connections are wanted. """ for input_name in self._compound_childr...
python
def input_connections(self, name): """Yield ordered list of connections to one child. Each result is a ((component, output), (component, input)) tuple. :param string name: the component whose input connections are wanted. """ for input_name in self._compound_childr...
[ "def", "input_connections", "(", "self", ",", "name", ")", ":", "for", "input_name", "in", "self", ".", "_compound_children", "[", "name", "]", ".", "inputs", ":", "dest", "=", "name", ",", "input_name", "for", "src", ",", "dests", "in", "self", ".", "...
Yield ordered list of connections to one child. Each result is a ((component, output), (component, input)) tuple. :param string name: the component whose input connections are wanted.
[ "Yield", "ordered", "list", "of", "connections", "to", "one", "child", "." ]
2a958665326892f45f249bebe62c2c23f306732b
https://github.com/jim-easterbrook/pyctools/blob/2a958665326892f45f249bebe62c2c23f306732b/src/pyctools/core/compound.py#L241-L256
train
Yields ordered list of connections to one child.
jim-easterbrook/pyctools
src/pyctools/core/compound.py
Compound.output_connections
def output_connections(self, name): """Yield ordered list of connections to one child. Each result is a ((component, output), (component, input)) tuple. :param string name: the component whose output connections are wanted. """ for output_name in self._compound_chi...
python
def output_connections(self, name): """Yield ordered list of connections to one child. Each result is a ((component, output), (component, input)) tuple. :param string name: the component whose output connections are wanted. """ for output_name in self._compound_chi...
[ "def", "output_connections", "(", "self", ",", "name", ")", ":", "for", "output_name", "in", "self", ".", "_compound_children", "[", "name", "]", ".", "outputs", ":", "src", "=", "name", ",", "output_name", "if", "src", "in", "self", ".", "_compound_linkag...
Yield ordered list of connections to one child. Each result is a ((component, output), (component, input)) tuple. :param string name: the component whose output connections are wanted.
[ "Yield", "ordered", "list", "of", "connections", "to", "one", "child", "." ]
2a958665326892f45f249bebe62c2c23f306732b
https://github.com/jim-easterbrook/pyctools/blob/2a958665326892f45f249bebe62c2c23f306732b/src/pyctools/core/compound.py#L258-L274
train
Yields ordered list of connections to one child.
jim-easterbrook/pyctools
src/pyctools/components/io/videofilereader.py
VideoFileReader.file_reader
def file_reader(self): """Generator process to read file""" self.update_config() path = self.config['path'] # open file to get dimensions with self.subprocess( ['ffmpeg', '-v', 'info', '-y', '-an', '-vn', '-i', path, '-'], stdout=subprocess.PIPE, s...
python
def file_reader(self): """Generator process to read file""" self.update_config() path = self.config['path'] # open file to get dimensions with self.subprocess( ['ffmpeg', '-v', 'info', '-y', '-an', '-vn', '-i', path, '-'], stdout=subprocess.PIPE, s...
[ "def", "file_reader", "(", "self", ")", ":", "self", ".", "update_config", "(", ")", "path", "=", "self", ".", "config", "[", "'path'", "]", "# open file to get dimensions", "with", "self", ".", "subprocess", "(", "[", "'ffmpeg'", ",", "'-v'", ",", "'info'...
Generator process to read file
[ "Generator", "process", "to", "read", "file" ]
2a958665326892f45f249bebe62c2c23f306732b
https://github.com/jim-easterbrook/pyctools/blob/2a958665326892f45f249bebe62c2c23f306732b/src/pyctools/components/io/videofilereader.py#L78-L135
train
Generator process to read a file and return a tuple of the ID and the size of the file.
astraw38/lint
bin/gpylinter.py
main
def main(review_id, repository, branch="development", user='admin', gerrit=None): """ Do the bulk of the work Exit status will be 1 if pylint fails. Exit status will be 0 if pylint passes. :param review_id: Target gerrit review ID. ex: refs/changes/99/299/3 :param repository: Git repository. ...
python
def main(review_id, repository, branch="development", user='admin', gerrit=None): """ Do the bulk of the work Exit status will be 1 if pylint fails. Exit status will be 0 if pylint passes. :param review_id: Target gerrit review ID. ex: refs/changes/99/299/3 :param repository: Git repository. ...
[ "def", "main", "(", "review_id", ",", "repository", ",", "branch", "=", "\"development\"", ",", "user", "=", "'admin'", ",", "gerrit", "=", "None", ")", ":", "checkout", "(", "repository", ",", "branch", ")", "raw_file_list", "=", "get_files_changed", "(", ...
Do the bulk of the work Exit status will be 1 if pylint fails. Exit status will be 0 if pylint passes. :param review_id: Target gerrit review ID. ex: refs/changes/99/299/3 :param repository: Git repository. :param branch: Git branch to compare to. :param user: SSH User that can connect to gerr...
[ "Do", "the", "bulk", "of", "the", "work" ]
162ceefcb812f07d18544aaa887b9ec4f102cfb1
https://github.com/astraw38/lint/blob/162ceefcb812f07d18544aaa887b9ec4f102cfb1/bin/gpylinter.py#L14-L55
train
Run the bulk of the work.
nicfit/MishMash
mishmash/orm.py
set_sqlite_pragma
def set_sqlite_pragma(dbapi_connection, connection_record): """Allows foreign keys to work in sqlite.""" import sqlite3 if dbapi_connection.__class__ is sqlite3.Connection: cursor = dbapi_connection.cursor() cursor.execute("PRAGMA foreign_keys=ON") cursor.close()
python
def set_sqlite_pragma(dbapi_connection, connection_record): """Allows foreign keys to work in sqlite.""" import sqlite3 if dbapi_connection.__class__ is sqlite3.Connection: cursor = dbapi_connection.cursor() cursor.execute("PRAGMA foreign_keys=ON") cursor.close()
[ "def", "set_sqlite_pragma", "(", "dbapi_connection", ",", "connection_record", ")", ":", "import", "sqlite3", "if", "dbapi_connection", ".", "__class__", "is", "sqlite3", ".", "Connection", ":", "cursor", "=", "dbapi_connection", ".", "cursor", "(", ")", "cursor",...
Allows foreign keys to work in sqlite.
[ "Allows", "foreign", "keys", "to", "work", "in", "sqlite", "." ]
8f988936340bf0ffb83ea90ea124efb3c36a1174
https://github.com/nicfit/MishMash/blob/8f988936340bf0ffb83ea90ea124efb3c36a1174/mishmash/orm.py#L539-L545
train
Allows foreign keys to work in sqlite.
nicfit/MishMash
mishmash/orm.py
Library.iterall
def iterall(Class, session, names=None): """Iterate over all Library rows found in `session`. :param names: Optional sequence of names to filter on. """ names = set(names if names else []) for lib in session.query(Class).filter(Class.id > NULL_LIB_ID).all(): if not na...
python
def iterall(Class, session, names=None): """Iterate over all Library rows found in `session`. :param names: Optional sequence of names to filter on. """ names = set(names if names else []) for lib in session.query(Class).filter(Class.id > NULL_LIB_ID).all(): if not na...
[ "def", "iterall", "(", "Class", ",", "session", ",", "names", "=", "None", ")", ":", "names", "=", "set", "(", "names", "if", "names", "else", "[", "]", ")", "for", "lib", "in", "session", ".", "query", "(", "Class", ")", ".", "filter", "(", "Cla...
Iterate over all Library rows found in `session`. :param names: Optional sequence of names to filter on.
[ "Iterate", "over", "all", "Library", "rows", "found", "in", "session", ".", ":", "param", "names", ":", "Optional", "sequence", "of", "names", "to", "filter", "on", "." ]
8f988936340bf0ffb83ea90ea124efb3c36a1174
https://github.com/nicfit/MishMash/blob/8f988936340bf0ffb83ea90ea124efb3c36a1174/mishmash/orm.py#L519-L526
train
Iterate over all Library rows found in session.
bear/bearlib
bearlib/logs.py
Logs
def Logs(loggername, echo=True, debug=False, chatty=False, loglevel=logging.INFO, logfile=None, logpath=None, fileHandler=None): """Initialize logging """ log = logging.getLogger(loggername) if fileHandler is None: if logfile is None: logFilename = _ourName else: ...
python
def Logs(loggername, echo=True, debug=False, chatty=False, loglevel=logging.INFO, logfile=None, logpath=None, fileHandler=None): """Initialize logging """ log = logging.getLogger(loggername) if fileHandler is None: if logfile is None: logFilename = _ourName else: ...
[ "def", "Logs", "(", "loggername", ",", "echo", "=", "True", ",", "debug", "=", "False", ",", "chatty", "=", "False", ",", "loglevel", "=", "logging", ".", "INFO", ",", "logfile", "=", "None", ",", "logpath", "=", "None", ",", "fileHandler", "=", "Non...
Initialize logging
[ "Initialize", "logging" ]
30f9b8ba4b7a8db4cd2f4c6e07966ae51d0a00dd
https://github.com/bear/bearlib/blob/30f9b8ba4b7a8db4cd2f4c6e07966ae51d0a00dd/bearlib/logs.py#L19-L60
train
Initialize logging.
Parsely/schemato
schemato/validator.py
SchemaValidator.validate
def validate(self): """Iterate over all triples in the graph and validate each one appropriately """ log.info("{}\nValidating against {}" .format("-" * 100, self.schema_def.__class__.__name__)) if not self.schema_def: raise ValueError("No schema ...
python
def validate(self): """Iterate over all triples in the graph and validate each one appropriately """ log.info("{}\nValidating against {}" .format("-" * 100, self.schema_def.__class__.__name__)) if not self.schema_def: raise ValueError("No schema ...
[ "def", "validate", "(", "self", ")", ":", "log", ".", "info", "(", "\"{}\\nValidating against {}\"", ".", "format", "(", "\"-\"", "*", "100", ",", "self", ".", "schema_def", ".", "__class__", ".", "__name__", ")", ")", "if", "not", "self", ".", "schema_d...
Iterate over all triples in the graph and validate each one appropriately
[ "Iterate", "over", "all", "triples", "in", "the", "graph", "and", "validate", "each", "one", "appropriately" ]
7002316fbcd52f2e669f8372bf1338c572e3df4b
https://github.com/Parsely/schemato/blob/7002316fbcd52f2e669f8372bf1338c572e3df4b/schemato/validator.py#L34-L55
train
Iterate over all triples in the graph and validate each one appropriately
Parsely/schemato
schemato/validator.py
SchemaValidator._check_triple
def _check_triple(self, triple): """compare triple to ontology, return error or None""" subj, pred, obj = triple if self._should_ignore_predicate(pred): log.info("Ignoring triple with predicate '{}'" .format(self._field_name_from_uri(pred))) return ...
python
def _check_triple(self, triple): """compare triple to ontology, return error or None""" subj, pred, obj = triple if self._should_ignore_predicate(pred): log.info("Ignoring triple with predicate '{}'" .format(self._field_name_from_uri(pred))) return ...
[ "def", "_check_triple", "(", "self", ",", "triple", ")", ":", "subj", ",", "pred", ",", "obj", "=", "triple", "if", "self", ".", "_should_ignore_predicate", "(", "pred", ")", ":", "log", ".", "info", "(", "\"Ignoring triple with predicate '{}'\"", ".", "form...
compare triple to ontology, return error or None
[ "compare", "triple", "to", "ontology", "return", "error", "or", "None" ]
7002316fbcd52f2e669f8372bf1338c572e3df4b
https://github.com/Parsely/schemato/blob/7002316fbcd52f2e669f8372bf1338c572e3df4b/schemato/validator.py#L61-L114
train
compare triple to ontology return error or None
Parsely/schemato
schemato/validator.py
SchemaValidator._validate_class
def _validate_class(self, cl): """return error if class `cl` is not found in the ontology""" if cl not in self.schema_def.attributes_by_class: search_string = self._build_search_string(cl) err = self.err( "{0} - invalid class", self._field_name_from_uri(cl), ...
python
def _validate_class(self, cl): """return error if class `cl` is not found in the ontology""" if cl not in self.schema_def.attributes_by_class: search_string = self._build_search_string(cl) err = self.err( "{0} - invalid class", self._field_name_from_uri(cl), ...
[ "def", "_validate_class", "(", "self", ",", "cl", ")", ":", "if", "cl", "not", "in", "self", ".", "schema_def", ".", "attributes_by_class", ":", "search_string", "=", "self", ".", "_build_search_string", "(", "cl", ")", "err", "=", "self", ".", "err", "(...
return error if class `cl` is not found in the ontology
[ "return", "error", "if", "class", "cl", "is", "not", "found", "in", "the", "ontology" ]
7002316fbcd52f2e669f8372bf1338c572e3df4b
https://github.com/Parsely/schemato/blob/7002316fbcd52f2e669f8372bf1338c572e3df4b/schemato/validator.py#L116-L124
train
return error if class cl is not found in the ontology
Parsely/schemato
schemato/validator.py
SchemaValidator._validate_member
def _validate_member(self, member, classes, instanceof): """return error if `member` is not a member of any class in `classes` """ log.info("Validating member %s" % member) stripped = self._get_stripped_attributes(member, classes) if self._field_name_from_uri(member) in ...
python
def _validate_member(self, member, classes, instanceof): """return error if `member` is not a member of any class in `classes` """ log.info("Validating member %s" % member) stripped = self._get_stripped_attributes(member, classes) if self._field_name_from_uri(member) in ...
[ "def", "_validate_member", "(", "self", ",", "member", ",", "classes", ",", "instanceof", ")", ":", "log", ".", "info", "(", "\"Validating member %s\"", "%", "member", ")", "stripped", "=", "self", ".", "_get_stripped_attributes", "(", "member", ",", "classes"...
return error if `member` is not a member of any class in `classes`
[ "return", "error", "if", "member", "is", "not", "a", "member", "of", "any", "class", "in", "classes" ]
7002316fbcd52f2e669f8372bf1338c572e3df4b
https://github.com/Parsely/schemato/blob/7002316fbcd52f2e669f8372bf1338c572e3df4b/schemato/validator.py#L138-L160
train
validate a member of any class in classes
Parsely/schemato
schemato/validator.py
SchemaValidator._validate_duplication
def _validate_duplication(self, subj_and_pred, cl): """returns error if we've already seen the member `pred` on `subj`""" subj, pred = subj_and_pred log.info("Validating duplication of member %s" % pred) if (subj, pred) in self.checked_attributes: err = self.err("{0} - dupli...
python
def _validate_duplication(self, subj_and_pred, cl): """returns error if we've already seen the member `pred` on `subj`""" subj, pred = subj_and_pred log.info("Validating duplication of member %s" % pred) if (subj, pred) in self.checked_attributes: err = self.err("{0} - dupli...
[ "def", "_validate_duplication", "(", "self", ",", "subj_and_pred", ",", "cl", ")", ":", "subj", ",", "pred", "=", "subj_and_pred", "log", ".", "info", "(", "\"Validating duplication of member %s\"", "%", "pred", ")", "if", "(", "subj", ",", "pred", ")", "in"...
returns error if we've already seen the member `pred` on `subj`
[ "returns", "error", "if", "we", "ve", "already", "seen", "the", "member", "pred", "on", "subj" ]
7002316fbcd52f2e669f8372bf1338c572e3df4b
https://github.com/Parsely/schemato/blob/7002316fbcd52f2e669f8372bf1338c572e3df4b/schemato/validator.py#L162-L172
train
returns error if we have already seen the member pred on subj
Parsely/schemato
schemato/validator.py
SchemaValidator._superclasses_for_subject
def _superclasses_for_subject(self, graph, typeof): """helper, returns a list of all superclasses of a given class""" # TODO - this might be replacing a fairly simple graph API query where # it doesn't need to classes = [] superclass = typeof while True: found...
python
def _superclasses_for_subject(self, graph, typeof): """helper, returns a list of all superclasses of a given class""" # TODO - this might be replacing a fairly simple graph API query where # it doesn't need to classes = [] superclass = typeof while True: found...
[ "def", "_superclasses_for_subject", "(", "self", ",", "graph", ",", "typeof", ")", ":", "# TODO - this might be replacing a fairly simple graph API query where", "# it doesn't need to", "classes", "=", "[", "]", "superclass", "=", "typeof", "while", "True", ":", "found", ...
helper, returns a list of all superclasses of a given class
[ "helper", "returns", "a", "list", "of", "all", "superclasses", "of", "a", "given", "class" ]
7002316fbcd52f2e669f8372bf1338c572e3df4b
https://github.com/Parsely/schemato/blob/7002316fbcd52f2e669f8372bf1338c572e3df4b/schemato/validator.py#L174-L189
train
helper returns a list of all superclasses of a given class
Parsely/schemato
schemato/validator.py
SchemaValidator._is_instance
def _is_instance(self, triple): """helper, returns the class type of subj""" subj, pred, obj = triple input_pred_ns = self._namespace_from_uri(self._expand_qname(pred)) triples = self.graph.triples( (subj, rt.URIRef(self.schema_def.lexicon['type']), None) ) if...
python
def _is_instance(self, triple): """helper, returns the class type of subj""" subj, pred, obj = triple input_pred_ns = self._namespace_from_uri(self._expand_qname(pred)) triples = self.graph.triples( (subj, rt.URIRef(self.schema_def.lexicon['type']), None) ) if...
[ "def", "_is_instance", "(", "self", ",", "triple", ")", ":", "subj", ",", "pred", ",", "obj", "=", "triple", "input_pred_ns", "=", "self", ".", "_namespace_from_uri", "(", "self", ".", "_expand_qname", "(", "pred", ")", ")", "triples", "=", "self", ".", ...
helper, returns the class type of subj
[ "helper", "returns", "the", "class", "type", "of", "subj" ]
7002316fbcd52f2e669f8372bf1338c572e3df4b
https://github.com/Parsely/schemato/blob/7002316fbcd52f2e669f8372bf1338c572e3df4b/schemato/validator.py#L191-L203
train
helper returns the class type of subj pred obj
Parsely/schemato
schemato/validator.py
SchemaValidator._field_name_from_uri
def _field_name_from_uri(self, uri): """helper, returns the name of an attribute (without namespace prefix) """ # TODO - should use graph API uri = str(uri) parts = uri.split('#') if len(parts) == 1: return uri.split('/')[-1] or uri return parts[-1]
python
def _field_name_from_uri(self, uri): """helper, returns the name of an attribute (without namespace prefix) """ # TODO - should use graph API uri = str(uri) parts = uri.split('#') if len(parts) == 1: return uri.split('/')[-1] or uri return parts[-1]
[ "def", "_field_name_from_uri", "(", "self", ",", "uri", ")", ":", "# TODO - should use graph API", "uri", "=", "str", "(", "uri", ")", "parts", "=", "uri", ".", "split", "(", "'#'", ")", "if", "len", "(", "parts", ")", "==", "1", ":", "return", "uri", ...
helper, returns the name of an attribute (without namespace prefix)
[ "helper", "returns", "the", "name", "of", "an", "attribute", "(", "without", "namespace", "prefix", ")" ]
7002316fbcd52f2e669f8372bf1338c572e3df4b
https://github.com/Parsely/schemato/blob/7002316fbcd52f2e669f8372bf1338c572e3df4b/schemato/validator.py#L205-L213
train
helper returns the name of an attribute
Parsely/schemato
schemato/validator.py
SchemaValidator._namespace_from_uri
def _namespace_from_uri(self, uri): """returns the expanded namespace prefix of a uri""" # TODO - this could be helped a bunch with proper use of the graph API # it seems a bit fragile to treat these as simple string-splits uri = str(uri) parts = uri.split('#') if len(par...
python
def _namespace_from_uri(self, uri): """returns the expanded namespace prefix of a uri""" # TODO - this could be helped a bunch with proper use of the graph API # it seems a bit fragile to treat these as simple string-splits uri = str(uri) parts = uri.split('#') if len(par...
[ "def", "_namespace_from_uri", "(", "self", ",", "uri", ")", ":", "# TODO - this could be helped a bunch with proper use of the graph API", "# it seems a bit fragile to treat these as simple string-splits", "uri", "=", "str", "(", "uri", ")", "parts", "=", "uri", ".", "split",...
returns the expanded namespace prefix of a uri
[ "returns", "the", "expanded", "namespace", "prefix", "of", "a", "uri" ]
7002316fbcd52f2e669f8372bf1338c572e3df4b
https://github.com/Parsely/schemato/blob/7002316fbcd52f2e669f8372bf1338c572e3df4b/schemato/validator.py#L215-L223
train
returns the expanded namespace prefix of a uri
Parsely/schemato
schemato/validator.py
SchemaValidator._expand_qname
def _expand_qname(self, qname): """expand a qualified name's namespace prefix to include the resolved namespace root url""" if type(qname) is not rt.URIRef: raise TypeError("Cannot expand qname of type {}, must be URIRef" .format(type(qname))) for ...
python
def _expand_qname(self, qname): """expand a qualified name's namespace prefix to include the resolved namespace root url""" if type(qname) is not rt.URIRef: raise TypeError("Cannot expand qname of type {}, must be URIRef" .format(type(qname))) for ...
[ "def", "_expand_qname", "(", "self", ",", "qname", ")", ":", "if", "type", "(", "qname", ")", "is", "not", "rt", ".", "URIRef", ":", "raise", "TypeError", "(", "\"Cannot expand qname of type {}, must be URIRef\"", ".", "format", "(", "type", "(", "qname", ")...
expand a qualified name's namespace prefix to include the resolved namespace root url
[ "expand", "a", "qualified", "name", "s", "namespace", "prefix", "to", "include", "the", "resolved", "namespace", "root", "url" ]
7002316fbcd52f2e669f8372bf1338c572e3df4b
https://github.com/Parsely/schemato/blob/7002316fbcd52f2e669f8372bf1338c572e3df4b/schemato/validator.py#L225-L234
train
expand a qualified name s namespace prefix to include the resolved namespace root url
kmike/port-for
port_for/_download_ranges.py
_write_unassigned_ranges
def _write_unassigned_ranges(out_filename): """ Downloads ports data from IANA & Wikipedia and converts it to a python module. This function is used to generate _ranges.py. """ with open(out_filename, 'wt') as f: f.write('# auto-generated by port_for._download_ranges (%s)\n' % datetime.date....
python
def _write_unassigned_ranges(out_filename): """ Downloads ports data from IANA & Wikipedia and converts it to a python module. This function is used to generate _ranges.py. """ with open(out_filename, 'wt') as f: f.write('# auto-generated by port_for._download_ranges (%s)\n' % datetime.date....
[ "def", "_write_unassigned_ranges", "(", "out_filename", ")", ":", "with", "open", "(", "out_filename", ",", "'wt'", ")", "as", "f", ":", "f", ".", "write", "(", "'# auto-generated by port_for._download_ranges (%s)\\n'", "%", "datetime", ".", "date", ".", "today", ...
Downloads ports data from IANA & Wikipedia and converts it to a python module. This function is used to generate _ranges.py.
[ "Downloads", "ports", "data", "from", "IANA", "&", "Wikipedia", "and", "converts", "it", "to", "a", "python", "module", ".", "This", "function", "is", "used", "to", "generate", "_ranges", ".", "py", "." ]
f61ebf3c2caf54eabe8233b40ef67b973176a6f5
https://github.com/kmike/port-for/blob/f61ebf3c2caf54eabe8233b40ef67b973176a6f5/port_for/_download_ranges.py#L24-L34
train
Writes the unassigned ports to a python module.
kmike/port-for
port_for/_download_ranges.py
_unassigned_ports
def _unassigned_ports(): """ Returns a set of all unassigned ports (according to IANA and Wikipedia) """ free_ports = ranges_to_set(_parse_ranges(_iana_unassigned_port_ranges())) known_ports = ranges_to_set(_wikipedia_known_port_ranges()) return free_ports.difference(known_ports)
python
def _unassigned_ports(): """ Returns a set of all unassigned ports (according to IANA and Wikipedia) """ free_ports = ranges_to_set(_parse_ranges(_iana_unassigned_port_ranges())) known_ports = ranges_to_set(_wikipedia_known_port_ranges()) return free_ports.difference(known_ports)
[ "def", "_unassigned_ports", "(", ")", ":", "free_ports", "=", "ranges_to_set", "(", "_parse_ranges", "(", "_iana_unassigned_port_ranges", "(", ")", ")", ")", "known_ports", "=", "ranges_to_set", "(", "_wikipedia_known_port_ranges", "(", ")", ")", "return", "free_por...
Returns a set of all unassigned ports (according to IANA and Wikipedia)
[ "Returns", "a", "set", "of", "all", "unassigned", "ports", "(", "according", "to", "IANA", "and", "Wikipedia", ")" ]
f61ebf3c2caf54eabe8233b40ef67b973176a6f5
https://github.com/kmike/port-for/blob/f61ebf3c2caf54eabe8233b40ef67b973176a6f5/port_for/_download_ranges.py#L37-L41
train
Returns a set of all unassigned ports in a node.
kmike/port-for
port_for/_download_ranges.py
_wikipedia_known_port_ranges
def _wikipedia_known_port_ranges(): """ Returns used port ranges according to Wikipedia page. This page contains unofficial well-known ports. """ req = urllib2.Request(WIKIPEDIA_PAGE, headers={'User-Agent' : "Magic Browser"}) page = urllib2.urlopen(req).read().decode('utf8') # just find all...
python
def _wikipedia_known_port_ranges(): """ Returns used port ranges according to Wikipedia page. This page contains unofficial well-known ports. """ req = urllib2.Request(WIKIPEDIA_PAGE, headers={'User-Agent' : "Magic Browser"}) page = urllib2.urlopen(req).read().decode('utf8') # just find all...
[ "def", "_wikipedia_known_port_ranges", "(", ")", ":", "req", "=", "urllib2", ".", "Request", "(", "WIKIPEDIA_PAGE", ",", "headers", "=", "{", "'User-Agent'", ":", "\"Magic Browser\"", "}", ")", "page", "=", "urllib2", ".", "urlopen", "(", "req", ")", ".", ...
Returns used port ranges according to Wikipedia page. This page contains unofficial well-known ports.
[ "Returns", "used", "port", "ranges", "according", "to", "Wikipedia", "page", ".", "This", "page", "contains", "unofficial", "well", "-", "known", "ports", "." ]
f61ebf3c2caf54eabe8233b40ef67b973176a6f5
https://github.com/kmike/port-for/blob/f61ebf3c2caf54eabe8233b40ef67b973176a6f5/port_for/_download_ranges.py#L44-L54
train
Returns used port ranges according to Wikipedia page.
kmike/port-for
port_for/_download_ranges.py
_iana_unassigned_port_ranges
def _iana_unassigned_port_ranges(): """ Returns unassigned port ranges according to IANA. """ page = urllib2.urlopen(IANA_DOWNLOAD_URL).read() xml = ElementTree.fromstring(page) records = xml.findall('{%s}record' % IANA_NS) for record in records: description = record.find('{%s}descri...
python
def _iana_unassigned_port_ranges(): """ Returns unassigned port ranges according to IANA. """ page = urllib2.urlopen(IANA_DOWNLOAD_URL).read() xml = ElementTree.fromstring(page) records = xml.findall('{%s}record' % IANA_NS) for record in records: description = record.find('{%s}descri...
[ "def", "_iana_unassigned_port_ranges", "(", ")", ":", "page", "=", "urllib2", ".", "urlopen", "(", "IANA_DOWNLOAD_URL", ")", ".", "read", "(", ")", "xml", "=", "ElementTree", ".", "fromstring", "(", "page", ")", "records", "=", "xml", ".", "findall", "(", ...
Returns unassigned port ranges according to IANA.
[ "Returns", "unassigned", "port", "ranges", "according", "to", "IANA", "." ]
f61ebf3c2caf54eabe8233b40ef67b973176a6f5
https://github.com/kmike/port-for/blob/f61ebf3c2caf54eabe8233b40ef67b973176a6f5/port_for/_download_ranges.py#L57-L68
train
Returns an iterator over the unassigned port ranges according to IANA.
kmike/port-for
port_for/_download_ranges.py
_parse_ranges
def _parse_ranges(ranges): """ Converts a list of string ranges to a list of [low, high] tuples. """ for txt in ranges: if '-' in txt: low, high = txt.split('-') else: low, high = txt, txt yield int(low), int(high)
python
def _parse_ranges(ranges): """ Converts a list of string ranges to a list of [low, high] tuples. """ for txt in ranges: if '-' in txt: low, high = txt.split('-') else: low, high = txt, txt yield int(low), int(high)
[ "def", "_parse_ranges", "(", "ranges", ")", ":", "for", "txt", "in", "ranges", ":", "if", "'-'", "in", "txt", ":", "low", ",", "high", "=", "txt", ".", "split", "(", "'-'", ")", "else", ":", "low", ",", "high", "=", "txt", ",", "txt", "yield", ...
Converts a list of string ranges to a list of [low, high] tuples.
[ "Converts", "a", "list", "of", "string", "ranges", "to", "a", "list", "of", "[", "low", "high", "]", "tuples", "." ]
f61ebf3c2caf54eabe8233b40ef67b973176a6f5
https://github.com/kmike/port-for/blob/f61ebf3c2caf54eabe8233b40ef67b973176a6f5/port_for/_download_ranges.py#L71-L78
train
Converts a list of string ranges to a list of low and high tuples.
astraw38/lint
lint/main.py
run_linters
def run_linters(files): """ Run through file list, and try to find a linter that matches the given file type. If it finds a linter, it will run it, and store the resulting data in a dictionary (keyed to file_type). :param files: :return: {file_extension: lint_data} """ data = {} ...
python
def run_linters(files): """ Run through file list, and try to find a linter that matches the given file type. If it finds a linter, it will run it, and store the resulting data in a dictionary (keyed to file_type). :param files: :return: {file_extension: lint_data} """ data = {} ...
[ "def", "run_linters", "(", "files", ")", ":", "data", "=", "{", "}", "for", "file_type", ",", "file_list", "in", "list", "(", "files", ".", "items", "(", ")", ")", ":", "linter", "=", "LintFactory", ".", "get_linter", "(", "file_type", ")", "if", "li...
Run through file list, and try to find a linter that matches the given file type. If it finds a linter, it will run it, and store the resulting data in a dictionary (keyed to file_type). :param files: :return: {file_extension: lint_data}
[ "Run", "through", "file", "list", "and", "try", "to", "find", "a", "linter", "that", "matches", "the", "given", "file", "type", "." ]
162ceefcb812f07d18544aaa887b9ec4f102cfb1
https://github.com/astraw38/lint/blob/162ceefcb812f07d18544aaa887b9ec4f102cfb1/lint/main.py#L12-L28
train
Run all linters in a file list and store the result in a dictionary.
astraw38/lint
lint/main.py
run_validators
def run_validators(new_data, old_data): """ Run through all matching validators. :param new_data: New lint data. :param old_data: Old lint data (before review) :return: """ #{'validator_name': (success, score, message)} validation_data = {} for file_type, lint_data in list(new_data....
python
def run_validators(new_data, old_data): """ Run through all matching validators. :param new_data: New lint data. :param old_data: Old lint data (before review) :return: """ #{'validator_name': (success, score, message)} validation_data = {} for file_type, lint_data in list(new_data....
[ "def", "run_validators", "(", "new_data", ",", "old_data", ")", ":", "#{'validator_name': (success, score, message)}", "validation_data", "=", "{", "}", "for", "file_type", ",", "lint_data", "in", "list", "(", "new_data", ".", "items", "(", ")", ")", ":", "#TODO...
Run through all matching validators. :param new_data: New lint data. :param old_data: Old lint data (before review) :return:
[ "Run", "through", "all", "matching", "validators", "." ]
162ceefcb812f07d18544aaa887b9ec4f102cfb1
https://github.com/astraw38/lint/blob/162ceefcb812f07d18544aaa887b9ec4f102cfb1/lint/main.py#L31-L47
train
Run through all validators in the order they were added.
Parsely/schemato
schemato/schemas/parselypage.py
ParselyPageParser.original_unescape
def original_unescape(self, s): """Since we need to use this sometimes""" if isinstance(s, basestring): return unicode(HTMLParser.unescape(self, s)) elif isinstance(s, list): return [unicode(HTMLParser.unescape(self, item)) for item in s] else: return ...
python
def original_unescape(self, s): """Since we need to use this sometimes""" if isinstance(s, basestring): return unicode(HTMLParser.unescape(self, s)) elif isinstance(s, list): return [unicode(HTMLParser.unescape(self, item)) for item in s] else: return ...
[ "def", "original_unescape", "(", "self", ",", "s", ")", ":", "if", "isinstance", "(", "s", ",", "basestring", ")", ":", "return", "unicode", "(", "HTMLParser", ".", "unescape", "(", "self", ",", "s", ")", ")", "elif", "isinstance", "(", "s", ",", "li...
Since we need to use this sometimes
[ "Since", "we", "need", "to", "use", "this", "sometimes" ]
7002316fbcd52f2e669f8372bf1338c572e3df4b
https://github.com/Parsely/schemato/blob/7002316fbcd52f2e669f8372bf1338c572e3df4b/schemato/schemas/parselypage.py#L35-L42
train
Unescape a string or list of strings.
Parsely/schemato
schemato/schemas/parselypage.py
ParselyPageValidator.get_standard
def get_standard(self): """get list of allowed parameters""" try: res = urlopen(PARSELY_PAGE_SCHEMA) except: return [] text = res.read() if isinstance(text, bytes): text = text.decode('utf-8') tree = etree.parse(StringIO(text)) ...
python
def get_standard(self): """get list of allowed parameters""" try: res = urlopen(PARSELY_PAGE_SCHEMA) except: return [] text = res.read() if isinstance(text, bytes): text = text.decode('utf-8') tree = etree.parse(StringIO(text)) ...
[ "def", "get_standard", "(", "self", ")", ":", "try", ":", "res", "=", "urlopen", "(", "PARSELY_PAGE_SCHEMA", ")", "except", ":", "return", "[", "]", "text", "=", "res", ".", "read", "(", ")", "if", "isinstance", "(", "text", ",", "bytes", ")", ":", ...
get list of allowed parameters
[ "get", "list", "of", "allowed", "parameters" ]
7002316fbcd52f2e669f8372bf1338c572e3df4b
https://github.com/Parsely/schemato/blob/7002316fbcd52f2e669f8372bf1338c572e3df4b/schemato/schemas/parselypage.py#L56-L67
train
get list of allowed parameters
Parsely/schemato
schemato/schemas/parselypage.py
ParselyPageValidator._get_parselypage
def _get_parselypage(self, body): """extract the parsely-page meta content from a page""" parser = ParselyPageParser() ret = None try: parser.feed(body) except HTMLParseError: pass # ignore and hope we got ppage if parser.ppage is None: ...
python
def _get_parselypage(self, body): """extract the parsely-page meta content from a page""" parser = ParselyPageParser() ret = None try: parser.feed(body) except HTMLParseError: pass # ignore and hope we got ppage if parser.ppage is None: ...
[ "def", "_get_parselypage", "(", "self", ",", "body", ")", ":", "parser", "=", "ParselyPageParser", "(", ")", "ret", "=", "None", "try", ":", "parser", ".", "feed", "(", "body", ")", "except", "HTMLParseError", ":", "pass", "# ignore and hope we got ppage", "...
extract the parsely-page meta content from a page
[ "extract", "the", "parsely", "-", "page", "meta", "content", "from", "a", "page" ]
7002316fbcd52f2e669f8372bf1338c572e3df4b
https://github.com/Parsely/schemato/blob/7002316fbcd52f2e669f8372bf1338c572e3df4b/schemato/schemas/parselypage.py#L69-L84
train
extract the parsely - page meta content from a page
Parsely/schemato
schemato/schemadef.py
SchemaDef._read_schema
def _read_schema(self): """return the local filename of the definition file for this schema if not present or older than expiry, pull the latest version from the web at self._ontology_file""" cache_filename = os.path.join( CACHE_ROOT, "%s.smt" % self._representation) ...
python
def _read_schema(self): """return the local filename of the definition file for this schema if not present or older than expiry, pull the latest version from the web at self._ontology_file""" cache_filename = os.path.join( CACHE_ROOT, "%s.smt" % self._representation) ...
[ "def", "_read_schema", "(", "self", ")", ":", "cache_filename", "=", "os", ".", "path", ".", "join", "(", "CACHE_ROOT", ",", "\"%s.smt\"", "%", "self", ".", "_representation", ")", "log", ".", "info", "(", "\"Attempting to read local schema at %s\"", "%", "cac...
return the local filename of the definition file for this schema if not present or older than expiry, pull the latest version from the web at self._ontology_file
[ "return", "the", "local", "filename", "of", "the", "definition", "file", "for", "this", "schema", "if", "not", "present", "or", "older", "than", "expiry", "pull", "the", "latest", "version", "from", "the", "web", "at", "self", ".", "_ontology_file" ]
7002316fbcd52f2e669f8372bf1338c572e3df4b
https://github.com/Parsely/schemato/blob/7002316fbcd52f2e669f8372bf1338c572e3df4b/schemato/schemadef.py#L38-L55
train
return the local filename of the definition file for this schema
Parsely/schemato
schemato/schemadef.py
SchemaDef._pull_schema_definition
def _pull_schema_definition(self, fname): """download an ontology definition from the web""" std_url = urlopen(self._ontology_file) cached_std = open(fname, "w+") cached_std.write(std_url.read()) cached_std.close()
python
def _pull_schema_definition(self, fname): """download an ontology definition from the web""" std_url = urlopen(self._ontology_file) cached_std = open(fname, "w+") cached_std.write(std_url.read()) cached_std.close()
[ "def", "_pull_schema_definition", "(", "self", ",", "fname", ")", ":", "std_url", "=", "urlopen", "(", "self", ".", "_ontology_file", ")", "cached_std", "=", "open", "(", "fname", ",", "\"w+\"", ")", "cached_std", ".", "write", "(", "std_url", ".", "read",...
download an ontology definition from the web
[ "download", "an", "ontology", "definition", "from", "the", "web" ]
7002316fbcd52f2e669f8372bf1338c572e3df4b
https://github.com/Parsely/schemato/blob/7002316fbcd52f2e669f8372bf1338c572e3df4b/schemato/schemadef.py#L57-L62
train
download an ontology definition from the web
Parsely/schemato
schemato/schemadef.py
SchemaDef.parse_ontology
def parse_ontology(self): """place the ontology graph into a set of custom data structures for use by the validator""" start = time.clock() log.info("Parsing ontology file for %s" % self.__class__.__name__) for subj, pred, obj in self._schema_nodes(): if subj not in s...
python
def parse_ontology(self): """place the ontology graph into a set of custom data structures for use by the validator""" start = time.clock() log.info("Parsing ontology file for %s" % self.__class__.__name__) for subj, pred, obj in self._schema_nodes(): if subj not in s...
[ "def", "parse_ontology", "(", "self", ")", ":", "start", "=", "time", ".", "clock", "(", ")", "log", ".", "info", "(", "\"Parsing ontology file for %s\"", "%", "self", ".", "__class__", ".", "__name__", ")", "for", "subj", ",", "pred", ",", "obj", "in", ...
place the ontology graph into a set of custom data structures for use by the validator
[ "place", "the", "ontology", "graph", "into", "a", "set", "of", "custom", "data", "structures", "for", "use", "by", "the", "validator" ]
7002316fbcd52f2e669f8372bf1338c572e3df4b
https://github.com/Parsely/schemato/blob/7002316fbcd52f2e669f8372bf1338c572e3df4b/schemato/schemadef.py#L64-L87
train
place the ontology graph into a set of custom data structures
Parsely/schemato
schemato/schemadef.py
SchemaDef._schema_nodes
def _schema_nodes(self): """parse self._ontology_file into a graph""" name, ext = os.path.splitext(self._ontology_file) if ext in ['.ttl']: self._ontology_parser_function = \ lambda s: rdflib.Graph().parse(s, format='n3') else: self._ontology_parse...
python
def _schema_nodes(self): """parse self._ontology_file into a graph""" name, ext = os.path.splitext(self._ontology_file) if ext in ['.ttl']: self._ontology_parser_function = \ lambda s: rdflib.Graph().parse(s, format='n3') else: self._ontology_parse...
[ "def", "_schema_nodes", "(", "self", ")", ":", "name", ",", "ext", "=", "os", ".", "path", ".", "splitext", "(", "self", ".", "_ontology_file", ")", "if", "ext", "in", "[", "'.ttl'", "]", ":", "self", ".", "_ontology_parser_function", "=", "lambda", "s...
parse self._ontology_file into a graph
[ "parse", "self", ".", "_ontology_file", "into", "a", "graph" ]
7002316fbcd52f2e669f8372bf1338c572e3df4b
https://github.com/Parsely/schemato/blob/7002316fbcd52f2e669f8372bf1338c572e3df4b/schemato/schemadef.py#L89-L118
train
parse self. _ontology_file into a graph
bear/bearlib
bearlib/tools.py
normalizeFilename
def normalizeFilename(filename): """Take a given filename and return the normalized version of it. Where ~/ is expanded to the full OS specific home directory and all relative path elements are resolved. """ result = os.path.expanduser(filename) result = os.path.abspath(result) return result
python
def normalizeFilename(filename): """Take a given filename and return the normalized version of it. Where ~/ is expanded to the full OS specific home directory and all relative path elements are resolved. """ result = os.path.expanduser(filename) result = os.path.abspath(result) return result
[ "def", "normalizeFilename", "(", "filename", ")", ":", "result", "=", "os", ".", "path", ".", "expanduser", "(", "filename", ")", "result", "=", "os", ".", "path", ".", "abspath", "(", "result", ")", "return", "result" ]
Take a given filename and return the normalized version of it. Where ~/ is expanded to the full OS specific home directory and all relative path elements are resolved.
[ "Take", "a", "given", "filename", "and", "return", "the", "normalized", "version", "of", "it", ".", "Where", "~", "/", "is", "expanded", "to", "the", "full", "OS", "specific", "home", "directory", "and", "all", "relative", "path", "elements", "are", "resol...
30f9b8ba4b7a8db4cd2f4c6e07966ae51d0a00dd
https://github.com/bear/bearlib/blob/30f9b8ba4b7a8db4cd2f4c6e07966ae51d0a00dd/bearlib/tools.py#L13-L20
train
Take a given filename and return the normalized version of it.
bear/bearlib
bearlib/tools.py
baseDomain
def baseDomain(domain, includeScheme=True): """Return only the network location portion of the given domain unless includeScheme is True """ result = '' url = urlparse(domain) if includeScheme: result = '%s://' % url.scheme if len(url.netloc) == 0: result += url.path e...
python
def baseDomain(domain, includeScheme=True): """Return only the network location portion of the given domain unless includeScheme is True """ result = '' url = urlparse(domain) if includeScheme: result = '%s://' % url.scheme if len(url.netloc) == 0: result += url.path e...
[ "def", "baseDomain", "(", "domain", ",", "includeScheme", "=", "True", ")", ":", "result", "=", "''", "url", "=", "urlparse", "(", "domain", ")", "if", "includeScheme", ":", "result", "=", "'%s://'", "%", "url", ".", "scheme", "if", "len", "(", "url", ...
Return only the network location portion of the given domain unless includeScheme is True
[ "Return", "only", "the", "network", "location", "portion", "of", "the", "given", "domain", "unless", "includeScheme", "is", "True" ]
30f9b8ba4b7a8db4cd2f4c6e07966ae51d0a00dd
https://github.com/bear/bearlib/blob/30f9b8ba4b7a8db4cd2f4c6e07966ae51d0a00dd/bearlib/tools.py#L22-L34
train
Return only the network location portion of the given domain unless includeScheme is True
nicfit/MishMash
mishmash/database.py
search
def search(session, query): """Naive search of the database for `query`. :return: A dict with keys 'artists', 'albums', and 'tracks'. Each containing a list of the respective ORM type. """ flat_query = "".join(query.split()) artists = session.query(Artist).filter( or_(Arti...
python
def search(session, query): """Naive search of the database for `query`. :return: A dict with keys 'artists', 'albums', and 'tracks'. Each containing a list of the respective ORM type. """ flat_query = "".join(query.split()) artists = session.query(Artist).filter( or_(Arti...
[ "def", "search", "(", "session", ",", "query", ")", ":", "flat_query", "=", "\"\"", ".", "join", "(", "query", ".", "split", "(", ")", ")", "artists", "=", "session", ".", "query", "(", "Artist", ")", ".", "filter", "(", "or_", "(", "Artist", ".", ...
Naive search of the database for `query`. :return: A dict with keys 'artists', 'albums', and 'tracks'. Each containing a list of the respective ORM type.
[ "Naive", "search", "of", "the", "database", "for", "query", "." ]
8f988936340bf0ffb83ea90ea124efb3c36a1174
https://github.com/nicfit/MishMash/blob/8f988936340bf0ffb83ea90ea124efb3c36a1174/mishmash/database.py#L86-L105
train
Naive search of the database for query.
jim-easterbrook/pyctools
src/pyctools/components/interp/filtergenerator.py
FilterGeneratorCore
def FilterGeneratorCore(x_up=1, x_down=1, x_ap=1, x_cut=100, y_up=1, y_down=1, y_ap=1, y_cut=100): """Classic filter generator core. Alternative to the :py:class:`FilterGenerator` component that can be used to make a non-reconfigurable resizer:: resize = Resize(xup=2) ...
python
def FilterGeneratorCore(x_up=1, x_down=1, x_ap=1, x_cut=100, y_up=1, y_down=1, y_ap=1, y_cut=100): """Classic filter generator core. Alternative to the :py:class:`FilterGenerator` component that can be used to make a non-reconfigurable resizer:: resize = Resize(xup=2) ...
[ "def", "FilterGeneratorCore", "(", "x_up", "=", "1", ",", "x_down", "=", "1", ",", "x_ap", "=", "1", ",", "x_cut", "=", "100", ",", "y_up", "=", "1", ",", "y_down", "=", "1", ",", "y_ap", "=", "1", ",", "y_cut", "=", "100", ")", ":", "def", "...
Classic filter generator core. Alternative to the :py:class:`FilterGenerator` component that can be used to make a non-reconfigurable resizer:: resize = Resize(xup=2) resize.filter(FilterGeneratorCore(xup=2, xaperture=16)) ... start(..., resize, ...) ... :keyword i...
[ "Classic", "filter", "generator", "core", "." ]
2a958665326892f45f249bebe62c2c23f306732b
https://github.com/jim-easterbrook/pyctools/blob/2a958665326892f45f249bebe62c2c23f306732b/src/pyctools/components/interp/filtergenerator.py#L114-L206
train
Classic filter generator core.
astraw38/lint
lint/linters/pylinter.py
pylint_raw
def pylint_raw(options): """ Use check_output to run pylint. Because pylint changes the exit code based on the code score, we have to wrap it in a try/except block. :param options: :return: """ command = ['pylint'] command.extend(options) proc = subprocess.Popen(command, stdout...
python
def pylint_raw(options): """ Use check_output to run pylint. Because pylint changes the exit code based on the code score, we have to wrap it in a try/except block. :param options: :return: """ command = ['pylint'] command.extend(options) proc = subprocess.Popen(command, stdout...
[ "def", "pylint_raw", "(", "options", ")", ":", "command", "=", "[", "'pylint'", "]", "command", ".", "extend", "(", "options", ")", "proc", "=", "subprocess", ".", "Popen", "(", "command", ",", "stdout", "=", "subprocess", ".", "PIPE", ",", "stderr", "...
Use check_output to run pylint. Because pylint changes the exit code based on the code score, we have to wrap it in a try/except block. :param options: :return:
[ "Use", "check_output", "to", "run", "pylint", ".", "Because", "pylint", "changes", "the", "exit", "code", "based", "on", "the", "code", "score", "we", "have", "to", "wrap", "it", "in", "a", "try", "/", "except", "block", "." ]
162ceefcb812f07d18544aaa887b9ec4f102cfb1
https://github.com/astraw38/lint/blob/162ceefcb812f07d18544aaa887b9ec4f102cfb1/lint/linters/pylinter.py#L86-L101
train
Use check_output to run pylint.
astraw38/lint
lint/linters/pylinter.py
Pylinter.run
def run(self, file_list): """ Runs pylint on the list of files and return a dictionary: {<filename>: [list of pylint errors], 'total': <int> - Total number of pylint messages, 'errors': <int> - Number of pylint errors, 'scores': (<filename>, score) - Individual sco...
python
def run(self, file_list): """ Runs pylint on the list of files and return a dictionary: {<filename>: [list of pylint errors], 'total': <int> - Total number of pylint messages, 'errors': <int> - Number of pylint errors, 'scores': (<filename>, score) - Individual sco...
[ "def", "run", "(", "self", ",", "file_list", ")", ":", "data", "=", "{", "'total'", ":", "0", ",", "'errors'", ":", "0", ",", "'scores'", ":", "[", "]", "}", "for", "filename", "in", "file_list", ":", "path", ",", "fname", "=", "os", ".", "path",...
Runs pylint on the list of files and return a dictionary: {<filename>: [list of pylint errors], 'total': <int> - Total number of pylint messages, 'errors': <int> - Number of pylint errors, 'scores': (<filename>, score) - Individual score for each file.} :param file_list: ...
[ "Runs", "pylint", "on", "the", "list", "of", "files", "and", "return", "a", "dictionary", ":", "{", "<filename", ">", ":", "[", "list", "of", "pylint", "errors", "]", "total", ":", "<int", ">", "-", "Total", "number", "of", "pylint", "messages", "error...
162ceefcb812f07d18544aaa887b9ec4f102cfb1
https://github.com/astraw38/lint/blob/162ceefcb812f07d18544aaa887b9ec4f102cfb1/lint/linters/pylinter.py#L33-L83
train
Runs pylint on the list of files and returns a dictionary of the data that is returned by the pylint command.
tylerdave/prompter
prompter/__init__.py
prompt
def prompt(message, default=None, strip=True, suffix=' '): """ Print a message and prompt user for input. Return user input. """ if default is not None: prompt_text = "{0} [{1}]{2}".format(message, default, suffix) else: prompt_text = "{0}{1}".format(message, suffix) input_value = get_i...
python
def prompt(message, default=None, strip=True, suffix=' '): """ Print a message and prompt user for input. Return user input. """ if default is not None: prompt_text = "{0} [{1}]{2}".format(message, default, suffix) else: prompt_text = "{0}{1}".format(message, suffix) input_value = get_i...
[ "def", "prompt", "(", "message", ",", "default", "=", "None", ",", "strip", "=", "True", ",", "suffix", "=", "' '", ")", ":", "if", "default", "is", "not", "None", ":", "prompt_text", "=", "\"{0} [{1}]{2}\"", ".", "format", "(", "message", ",", "defaul...
Print a message and prompt user for input. Return user input.
[ "Print", "a", "message", "and", "prompt", "user", "for", "input", ".", "Return", "user", "input", "." ]
b6a72f4d02cd68c6d9a2bbe00bfc5bf62b25feda
https://github.com/tylerdave/prompter/blob/b6a72f4d02cd68c6d9a2bbe00bfc5bf62b25feda/prompter/__init__.py#L66-L81
train
Print a message and prompt user for input. Return user input.
tylerdave/prompter
prompter/__init__.py
yesno
def yesno(message, default='yes', suffix=' '): """ Prompt user to answer yes or no. Return True if the default is chosen, otherwise False. """ if default == 'yes': yesno_prompt = '[Y/n]' elif default == 'no': yesno_prompt = '[y/N]' else: raise ValueError("default must be 'ye...
python
def yesno(message, default='yes', suffix=' '): """ Prompt user to answer yes or no. Return True if the default is chosen, otherwise False. """ if default == 'yes': yesno_prompt = '[Y/n]' elif default == 'no': yesno_prompt = '[y/N]' else: raise ValueError("default must be 'ye...
[ "def", "yesno", "(", "message", ",", "default", "=", "'yes'", ",", "suffix", "=", "' '", ")", ":", "if", "default", "==", "'yes'", ":", "yesno_prompt", "=", "'[Y/n]'", "elif", "default", "==", "'no'", ":", "yesno_prompt", "=", "'[y/N]'", "else", ":", "...
Prompt user to answer yes or no. Return True if the default is chosen, otherwise False.
[ "Prompt", "user", "to", "answer", "yes", "or", "no", ".", "Return", "True", "if", "the", "default", "is", "chosen", "otherwise", "False", "." ]
b6a72f4d02cd68c6d9a2bbe00bfc5bf62b25feda
https://github.com/tylerdave/prompter/blob/b6a72f4d02cd68c6d9a2bbe00bfc5bf62b25feda/prompter/__init__.py#L83-L112
train
Prompt user to answer yes or no. Return True if the default is chosen otherwise False.
astraw38/lint
lint/validators/validation_factory.py
ValidatorFactory.register_validator
def register_validator(validator): """ Register a Validator class for file verification. :param validator: :return: """ if hasattr(validator, "EXTS") and hasattr(validator, "run"): ValidatorFactory.PLUGINS.append(validator) else: raise Val...
python
def register_validator(validator): """ Register a Validator class for file verification. :param validator: :return: """ if hasattr(validator, "EXTS") and hasattr(validator, "run"): ValidatorFactory.PLUGINS.append(validator) else: raise Val...
[ "def", "register_validator", "(", "validator", ")", ":", "if", "hasattr", "(", "validator", ",", "\"EXTS\"", ")", "and", "hasattr", "(", "validator", ",", "\"run\"", ")", ":", "ValidatorFactory", ".", "PLUGINS", ".", "append", "(", "validator", ")", "else", ...
Register a Validator class for file verification. :param validator: :return:
[ "Register", "a", "Validator", "class", "for", "file", "verification", "." ]
162ceefcb812f07d18544aaa887b9ec4f102cfb1
https://github.com/astraw38/lint/blob/162ceefcb812f07d18544aaa887b9ec4f102cfb1/lint/validators/validation_factory.py#L32-L42
train
Register a Validator class for file verification.
jim-easterbrook/pyctools
src/pyctools/components/io/videofilewriter.py
VideoFileWriter.file_writer
def file_writer(self, in_frame): """Generator process to write file""" self.update_config() path = self.config['path'] encoder = self.config['encoder'] fps = self.config['fps'] bit16 = self.config['16bit'] numpy_image = in_frame.as_numpy() ylen, xlen, bpc ...
python
def file_writer(self, in_frame): """Generator process to write file""" self.update_config() path = self.config['path'] encoder = self.config['encoder'] fps = self.config['fps'] bit16 = self.config['16bit'] numpy_image = in_frame.as_numpy() ylen, xlen, bpc ...
[ "def", "file_writer", "(", "self", ",", "in_frame", ")", ":", "self", ".", "update_config", "(", ")", "path", "=", "self", ".", "config", "[", "'path'", "]", "encoder", "=", "self", ".", "config", "[", "'encoder'", "]", "fps", "=", "self", ".", "conf...
Generator process to write file
[ "Generator", "process", "to", "write", "file" ]
2a958665326892f45f249bebe62c2c23f306732b
https://github.com/jim-easterbrook/pyctools/blob/2a958665326892f45f249bebe62c2c23f306732b/src/pyctools/components/io/videofilewriter.py#L85-L132
train
Generator process to write a single file in the archive.
jim-easterbrook/pyctools
src/pyctools/components/deinterlace/hhiprefilter.py
HHIPreFilter
def HHIPreFilter(config={}): """HHI pre-interlace filter. A widely used prefilter to prevent line twitter when converting sequential images to interlace. Coefficients taken from: 'Specification of a Generic Format Converter', S. Pigeon, L. Vandendorpe, L. Cuvelier and B. Maison, CEC RACE/HAMLE...
python
def HHIPreFilter(config={}): """HHI pre-interlace filter. A widely used prefilter to prevent line twitter when converting sequential images to interlace. Coefficients taken from: 'Specification of a Generic Format Converter', S. Pigeon, L. Vandendorpe, L. Cuvelier and B. Maison, CEC RACE/HAMLE...
[ "def", "HHIPreFilter", "(", "config", "=", "{", "}", ")", ":", "fil", "=", "numpy", ".", "array", "(", "[", "-", "4", ",", "8", ",", "25", ",", "-", "123", ",", "230", ",", "728", ",", "230", ",", "-", "123", ",", "25", ",", "8", ",", "-"...
HHI pre-interlace filter. A widely used prefilter to prevent line twitter when converting sequential images to interlace. Coefficients taken from: 'Specification of a Generic Format Converter', S. Pigeon, L. Vandendorpe, L. Cuvelier and B. Maison, CEC RACE/HAMLET Deliverable no R2110/WP2/DS/S/006/...
[ "HHI", "pre", "-", "interlace", "filter", "." ]
2a958665326892f45f249bebe62c2c23f306732b
https://github.com/jim-easterbrook/pyctools/blob/2a958665326892f45f249bebe62c2c23f306732b/src/pyctools/components/deinterlace/hhiprefilter.py#L27-L51
train
A widely used prefilter to prevent line twitter when converting sequential images to interlace.
kmike/port-for
port_for/ephemeral.py
port_ranges
def port_ranges(): """ Returns a list of ephemeral port ranges for current machine. """ try: return _linux_ranges() except (OSError, IOError): # not linux, try BSD try: ranges = _bsd_ranges() if ranges: return ranges except (OSError, IO...
python
def port_ranges(): """ Returns a list of ephemeral port ranges for current machine. """ try: return _linux_ranges() except (OSError, IOError): # not linux, try BSD try: ranges = _bsd_ranges() if ranges: return ranges except (OSError, IO...
[ "def", "port_ranges", "(", ")", ":", "try", ":", "return", "_linux_ranges", "(", ")", "except", "(", "OSError", ",", "IOError", ")", ":", "# not linux, try BSD", "try", ":", "ranges", "=", "_bsd_ranges", "(", ")", "if", "ranges", ":", "return", "ranges", ...
Returns a list of ephemeral port ranges for current machine.
[ "Returns", "a", "list", "of", "ephemeral", "port", "ranges", "for", "current", "machine", "." ]
f61ebf3c2caf54eabe8233b40ef67b973176a6f5
https://github.com/kmike/port-for/blob/f61ebf3c2caf54eabe8233b40ef67b973176a6f5/port_for/ephemeral.py#L15-L30
train
Returns a list of ephemeral port ranges for current machine.
jim-easterbrook/pyctools
src/pyctools/core/base.py
ThreadEventLoop.run
def run(self): """The actual event loop. Calls the ``owner``'s :py:meth:`~Component.start_event` method, then calls its :py:meth:`~Component.new_frame_event` and :py:meth:`~Component.new_config_event` methods as required until :py:meth:`~Component.stop` is called. Finally the ``...
python
def run(self): """The actual event loop. Calls the ``owner``'s :py:meth:`~Component.start_event` method, then calls its :py:meth:`~Component.new_frame_event` and :py:meth:`~Component.new_config_event` methods as required until :py:meth:`~Component.stop` is called. Finally the ``...
[ "def", "run", "(", "self", ")", ":", "try", ":", "self", ".", "owner", ".", "start_event", "(", ")", "while", "True", ":", "while", "not", "self", ".", "incoming", ":", "time", ".", "sleep", "(", "0.01", ")", "while", "self", ".", "incoming", ":", ...
The actual event loop. Calls the ``owner``'s :py:meth:`~Component.start_event` method, then calls its :py:meth:`~Component.new_frame_event` and :py:meth:`~Component.new_config_event` methods as required until :py:meth:`~Component.stop` is called. Finally the ``owner``'s :py:meth...
[ "The", "actual", "event", "loop", "." ]
2a958665326892f45f249bebe62c2c23f306732b
https://github.com/jim-easterbrook/pyctools/blob/2a958665326892f45f249bebe62c2c23f306732b/src/pyctools/core/base.py#L131-L154
train
The main event loop.
jim-easterbrook/pyctools
src/pyctools/core/base.py
Component.send
def send(self, output_name, frame): """Send an output frame. The frame is sent to each input the output is connected to. If there are no connections this is a null operation with little overhead. :param str output_name: the output to use. Must be a member of :py:att...
python
def send(self, output_name, frame): """Send an output frame. The frame is sent to each input the output is connected to. If there are no connections this is a null operation with little overhead. :param str output_name: the output to use. Must be a member of :py:att...
[ "def", "send", "(", "self", ",", "output_name", ",", "frame", ")", ":", "for", "input_method", "in", "self", ".", "_component_connections", "[", "output_name", "]", ":", "input_method", "(", "frame", ")" ]
Send an output frame. The frame is sent to each input the output is connected to. If there are no connections this is a null operation with little overhead. :param str output_name: the output to use. Must be a member of :py:attr:`~Component.outputs`. :param Frame f...
[ "Send", "an", "output", "frame", "." ]
2a958665326892f45f249bebe62c2c23f306732b
https://github.com/jim-easterbrook/pyctools/blob/2a958665326892f45f249bebe62c2c23f306732b/src/pyctools/core/base.py#L280-L294
train
Send an output frame.
jim-easterbrook/pyctools
src/pyctools/core/base.py
Component.connect
def connect(self, output_name, input_method): """Connect an output to any callable object. :py:meth:`on_connect` is called after the connection is made to allow components to do something when an output is conected. :param str output_name: the output to connect. Must be a member ...
python
def connect(self, output_name, input_method): """Connect an output to any callable object. :py:meth:`on_connect` is called after the connection is made to allow components to do something when an output is conected. :param str output_name: the output to connect. Must be a member ...
[ "def", "connect", "(", "self", ",", "output_name", ",", "input_method", ")", ":", "self", ".", "logger", ".", "debug", "(", "'connect \"%s\"'", ",", "output_name", ")", "if", "self", ".", "running", "(", ")", ":", "raise", "RuntimeError", "(", "'Cannot con...
Connect an output to any callable object. :py:meth:`on_connect` is called after the connection is made to allow components to do something when an output is conected. :param str output_name: the output to connect. Must be a member of :py:attr:`~Component.outputs`. :param c...
[ "Connect", "an", "output", "to", "any", "callable", "object", "." ]
2a958665326892f45f249bebe62c2c23f306732b
https://github.com/jim-easterbrook/pyctools/blob/2a958665326892f45f249bebe62c2c23f306732b/src/pyctools/core/base.py#L296-L313
train
Connect an output to any callable object.
jim-easterbrook/pyctools
src/pyctools/core/base.py
Component.start_event
def start_event(self): """Called by the event loop when it is started. Creates the output frame pools (if used) then calls :py:meth:`on_start`. Creating the output frame pools now allows their size to be configured before starting the component. """ # create object pool...
python
def start_event(self): """Called by the event loop when it is started. Creates the output frame pools (if used) then calls :py:meth:`on_start`. Creating the output frame pools now allows their size to be configured before starting the component. """ # create object pool...
[ "def", "start_event", "(", "self", ")", ":", "# create object pool for each output", "if", "self", ".", "with_outframe_pool", ":", "self", ".", "update_config", "(", ")", "for", "name", "in", "self", ".", "outputs", ":", "self", ".", "outframe_pool", "[", "nam...
Called by the event loop when it is started. Creates the output frame pools (if used) then calls :py:meth:`on_start`. Creating the output frame pools now allows their size to be configured before starting the component.
[ "Called", "by", "the", "event", "loop", "when", "it", "is", "started", "." ]
2a958665326892f45f249bebe62c2c23f306732b
https://github.com/jim-easterbrook/pyctools/blob/2a958665326892f45f249bebe62c2c23f306732b/src/pyctools/core/base.py#L324-L342
train
Called by the event loop when the event loop is started.
jim-easterbrook/pyctools
src/pyctools/core/base.py
Component.stop_event
def stop_event(self): """Called by the event loop when it is stopped. Calls :py:meth:`on_stop`, then sends :py:data:`None` to each output to shut down the rest of the processing pipeline. """ self.logger.debug('stopping') try: self.on_stop() except E...
python
def stop_event(self): """Called by the event loop when it is stopped. Calls :py:meth:`on_stop`, then sends :py:data:`None` to each output to shut down the rest of the processing pipeline. """ self.logger.debug('stopping') try: self.on_stop() except E...
[ "def", "stop_event", "(", "self", ")", ":", "self", ".", "logger", ".", "debug", "(", "'stopping'", ")", "try", ":", "self", ".", "on_stop", "(", ")", "except", "Exception", "as", "ex", ":", "self", ".", "logger", ".", "exception", "(", "ex", ")", ...
Called by the event loop when it is stopped. Calls :py:meth:`on_stop`, then sends :py:data:`None` to each output to shut down the rest of the processing pipeline.
[ "Called", "by", "the", "event", "loop", "when", "it", "is", "stopped", "." ]
2a958665326892f45f249bebe62c2c23f306732b
https://github.com/jim-easterbrook/pyctools/blob/2a958665326892f45f249bebe62c2c23f306732b/src/pyctools/core/base.py#L348-L361
train
Called by the event loop when it is stopped.
jim-easterbrook/pyctools
src/pyctools/core/base.py
Component.is_pipe_end
def is_pipe_end(self): """Is component the last one in a pipeline. When waiting for a network of components to finish processing it's not necessary to wait for every component to stop, and in many cases they won't all stop anyway. This method makes it easier to choose which com...
python
def is_pipe_end(self): """Is component the last one in a pipeline. When waiting for a network of components to finish processing it's not necessary to wait for every component to stop, and in many cases they won't all stop anyway. This method makes it easier to choose which com...
[ "def", "is_pipe_end", "(", "self", ")", ":", "for", "name", "in", "self", ".", "outputs", ":", "if", "self", ".", "_component_connections", "[", "name", "]", ":", "return", "False", "return", "True" ]
Is component the last one in a pipeline. When waiting for a network of components to finish processing it's not necessary to wait for every component to stop, and in many cases they won't all stop anyway. This method makes it easier to choose which components to wait for. See t...
[ "Is", "component", "the", "last", "one", "in", "a", "pipeline", "." ]
2a958665326892f45f249bebe62c2c23f306732b
https://github.com/jim-easterbrook/pyctools/blob/2a958665326892f45f249bebe62c2c23f306732b/src/pyctools/core/base.py#L363-L380
train
Is the last one in a pipeline?
jim-easterbrook/pyctools
src/pyctools/core/base.py
Component.new_config_event
def new_config_event(self): """Called by the event loop when new config is available. """ try: self.on_set_config() except Exception as ex: self.logger.exception(ex) raise StopIteration()
python
def new_config_event(self): """Called by the event loop when new config is available. """ try: self.on_set_config() except Exception as ex: self.logger.exception(ex) raise StopIteration()
[ "def", "new_config_event", "(", "self", ")", ":", "try", ":", "self", ".", "on_set_config", "(", ")", "except", "Exception", "as", "ex", ":", "self", ".", "logger", ".", "exception", "(", "ex", ")", "raise", "StopIteration", "(", ")" ]
Called by the event loop when new config is available.
[ "Called", "by", "the", "event", "loop", "when", "new", "config", "is", "available", "." ]
2a958665326892f45f249bebe62c2c23f306732b
https://github.com/jim-easterbrook/pyctools/blob/2a958665326892f45f249bebe62c2c23f306732b/src/pyctools/core/base.py#L389-L397
train
Called by the event loop when new config is available.
jim-easterbrook/pyctools
src/pyctools/core/base.py
Component.new_frame_event
def new_frame_event(self): """Called by the event loop when a new input or output frame is available. Inputs are correlated by comparing their frame numbers. If there is a complete set of inputs, and all output frame pools are ready, the :py:meth:`process_frame` method is called...
python
def new_frame_event(self): """Called by the event loop when a new input or output frame is available. Inputs are correlated by comparing their frame numbers. If there is a complete set of inputs, and all output frame pools are ready, the :py:meth:`process_frame` method is called...
[ "def", "new_frame_event", "(", "self", ")", ":", "# check output frames are available", "for", "out_pool", "in", "self", ".", "outframe_pool", ".", "values", "(", ")", ":", "if", "not", "out_pool", ".", "available", "(", ")", ":", "return", "# check input frames...
Called by the event loop when a new input or output frame is available. Inputs are correlated by comparing their frame numbers. If there is a complete set of inputs, and all output frame pools are ready, the :py:meth:`process_frame` method is called. If an input frame has a neg...
[ "Called", "by", "the", "event", "loop", "when", "a", "new", "input", "or", "output", "frame", "is", "available", "." ]
2a958665326892f45f249bebe62c2c23f306732b
https://github.com/jim-easterbrook/pyctools/blob/2a958665326892f45f249bebe62c2c23f306732b/src/pyctools/core/base.py#L410-L466
train
Called by the event loop when a new input or output frame is available.
jim-easterbrook/pyctools
src/pyctools/core/base.py
Transformer.process_frame
def process_frame(self): """Get the input and output frame, then call :py:meth:`transform`. """ input_name = self.inputs[0] output_name = self.outputs[0] in_frame = self.input_buffer[input_name].get() out_frame = self.outframe_pool[output_name].get() out_...
python
def process_frame(self): """Get the input and output frame, then call :py:meth:`transform`. """ input_name = self.inputs[0] output_name = self.outputs[0] in_frame = self.input_buffer[input_name].get() out_frame = self.outframe_pool[output_name].get() out_...
[ "def", "process_frame", "(", "self", ")", ":", "input_name", "=", "self", ".", "inputs", "[", "0", "]", "output_name", "=", "self", ".", "outputs", "[", "0", "]", "in_frame", "=", "self", ".", "input_buffer", "[", "input_name", "]", ".", "get", "(", ...
Get the input and output frame, then call :py:meth:`transform`.
[ "Get", "the", "input", "and", "output", "frame", "then", "call", ":", "py", ":", "meth", ":", "transform", "." ]
2a958665326892f45f249bebe62c2c23f306732b
https://github.com/jim-easterbrook/pyctools/blob/2a958665326892f45f249bebe62c2c23f306732b/src/pyctools/core/base.py#L497-L510
train
Process the next input and output frame and call the transform method.
kavdev/ldap-groups
ldap_groups/groups.py
ADGroup._get_valididty
def _get_valididty(self): """ Determines whether this AD Group is valid. :returns: True and "" if this group is valid or False and a string description with the reason why it isn't valid otherwise. """ try: self.ldap_connection.search(search_base...
python
def _get_valididty(self): """ Determines whether this AD Group is valid. :returns: True and "" if this group is valid or False and a string description with the reason why it isn't valid otherwise. """ try: self.ldap_connection.search(search_base...
[ "def", "_get_valididty", "(", "self", ")", ":", "try", ":", "self", ".", "ldap_connection", ".", "search", "(", "search_base", "=", "self", ".", "VALID_GROUP_TEST", "[", "'base_dn'", "]", ",", "search_filter", "=", "self", ".", "VALID_GROUP_TEST", "[", "'fil...
Determines whether this AD Group is valid. :returns: True and "" if this group is valid or False and a string description with the reason why it isn't valid otherwise.
[ "Determines", "whether", "this", "AD", "Group", "is", "valid", ".", ":", "returns", ":", "True", "and", "if", "this", "group", "is", "valid", "or", "False", "and", "a", "string", "description", "with", "the", "reason", "why", "it", "isn", "t", "valid", ...
0dd3a7d9eafa3903127364839b12a4b3dd3ca521
https://github.com/kavdev/ldap-groups/blob/0dd3a7d9eafa3903127364839b12a4b3dd3ca521/ldap_groups/groups.py#L270-L294
train
Returns True if this group is valid False otherwise.
kavdev/ldap-groups
ldap_groups/groups.py
ADGroup.get_attribute
def get_attribute(self, attribute_name, no_cache=False): """ Gets the passed attribute of this group. :param attribute_name: The name of the attribute to get. :type attribute_name: str :param no_cache (optional): Set to True to pull the attribute directly from an LDAP search instea...
python
def get_attribute(self, attribute_name, no_cache=False): """ Gets the passed attribute of this group. :param attribute_name: The name of the attribute to get. :type attribute_name: str :param no_cache (optional): Set to True to pull the attribute directly from an LDAP search instea...
[ "def", "get_attribute", "(", "self", ",", "attribute_name", ",", "no_cache", "=", "False", ")", ":", "attributes", "=", "self", ".", "get_attributes", "(", "no_cache", ")", "if", "attribute_name", "not", "in", "attributes", ":", "logger", ".", "debug", "(", ...
Gets the passed attribute of this group. :param attribute_name: The name of the attribute to get. :type attribute_name: str :param no_cache (optional): Set to True to pull the attribute directly from an LDAP search instead of from the cache. Default Fals...
[ "Gets", "the", "passed", "attribute", "of", "this", "group", ".", ":", "param", "attribute_name", ":", "The", "name", "of", "the", "attribute", "to", "get", ".", ":", "type", "attribute_name", ":", "str", ":", "param", "no_cache", "(", "optional", ")", "...
0dd3a7d9eafa3903127364839b12a4b3dd3ca521
https://github.com/kavdev/ldap-groups/blob/0dd3a7d9eafa3903127364839b12a4b3dd3ca521/ldap_groups/groups.py#L296-L322
train
Gets the specified attribute from the group.
kavdev/ldap-groups
ldap_groups/groups.py
ADGroup.get_attributes
def get_attributes(self, no_cache=False): """ Returns a dictionary of this group's attributes. This method caches the attributes after the first search unless no_cache is specified. :param no_cache (optional): Set to True to pull attributes directly from an LDAP search instead of ...
python
def get_attributes(self, no_cache=False): """ Returns a dictionary of this group's attributes. This method caches the attributes after the first search unless no_cache is specified. :param no_cache (optional): Set to True to pull attributes directly from an LDAP search instead of ...
[ "def", "get_attributes", "(", "self", ",", "no_cache", "=", "False", ")", ":", "if", "not", "self", ".", "attributes", ":", "self", ".", "ldap_connection", ".", "search", "(", "search_base", "=", "self", ".", "ATTRIBUTES_SEARCH", "[", "'base_dn'", "]", ","...
Returns a dictionary of this group's attributes. This method caches the attributes after the first search unless no_cache is specified. :param no_cache (optional): Set to True to pull attributes directly from an LDAP search instead of from the cache. Default Fals...
[ "Returns", "a", "dictionary", "of", "this", "group", "s", "attributes", ".", "This", "method", "caches", "the", "attributes", "after", "the", "first", "search", "unless", "no_cache", "is", "specified", ".", ":", "param", "no_cache", "(", "optional", ")", ":"...
0dd3a7d9eafa3903127364839b12a4b3dd3ca521
https://github.com/kavdev/ldap-groups/blob/0dd3a7d9eafa3903127364839b12a4b3dd3ca521/ldap_groups/groups.py#L324-L353
train
Returns a dictionary of attributes for this group.
kavdev/ldap-groups
ldap_groups/groups.py
ADGroup._get_user_dn
def _get_user_dn(self, user_lookup_attribute_value): """ Searches for a user and retrieves his distinguished name. :param user_lookup_attribute_value: The value for the LDAP_GROUPS_USER_LOOKUP_ATTRIBUTE :type user_lookup_attribute_value: str :raises: **AccountDoesNotExist** if th...
python
def _get_user_dn(self, user_lookup_attribute_value): """ Searches for a user and retrieves his distinguished name. :param user_lookup_attribute_value: The value for the LDAP_GROUPS_USER_LOOKUP_ATTRIBUTE :type user_lookup_attribute_value: str :raises: **AccountDoesNotExist** if th...
[ "def", "_get_user_dn", "(", "self", ",", "user_lookup_attribute_value", ")", ":", "self", ".", "ldap_connection", ".", "search", "(", "search_base", "=", "self", ".", "USER_SEARCH", "[", "'base_dn'", "]", ",", "search_filter", "=", "self", ".", "USER_SEARCH", ...
Searches for a user and retrieves his distinguished name. :param user_lookup_attribute_value: The value for the LDAP_GROUPS_USER_LOOKUP_ATTRIBUTE :type user_lookup_attribute_value: str :raises: **AccountDoesNotExist** if the account doesn't exist in the active directory.
[ "Searches", "for", "a", "user", "and", "retrieves", "his", "distinguished", "name", ".", ":", "param", "user_lookup_attribute_value", ":", "The", "value", "for", "the", "LDAP_GROUPS_USER_LOOKUP_ATTRIBUTE", ":", "type", "user_lookup_attribute_value", ":", "str", ":", ...
0dd3a7d9eafa3903127364839b12a4b3dd3ca521
https://github.com/kavdev/ldap-groups/blob/0dd3a7d9eafa3903127364839b12a4b3dd3ca521/ldap_groups/groups.py#L355-L381
train
Searches for a user and retrieves his distinguished name.
kavdev/ldap-groups
ldap_groups/groups.py
ADGroup._get_group_dn
def _get_group_dn(self, group_lookup_attribute_value): """ Searches for a group and retrieves its distinguished name. :param group_lookup_attribute_value: The value for the LDAP_GROUPS_GROUP_LOOKUP_ATTRIBUTE :type group_lookup_attribute_value: str :raises: **GroupDoesNotExist** i...
python
def _get_group_dn(self, group_lookup_attribute_value): """ Searches for a group and retrieves its distinguished name. :param group_lookup_attribute_value: The value for the LDAP_GROUPS_GROUP_LOOKUP_ATTRIBUTE :type group_lookup_attribute_value: str :raises: **GroupDoesNotExist** i...
[ "def", "_get_group_dn", "(", "self", ",", "group_lookup_attribute_value", ")", ":", "self", ".", "ldap_connection", ".", "search", "(", "search_base", "=", "self", ".", "GROUP_SEARCH", "[", "'base_dn'", "]", ",", "search_filter", "=", "self", ".", "GROUP_SEARCH"...
Searches for a group and retrieves its distinguished name. :param group_lookup_attribute_value: The value for the LDAP_GROUPS_GROUP_LOOKUP_ATTRIBUTE :type group_lookup_attribute_value: str :raises: **GroupDoesNotExist** if the group doesn't exist in the active directory.
[ "Searches", "for", "a", "group", "and", "retrieves", "its", "distinguished", "name", ".", ":", "param", "group_lookup_attribute_value", ":", "The", "value", "for", "the", "LDAP_GROUPS_GROUP_LOOKUP_ATTRIBUTE", ":", "type", "group_lookup_attribute_value", ":", "str", ":...
0dd3a7d9eafa3903127364839b12a4b3dd3ca521
https://github.com/kavdev/ldap-groups/blob/0dd3a7d9eafa3903127364839b12a4b3dd3ca521/ldap_groups/groups.py#L383-L409
train
Searches for a group and retrieves its distinguished name.
kavdev/ldap-groups
ldap_groups/groups.py
ADGroup._get_group_members
def _get_group_members(self, page_size=500): """ Searches for a group and retrieve its members. :param page_size (optional): Many servers have a limit on the number of results that can be returned. Paged searches circumvent that limit. Adjust the page_size to be...
python
def _get_group_members(self, page_size=500): """ Searches for a group and retrieve its members. :param page_size (optional): Many servers have a limit on the number of results that can be returned. Paged searches circumvent that limit. Adjust the page_size to be...
[ "def", "_get_group_members", "(", "self", ",", "page_size", "=", "500", ")", ":", "entry_list", "=", "self", ".", "ldap_connection", ".", "extend", ".", "standard", ".", "paged_search", "(", "search_base", "=", "self", ".", "GROUP_MEMBER_SEARCH", "[", "'base_d...
Searches for a group and retrieve its members. :param page_size (optional): Many servers have a limit on the number of results that can be returned. Paged searches circumvent that limit. Adjust the page_size to be below the server's ...
[ "Searches", "for", "a", "group", "and", "retrieve", "its", "members", ".", ":", "param", "page_size", "(", "optional", ")", ":", "Many", "servers", "have", "a", "limit", "on", "the", "number", "of", "results", "that", "can", "be", "returned", ".", "Paged...
0dd3a7d9eafa3903127364839b12a4b3dd3ca521
https://github.com/kavdev/ldap-groups/blob/0dd3a7d9eafa3903127364839b12a4b3dd3ca521/ldap_groups/groups.py#L411-L431
train
Returns a list of group members.
kavdev/ldap-groups
ldap_groups/groups.py
ADGroup.get_member_info
def get_member_info(self, page_size=500): """ Retrieves member information from the AD group object. :param page_size (optional): Many servers have a limit on the number of results that can be returned. Paged searches circumvent that limit. Adjust the page_size ...
python
def get_member_info(self, page_size=500): """ Retrieves member information from the AD group object. :param page_size (optional): Many servers have a limit on the number of results that can be returned. Paged searches circumvent that limit. Adjust the page_size ...
[ "def", "get_member_info", "(", "self", ",", "page_size", "=", "500", ")", ":", "member_info", "=", "[", "]", "for", "member", "in", "self", ".", "_get_group_members", "(", "page_size", ")", ":", "info_dict", "=", "{", "}", "for", "attribute_name", "in", ...
Retrieves member information from the AD group object. :param page_size (optional): Many servers have a limit on the number of results that can be returned. Paged searches circumvent that limit. Adjust the page_size to be below the s...
[ "Retrieves", "member", "information", "from", "the", "AD", "group", "object", ".", ":", "param", "page_size", "(", "optional", ")", ":", "Many", "servers", "have", "a", "limit", "on", "the", "number", "of", "results", "that", "can", "be", "returned", ".", ...
0dd3a7d9eafa3903127364839b12a4b3dd3ca521
https://github.com/kavdev/ldap-groups/blob/0dd3a7d9eafa3903127364839b12a4b3dd3ca521/ldap_groups/groups.py#L433-L462
train
Returns a list of dictionary of member names and values for each member of the group.
kavdev/ldap-groups
ldap_groups/groups.py
ADGroup.get_tree_members
def get_tree_members(self): """ Retrieves all members from this node of the tree down.""" members = [] queue = deque() queue.appendleft(self) visited = set() while len(queue): node = queue.popleft() if node not in visited: ...
python
def get_tree_members(self): """ Retrieves all members from this node of the tree down.""" members = [] queue = deque() queue.appendleft(self) visited = set() while len(queue): node = queue.popleft() if node not in visited: ...
[ "def", "get_tree_members", "(", "self", ")", ":", "members", "=", "[", "]", "queue", "=", "deque", "(", ")", "queue", ".", "appendleft", "(", "self", ")", "visited", "=", "set", "(", ")", "while", "len", "(", "queue", ")", ":", "node", "=", "queue"...
Retrieves all members from this node of the tree down.
[ "Retrieves", "all", "members", "from", "this", "node", "of", "the", "tree", "down", "." ]
0dd3a7d9eafa3903127364839b12a4b3dd3ca521
https://github.com/kavdev/ldap-groups/blob/0dd3a7d9eafa3903127364839b12a4b3dd3ca521/ldap_groups/groups.py#L464-L480
train
Gets all members from this node of the tree down.
kavdev/ldap-groups
ldap_groups/groups.py
ADGroup.add_member
def add_member(self, user_lookup_attribute_value): """ Attempts to add a member to the AD group. :param user_lookup_attribute_value: The value for the LDAP_GROUPS_USER_LOOKUP_ATTRIBUTE. :type user_lookup_attribute_value: str :raises: **AccountDoesNotExist** if the provided accoun...
python
def add_member(self, user_lookup_attribute_value): """ Attempts to add a member to the AD group. :param user_lookup_attribute_value: The value for the LDAP_GROUPS_USER_LOOKUP_ATTRIBUTE. :type user_lookup_attribute_value: str :raises: **AccountDoesNotExist** if the provided accoun...
[ "def", "add_member", "(", "self", ",", "user_lookup_attribute_value", ")", ":", "add_member", "=", "{", "'member'", ":", "(", "MODIFY_ADD", ",", "[", "self", ".", "_get_user_dn", "(", "user_lookup_attribute_value", ")", "]", ")", "}", "self", ".", "_attempt_mo...
Attempts to add a member to the AD group. :param user_lookup_attribute_value: The value for the LDAP_GROUPS_USER_LOOKUP_ATTRIBUTE. :type user_lookup_attribute_value: str :raises: **AccountDoesNotExist** if the provided account doesn't exist in the active directory. ...
[ "Attempts", "to", "add", "a", "member", "to", "the", "AD", "group", ".", ":", "param", "user_lookup_attribute_value", ":", "The", "value", "for", "the", "LDAP_GROUPS_USER_LOOKUP_ATTRIBUTE", ".", ":", "type", "user_lookup_attribute_value", ":", "str", ":", "raises"...
0dd3a7d9eafa3903127364839b12a4b3dd3ca521
https://github.com/kavdev/ldap-groups/blob/0dd3a7d9eafa3903127364839b12a4b3dd3ca521/ldap_groups/groups.py#L512-L528
train
Adds a member to the group.
kavdev/ldap-groups
ldap_groups/groups.py
ADGroup.remove_member
def remove_member(self, user_lookup_attribute_value): """ Attempts to remove a member from the AD group. :param user_lookup_attribute_value: The value for the LDAP_GROUPS_USER_LOOKUP_ATTRIBUTE. :type user_lookup_attribute_value: str :raises: **AccountDoesNotExist** if the provide...
python
def remove_member(self, user_lookup_attribute_value): """ Attempts to remove a member from the AD group. :param user_lookup_attribute_value: The value for the LDAP_GROUPS_USER_LOOKUP_ATTRIBUTE. :type user_lookup_attribute_value: str :raises: **AccountDoesNotExist** if the provide...
[ "def", "remove_member", "(", "self", ",", "user_lookup_attribute_value", ")", ":", "remove_member", "=", "{", "'member'", ":", "(", "MODIFY_DELETE", ",", "[", "self", ".", "_get_user_dn", "(", "user_lookup_attribute_value", ")", "]", ")", "}", "self", ".", "_a...
Attempts to remove a member from the AD group. :param user_lookup_attribute_value: The value for the LDAP_GROUPS_USER_LOOKUP_ATTRIBUTE. :type user_lookup_attribute_value: str :raises: **AccountDoesNotExist** if the provided account doesn't exist in the active directory. ...
[ "Attempts", "to", "remove", "a", "member", "from", "the", "AD", "group", ".", ":", "param", "user_lookup_attribute_value", ":", "The", "value", "for", "the", "LDAP_GROUPS_USER_LOOKUP_ATTRIBUTE", ".", ":", "type", "user_lookup_attribute_value", ":", "str", ":", "ra...
0dd3a7d9eafa3903127364839b12a4b3dd3ca521
https://github.com/kavdev/ldap-groups/blob/0dd3a7d9eafa3903127364839b12a4b3dd3ca521/ldap_groups/groups.py#L530-L545
train
Removes a member from the group.
kavdev/ldap-groups
ldap_groups/groups.py
ADGroup.add_child
def add_child(self, group_lookup_attribute_value): """ Attempts to add a child to the AD group. :param group_lookup_attribute_value: The value for the LDAP_GROUPS_GROUP_LOOKUP_ATTRIBUTE. :type group_lookup_attribute_value: str :raises: **GroupDoesNotExist** if the provided group ...
python
def add_child(self, group_lookup_attribute_value): """ Attempts to add a child to the AD group. :param group_lookup_attribute_value: The value for the LDAP_GROUPS_GROUP_LOOKUP_ATTRIBUTE. :type group_lookup_attribute_value: str :raises: **GroupDoesNotExist** if the provided group ...
[ "def", "add_child", "(", "self", ",", "group_lookup_attribute_value", ")", ":", "add_child", "=", "{", "'member'", ":", "(", "MODIFY_ADD", ",", "[", "self", ".", "_get_group_dn", "(", "group_lookup_attribute_value", ")", "]", ")", "}", "self", ".", "_attempt_m...
Attempts to add a child to the AD group. :param group_lookup_attribute_value: The value for the LDAP_GROUPS_GROUP_LOOKUP_ATTRIBUTE. :type group_lookup_attribute_value: str :raises: **GroupDoesNotExist** if the provided group doesn't exist in the active directory. ...
[ "Attempts", "to", "add", "a", "child", "to", "the", "AD", "group", ".", ":", "param", "group_lookup_attribute_value", ":", "The", "value", "for", "the", "LDAP_GROUPS_GROUP_LOOKUP_ATTRIBUTE", ".", ":", "type", "group_lookup_attribute_value", ":", "str", ":", "raise...
0dd3a7d9eafa3903127364839b12a4b3dd3ca521
https://github.com/kavdev/ldap-groups/blob/0dd3a7d9eafa3903127364839b12a4b3dd3ca521/ldap_groups/groups.py#L547-L563
train
Adds a child to the group.
kavdev/ldap-groups
ldap_groups/groups.py
ADGroup.remove_child
def remove_child(self, group_lookup_attribute_value): """ Attempts to remove a child from the AD group. :param group_lookup_attribute_value: The value for the LDAP_GROUPS_GROUP_LOOKUP_ATTRIBUTE. :type group_lookup_attribute_value: str :raises: **GroupDoesNotExist** if the provide...
python
def remove_child(self, group_lookup_attribute_value): """ Attempts to remove a child from the AD group. :param group_lookup_attribute_value: The value for the LDAP_GROUPS_GROUP_LOOKUP_ATTRIBUTE. :type group_lookup_attribute_value: str :raises: **GroupDoesNotExist** if the provide...
[ "def", "remove_child", "(", "self", ",", "group_lookup_attribute_value", ")", ":", "remove_child", "=", "{", "'member'", ":", "(", "MODIFY_DELETE", ",", "[", "self", ".", "_get_group_dn", "(", "group_lookup_attribute_value", ")", "]", ")", "}", "self", ".", "_...
Attempts to remove a child from the AD group. :param group_lookup_attribute_value: The value for the LDAP_GROUPS_GROUP_LOOKUP_ATTRIBUTE. :type group_lookup_attribute_value: str :raises: **GroupDoesNotExist** if the provided group doesn't exist in the active directory. ...
[ "Attempts", "to", "remove", "a", "child", "from", "the", "AD", "group", ".", ":", "param", "group_lookup_attribute_value", ":", "The", "value", "for", "the", "LDAP_GROUPS_GROUP_LOOKUP_ATTRIBUTE", ".", ":", "type", "group_lookup_attribute_value", ":", "str", ":", "...
0dd3a7d9eafa3903127364839b12a4b3dd3ca521
https://github.com/kavdev/ldap-groups/blob/0dd3a7d9eafa3903127364839b12a4b3dd3ca521/ldap_groups/groups.py#L565-L581
train
Removes a child from the group.
kavdev/ldap-groups
ldap_groups/groups.py
ADGroup.get_descendants
def get_descendants(self, page_size=500): """ Returns a list of all descendants of this group. :param page_size (optional): Many servers have a limit on the number of results that can be returned. Paged searches circumvent that limit. Adjust the page_size to be ...
python
def get_descendants(self, page_size=500): """ Returns a list of all descendants of this group. :param page_size (optional): Many servers have a limit on the number of results that can be returned. Paged searches circumvent that limit. Adjust the page_size to be ...
[ "def", "get_descendants", "(", "self", ",", "page_size", "=", "500", ")", ":", "entry_list", "=", "self", ".", "ldap_connection", ".", "extend", ".", "standard", ".", "paged_search", "(", "search_base", "=", "self", ".", "DESCENDANT_SEARCH", "[", "'base_dn'", ...
Returns a list of all descendants of this group. :param page_size (optional): Many servers have a limit on the number of results that can be returned. Paged searches circumvent that limit. Adjust the page_size to be below the server'...
[ "Returns", "a", "list", "of", "all", "descendants", "of", "this", "group", ".", ":", "param", "page_size", "(", "optional", ")", ":", "Many", "servers", "have", "a", "limit", "on", "the", "number", "of", "results", "that", "can", "be", "returned", ".", ...
0dd3a7d9eafa3903127364839b12a4b3dd3ca521
https://github.com/kavdev/ldap-groups/blob/0dd3a7d9eafa3903127364839b12a4b3dd3ca521/ldap_groups/groups.py#L587-L612
train
Returns a list of all the descendants of the group.