id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
39,600
trevisanj/a99
a99/gui/xmisc.py
enc_name_descr
def enc_name_descr(name, descr, color=a99.COLOR_DESCR): """Encodes html given name and description.""" return enc_name(name, color)+"<br>"+descr
python
def enc_name_descr(name, descr, color=a99.COLOR_DESCR): """Encodes html given name and description.""" return enc_name(name, color)+"<br>"+descr
[ "def", "enc_name_descr", "(", "name", ",", "descr", ",", "color", "=", "a99", ".", "COLOR_DESCR", ")", ":", "return", "enc_name", "(", "name", ",", "color", ")", "+", "\"<br>\"", "+", "descr" ]
Encodes html given name and description.
[ "Encodes", "html", "given", "name", "and", "description", "." ]
193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539
https://github.com/trevisanj/a99/blob/193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539/a99/gui/xmisc.py#L47-L49
39,601
trevisanj/a99
a99/gui/xmisc.py
style_checkboxes
def style_checkboxes(widget): """ Iterates over widget children to change checkboxes stylesheet. The default rendering of checkboxes does not allow to tell a focused one from an unfocused one. """ ww = widget.findChildren(QCheckBox) for w in ww: w.setStyleSheet("QCheckBox...
python
def style_checkboxes(widget): """ Iterates over widget children to change checkboxes stylesheet. The default rendering of checkboxes does not allow to tell a focused one from an unfocused one. """ ww = widget.findChildren(QCheckBox) for w in ww: w.setStyleSheet("QCheckBox...
[ "def", "style_checkboxes", "(", "widget", ")", ":", "ww", "=", "widget", ".", "findChildren", "(", "QCheckBox", ")", "for", "w", "in", "ww", ":", "w", ".", "setStyleSheet", "(", "\"QCheckBox:focus {border: 1px solid #000000;}\"", ")" ]
Iterates over widget children to change checkboxes stylesheet. The default rendering of checkboxes does not allow to tell a focused one from an unfocused one.
[ "Iterates", "over", "widget", "children", "to", "change", "checkboxes", "stylesheet", ".", "The", "default", "rendering", "of", "checkboxes", "does", "not", "allow", "to", "tell", "a", "focused", "one", "from", "an", "unfocused", "one", "." ]
193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539
https://github.com/trevisanj/a99/blob/193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539/a99/gui/xmisc.py#L57-L67
39,602
trevisanj/a99
a99/gui/xmisc.py
reset_table_widget
def reset_table_widget(t, rowCount, colCount): """Clears and resizes a table widget.""" t.reset() t.horizontalHeader().reset() t.clear() t.sortItems(-1) t.setRowCount(rowCount) t.setColumnCount(colCount)
python
def reset_table_widget(t, rowCount, colCount): """Clears and resizes a table widget.""" t.reset() t.horizontalHeader().reset() t.clear() t.sortItems(-1) t.setRowCount(rowCount) t.setColumnCount(colCount)
[ "def", "reset_table_widget", "(", "t", ",", "rowCount", ",", "colCount", ")", ":", "t", ".", "reset", "(", ")", "t", ".", "horizontalHeader", "(", ")", ".", "reset", "(", ")", "t", ".", "clear", "(", ")", "t", ".", "sortItems", "(", "-", "1", ")"...
Clears and resizes a table widget.
[ "Clears", "and", "resizes", "a", "table", "widget", "." ]
193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539
https://github.com/trevisanj/a99/blob/193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539/a99/gui/xmisc.py#L127-L134
39,603
trevisanj/a99
a99/gui/xmisc.py
place_center
def place_center(window, width=None, height=None): """Places window in the center of the screen.""" screenGeometry = QApplication.desktop().screenGeometry() w, h = window.width(), window.height() if width is not None or height is not None: w = width if width is not None else w ...
python
def place_center(window, width=None, height=None): """Places window in the center of the screen.""" screenGeometry = QApplication.desktop().screenGeometry() w, h = window.width(), window.height() if width is not None or height is not None: w = width if width is not None else w ...
[ "def", "place_center", "(", "window", ",", "width", "=", "None", ",", "height", "=", "None", ")", ":", "screenGeometry", "=", "QApplication", ".", "desktop", "(", ")", ".", "screenGeometry", "(", ")", "w", ",", "h", "=", "window", ".", "width", "(", ...
Places window in the center of the screen.
[ "Places", "window", "in", "the", "center", "of", "the", "screen", "." ]
193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539
https://github.com/trevisanj/a99/blob/193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539/a99/gui/xmisc.py#L201-L214
39,604
trevisanj/a99
a99/gui/xmisc.py
get_QApplication
def get_QApplication(args=[]): """Returns the QApplication instance, creating it is does not yet exist.""" global _qapp if _qapp is None: QCoreApplication.setAttribute(Qt.AA_X11InitThreads) _qapp = QApplication(args) return _qapp
python
def get_QApplication(args=[]): """Returns the QApplication instance, creating it is does not yet exist.""" global _qapp if _qapp is None: QCoreApplication.setAttribute(Qt.AA_X11InitThreads) _qapp = QApplication(args) return _qapp
[ "def", "get_QApplication", "(", "args", "=", "[", "]", ")", ":", "global", "_qapp", "if", "_qapp", "is", "None", ":", "QCoreApplication", ".", "setAttribute", "(", "Qt", ".", "AA_X11InitThreads", ")", "_qapp", "=", "QApplication", "(", "args", ")", "return...
Returns the QApplication instance, creating it is does not yet exist.
[ "Returns", "the", "QApplication", "instance", "creating", "it", "is", "does", "not", "yet", "exist", "." ]
193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539
https://github.com/trevisanj/a99/blob/193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539/a99/gui/xmisc.py#L324-L331
39,605
trevisanj/a99
a99/gui/xmisc.py
get_frame
def get_frame(): """Returns a QFrame formatted in a particular way""" ret = QFrame() ret.setLineWidth(1) ret.setMidLineWidth(0) ret.setFrameShadow(QFrame.Sunken) ret.setFrameShape(QFrame.Box) return ret
python
def get_frame(): """Returns a QFrame formatted in a particular way""" ret = QFrame() ret.setLineWidth(1) ret.setMidLineWidth(0) ret.setFrameShadow(QFrame.Sunken) ret.setFrameShape(QFrame.Box) return ret
[ "def", "get_frame", "(", ")", ":", "ret", "=", "QFrame", "(", ")", "ret", ".", "setLineWidth", "(", "1", ")", "ret", ".", "setMidLineWidth", "(", "0", ")", "ret", ".", "setFrameShadow", "(", "QFrame", ".", "Sunken", ")", "ret", ".", "setFrameShape", ...
Returns a QFrame formatted in a particular way
[ "Returns", "a", "QFrame", "formatted", "in", "a", "particular", "way" ]
193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539
https://github.com/trevisanj/a99/blob/193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539/a99/gui/xmisc.py#L549-L556
39,606
trevisanj/a99
a99/gui/xmisc.py
SignalProxy.add_signal
def add_signal(self, signal): """Adds "input" signal to connected signals. Internally connects the signal to a control slot.""" self.__signals.append(signal) if self.__connected: # Connects signal if the current state is "connected" self.__connect_signal(sig...
python
def add_signal(self, signal): """Adds "input" signal to connected signals. Internally connects the signal to a control slot.""" self.__signals.append(signal) if self.__connected: # Connects signal if the current state is "connected" self.__connect_signal(sig...
[ "def", "add_signal", "(", "self", ",", "signal", ")", ":", "self", ".", "__signals", ".", "append", "(", "signal", ")", "if", "self", ".", "__connected", ":", "# Connects signal if the current state is \"connected\"\r", "self", ".", "__connect_signal", "(", "signa...
Adds "input" signal to connected signals. Internally connects the signal to a control slot.
[ "Adds", "input", "signal", "to", "connected", "signals", ".", "Internally", "connects", "the", "signal", "to", "a", "control", "slot", "." ]
193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539
https://github.com/trevisanj/a99/blob/193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539/a99/gui/xmisc.py#L424-L430
39,607
trevisanj/a99
a99/gui/xmisc.py
SignalProxy.disconnect_all
def disconnect_all(self): """Disconnects all signals and slots. If already in "disconnected" state, ignores the call. """ if not self.__connected: return # assert self.__connected, "disconnect_all() already in \"disconnected\" state" self.__disconnecting = Tr...
python
def disconnect_all(self): """Disconnects all signals and slots. If already in "disconnected" state, ignores the call. """ if not self.__connected: return # assert self.__connected, "disconnect_all() already in \"disconnected\" state" self.__disconnecting = Tr...
[ "def", "disconnect_all", "(", "self", ")", ":", "if", "not", "self", ".", "__connected", ":", "return", "# assert self.__connected, \"disconnect_all() already in \\\"disconnected\\\" state\"\r", "self", ".", "__disconnecting", "=", "True", "try", ":", "for", "signal", "...
Disconnects all signals and slots. If already in "disconnected" state, ignores the call.
[ "Disconnects", "all", "signals", "and", "slots", ".", "If", "already", "in", "disconnected", "state", "ignores", "the", "call", "." ]
193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539
https://github.com/trevisanj/a99/blob/193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539/a99/gui/xmisc.py#L446-L461
39,608
trevisanj/a99
a99/gui/xmisc.py
SignalProxy.__signalReceived
def __signalReceived(self, *args): """Received signal. Cancel previous timer and store args to be forwarded later.""" if self.__disconnecting: return with self.__lock: self.__args = args if self.__rateLimit == 0: self.__timer.stop() ...
python
def __signalReceived(self, *args): """Received signal. Cancel previous timer and store args to be forwarded later.""" if self.__disconnecting: return with self.__lock: self.__args = args if self.__rateLimit == 0: self.__timer.stop() ...
[ "def", "__signalReceived", "(", "self", ",", "*", "args", ")", ":", "if", "self", ".", "__disconnecting", ":", "return", "with", "self", ".", "__lock", ":", "self", ".", "__args", "=", "args", "if", "self", ".", "__rateLimit", "==", "0", ":", "self", ...
Received signal. Cancel previous timer and store args to be forwarded later.
[ "Received", "signal", ".", "Cancel", "previous", "timer", "and", "store", "args", "to", "be", "forwarded", "later", "." ]
193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539
https://github.com/trevisanj/a99/blob/193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539/a99/gui/xmisc.py#L463-L483
39,609
trevisanj/a99
a99/gui/xmisc.py
SignalProxy.__flush
def __flush(self): """If there is a signal queued up, send it now.""" if self.__args is None or self.__disconnecting: return False #self.emit(self.signal, *self.args) self.__sigDelayed.emit(self.__args) self.__args = None self.__timer.stop() se...
python
def __flush(self): """If there is a signal queued up, send it now.""" if self.__args is None or self.__disconnecting: return False #self.emit(self.signal, *self.args) self.__sigDelayed.emit(self.__args) self.__args = None self.__timer.stop() se...
[ "def", "__flush", "(", "self", ")", ":", "if", "self", ".", "__args", "is", "None", "or", "self", ".", "__disconnecting", ":", "return", "False", "#self.emit(self.signal, *self.args)\r", "self", ".", "__sigDelayed", ".", "emit", "(", "self", ".", "__args", "...
If there is a signal queued up, send it now.
[ "If", "there", "is", "a", "signal", "queued", "up", "send", "it", "now", "." ]
193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539
https://github.com/trevisanj/a99/blob/193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539/a99/gui/xmisc.py#L485-L494
39,610
blockadeio/analyst_toolbench
blockade/common/utils.py
clean_indicators
def clean_indicators(indicators): """Remove any extra details from indicators.""" output = list() for indicator in indicators: strip = ['http://', 'https://'] for item in strip: indicator = indicator.replace(item, '') indicator = indicator.strip('.').strip() parts...
python
def clean_indicators(indicators): """Remove any extra details from indicators.""" output = list() for indicator in indicators: strip = ['http://', 'https://'] for item in strip: indicator = indicator.replace(item, '') indicator = indicator.strip('.').strip() parts...
[ "def", "clean_indicators", "(", "indicators", ")", ":", "output", "=", "list", "(", ")", "for", "indicator", "in", "indicators", ":", "strip", "=", "[", "'http://'", ",", "'https://'", "]", "for", "item", "in", "strip", ":", "indicator", "=", "indicator", ...
Remove any extra details from indicators.
[ "Remove", "any", "extra", "details", "from", "indicators", "." ]
159b6f8cf8a91c5ff050f1579636ea90ab269863
https://github.com/blockadeio/analyst_toolbench/blob/159b6f8cf8a91c5ff050f1579636ea90ab269863/blockade/common/utils.py#L4-L17
39,611
blockadeio/analyst_toolbench
blockade/common/utils.py
hash_values
def hash_values(values, alg="md5"): """Hash a list of values.""" import hashlib if alg not in ['md5', 'sha1', 'sha256']: raise Exception("Invalid hashing algorithm!") hasher = getattr(hashlib, alg) if type(values) == str: output = hasher(values).hexdigest() elif type(values) == ...
python
def hash_values(values, alg="md5"): """Hash a list of values.""" import hashlib if alg not in ['md5', 'sha1', 'sha256']: raise Exception("Invalid hashing algorithm!") hasher = getattr(hashlib, alg) if type(values) == str: output = hasher(values).hexdigest() elif type(values) == ...
[ "def", "hash_values", "(", "values", ",", "alg", "=", "\"md5\"", ")", ":", "import", "hashlib", "if", "alg", "not", "in", "[", "'md5'", ",", "'sha1'", ",", "'sha256'", "]", ":", "raise", "Exception", "(", "\"Invalid hashing algorithm!\"", ")", "hasher", "=...
Hash a list of values.
[ "Hash", "a", "list", "of", "values", "." ]
159b6f8cf8a91c5ff050f1579636ea90ab269863
https://github.com/blockadeio/analyst_toolbench/blob/159b6f8cf8a91c5ff050f1579636ea90ab269863/blockade/common/utils.py#L26-L39
39,612
blockadeio/analyst_toolbench
blockade/common/utils.py
check_whitelist
def check_whitelist(values): """Check the indicators against known whitelists.""" import os import tldextract whitelisted = list() for name in ['alexa.txt', 'cisco.txt']: config_path = os.path.expanduser('~/.config/blockade') file_path = os.path.join(config_path, name) whitel...
python
def check_whitelist(values): """Check the indicators against known whitelists.""" import os import tldextract whitelisted = list() for name in ['alexa.txt', 'cisco.txt']: config_path = os.path.expanduser('~/.config/blockade') file_path = os.path.join(config_path, name) whitel...
[ "def", "check_whitelist", "(", "values", ")", ":", "import", "os", "import", "tldextract", "whitelisted", "=", "list", "(", ")", "for", "name", "in", "[", "'alexa.txt'", ",", "'cisco.txt'", "]", ":", "config_path", "=", "os", ".", "path", ".", "expanduser"...
Check the indicators against known whitelists.
[ "Check", "the", "indicators", "against", "known", "whitelists", "." ]
159b6f8cf8a91c5ff050f1579636ea90ab269863
https://github.com/blockadeio/analyst_toolbench/blob/159b6f8cf8a91c5ff050f1579636ea90ab269863/blockade/common/utils.py#L42-L57
39,613
blockadeio/analyst_toolbench
blockade/common/utils.py
cache_items
def cache_items(values): """Cache indicators that were successfully sent to avoid dups.""" import os config_path = os.path.expanduser('~/.config/blockade') file_path = os.path.join(config_path, 'cache.txt') if not os.path.isfile(file_path): file(file_path, 'w').close() written = [x.strip...
python
def cache_items(values): """Cache indicators that were successfully sent to avoid dups.""" import os config_path = os.path.expanduser('~/.config/blockade') file_path = os.path.join(config_path, 'cache.txt') if not os.path.isfile(file_path): file(file_path, 'w').close() written = [x.strip...
[ "def", "cache_items", "(", "values", ")", ":", "import", "os", "config_path", "=", "os", ".", "path", ".", "expanduser", "(", "'~/.config/blockade'", ")", "file_path", "=", "os", ".", "path", ".", "join", "(", "config_path", ",", "'cache.txt'", ")", "if", ...
Cache indicators that were successfully sent to avoid dups.
[ "Cache", "indicators", "that", "were", "successfully", "sent", "to", "avoid", "dups", "." ]
159b6f8cf8a91c5ff050f1579636ea90ab269863
https://github.com/blockadeio/analyst_toolbench/blob/159b6f8cf8a91c5ff050f1579636ea90ab269863/blockade/common/utils.py#L60-L81
39,614
blockadeio/analyst_toolbench
blockade/common/utils.py
prune_cached
def prune_cached(values): """Remove the items that have already been cached.""" import os config_path = os.path.expanduser('~/.config/blockade') file_path = os.path.join(config_path, 'cache.txt') if not os.path.isfile(file_path): return values cached = [x.strip() for x in open(file_path,...
python
def prune_cached(values): """Remove the items that have already been cached.""" import os config_path = os.path.expanduser('~/.config/blockade') file_path = os.path.join(config_path, 'cache.txt') if not os.path.isfile(file_path): return values cached = [x.strip() for x in open(file_path,...
[ "def", "prune_cached", "(", "values", ")", ":", "import", "os", "config_path", "=", "os", ".", "path", ".", "expanduser", "(", "'~/.config/blockade'", ")", "file_path", "=", "os", ".", "path", ".", "join", "(", "config_path", ",", "'cache.txt'", ")", "if",...
Remove the items that have already been cached.
[ "Remove", "the", "items", "that", "have", "already", "been", "cached", "." ]
159b6f8cf8a91c5ff050f1579636ea90ab269863
https://github.com/blockadeio/analyst_toolbench/blob/159b6f8cf8a91c5ff050f1579636ea90ab269863/blockade/common/utils.py#L84-L98
39,615
blockadeio/analyst_toolbench
blockade/common/utils.py
get_logger
def get_logger(name): """Get a logging instance we can use.""" import logging import sys logger = logging.getLogger(name) logger.setLevel(logging.DEBUG) shandler = logging.StreamHandler(sys.stdout) fmt = "" fmt += '\033[1;32m%(levelname)-5s %(module)s:%(funcName)s():' fmt += '%(linen...
python
def get_logger(name): """Get a logging instance we can use.""" import logging import sys logger = logging.getLogger(name) logger.setLevel(logging.DEBUG) shandler = logging.StreamHandler(sys.stdout) fmt = "" fmt += '\033[1;32m%(levelname)-5s %(module)s:%(funcName)s():' fmt += '%(linen...
[ "def", "get_logger", "(", "name", ")", ":", "import", "logging", "import", "sys", "logger", "=", "logging", ".", "getLogger", "(", "name", ")", "logger", ".", "setLevel", "(", "logging", ".", "DEBUG", ")", "shandler", "=", "logging", ".", "StreamHandler", ...
Get a logging instance we can use.
[ "Get", "a", "logging", "instance", "we", "can", "use", "." ]
159b6f8cf8a91c5ff050f1579636ea90ab269863
https://github.com/blockadeio/analyst_toolbench/blob/159b6f8cf8a91c5ff050f1579636ea90ab269863/blockade/common/utils.py#L101-L114
39,616
blockadeio/analyst_toolbench
blockade/common/utils.py
process_whitelists
def process_whitelists(): """Download approved top 1M lists.""" import csv import grequests import os import StringIO import zipfile mapping = { 'http://s3.amazonaws.com/alexa-static/top-1m.csv.zip': { 'name': 'alexa.txt' }, 'http://s3-us-west-1.amazonaws.com/umbr...
python
def process_whitelists(): """Download approved top 1M lists.""" import csv import grequests import os import StringIO import zipfile mapping = { 'http://s3.amazonaws.com/alexa-static/top-1m.csv.zip': { 'name': 'alexa.txt' }, 'http://s3-us-west-1.amazonaws.com/umbr...
[ "def", "process_whitelists", "(", ")", ":", "import", "csv", "import", "grequests", "import", "os", "import", "StringIO", "import", "zipfile", "mapping", "=", "{", "'http://s3.amazonaws.com/alexa-static/top-1m.csv.zip'", ":", "{", "'name'", ":", "'alexa.txt'", "}", ...
Download approved top 1M lists.
[ "Download", "approved", "top", "1M", "lists", "." ]
159b6f8cf8a91c5ff050f1579636ea90ab269863
https://github.com/blockadeio/analyst_toolbench/blob/159b6f8cf8a91c5ff050f1579636ea90ab269863/blockade/common/utils.py#L117-L148
39,617
tradenity/python-sdk
tradenity/resources/braintree_gateway.py
BraintreeGateway.mode
def mode(self, mode): """Sets the mode of this BraintreeGateway. :param mode: The mode of this BraintreeGateway. :type: str """ allowed_values = ["test", "live"] if mode is not None and mode not in allowed_values: raise ValueError( "Invalid v...
python
def mode(self, mode): """Sets the mode of this BraintreeGateway. :param mode: The mode of this BraintreeGateway. :type: str """ allowed_values = ["test", "live"] if mode is not None and mode not in allowed_values: raise ValueError( "Invalid v...
[ "def", "mode", "(", "self", ",", "mode", ")", ":", "allowed_values", "=", "[", "\"test\"", ",", "\"live\"", "]", "if", "mode", "is", "not", "None", "and", "mode", "not", "in", "allowed_values", ":", "raise", "ValueError", "(", "\"Invalid value for `mode` ({0...
Sets the mode of this BraintreeGateway. :param mode: The mode of this BraintreeGateway. :type: str
[ "Sets", "the", "mode", "of", "this", "BraintreeGateway", "." ]
d13fbe23f4d6ff22554c6d8d2deaf209371adaf1
https://github.com/tradenity/python-sdk/blob/d13fbe23f4d6ff22554c6d8d2deaf209371adaf1/tradenity/resources/braintree_gateway.py#L158-L172
39,618
a2liu/mr-clean
mr_clean/core/tools/diagnose.py
diagnose
def diagnose(df,preview_rows = 2, display_max_cols = 0,display_width = None): """ Prints information about the DataFrame pertinent to data cleaning. Parameters ---------- df - DataFrame The DataFrame to summarize preview_rows - int, default 5 Amount of rows to preview f...
python
def diagnose(df,preview_rows = 2, display_max_cols = 0,display_width = None): """ Prints information about the DataFrame pertinent to data cleaning. Parameters ---------- df - DataFrame The DataFrame to summarize preview_rows - int, default 5 Amount of rows to preview f...
[ "def", "diagnose", "(", "df", ",", "preview_rows", "=", "2", ",", "display_max_cols", "=", "0", ",", "display_width", "=", "None", ")", ":", "assert", "type", "(", "df", ")", "is", "pd", ".", "DataFrame", "# Diagnose problems with the data formats that can be ad...
Prints information about the DataFrame pertinent to data cleaning. Parameters ---------- df - DataFrame The DataFrame to summarize preview_rows - int, default 5 Amount of rows to preview from the head and tail of the DataFrame display_max_cols - int, default None Maximum amo...
[ "Prints", "information", "about", "the", "DataFrame", "pertinent", "to", "data", "cleaning", "." ]
0ee4ee5639f834dec4b59b94442fa84373f3c176
https://github.com/a2liu/mr-clean/blob/0ee4ee5639f834dec4b59b94442fa84373f3c176/mr_clean/core/tools/diagnose.py#L7-L78
39,619
trevisanj/f311
f311/explorer/util.py
cut_spectrum
def cut_spectrum(sp, l0, lf): """ Cuts spectrum given a wavelength interval, leaving origina intact Args: sp: Spectrum instance l0: initial wavelength lf: final wavelength Returns: Spectrum: cut spectrum """ if l0 >= lf: raise ValueError("l0 must be low...
python
def cut_spectrum(sp, l0, lf): """ Cuts spectrum given a wavelength interval, leaving origina intact Args: sp: Spectrum instance l0: initial wavelength lf: final wavelength Returns: Spectrum: cut spectrum """ if l0 >= lf: raise ValueError("l0 must be low...
[ "def", "cut_spectrum", "(", "sp", ",", "l0", ",", "lf", ")", ":", "if", "l0", ">=", "lf", ":", "raise", "ValueError", "(", "\"l0 must be lower than lf\"", ")", "idx0", "=", "np", ".", "argmin", "(", "np", ".", "abs", "(", "sp", ".", "x", "-", "l0",...
Cuts spectrum given a wavelength interval, leaving origina intact Args: sp: Spectrum instance l0: initial wavelength lf: final wavelength Returns: Spectrum: cut spectrum
[ "Cuts", "spectrum", "given", "a", "wavelength", "interval", "leaving", "origina", "intact" ]
9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7
https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/explorer/util.py#L14-L34
39,620
CodyKochmann/generators
generators/skip_first.py
skip_first
def skip_first(pipe, items=1): ''' this is an alias for skip to parallel the dedicated skip_last function to provide a little more readability to the code. the action of actually skipping does not occur until the first iteration is done ''' pipe = iter(pipe) for i in skip(pipe, items): ...
python
def skip_first(pipe, items=1): ''' this is an alias for skip to parallel the dedicated skip_last function to provide a little more readability to the code. the action of actually skipping does not occur until the first iteration is done ''' pipe = iter(pipe) for i in skip(pipe, items): ...
[ "def", "skip_first", "(", "pipe", ",", "items", "=", "1", ")", ":", "pipe", "=", "iter", "(", "pipe", ")", "for", "i", "in", "skip", "(", "pipe", ",", "items", ")", ":", "yield", "i" ]
this is an alias for skip to parallel the dedicated skip_last function to provide a little more readability to the code. the action of actually skipping does not occur until the first iteration is done
[ "this", "is", "an", "alias", "for", "skip", "to", "parallel", "the", "dedicated", "skip_last", "function", "to", "provide", "a", "little", "more", "readability", "to", "the", "code", ".", "the", "action", "of", "actually", "skipping", "does", "not", "occur",...
e4ca4dd25d5023a94b0349c69d6224070cc2526f
https://github.com/CodyKochmann/generators/blob/e4ca4dd25d5023a94b0349c69d6224070cc2526f/generators/skip_first.py#L9-L16
39,621
slickqa/python-client
slickqa/connection.py
SlickApiPart.find
def find(self, query=None, **kwargs): """ You can pass in the appropriate model object from the queries module, or a dictionary with the keys and values for the query, or a set of key=value parameters. """ url = self.getUrl() if query is not None: if i...
python
def find(self, query=None, **kwargs): """ You can pass in the appropriate model object from the queries module, or a dictionary with the keys and values for the query, or a set of key=value parameters. """ url = self.getUrl() if query is not None: if i...
[ "def", "find", "(", "self", ",", "query", "=", "None", ",", "*", "*", "kwargs", ")", ":", "url", "=", "self", ".", "getUrl", "(", ")", "if", "query", "is", "not", "None", ":", "if", "isinstance", "(", "query", ",", "queries", ".", "SlickQuery", "...
You can pass in the appropriate model object from the queries module, or a dictionary with the keys and values for the query, or a set of key=value parameters.
[ "You", "can", "pass", "in", "the", "appropriate", "model", "object", "from", "the", "queries", "module", "or", "a", "dictionary", "with", "the", "keys", "and", "values", "for", "the", "query", "or", "a", "set", "of", "key", "=", "value", "parameters", "....
1d36b4977cd4140d7d24917cab2b3f82b60739c2
https://github.com/slickqa/python-client/blob/1d36b4977cd4140d7d24917cab2b3f82b60739c2/slickqa/connection.py#L89-L123
39,622
slickqa/python-client
slickqa/connection.py
SlickApiPart.findOne
def findOne(self, query=None, mode=FindOneMode.FIRST, **kwargs): """ Perform a find, with the same options present, but only return a maximum of one result. If find returns an empty array, then None is returned. If there are multiple results from find, the one returned depends on the m...
python
def findOne(self, query=None, mode=FindOneMode.FIRST, **kwargs): """ Perform a find, with the same options present, but only return a maximum of one result. If find returns an empty array, then None is returned. If there are multiple results from find, the one returned depends on the m...
[ "def", "findOne", "(", "self", ",", "query", "=", "None", ",", "mode", "=", "FindOneMode", ".", "FIRST", ",", "*", "*", "kwargs", ")", ":", "results", "=", "self", ".", "find", "(", "query", ",", "*", "*", "kwargs", ")", "if", "len", "(", "result...
Perform a find, with the same options present, but only return a maximum of one result. If find returns an empty array, then None is returned. If there are multiple results from find, the one returned depends on the mode parameter. If mode is FindOneMode.FIRST, then the first result is return...
[ "Perform", "a", "find", "with", "the", "same", "options", "present", "but", "only", "return", "a", "maximum", "of", "one", "result", ".", "If", "find", "returns", "an", "empty", "array", "then", "None", "is", "returned", "." ]
1d36b4977cd4140d7d24917cab2b3f82b60739c2
https://github.com/slickqa/python-client/blob/1d36b4977cd4140d7d24917cab2b3f82b60739c2/slickqa/connection.py#L127-L142
39,623
nuSTORM/gnomon
gnomon/GeneratorAction.py
lookup_cc_partner
def lookup_cc_partner(nu_pid): """Lookup the charge current partner Takes as an input neutrino nu_pid is a PDG code, then returns the charged lepton partner. So 12 (nu_e) returns 11. Keeps sign """ neutrino_type = math.fabs(nu_pid) assert neutrino_type in [12, 14, 16] cc_partner = neutr...
python
def lookup_cc_partner(nu_pid): """Lookup the charge current partner Takes as an input neutrino nu_pid is a PDG code, then returns the charged lepton partner. So 12 (nu_e) returns 11. Keeps sign """ neutrino_type = math.fabs(nu_pid) assert neutrino_type in [12, 14, 16] cc_partner = neutr...
[ "def", "lookup_cc_partner", "(", "nu_pid", ")", ":", "neutrino_type", "=", "math", ".", "fabs", "(", "nu_pid", ")", "assert", "neutrino_type", "in", "[", "12", ",", "14", ",", "16", "]", "cc_partner", "=", "neutrino_type", "-", "1", "# get e, mu, tau", "cc...
Lookup the charge current partner Takes as an input neutrino nu_pid is a PDG code, then returns the charged lepton partner. So 12 (nu_e) returns 11. Keeps sign
[ "Lookup", "the", "charge", "current", "partner" ]
7616486ecd6e26b76f677c380e62db1c0ade558a
https://github.com/nuSTORM/gnomon/blob/7616486ecd6e26b76f677c380e62db1c0ade558a/gnomon/GeneratorAction.py#L24-L39
39,624
chaosim/dao
dao/t/classic_utils.py
block_comment
def block_comment(solver, start, end): '''embedable block comment''' text, pos = solver.parse_state length = len(text) startlen = len(start) endlen = len(end) if pos==length: return if not text[pos:].startswith(start): return level = 1 p = pos+1 while p<length: if text[p:].starts...
python
def block_comment(solver, start, end): '''embedable block comment''' text, pos = solver.parse_state length = len(text) startlen = len(start) endlen = len(end) if pos==length: return if not text[pos:].startswith(start): return level = 1 p = pos+1 while p<length: if text[p:].starts...
[ "def", "block_comment", "(", "solver", ",", "start", ",", "end", ")", ":", "text", ",", "pos", "=", "solver", ".", "parse_state", "length", "=", "len", "(", "text", ")", "startlen", "=", "len", "(", "start", ")", "endlen", "=", "len", "(", "end", "...
embedable block comment
[ "embedable", "block", "comment" ]
d7ba65c98ee063aefd1ff4eabb192d1536fdbaaa
https://github.com/chaosim/dao/blob/d7ba65c98ee063aefd1ff4eabb192d1536fdbaaa/dao/t/classic_utils.py#L242-L266
39,625
e3krisztian/pyrene
pyrene/util.py
pip_install
def pip_install(*args): ''' Run pip install ... Explicitly ignores user's config. ''' pip_cmd = os.path.join(os.path.dirname(sys.executable), 'pip') with set_env('PIP_CONFIG_FILE', os.devnull): cmd = [pip_cmd, 'install'] + list(args) print_command(cmd) subprocess.call(cm...
python
def pip_install(*args): ''' Run pip install ... Explicitly ignores user's config. ''' pip_cmd = os.path.join(os.path.dirname(sys.executable), 'pip') with set_env('PIP_CONFIG_FILE', os.devnull): cmd = [pip_cmd, 'install'] + list(args) print_command(cmd) subprocess.call(cm...
[ "def", "pip_install", "(", "*", "args", ")", ":", "pip_cmd", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "sys", ".", "executable", ")", ",", "'pip'", ")", "with", "set_env", "(", "'PIP_CONFIG_FILE'", ",", "os", ...
Run pip install ... Explicitly ignores user's config.
[ "Run", "pip", "install", "..." ]
ad9f2fb979f06930399c9c8214c3fe3c2d6efa06
https://github.com/e3krisztian/pyrene/blob/ad9f2fb979f06930399c9c8214c3fe3c2d6efa06/pyrene/util.py#L49-L59
39,626
inveniosoftware-attic/invenio-utils
invenio_utils/text.py
indent_text
def indent_text(text, nb_tabs=0, tab_str=" ", linebreak_input="\n", linebreak_output="\n", wrap=False): r"""Add tabs to each line of text. :param text: the text to indent :param nb_tabs: number of tabs to add :param tab_st...
python
def indent_text(text, nb_tabs=0, tab_str=" ", linebreak_input="\n", linebreak_output="\n", wrap=False): r"""Add tabs to each line of text. :param text: the text to indent :param nb_tabs: number of tabs to add :param tab_st...
[ "def", "indent_text", "(", "text", ",", "nb_tabs", "=", "0", ",", "tab_str", "=", "\" \"", ",", "linebreak_input", "=", "\"\\n\"", ",", "linebreak_output", "=", "\"\\n\"", ",", "wrap", "=", "False", ")", ":", "if", "not", "wrap", ":", "lines", "=", "t...
r"""Add tabs to each line of text. :param text: the text to indent :param nb_tabs: number of tabs to add :param tab_str: type of tab (could be, for example "\t", default: 2 spaces :param linebreak_input: linebreak on input :param linebreak_output: linebreak on output :param wrap: wethever to ap...
[ "r", "Add", "tabs", "to", "each", "line", "of", "text", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/text.py#L149-L175
39,627
inveniosoftware-attic/invenio-utils
invenio_utils/text.py
wait_for_user
def wait_for_user(msg=""): """ Print MSG and a confirmation prompt. Waiting for user's confirmation, unless silent '--yes-i-know' command line option was used, in which case the function returns immediately without printing anything. """ if '--yes-i-know' in sys.argv: return pri...
python
def wait_for_user(msg=""): """ Print MSG and a confirmation prompt. Waiting for user's confirmation, unless silent '--yes-i-know' command line option was used, in which case the function returns immediately without printing anything. """ if '--yes-i-know' in sys.argv: return pri...
[ "def", "wait_for_user", "(", "msg", "=", "\"\"", ")", ":", "if", "'--yes-i-know'", "in", "sys", ".", "argv", ":", "return", "print", "(", "msg", ")", "try", ":", "answer", "=", "raw_input", "(", "\"Please confirm by typing 'Yes, I know!': \"", ")", "except", ...
Print MSG and a confirmation prompt. Waiting for user's confirmation, unless silent '--yes-i-know' command line option was used, in which case the function returns immediately without printing anything.
[ "Print", "MSG", "and", "a", "confirmation", "prompt", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/text.py#L325-L344
39,628
inveniosoftware-attic/invenio-utils
invenio_utils/text.py
guess_minimum_encoding
def guess_minimum_encoding(text, charsets=('ascii', 'latin1', 'utf8')): """Try to guess the minimum charset that is able to represent. Try to guess the minimum charset that is able to represent the given text using the provided charsets. text is supposed to be encoded in utf8. Returns (encoded_text, ch...
python
def guess_minimum_encoding(text, charsets=('ascii', 'latin1', 'utf8')): """Try to guess the minimum charset that is able to represent. Try to guess the minimum charset that is able to represent the given text using the provided charsets. text is supposed to be encoded in utf8. Returns (encoded_text, ch...
[ "def", "guess_minimum_encoding", "(", "text", ",", "charsets", "=", "(", "'ascii'", ",", "'latin1'", ",", "'utf8'", ")", ")", ":", "text_in_unicode", "=", "text", ".", "decode", "(", "'utf8'", ",", "'replace'", ")", "for", "charset", "in", "charsets", ":",...
Try to guess the minimum charset that is able to represent. Try to guess the minimum charset that is able to represent the given text using the provided charsets. text is supposed to be encoded in utf8. Returns (encoded_text, charset) where charset is the first charset in the sequence being able to enc...
[ "Try", "to", "guess", "the", "minimum", "charset", "that", "is", "able", "to", "represent", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/text.py#L347-L365
39,629
inveniosoftware-attic/invenio-utils
invenio_utils/text.py
encode_for_xml
def encode_for_xml(text, wash=False, xml_version='1.0', quote=False): """Encode special characters in a text so that it would be XML-compliant. :param text: text to encode :return: an encoded text """ text = text.replace('&', '&amp;') text = text.replace('<', '&lt;') if quote: text ...
python
def encode_for_xml(text, wash=False, xml_version='1.0', quote=False): """Encode special characters in a text so that it would be XML-compliant. :param text: text to encode :return: an encoded text """ text = text.replace('&', '&amp;') text = text.replace('<', '&lt;') if quote: text ...
[ "def", "encode_for_xml", "(", "text", ",", "wash", "=", "False", ",", "xml_version", "=", "'1.0'", ",", "quote", "=", "False", ")", ":", "text", "=", "text", ".", "replace", "(", "'&'", ",", "'&amp;'", ")", "text", "=", "text", ".", "replace", "(", ...
Encode special characters in a text so that it would be XML-compliant. :param text: text to encode :return: an encoded text
[ "Encode", "special", "characters", "in", "a", "text", "so", "that", "it", "would", "be", "XML", "-", "compliant", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/text.py#L368-L380
39,630
inveniosoftware-attic/invenio-utils
invenio_utils/text.py
wash_for_xml
def wash_for_xml(text, xml_version='1.0'): """Remove any character which isn't a allowed characters for XML. The allowed characters depends on the version of XML. - XML 1.0: <http://www.w3.org/TR/REC-xml/#charsets> - XML 1.1: <http://www.w3.org/TR/xml11/#charsets> ...
python
def wash_for_xml(text, xml_version='1.0'): """Remove any character which isn't a allowed characters for XML. The allowed characters depends on the version of XML. - XML 1.0: <http://www.w3.org/TR/REC-xml/#charsets> - XML 1.1: <http://www.w3.org/TR/xml11/#charsets> ...
[ "def", "wash_for_xml", "(", "text", ",", "xml_version", "=", "'1.0'", ")", ":", "if", "xml_version", "==", "'1.0'", ":", "return", "RE_ALLOWED_XML_1_0_CHARS", ".", "sub", "(", "''", ",", "unicode", "(", "text", ",", "'utf-8'", ")", ")", ".", "encode", "(...
Remove any character which isn't a allowed characters for XML. The allowed characters depends on the version of XML. - XML 1.0: <http://www.w3.org/TR/REC-xml/#charsets> - XML 1.1: <http://www.w3.org/TR/xml11/#charsets> :param text: input string to wash. :param ...
[ "Remove", "any", "character", "which", "isn", "t", "a", "allowed", "characters", "for", "XML", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/text.py#L399-L419
39,631
inveniosoftware-attic/invenio-utils
invenio_utils/text.py
wash_for_utf8
def wash_for_utf8(text, correct=True): """Return UTF-8 encoded binary string with incorrect characters washed away. :param text: input string to wash (can be either a binary or Unicode string) :param correct: whether to correct bad characters or throw exception """ if isinstance(text, unicode): ...
python
def wash_for_utf8(text, correct=True): """Return UTF-8 encoded binary string with incorrect characters washed away. :param text: input string to wash (can be either a binary or Unicode string) :param correct: whether to correct bad characters or throw exception """ if isinstance(text, unicode): ...
[ "def", "wash_for_utf8", "(", "text", ",", "correct", "=", "True", ")", ":", "if", "isinstance", "(", "text", ",", "unicode", ")", ":", "return", "text", ".", "encode", "(", "'utf-8'", ")", "errors", "=", "\"ignore\"", "if", "correct", "else", "\"strict\"...
Return UTF-8 encoded binary string with incorrect characters washed away. :param text: input string to wash (can be either a binary or Unicode string) :param correct: whether to correct bad characters or throw exception
[ "Return", "UTF", "-", "8", "encoded", "binary", "string", "with", "incorrect", "characters", "washed", "away", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/text.py#L422-L432
39,632
inveniosoftware-attic/invenio-utils
invenio_utils/text.py
nice_number
def nice_number(number, thousands_separator=',', max_ndigits_after_dot=None): """Return nicely printed number NUMBER in language LN. Return nicely printed number NUMBER in language LN using given THOUSANDS_SEPARATOR character. If max_ndigits_after_dot is specified and the number is float, the numbe...
python
def nice_number(number, thousands_separator=',', max_ndigits_after_dot=None): """Return nicely printed number NUMBER in language LN. Return nicely printed number NUMBER in language LN using given THOUSANDS_SEPARATOR character. If max_ndigits_after_dot is specified and the number is float, the numbe...
[ "def", "nice_number", "(", "number", ",", "thousands_separator", "=", "','", ",", "max_ndigits_after_dot", "=", "None", ")", ":", "if", "isinstance", "(", "number", ",", "float", ")", ":", "if", "max_ndigits_after_dot", "is", "not", "None", ":", "number", "=...
Return nicely printed number NUMBER in language LN. Return nicely printed number NUMBER in language LN using given THOUSANDS_SEPARATOR character. If max_ndigits_after_dot is specified and the number is float, the number is rounded by taking in consideration up to max_ndigits_after_dot digit after t...
[ "Return", "nicely", "printed", "number", "NUMBER", "in", "language", "LN", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/text.py#L435-L462
39,633
inveniosoftware-attic/invenio-utils
invenio_utils/text.py
nice_size
def nice_size(size): """Nice size. :param size: the size. :type size: int :return: a nicely printed size. :rtype: string """ unit = 'B' if size > 1024: size /= 1024.0 unit = 'KB' if size > 1024: size /= 1024.0 unit = 'MB' if si...
python
def nice_size(size): """Nice size. :param size: the size. :type size: int :return: a nicely printed size. :rtype: string """ unit = 'B' if size > 1024: size /= 1024.0 unit = 'KB' if size > 1024: size /= 1024.0 unit = 'MB' if si...
[ "def", "nice_size", "(", "size", ")", ":", "unit", "=", "'B'", "if", "size", ">", "1024", ":", "size", "/=", "1024.0", "unit", "=", "'KB'", "if", "size", ">", "1024", ":", "size", "/=", "1024.0", "unit", "=", "'MB'", "if", "size", ">", "1024", ":...
Nice size. :param size: the size. :type size: int :return: a nicely printed size. :rtype: string
[ "Nice", "size", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/text.py#L465-L483
39,634
inveniosoftware-attic/invenio-utils
invenio_utils/text.py
remove_line_breaks
def remove_line_breaks(text): """Remove line breaks from input. Including unicode 'line separator', 'paragraph separator', and 'next line' characters. """ return unicode(text, 'utf-8').replace('\f', '').replace('\n', '') \ .replace('\r', '').replace(u'\xe2\x80\xa8', '') \ .replace(u...
python
def remove_line_breaks(text): """Remove line breaks from input. Including unicode 'line separator', 'paragraph separator', and 'next line' characters. """ return unicode(text, 'utf-8').replace('\f', '').replace('\n', '') \ .replace('\r', '').replace(u'\xe2\x80\xa8', '') \ .replace(u...
[ "def", "remove_line_breaks", "(", "text", ")", ":", "return", "unicode", "(", "text", ",", "'utf-8'", ")", ".", "replace", "(", "'\\f'", ",", "''", ")", ".", "replace", "(", "'\\n'", ",", "''", ")", ".", "replace", "(", "'\\r'", ",", "''", ")", "."...
Remove line breaks from input. Including unicode 'line separator', 'paragraph separator', and 'next line' characters.
[ "Remove", "line", "breaks", "from", "input", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/text.py#L486-L495
39,635
inveniosoftware-attic/invenio-utils
invenio_utils/text.py
decode_to_unicode
def decode_to_unicode(text, default_encoding='utf-8'): """Decode input text into Unicode representation. Decode input text into Unicode representation by first using the default encoding utf-8. If the operation fails, it detects the type of encoding used in the given text. For optimal result, i...
python
def decode_to_unicode(text, default_encoding='utf-8'): """Decode input text into Unicode representation. Decode input text into Unicode representation by first using the default encoding utf-8. If the operation fails, it detects the type of encoding used in the given text. For optimal result, i...
[ "def", "decode_to_unicode", "(", "text", ",", "default_encoding", "=", "'utf-8'", ")", ":", "if", "not", "text", ":", "return", "\"\"", "try", ":", "return", "text", ".", "decode", "(", "default_encoding", ")", "except", "(", "UnicodeError", ",", "LookupErro...
Decode input text into Unicode representation. Decode input text into Unicode representation by first using the default encoding utf-8. If the operation fails, it detects the type of encoding used in the given text. For optimal result, it is recommended that the 'chardet' module is installed. ...
[ "Decode", "input", "text", "into", "Unicode", "representation", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/text.py#L498-L541
39,636
inveniosoftware-attic/invenio-utils
invenio_utils/text.py
to_unicode
def to_unicode(text): """Convert to unicode.""" if isinstance(text, unicode): return text if isinstance(text, six.string_types): return decode_to_unicode(text) return unicode(text)
python
def to_unicode(text): """Convert to unicode.""" if isinstance(text, unicode): return text if isinstance(text, six.string_types): return decode_to_unicode(text) return unicode(text)
[ "def", "to_unicode", "(", "text", ")", ":", "if", "isinstance", "(", "text", ",", "unicode", ")", ":", "return", "text", "if", "isinstance", "(", "text", ",", "six", ".", "string_types", ")", ":", "return", "decode_to_unicode", "(", "text", ")", "return"...
Convert to unicode.
[ "Convert", "to", "unicode", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/text.py#L544-L550
39,637
inveniosoftware-attic/invenio-utils
invenio_utils/text.py
translate_latex2unicode
def translate_latex2unicode(text, kb_file=None): """Translate latex text to unicode. This function will take given text, presumably containing LaTeX symbols, and attempts to translate it to Unicode using the given or default KB translation table located under CFG_ETCDIR/bibconvert/KB/latex-to-unico...
python
def translate_latex2unicode(text, kb_file=None): """Translate latex text to unicode. This function will take given text, presumably containing LaTeX symbols, and attempts to translate it to Unicode using the given or default KB translation table located under CFG_ETCDIR/bibconvert/KB/latex-to-unico...
[ "def", "translate_latex2unicode", "(", "text", ",", "kb_file", "=", "None", ")", ":", "if", "kb_file", "is", "None", ":", "kb_file", "=", "get_kb_filename", "(", ")", "# First decode input text to Unicode", "try", ":", "text", "=", "decode_to_unicode", "(", "tex...
Translate latex text to unicode. This function will take given text, presumably containing LaTeX symbols, and attempts to translate it to Unicode using the given or default KB translation table located under CFG_ETCDIR/bibconvert/KB/latex-to-unicode.kb. The translated Unicode string will then be re...
[ "Translate", "latex", "text", "to", "unicode", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/text.py#L553-L595
39,638
inveniosoftware-attic/invenio-utils
invenio_utils/text.py
_load_latex2unicode_constants
def _load_latex2unicode_constants(kb_file=None): """Load LaTeX2Unicode translation table dictionary. Load LaTeX2Unicode translation table dictionary and regular expression object from KB to a global dictionary. :param kb_file: full path to file containing latex2unicode translations. ...
python
def _load_latex2unicode_constants(kb_file=None): """Load LaTeX2Unicode translation table dictionary. Load LaTeX2Unicode translation table dictionary and regular expression object from KB to a global dictionary. :param kb_file: full path to file containing latex2unicode translations. ...
[ "def", "_load_latex2unicode_constants", "(", "kb_file", "=", "None", ")", ":", "if", "kb_file", "is", "None", ":", "kb_file", "=", "get_kb_filename", "(", ")", "try", ":", "data", "=", "open", "(", "kb_file", ")", "except", "IOError", ":", "# File not found ...
Load LaTeX2Unicode translation table dictionary. Load LaTeX2Unicode translation table dictionary and regular expression object from KB to a global dictionary. :param kb_file: full path to file containing latex2unicode translations. Defaults to CFG_ETCDIR/bibconvert/KB/latex-to-unicode....
[ "Load", "LaTeX2Unicode", "translation", "table", "dictionary", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/text.py#L598-L634
39,639
inveniosoftware-attic/invenio-utils
invenio_utils/text.py
translate_to_ascii
def translate_to_ascii(values): r"""Transliterate the string into ascii representation. Transliterate the string contents of the given sequence into ascii representation. Returns a sequence with the modified values if the module 'unidecode' is available. Otherwise it will fall back to the inferior ...
python
def translate_to_ascii(values): r"""Transliterate the string into ascii representation. Transliterate the string contents of the given sequence into ascii representation. Returns a sequence with the modified values if the module 'unidecode' is available. Otherwise it will fall back to the inferior ...
[ "def", "translate_to_ascii", "(", "values", ")", ":", "if", "not", "values", "and", "not", "isinstance", "(", "values", ",", "str", ")", ":", "return", "values", "if", "isinstance", "(", "values", ",", "str", ")", ":", "values", "=", "[", "values", "]"...
r"""Transliterate the string into ascii representation. Transliterate the string contents of the given sequence into ascii representation. Returns a sequence with the modified values if the module 'unidecode' is available. Otherwise it will fall back to the inferior strip_accents function. For...
[ "r", "Transliterate", "the", "string", "into", "ascii", "representation", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/text.py#L637-L677
39,640
inveniosoftware-attic/invenio-utils
invenio_utils/text.py
xml_entities_to_utf8
def xml_entities_to_utf8(text, skip=('lt', 'gt', 'amp')): """Translate HTML or XML character references to UTF-8. Removes HTML or XML character references and entities from a text string and replaces them with their UTF-8 representation, if possible. :param text: The HTML (or XML) source text. :ty...
python
def xml_entities_to_utf8(text, skip=('lt', 'gt', 'amp')): """Translate HTML or XML character references to UTF-8. Removes HTML or XML character references and entities from a text string and replaces them with their UTF-8 representation, if possible. :param text: The HTML (or XML) source text. :ty...
[ "def", "xml_entities_to_utf8", "(", "text", ",", "skip", "=", "(", "'lt'", ",", "'gt'", ",", "'amp'", ")", ")", ":", "def", "fixup", "(", "m", ")", ":", "text", "=", "m", ".", "group", "(", "0", ")", "if", "text", "[", ":", "2", "]", "==", "\...
Translate HTML or XML character references to UTF-8. Removes HTML or XML character references and entities from a text string and replaces them with their UTF-8 representation, if possible. :param text: The HTML (or XML) source text. :type text: string :param skip: list of entity names to skip wh...
[ "Translate", "HTML", "or", "XML", "character", "references", "to", "UTF", "-", "8", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/text.py#L680-L716
39,641
inveniosoftware-attic/invenio-utils
invenio_utils/text.py
strip_accents
def strip_accents(x): u"""Strip accents in the input phrase X. Strip accents in the input phrase X (assumed in UTF-8) by replacing accented characters with their unaccented cousins (e.g. é by e). :param x: the input phrase to strip. :type x: string :return: Return such a stripped X. """ ...
python
def strip_accents(x): u"""Strip accents in the input phrase X. Strip accents in the input phrase X (assumed in UTF-8) by replacing accented characters with their unaccented cousins (e.g. é by e). :param x: the input phrase to strip. :type x: string :return: Return such a stripped X. """ ...
[ "def", "strip_accents", "(", "x", ")", ":", "x", "=", "re_latex_lowercase_a", ".", "sub", "(", "\"a\"", ",", "x", ")", "x", "=", "re_latex_lowercase_ae", ".", "sub", "(", "\"ae\"", ",", "x", ")", "x", "=", "re_latex_lowercase_oe", ".", "sub", "(", "\"o...
u"""Strip accents in the input phrase X. Strip accents in the input phrase X (assumed in UTF-8) by replacing accented characters with their unaccented cousins (e.g. é by e). :param x: the input phrase to strip. :type x: string :return: Return such a stripped X.
[ "u", "Strip", "accents", "in", "the", "input", "phrase", "X", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/text.py#L719-L780
39,642
inveniosoftware-attic/invenio-utils
invenio_utils/text.py
show_diff
def show_diff(original, modified, prefix='', suffix='', prefix_unchanged=' ', suffix_unchanged='', prefix_removed='-', suffix_removed='', prefix_added='+', suffix_added=''): """Return the diff view between original and modified stri...
python
def show_diff(original, modified, prefix='', suffix='', prefix_unchanged=' ', suffix_unchanged='', prefix_removed='-', suffix_removed='', prefix_added='+', suffix_added=''): """Return the diff view between original and modified stri...
[ "def", "show_diff", "(", "original", ",", "modified", ",", "prefix", "=", "''", ",", "suffix", "=", "''", ",", "prefix_unchanged", "=", "' '", ",", "suffix_unchanged", "=", "''", ",", "prefix_removed", "=", "'-'", ",", "suffix_removed", "=", "''", ",", "...
Return the diff view between original and modified strings. Function checks both arguments line by line and returns a string with a: - prefix_unchanged when line is common to both sequences - prefix_removed when line is unique to sequence 1 - prefix_added when line is unique to sequence 2 and a...
[ "Return", "the", "diff", "view", "between", "original", "and", "modified", "strings", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/text.py#L793-L839
39,643
inveniosoftware-attic/invenio-utils
invenio_utils/text.py
escape_latex
def escape_latex(text): r"""Escape characters of given text. This function takes the given text and escapes characters that have a special meaning in LaTeX: # $ % ^ & _ { } ~ \ """ text = unicode(text.decode('utf-8')) CHARS = { '&': r'\&', '%': r'\%', '$': r'\$', ...
python
def escape_latex(text): r"""Escape characters of given text. This function takes the given text and escapes characters that have a special meaning in LaTeX: # $ % ^ & _ { } ~ \ """ text = unicode(text.decode('utf-8')) CHARS = { '&': r'\&', '%': r'\%', '$': r'\$', ...
[ "def", "escape_latex", "(", "text", ")", ":", "text", "=", "unicode", "(", "text", ".", "decode", "(", "'utf-8'", ")", ")", "CHARS", "=", "{", "'&'", ":", "r'\\&'", ",", "'%'", ":", "r'\\%'", ",", "'$'", ":", "r'\\$'", ",", "'#'", ":", "r'\\#'", ...
r"""Escape characters of given text. This function takes the given text and escapes characters that have a special meaning in LaTeX: # $ % ^ & _ { } ~ \
[ "r", "Escape", "characters", "of", "given", "text", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/text.py#L863-L883
39,644
trevisanj/f311
f311/filetypes/filepy.py
FilePy._copy_attr
def _copy_attr(self, module, varname, cls, attrname=None): """ Copies attribute from module object to self. Raises if object not of expected class Args: module: module object varname: variable name cls: expected class of variable attrname: attribu...
python
def _copy_attr(self, module, varname, cls, attrname=None): """ Copies attribute from module object to self. Raises if object not of expected class Args: module: module object varname: variable name cls: expected class of variable attrname: attribu...
[ "def", "_copy_attr", "(", "self", ",", "module", ",", "varname", ",", "cls", ",", "attrname", "=", "None", ")", ":", "if", "not", "hasattr", "(", "module", ",", "varname", ")", ":", "raise", "RuntimeError", "(", "\"Variable '{}' not found\"", ".", "format"...
Copies attribute from module object to self. Raises if object not of expected class Args: module: module object varname: variable name cls: expected class of variable attrname: attribute name of self. Falls back to varname
[ "Copies", "attribute", "from", "module", "object", "to", "self", ".", "Raises", "if", "object", "not", "of", "expected", "class" ]
9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7
https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/filetypes/filepy.py#L49-L72
39,645
dsoprea/PathScan
fss/workers/generator.py
GeneratorWorker.__check_to_permit
def __check_to_permit(self, entry_type, entry_filename): """Applying the filter rules.""" rules = self.__filter_rules[entry_type] # Should explicitly include? for pattern in rules[fss.constants.FILTER_INCLUDE]: if fnmatch.fnmatch(entry_filename, pattern): _L...
python
def __check_to_permit(self, entry_type, entry_filename): """Applying the filter rules.""" rules = self.__filter_rules[entry_type] # Should explicitly include? for pattern in rules[fss.constants.FILTER_INCLUDE]: if fnmatch.fnmatch(entry_filename, pattern): _L...
[ "def", "__check_to_permit", "(", "self", ",", "entry_type", ",", "entry_filename", ")", ":", "rules", "=", "self", ".", "__filter_rules", "[", "entry_type", "]", "# Should explicitly include?", "for", "pattern", "in", "rules", "[", "fss", ".", "constants", ".", ...
Applying the filter rules.
[ "Applying", "the", "filter", "rules", "." ]
1195a94f3b14c202ddf3e593630be5556e974dd1
https://github.com/dsoprea/PathScan/blob/1195a94f3b14c202ddf3e593630be5556e974dd1/fss/workers/generator.py#L85-L113
39,646
micha030201/aionationstates
aionationstates/shared.py
Census.census
def census(self, *scales): """Current World Census data. By default returns data on today's featured World Census scale, use arguments to get results on specific scales. In order to request data on all scales at once you can do ``x.census(*range(81))``. Parameters ...
python
def census(self, *scales): """Current World Census data. By default returns data on today's featured World Census scale, use arguments to get results on specific scales. In order to request data on all scales at once you can do ``x.census(*range(81))``. Parameters ...
[ "def", "census", "(", "self", ",", "*", "scales", ")", ":", "params", "=", "{", "'mode'", ":", "'score+rank+rrank+prank+prrank'", "}", "if", "scales", ":", "params", "[", "'scale'", "]", "=", "'+'", ".", "join", "(", "str", "(", "x", ")", "for", "x",...
Current World Census data. By default returns data on today's featured World Census scale, use arguments to get results on specific scales. In order to request data on all scales at once you can do ``x.census(*range(81))``. Parameters ---------- scales : int ...
[ "Current", "World", "Census", "data", "." ]
dc86b86d994cbab830b69ab8023601c73e778b3a
https://github.com/micha030201/aionationstates/blob/dc86b86d994cbab830b69ab8023601c73e778b3a/aionationstates/shared.py#L271-L298
39,647
micha030201/aionationstates
aionationstates/shared.py
Census.censushistory
def censushistory(self, *scales): """Historical World Census data. Was split into its own method for the sake of simplicity. By default returns data on today's featured World Census scale, use arguments to get results on specific scales. In order to request data on all scales ...
python
def censushistory(self, *scales): """Historical World Census data. Was split into its own method for the sake of simplicity. By default returns data on today's featured World Census scale, use arguments to get results on specific scales. In order to request data on all scales ...
[ "def", "censushistory", "(", "self", ",", "*", "scales", ")", ":", "params", "=", "{", "'mode'", ":", "'history'", "}", "if", "scales", ":", "params", "[", "'scale'", "]", "=", "'+'", ".", "join", "(", "str", "(", "x", ")", "for", "x", "in", "sca...
Historical World Census data. Was split into its own method for the sake of simplicity. By default returns data on today's featured World Census scale, use arguments to get results on specific scales. In order to request data on all scales at once you can do ``x.censushistory(...
[ "Historical", "World", "Census", "data", "." ]
dc86b86d994cbab830b69ab8023601c73e778b3a
https://github.com/micha030201/aionationstates/blob/dc86b86d994cbab830b69ab8023601c73e778b3a/aionationstates/shared.py#L300-L332
39,648
micha030201/aionationstates
aionationstates/shared.py
CensusRanks.censusranks
async def censusranks(self, scale): """Iterate through nations ranked on the World Census scale. If the ranks change while you interate over them, they may be inconsistent. Parameters ---------- scale : int A World Census scale, an integer between 0 and 85 i...
python
async def censusranks(self, scale): """Iterate through nations ranked on the World Census scale. If the ranks change while you interate over them, they may be inconsistent. Parameters ---------- scale : int A World Census scale, an integer between 0 and 85 i...
[ "async", "def", "censusranks", "(", "self", ",", "scale", ")", ":", "order", "=", "count", "(", "1", ")", "for", "offset", "in", "count", "(", "1", ",", "20", ")", ":", "census_ranks", "=", "await", "self", ".", "_get_censusranks", "(", "scale", "=",...
Iterate through nations ranked on the World Census scale. If the ranks change while you interate over them, they may be inconsistent. Parameters ---------- scale : int A World Census scale, an integer between 0 and 85 inclusive. Returns ------- ...
[ "Iterate", "through", "nations", "ranked", "on", "the", "World", "Census", "scale", "." ]
dc86b86d994cbab830b69ab8023601c73e778b3a
https://github.com/micha030201/aionationstates/blob/dc86b86d994cbab830b69ab8023601c73e778b3a/aionationstates/shared.py#L433-L456
39,649
inveniosoftware-attic/invenio-utils
invenio_utils/serializers.py
ZlibMarshal.loads
def loads(astring): """Decompress and deserialize string into Python object via marshal.""" try: return marshal.loads(zlib.decompress(astring)) except zlib.error as e: raise SerializerError( 'Cannot decompress object ("{}")'.format(str(e)) ) ...
python
def loads(astring): """Decompress and deserialize string into Python object via marshal.""" try: return marshal.loads(zlib.decompress(astring)) except zlib.error as e: raise SerializerError( 'Cannot decompress object ("{}")'.format(str(e)) ) ...
[ "def", "loads", "(", "astring", ")", ":", "try", ":", "return", "marshal", ".", "loads", "(", "zlib", ".", "decompress", "(", "astring", ")", ")", "except", "zlib", ".", "error", "as", "e", ":", "raise", "SerializerError", "(", "'Cannot decompress object (...
Decompress and deserialize string into Python object via marshal.
[ "Decompress", "and", "deserialize", "string", "into", "Python", "object", "via", "marshal", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/serializers.py#L48-L60
39,650
inveniosoftware-attic/invenio-utils
invenio_utils/serializers.py
ZlibPickle.loads
def loads(astring): """Decompress and deserialize string into Python object via pickle.""" try: return pickle.loads(zlib.decompress(astring)) except zlib.error as e: raise SerializerError( 'Cannot decompress object ("{}")'.format(str(e)) ) ...
python
def loads(astring): """Decompress and deserialize string into Python object via pickle.""" try: return pickle.loads(zlib.decompress(astring)) except zlib.error as e: raise SerializerError( 'Cannot decompress object ("{}")'.format(str(e)) ) ...
[ "def", "loads", "(", "astring", ")", ":", "try", ":", "return", "pickle", ".", "loads", "(", "zlib", ".", "decompress", "(", "astring", ")", ")", "except", "zlib", ".", "error", "as", "e", ":", "raise", "SerializerError", "(", "'Cannot decompress object (\...
Decompress and deserialize string into Python object via pickle.
[ "Decompress", "and", "deserialize", "string", "into", "Python", "object", "via", "pickle", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/serializers.py#L77-L88
39,651
inveniosoftware-attic/invenio-utils
invenio_utils/serializers.py
LzmaPickle.loads
def loads(astring): """Decompress and deserialize string into a Python object via pickle.""" try: return pickle.loads(lzma.decompress(astring)) except lzma.LZMAError as e: raise SerializerError( 'Cannot decompress object ("{}")'.format(str(e)) ...
python
def loads(astring): """Decompress and deserialize string into a Python object via pickle.""" try: return pickle.loads(lzma.decompress(astring)) except lzma.LZMAError as e: raise SerializerError( 'Cannot decompress object ("{}")'.format(str(e)) ...
[ "def", "loads", "(", "astring", ")", ":", "try", ":", "return", "pickle", ".", "loads", "(", "lzma", ".", "decompress", "(", "astring", ")", ")", "except", "lzma", ".", "LZMAError", "as", "e", ":", "raise", "SerializerError", "(", "'Cannot decompress objec...
Decompress and deserialize string into a Python object via pickle.
[ "Decompress", "and", "deserialize", "string", "into", "a", "Python", "object", "via", "pickle", "." ]
9a1c6db4e3f1370901f329f510480dd8df188296
https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/serializers.py#L105-L116
39,652
flashashen/flange
flange/data.py
Data.search
def search(self, path_expression, mode=UXP, values=None, ifunc=lambda x: x): """ find matches for the given path expression in the data :param path_expression: path tuple or string :return: """ # keys = path_expression if isinstance(path_expression, six.string_types) els...
python
def search(self, path_expression, mode=UXP, values=None, ifunc=lambda x: x): """ find matches for the given path expression in the data :param path_expression: path tuple or string :return: """ # keys = path_expression if isinstance(path_expression, six.string_types) els...
[ "def", "search", "(", "self", ",", "path_expression", ",", "mode", "=", "UXP", ",", "values", "=", "None", ",", "ifunc", "=", "lambda", "x", ":", "x", ")", ":", "# keys = path_expression if isinstance(path_expression, six.string_types) else path_expression[-1]", "path...
find matches for the given path expression in the data :param path_expression: path tuple or string :return:
[ "find", "matches", "for", "the", "given", "path", "expression", "in", "the", "data" ]
67ebaf70e39887f65ce1163168d182a8e4c2774a
https://github.com/flashashen/flange/blob/67ebaf70e39887f65ce1163168d182a8e4c2774a/flange/data.py#L37-L52
39,653
flashashen/flange
flange/data.py
Data.__visit_index_path
def __visit_index_path(self, src, p, k, v): """ Called during processing of source data """ cp = p + (k,) self.path_index[cp] = self.indexed_obj_factory(p, k, v, self.path_index.get(cp)) if cp in self.path_index: # if self.path_index[cp].assert_val_equals(...
python
def __visit_index_path(self, src, p, k, v): """ Called during processing of source data """ cp = p + (k,) self.path_index[cp] = self.indexed_obj_factory(p, k, v, self.path_index.get(cp)) if cp in self.path_index: # if self.path_index[cp].assert_val_equals(...
[ "def", "__visit_index_path", "(", "self", ",", "src", ",", "p", ",", "k", ",", "v", ")", ":", "cp", "=", "p", "+", "(", "k", ",", ")", "self", ".", "path_index", "[", "cp", "]", "=", "self", ".", "indexed_obj_factory", "(", "p", ",", "k", ",", ...
Called during processing of source data
[ "Called", "during", "processing", "of", "source", "data" ]
67ebaf70e39887f65ce1163168d182a8e4c2774a
https://github.com/flashashen/flange/blob/67ebaf70e39887f65ce1163168d182a8e4c2774a/flange/data.py#L72-L83
39,654
trevisanj/f311
f311/pathfinder.py
get_default_data_path
def get_default_data_path(*args, module=None, class_=None, flag_raise=True): """ Returns path to default data directory Arguments 'module' and 'class' give the chance to return path relative to package other than f311.filetypes Args: module: Python module object. It is expected that this m...
python
def get_default_data_path(*args, module=None, class_=None, flag_raise=True): """ Returns path to default data directory Arguments 'module' and 'class' give the chance to return path relative to package other than f311.filetypes Args: module: Python module object. It is expected that this m...
[ "def", "get_default_data_path", "(", "*", "args", ",", "module", "=", "None", ",", "class_", "=", "None", ",", "flag_raise", "=", "True", ")", ":", "if", "module", "is", "None", ":", "module", "=", "__get_filetypes_module", "(", ")", "if", "class_", "is"...
Returns path to default data directory Arguments 'module' and 'class' give the chance to return path relative to package other than f311.filetypes Args: module: Python module object. It is expected that this module has a sub-subdirectory named 'data/default' class_: Python ...
[ "Returns", "path", "to", "default", "data", "directory" ]
9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7
https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/pathfinder.py#L8-L43
39,655
trevisanj/f311
f311/pathfinder.py
copy_default_data_file
def copy_default_data_file(filename, module=None): """Copies file from default data directory to local directory.""" if module is None: module = __get_filetypes_module() fullpath = get_default_data_path(filename, module=module) shutil.copy(fullpath, ".")
python
def copy_default_data_file(filename, module=None): """Copies file from default data directory to local directory.""" if module is None: module = __get_filetypes_module() fullpath = get_default_data_path(filename, module=module) shutil.copy(fullpath, ".")
[ "def", "copy_default_data_file", "(", "filename", ",", "module", "=", "None", ")", ":", "if", "module", "is", "None", ":", "module", "=", "__get_filetypes_module", "(", ")", "fullpath", "=", "get_default_data_path", "(", "filename", ",", "module", "=", "module...
Copies file from default data directory to local directory.
[ "Copies", "file", "from", "default", "data", "directory", "to", "local", "directory", "." ]
9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7
https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/pathfinder.py#L46-L51
39,656
ten10solutions/Geist
geist/backends/xvfb.py
GeistXvfbBackend._find_display
def _find_display(self): """ Find a usable display, which doesn't have an existing Xvfb file """ self.display_num = 2 while os.path.isdir(XVFB_PATH % (self.display_num,)): self.display_num += 1
python
def _find_display(self): """ Find a usable display, which doesn't have an existing Xvfb file """ self.display_num = 2 while os.path.isdir(XVFB_PATH % (self.display_num,)): self.display_num += 1
[ "def", "_find_display", "(", "self", ")", ":", "self", ".", "display_num", "=", "2", "while", "os", ".", "path", ".", "isdir", "(", "XVFB_PATH", "%", "(", "self", ".", "display_num", ",", ")", ")", ":", "self", ".", "display_num", "+=", "1" ]
Find a usable display, which doesn't have an existing Xvfb file
[ "Find", "a", "usable", "display", "which", "doesn", "t", "have", "an", "existing", "Xvfb", "file" ]
a1ef16d8b4c3777735008b671a50acfde3ce7bf1
https://github.com/ten10solutions/Geist/blob/a1ef16d8b4c3777735008b671a50acfde3ce7bf1/geist/backends/xvfb.py#L85-L91
39,657
inveniosoftware-attic/invenio-comments
invenio_comments/views.py
comments
def comments(recid): """Display comments.""" from invenio_access.local_config import VIEWRESTRCOLL from invenio_access.mailcookie import \ mail_cookie_create_authorize_action from .api import check_user_can_view_comments auth_code, auth_msg = check_user_can_view_comments(current_user, recid)...
python
def comments(recid): """Display comments.""" from invenio_access.local_config import VIEWRESTRCOLL from invenio_access.mailcookie import \ mail_cookie_create_authorize_action from .api import check_user_can_view_comments auth_code, auth_msg = check_user_can_view_comments(current_user, recid)...
[ "def", "comments", "(", "recid", ")", ":", "from", "invenio_access", ".", "local_config", "import", "VIEWRESTRCOLL", "from", "invenio_access", ".", "mailcookie", "import", "mail_cookie_create_authorize_action", "from", ".", "api", "import", "check_user_can_view_comments",...
Display comments.
[ "Display", "comments", "." ]
62bb6e07c146baf75bf8de80b5896ab2a01a8423
https://github.com/inveniosoftware-attic/invenio-comments/blob/62bb6e07c146baf75bf8de80b5896ab2a01a8423/invenio_comments/views.py#L189-L213
39,658
stxnext/mappet
mappet/mappet.py
Node.getattr
def getattr(self, key, default=None, callback=None): u"""Getting the attribute of an element. >>> xml = etree.Element('root') >>> xml.text = 'text' >>> Node(xml).getattr('text') 'text' >>> Node(xml).getattr('text', callback=str.upper) 'TEXT' >>> Node(xml)...
python
def getattr(self, key, default=None, callback=None): u"""Getting the attribute of an element. >>> xml = etree.Element('root') >>> xml.text = 'text' >>> Node(xml).getattr('text') 'text' >>> Node(xml).getattr('text', callback=str.upper) 'TEXT' >>> Node(xml)...
[ "def", "getattr", "(", "self", ",", "key", ",", "default", "=", "None", ",", "callback", "=", "None", ")", ":", "value", "=", "self", ".", "_xml", ".", "text", "if", "key", "==", "'text'", "else", "self", ".", "_xml", ".", "get", "(", "key", ",",...
u"""Getting the attribute of an element. >>> xml = etree.Element('root') >>> xml.text = 'text' >>> Node(xml).getattr('text') 'text' >>> Node(xml).getattr('text', callback=str.upper) 'TEXT' >>> Node(xml).getattr('wrong_attr', default='default') 'default'
[ "u", "Getting", "the", "attribute", "of", "an", "element", "." ]
ac7468ac28ed82e45065b1e348cf865c8f73f0db
https://github.com/stxnext/mappet/blob/ac7468ac28ed82e45065b1e348cf865c8f73f0db/mappet/mappet.py#L75-L88
39,659
stxnext/mappet
mappet/mappet.py
Node.setattr
def setattr(self, key, value): u"""Sets an attribute on a node. >>> xml = etree.Element('root') >>> Node(xml).setattr('text', 'text2') >>> Node(xml).getattr('text') 'text2' >>> Node(xml).setattr('attr', 'val') >>> Node(xml).getattr('attr') 'val' "...
python
def setattr(self, key, value): u"""Sets an attribute on a node. >>> xml = etree.Element('root') >>> Node(xml).setattr('text', 'text2') >>> Node(xml).getattr('text') 'text2' >>> Node(xml).setattr('attr', 'val') >>> Node(xml).getattr('attr') 'val' "...
[ "def", "setattr", "(", "self", ",", "key", ",", "value", ")", ":", "if", "key", "==", "'text'", ":", "self", ".", "_xml", ".", "text", "=", "str", "(", "value", ")", "else", ":", "self", ".", "_xml", ".", "set", "(", "key", ",", "str", "(", "...
u"""Sets an attribute on a node. >>> xml = etree.Element('root') >>> Node(xml).setattr('text', 'text2') >>> Node(xml).getattr('text') 'text2' >>> Node(xml).setattr('attr', 'val') >>> Node(xml).getattr('attr') 'val'
[ "u", "Sets", "an", "attribute", "on", "a", "node", "." ]
ac7468ac28ed82e45065b1e348cf865c8f73f0db
https://github.com/stxnext/mappet/blob/ac7468ac28ed82e45065b1e348cf865c8f73f0db/mappet/mappet.py#L90-L104
39,660
stxnext/mappet
mappet/mappet.py
Literal.get
def get(self, default=None, callback=None): u"""Returns leaf's value.""" value = self._xml.text if self._xml.text else default return callback(value) if callback else value
python
def get(self, default=None, callback=None): u"""Returns leaf's value.""" value = self._xml.text if self._xml.text else default return callback(value) if callback else value
[ "def", "get", "(", "self", ",", "default", "=", "None", ",", "callback", "=", "None", ")", ":", "value", "=", "self", ".", "_xml", ".", "text", "if", "self", ".", "_xml", ".", "text", "else", "default", "return", "callback", "(", "value", ")", "if"...
u"""Returns leaf's value.
[ "u", "Returns", "leaf", "s", "value", "." ]
ac7468ac28ed82e45065b1e348cf865c8f73f0db
https://github.com/stxnext/mappet/blob/ac7468ac28ed82e45065b1e348cf865c8f73f0db/mappet/mappet.py#L209-L212
39,661
stxnext/mappet
mappet/mappet.py
Mappet.to_str
def to_str(self, pretty_print=False, encoding=None, **kw): u"""Converts a node with all of it's children to a string. Remaining arguments are passed to etree.tostring as is. kwarg without_comments: bool because it works only in C14N flags: 'pretty print' and 'encoding' are ignored. ...
python
def to_str(self, pretty_print=False, encoding=None, **kw): u"""Converts a node with all of it's children to a string. Remaining arguments are passed to etree.tostring as is. kwarg without_comments: bool because it works only in C14N flags: 'pretty print' and 'encoding' are ignored. ...
[ "def", "to_str", "(", "self", ",", "pretty_print", "=", "False", ",", "encoding", "=", "None", ",", "*", "*", "kw", ")", ":", "if", "kw", ".", "get", "(", "'without_comments'", ")", "and", "not", "kw", ".", "get", "(", "'method'", ")", ":", "kw", ...
u"""Converts a node with all of it's children to a string. Remaining arguments are passed to etree.tostring as is. kwarg without_comments: bool because it works only in C14N flags: 'pretty print' and 'encoding' are ignored. :param bool pretty_print: whether to format the output ...
[ "u", "Converts", "a", "node", "with", "all", "of", "it", "s", "children", "to", "a", "string", "." ]
ac7468ac28ed82e45065b1e348cf865c8f73f0db
https://github.com/stxnext/mappet/blob/ac7468ac28ed82e45065b1e348cf865c8f73f0db/mappet/mappet.py#L384-L406
39,662
stxnext/mappet
mappet/mappet.py
Mappet.iter_children
def iter_children(self, key=None): u"""Iterates over children. :param key: A key for filtering children by tagname. """ tag = None if key: tag = self._get_aliases().get(key) if not tag: raise KeyError(key) for child in self._xml...
python
def iter_children(self, key=None): u"""Iterates over children. :param key: A key for filtering children by tagname. """ tag = None if key: tag = self._get_aliases().get(key) if not tag: raise KeyError(key) for child in self._xml...
[ "def", "iter_children", "(", "self", ",", "key", "=", "None", ")", ":", "tag", "=", "None", "if", "key", ":", "tag", "=", "self", ".", "_get_aliases", "(", ")", ".", "get", "(", "key", ")", "if", "not", "tag", ":", "raise", "KeyError", "(", "key"...
u"""Iterates over children. :param key: A key for filtering children by tagname.
[ "u", "Iterates", "over", "children", "." ]
ac7468ac28ed82e45065b1e348cf865c8f73f0db
https://github.com/stxnext/mappet/blob/ac7468ac28ed82e45065b1e348cf865c8f73f0db/mappet/mappet.py#L412-L429
39,663
stxnext/mappet
mappet/mappet.py
Mappet.update
def update(self, **kwargs): u"""Updating or creation of new simple nodes. Each dict key is used as a tagname and value as text. """ for key, value in kwargs.items(): helper = helpers.CAST_DICT.get(type(value), str) tag = self._get_aliases().get(key, key) ...
python
def update(self, **kwargs): u"""Updating or creation of new simple nodes. Each dict key is used as a tagname and value as text. """ for key, value in kwargs.items(): helper = helpers.CAST_DICT.get(type(value), str) tag = self._get_aliases().get(key, key) ...
[ "def", "update", "(", "self", ",", "*", "*", "kwargs", ")", ":", "for", "key", ",", "value", "in", "kwargs", ".", "items", "(", ")", ":", "helper", "=", "helpers", ".", "CAST_DICT", ".", "get", "(", "type", "(", "value", ")", ",", "str", ")", "...
u"""Updating or creation of new simple nodes. Each dict key is used as a tagname and value as text.
[ "u", "Updating", "or", "creation", "of", "new", "simple", "nodes", "." ]
ac7468ac28ed82e45065b1e348cf865c8f73f0db
https://github.com/stxnext/mappet/blob/ac7468ac28ed82e45065b1e348cf865c8f73f0db/mappet/mappet.py#L438-L455
39,664
stxnext/mappet
mappet/mappet.py
Mappet.sget
def sget(self, path, default=NONE_NODE): u"""Enables access to nodes if one or more of them don't exist. Example: >>> m = Mappet('<root><tag attr1="attr text">text value</tag></root>') >>> m.sget('tag') text value >>> m.sget('tag.@attr1') 'attr text' >>> ...
python
def sget(self, path, default=NONE_NODE): u"""Enables access to nodes if one or more of them don't exist. Example: >>> m = Mappet('<root><tag attr1="attr text">text value</tag></root>') >>> m.sget('tag') text value >>> m.sget('tag.@attr1') 'attr text' >>> ...
[ "def", "sget", "(", "self", ",", "path", ",", "default", "=", "NONE_NODE", ")", ":", "attrs", "=", "str", "(", "path", ")", ".", "split", "(", "\".\"", ")", "text_or_attr", "=", "None", "last_attr", "=", "attrs", "[", "-", "1", "]", "# Case of gettin...
u"""Enables access to nodes if one or more of them don't exist. Example: >>> m = Mappet('<root><tag attr1="attr text">text value</tag></root>') >>> m.sget('tag') text value >>> m.sget('tag.@attr1') 'attr text' >>> m.sget('tag.#text') 'text value' ...
[ "u", "Enables", "access", "to", "nodes", "if", "one", "or", "more", "of", "them", "don", "t", "exist", "." ]
ac7468ac28ed82e45065b1e348cf865c8f73f0db
https://github.com/stxnext/mappet/blob/ac7468ac28ed82e45065b1e348cf865c8f73f0db/mappet/mappet.py#L457-L507
39,665
stxnext/mappet
mappet/mappet.py
Mappet.create
def create(self, tag, value): u"""Creates a node, if it doesn't exist yet. Unlike attribute access, this allows to pass a node's name with hyphens. Those hyphens will be normalized automatically. In case the required element already exists, raises an exception. Updating/overwri...
python
def create(self, tag, value): u"""Creates a node, if it doesn't exist yet. Unlike attribute access, this allows to pass a node's name with hyphens. Those hyphens will be normalized automatically. In case the required element already exists, raises an exception. Updating/overwri...
[ "def", "create", "(", "self", ",", "tag", ",", "value", ")", ":", "child_tags", "=", "{", "child", ".", "tag", "for", "child", "in", "self", ".", "_xml", "}", "if", "tag", "in", "child_tags", ":", "raise", "KeyError", "(", "'Node {} already exists in XML...
u"""Creates a node, if it doesn't exist yet. Unlike attribute access, this allows to pass a node's name with hyphens. Those hyphens will be normalized automatically. In case the required element already exists, raises an exception. Updating/overwriting should be done using `update``.
[ "u", "Creates", "a", "node", "if", "it", "doesn", "t", "exist", "yet", "." ]
ac7468ac28ed82e45065b1e348cf865c8f73f0db
https://github.com/stxnext/mappet/blob/ac7468ac28ed82e45065b1e348cf865c8f73f0db/mappet/mappet.py#L509-L523
39,666
stxnext/mappet
mappet/mappet.py
Mappet.set
def set(self, name, value): u"""Assigns a new XML structure to the node. A literal value, dict or list can be passed in. Works for all nested levels. Dictionary: >>> m = Mappet('<root/>') >>> m.head = {'a': 'A', 'b': {'#text': 'B', '@attr': 'val'}} >>> m.head.to_str() ...
python
def set(self, name, value): u"""Assigns a new XML structure to the node. A literal value, dict or list can be passed in. Works for all nested levels. Dictionary: >>> m = Mappet('<root/>') >>> m.head = {'a': 'A', 'b': {'#text': 'B', '@attr': 'val'}} >>> m.head.to_str() ...
[ "def", "set", "(", "self", ",", "name", ",", "value", ")", ":", "try", ":", "# Searches for a node to assign to.", "element", "=", "next", "(", "self", ".", "_xml", ".", "iterchildren", "(", "tag", "=", "name", ")", ")", "except", "StopIteration", ":", "...
u"""Assigns a new XML structure to the node. A literal value, dict or list can be passed in. Works for all nested levels. Dictionary: >>> m = Mappet('<root/>') >>> m.head = {'a': 'A', 'b': {'#text': 'B', '@attr': 'val'}} >>> m.head.to_str() '<head><a>A</a><b attr="val">...
[ "u", "Assigns", "a", "new", "XML", "structure", "to", "the", "node", "." ]
ac7468ac28ed82e45065b1e348cf865c8f73f0db
https://github.com/stxnext/mappet/blob/ac7468ac28ed82e45065b1e348cf865c8f73f0db/mappet/mappet.py#L525-L563
39,667
stxnext/mappet
mappet/mappet.py
Mappet.assign_dict
def assign_dict(self, node, xml_dict): """Assigns a Python dict to a ``lxml`` node. :param node: A node to assign the dict to. :param xml_dict: The dict with attributes/children to use. """ new_node = etree.Element(node.tag) # Replaces the previous node with the new one...
python
def assign_dict(self, node, xml_dict): """Assigns a Python dict to a ``lxml`` node. :param node: A node to assign the dict to. :param xml_dict: The dict with attributes/children to use. """ new_node = etree.Element(node.tag) # Replaces the previous node with the new one...
[ "def", "assign_dict", "(", "self", ",", "node", ",", "xml_dict", ")", ":", "new_node", "=", "etree", ".", "Element", "(", "node", ".", "tag", ")", "# Replaces the previous node with the new one", "self", ".", "_xml", ".", "replace", "(", "node", ",", "new_no...
Assigns a Python dict to a ``lxml`` node. :param node: A node to assign the dict to. :param xml_dict: The dict with attributes/children to use.
[ "Assigns", "a", "Python", "dict", "to", "a", "lxml", "node", "." ]
ac7468ac28ed82e45065b1e348cf865c8f73f0db
https://github.com/stxnext/mappet/blob/ac7468ac28ed82e45065b1e348cf865c8f73f0db/mappet/mappet.py#L565-L577
39,668
stxnext/mappet
mappet/mappet.py
Mappet.assign_literal
def assign_literal(element, value): u"""Assigns a literal. If a given node doesn't exist, it will be created. :param etree.Element element: element to which we assign. :param value: the value to assign """ # Searches for a conversion method specific to the type of value...
python
def assign_literal(element, value): u"""Assigns a literal. If a given node doesn't exist, it will be created. :param etree.Element element: element to which we assign. :param value: the value to assign """ # Searches for a conversion method specific to the type of value...
[ "def", "assign_literal", "(", "element", ",", "value", ")", ":", "# Searches for a conversion method specific to the type of value.", "helper", "=", "helpers", ".", "CAST_DICT", ".", "get", "(", "type", "(", "value", ")", ",", "str", ")", "# Removes all children and a...
u"""Assigns a literal. If a given node doesn't exist, it will be created. :param etree.Element element: element to which we assign. :param value: the value to assign
[ "u", "Assigns", "a", "literal", "." ]
ac7468ac28ed82e45065b1e348cf865c8f73f0db
https://github.com/stxnext/mappet/blob/ac7468ac28ed82e45065b1e348cf865c8f73f0db/mappet/mappet.py#L591-L604
39,669
stxnext/mappet
mappet/mappet.py
Mappet.to_dict
def to_dict(self, **kw): u"""Converts the lxml object to a dict. possible kwargs: without_comments: bool """ _, value = helpers.etree_to_dict(self._xml, **kw).popitem() return value
python
def to_dict(self, **kw): u"""Converts the lxml object to a dict. possible kwargs: without_comments: bool """ _, value = helpers.etree_to_dict(self._xml, **kw).popitem() return value
[ "def", "to_dict", "(", "self", ",", "*", "*", "kw", ")", ":", "_", ",", "value", "=", "helpers", ".", "etree_to_dict", "(", "self", ".", "_xml", ",", "*", "*", "kw", ")", ".", "popitem", "(", ")", "return", "value" ]
u"""Converts the lxml object to a dict. possible kwargs: without_comments: bool
[ "u", "Converts", "the", "lxml", "object", "to", "a", "dict", "." ]
ac7468ac28ed82e45065b1e348cf865c8f73f0db
https://github.com/stxnext/mappet/blob/ac7468ac28ed82e45065b1e348cf865c8f73f0db/mappet/mappet.py#L606-L613
39,670
stxnext/mappet
mappet/mappet.py
Mappet._get_aliases
def _get_aliases(self): u"""Creates a dict with aliases. The key is a normalized tagname, value the original tagname. """ if self._aliases is None: self._aliases = {} if self._xml is not None: for child in self._xml.iterchildren(): ...
python
def _get_aliases(self): u"""Creates a dict with aliases. The key is a normalized tagname, value the original tagname. """ if self._aliases is None: self._aliases = {} if self._xml is not None: for child in self._xml.iterchildren(): ...
[ "def", "_get_aliases", "(", "self", ")", ":", "if", "self", ".", "_aliases", "is", "None", ":", "self", ".", "_aliases", "=", "{", "}", "if", "self", ".", "_xml", "is", "not", "None", ":", "for", "child", "in", "self", ".", "_xml", ".", "iterchildr...
u"""Creates a dict with aliases. The key is a normalized tagname, value the original tagname.
[ "u", "Creates", "a", "dict", "with", "aliases", "." ]
ac7468ac28ed82e45065b1e348cf865c8f73f0db
https://github.com/stxnext/mappet/blob/ac7468ac28ed82e45065b1e348cf865c8f73f0db/mappet/mappet.py#L615-L627
39,671
stxnext/mappet
mappet/mappet.py
Mappet.xpath
def xpath( self, path, namespaces=None, regexp=False, smart_strings=True, single_use=False, ): u"""Executes XPath query on the ``lxml`` object and returns a correct object. :param str path: XPath string e.g., 'cars'/'car' ...
python
def xpath( self, path, namespaces=None, regexp=False, smart_strings=True, single_use=False, ): u"""Executes XPath query on the ``lxml`` object and returns a correct object. :param str path: XPath string e.g., 'cars'/'car' ...
[ "def", "xpath", "(", "self", ",", "path", ",", "namespaces", "=", "None", ",", "regexp", "=", "False", ",", "smart_strings", "=", "True", ",", "single_use", "=", "False", ",", ")", ":", "if", "(", "namespaces", "in", "[", "'exslt'", ",", "'re'", "]",...
u"""Executes XPath query on the ``lxml`` object and returns a correct object. :param str path: XPath string e.g., 'cars'/'car' :param str/dict namespaces: e.g., 'exslt', 're' or ``{'re': "http://exslt.org/regular-expressions"}`` :param bool regexp: if ``True`` and no namespaces is ...
[ "u", "Executes", "XPath", "query", "on", "the", "lxml", "object", "and", "returns", "a", "correct", "object", "." ]
ac7468ac28ed82e45065b1e348cf865c8f73f0db
https://github.com/stxnext/mappet/blob/ac7468ac28ed82e45065b1e348cf865c8f73f0db/mappet/mappet.py#L629-L677
39,672
stxnext/mappet
mappet/mappet.py
Mappet.xpath_evaluator
def xpath_evaluator(self, namespaces=None, regexp=False, smart_strings=True): u"""Creates an XPathEvaluator instance for an ElementTree or an Element. :returns: ``XPathEvaluator`` instance """ return etree.XPathEvaluator( self._xml, namespaces=namespaces, ...
python
def xpath_evaluator(self, namespaces=None, regexp=False, smart_strings=True): u"""Creates an XPathEvaluator instance for an ElementTree or an Element. :returns: ``XPathEvaluator`` instance """ return etree.XPathEvaluator( self._xml, namespaces=namespaces, ...
[ "def", "xpath_evaluator", "(", "self", ",", "namespaces", "=", "None", ",", "regexp", "=", "False", ",", "smart_strings", "=", "True", ")", ":", "return", "etree", ".", "XPathEvaluator", "(", "self", ".", "_xml", ",", "namespaces", "=", "namespaces", ",", ...
u"""Creates an XPathEvaluator instance for an ElementTree or an Element. :returns: ``XPathEvaluator`` instance
[ "u", "Creates", "an", "XPathEvaluator", "instance", "for", "an", "ElementTree", "or", "an", "Element", "." ]
ac7468ac28ed82e45065b1e348cf865c8f73f0db
https://github.com/stxnext/mappet/blob/ac7468ac28ed82e45065b1e348cf865c8f73f0db/mappet/mappet.py#L679-L689
39,673
mozilla/rna
rna/utils.py
get_last_modified_date
def get_last_modified_date(*args, **kwargs): """Returns the date of the last modified Note or Release. For use with Django's last_modified decorator. """ try: latest_note = Note.objects.latest() latest_release = Release.objects.latest() except ObjectDoesNotExist: return None...
python
def get_last_modified_date(*args, **kwargs): """Returns the date of the last modified Note or Release. For use with Django's last_modified decorator. """ try: latest_note = Note.objects.latest() latest_release = Release.objects.latest() except ObjectDoesNotExist: return None...
[ "def", "get_last_modified_date", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "latest_note", "=", "Note", ".", "objects", ".", "latest", "(", ")", "latest_release", "=", "Release", ".", "objects", ".", "latest", "(", ")", "except", ...
Returns the date of the last modified Note or Release. For use with Django's last_modified decorator.
[ "Returns", "the", "date", "of", "the", "last", "modified", "Note", "or", "Release", "." ]
c1d3931f577dc9c54997f876d36bc0b44dc225ea
https://github.com/mozilla/rna/blob/c1d3931f577dc9c54997f876d36bc0b44dc225ea/rna/utils.py#L9-L20
39,674
CodyKochmann/generators
setup.py
using_ios_stash
def using_ios_stash(): ''' returns true if sys path hints the install is running on ios ''' print('detected install path:') print(os.path.dirname(__file__)) module_names = set(sys.modules.keys()) return 'stash' in module_names or 'stash.system' in module_names
python
def using_ios_stash(): ''' returns true if sys path hints the install is running on ios ''' print('detected install path:') print(os.path.dirname(__file__)) module_names = set(sys.modules.keys()) return 'stash' in module_names or 'stash.system' in module_names
[ "def", "using_ios_stash", "(", ")", ":", "print", "(", "'detected install path:'", ")", "print", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ")", "module_names", "=", "set", "(", "sys", ".", "modules", ".", "keys", "(", ")", ")", "ret...
returns true if sys path hints the install is running on ios
[ "returns", "true", "if", "sys", "path", "hints", "the", "install", "is", "running", "on", "ios" ]
e4ca4dd25d5023a94b0349c69d6224070cc2526f
https://github.com/CodyKochmann/generators/blob/e4ca4dd25d5023a94b0349c69d6224070cc2526f/setup.py#L8-L13
39,675
ten10solutions/Geist
geist/vision.py
get_partition_scores
def get_partition_scores(image, min_w=1, min_h=1): """Return list of best to worst binary splits along the x and y axis. """ h, w = image.shape[:2] if w == 0 or h == 0: return [] area = h * w cnz = numpy.count_nonzero total = cnz(image) if total == 0 or area == total: ...
python
def get_partition_scores(image, min_w=1, min_h=1): """Return list of best to worst binary splits along the x and y axis. """ h, w = image.shape[:2] if w == 0 or h == 0: return [] area = h * w cnz = numpy.count_nonzero total = cnz(image) if total == 0 or area == total: ...
[ "def", "get_partition_scores", "(", "image", ",", "min_w", "=", "1", ",", "min_h", "=", "1", ")", ":", "h", ",", "w", "=", "image", ".", "shape", "[", ":", "2", "]", "if", "w", "==", "0", "or", "h", "==", "0", ":", "return", "[", "]", "area",...
Return list of best to worst binary splits along the x and y axis.
[ "Return", "list", "of", "best", "to", "worst", "binary", "splits", "along", "the", "x", "and", "y", "axis", "." ]
a1ef16d8b4c3777735008b671a50acfde3ce7bf1
https://github.com/ten10solutions/Geist/blob/a1ef16d8b4c3777735008b671a50acfde3ce7bf1/geist/vision.py#L259-L285
39,676
kyzima-spb/pony-database-facade
pony_database_facade/__init__.py
DatabaseFacade.__init_defaults
def __init_defaults(self, config): """Initializes the default connection settings.""" provider = self.__provider if provider == 'sqlite': config.setdefault('dbname', ':memory:') config.setdefault('create_db', True) elif provider == 'mysql': config.s...
python
def __init_defaults(self, config): """Initializes the default connection settings.""" provider = self.__provider if provider == 'sqlite': config.setdefault('dbname', ':memory:') config.setdefault('create_db', True) elif provider == 'mysql': config.s...
[ "def", "__init_defaults", "(", "self", ",", "config", ")", ":", "provider", "=", "self", ".", "__provider", "if", "provider", "==", "'sqlite'", ":", "config", ".", "setdefault", "(", "'dbname'", ",", "':memory:'", ")", "config", ".", "setdefault", "(", "'c...
Initializes the default connection settings.
[ "Initializes", "the", "default", "connection", "settings", "." ]
a6e8ea87625ac21565e8fe3a280de8ca749d71d8
https://github.com/kyzima-spb/pony-database-facade/blob/a6e8ea87625ac21565e8fe3a280de8ca749d71d8/pony_database_facade/__init__.py#L32-L54
39,677
micha030201/aionationstates
aionationstates/world_.py
_World.newnations
async def newnations(self, root): """Most recently founded nations, from newest. Returns ------- an :class:`ApiQuery` of a list of :class:`Nation` """ return [aionationstates.Nation(n) for n in root.find('NEWNATIONS').text.split(',')]
python
async def newnations(self, root): """Most recently founded nations, from newest. Returns ------- an :class:`ApiQuery` of a list of :class:`Nation` """ return [aionationstates.Nation(n) for n in root.find('NEWNATIONS').text.split(',')]
[ "async", "def", "newnations", "(", "self", ",", "root", ")", ":", "return", "[", "aionationstates", ".", "Nation", "(", "n", ")", "for", "n", "in", "root", ".", "find", "(", "'NEWNATIONS'", ")", ".", "text", ".", "split", "(", "','", ")", "]" ]
Most recently founded nations, from newest. Returns ------- an :class:`ApiQuery` of a list of :class:`Nation`
[ "Most", "recently", "founded", "nations", "from", "newest", "." ]
dc86b86d994cbab830b69ab8023601c73e778b3a
https://github.com/micha030201/aionationstates/blob/dc86b86d994cbab830b69ab8023601c73e778b3a/aionationstates/world_.py#L72-L80
39,678
micha030201/aionationstates
aionationstates/world_.py
_World.regions
async def regions(self, root): """List of all the regions, seemingly in order of creation. Returns ------- an :class:`ApiQuery` of a list of :class:`Region` """ return [aionationstates.Region(r) for r in root.find('REGIONS').text.split(',')]
python
async def regions(self, root): """List of all the regions, seemingly in order of creation. Returns ------- an :class:`ApiQuery` of a list of :class:`Region` """ return [aionationstates.Region(r) for r in root.find('REGIONS').text.split(',')]
[ "async", "def", "regions", "(", "self", ",", "root", ")", ":", "return", "[", "aionationstates", ".", "Region", "(", "r", ")", "for", "r", "in", "root", ".", "find", "(", "'REGIONS'", ")", ".", "text", ".", "split", "(", "','", ")", "]" ]
List of all the regions, seemingly in order of creation. Returns ------- an :class:`ApiQuery` of a list of :class:`Region`
[ "List", "of", "all", "the", "regions", "seemingly", "in", "order", "of", "creation", "." ]
dc86b86d994cbab830b69ab8023601c73e778b3a
https://github.com/micha030201/aionationstates/blob/dc86b86d994cbab830b69ab8023601c73e778b3a/aionationstates/world_.py#L104-L112
39,679
micha030201/aionationstates
aionationstates/world_.py
_World.regionsbytag
def regionsbytag(self, *tags): """All regions with any of the named tags. Parameters ---------- *tags : str Regional tags. Can be preceded by a ``-`` to select regions without that tag. Returns ------- an :class:`ApiQuery` of a list of :...
python
def regionsbytag(self, *tags): """All regions with any of the named tags. Parameters ---------- *tags : str Regional tags. Can be preceded by a ``-`` to select regions without that tag. Returns ------- an :class:`ApiQuery` of a list of :...
[ "def", "regionsbytag", "(", "self", ",", "*", "tags", ")", ":", "if", "len", "(", "tags", ")", ">", "10", ":", "raise", "ValueError", "(", "'You can specify up to 10 tags'", ")", "if", "not", "tags", ":", "raise", "ValueError", "(", "'No tags specified'", ...
All regions with any of the named tags. Parameters ---------- *tags : str Regional tags. Can be preceded by a ``-`` to select regions without that tag. Returns ------- an :class:`ApiQuery` of a list of :class:`Region`
[ "All", "regions", "with", "any", "of", "the", "named", "tags", "." ]
dc86b86d994cbab830b69ab8023601c73e778b3a
https://github.com/micha030201/aionationstates/blob/dc86b86d994cbab830b69ab8023601c73e778b3a/aionationstates/world_.py#L124-L150
39,680
micha030201/aionationstates
aionationstates/world_.py
_World.dispatch
def dispatch(self, id): """Dispatch by id. Parameters ---------- id : int Dispatch id. Returns ------- an :class:`ApiQuery` of :class:`Dispatch` Raises ------ :class:`NotFound` If a dispatch with the requested id ...
python
def dispatch(self, id): """Dispatch by id. Parameters ---------- id : int Dispatch id. Returns ------- an :class:`ApiQuery` of :class:`Dispatch` Raises ------ :class:`NotFound` If a dispatch with the requested id ...
[ "def", "dispatch", "(", "self", ",", "id", ")", ":", "@", "api_query", "(", "'dispatch'", ",", "dispatchid", "=", "str", "(", "id", ")", ")", "async", "def", "result", "(", "_", ",", "root", ")", ":", "elem", "=", "root", ".", "find", "(", "'DISP...
Dispatch by id. Parameters ---------- id : int Dispatch id. Returns ------- an :class:`ApiQuery` of :class:`Dispatch` Raises ------ :class:`NotFound` If a dispatch with the requested id doesn't exist.
[ "Dispatch", "by", "id", "." ]
dc86b86d994cbab830b69ab8023601c73e778b3a
https://github.com/micha030201/aionationstates/blob/dc86b86d994cbab830b69ab8023601c73e778b3a/aionationstates/world_.py#L152-L175
39,681
micha030201/aionationstates
aionationstates/world_.py
_World.dispatchlist
def dispatchlist(self, *, author=None, category=None, subcategory=None, sort='new'): """Find dispatches by certain criteria. Parameters ---------- author : str Name of the nation authoring the dispatch. category : str Dispatch's prima...
python
def dispatchlist(self, *, author=None, category=None, subcategory=None, sort='new'): """Find dispatches by certain criteria. Parameters ---------- author : str Name of the nation authoring the dispatch. category : str Dispatch's prima...
[ "def", "dispatchlist", "(", "self", ",", "*", ",", "author", "=", "None", ",", "category", "=", "None", ",", "subcategory", "=", "None", ",", "sort", "=", "'new'", ")", ":", "params", "=", "{", "'sort'", ":", "sort", "}", "if", "author", ":", "para...
Find dispatches by certain criteria. Parameters ---------- author : str Name of the nation authoring the dispatch. category : str Dispatch's primary category. subcategory : str Dispatch's secondary category. sort : str Sort...
[ "Find", "dispatches", "by", "certain", "criteria", "." ]
dc86b86d994cbab830b69ab8023601c73e778b3a
https://github.com/micha030201/aionationstates/blob/dc86b86d994cbab830b69ab8023601c73e778b3a/aionationstates/world_.py#L177-L220
39,682
micha030201/aionationstates
aionationstates/world_.py
_World.poll
def poll(self, id): """Poll with a given id. Parameters ---------- id : int Poll id. Returns ------- an :class:`ApiQuery` of :class:`Poll` Raises ------ :class:`NotFound` If a poll with the requested id doesn't ex...
python
def poll(self, id): """Poll with a given id. Parameters ---------- id : int Poll id. Returns ------- an :class:`ApiQuery` of :class:`Poll` Raises ------ :class:`NotFound` If a poll with the requested id doesn't ex...
[ "def", "poll", "(", "self", ",", "id", ")", ":", "@", "api_query", "(", "'poll'", ",", "pollid", "=", "str", "(", "id", ")", ")", "async", "def", "result", "(", "_", ",", "root", ")", ":", "elem", "=", "root", ".", "find", "(", "'POLL'", ")", ...
Poll with a given id. Parameters ---------- id : int Poll id. Returns ------- an :class:`ApiQuery` of :class:`Poll` Raises ------ :class:`NotFound` If a poll with the requested id doesn't exist.
[ "Poll", "with", "a", "given", "id", "." ]
dc86b86d994cbab830b69ab8023601c73e778b3a
https://github.com/micha030201/aionationstates/blob/dc86b86d994cbab830b69ab8023601c73e778b3a/aionationstates/world_.py#L222-L245
39,683
micha030201/aionationstates
aionationstates/world_.py
_World.banner
def banner(self, *ids, _expand_macros=None): """Get data about banners by their ids. Macros in banners' names and descriptions are not expanded. Parameters ---------- *ids : str Banner ids. Returns ------- an :class:`ApiQuery` of a list of :c...
python
def banner(self, *ids, _expand_macros=None): """Get data about banners by their ids. Macros in banners' names and descriptions are not expanded. Parameters ---------- *ids : str Banner ids. Returns ------- an :class:`ApiQuery` of a list of :c...
[ "def", "banner", "(", "self", ",", "*", "ids", ",", "_expand_macros", "=", "None", ")", ":", "async", "def", "noop", "(", "s", ")", ":", "return", "s", "_expand_macros", "=", "_expand_macros", "or", "noop", "@", "api_query", "(", "'banner'", ",", "bann...
Get data about banners by their ids. Macros in banners' names and descriptions are not expanded. Parameters ---------- *ids : str Banner ids. Returns ------- an :class:`ApiQuery` of a list of :class:`Banner` Raises ------ :cl...
[ "Get", "data", "about", "banners", "by", "their", "ids", "." ]
dc86b86d994cbab830b69ab8023601c73e778b3a
https://github.com/micha030201/aionationstates/blob/dc86b86d994cbab830b69ab8023601c73e778b3a/aionationstates/world_.py#L247-L278
39,684
micha030201/aionationstates
aionationstates/world_.py
_World.send_telegram
async def send_telegram(self, *, client_key, telegram_id, telegram_key, recepient): """A basic interface to the Telegrams API. Parameters ---------- client_key : str Telegrams API Client Key. telegram_id : int or str Telegram i...
python
async def send_telegram(self, *, client_key, telegram_id, telegram_key, recepient): """A basic interface to the Telegrams API. Parameters ---------- client_key : str Telegrams API Client Key. telegram_id : int or str Telegram i...
[ "async", "def", "send_telegram", "(", "self", ",", "*", ",", "client_key", ",", "telegram_id", ",", "telegram_key", ",", "recepient", ")", ":", "params", "=", "{", "'a'", ":", "'sendTG'", ",", "'client'", ":", "client_key", ",", "'tgid'", ":", "str", "("...
A basic interface to the Telegrams API. Parameters ---------- client_key : str Telegrams API Client Key. telegram_id : int or str Telegram id. telegram_key : str Telegram key. recepient : str Name of the nation you want to ...
[ "A", "basic", "interface", "to", "the", "Telegrams", "API", "." ]
dc86b86d994cbab830b69ab8023601c73e778b3a
https://github.com/micha030201/aionationstates/blob/dc86b86d994cbab830b69ab8023601c73e778b3a/aionationstates/world_.py#L290-L316
39,685
micha030201/aionationstates
aionationstates/world_.py
_World.happenings
async def happenings(self, *, nations=None, regions=None, filters=None, beforeid=None, beforetime=None): """Iterate through happenings from newest to oldest. Parameters ---------- nations : iterable of str Nations happenings of which will be requeste...
python
async def happenings(self, *, nations=None, regions=None, filters=None, beforeid=None, beforetime=None): """Iterate through happenings from newest to oldest. Parameters ---------- nations : iterable of str Nations happenings of which will be requeste...
[ "async", "def", "happenings", "(", "self", ",", "*", ",", "nations", "=", "None", ",", "regions", "=", "None", ",", "filters", "=", "None", ",", "beforeid", "=", "None", ",", "beforetime", "=", "None", ")", ":", "while", "True", ":", "happening_bunch",...
Iterate through happenings from newest to oldest. Parameters ---------- nations : iterable of str Nations happenings of which will be requested. Cannot be specified at the same time with ``regions``. regions : iterable of str Regions happenings of wh...
[ "Iterate", "through", "happenings", "from", "newest", "to", "oldest", "." ]
dc86b86d994cbab830b69ab8023601c73e778b3a
https://github.com/micha030201/aionationstates/blob/dc86b86d994cbab830b69ab8023601c73e778b3a/aionationstates/world_.py#L350-L387
39,686
ten10solutions/Geist
geist/match_position_finder_helpers.py
find_potential_match_regions
def find_potential_match_regions(template, transformed_array, method='correlation', raw_tolerance=0.666): """To prevent prohibitively slow calculation of normalisation coefficient at each point in image find potential match points, and normalise these only these. This function uses the definitions of ...
python
def find_potential_match_regions(template, transformed_array, method='correlation', raw_tolerance=0.666): """To prevent prohibitively slow calculation of normalisation coefficient at each point in image find potential match points, and normalise these only these. This function uses the definitions of ...
[ "def", "find_potential_match_regions", "(", "template", ",", "transformed_array", ",", "method", "=", "'correlation'", ",", "raw_tolerance", "=", "0.666", ")", ":", "if", "method", "==", "'correlation'", ":", "match_value", "=", "np", ".", "sum", "(", "template"...
To prevent prohibitively slow calculation of normalisation coefficient at each point in image find potential match points, and normalise these only these. This function uses the definitions of the matching functions to calculate the expected match value and finds positions in the transformed array ...
[ "To", "prevent", "prohibitively", "slow", "calculation", "of", "normalisation", "coefficient", "at", "each", "point", "in", "image", "find", "potential", "match", "points", "and", "normalise", "these", "only", "these", ".", "This", "function", "uses", "the", "de...
a1ef16d8b4c3777735008b671a50acfde3ce7bf1
https://github.com/ten10solutions/Geist/blob/a1ef16d8b4c3777735008b671a50acfde3ce7bf1/geist/match_position_finder_helpers.py#L4-L21
39,687
ten10solutions/Geist
geist/match_position_finder_helpers.py
normalise_correlation
def normalise_correlation(image_tile_dict, transformed_array, template, normed_tolerance=1): """Calculates the normalisation coefficients of potential match positions Then normalises the correlation at these positions, and returns them if they do indeed constitute a match """ template_norm = n...
python
def normalise_correlation(image_tile_dict, transformed_array, template, normed_tolerance=1): """Calculates the normalisation coefficients of potential match positions Then normalises the correlation at these positions, and returns them if they do indeed constitute a match """ template_norm = n...
[ "def", "normalise_correlation", "(", "image_tile_dict", ",", "transformed_array", ",", "template", ",", "normed_tolerance", "=", "1", ")", ":", "template_norm", "=", "np", ".", "linalg", ".", "norm", "(", "template", ")", "image_norms", "=", "{", "(", "x", "...
Calculates the normalisation coefficients of potential match positions Then normalises the correlation at these positions, and returns them if they do indeed constitute a match
[ "Calculates", "the", "normalisation", "coefficients", "of", "potential", "match", "positions", "Then", "normalises", "the", "correlation", "at", "these", "positions", "and", "returns", "them", "if", "they", "do", "indeed", "constitute", "a", "match" ]
a1ef16d8b4c3777735008b671a50acfde3ce7bf1
https://github.com/ten10solutions/Geist/blob/a1ef16d8b4c3777735008b671a50acfde3ce7bf1/geist/match_position_finder_helpers.py#L44-L57
39,688
ten10solutions/Geist
geist/match_position_finder_helpers.py
normalise_correlation_coefficient
def normalise_correlation_coefficient(image_tile_dict, transformed_array, template, normed_tolerance=1): """As above, but for when the correlation coefficient matching method is used """ template_mean = np.mean(template) template_minus_mean = template - template_mean template_norm = np.linalg.norm(t...
python
def normalise_correlation_coefficient(image_tile_dict, transformed_array, template, normed_tolerance=1): """As above, but for when the correlation coefficient matching method is used """ template_mean = np.mean(template) template_minus_mean = template - template_mean template_norm = np.linalg.norm(t...
[ "def", "normalise_correlation_coefficient", "(", "image_tile_dict", ",", "transformed_array", ",", "template", ",", "normed_tolerance", "=", "1", ")", ":", "template_mean", "=", "np", ".", "mean", "(", "template", ")", "template_minus_mean", "=", "template", "-", ...
As above, but for when the correlation coefficient matching method is used
[ "As", "above", "but", "for", "when", "the", "correlation", "coefficient", "matching", "method", "is", "used" ]
a1ef16d8b4c3777735008b671a50acfde3ce7bf1
https://github.com/ten10solutions/Geist/blob/a1ef16d8b4c3777735008b671a50acfde3ce7bf1/geist/match_position_finder_helpers.py#L61-L73
39,689
ten10solutions/Geist
geist/match_position_finder_helpers.py
calculate_squared_differences
def calculate_squared_differences(image_tile_dict, transformed_array, template, sq_diff_tolerance=0.1): """As above, but for when the squared differences matching method is used """ template_norm_squared = np.sum(template**2) image_norms_squared = {(x,y):np.sum(image_tile_dict[(x,y)]**2) for (x,y) in im...
python
def calculate_squared_differences(image_tile_dict, transformed_array, template, sq_diff_tolerance=0.1): """As above, but for when the squared differences matching method is used """ template_norm_squared = np.sum(template**2) image_norms_squared = {(x,y):np.sum(image_tile_dict[(x,y)]**2) for (x,y) in im...
[ "def", "calculate_squared_differences", "(", "image_tile_dict", ",", "transformed_array", ",", "template", ",", "sq_diff_tolerance", "=", "0.1", ")", ":", "template_norm_squared", "=", "np", ".", "sum", "(", "template", "**", "2", ")", "image_norms_squared", "=", ...
As above, but for when the squared differences matching method is used
[ "As", "above", "but", "for", "when", "the", "squared", "differences", "matching", "method", "is", "used" ]
a1ef16d8b4c3777735008b671a50acfde3ce7bf1
https://github.com/ten10solutions/Geist/blob/a1ef16d8b4c3777735008b671a50acfde3ce7bf1/geist/match_position_finder_helpers.py#L77-L89
39,690
micha030201/aionationstates
aionationstates/happenings.py
MessageLodgement.post
async def post(self): """Get the message lodged. Returns ------- an :class:`aionationstates.ApiQuery` of :class:`aionationstates.Post` """ post = (await self.region._get_messages( fromid=self._post_id, limit=1))[0] assert post.id == self._post_id ...
python
async def post(self): """Get the message lodged. Returns ------- an :class:`aionationstates.ApiQuery` of :class:`aionationstates.Post` """ post = (await self.region._get_messages( fromid=self._post_id, limit=1))[0] assert post.id == self._post_id ...
[ "async", "def", "post", "(", "self", ")", ":", "post", "=", "(", "await", "self", ".", "region", ".", "_get_messages", "(", "fromid", "=", "self", ".", "_post_id", ",", "limit", "=", "1", ")", ")", "[", "0", "]", "assert", "post", ".", "id", "=="...
Get the message lodged. Returns ------- an :class:`aionationstates.ApiQuery` of :class:`aionationstates.Post`
[ "Get", "the", "message", "lodged", "." ]
dc86b86d994cbab830b69ab8023601c73e778b3a
https://github.com/micha030201/aionationstates/blob/dc86b86d994cbab830b69ab8023601c73e778b3a/aionationstates/happenings.py#L299-L309
39,691
micha030201/aionationstates
aionationstates/happenings.py
ResolutionVote.resolution
async def resolution(self): """Get the resolution voted on. Returns ------- awaitable of :class:`aionationstates.ResolutionAtVote` The resolution voted for. Raises ------ aionationstates.NotFound If the resolution has since been passed or...
python
async def resolution(self): """Get the resolution voted on. Returns ------- awaitable of :class:`aionationstates.ResolutionAtVote` The resolution voted for. Raises ------ aionationstates.NotFound If the resolution has since been passed or...
[ "async", "def", "resolution", "(", "self", ")", ":", "resolutions", "=", "await", "asyncio", ".", "gather", "(", "aionationstates", ".", "ga", ".", "resolution_at_vote", ",", "aionationstates", ".", "sc", ".", "resolution_at_vote", ",", ")", "for", "resolution...
Get the resolution voted on. Returns ------- awaitable of :class:`aionationstates.ResolutionAtVote` The resolution voted for. Raises ------ aionationstates.NotFound If the resolution has since been passed or defeated.
[ "Get", "the", "resolution", "voted", "on", "." ]
dc86b86d994cbab830b69ab8023601c73e778b3a
https://github.com/micha030201/aionationstates/blob/dc86b86d994cbab830b69ab8023601c73e778b3a/aionationstates/happenings.py#L369-L390
39,692
micha030201/aionationstates
aionationstates/happenings.py
_ProposalHappening.proposal
async def proposal(self): """Get the proposal in question. Actually just the first proposal with the same name, but the chance of a collision is tiny. Returns ------- awaitable of :class:`aionationstates.Proposal` The proposal submitted. Raises ...
python
async def proposal(self): """Get the proposal in question. Actually just the first proposal with the same name, but the chance of a collision is tiny. Returns ------- awaitable of :class:`aionationstates.Proposal` The proposal submitted. Raises ...
[ "async", "def", "proposal", "(", "self", ")", ":", "proposals", "=", "await", "aionationstates", ".", "wa", ".", "proposals", "(", ")", "for", "proposal", "in", "proposals", ":", "if", "(", "proposal", ".", "name", "==", "self", ".", "proposal_name", ")"...
Get the proposal in question. Actually just the first proposal with the same name, but the chance of a collision is tiny. Returns ------- awaitable of :class:`aionationstates.Proposal` The proposal submitted. Raises ------ aionationstates.No...
[ "Get", "the", "proposal", "in", "question", "." ]
dc86b86d994cbab830b69ab8023601c73e778b3a
https://github.com/micha030201/aionationstates/blob/dc86b86d994cbab830b69ab8023601c73e778b3a/aionationstates/happenings.py#L437-L457
39,693
sci-bots/dmf-device-ui
dmf_device_ui/canvas.py
Route.append
def append(self, electrode_id): ''' Append the specified electrode to the route. The route is not modified (i.e., electrode is not appended) if electrode is not connected to the last electrode in the existing route. Parameters ---------- electrode_id : str ...
python
def append(self, electrode_id): ''' Append the specified electrode to the route. The route is not modified (i.e., electrode is not appended) if electrode is not connected to the last electrode in the existing route. Parameters ---------- electrode_id : str ...
[ "def", "append", "(", "self", ",", "electrode_id", ")", ":", "do_append", "=", "False", "if", "not", "self", ".", "electrode_ids", ":", "do_append", "=", "True", "elif", "self", ".", "device", ".", "shape_indexes", ".", "shape", "[", "0", "]", ">", "0"...
Append the specified electrode to the route. The route is not modified (i.e., electrode is not appended) if electrode is not connected to the last electrode in the existing route. Parameters ---------- electrode_id : str Electrode identifier.
[ "Append", "the", "specified", "electrode", "to", "the", "route", "." ]
05b480683c9fa43f91ce5a58de2fa90cdf363fc8
https://github.com/sci-bots/dmf-device-ui/blob/05b480683c9fa43f91ce5a58de2fa90cdf363fc8/dmf_device_ui/canvas.py#L43-L76
39,694
sci-bots/dmf-device-ui
dmf_device_ui/canvas.py
DmfDeviceCanvas.insert_surface
def insert_surface(self, position, name, surface, alpha=1.): ''' Insert Cairo surface as new layer. Args ---- position (int) : Index position to insert layer at. name (str) : Name of layer. surface (cairo.Context) : Surface to render. al...
python
def insert_surface(self, position, name, surface, alpha=1.): ''' Insert Cairo surface as new layer. Args ---- position (int) : Index position to insert layer at. name (str) : Name of layer. surface (cairo.Context) : Surface to render. al...
[ "def", "insert_surface", "(", "self", ",", "position", ",", "name", ",", "surface", ",", "alpha", "=", "1.", ")", ":", "if", "name", "in", "self", ".", "df_surfaces", ".", "index", ":", "raise", "NameError", "(", "'Surface already exists with `name=\"{}\"`.'",...
Insert Cairo surface as new layer. Args ---- position (int) : Index position to insert layer at. name (str) : Name of layer. surface (cairo.Context) : Surface to render. alpha (float) : Alpha/transparency level in the range `[0, 1]`.
[ "Insert", "Cairo", "surface", "as", "new", "layer", "." ]
05b480683c9fa43f91ce5a58de2fa90cdf363fc8
https://github.com/sci-bots/dmf-device-ui/blob/05b480683c9fa43f91ce5a58de2fa90cdf363fc8/dmf_device_ui/canvas.py#L380-L406
39,695
sci-bots/dmf-device-ui
dmf_device_ui/canvas.py
DmfDeviceCanvas.append_surface
def append_surface(self, name, surface, alpha=1.): ''' Append Cairo surface as new layer on top of existing layers. Args ---- name (str) : Name of layer. surface (cairo.ImageSurface) : Surface to render. alpha (float) : Alpha/transparency level in th...
python
def append_surface(self, name, surface, alpha=1.): ''' Append Cairo surface as new layer on top of existing layers. Args ---- name (str) : Name of layer. surface (cairo.ImageSurface) : Surface to render. alpha (float) : Alpha/transparency level in th...
[ "def", "append_surface", "(", "self", ",", "name", ",", "surface", ",", "alpha", "=", "1.", ")", ":", "self", ".", "insert_surface", "(", "position", "=", "self", ".", "df_surfaces", ".", "index", ".", "shape", "[", "0", "]", ",", "name", "=", "name"...
Append Cairo surface as new layer on top of existing layers. Args ---- name (str) : Name of layer. surface (cairo.ImageSurface) : Surface to render. alpha (float) : Alpha/transparency level in the range `[0, 1]`.
[ "Append", "Cairo", "surface", "as", "new", "layer", "on", "top", "of", "existing", "layers", "." ]
05b480683c9fa43f91ce5a58de2fa90cdf363fc8
https://github.com/sci-bots/dmf-device-ui/blob/05b480683c9fa43f91ce5a58de2fa90cdf363fc8/dmf_device_ui/canvas.py#L408-L420
39,696
sci-bots/dmf-device-ui
dmf_device_ui/canvas.py
DmfDeviceCanvas.remove_surface
def remove_surface(self, name): ''' Remove layer from rendering stack and flatten remaining layers. Args ---- name (str) : Name of layer. ''' self.df_surfaces.drop(name, axis=0, inplace=True) # Order of layers may have changed after removing a layer...
python
def remove_surface(self, name): ''' Remove layer from rendering stack and flatten remaining layers. Args ---- name (str) : Name of layer. ''' self.df_surfaces.drop(name, axis=0, inplace=True) # Order of layers may have changed after removing a layer...
[ "def", "remove_surface", "(", "self", ",", "name", ")", ":", "self", ".", "df_surfaces", ".", "drop", "(", "name", ",", "axis", "=", "0", ",", "inplace", "=", "True", ")", "# Order of layers may have changed after removing a layer. Trigger", "# refresh of surfaces."...
Remove layer from rendering stack and flatten remaining layers. Args ---- name (str) : Name of layer.
[ "Remove", "layer", "from", "rendering", "stack", "and", "flatten", "remaining", "layers", "." ]
05b480683c9fa43f91ce5a58de2fa90cdf363fc8
https://github.com/sci-bots/dmf-device-ui/blob/05b480683c9fa43f91ce5a58de2fa90cdf363fc8/dmf_device_ui/canvas.py#L422-L435
39,697
sci-bots/dmf-device-ui
dmf_device_ui/canvas.py
DmfDeviceCanvas.clone_surface
def clone_surface(self, source_name, target_name, target_position=-1, alpha=1.): ''' Clone surface from existing layer to a new name, inserting new surface at specified position. By default, new surface is appended as the top surface layer. Args --...
python
def clone_surface(self, source_name, target_name, target_position=-1, alpha=1.): ''' Clone surface from existing layer to a new name, inserting new surface at specified position. By default, new surface is appended as the top surface layer. Args --...
[ "def", "clone_surface", "(", "self", ",", "source_name", ",", "target_name", ",", "target_position", "=", "-", "1", ",", "alpha", "=", "1.", ")", ":", "source_surface", "=", "self", ".", "df_surfaces", ".", "surface", ".", "ix", "[", "source_name", "]", ...
Clone surface from existing layer to a new name, inserting new surface at specified position. By default, new surface is appended as the top surface layer. Args ---- source_name (str) : Name of layer to clone. target_name (str) : Name of new layer.
[ "Clone", "surface", "from", "existing", "layer", "to", "a", "new", "name", "inserting", "new", "surface", "at", "specified", "position", "." ]
05b480683c9fa43f91ce5a58de2fa90cdf363fc8
https://github.com/sci-bots/dmf-device-ui/blob/05b480683c9fa43f91ce5a58de2fa90cdf363fc8/dmf_device_ui/canvas.py#L437-L462
39,698
sci-bots/dmf-device-ui
dmf_device_ui/canvas.py
DmfDeviceCanvas.render_electrode_shapes
def render_electrode_shapes(self, df_shapes=None, shape_scale=0.8, fill=(1, 1, 1)): ''' Render electrode state shapes. By default, draw each electrode shape filled white. See also :meth:`render_shapes()`. Parameters ---------- df...
python
def render_electrode_shapes(self, df_shapes=None, shape_scale=0.8, fill=(1, 1, 1)): ''' Render electrode state shapes. By default, draw each electrode shape filled white. See also :meth:`render_shapes()`. Parameters ---------- df...
[ "def", "render_electrode_shapes", "(", "self", ",", "df_shapes", "=", "None", ",", "shape_scale", "=", "0.8", ",", "fill", "=", "(", "1", ",", "1", ",", "1", ")", ")", ":", "surface", "=", "self", ".", "get_surface", "(", ")", "if", "df_shapes", "is"...
Render electrode state shapes. By default, draw each electrode shape filled white. See also :meth:`render_shapes()`. Parameters ---------- df_shapes = : pandas.DataFrame .. versionadded:: 0.12
[ "Render", "electrode", "state", "shapes", "." ]
05b480683c9fa43f91ce5a58de2fa90cdf363fc8
https://github.com/sci-bots/dmf-device-ui/blob/05b480683c9fa43f91ce5a58de2fa90cdf363fc8/dmf_device_ui/canvas.py#L602-L652
39,699
sci-bots/dmf-device-ui
dmf_device_ui/canvas.py
DmfDeviceCanvas.render_registration
def render_registration(self): ''' Render pinned points on video frame as red rectangle. ''' surface = self.get_surface() if self.canvas is None or self.df_canvas_corners.shape[0] == 0: return surface corners = self.df_canvas_corners.copy() corners['w...
python
def render_registration(self): ''' Render pinned points on video frame as red rectangle. ''' surface = self.get_surface() if self.canvas is None or self.df_canvas_corners.shape[0] == 0: return surface corners = self.df_canvas_corners.copy() corners['w...
[ "def", "render_registration", "(", "self", ")", ":", "surface", "=", "self", ".", "get_surface", "(", ")", "if", "self", ".", "canvas", "is", "None", "or", "self", ".", "df_canvas_corners", ".", "shape", "[", "0", "]", "==", "0", ":", "return", "surfac...
Render pinned points on video frame as red rectangle.
[ "Render", "pinned", "points", "on", "video", "frame", "as", "red", "rectangle", "." ]
05b480683c9fa43f91ce5a58de2fa90cdf363fc8
https://github.com/sci-bots/dmf-device-ui/blob/05b480683c9fa43f91ce5a58de2fa90cdf363fc8/dmf_device_ui/canvas.py#L786-L810