repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
infothrill/python-dyndnsc
dyndnsc/updater/afraid.py
records
def records(credentials, url="https://freedns.afraid.org/api/"): """ Yield the dynamic DNS records associated with this account. :param credentials: an AfraidCredentials instance :param url: the service URL """ params = {"action": "getdyndns", "sha": credentials.sha} req = requests.get( ...
python
def records(credentials, url="https://freedns.afraid.org/api/"): """ Yield the dynamic DNS records associated with this account. :param credentials: an AfraidCredentials instance :param url: the service URL """ params = {"action": "getdyndns", "sha": credentials.sha} req = requests.get( ...
[ "def", "records", "(", "credentials", ",", "url", "=", "\"https://freedns.afraid.org/api/\"", ")", ":", "params", "=", "{", "\"action\"", ":", "\"getdyndns\"", ",", "\"sha\"", ":", "credentials", ".", "sha", "}", "req", "=", "requests", ".", "get", "(", "url...
Yield the dynamic DNS records associated with this account. :param credentials: an AfraidCredentials instance :param url: the service URL
[ "Yield", "the", "dynamic", "DNS", "records", "associated", "with", "this", "account", "." ]
train
https://github.com/infothrill/python-dyndnsc/blob/2196d48aa6098da9835a7611fbdb0b5f0fbf51e4/dyndnsc/updater/afraid.py#L77-L89
infothrill/python-dyndnsc
dyndnsc/updater/afraid.py
update
def update(url): """ Update remote DNS record by requesting its special endpoint URL. This automatically picks the IP address using the HTTP connection: it is not possible to specify the IP address explicitly. :param url: URL to retrieve for triggering the update :return: IP address """ ...
python
def update(url): """ Update remote DNS record by requesting its special endpoint URL. This automatically picks the IP address using the HTTP connection: it is not possible to specify the IP address explicitly. :param url: URL to retrieve for triggering the update :return: IP address """ ...
[ "def", "update", "(", "url", ")", ":", "req", "=", "requests", ".", "get", "(", "url", ",", "headers", "=", "constants", ".", "REQUEST_HEADERS_DEFAULT", ",", "timeout", "=", "60", ")", "req", ".", "close", "(", ")", "# Response must contain an IP address, or...
Update remote DNS record by requesting its special endpoint URL. This automatically picks the IP address using the HTTP connection: it is not possible to specify the IP address explicitly. :param url: URL to retrieve for triggering the update :return: IP address
[ "Update", "remote", "DNS", "record", "by", "requesting", "its", "special", "endpoint", "URL", "." ]
train
https://github.com/infothrill/python-dyndnsc/blob/2196d48aa6098da9835a7611fbdb0b5f0fbf51e4/dyndnsc/updater/afraid.py#L92-L112
infothrill/python-dyndnsc
dyndnsc/updater/afraid.py
AfraidCredentials.sha
def sha(self): """Return sha, lazily compute if not done yet.""" if self._sha is None: self._sha = compute_auth_key(self.userid, self.password) return self._sha
python
def sha(self): """Return sha, lazily compute if not done yet.""" if self._sha is None: self._sha = compute_auth_key(self.userid, self.password) return self._sha
[ "def", "sha", "(", "self", ")", ":", "if", "self", ".", "_sha", "is", "None", ":", "self", ".", "_sha", "=", "compute_auth_key", "(", "self", ".", "userid", ",", "self", ".", "password", ")", "return", "self", ".", "_sha" ]
Return sha, lazily compute if not done yet.
[ "Return", "sha", "lazily", "compute", "if", "not", "done", "yet", "." ]
train
https://github.com/infothrill/python-dyndnsc/blob/2196d48aa6098da9835a7611fbdb0b5f0fbf51e4/dyndnsc/updater/afraid.py#L53-L57
infothrill/python-dyndnsc
dyndnsc/updater/afraid.py
UpdateProtocolAfraid.update
def update(self, *args, **kwargs): """Update the IP on the remote service.""" # first find the update_url for the provided account + hostname: update_url = next((r.update_url for r in records(self._credentials, self._url) if r.hostname == sel...
python
def update(self, *args, **kwargs): """Update the IP on the remote service.""" # first find the update_url for the provided account + hostname: update_url = next((r.update_url for r in records(self._credentials, self._url) if r.hostname == sel...
[ "def", "update", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# first find the update_url for the provided account + hostname:", "update_url", "=", "next", "(", "(", "r", ".", "update_url", "for", "r", "in", "records", "(", "self", ".", ...
Update the IP on the remote service.
[ "Update", "the", "IP", "on", "the", "remote", "service", "." ]
train
https://github.com/infothrill/python-dyndnsc/blob/2196d48aa6098da9835a7611fbdb0b5f0fbf51e4/dyndnsc/updater/afraid.py#L135-L145
infothrill/python-dyndnsc
dyndnsc/common/subject.py
Subject.register_observer
def register_observer(self, observer, events=None): """Register a listener function. :param observer: external listener function :param events: tuple or list of relevant events (default=None) """ if events is not None and not isinstance(events, (tuple, list)): events...
python
def register_observer(self, observer, events=None): """Register a listener function. :param observer: external listener function :param events: tuple or list of relevant events (default=None) """ if events is not None and not isinstance(events, (tuple, list)): events...
[ "def", "register_observer", "(", "self", ",", "observer", ",", "events", "=", "None", ")", ":", "if", "events", "is", "not", "None", "and", "not", "isinstance", "(", "events", ",", "(", "tuple", ",", "list", ")", ")", ":", "events", "=", "(", "events...
Register a listener function. :param observer: external listener function :param events: tuple or list of relevant events (default=None)
[ "Register", "a", "listener", "function", "." ]
train
https://github.com/infothrill/python-dyndnsc/blob/2196d48aa6098da9835a7611fbdb0b5f0fbf51e4/dyndnsc/common/subject.py#L17-L29
infothrill/python-dyndnsc
dyndnsc/common/subject.py
Subject.notify_observers
def notify_observers(self, event=None, msg=None): """Notify observers.""" for observer, events in list(self._observers.items()): # LOG.debug("trying to notify the observer") if events is None or event is None or event in events: try: observer(s...
python
def notify_observers(self, event=None, msg=None): """Notify observers.""" for observer, events in list(self._observers.items()): # LOG.debug("trying to notify the observer") if events is None or event is None or event in events: try: observer(s...
[ "def", "notify_observers", "(", "self", ",", "event", "=", "None", ",", "msg", "=", "None", ")", ":", "for", "observer", ",", "events", "in", "list", "(", "self", ".", "_observers", ".", "items", "(", ")", ")", ":", "# LOG.debug(\"trying to notify the obse...
Notify observers.
[ "Notify", "observers", "." ]
train
https://github.com/infothrill/python-dyndnsc/blob/2196d48aa6098da9835a7611fbdb0b5f0fbf51e4/dyndnsc/common/subject.py#L31-L42
infothrill/python-dyndnsc
dyndnsc/detector/socket_ip.py
IPDetector_Socket.detect
def detect(self): """Detect the IP address.""" if self.opts_family == AF_INET6: kind = IPV6_PUBLIC else: # 'INET': kind = IPV4 theip = None try: theip = detect_ip(kind) except GetIpException: LOG.exception("socket detector ...
python
def detect(self): """Detect the IP address.""" if self.opts_family == AF_INET6: kind = IPV6_PUBLIC else: # 'INET': kind = IPV4 theip = None try: theip = detect_ip(kind) except GetIpException: LOG.exception("socket detector ...
[ "def", "detect", "(", "self", ")", ":", "if", "self", ".", "opts_family", "==", "AF_INET6", ":", "kind", "=", "IPV6_PUBLIC", "else", ":", "# 'INET':", "kind", "=", "IPV4", "theip", "=", "None", "try", ":", "theip", "=", "detect_ip", "(", "kind", ")", ...
Detect the IP address.
[ "Detect", "the", "IP", "address", "." ]
train
https://github.com/infothrill/python-dyndnsc/blob/2196d48aa6098da9835a7611fbdb0b5f0fbf51e4/dyndnsc/detector/socket_ip.py#L32-L44
infothrill/python-dyndnsc
dyndnsc/detector/iface.py
IPDetector_Iface._detect
def _detect(self): """Use the netifaces module to detect ifconfig information.""" theip = None try: if self.opts_family == AF_INET6: addrlist = netifaces.ifaddresses(self.opts_iface)[netifaces.AF_INET6] else: addrlist = netifaces.ifaddresse...
python
def _detect(self): """Use the netifaces module to detect ifconfig information.""" theip = None try: if self.opts_family == AF_INET6: addrlist = netifaces.ifaddresses(self.opts_iface)[netifaces.AF_INET6] else: addrlist = netifaces.ifaddresse...
[ "def", "_detect", "(", "self", ")", ":", "theip", "=", "None", "try", ":", "if", "self", ".", "opts_family", "==", "AF_INET6", ":", "addrlist", "=", "netifaces", ".", "ifaddresses", "(", "self", ".", "opts_iface", ")", "[", "netifaces", ".", "AF_INET6", ...
Use the netifaces module to detect ifconfig information.
[ "Use", "the", "netifaces", "module", "to", "detect", "ifconfig", "information", "." ]
train
https://github.com/infothrill/python-dyndnsc/blob/2196d48aa6098da9835a7611fbdb0b5f0fbf51e4/dyndnsc/detector/iface.py#L66-L96
softwarefactory-project/rdopkg
features/environment.py
clean_tempdir
def clean_tempdir(context, scenario): """ Clean up temporary test dirs for passed tests. Leave failed test dirs for manual inspection. """ tempdir = getattr(context, 'tempdir', None) if tempdir and scenario.status == 'passed': shutil.rmtree(tempdir) del(context.tempdir)
python
def clean_tempdir(context, scenario): """ Clean up temporary test dirs for passed tests. Leave failed test dirs for manual inspection. """ tempdir = getattr(context, 'tempdir', None) if tempdir and scenario.status == 'passed': shutil.rmtree(tempdir) del(context.tempdir)
[ "def", "clean_tempdir", "(", "context", ",", "scenario", ")", ":", "tempdir", "=", "getattr", "(", "context", ",", "'tempdir'", ",", "None", ")", "if", "tempdir", "and", "scenario", ".", "status", "==", "'passed'", ":", "shutil", ".", "rmtree", "(", "tem...
Clean up temporary test dirs for passed tests. Leave failed test dirs for manual inspection.
[ "Clean", "up", "temporary", "test", "dirs", "for", "passed", "tests", "." ]
train
https://github.com/softwarefactory-project/rdopkg/blob/2d2bed4e7cd329558a36d0dd404ec4ac8f9f254c/features/environment.py#L6-L16
infothrill/python-dyndnsc
dyndnsc/detector/rand.py
RandomIPGenerator.is_reserved_ip
def is_reserved_ip(self, ip): """Check if the given ip address is in a reserved ipv4 address space. :param ip: ip address :return: boolean """ theip = ipaddress(ip) for res in self._reserved_netmasks: if theip in ipnetwork(res): return True ...
python
def is_reserved_ip(self, ip): """Check if the given ip address is in a reserved ipv4 address space. :param ip: ip address :return: boolean """ theip = ipaddress(ip) for res in self._reserved_netmasks: if theip in ipnetwork(res): return True ...
[ "def", "is_reserved_ip", "(", "self", ",", "ip", ")", ":", "theip", "=", "ipaddress", "(", "ip", ")", "for", "res", "in", "self", ".", "_reserved_netmasks", ":", "if", "theip", "in", "ipnetwork", "(", "res", ")", ":", "return", "True", "return", "False...
Check if the given ip address is in a reserved ipv4 address space. :param ip: ip address :return: boolean
[ "Check", "if", "the", "given", "ip", "address", "is", "in", "a", "reserved", "ipv4", "address", "space", "." ]
train
https://github.com/infothrill/python-dyndnsc/blob/2196d48aa6098da9835a7611fbdb0b5f0fbf51e4/dyndnsc/detector/rand.py#L52-L62
infothrill/python-dyndnsc
dyndnsc/detector/rand.py
RandomIPGenerator.random_public_ip
def random_public_ip(self): """Return a randomly generated, public IPv4 address. :return: ip address """ randomip = random_ip() while self.is_reserved_ip(randomip): randomip = random_ip() return randomip
python
def random_public_ip(self): """Return a randomly generated, public IPv4 address. :return: ip address """ randomip = random_ip() while self.is_reserved_ip(randomip): randomip = random_ip() return randomip
[ "def", "random_public_ip", "(", "self", ")", ":", "randomip", "=", "random_ip", "(", ")", "while", "self", ".", "is_reserved_ip", "(", "randomip", ")", ":", "randomip", "=", "random_ip", "(", ")", "return", "randomip" ]
Return a randomly generated, public IPv4 address. :return: ip address
[ "Return", "a", "randomly", "generated", "public", "IPv4", "address", "." ]
train
https://github.com/infothrill/python-dyndnsc/blob/2196d48aa6098da9835a7611fbdb0b5f0fbf51e4/dyndnsc/detector/rand.py#L64-L72
infothrill/python-dyndnsc
dyndnsc/detector/rand.py
IPDetector_Random.detect
def detect(self): """Detect IP and return it.""" for theip in self.rips: LOG.debug("detected %s", str(theip)) self.set_current_value(str(theip)) return str(theip)
python
def detect(self): """Detect IP and return it.""" for theip in self.rips: LOG.debug("detected %s", str(theip)) self.set_current_value(str(theip)) return str(theip)
[ "def", "detect", "(", "self", ")", ":", "for", "theip", "in", "self", ".", "rips", ":", "LOG", ".", "debug", "(", "\"detected %s\"", ",", "str", "(", "theip", ")", ")", "self", ".", "set_current_value", "(", "str", "(", "theip", ")", ")", "return", ...
Detect IP and return it.
[ "Detect", "IP", "and", "return", "it", "." ]
train
https://github.com/infothrill/python-dyndnsc/blob/2196d48aa6098da9835a7611fbdb0b5f0fbf51e4/dyndnsc/detector/rand.py#L102-L107
infothrill/python-dyndnsc
dyndnsc/updater/dyndns2.py
UpdateProtocolDyndns2.update
def update(self, ip): """Update the IP on the remote service.""" timeout = 60 LOG.debug("Updating '%s' to '%s' at service '%s'", self.hostname, ip, self._updateurl) params = {"myip": ip, "hostname": self.hostname} req = requests.get(self._updateurl, params=params, headers=constan...
python
def update(self, ip): """Update the IP on the remote service.""" timeout = 60 LOG.debug("Updating '%s' to '%s' at service '%s'", self.hostname, ip, self._updateurl) params = {"myip": ip, "hostname": self.hostname} req = requests.get(self._updateurl, params=params, headers=constan...
[ "def", "update", "(", "self", ",", "ip", ")", ":", "timeout", "=", "60", "LOG", ".", "debug", "(", "\"Updating '%s' to '%s' at service '%s'\"", ",", "self", ".", "hostname", ",", "ip", ",", "self", ".", "_updateurl", ")", "params", "=", "{", "\"myip\"", ...
Update the IP on the remote service.
[ "Update", "the", "IP", "on", "the", "remote", "service", "." ]
train
https://github.com/infothrill/python-dyndnsc/blob/2196d48aa6098da9835a7611fbdb0b5f0fbf51e4/dyndnsc/updater/dyndns2.py#L36-L49
softwarefactory-project/rdopkg
rdopkg/guess.py
patches_base_ref
def patches_base_ref(default=exception.CantGuess): """Return a git reference to patches branch base. Returns first part of .spec's patches_base is found, otherwise return Version(+%{milestone}). """ ref = None try: spec = specfile.Spec() ref, _ = spec.get_patches_base(expand_mac...
python
def patches_base_ref(default=exception.CantGuess): """Return a git reference to patches branch base. Returns first part of .spec's patches_base is found, otherwise return Version(+%{milestone}). """ ref = None try: spec = specfile.Spec() ref, _ = spec.get_patches_base(expand_mac...
[ "def", "patches_base_ref", "(", "default", "=", "exception", ".", "CantGuess", ")", ":", "ref", "=", "None", "try", ":", "spec", "=", "specfile", ".", "Spec", "(", ")", "ref", ",", "_", "=", "spec", ".", "get_patches_base", "(", "expand_macros", "=", "...
Return a git reference to patches branch base. Returns first part of .spec's patches_base is found, otherwise return Version(+%{milestone}).
[ "Return", "a", "git", "reference", "to", "patches", "branch", "base", "." ]
train
https://github.com/softwarefactory-project/rdopkg/blob/2d2bed4e7cd329558a36d0dd404ec4ac8f9f254c/rdopkg/guess.py#L23-L50
jbeluch/xbmcswift2
xbmcswift2/cli/console.py
display_listitems
def display_listitems(items, url): '''Displays a list of items along with the index to enable a user to select an item. ''' if (len(items) == 2 and items[0].get_label() == '..' and items[1].get_played()): display_video(items) else: label_width = get_max_len(item.get_label() f...
python
def display_listitems(items, url): '''Displays a list of items along with the index to enable a user to select an item. ''' if (len(items) == 2 and items[0].get_label() == '..' and items[1].get_played()): display_video(items) else: label_width = get_max_len(item.get_label() f...
[ "def", "display_listitems", "(", "items", ",", "url", ")", ":", "if", "(", "len", "(", "items", ")", "==", "2", "and", "items", "[", "0", "]", ".", "get_label", "(", ")", "==", "'..'", "and", "items", "[", "1", "]", ".", "get_played", "(", ")", ...
Displays a list of items along with the index to enable a user to select an item.
[ "Displays", "a", "list", "of", "items", "along", "with", "the", "index", "to", "enable", "a", "user", "to", "select", "an", "item", "." ]
train
https://github.com/jbeluch/xbmcswift2/blob/0e7a3642499554edc8265fdf1ba6c5ee567daa78/xbmcswift2/cli/console.py#L20-L49
jbeluch/xbmcswift2
xbmcswift2/cli/console.py
display_video
def display_video(items): '''Prints a message for a playing video and displays the parent listitem. ''' parent_item, played_item = items title_line = 'Playing Media %s (%s)' % (played_item.get_label(), played_item.get_path()) parent_line = '[0] %s (%s...
python
def display_video(items): '''Prints a message for a playing video and displays the parent listitem. ''' parent_item, played_item = items title_line = 'Playing Media %s (%s)' % (played_item.get_label(), played_item.get_path()) parent_line = '[0] %s (%s...
[ "def", "display_video", "(", "items", ")", ":", "parent_item", ",", "played_item", "=", "items", "title_line", "=", "'Playing Media %s (%s)'", "%", "(", "played_item", ".", "get_label", "(", ")", ",", "played_item", ".", "get_path", "(", ")", ")", "parent_line...
Prints a message for a playing video and displays the parent listitem.
[ "Prints", "a", "message", "for", "a", "playing", "video", "and", "displays", "the", "parent", "listitem", "." ]
train
https://github.com/jbeluch/xbmcswift2/blob/0e7a3642499554edc8265fdf1ba6c5ee567daa78/xbmcswift2/cli/console.py#L52-L70
jbeluch/xbmcswift2
xbmcswift2/cli/console.py
get_user_choice
def get_user_choice(items): '''Returns the selected item from provided items or None if 'q' was entered for quit. ''' choice = raw_input('Choose an item or "q" to quit: ') while choice != 'q': try: item = items[int(choice)] print # Blank line for readability between ...
python
def get_user_choice(items): '''Returns the selected item from provided items or None if 'q' was entered for quit. ''' choice = raw_input('Choose an item or "q" to quit: ') while choice != 'q': try: item = items[int(choice)] print # Blank line for readability between ...
[ "def", "get_user_choice", "(", "items", ")", ":", "choice", "=", "raw_input", "(", "'Choose an item or \"q\" to quit: '", ")", "while", "choice", "!=", "'q'", ":", "try", ":", "item", "=", "items", "[", "int", "(", "choice", ")", "]", "print", "# Blank line ...
Returns the selected item from provided items or None if 'q' was entered for quit.
[ "Returns", "the", "selected", "item", "from", "provided", "items", "or", "None", "if", "q", "was", "entered", "for", "quit", "." ]
train
https://github.com/jbeluch/xbmcswift2/blob/0e7a3642499554edc8265fdf1ba6c5ee567daa78/xbmcswift2/cli/console.py#L73-L91
mozilla/amo-validator
validator/unicodehelper.py
decode
def decode(data): """ Decode data employing some charset detection and including unicode BOM stripping. """ if isinstance(data, unicode): return data # Detect standard unicode BOMs. for bom, encoding in UNICODE_BOMS: if data.startswith(bom): return data[len(bom)...
python
def decode(data): """ Decode data employing some charset detection and including unicode BOM stripping. """ if isinstance(data, unicode): return data # Detect standard unicode BOMs. for bom, encoding in UNICODE_BOMS: if data.startswith(bom): return data[len(bom)...
[ "def", "decode", "(", "data", ")", ":", "if", "isinstance", "(", "data", ",", "unicode", ")", ":", "return", "data", "# Detect standard unicode BOMs.", "for", "bom", ",", "encoding", "in", "UNICODE_BOMS", ":", "if", "data", ".", "startswith", "(", "bom", "...
Decode data employing some charset detection and including unicode BOM stripping.
[ "Decode", "data", "employing", "some", "charset", "detection", "and", "including", "unicode", "BOM", "stripping", "." ]
train
https://github.com/mozilla/amo-validator/blob/0251bfbd7d93106e01ecdb6de5fcd1dc1a180664/validator/unicodehelper.py#L22-L50
mozilla/amo-validator
validator/contextgenerator.py
ContextGenerator.get_context
def get_context(self, line=1, column=0): 'Returns a tuple containing the context for a line' line -= 1 # The line is one-based # If there is no data in the file, there can be no context. datalen = len(self.data) if datalen <= line: return None build = [sel...
python
def get_context(self, line=1, column=0): 'Returns a tuple containing the context for a line' line -= 1 # The line is one-based # If there is no data in the file, there can be no context. datalen = len(self.data) if datalen <= line: return None build = [sel...
[ "def", "get_context", "(", "self", ",", "line", "=", "1", ",", "column", "=", "0", ")", ":", "line", "-=", "1", "# The line is one-based", "# If there is no data in the file, there can be no context.", "datalen", "=", "len", "(", "self", ".", "data", ")", "if", ...
Returns a tuple containing the context for a line
[ "Returns", "a", "tuple", "containing", "the", "context", "for", "a", "line" ]
train
https://github.com/mozilla/amo-validator/blob/0251bfbd7d93106e01ecdb6de5fcd1dc1a180664/validator/contextgenerator.py#L19-L82
mozilla/amo-validator
validator/contextgenerator.py
ContextGenerator._format_line
def _format_line(self, data, column=0, rel_line=1): 'Formats a line from the data to be the appropriate length' line_length = len(data) if line_length > 140: if rel_line == 0: # Trim from the beginning data = '... %s' % data[-140:] elif re...
python
def _format_line(self, data, column=0, rel_line=1): 'Formats a line from the data to be the appropriate length' line_length = len(data) if line_length > 140: if rel_line == 0: # Trim from the beginning data = '... %s' % data[-140:] elif re...
[ "def", "_format_line", "(", "self", ",", "data", ",", "column", "=", "0", ",", "rel_line", "=", "1", ")", ":", "line_length", "=", "len", "(", "data", ")", "if", "line_length", ">", "140", ":", "if", "rel_line", "==", "0", ":", "# Trim from the beginni...
Formats a line from the data to be the appropriate length
[ "Formats", "a", "line", "from", "the", "data", "to", "be", "the", "appropriate", "length" ]
train
https://github.com/mozilla/amo-validator/blob/0251bfbd7d93106e01ecdb6de5fcd1dc1a180664/validator/contextgenerator.py#L84-L106
mozilla/amo-validator
validator/contextgenerator.py
ContextGenerator.get_line
def get_line(self, position): 'Returns the line number that the given string position is found on' datalen = len(self.data) count = len(self.data[0]) line = 1 while count < position: if line >= datalen: break count += len(self.data[line]) ...
python
def get_line(self, position): 'Returns the line number that the given string position is found on' datalen = len(self.data) count = len(self.data[0]) line = 1 while count < position: if line >= datalen: break count += len(self.data[line]) ...
[ "def", "get_line", "(", "self", ",", "position", ")", ":", "datalen", "=", "len", "(", "self", ".", "data", ")", "count", "=", "len", "(", "self", ".", "data", "[", "0", "]", ")", "line", "=", "1", "while", "count", "<", "position", ":", "if", ...
Returns the line number that the given string position is found on
[ "Returns", "the", "line", "number", "that", "the", "given", "string", "position", "is", "found", "on" ]
train
https://github.com/mozilla/amo-validator/blob/0251bfbd7d93106e01ecdb6de5fcd1dc1a180664/validator/contextgenerator.py#L108-L120
jbeluch/xbmcswift2
xbmcswift2/mockxbmc/utils.py
load_addon_strings
def load_addon_strings(addon, filename): '''This is not an official XBMC method, it is here to faciliate mocking up the other methods when running outside of XBMC.''' def get_strings(fn): xml = parse(fn) strings = dict((tag.getAttribute('id'), tag.firstChild.data) for tag in xml.getElementsB...
python
def load_addon_strings(addon, filename): '''This is not an official XBMC method, it is here to faciliate mocking up the other methods when running outside of XBMC.''' def get_strings(fn): xml = parse(fn) strings = dict((tag.getAttribute('id'), tag.firstChild.data) for tag in xml.getElementsB...
[ "def", "load_addon_strings", "(", "addon", ",", "filename", ")", ":", "def", "get_strings", "(", "fn", ")", ":", "xml", "=", "parse", "(", "fn", ")", "strings", "=", "dict", "(", "(", "tag", ".", "getAttribute", "(", "'id'", ")", ",", "tag", ".", "...
This is not an official XBMC method, it is here to faciliate mocking up the other methods when running outside of XBMC.
[ "This", "is", "not", "an", "official", "XBMC", "method", "it", "is", "here", "to", "faciliate", "mocking", "up", "the", "other", "methods", "when", "running", "outside", "of", "XBMC", "." ]
train
https://github.com/jbeluch/xbmcswift2/blob/0e7a3642499554edc8265fdf1ba6c5ee567daa78/xbmcswift2/mockxbmc/utils.py#L4-L14
jbeluch/xbmcswift2
xbmcswift2/mockxbmc/utils.py
get_addon_id
def get_addon_id(addonxml): '''Parses an addon id from the given addon.xml filename.''' xml = parse(addonxml) addon_node = xml.getElementsByTagName('addon')[0] return addon_node.getAttribute('id')
python
def get_addon_id(addonxml): '''Parses an addon id from the given addon.xml filename.''' xml = parse(addonxml) addon_node = xml.getElementsByTagName('addon')[0] return addon_node.getAttribute('id')
[ "def", "get_addon_id", "(", "addonxml", ")", ":", "xml", "=", "parse", "(", "addonxml", ")", "addon_node", "=", "xml", ".", "getElementsByTagName", "(", "'addon'", ")", "[", "0", "]", "return", "addon_node", ".", "getAttribute", "(", "'id'", ")" ]
Parses an addon id from the given addon.xml filename.
[ "Parses", "an", "addon", "id", "from", "the", "given", "addon", ".", "xml", "filename", "." ]
train
https://github.com/jbeluch/xbmcswift2/blob/0e7a3642499554edc8265fdf1ba6c5ee567daa78/xbmcswift2/mockxbmc/utils.py#L17-L21
jbeluch/xbmcswift2
xbmcswift2/mockxbmc/utils.py
get_addon_name
def get_addon_name(addonxml): '''Parses an addon name from the given addon.xml filename.''' xml = parse(addonxml) addon_node = xml.getElementsByTagName('addon')[0] return addon_node.getAttribute('name')
python
def get_addon_name(addonxml): '''Parses an addon name from the given addon.xml filename.''' xml = parse(addonxml) addon_node = xml.getElementsByTagName('addon')[0] return addon_node.getAttribute('name')
[ "def", "get_addon_name", "(", "addonxml", ")", ":", "xml", "=", "parse", "(", "addonxml", ")", "addon_node", "=", "xml", ".", "getElementsByTagName", "(", "'addon'", ")", "[", "0", "]", "return", "addon_node", ".", "getAttribute", "(", "'name'", ")" ]
Parses an addon name from the given addon.xml filename.
[ "Parses", "an", "addon", "name", "from", "the", "given", "addon", ".", "xml", "filename", "." ]
train
https://github.com/jbeluch/xbmcswift2/blob/0e7a3642499554edc8265fdf1ba6c5ee567daa78/xbmcswift2/mockxbmc/utils.py#L24-L28
jbeluch/xbmcswift2
xbmcswift2/mockxbmc/xbmc.py
_create_dir
def _create_dir(path): '''Creates necessary directories for the given path or does nothing if the directories already exist. ''' try: os.makedirs(path) except OSError, exc: if exc.errno == errno.EEXIST: pass else: raise
python
def _create_dir(path): '''Creates necessary directories for the given path or does nothing if the directories already exist. ''' try: os.makedirs(path) except OSError, exc: if exc.errno == errno.EEXIST: pass else: raise
[ "def", "_create_dir", "(", "path", ")", ":", "try", ":", "os", ".", "makedirs", "(", "path", ")", "except", "OSError", ",", "exc", ":", "if", "exc", ".", "errno", "==", "errno", ".", "EEXIST", ":", "pass", "else", ":", "raise" ]
Creates necessary directories for the given path or does nothing if the directories already exist.
[ "Creates", "necessary", "directories", "for", "the", "given", "path", "or", "does", "nothing", "if", "the", "directories", "already", "exist", "." ]
train
https://github.com/jbeluch/xbmcswift2/blob/0e7a3642499554edc8265fdf1ba6c5ee567daa78/xbmcswift2/mockxbmc/xbmc.py#L11-L21
jbeluch/xbmcswift2
xbmcswift2/mockxbmc/xbmc.py
translatePath
def translatePath(path): '''Creates folders in the OS's temp directory. Doesn't touch any possible XBMC installation on the machine. Attempting to do as little work as possible to enable this function to work seamlessly. ''' valid_dirs = ['xbmc', 'home', 'temp', 'masterprofile', 'profile', '...
python
def translatePath(path): '''Creates folders in the OS's temp directory. Doesn't touch any possible XBMC installation on the machine. Attempting to do as little work as possible to enable this function to work seamlessly. ''' valid_dirs = ['xbmc', 'home', 'temp', 'masterprofile', 'profile', '...
[ "def", "translatePath", "(", "path", ")", ":", "valid_dirs", "=", "[", "'xbmc'", ",", "'home'", ",", "'temp'", ",", "'masterprofile'", ",", "'profile'", ",", "'subtitles'", ",", "'userdata'", ",", "'database'", ",", "'thumbnails'", ",", "'recordings'", ",", ...
Creates folders in the OS's temp directory. Doesn't touch any possible XBMC installation on the machine. Attempting to do as little work as possible to enable this function to work seamlessly.
[ "Creates", "folders", "in", "the", "OS", "s", "temp", "directory", ".", "Doesn", "t", "touch", "any", "possible", "XBMC", "installation", "on", "the", "machine", ".", "Attempting", "to", "do", "as", "little", "work", "as", "possible", "to", "enable", "this...
train
https://github.com/jbeluch/xbmcswift2/blob/0e7a3642499554edc8265fdf1ba6c5ee567daa78/xbmcswift2/mockxbmc/xbmc.py#L37-L56
jbeluch/xbmcswift2
xbmcswift2/plugin.py
Plugin._parse_request
def _parse_request(self, url=None, handle=None): '''Handles setup of the plugin state, including request arguments, handle, mode. This method never needs to be called directly. For testing, see plugin.test() ''' # To accomdate self.redirect, we need to be able to parse a...
python
def _parse_request(self, url=None, handle=None): '''Handles setup of the plugin state, including request arguments, handle, mode. This method never needs to be called directly. For testing, see plugin.test() ''' # To accomdate self.redirect, we need to be able to parse a...
[ "def", "_parse_request", "(", "self", ",", "url", "=", "None", ",", "handle", "=", "None", ")", ":", "# To accomdate self.redirect, we need to be able to parse a full url as", "# well", "if", "url", "is", "None", ":", "url", "=", "sys", ".", "argv", "[", "0", ...
Handles setup of the plugin state, including request arguments, handle, mode. This method never needs to be called directly. For testing, see plugin.test()
[ "Handles", "setup", "of", "the", "plugin", "state", "including", "request", "arguments", "handle", "mode", "." ]
train
https://github.com/jbeluch/xbmcswift2/blob/0e7a3642499554edc8265fdf1ba6c5ee567daa78/xbmcswift2/plugin.py#L194-L209
jbeluch/xbmcswift2
xbmcswift2/plugin.py
Plugin.register_module
def register_module(self, module, url_prefix): '''Registers a module with a plugin. Requires a url_prefix that will then enable calls to url_for. :param module: Should be an instance `xbmcswift2.Module`. :param url_prefix: A url prefix to use for all module urls, ...
python
def register_module(self, module, url_prefix): '''Registers a module with a plugin. Requires a url_prefix that will then enable calls to url_for. :param module: Should be an instance `xbmcswift2.Module`. :param url_prefix: A url prefix to use for all module urls, ...
[ "def", "register_module", "(", "self", ",", "module", ",", "url_prefix", ")", ":", "module", ".", "_plugin", "=", "self", "module", ".", "_url_prefix", "=", "url_prefix", "for", "func", "in", "module", ".", "_register_funcs", ":", "func", "(", "self", ",",...
Registers a module with a plugin. Requires a url_prefix that will then enable calls to url_for. :param module: Should be an instance `xbmcswift2.Module`. :param url_prefix: A url prefix to use for all module urls, e.g. '/mymodule'
[ "Registers", "a", "module", "with", "a", "plugin", ".", "Requires", "a", "url_prefix", "that", "will", "then", "enable", "calls", "to", "url_for", "." ]
train
https://github.com/jbeluch/xbmcswift2/blob/0e7a3642499554edc8265fdf1ba6c5ee567daa78/xbmcswift2/plugin.py#L211-L222
jbeluch/xbmcswift2
xbmcswift2/plugin.py
Plugin.cached_route
def cached_route(self, url_rule, name=None, options=None, TTL=None): '''A decorator to add a route to a view and also apply caching. The url_rule, name and options arguments are the same arguments for the route function. The TTL argument if given will passed along to the caching decorato...
python
def cached_route(self, url_rule, name=None, options=None, TTL=None): '''A decorator to add a route to a view and also apply caching. The url_rule, name and options arguments are the same arguments for the route function. The TTL argument if given will passed along to the caching decorato...
[ "def", "cached_route", "(", "self", ",", "url_rule", ",", "name", "=", "None", ",", "options", "=", "None", ",", "TTL", "=", "None", ")", ":", "route_decorator", "=", "self", ".", "route", "(", "url_rule", ",", "name", "=", "name", ",", "options", "=...
A decorator to add a route to a view and also apply caching. The url_rule, name and options arguments are the same arguments for the route function. The TTL argument if given will passed along to the caching decorator.
[ "A", "decorator", "to", "add", "a", "route", "to", "a", "view", "and", "also", "apply", "caching", ".", "The", "url_rule", "name", "and", "options", "arguments", "are", "the", "same", "arguments", "for", "the", "route", "function", ".", "The", "TTL", "ar...
train
https://github.com/jbeluch/xbmcswift2/blob/0e7a3642499554edc8265fdf1ba6c5ee567daa78/xbmcswift2/plugin.py#L224-L238
jbeluch/xbmcswift2
xbmcswift2/plugin.py
Plugin.route
def route(self, url_rule, name=None, options=None): '''A decorator to add a route to a view. name is used to differentiate when there are multiple routes for a given view.''' # TODO: change options kwarg to defaults def decorator(f): view_name = name or f.__name__ ...
python
def route(self, url_rule, name=None, options=None): '''A decorator to add a route to a view. name is used to differentiate when there are multiple routes for a given view.''' # TODO: change options kwarg to defaults def decorator(f): view_name = name or f.__name__ ...
[ "def", "route", "(", "self", ",", "url_rule", ",", "name", "=", "None", ",", "options", "=", "None", ")", ":", "# TODO: change options kwarg to defaults", "def", "decorator", "(", "f", ")", ":", "view_name", "=", "name", "or", "f", ".", "__name__", "self",...
A decorator to add a route to a view. name is used to differentiate when there are multiple routes for a given view.
[ "A", "decorator", "to", "add", "a", "route", "to", "a", "view", ".", "name", "is", "used", "to", "differentiate", "when", "there", "are", "multiple", "routes", "for", "a", "given", "view", "." ]
train
https://github.com/jbeluch/xbmcswift2/blob/0e7a3642499554edc8265fdf1ba6c5ee567daa78/xbmcswift2/plugin.py#L240-L248
jbeluch/xbmcswift2
xbmcswift2/plugin.py
Plugin.add_url_rule
def add_url_rule(self, url_rule, view_func, name, options=None): '''This method adds a URL rule for routing purposes. The provided name can be different from the view function name if desired. The provided name is what is used in url_for to build a URL. The route decorator provi...
python
def add_url_rule(self, url_rule, view_func, name, options=None): '''This method adds a URL rule for routing purposes. The provided name can be different from the view function name if desired. The provided name is what is used in url_for to build a URL. The route decorator provi...
[ "def", "add_url_rule", "(", "self", ",", "url_rule", ",", "view_func", ",", "name", ",", "options", "=", "None", ")", ":", "rule", "=", "UrlRule", "(", "url_rule", ",", "view_func", ",", "name", ",", "options", ")", "if", "name", "in", "self", ".", "...
This method adds a URL rule for routing purposes. The provided name can be different from the view function name if desired. The provided name is what is used in url_for to build a URL. The route decorator provides the same functionality.
[ "This", "method", "adds", "a", "URL", "rule", "for", "routing", "purposes", ".", "The", "provided", "name", "can", "be", "different", "from", "the", "view", "function", "name", "if", "desired", ".", "The", "provided", "name", "is", "what", "is", "used", ...
train
https://github.com/jbeluch/xbmcswift2/blob/0e7a3642499554edc8265fdf1ba6c5ee567daa78/xbmcswift2/plugin.py#L250-L268
jbeluch/xbmcswift2
xbmcswift2/plugin.py
Plugin.url_for
def url_for(self, endpoint, **items): '''Returns a valid XBMC plugin URL for the given endpoint name. endpoint can be the literal name of a function, or it can correspond to the name keyword arguments passed to the route decorator. Raises AmbiguousUrlException if there is more t...
python
def url_for(self, endpoint, **items): '''Returns a valid XBMC plugin URL for the given endpoint name. endpoint can be the literal name of a function, or it can correspond to the name keyword arguments passed to the route decorator. Raises AmbiguousUrlException if there is more t...
[ "def", "url_for", "(", "self", ",", "endpoint", ",", "*", "*", "items", ")", ":", "try", ":", "rule", "=", "self", ".", "_view_functions", "[", "endpoint", "]", "except", "KeyError", ":", "try", ":", "rule", "=", "(", "rule", "for", "rule", "in", "...
Returns a valid XBMC plugin URL for the given endpoint name. endpoint can be the literal name of a function, or it can correspond to the name keyword arguments passed to the route decorator. Raises AmbiguousUrlException if there is more than one possible view for the given endpo...
[ "Returns", "a", "valid", "XBMC", "plugin", "URL", "for", "the", "given", "endpoint", "name", ".", "endpoint", "can", "be", "the", "literal", "name", "of", "a", "function", "or", "it", "can", "correspond", "to", "the", "name", "keyword", "arguments", "passe...
train
https://github.com/jbeluch/xbmcswift2/blob/0e7a3642499554edc8265fdf1ba6c5ee567daa78/xbmcswift2/plugin.py#L270-L296
jbeluch/xbmcswift2
xbmcswift2/plugin.py
Plugin.redirect
def redirect(self, url): '''Used when you need to redirect to another view, and you only have the final plugin:// url.''' # TODO: Should we be overriding self.request with the new request? new_request = self._parse_request(url=url, handle=self.request.handle) log.debug('Redirecti...
python
def redirect(self, url): '''Used when you need to redirect to another view, and you only have the final plugin:// url.''' # TODO: Should we be overriding self.request with the new request? new_request = self._parse_request(url=url, handle=self.request.handle) log.debug('Redirecti...
[ "def", "redirect", "(", "self", ",", "url", ")", ":", "# TODO: Should we be overriding self.request with the new request?", "new_request", "=", "self", ".", "_parse_request", "(", "url", "=", "url", ",", "handle", "=", "self", ".", "request", ".", "handle", ")", ...
Used when you need to redirect to another view, and you only have the final plugin:// url.
[ "Used", "when", "you", "need", "to", "redirect", "to", "another", "view", "and", "you", "only", "have", "the", "final", "plugin", ":", "//", "url", "." ]
train
https://github.com/jbeluch/xbmcswift2/blob/0e7a3642499554edc8265fdf1ba6c5ee567daa78/xbmcswift2/plugin.py#L320-L326
jbeluch/xbmcswift2
xbmcswift2/plugin.py
Plugin.run
def run(self, test=False): '''The main entry point for a plugin.''' self._request = self._parse_request() log.debug('Handling incoming request for %s', self.request.path) items = self._dispatch(self.request.path) # Close any open storages which will persist them to disk ...
python
def run(self, test=False): '''The main entry point for a plugin.''' self._request = self._parse_request() log.debug('Handling incoming request for %s', self.request.path) items = self._dispatch(self.request.path) # Close any open storages which will persist them to disk ...
[ "def", "run", "(", "self", ",", "test", "=", "False", ")", ":", "self", ".", "_request", "=", "self", ".", "_parse_request", "(", ")", "log", ".", "debug", "(", "'Handling incoming request for %s'", ",", "self", ".", "request", ".", "path", ")", "items",...
The main entry point for a plugin.
[ "The", "main", "entry", "point", "for", "a", "plugin", "." ]
train
https://github.com/jbeluch/xbmcswift2/blob/0e7a3642499554edc8265fdf1ba6c5ee567daa78/xbmcswift2/plugin.py#L328-L341
jbeluch/xbmcswift2
xbmcswift2/cli/cli.py
main
def main(): '''The entry point for the console script xbmcswift2. The 'xbcmswift2' script is command bassed, so the second argument is always the command to execute. Each command has its own parser options and usages. If no command is provided or the -h flag is used without any other commands, the ...
python
def main(): '''The entry point for the console script xbmcswift2. The 'xbcmswift2' script is command bassed, so the second argument is always the command to execute. Each command has its own parser options and usages. If no command is provided or the -h flag is used without any other commands, the ...
[ "def", "main", "(", ")", ":", "parser", "=", "OptionParser", "(", ")", "if", "len", "(", "sys", ".", "argv", ")", "==", "1", ":", "parser", ".", "set_usage", "(", "USAGE", ")", "parser", ".", "error", "(", "'At least one command is required.'", ")", "#...
The entry point for the console script xbmcswift2. The 'xbcmswift2' script is command bassed, so the second argument is always the command to execute. Each command has its own parser options and usages. If no command is provided or the -h flag is used without any other commands, the general help messag...
[ "The", "entry", "point", "for", "the", "console", "script", "xbmcswift2", "." ]
train
https://github.com/jbeluch/xbmcswift2/blob/0e7a3642499554edc8265fdf1ba6c5ee567daa78/xbmcswift2/cli/cli.py#L40-L76
mozilla/amo-validator
validator/outputhandlers/shellcolors.py
OutputHandler.colorize_text
def colorize_text(self, text): """Adds escape sequences to colorize text and make it beautiful. To colorize text, prefix the text you want to color with the color (capitalized) wrapped in double angle brackets (i.e.: <<GREEN>>). End your string with <<NORMAL>>. If you don't, it w...
python
def colorize_text(self, text): """Adds escape sequences to colorize text and make it beautiful. To colorize text, prefix the text you want to color with the color (capitalized) wrapped in double angle brackets (i.e.: <<GREEN>>). End your string with <<NORMAL>>. If you don't, it w...
[ "def", "colorize_text", "(", "self", ",", "text", ")", ":", "# Take note of where the escape sequences are.", "rnormal", "=", "text", ".", "rfind", "(", "'<<NORMAL'", ")", "rany", "=", "text", ".", "rfind", "(", "'<<'", ")", "# Put in the escape sequences.", "for"...
Adds escape sequences to colorize text and make it beautiful. To colorize text, prefix the text you want to color with the color (capitalized) wrapped in double angle brackets (i.e.: <<GREEN>>). End your string with <<NORMAL>>. If you don't, it will be done for you (assuming you used a c...
[ "Adds", "escape", "sequences", "to", "colorize", "text", "and", "make", "it", "beautiful", ".", "To", "colorize", "text", "prefix", "the", "text", "you", "want", "to", "color", "with", "the", "color", "(", "capitalized", ")", "wrapped", "in", "double", "an...
train
https://github.com/mozilla/amo-validator/blob/0251bfbd7d93106e01ecdb6de5fcd1dc1a180664/validator/outputhandlers/shellcolors.py#L51-L71
mozilla/amo-validator
validator/outputhandlers/shellcolors.py
OutputHandler.write
def write(self, text): 'Uses curses to print in the fanciest way possible.' # Add color to the terminal. if not self.no_color: text = self.colorize_text(text) else: pattern = re.compile('\<\<[A-Z]*?\>\>') text = pattern.sub('', text) text += ...
python
def write(self, text): 'Uses curses to print in the fanciest way possible.' # Add color to the terminal. if not self.no_color: text = self.colorize_text(text) else: pattern = re.compile('\<\<[A-Z]*?\>\>') text = pattern.sub('', text) text += ...
[ "def", "write", "(", "self", ",", "text", ")", ":", "# Add color to the terminal.", "if", "not", "self", ".", "no_color", ":", "text", "=", "self", ".", "colorize_text", "(", "text", ")", "else", ":", "pattern", "=", "re", ".", "compile", "(", "'\\<\\<[A...
Uses curses to print in the fanciest way possible.
[ "Uses", "curses", "to", "print", "in", "the", "fanciest", "way", "possible", "." ]
train
https://github.com/mozilla/amo-validator/blob/0251bfbd7d93106e01ecdb6de5fcd1dc1a180664/validator/outputhandlers/shellcolors.py#L73-L87
orlnub123/cleverbot.py
cleverbot/cleverbot.py
SayMixin.say
def say(self, input=None, **kwargs): """Talk to Cleverbot. Arguments: input: The input argument is what you want to say to Cleverbot, such as "hello". tweak1-3: Changes Cleverbot's mood. **kwargs: Keyword arguments to update the request parameters wit...
python
def say(self, input=None, **kwargs): """Talk to Cleverbot. Arguments: input: The input argument is what you want to say to Cleverbot, such as "hello". tweak1-3: Changes Cleverbot's mood. **kwargs: Keyword arguments to update the request parameters wit...
[ "def", "say", "(", "self", ",", "input", "=", "None", ",", "*", "*", "kwargs", ")", ":", "params", "=", "self", ".", "_get_params", "(", "input", ",", "kwargs", ")", "try", ":", "reply", "=", "self", ".", "session", ".", "get", "(", "self", ".", ...
Talk to Cleverbot. Arguments: input: The input argument is what you want to say to Cleverbot, such as "hello". tweak1-3: Changes Cleverbot's mood. **kwargs: Keyword arguments to update the request parameters with. Returns: Cleverbot's rep...
[ "Talk", "to", "Cleverbot", "." ]
train
https://github.com/orlnub123/cleverbot.py/blob/83aa45fc2582c30d8646372d9e09756525af931f/cleverbot/cleverbot.py#L14-L47
TurboGears/gearbox
gearbox/commands/serve.py
live_pidfile
def live_pidfile(pidfile): # pragma: no cover """(pidfile:str) -> int | None Returns an int found in the named file, if there is one, and if there is a running process with that process id. Return None if no such process exists. """ pid = read_pidfile(pidfile) if pid: try: ...
python
def live_pidfile(pidfile): # pragma: no cover """(pidfile:str) -> int | None Returns an int found in the named file, if there is one, and if there is a running process with that process id. Return None if no such process exists. """ pid = read_pidfile(pidfile) if pid: try: ...
[ "def", "live_pidfile", "(", "pidfile", ")", ":", "# pragma: no cover", "pid", "=", "read_pidfile", "(", "pidfile", ")", "if", "pid", ":", "try", ":", "kill", "(", "int", "(", "pid", ")", ",", "0", ")", "return", "pid", "except", "OSError", "as", "e", ...
(pidfile:str) -> int | None Returns an int found in the named file, if there is one, and if there is a running process with that process id. Return None if no such process exists.
[ "(", "pidfile", ":", "str", ")", "-", ">", "int", "|", "None", "Returns", "an", "int", "found", "in", "the", "named", "file", "if", "there", "is", "one", "and", "if", "there", "is", "a", "running", "process", "with", "that", "process", "id", ".", "...
train
https://github.com/TurboGears/gearbox/blob/df496ab28050ce6a4cc4c502488f5c5812f2baff/gearbox/commands/serve.py#L595-L609
TurboGears/gearbox
gearbox/commands/serve.py
_turn_sigterm_into_systemexit
def _turn_sigterm_into_systemexit(): # pragma: no cover """ Attempts to turn a SIGTERM exception into a SystemExit exception. """ try: import signal except ImportError: return def handle_term(signo, frame): raise SystemExit signal.signal(signal.SIGTERM, handle_term)
python
def _turn_sigterm_into_systemexit(): # pragma: no cover """ Attempts to turn a SIGTERM exception into a SystemExit exception. """ try: import signal except ImportError: return def handle_term(signo, frame): raise SystemExit signal.signal(signal.SIGTERM, handle_term)
[ "def", "_turn_sigterm_into_systemexit", "(", ")", ":", "# pragma: no cover", "try", ":", "import", "signal", "except", "ImportError", ":", "return", "def", "handle_term", "(", "signo", ",", "frame", ")", ":", "raise", "SystemExit", "signal", ".", "signal", "(", ...
Attempts to turn a SIGTERM exception into a SystemExit exception.
[ "Attempts", "to", "turn", "a", "SIGTERM", "exception", "into", "a", "SystemExit", "exception", "." ]
train
https://github.com/TurboGears/gearbox/blob/df496ab28050ce6a4cc4c502488f5c5812f2baff/gearbox/commands/serve.py#L624-L634
TurboGears/gearbox
gearbox/commands/serve.py
wsgiref_server_runner
def wsgiref_server_runner(wsgi_app, global_conf, **kw): # pragma: no cover """ Entry point for wsgiref's WSGI server Additional parameters: ``certfile``, ``keyfile`` Optional SSL certificate file and host key file names. You can generate self-signed test files as follows: ...
python
def wsgiref_server_runner(wsgi_app, global_conf, **kw): # pragma: no cover """ Entry point for wsgiref's WSGI server Additional parameters: ``certfile``, ``keyfile`` Optional SSL certificate file and host key file names. You can generate self-signed test files as follows: ...
[ "def", "wsgiref_server_runner", "(", "wsgi_app", ",", "global_conf", ",", "*", "*", "kw", ")", ":", "# pragma: no cover", "from", "wsgiref", ".", "simple_server", "import", "make_server", ",", "WSGIServer", "host", "=", "kw", ".", "get", "(", "'host'", ",", ...
Entry point for wsgiref's WSGI server Additional parameters: ``certfile``, ``keyfile`` Optional SSL certificate file and host key file names. You can generate self-signed test files as follows: $ openssl genrsa 1024 > keyfile $ chmod 400 keyfile $ openssl ...
[ "Entry", "point", "for", "wsgiref", "s", "WSGI", "server" ]
train
https://github.com/TurboGears/gearbox/blob/df496ab28050ce6a4cc4c502488f5c5812f2baff/gearbox/commands/serve.py#L638-L704
TurboGears/gearbox
gearbox/commands/serve.py
cherrypy_server_runner
def cherrypy_server_runner( app, global_conf=None, host='127.0.0.1', port=None, ssl_pem=None, protocol_version=None, numthreads=None, server_name=None, max=None, request_queue_size=None, timeout=None ): # pragma: no cover """ Entry point for CherryPy's WSGI server Serves the...
python
def cherrypy_server_runner( app, global_conf=None, host='127.0.0.1', port=None, ssl_pem=None, protocol_version=None, numthreads=None, server_name=None, max=None, request_queue_size=None, timeout=None ): # pragma: no cover """ Entry point for CherryPy's WSGI server Serves the...
[ "def", "cherrypy_server_runner", "(", "app", ",", "global_conf", "=", "None", ",", "host", "=", "'127.0.0.1'", ",", "port", "=", "None", ",", "ssl_pem", "=", "None", ",", "protocol_version", "=", "None", ",", "numthreads", "=", "None", ",", "server_name", ...
Entry point for CherryPy's WSGI server Serves the specified WSGI app via CherryPyWSGIServer. ``app`` The WSGI 'application callable'; multiple WSGI applications may be passed as (script_name, callable) pairs. ``host`` This is the ipaddress to bind to (or a hostname if your ...
[ "Entry", "point", "for", "CherryPy", "s", "WSGI", "server" ]
train
https://github.com/TurboGears/gearbox/blob/df496ab28050ce6a4cc4c502488f5c5812f2baff/gearbox/commands/serve.py#L729-L840
TurboGears/gearbox
gearbox/commands/serve.py
ServeCommand.parse_vars
def parse_vars(self, args): """ Given variables like ``['a=b', 'c=d']`` turns it into ``{'a': 'b', 'c': 'd'}`` """ result = {} for arg in args: if '=' not in arg: raise ValueError( 'Variable assignment %r invalid (no "=")' ...
python
def parse_vars(self, args): """ Given variables like ``['a=b', 'c=d']`` turns it into ``{'a': 'b', 'c': 'd'}`` """ result = {} for arg in args: if '=' not in arg: raise ValueError( 'Variable assignment %r invalid (no "=")' ...
[ "def", "parse_vars", "(", "self", ",", "args", ")", ":", "result", "=", "{", "}", "for", "arg", "in", "args", ":", "if", "'='", "not", "in", "arg", ":", "raise", "ValueError", "(", "'Variable assignment %r invalid (no \"=\")'", "%", "arg", ")", "name", "...
Given variables like ``['a=b', 'c=d']`` turns it into ``{'a': 'b', 'c': 'd'}``
[ "Given", "variables", "like", "[", "a", "=", "b", "c", "=", "d", "]", "turns", "it", "into", "{", "a", ":", "b", "c", ":", "d", "}" ]
train
https://github.com/TurboGears/gearbox/blob/df496ab28050ce6a4cc4c502488f5c5812f2baff/gearbox/commands/serve.py#L313-L326
TurboGears/gearbox
gearbox/commands/serve.py
ServeCommand.get_fixed_argv
def get_fixed_argv(self): # pragma: no cover """Get proper arguments for re-running the command. This is primarily for fixing some issues under Windows. First, there was a bug in Windows when running an executable located at a path with a space in it. This has become a non-iss...
python
def get_fixed_argv(self): # pragma: no cover """Get proper arguments for re-running the command. This is primarily for fixing some issues under Windows. First, there was a bug in Windows when running an executable located at a path with a space in it. This has become a non-iss...
[ "def", "get_fixed_argv", "(", "self", ")", ":", "# pragma: no cover", "argv", "=", "sys", ".", "argv", "[", ":", "]", "if", "sys", ".", "platform", "==", "'win32'", "and", "argv", "[", "0", "]", ".", "endswith", "(", "'.py'", ")", ":", "argv", ".", ...
Get proper arguments for re-running the command. This is primarily for fixing some issues under Windows. First, there was a bug in Windows when running an executable located at a path with a space in it. This has become a non-issue with current versions of Python and Windows, s...
[ "Get", "proper", "arguments", "for", "re", "-", "running", "the", "command", "." ]
train
https://github.com/TurboGears/gearbox/blob/df496ab28050ce6a4cc4c502488f5c5812f2baff/gearbox/commands/serve.py#L328-L348
mozilla/amo-validator
validator/main.py
main
def main(): 'Main function. Handles delegation to other functions.' logging.basicConfig() type_choices = {'any': constants.PACKAGE_ANY, 'extension': constants.PACKAGE_EXTENSION, 'theme': constants.PACKAGE_THEME, 'dictionary': constants.PACKAGE_DI...
python
def main(): 'Main function. Handles delegation to other functions.' logging.basicConfig() type_choices = {'any': constants.PACKAGE_ANY, 'extension': constants.PACKAGE_EXTENSION, 'theme': constants.PACKAGE_THEME, 'dictionary': constants.PACKAGE_DI...
[ "def", "main", "(", ")", ":", "logging", ".", "basicConfig", "(", ")", "type_choices", "=", "{", "'any'", ":", "constants", ".", "PACKAGE_ANY", ",", "'extension'", ":", "constants", ".", "PACKAGE_EXTENSION", ",", "'theme'", ":", "constants", ".", "PACKAGE_TH...
Main function. Handles delegation to other functions.
[ "Main", "function", ".", "Handles", "delegation", "to", "other", "functions", "." ]
train
https://github.com/mozilla/amo-validator/blob/0251bfbd7d93106e01ecdb6de5fcd1dc1a180664/validator/main.py#L10-L143
mozilla/amo-validator
validator/xpi.py
XPIManager.package_contents
def package_contents(self): 'Returns a dictionary of file information' if self.contents_cache: return self.contents_cache # Get a list of ZipInfo objects. files = self.zf.infolist() out_files = {} # Iterate through each file in the XPI. for file_ in...
python
def package_contents(self): 'Returns a dictionary of file information' if self.contents_cache: return self.contents_cache # Get a list of ZipInfo objects. files = self.zf.infolist() out_files = {} # Iterate through each file in the XPI. for file_ in...
[ "def", "package_contents", "(", "self", ")", ":", "if", "self", ".", "contents_cache", ":", "return", "self", ".", "contents_cache", "# Get a list of ZipInfo objects.", "files", "=", "self", ".", "zf", ".", "infolist", "(", ")", "out_files", "=", "{", "}", "...
Returns a dictionary of file information
[ "Returns", "a", "dictionary", "of", "file", "information" ]
train
https://github.com/mozilla/amo-validator/blob/0251bfbd7d93106e01ecdb6de5fcd1dc1a180664/validator/xpi.py#L40-L62
mozilla/amo-validator
validator/xpi.py
XPIManager.write
def write(self, name, data): """Write a blob of data to the XPI manager.""" if isinstance(data, StringIO): self.zf.writestr(name, data.getvalue()) else: self.zf.writestr(name, to_utf8(data))
python
def write(self, name, data): """Write a blob of data to the XPI manager.""" if isinstance(data, StringIO): self.zf.writestr(name, data.getvalue()) else: self.zf.writestr(name, to_utf8(data))
[ "def", "write", "(", "self", ",", "name", ",", "data", ")", ":", "if", "isinstance", "(", "data", ",", "StringIO", ")", ":", "self", ".", "zf", ".", "writestr", "(", "name", ",", "data", ".", "getvalue", "(", ")", ")", "else", ":", "self", ".", ...
Write a blob of data to the XPI manager.
[ "Write", "a", "blob", "of", "data", "to", "the", "XPI", "manager", "." ]
train
https://github.com/mozilla/amo-validator/blob/0251bfbd7d93106e01ecdb6de5fcd1dc1a180664/validator/xpi.py#L70-L75
mozilla/amo-validator
validator/xpi.py
XPIManager.write_file
def write_file(self, name, path=None): """Write the contents of a file from the disk to the XPI.""" if path is None: path = name self.zf.write(path, name)
python
def write_file(self, name, path=None): """Write the contents of a file from the disk to the XPI.""" if path is None: path = name self.zf.write(path, name)
[ "def", "write_file", "(", "self", ",", "name", ",", "path", "=", "None", ")", ":", "if", "path", "is", "None", ":", "path", "=", "name", "self", ".", "zf", ".", "write", "(", "path", ",", "name", ")" ]
Write the contents of a file from the disk to the XPI.
[ "Write", "the", "contents", "of", "a", "file", "from", "the", "disk", "to", "the", "XPI", "." ]
train
https://github.com/mozilla/amo-validator/blob/0251bfbd7d93106e01ecdb6de5fcd1dc1a180664/validator/xpi.py#L77-L83
jbeluch/xbmcswift2
xbmcswift2/common.py
xbmc_url
def xbmc_url(url, **options): '''Appends key/val pairs to the end of a URL. Useful for passing arbitrary HTTP headers to XBMC to be used when fetching a media resource, e.g. cookies. ''' optionstring = urllib.urlencode(options) if optionstring: return url + '|' + optionstring return ...
python
def xbmc_url(url, **options): '''Appends key/val pairs to the end of a URL. Useful for passing arbitrary HTTP headers to XBMC to be used when fetching a media resource, e.g. cookies. ''' optionstring = urllib.urlencode(options) if optionstring: return url + '|' + optionstring return ...
[ "def", "xbmc_url", "(", "url", ",", "*", "*", "options", ")", ":", "optionstring", "=", "urllib", ".", "urlencode", "(", "options", ")", "if", "optionstring", ":", "return", "url", "+", "'|'", "+", "optionstring", "return", "url" ]
Appends key/val pairs to the end of a URL. Useful for passing arbitrary HTTP headers to XBMC to be used when fetching a media resource, e.g. cookies.
[ "Appends", "key", "/", "val", "pairs", "to", "the", "end", "of", "a", "URL", ".", "Useful", "for", "passing", "arbitrary", "HTTP", "headers", "to", "XBMC", "to", "be", "used", "when", "fetching", "a", "media", "resource", "e", ".", "g", ".", "cookies",...
train
https://github.com/jbeluch/xbmcswift2/blob/0e7a3642499554edc8265fdf1ba6c5ee567daa78/xbmcswift2/common.py#L18-L26
jbeluch/xbmcswift2
xbmcswift2/common.py
enum
def enum(*args, **kwargs): '''An enum class to mirror XBMC constatns. All args and kwargs.keys are added as atrrs on the returned object. >>> States = enum('NEW_JERSEY', NY='NEW_YORK') >>> States.NY 'NEW_YORK' >>> States.NEW_JERSEY 'NEW_JERSEY' >>> States._fields ['NY', 'NEW_JERSEY'...
python
def enum(*args, **kwargs): '''An enum class to mirror XBMC constatns. All args and kwargs.keys are added as atrrs on the returned object. >>> States = enum('NEW_JERSEY', NY='NEW_YORK') >>> States.NY 'NEW_YORK' >>> States.NEW_JERSEY 'NEW_JERSEY' >>> States._fields ['NY', 'NEW_JERSEY'...
[ "def", "enum", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "update", "(", "(", "arg", ",", "arg", ")", "for", "arg", "in", "args", ")", "kwargs", "[", "'_fields'", "]", "=", "kwargs", ".", "keys", "(", ")", "return", "ty...
An enum class to mirror XBMC constatns. All args and kwargs.keys are added as atrrs on the returned object. >>> States = enum('NEW_JERSEY', NY='NEW_YORK') >>> States.NY 'NEW_YORK' >>> States.NEW_JERSEY 'NEW_JERSEY' >>> States._fields ['NY', 'NEW_JERSEY']
[ "An", "enum", "class", "to", "mirror", "XBMC", "constatns", ".", "All", "args", "and", "kwargs", ".", "keys", "are", "added", "as", "atrrs", "on", "the", "returned", "object", "." ]
train
https://github.com/jbeluch/xbmcswift2/blob/0e7a3642499554edc8265fdf1ba6c5ee567daa78/xbmcswift2/common.py#L29-L43
jbeluch/xbmcswift2
xbmcswift2/common.py
clean_dict
def clean_dict(dct): '''Returns a dict where items with a None value are removed''' return dict((key, val) for key, val in dct.items() if val is not None)
python
def clean_dict(dct): '''Returns a dict where items with a None value are removed''' return dict((key, val) for key, val in dct.items() if val is not None)
[ "def", "clean_dict", "(", "dct", ")", ":", "return", "dict", "(", "(", "key", ",", "val", ")", "for", "key", ",", "val", "in", "dct", ".", "items", "(", ")", "if", "val", "is", "not", "None", ")" ]
Returns a dict where items with a None value are removed
[ "Returns", "a", "dict", "where", "items", "with", "a", "None", "value", "are", "removed" ]
train
https://github.com/jbeluch/xbmcswift2/blob/0e7a3642499554edc8265fdf1ba6c5ee567daa78/xbmcswift2/common.py#L50-L52
jbeluch/xbmcswift2
xbmcswift2/common.py
pickle_dict
def pickle_dict(items): '''Returns a new dictionary where values which aren't instances of basestring are pickled. Also, a new key '_pickled' contains a comma separated list of keys corresponding to the pickled values. ''' ret = {} pickled_keys = [] for key, val in items.items(): if ...
python
def pickle_dict(items): '''Returns a new dictionary where values which aren't instances of basestring are pickled. Also, a new key '_pickled' contains a comma separated list of keys corresponding to the pickled values. ''' ret = {} pickled_keys = [] for key, val in items.items(): if ...
[ "def", "pickle_dict", "(", "items", ")", ":", "ret", "=", "{", "}", "pickled_keys", "=", "[", "]", "for", "key", ",", "val", "in", "items", ".", "items", "(", ")", ":", "if", "isinstance", "(", "val", ",", "basestring", ")", ":", "ret", "[", "key...
Returns a new dictionary where values which aren't instances of basestring are pickled. Also, a new key '_pickled' contains a comma separated list of keys corresponding to the pickled values.
[ "Returns", "a", "new", "dictionary", "where", "values", "which", "aren", "t", "instances", "of", "basestring", "are", "pickled", ".", "Also", "a", "new", "key", "_pickled", "contains", "a", "comma", "separated", "list", "of", "keys", "corresponding", "to", "...
train
https://github.com/jbeluch/xbmcswift2/blob/0e7a3642499554edc8265fdf1ba6c5ee567daa78/xbmcswift2/common.py#L55-L70
jbeluch/xbmcswift2
xbmcswift2/common.py
unpickle_args
def unpickle_args(items): '''Takes a dict and unpickles values whose keys are found in '_pickled' key. >>> unpickle_args({'_pickled': ['foo']. 'foo': ['I3%0A.']}) {'foo': 3} ''' # Technically there can be more than one _pickled value. At this point # we'll just use the first one pickled...
python
def unpickle_args(items): '''Takes a dict and unpickles values whose keys are found in '_pickled' key. >>> unpickle_args({'_pickled': ['foo']. 'foo': ['I3%0A.']}) {'foo': 3} ''' # Technically there can be more than one _pickled value. At this point # we'll just use the first one pickled...
[ "def", "unpickle_args", "(", "items", ")", ":", "# Technically there can be more than one _pickled value. At this point", "# we'll just use the first one", "pickled", "=", "items", ".", "pop", "(", "'_pickled'", ",", "None", ")", "if", "pickled", "is", "None", ":", "ret...
Takes a dict and unpickles values whose keys are found in '_pickled' key. >>> unpickle_args({'_pickled': ['foo']. 'foo': ['I3%0A.']}) {'foo': 3}
[ "Takes", "a", "dict", "and", "unpickles", "values", "whose", "keys", "are", "found", "in", "_pickled", "key", "." ]
train
https://github.com/jbeluch/xbmcswift2/blob/0e7a3642499554edc8265fdf1ba6c5ee567daa78/xbmcswift2/common.py#L73-L93
jbeluch/xbmcswift2
xbmcswift2/common.py
unpickle_dict
def unpickle_dict(items): '''Returns a dict pickled with pickle_dict''' pickled_keys = items.pop('_pickled', '').split(',') ret = {} for key, val in items.items(): if key in pickled_keys: ret[key] = pickle.loads(val) else: ret[key] = val return ret
python
def unpickle_dict(items): '''Returns a dict pickled with pickle_dict''' pickled_keys = items.pop('_pickled', '').split(',') ret = {} for key, val in items.items(): if key in pickled_keys: ret[key] = pickle.loads(val) else: ret[key] = val return ret
[ "def", "unpickle_dict", "(", "items", ")", ":", "pickled_keys", "=", "items", ".", "pop", "(", "'_pickled'", ",", "''", ")", ".", "split", "(", "','", ")", "ret", "=", "{", "}", "for", "key", ",", "val", "in", "items", ".", "items", "(", ")", ":"...
Returns a dict pickled with pickle_dict
[ "Returns", "a", "dict", "pickled", "with", "pickle_dict" ]
train
https://github.com/jbeluch/xbmcswift2/blob/0e7a3642499554edc8265fdf1ba6c5ee567daa78/xbmcswift2/common.py#L95-L104
jbeluch/xbmcswift2
xbmcswift2/common.py
download_page
def download_page(url, data=None): '''Returns the response for the given url. The optional data argument is passed directly to urlopen.''' conn = urllib2.urlopen(url, data) resp = conn.read() conn.close() return resp
python
def download_page(url, data=None): '''Returns the response for the given url. The optional data argument is passed directly to urlopen.''' conn = urllib2.urlopen(url, data) resp = conn.read() conn.close() return resp
[ "def", "download_page", "(", "url", ",", "data", "=", "None", ")", ":", "conn", "=", "urllib2", ".", "urlopen", "(", "url", ",", "data", ")", "resp", "=", "conn", ".", "read", "(", ")", "conn", ".", "close", "(", ")", "return", "resp" ]
Returns the response for the given url. The optional data argument is passed directly to urlopen.
[ "Returns", "the", "response", "for", "the", "given", "url", ".", "The", "optional", "data", "argument", "is", "passed", "directly", "to", "urlopen", "." ]
train
https://github.com/jbeluch/xbmcswift2/blob/0e7a3642499554edc8265fdf1ba6c5ee567daa78/xbmcswift2/common.py#L107-L113
jbeluch/xbmcswift2
xbmcswift2/common.py
unhex
def unhex(inp): '''unquote(r'abc\x20def') -> 'abc def'.''' res = inp.split(r'\x') for i in xrange(1, len(res)): item = res[i] try: res[i] = _hextochr[item[:2]] + item[2:] except KeyError: res[i] = '%' + item except UnicodeDecodeError: res[i...
python
def unhex(inp): '''unquote(r'abc\x20def') -> 'abc def'.''' res = inp.split(r'\x') for i in xrange(1, len(res)): item = res[i] try: res[i] = _hextochr[item[:2]] + item[2:] except KeyError: res[i] = '%' + item except UnicodeDecodeError: res[i...
[ "def", "unhex", "(", "inp", ")", ":", "res", "=", "inp", ".", "split", "(", "r'\\x'", ")", "for", "i", "in", "xrange", "(", "1", ",", "len", "(", "res", ")", ")", ":", "item", "=", "res", "[", "i", "]", "try", ":", "res", "[", "i", "]", "...
unquote(r'abc\x20def') -> 'abc def'.
[ "unquote", "(", "r", "abc", "\\", "x20def", ")", "-", ">", "abc", "def", "." ]
train
https://github.com/jbeluch/xbmcswift2/blob/0e7a3642499554edc8265fdf1ba6c5ee567daa78/xbmcswift2/common.py#L120-L131
TurboGears/gearbox
gearbox/commandmanager.py
CommandManager.load_commands
def load_commands(self, namespace): """Load all the commands from an entrypoint""" for ep in pkg_resources.iter_entry_points(namespace): LOG.debug('found command %r', ep.name) cmd_name = (ep.name.replace('_', ' ') if self.convert_underscores ...
python
def load_commands(self, namespace): """Load all the commands from an entrypoint""" for ep in pkg_resources.iter_entry_points(namespace): LOG.debug('found command %r', ep.name) cmd_name = (ep.name.replace('_', ' ') if self.convert_underscores ...
[ "def", "load_commands", "(", "self", ",", "namespace", ")", ":", "for", "ep", "in", "pkg_resources", ".", "iter_entry_points", "(", "namespace", ")", ":", "LOG", ".", "debug", "(", "'found command %r'", ",", "ep", ".", "name", ")", "cmd_name", "=", "(", ...
Load all the commands from an entrypoint
[ "Load", "all", "the", "commands", "from", "an", "entrypoint" ]
train
https://github.com/TurboGears/gearbox/blob/df496ab28050ce6a4cc4c502488f5c5812f2baff/gearbox/commandmanager.py#L47-L55
TurboGears/gearbox
gearbox/commandmanager.py
CommandManager.find_command
def find_command(self, argv): """Given an argument list, find a command and return the processor and any remaining arguments. """ search_args = argv[:] name = '' while search_args: if search_args[0].startswith('-'): name = '%s %s' % (name, sear...
python
def find_command(self, argv): """Given an argument list, find a command and return the processor and any remaining arguments. """ search_args = argv[:] name = '' while search_args: if search_args[0].startswith('-'): name = '%s %s' % (name, sear...
[ "def", "find_command", "(", "self", ",", "argv", ")", ":", "search_args", "=", "argv", "[", ":", "]", "name", "=", "''", "while", "search_args", ":", "if", "search_args", "[", "0", "]", ".", "startswith", "(", "'-'", ")", ":", "name", "=", "'%s %s'",...
Given an argument list, find a command and return the processor and any remaining arguments.
[ "Given", "an", "argument", "list", "find", "a", "command", "and", "return", "the", "processor", "and", "any", "remaining", "arguments", "." ]
train
https://github.com/TurboGears/gearbox/blob/df496ab28050ce6a4cc4c502488f5c5812f2baff/gearbox/commandmanager.py#L63-L89
TurboGears/gearbox
gearbox/utils/log.py
setup_logging
def setup_logging(config_uri, fileConfig=fileConfig, configparser=configparser): """ Set up logging via the logging module's fileConfig function with the filename specified via ``config_uri`` (a string in the form ``filename#sectionname``). ConfigParser defaults are specified for ...
python
def setup_logging(config_uri, fileConfig=fileConfig, configparser=configparser): """ Set up logging via the logging module's fileConfig function with the filename specified via ``config_uri`` (a string in the form ``filename#sectionname``). ConfigParser defaults are specified for ...
[ "def", "setup_logging", "(", "config_uri", ",", "fileConfig", "=", "fileConfig", ",", "configparser", "=", "configparser", ")", ":", "path", ",", "_", "=", "_getpathsec", "(", "config_uri", ",", "None", ")", "parser", "=", "configparser", ".", "ConfigParser", ...
Set up logging via the logging module's fileConfig function with the filename specified via ``config_uri`` (a string in the form ``filename#sectionname``). ConfigParser defaults are specified for the special ``__file__`` and ``here`` variables, similar to PasteDeploy config loading.
[ "Set", "up", "logging", "via", "the", "logging", "module", "s", "fileConfig", "function", "with", "the", "filename", "specified", "via", "config_uri", "(", "a", "string", "in", "the", "form", "filename#sectionname", ")", "." ]
train
https://github.com/TurboGears/gearbox/blob/df496ab28050ce6a4cc4c502488f5c5812f2baff/gearbox/utils/log.py#L11-L32
mozilla/amo-validator
validator/submain.py
prepare_package
def prepare_package(err, path, expectation=0, for_appversions=None, timeout=-1): """Prepares a file-based package for validation. timeout is the number of seconds before validation is aborted. If timeout is -1 then no timeout checking code will run. """ package = None try: ...
python
def prepare_package(err, path, expectation=0, for_appversions=None, timeout=-1): """Prepares a file-based package for validation. timeout is the number of seconds before validation is aborted. If timeout is -1 then no timeout checking code will run. """ package = None try: ...
[ "def", "prepare_package", "(", "err", ",", "path", ",", "expectation", "=", "0", ",", "for_appversions", "=", "None", ",", "timeout", "=", "-", "1", ")", ":", "package", "=", "None", "try", ":", "# Test that the package actually exists. I consider this Tier 0", ...
Prepares a file-based package for validation. timeout is the number of seconds before validation is aborted. If timeout is -1 then no timeout checking code will run.
[ "Prepares", "a", "file", "-", "based", "package", "for", "validation", "." ]
train
https://github.com/mozilla/amo-validator/blob/0251bfbd7d93106e01ecdb6de5fcd1dc1a180664/validator/submain.py#L35-L100
mozilla/amo-validator
validator/submain.py
populate_chrome_manifest
def populate_chrome_manifest(err, xpi_package): "Loads the chrome.manifest if it's present" if 'chrome.manifest' in xpi_package: chrome_data = xpi_package.read('chrome.manifest') chrome = ChromeManifest(chrome_data, 'chrome.manifest') chrome_recursion_buster = set() # Handle t...
python
def populate_chrome_manifest(err, xpi_package): "Loads the chrome.manifest if it's present" if 'chrome.manifest' in xpi_package: chrome_data = xpi_package.read('chrome.manifest') chrome = ChromeManifest(chrome_data, 'chrome.manifest') chrome_recursion_buster = set() # Handle t...
[ "def", "populate_chrome_manifest", "(", "err", ",", "xpi_package", ")", ":", "if", "'chrome.manifest'", "in", "xpi_package", ":", "chrome_data", "=", "xpi_package", ".", "read", "(", "'chrome.manifest'", ")", "chrome", "=", "ChromeManifest", "(", "chrome_data", ",...
Loads the chrome.manifest if it's present
[ "Loads", "the", "chrome", ".", "manifest", "if", "it", "s", "present" ]
train
https://github.com/mozilla/amo-validator/blob/0251bfbd7d93106e01ecdb6de5fcd1dc1a180664/validator/submain.py#L279-L354
mozilla/amo-validator
validator/typedetection.py
detect_type
def detect_type(err, install_rdf=None, xpi_package=None): """Determines the type of add-on being validated based on install.rdf, file extension, and other properties.""" # The types in the install.rdf don't pair up 1:1 with the type # system that we're using for expectations and the like. This is #...
python
def detect_type(err, install_rdf=None, xpi_package=None): """Determines the type of add-on being validated based on install.rdf, file extension, and other properties.""" # The types in the install.rdf don't pair up 1:1 with the type # system that we're using for expectations and the like. This is #...
[ "def", "detect_type", "(", "err", ",", "install_rdf", "=", "None", ",", "xpi_package", "=", "None", ")", ":", "# The types in the install.rdf don't pair up 1:1 with the type", "# system that we're using for expectations and the like. This is", "# to help translate between the two.", ...
Determines the type of add-on being validated based on install.rdf, file extension, and other properties.
[ "Determines", "the", "type", "of", "add", "-", "on", "being", "validated", "based", "on", "install", ".", "rdf", "file", "extension", "and", "other", "properties", "." ]
train
https://github.com/mozilla/amo-validator/blob/0251bfbd7d93106e01ecdb6de5fcd1dc1a180664/validator/typedetection.py#L4-L99
mozilla/amo-validator
validator/opensearch.py
detect_opensearch
def detect_opensearch(err, package, listed=False): 'Detect, parse, and validate an OpenSearch provider' # Parse the file. try: # Check if it is a file object. if hasattr(package, 'read'): srch_prov = parse(package) else: # It's not a file object; open it (the...
python
def detect_opensearch(err, package, listed=False): 'Detect, parse, and validate an OpenSearch provider' # Parse the file. try: # Check if it is a file object. if hasattr(package, 'read'): srch_prov = parse(package) else: # It's not a file object; open it (the...
[ "def", "detect_opensearch", "(", "err", ",", "package", ",", "listed", "=", "False", ")", ":", "# Parse the file.", "try", ":", "# Check if it is a file object.", "if", "hasattr", "(", "package", ",", "'read'", ")", ":", "srch_prov", "=", "parse", "(", "packag...
Detect, parse, and validate an OpenSearch provider
[ "Detect", "parse", "and", "validate", "an", "OpenSearch", "provider" ]
train
https://github.com/mozilla/amo-validator/blob/0251bfbd7d93106e01ecdb6de5fcd1dc1a180664/validator/opensearch.py#L9-L218
TurboGears/gearbox
gearbox/utils/copydir.py
copy_dir
def copy_dir(source, dest, vars, verbosity=1, simulate=False, indent=0, sub_vars=True, interactive=False, overwrite=True, template_renderer=None, out_=sys.stdout): """ Copies the ``source`` directory to the ``dest`` directory. ``vars``: A dictionary of variables to use in any subs...
python
def copy_dir(source, dest, vars, verbosity=1, simulate=False, indent=0, sub_vars=True, interactive=False, overwrite=True, template_renderer=None, out_=sys.stdout): """ Copies the ``source`` directory to the ``dest`` directory. ``vars``: A dictionary of variables to use in any subs...
[ "def", "copy_dir", "(", "source", ",", "dest", ",", "vars", ",", "verbosity", "=", "1", ",", "simulate", "=", "False", ",", "indent", "=", "0", ",", "sub_vars", "=", "True", ",", "interactive", "=", "False", ",", "overwrite", "=", "True", ",", "templ...
Copies the ``source`` directory to the ``dest`` directory. ``vars``: A dictionary of variables to use in any substitutions. ``verbosity``: Higher numbers will show more about what is happening. ``simulate``: If true, then don't actually *do* anything. ``indent``: Indent any messages by this amount. ...
[ "Copies", "the", "source", "directory", "to", "the", "dest", "directory", "." ]
train
https://github.com/TurboGears/gearbox/blob/df496ab28050ce6a4cc4c502488f5c5812f2baff/gearbox/utils/copydir.py#L32-L156
TurboGears/gearbox
gearbox/utils/copydir.py
should_skip_file
def should_skip_file(name): """ Checks if a file should be skipped based on its name. If it should be skipped, returns the reason, otherwise returns None. """ if name.startswith('.'): return 'Skipping hidden file %(filename)s' if name.endswith('~') or name.endswith('.bak'): ...
python
def should_skip_file(name): """ Checks if a file should be skipped based on its name. If it should be skipped, returns the reason, otherwise returns None. """ if name.startswith('.'): return 'Skipping hidden file %(filename)s' if name.endswith('~') or name.endswith('.bak'): ...
[ "def", "should_skip_file", "(", "name", ")", ":", "if", "name", ".", "startswith", "(", "'.'", ")", ":", "return", "'Skipping hidden file %(filename)s'", "if", "name", ".", "endswith", "(", "'~'", ")", "or", "name", ".", "endswith", "(", "'.bak'", ")", ":"...
Checks if a file should be skipped based on its name. If it should be skipped, returns the reason, otherwise returns None.
[ "Checks", "if", "a", "file", "should", "be", "skipped", "based", "on", "its", "name", "." ]
train
https://github.com/TurboGears/gearbox/blob/df496ab28050ce6a4cc4c502488f5c5812f2baff/gearbox/utils/copydir.py#L182-L199
jbeluch/xbmcswift2
xbmcswift2/cli/app.py
setup_options
def setup_options(opts): '''Takes any actions necessary based on command line options''' if opts.quiet: logger.log.setLevel(logging.WARNING) logger.GLOBAL_LOG_LEVEL = logging.WARNING if opts.verbose: logger.log.setLevel(logging.DEBUG) logger.GLOBAL_LOG_LEVEL = logging.DEBUG
python
def setup_options(opts): '''Takes any actions necessary based on command line options''' if opts.quiet: logger.log.setLevel(logging.WARNING) logger.GLOBAL_LOG_LEVEL = logging.WARNING if opts.verbose: logger.log.setLevel(logging.DEBUG) logger.GLOBAL_LOG_LEVEL = logging.DEBUG
[ "def", "setup_options", "(", "opts", ")", ":", "if", "opts", ".", "quiet", ":", "logger", ".", "log", ".", "setLevel", "(", "logging", ".", "WARNING", ")", "logger", ".", "GLOBAL_LOG_LEVEL", "=", "logging", ".", "WARNING", "if", "opts", ".", "verbose", ...
Takes any actions necessary based on command line options
[ "Takes", "any", "actions", "necessary", "based", "on", "command", "line", "options" ]
train
https://github.com/jbeluch/xbmcswift2/blob/0e7a3642499554edc8265fdf1ba6c5ee567daa78/xbmcswift2/cli/app.py#L55-L63
jbeluch/xbmcswift2
xbmcswift2/cli/app.py
get_addon_module_name
def get_addon_module_name(addonxml_filename): '''Attempts to extract a module name for the given addon's addon.xml file. Looks for the 'xbmc.python.pluginsource' extension node and returns the addon's filename without the .py suffix. ''' try: xml = ET.parse(addonxml_filename).getroot() e...
python
def get_addon_module_name(addonxml_filename): '''Attempts to extract a module name for the given addon's addon.xml file. Looks for the 'xbmc.python.pluginsource' extension node and returns the addon's filename without the .py suffix. ''' try: xml = ET.parse(addonxml_filename).getroot() e...
[ "def", "get_addon_module_name", "(", "addonxml_filename", ")", ":", "try", ":", "xml", "=", "ET", ".", "parse", "(", "addonxml_filename", ")", ".", "getroot", "(", ")", "except", "IOError", ":", "sys", ".", "exit", "(", "'Cannot find an addon.xml file in the cur...
Attempts to extract a module name for the given addon's addon.xml file. Looks for the 'xbmc.python.pluginsource' extension node and returns the addon's filename without the .py suffix.
[ "Attempts", "to", "extract", "a", "module", "name", "for", "the", "given", "addon", "s", "addon", ".", "xml", "file", ".", "Looks", "for", "the", "xbmc", ".", "python", ".", "pluginsource", "extension", "node", "and", "returns", "the", "addon", "s", "fil...
train
https://github.com/jbeluch/xbmcswift2/blob/0e7a3642499554edc8265fdf1ba6c5ee567daa78/xbmcswift2/cli/app.py#L66-L84
jbeluch/xbmcswift2
xbmcswift2/cli/app.py
patch_plugin
def patch_plugin(plugin, path, handle=None): '''Patches a few attributes of a plugin instance to enable a new call to plugin.run() ''' if handle is None: handle = plugin.request.handle patch_sysargv(path, handle) plugin._end_of_directory = False
python
def patch_plugin(plugin, path, handle=None): '''Patches a few attributes of a plugin instance to enable a new call to plugin.run() ''' if handle is None: handle = plugin.request.handle patch_sysargv(path, handle) plugin._end_of_directory = False
[ "def", "patch_plugin", "(", "plugin", ",", "path", ",", "handle", "=", "None", ")", ":", "if", "handle", "is", "None", ":", "handle", "=", "plugin", ".", "request", ".", "handle", "patch_sysargv", "(", "path", ",", "handle", ")", "plugin", ".", "_end_o...
Patches a few attributes of a plugin instance to enable a new call to plugin.run()
[ "Patches", "a", "few", "attributes", "of", "a", "plugin", "instance", "to", "enable", "a", "new", "call", "to", "plugin", ".", "run", "()" ]
train
https://github.com/jbeluch/xbmcswift2/blob/0e7a3642499554edc8265fdf1ba6c5ee567daa78/xbmcswift2/cli/app.py#L137-L144
jbeluch/xbmcswift2
xbmcswift2/cli/app.py
once
def once(plugin, parent_stack=None): '''A run mode for the CLI that runs the plugin once and exits.''' plugin.clear_added_items() items = plugin.run() # if update_listing=True, we need to remove the last url from the parent # stack if parent_stack and plugin._update_listing: del parent_...
python
def once(plugin, parent_stack=None): '''A run mode for the CLI that runs the plugin once and exits.''' plugin.clear_added_items() items = plugin.run() # if update_listing=True, we need to remove the last url from the parent # stack if parent_stack and plugin._update_listing: del parent_...
[ "def", "once", "(", "plugin", ",", "parent_stack", "=", "None", ")", ":", "plugin", ".", "clear_added_items", "(", ")", "items", "=", "plugin", ".", "run", "(", ")", "# if update_listing=True, we need to remove the last url from the parent", "# stack", "if", "parent...
A run mode for the CLI that runs the plugin once and exits.
[ "A", "run", "mode", "for", "the", "CLI", "that", "runs", "the", "plugin", "once", "and", "exits", "." ]
train
https://github.com/jbeluch/xbmcswift2/blob/0e7a3642499554edc8265fdf1ba6c5ee567daa78/xbmcswift2/cli/app.py#L147-L162
jbeluch/xbmcswift2
xbmcswift2/cli/app.py
interactive
def interactive(plugin): '''A run mode for the CLI that runs the plugin in a loop based on user input. ''' items = [item for item in once(plugin) if not item.get_played()] parent_stack = [] # Keep track of parents so we can have a '..' option selected_item = get_user_choice(items) while se...
python
def interactive(plugin): '''A run mode for the CLI that runs the plugin in a loop based on user input. ''' items = [item for item in once(plugin) if not item.get_played()] parent_stack = [] # Keep track of parents so we can have a '..' option selected_item = get_user_choice(items) while se...
[ "def", "interactive", "(", "plugin", ")", ":", "items", "=", "[", "item", "for", "item", "in", "once", "(", "plugin", ")", "if", "not", "item", ".", "get_played", "(", ")", "]", "parent_stack", "=", "[", "]", "# Keep track of parents so we can have a '..' op...
A run mode for the CLI that runs the plugin in a loop based on user input.
[ "A", "run", "mode", "for", "the", "CLI", "that", "runs", "the", "plugin", "in", "a", "loop", "based", "on", "user", "input", "." ]
train
https://github.com/jbeluch/xbmcswift2/blob/0e7a3642499554edc8265fdf1ba6c5ee567daa78/xbmcswift2/cli/app.py#L165-L185
jbeluch/xbmcswift2
xbmcswift2/cli/app.py
crawl
def crawl(plugin): '''Performs a breadth-first crawl of all possible routes from the starting path. Will only visit a URL once, even if it is referenced multiple times in a plugin. Requires user interaction in between each fetch. ''' # TODO: use OrderedSet? paths_visited = set() paths_to...
python
def crawl(plugin): '''Performs a breadth-first crawl of all possible routes from the starting path. Will only visit a URL once, even if it is referenced multiple times in a plugin. Requires user interaction in between each fetch. ''' # TODO: use OrderedSet? paths_visited = set() paths_to...
[ "def", "crawl", "(", "plugin", ")", ":", "# TODO: use OrderedSet?", "paths_visited", "=", "set", "(", ")", "paths_to_visit", "=", "set", "(", "item", ".", "get_path", "(", ")", "for", "item", "in", "once", "(", "plugin", ")", ")", "while", "paths_to_visit"...
Performs a breadth-first crawl of all possible routes from the starting path. Will only visit a URL once, even if it is referenced multiple times in a plugin. Requires user interaction in between each fetch.
[ "Performs", "a", "breadth", "-", "first", "crawl", "of", "all", "possible", "routes", "from", "the", "starting", "path", ".", "Will", "only", "visit", "a", "URL", "once", "even", "if", "it", "is", "referenced", "multiple", "times", "in", "a", "plugin", "...
train
https://github.com/jbeluch/xbmcswift2/blob/0e7a3642499554edc8265fdf1ba6c5ee567daa78/xbmcswift2/cli/app.py#L188-L209
jbeluch/xbmcswift2
xbmcswift2/cli/app.py
RunCommand.run
def run(opts, args): '''The run method for the 'run' command. Executes a plugin from the command line. ''' setup_options(opts) mode = Modes.ONCE if len(args) > 0 and hasattr(Modes, args[0].upper()): _mode = args.pop(0).upper() mode = getattr(Modes...
python
def run(opts, args): '''The run method for the 'run' command. Executes a plugin from the command line. ''' setup_options(opts) mode = Modes.ONCE if len(args) > 0 and hasattr(Modes, args[0].upper()): _mode = args.pop(0).upper() mode = getattr(Modes...
[ "def", "run", "(", "opts", ",", "args", ")", ":", "setup_options", "(", "opts", ")", "mode", "=", "Modes", ".", "ONCE", "if", "len", "(", "args", ")", ">", "0", "and", "hasattr", "(", "Modes", ",", "args", "[", "0", "]", ".", "upper", "(", ")",...
The run method for the 'run' command. Executes a plugin from the command line.
[ "The", "run", "method", "for", "the", "run", "command", ".", "Executes", "a", "plugin", "from", "the", "command", "line", "." ]
train
https://github.com/jbeluch/xbmcswift2/blob/0e7a3642499554edc8265fdf1ba6c5ee567daa78/xbmcswift2/cli/app.py#L35-L52
jbeluch/xbmcswift2
xbmcswift2/cli/app.py
PluginManager.load_plugin_from_addonxml
def load_plugin_from_addonxml(cls, mode, url): '''Attempts to import a plugin's source code and find an instance of :class:`~xbmcswif2.Plugin`. Returns an instance of PluginManager if succesful. ''' cwd = os.getcwd() sys.path.insert(0, cwd) module_name = get_addon...
python
def load_plugin_from_addonxml(cls, mode, url): '''Attempts to import a plugin's source code and find an instance of :class:`~xbmcswif2.Plugin`. Returns an instance of PluginManager if succesful. ''' cwd = os.getcwd() sys.path.insert(0, cwd) module_name = get_addon...
[ "def", "load_plugin_from_addonxml", "(", "cls", ",", "mode", ",", "url", ")", ":", "cwd", "=", "os", ".", "getcwd", "(", ")", "sys", ".", "path", ".", "insert", "(", "0", ",", "cwd", ")", "module_name", "=", "get_addon_module_name", "(", "os", ".", "...
Attempts to import a plugin's source code and find an instance of :class:`~xbmcswif2.Plugin`. Returns an instance of PluginManager if succesful.
[ "Attempts", "to", "import", "a", "plugin", "s", "source", "code", "and", "find", "an", "instance", "of", ":", "class", ":", "~xbmcswif2", ".", "Plugin", ".", "Returns", "an", "instance", "of", "PluginManager", "if", "succesful", "." ]
train
https://github.com/jbeluch/xbmcswift2/blob/0e7a3642499554edc8265fdf1ba6c5ee567daa78/xbmcswift2/cli/app.py#L93-L110
jbeluch/xbmcswift2
xbmcswift2/cli/app.py
PluginManager.run
def run(self): '''This method runs the the plugin in the appropriate mode parsed from the command line options. ''' handle = 0 handlers = { Modes.ONCE: once, Modes.CRAWL: crawl, Modes.INTERACTIVE: interactive, } handler = handlers[...
python
def run(self): '''This method runs the the plugin in the appropriate mode parsed from the command line options. ''' handle = 0 handlers = { Modes.ONCE: once, Modes.CRAWL: crawl, Modes.INTERACTIVE: interactive, } handler = handlers[...
[ "def", "run", "(", "self", ")", ":", "handle", "=", "0", "handlers", "=", "{", "Modes", ".", "ONCE", ":", "once", ",", "Modes", ".", "CRAWL", ":", "crawl", ",", "Modes", ".", "INTERACTIVE", ":", "interactive", ",", "}", "handler", "=", "handlers", ...
This method runs the the plugin in the appropriate mode parsed from the command line options.
[ "This", "method", "runs", "the", "the", "plugin", "in", "the", "appropriate", "mode", "parsed", "from", "the", "command", "line", "options", "." ]
train
https://github.com/jbeluch/xbmcswift2/blob/0e7a3642499554edc8265fdf1ba6c5ee567daa78/xbmcswift2/cli/app.py#L117-L129
TurboGears/gearbox
gearbox/commands/setup_app.py
SetupAppCommand._setup_config
def _setup_config(self, dist, filename, section, vars, verbosity): """ Called to setup an application, given its configuration file/directory. The default implementation calls ``package.websetup.setup_config(command, filename, section, vars)`` or ``package.websetup.setup...
python
def _setup_config(self, dist, filename, section, vars, verbosity): """ Called to setup an application, given its configuration file/directory. The default implementation calls ``package.websetup.setup_config(command, filename, section, vars)`` or ``package.websetup.setup...
[ "def", "_setup_config", "(", "self", ",", "dist", ",", "filename", ",", "section", ",", "vars", ",", "verbosity", ")", ":", "modules", "=", "[", "line", ".", "strip", "(", ")", "for", "line", "in", "dist", ".", "get_metadata_lines", "(", "'top_level.txt'...
Called to setup an application, given its configuration file/directory. The default implementation calls ``package.websetup.setup_config(command, filename, section, vars)`` or ``package.websetup.setup_app(command, config, vars)`` With ``setup_app`` the ``config`` object...
[ "Called", "to", "setup", "an", "application", "given", "its", "configuration", "file", "/", "directory", "." ]
train
https://github.com/TurboGears/gearbox/blob/df496ab28050ce6a4cc4c502488f5c5812f2baff/gearbox/commands/setup_app.py#L55-L99
TurboGears/gearbox
gearbox/commands/setup_app.py
SetupAppCommand._import_module
def _import_module(self, s): """ Import a module. """ mod = __import__(s) parts = s.split('.') for part in parts[1:]: mod = getattr(mod, part) return mod
python
def _import_module(self, s): """ Import a module. """ mod = __import__(s) parts = s.split('.') for part in parts[1:]: mod = getattr(mod, part) return mod
[ "def", "_import_module", "(", "self", ",", "s", ")", ":", "mod", "=", "__import__", "(", "s", ")", "parts", "=", "s", ".", "split", "(", "'.'", ")", "for", "part", "in", "parts", "[", "1", ":", "]", ":", "mod", "=", "getattr", "(", "mod", ",", ...
Import a module.
[ "Import", "a", "module", "." ]
train
https://github.com/TurboGears/gearbox/blob/df496ab28050ce6a4cc4c502488f5c5812f2baff/gearbox/commands/setup_app.py#L110-L118
orlnub123/cleverbot.py
cleverbot/async_/cleverbot.py
SayMixin.say
def say(self, input=None, **kwargs): """Talk to Cleverbot. Arguments: input: The input argument is what you want to say to Cleverbot, such as "hello". tweak1-3: Changes Cleverbot's mood. **kwargs: Keyword arguments to update the request parameters wit...
python
def say(self, input=None, **kwargs): """Talk to Cleverbot. Arguments: input: The input argument is what you want to say to Cleverbot, such as "hello". tweak1-3: Changes Cleverbot's mood. **kwargs: Keyword arguments to update the request parameters wit...
[ "def", "say", "(", "self", ",", "input", "=", "None", ",", "*", "*", "kwargs", ")", ":", "params", "=", "self", ".", "_get_params", "(", "input", ",", "kwargs", ")", "try", ":", "reply", "=", "yield", "from", "self", ".", "session", ".", "get", "...
Talk to Cleverbot. Arguments: input: The input argument is what you want to say to Cleverbot, such as "hello". tweak1-3: Changes Cleverbot's mood. **kwargs: Keyword arguments to update the request parameters with. Returns: Cleverbot's rep...
[ "Talk", "to", "Cleverbot", "." ]
train
https://github.com/orlnub123/cleverbot.py/blob/83aa45fc2582c30d8646372d9e09756525af931f/cleverbot/async_/cleverbot.py#L16-L49
orlnub123/cleverbot.py
cleverbot/async_/cleverbot.py
Cleverbot.conversation
def conversation(self, name=None, **kwargs): """Make a new conversation. Arguments: name: The key for the dictionary the conversation will be stored as in conversations. If None the conversation will be stored as a list instead. Mixing both types results in a...
python
def conversation(self, name=None, **kwargs): """Make a new conversation. Arguments: name: The key for the dictionary the conversation will be stored as in conversations. If None the conversation will be stored as a list instead. Mixing both types results in a...
[ "def", "conversation", "(", "self", ",", "name", "=", "None", ",", "*", "*", "kwargs", ")", ":", "convo", "=", "Conversation", "(", "self", ",", "*", "*", "kwargs", ")", "super", "(", ")", ".", "conversation", "(", "name", ",", "convo", ")", "retur...
Make a new conversation. Arguments: name: The key for the dictionary the conversation will be stored as in conversations. If None the conversation will be stored as a list instead. Mixing both types results in an error. **kwargs: Keyword arguments to pass...
[ "Make", "a", "new", "conversation", "." ]
train
https://github.com/orlnub123/cleverbot.py/blob/83aa45fc2582c30d8646372d9e09756525af931f/cleverbot/async_/cleverbot.py#L73-L88
mozilla/amo-validator
validator/validate.py
validate
def validate(path, format='json', approved_applications=None, determined=True, listed=True, expectation=PACKAGE_ANY, for_appversions=None, overrides=None, timeout=-1, compat_test=False, **kw): """ ...
python
def validate(path, format='json', approved_applications=None, determined=True, listed=True, expectation=PACKAGE_ANY, for_appversions=None, overrides=None, timeout=-1, compat_test=False, **kw): """ ...
[ "def", "validate", "(", "path", ",", "format", "=", "'json'", ",", "approved_applications", "=", "None", ",", "determined", "=", "True", ",", "listed", "=", "True", ",", "expectation", "=", "PACKAGE_ANY", ",", "for_appversions", "=", "None", ",", "overrides"...
Perform validation in one easy step! `path`: *Required* A file system path to the package to be validated. `format`: The format to return the results in. Defaults to "json". Currently, any other format will simply return the error bundle. `approved_applications`: Pat...
[ "Perform", "validation", "in", "one", "easy", "step!" ]
train
https://github.com/mozilla/amo-validator/blob/0251bfbd7d93106e01ecdb6de5fcd1dc1a180664/validator/validate.py#L14-L83
mozilla/amo-validator
validator/errorbundler.py
ErrorBundle.system_error
def system_error(self, msg_id=None, message=None, description=None, validation_timeout=False, exc_info=None, **kw): """Add an error message for an unexpected exception in validator code, and move it to the front of the error message list. If `exc_info` is supplied, the error...
python
def system_error(self, msg_id=None, message=None, description=None, validation_timeout=False, exc_info=None, **kw): """Add an error message for an unexpected exception in validator code, and move it to the front of the error message list. If `exc_info` is supplied, the error...
[ "def", "system_error", "(", "self", ",", "msg_id", "=", "None", ",", "message", "=", "None", ",", "description", "=", "None", ",", "validation_timeout", "=", "False", ",", "exc_info", "=", "None", ",", "*", "*", "kw", ")", ":", "if", "exc_info", ":", ...
Add an error message for an unexpected exception in validator code, and move it to the front of the error message list. If `exc_info` is supplied, the error will be logged. If the error is a validation timeout, it is re-raised unless `msg_id` is "validation_timeout".
[ "Add", "an", "error", "message", "for", "an", "unexpected", "exception", "in", "validator", "code", "and", "move", "it", "to", "the", "front", "of", "the", "error", "message", "list", ".", "If", "exc_info", "is", "supplied", "the", "error", "will", "be", ...
train
https://github.com/mozilla/amo-validator/blob/0251bfbd7d93106e01ecdb6de5fcd1dc1a180664/validator/errorbundler.py#L124-L159
mozilla/amo-validator
validator/errorbundler.py
ErrorBundle.drop_message
def drop_message(self, message): """Drop the given message object from the appropriate message list. Returns True if the message was found, otherwise False.""" for type_ in 'errors', 'warnings', 'notices': list_ = getattr(self, type_) if message in list_: ...
python
def drop_message(self, message): """Drop the given message object from the appropriate message list. Returns True if the message was found, otherwise False.""" for type_ in 'errors', 'warnings', 'notices': list_ = getattr(self, type_) if message in list_: ...
[ "def", "drop_message", "(", "self", ",", "message", ")", ":", "for", "type_", "in", "'errors'", ",", "'warnings'", ",", "'notices'", ":", "list_", "=", "getattr", "(", "self", ",", "type_", ")", "if", "message", "in", "list_", ":", "list_", ".", "remov...
Drop the given message object from the appropriate message list. Returns True if the message was found, otherwise False.
[ "Drop", "the", "given", "message", "object", "from", "the", "appropriate", "message", "list", "." ]
train
https://github.com/mozilla/amo-validator/blob/0251bfbd7d93106e01ecdb6de5fcd1dc1a180664/validator/errorbundler.py#L161-L174
mozilla/amo-validator
validator/errorbundler.py
ErrorBundle.set_tier
def set_tier(self, tier): 'Updates the tier and ending tier' self.tier = tier if tier > self.ending_tier: self.ending_tier = tier
python
def set_tier(self, tier): 'Updates the tier and ending tier' self.tier = tier if tier > self.ending_tier: self.ending_tier = tier
[ "def", "set_tier", "(", "self", ",", "tier", ")", ":", "self", ".", "tier", "=", "tier", "if", "tier", ">", "self", ".", "ending_tier", ":", "self", ".", "ending_tier", "=", "tier" ]
Updates the tier and ending tier
[ "Updates", "the", "tier", "and", "ending", "tier" ]
train
https://github.com/mozilla/amo-validator/blob/0251bfbd7d93106e01ecdb6de5fcd1dc1a180664/validator/errorbundler.py#L176-L180
mozilla/amo-validator
validator/errorbundler.py
ErrorBundle._save_message
def _save_message(self, stack, type_, message, context=None, from_merge=False): 'Stores a message in the appropriate message stack.' uid = uuid.uuid4().hex message['uid'] = uid # Get the context for the message (if there's a context available) if context i...
python
def _save_message(self, stack, type_, message, context=None, from_merge=False): 'Stores a message in the appropriate message stack.' uid = uuid.uuid4().hex message['uid'] = uid # Get the context for the message (if there's a context available) if context i...
[ "def", "_save_message", "(", "self", ",", "stack", ",", "type_", ",", "message", ",", "context", "=", "None", ",", "from_merge", "=", "False", ")", ":", "uid", "=", "uuid", ".", "uuid4", "(", ")", ".", "hex", "message", "[", "'uid'", "]", "=", "uid...
Stores a message in the appropriate message stack.
[ "Stores", "a", "message", "in", "the", "appropriate", "message", "stack", "." ]
train
https://github.com/mozilla/amo-validator/blob/0251bfbd7d93106e01ecdb6de5fcd1dc1a180664/validator/errorbundler.py#L186-L255
mozilla/amo-validator
validator/errorbundler.py
ErrorBundle.failed
def failed(self, fail_on_warnings=True): """Returns a boolean value describing whether the validation succeeded or not.""" return bool(self.errors) or (fail_on_warnings and bool(self.warnings))
python
def failed(self, fail_on_warnings=True): """Returns a boolean value describing whether the validation succeeded or not.""" return bool(self.errors) or (fail_on_warnings and bool(self.warnings))
[ "def", "failed", "(", "self", ",", "fail_on_warnings", "=", "True", ")", ":", "return", "bool", "(", "self", ".", "errors", ")", "or", "(", "fail_on_warnings", "and", "bool", "(", "self", ".", "warnings", ")", ")" ]
Returns a boolean value describing whether the validation succeeded or not.
[ "Returns", "a", "boolean", "value", "describing", "whether", "the", "validation", "succeeded", "or", "not", "." ]
train
https://github.com/mozilla/amo-validator/blob/0251bfbd7d93106e01ecdb6de5fcd1dc1a180664/validator/errorbundler.py#L257-L261
mozilla/amo-validator
validator/errorbundler.py
ErrorBundle.get_resource
def get_resource(self, name): 'Retrieves an object that has been stored by another test.' if name in self.resources: return self.resources[name] elif name in self.pushable_resources: return self.pushable_resources[name] else: return False
python
def get_resource(self, name): 'Retrieves an object that has been stored by another test.' if name in self.resources: return self.resources[name] elif name in self.pushable_resources: return self.pushable_resources[name] else: return False
[ "def", "get_resource", "(", "self", ",", "name", ")", ":", "if", "name", "in", "self", ".", "resources", ":", "return", "self", ".", "resources", "[", "name", "]", "elif", "name", "in", "self", ".", "pushable_resources", ":", "return", "self", ".", "pu...
Retrieves an object that has been stored by another test.
[ "Retrieves", "an", "object", "that", "has", "been", "stored", "by", "another", "test", "." ]
train
https://github.com/mozilla/amo-validator/blob/0251bfbd7d93106e01ecdb6de5fcd1dc1a180664/validator/errorbundler.py#L263-L271
mozilla/amo-validator
validator/errorbundler.py
ErrorBundle.save_resource
def save_resource(self, name, resource, pushable=False): 'Saves an object such that it can be used by other tests.' if pushable: self.pushable_resources[name] = resource else: self.resources[name] = resource
python
def save_resource(self, name, resource, pushable=False): 'Saves an object such that it can be used by other tests.' if pushable: self.pushable_resources[name] = resource else: self.resources[name] = resource
[ "def", "save_resource", "(", "self", ",", "name", ",", "resource", ",", "pushable", "=", "False", ")", ":", "if", "pushable", ":", "self", ".", "pushable_resources", "[", "name", "]", "=", "resource", "else", ":", "self", ".", "resources", "[", "name", ...
Saves an object such that it can be used by other tests.
[ "Saves", "an", "object", "such", "that", "it", "can", "be", "used", "by", "other", "tests", "." ]
train
https://github.com/mozilla/amo-validator/blob/0251bfbd7d93106e01ecdb6de5fcd1dc1a180664/validator/errorbundler.py#L273-L279
mozilla/amo-validator
validator/errorbundler.py
ErrorBundle.push_state
def push_state(self, new_file=''): 'Saves the current error state to parse subpackages' self.subpackages.append({'detected_type': self.detected_type, 'message_tree': self.message_tree, 'resources': self.pushable_resources, ...
python
def push_state(self, new_file=''): 'Saves the current error state to parse subpackages' self.subpackages.append({'detected_type': self.detected_type, 'message_tree': self.message_tree, 'resources': self.pushable_resources, ...
[ "def", "push_state", "(", "self", ",", "new_file", "=", "''", ")", ":", "self", ".", "subpackages", ".", "append", "(", "{", "'detected_type'", ":", "self", ".", "detected_type", ",", "'message_tree'", ":", "self", ".", "message_tree", ",", "'resources'", ...
Saves the current error state to parse subpackages
[ "Saves", "the", "current", "error", "state", "to", "parse", "subpackages" ]
train
https://github.com/mozilla/amo-validator/blob/0251bfbd7d93106e01ecdb6de5fcd1dc1a180664/validator/errorbundler.py#L286-L300
mozilla/amo-validator
validator/errorbundler.py
ErrorBundle.pop_state
def pop_state(self): 'Retrieves the last saved state and restores it.' # Save a copy of the current state. state = self.subpackages.pop() metadata = self.metadata # We only rebuild message_tree anyway. No need to restore. # Copy the existing state back into place ...
python
def pop_state(self): 'Retrieves the last saved state and restores it.' # Save a copy of the current state. state = self.subpackages.pop() metadata = self.metadata # We only rebuild message_tree anyway. No need to restore. # Copy the existing state back into place ...
[ "def", "pop_state", "(", "self", ")", ":", "# Save a copy of the current state.", "state", "=", "self", ".", "subpackages", ".", "pop", "(", ")", "metadata", "=", "self", ".", "metadata", "# We only rebuild message_tree anyway. No need to restore.", "# Copy the existing s...
Retrieves the last saved state and restores it.
[ "Retrieves", "the", "last", "saved", "state", "and", "restores", "it", "." ]
train
https://github.com/mozilla/amo-validator/blob/0251bfbd7d93106e01ecdb6de5fcd1dc1a180664/validator/errorbundler.py#L302-L318
mozilla/amo-validator
validator/errorbundler.py
ErrorBundle.render_json
def render_json(self): 'Returns a JSON summary of the validation operation.' types = {0: 'unknown', 1: 'extension', 2: 'theme', 3: 'dictionary', 4: 'langpack', 5: 'search', 8: 'webapp'} output ...
python
def render_json(self): 'Returns a JSON summary of the validation operation.' types = {0: 'unknown', 1: 'extension', 2: 'theme', 3: 'dictionary', 4: 'langpack', 5: 'search', 8: 'webapp'} output ...
[ "def", "render_json", "(", "self", ")", ":", "types", "=", "{", "0", ":", "'unknown'", ",", "1", ":", "'extension'", ",", "2", ":", "'theme'", ",", "3", ":", "'dictionary'", ",", "4", ":", "'langpack'", ",", "5", ":", "'search'", ",", "8", ":", "...
Returns a JSON summary of the validation operation.
[ "Returns", "a", "JSON", "summary", "of", "the", "validation", "operation", "." ]
train
https://github.com/mozilla/amo-validator/blob/0251bfbd7d93106e01ecdb6de5fcd1dc1a180664/validator/errorbundler.py#L320-L358
mozilla/amo-validator
validator/errorbundler.py
ErrorBundle.print_summary
def print_summary(self, verbose=False, no_color=False): 'Prints a summary of the validation process so far.' types = {0: 'Unknown', 1: 'Extension/Multi-Extension', 2: 'Full Theme', 3: 'Dictionary', 4: 'Language Pack', ...
python
def print_summary(self, verbose=False, no_color=False): 'Prints a summary of the validation process so far.' types = {0: 'Unknown', 1: 'Extension/Multi-Extension', 2: 'Full Theme', 3: 'Dictionary', 4: 'Language Pack', ...
[ "def", "print_summary", "(", "self", ",", "verbose", "=", "False", ",", "no_color", "=", "False", ")", ":", "types", "=", "{", "0", ":", "'Unknown'", ",", "1", ":", "'Extension/Multi-Extension'", ",", "2", ":", "'Full Theme'", ",", "3", ":", "'Dictionary...
Prints a summary of the validation process so far.
[ "Prints", "a", "summary", "of", "the", "validation", "process", "so", "far", "." ]
train
https://github.com/mozilla/amo-validator/blob/0251bfbd7d93106e01ecdb6de5fcd1dc1a180664/validator/errorbundler.py#L360-L425
mozilla/amo-validator
validator/errorbundler.py
ErrorBundle._flatten_list
def _flatten_list(self, data): 'Flattens nested lists into strings.' if data is None: return '' if isinstance(data, types.StringTypes): return data elif isinstance(data, (list, tuple)): return '\n'.join(self._flatten_list(x) for x in data)
python
def _flatten_list(self, data): 'Flattens nested lists into strings.' if data is None: return '' if isinstance(data, types.StringTypes): return data elif isinstance(data, (list, tuple)): return '\n'.join(self._flatten_list(x) for x in data)
[ "def", "_flatten_list", "(", "self", ",", "data", ")", ":", "if", "data", "is", "None", ":", "return", "''", "if", "isinstance", "(", "data", ",", "types", ".", "StringTypes", ")", ":", "return", "data", "elif", "isinstance", "(", "data", ",", "(", "...
Flattens nested lists into strings.
[ "Flattens", "nested", "lists", "into", "strings", "." ]
train
https://github.com/mozilla/amo-validator/blob/0251bfbd7d93106e01ecdb6de5fcd1dc1a180664/validator/errorbundler.py#L427-L435
mozilla/amo-validator
validator/errorbundler.py
ErrorBundle._print_message
def _print_message(self, prefix, message, verbose=True): 'Prints a message and takes care of all sorts of nasty code' # Load up the standard output. output = ['\n', prefix, message['message']] # We have some extra stuff for verbose mode. if verbose: verbose_output =...
python
def _print_message(self, prefix, message, verbose=True): 'Prints a message and takes care of all sorts of nasty code' # Load up the standard output. output = ['\n', prefix, message['message']] # We have some extra stuff for verbose mode. if verbose: verbose_output =...
[ "def", "_print_message", "(", "self", ",", "prefix", ",", "message", ",", "verbose", "=", "True", ")", ":", "# Load up the standard output.", "output", "=", "[", "'\\n'", ",", "prefix", ",", "message", "[", "'message'", "]", "]", "# We have some extra stuff for ...
Prints a message and takes care of all sorts of nasty code
[ "Prints", "a", "message", "and", "takes", "care", "of", "all", "sorts", "of", "nasty", "code" ]
train
https://github.com/mozilla/amo-validator/blob/0251bfbd7d93106e01ecdb6de5fcd1dc1a180664/validator/errorbundler.py#L437-L498
mozilla/amo-validator
validator/errorbundler.py
ErrorBundle.supports_version
def supports_version(self, guid_set): """ Returns whether a GUID set in for_appversions format is compatbile with the current supported applications list. """ # Don't let the test run if we haven't parsed install.rdf yet. if self.supported_versions is None: r...
python
def supports_version(self, guid_set): """ Returns whether a GUID set in for_appversions format is compatbile with the current supported applications list. """ # Don't let the test run if we haven't parsed install.rdf yet. if self.supported_versions is None: r...
[ "def", "supports_version", "(", "self", ",", "guid_set", ")", ":", "# Don't let the test run if we haven't parsed install.rdf yet.", "if", "self", ".", "supported_versions", "is", "None", ":", "raise", "Exception", "(", "'Early compatibility test run before install.rdf '", "'...
Returns whether a GUID set in for_appversions format is compatbile with the current supported applications list.
[ "Returns", "whether", "a", "GUID", "set", "in", "for_appversions", "format", "is", "compatbile", "with", "the", "current", "supported", "applications", "list", "." ]
train
https://github.com/mozilla/amo-validator/blob/0251bfbd7d93106e01ecdb6de5fcd1dc1a180664/validator/errorbundler.py#L500-L512
mozilla/amo-validator
validator/errorbundler.py
ErrorBundle._compare_version
def _compare_version(self, requirements, support): """ Return whether there is an intersection between a support applications GUID set and a set of supported applications. """ for guid in requirements: # If we support any of the GUIDs in the guid_set, test if any of ...
python
def _compare_version(self, requirements, support): """ Return whether there is an intersection between a support applications GUID set and a set of supported applications. """ for guid in requirements: # If we support any of the GUIDs in the guid_set, test if any of ...
[ "def", "_compare_version", "(", "self", ",", "requirements", ",", "support", ")", ":", "for", "guid", "in", "requirements", ":", "# If we support any of the GUIDs in the guid_set, test if any of", "# the provided versions for the GUID are supported.", "if", "(", "guid", "in",...
Return whether there is an intersection between a support applications GUID set and a set of supported applications.
[ "Return", "whether", "there", "is", "an", "intersection", "between", "a", "support", "applications", "GUID", "set", "and", "a", "set", "of", "supported", "applications", "." ]
train
https://github.com/mozilla/amo-validator/blob/0251bfbd7d93106e01ecdb6de5fcd1dc1a180664/validator/errorbundler.py#L514-L526
mozilla/amo-validator
validator/errorbundler.py
ErrorBundle.discard_unused_messages
def discard_unused_messages(self, ending_tier): """ Delete messages from errors, warnings, and notices whose tier is greater than the ending tier. """ stacks = [self.errors, self.warnings, self.notices] for stack in stacks: for message in stack: ...
python
def discard_unused_messages(self, ending_tier): """ Delete messages from errors, warnings, and notices whose tier is greater than the ending tier. """ stacks = [self.errors, self.warnings, self.notices] for stack in stacks: for message in stack: ...
[ "def", "discard_unused_messages", "(", "self", ",", "ending_tier", ")", ":", "stacks", "=", "[", "self", ".", "errors", ",", "self", ".", "warnings", ",", "self", ".", "notices", "]", "for", "stack", "in", "stacks", ":", "for", "message", "in", "stack", ...
Delete messages from errors, warnings, and notices whose tier is greater than the ending tier.
[ "Delete", "messages", "from", "errors", "warnings", "and", "notices", "whose", "tier", "is", "greater", "than", "the", "ending", "tier", "." ]
train
https://github.com/mozilla/amo-validator/blob/0251bfbd7d93106e01ecdb6de5fcd1dc1a180664/validator/errorbundler.py#L528-L538
orlnub123/cleverbot.py
cleverbot/migrations.py
migrator
def migrator(state): """Tweaks will be lost for Cleverbot and its conversations.""" for tweak in ('tweak1', 'tweak2', 'tweak3'): del state[0][tweak] for convo in state[1]: if tweak in convo: del convo[tweak] return state
python
def migrator(state): """Tweaks will be lost for Cleverbot and its conversations.""" for tweak in ('tweak1', 'tweak2', 'tweak3'): del state[0][tweak] for convo in state[1]: if tweak in convo: del convo[tweak] return state
[ "def", "migrator", "(", "state", ")", ":", "for", "tweak", "in", "(", "'tweak1'", ",", "'tweak2'", ",", "'tweak3'", ")", ":", "del", "state", "[", "0", "]", "[", "tweak", "]", "for", "convo", "in", "state", "[", "1", "]", ":", "if", "tweak", "in"...
Tweaks will be lost for Cleverbot and its conversations.
[ "Tweaks", "will", "be", "lost", "for", "Cleverbot", "and", "its", "conversations", "." ]
train
https://github.com/orlnub123/cleverbot.py/blob/83aa45fc2582c30d8646372d9e09756525af931f/cleverbot/migrations.py#L65-L72
orlnub123/cleverbot.py
cleverbot/migrations.py
migrator
def migrator(state): """Nameless conversations will be lost.""" cleverbot_kwargs, convos_kwargs = state cb = Cleverbot(**cleverbot_kwargs) for convo_kwargs in convos_kwargs: cb.conversation(**convo_kwargs) return cb
python
def migrator(state): """Nameless conversations will be lost.""" cleverbot_kwargs, convos_kwargs = state cb = Cleverbot(**cleverbot_kwargs) for convo_kwargs in convos_kwargs: cb.conversation(**convo_kwargs) return cb
[ "def", "migrator", "(", "state", ")", ":", "cleverbot_kwargs", ",", "convos_kwargs", "=", "state", "cb", "=", "Cleverbot", "(", "*", "*", "cleverbot_kwargs", ")", "for", "convo_kwargs", "in", "convos_kwargs", ":", "cb", ".", "conversation", "(", "*", "*", ...
Nameless conversations will be lost.
[ "Nameless", "conversations", "will", "be", "lost", "." ]
train
https://github.com/orlnub123/cleverbot.py/blob/83aa45fc2582c30d8646372d9e09756525af931f/cleverbot/migrations.py#L76-L82
senaite/senaite.core.supermodel
src/senaite/core/supermodel/model.py
SuperModel.init_with_uid
def init_with_uid(self, uid): """Initialize with an UID """ self._uid = uid self._brain = None self._catalog = None self._instance = None
python
def init_with_uid(self, uid): """Initialize with an UID """ self._uid = uid self._brain = None self._catalog = None self._instance = None
[ "def", "init_with_uid", "(", "self", ",", "uid", ")", ":", "self", ".", "_uid", "=", "uid", "self", ".", "_brain", "=", "None", "self", ".", "_catalog", "=", "None", "self", ".", "_instance", "=", "None" ]
Initialize with an UID
[ "Initialize", "with", "an", "UID" ]
train
https://github.com/senaite/senaite.core.supermodel/blob/1819154332b8776f187aa98a2e299701983a0119/src/senaite/core/supermodel/model.py#L69-L75
senaite/senaite.core.supermodel
src/senaite/core/supermodel/model.py
SuperModel.init_with_brain
def init_with_brain(self, brain): """Initialize with a catalog brain """ self._uid = api.get_uid(brain) self._brain = brain self._catalog = self.get_catalog_for(brain) self._instance = None
python
def init_with_brain(self, brain): """Initialize with a catalog brain """ self._uid = api.get_uid(brain) self._brain = brain self._catalog = self.get_catalog_for(brain) self._instance = None
[ "def", "init_with_brain", "(", "self", ",", "brain", ")", ":", "self", ".", "_uid", "=", "api", ".", "get_uid", "(", "brain", ")", "self", ".", "_brain", "=", "brain", "self", ".", "_catalog", "=", "self", ".", "get_catalog_for", "(", "brain", ")", "...
Initialize with a catalog brain
[ "Initialize", "with", "a", "catalog", "brain" ]
train
https://github.com/senaite/senaite.core.supermodel/blob/1819154332b8776f187aa98a2e299701983a0119/src/senaite/core/supermodel/model.py#L77-L83
senaite/senaite.core.supermodel
src/senaite/core/supermodel/model.py
SuperModel.init_with_instance
def init_with_instance(self, instance): """Initialize with an instance object """ self._uid = api.get_uid(instance) self._brain = None self._catalog = self.get_catalog_for(instance) self._instance = instance
python
def init_with_instance(self, instance): """Initialize with an instance object """ self._uid = api.get_uid(instance) self._brain = None self._catalog = self.get_catalog_for(instance) self._instance = instance
[ "def", "init_with_instance", "(", "self", ",", "instance", ")", ":", "self", ".", "_uid", "=", "api", ".", "get_uid", "(", "instance", ")", "self", ".", "_brain", "=", "None", "self", ".", "_catalog", "=", "self", ".", "get_catalog_for", "(", "instance",...
Initialize with an instance object
[ "Initialize", "with", "an", "instance", "object" ]
train
https://github.com/senaite/senaite.core.supermodel/blob/1819154332b8776f187aa98a2e299701983a0119/src/senaite/core/supermodel/model.py#L85-L91