repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
EwilDawe/typy
typy/keyboard.py
hold
def hold(*keys, hold_time = 0, hold_while = None): """ Simulates the holding of all the keys passed to the function These keys are held down for a default period of 0 seconds before release :param keys: list of keys to be held :param hold_time: length of time to hold keys :param hold_while: hol...
python
def hold(*keys, hold_time = 0, hold_while = None): """ Simulates the holding of all the keys passed to the function These keys are held down for a default period of 0 seconds before release :param keys: list of keys to be held :param hold_time: length of time to hold keys :param hold_while: hol...
[ "def", "hold", "(", "*", "keys", ",", "hold_time", "=", "0", ",", "hold_while", "=", "None", ")", ":", "for", "key", "in", "keys", ":", "win32api", ".", "keybd_event", "(", "codes", "[", "key", "]", ",", "0", ",", "0", ",", "0", ")", "if", "cal...
Simulates the holding of all the keys passed to the function These keys are held down for a default period of 0 seconds before release :param keys: list of keys to be held :param hold_time: length of time to hold keys :param hold_while: hold keys while hold_while returns True :return: None
[ "Simulates", "the", "holding", "of", "all", "the", "keys", "passed", "to", "the", "function", "These", "keys", "are", "held", "down", "for", "a", "default", "period", "of", "0", "seconds", "before", "release" ]
train
https://github.com/EwilDawe/typy/blob/0349e7176567a4dbef318e75d9b3d6868950a1a9/typy/keyboard.py#L24-L42
EwilDawe/typy
typy/keyboard.py
release
def release(*keys): """ Simulates the release of all the keys passed to this function :param keys: list of keys to be released :return: None """ for key in keys: win32api.keybd_event(codes[key], 0, win32con.KEYEVENTF_KEYUP, 0)
python
def release(*keys): """ Simulates the release of all the keys passed to this function :param keys: list of keys to be released :return: None """ for key in keys: win32api.keybd_event(codes[key], 0, win32con.KEYEVENTF_KEYUP, 0)
[ "def", "release", "(", "*", "keys", ")", ":", "for", "key", "in", "keys", ":", "win32api", ".", "keybd_event", "(", "codes", "[", "key", "]", ",", "0", ",", "win32con", ".", "KEYEVENTF_KEYUP", ",", "0", ")" ]
Simulates the release of all the keys passed to this function :param keys: list of keys to be released :return: None
[ "Simulates", "the", "release", "of", "all", "the", "keys", "passed", "to", "this", "function" ]
train
https://github.com/EwilDawe/typy/blob/0349e7176567a4dbef318e75d9b3d6868950a1a9/typy/keyboard.py#L45-L54
EwilDawe/typy
typy/keyboard.py
write
def write(s = ''): """ Automates the process of typing by converting a string into a set of press() and hold() calls :param s: string to be written :return: None """ for char in s: if char.isupper(): # Handles uppercase hold('shift', char.lower()) elif char == " ":...
python
def write(s = ''): """ Automates the process of typing by converting a string into a set of press() and hold() calls :param s: string to be written :return: None """ for char in s: if char.isupper(): # Handles uppercase hold('shift', char.lower()) elif char == " ":...
[ "def", "write", "(", "s", "=", "''", ")", ":", "for", "char", "in", "s", ":", "if", "char", ".", "isupper", "(", ")", ":", "# Handles uppercase", "hold", "(", "'shift'", ",", "char", ".", "lower", "(", ")", ")", "elif", "char", "==", "\" \"", ":"...
Automates the process of typing by converting a string into a set of press() and hold() calls :param s: string to be written :return: None
[ "Automates", "the", "process", "of", "typing", "by", "converting", "a", "string", "into", "a", "set", "of", "press", "()", "and", "hold", "()", "calls" ]
train
https://github.com/EwilDawe/typy/blob/0349e7176567a4dbef318e75d9b3d6868950a1a9/typy/keyboard.py#L57-L78
fr33jc/bang
bang/providers/rs.py
server_to_dict
def server_to_dict(server): """ Returns the :class:`dict` representation of a server object. The returned :class:`dict` is meant to be consumed by :class:`~bang.deployers.cloud.ServerDeployer` objects. """ soul = server.soul return { A.server.ID: server.href, A.serv...
python
def server_to_dict(server): """ Returns the :class:`dict` representation of a server object. The returned :class:`dict` is meant to be consumed by :class:`~bang.deployers.cloud.ServerDeployer` objects. """ soul = server.soul return { A.server.ID: server.href, A.serv...
[ "def", "server_to_dict", "(", "server", ")", ":", "soul", "=", "server", ".", "soul", "return", "{", "A", ".", "server", ".", "ID", ":", "server", ".", "href", ",", "A", ".", "server", ".", "PUBLIC_IPS", ":", "soul", ".", "get", "(", "'public_dns_nam...
Returns the :class:`dict` representation of a server object. The returned :class:`dict` is meant to be consumed by :class:`~bang.deployers.cloud.ServerDeployer` objects.
[ "Returns", "the", ":", "class", ":", "dict", "representation", "of", "a", "server", "object", "." ]
train
https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/providers/rs.py#L13-L26
fr33jc/bang
bang/providers/rs.py
normalize_input_value
def normalize_input_value(value): """ Returns an input value normalized for RightScale API 2.0. This typically means adjusting the *input type* prefix to be one of the valid values:: blank ignore inherit text: env: cred: key: array: ...
python
def normalize_input_value(value): """ Returns an input value normalized for RightScale API 2.0. This typically means adjusting the *input type* prefix to be one of the valid values:: blank ignore inherit text: env: cred: key: array: ...
[ "def", "normalize_input_value", "(", "value", ")", ":", "if", "value", "in", "(", "'blank'", ",", "'ignore'", ",", "'inherit'", ")", ":", "return", "value", "# assume any unspecified or unknown types are text", "tokens", "=", "value", ".", "split", "(", "':'", "...
Returns an input value normalized for RightScale API 2.0. This typically means adjusting the *input type* prefix to be one of the valid values:: blank ignore inherit text: env: cred: key: array: This list comes from the table published here:...
[ "Returns", "an", "input", "value", "normalized", "for", "RightScale", "API", "2", ".", "0", "." ]
train
https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/providers/rs.py#L52-L84
fr33jc/bang
bang/providers/rs.py
Servers.create_stack
def create_stack(self, name): """ Creates stack if necessary. """ deployment = find_exact(self.api.deployments, name=name) if not deployment: try: # TODO: replace when python-rightscale handles non-json self.api.client.post( ...
python
def create_stack(self, name): """ Creates stack if necessary. """ deployment = find_exact(self.api.deployments, name=name) if not deployment: try: # TODO: replace when python-rightscale handles non-json self.api.client.post( ...
[ "def", "create_stack", "(", "self", ",", "name", ")", ":", "deployment", "=", "find_exact", "(", "self", ".", "api", ".", "deployments", ",", "name", "=", "name", ")", "if", "not", "deployment", ":", "try", ":", "# TODO: replace when python-rightscale handles ...
Creates stack if necessary.
[ "Creates", "stack", "if", "necessary", "." ]
train
https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/providers/rs.py#L100-L117
fr33jc/bang
bang/providers/rs.py
Servers.find_server_defs
def find_server_defs(self, basename): """ Finds *usable* server definitions by name. A server definition is *usable* if it doesn't have a current instance. NOTE: This might result in extra server definitions if some servers are in various non-operational states (e.g. terminatin...
python
def find_server_defs(self, basename): """ Finds *usable* server definitions by name. A server definition is *usable* if it doesn't have a current instance. NOTE: This might result in extra server definitions if some servers are in various non-operational states (e.g. terminatin...
[ "def", "find_server_defs", "(", "self", ",", "basename", ")", ":", "filters", "=", "[", "'name==%s'", "%", "basename", "]", "fuzzy", "=", "self", ".", "deployment", ".", "servers", ".", "index", "(", "params", "=", "{", "'filter[]'", ":", "filters", "}",...
Finds *usable* server definitions by name. A server definition is *usable* if it doesn't have a current instance. NOTE: This might result in extra server definitions if some servers are in various non-operational states (e.g. terminating).
[ "Finds", "*", "usable", "*", "server", "definitions", "by", "name", "." ]
train
https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/providers/rs.py#L170-L189
fr33jc/bang
bang/providers/rs.py
Servers.define_server
def define_server( self, basename, server_tpl, server_tpl_rev, instance_type, ssh_key_name, tags=None, availability_zone=None, security_groups=None, **provider_extras ): """ Creates a new server instance. This call blocks until the server is creat...
python
def define_server( self, basename, server_tpl, server_tpl_rev, instance_type, ssh_key_name, tags=None, availability_zone=None, security_groups=None, **provider_extras ): """ Creates a new server instance. This call blocks until the server is creat...
[ "def", "define_server", "(", "self", ",", "basename", ",", "server_tpl", ",", "server_tpl_rev", ",", "instance_type", ",", "ssh_key_name", ",", "tags", "=", "None", ",", "availability_zone", "=", "None", ",", "security_groups", "=", "None", ",", "*", "*", "p...
Creates a new server instance. This call blocks until the server is created and available for normal use, or :attr:`timeout_s` has elapsed. :param str basename: An identifier for the server. :param str server_tpl: The name of the server template to use. :param str server_tpl_rev: ...
[ "Creates", "a", "new", "server", "instance", ".", "This", "call", "blocks", "until", "the", "server", "is", "created", "and", "available", "for", "normal", "use", "or", ":", "attr", ":", "timeout_s", "has", "elapsed", "." ]
train
https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/providers/rs.py#L191-L325
shi-cong/PYSTUDY
PYSTUDY/middleware/mysqllib.py
get_mysql_pool
def get_mysql_pool(host=None, user=None, password=None, charset='utf8', db=None, size=None, isSync=True, ioloop=None): """使用工厂方法返回一个连接池""" factory = mysql_pool_factory(isSync) kwargs = { 'host': host, 'user': user, 'password': password, 'charset': charset, 'd...
python
def get_mysql_pool(host=None, user=None, password=None, charset='utf8', db=None, size=None, isSync=True, ioloop=None): """使用工厂方法返回一个连接池""" factory = mysql_pool_factory(isSync) kwargs = { 'host': host, 'user': user, 'password': password, 'charset': charset, 'd...
[ "def", "get_mysql_pool", "(", "host", "=", "None", ",", "user", "=", "None", ",", "password", "=", "None", ",", "charset", "=", "'utf8'", ",", "db", "=", "None", ",", "size", "=", "None", ",", "isSync", "=", "True", ",", "ioloop", "=", "None", ")",...
使用工厂方法返回一个连接池
[ "使用工厂方法返回一个连接池" ]
train
https://github.com/shi-cong/PYSTUDY/blob/c8da7128ea18ecaa5849f2066d321e70d6f97f70/PYSTUDY/middleware/mysqllib.py#L154-L166
shi-cong/PYSTUDY
PYSTUDY/middleware/mysqllib.py
AsyncMySQLPool._execute
def _execute(self, sql, args): """执行sql语句 :param sql: sql语句 :param args: 参数 :return: 返回的都是数组对象 """ sql = sql.lower().strip() args = args or () tmp = sql[:6] with (yield self._pool.Connection()) as conn: try: with conn.cu...
python
def _execute(self, sql, args): """执行sql语句 :param sql: sql语句 :param args: 参数 :return: 返回的都是数组对象 """ sql = sql.lower().strip() args = args or () tmp = sql[:6] with (yield self._pool.Connection()) as conn: try: with conn.cu...
[ "def", "_execute", "(", "self", ",", "sql", ",", "args", ")", ":", "sql", "=", "sql", ".", "lower", "(", ")", ".", "strip", "(", ")", "args", "=", "args", "or", "(", ")", "tmp", "=", "sql", "[", ":", "6", "]", "with", "(", "yield", "self", ...
执行sql语句 :param sql: sql语句 :param args: 参数 :return: 返回的都是数组对象
[ "执行sql语句", ":", "param", "sql", ":", "sql语句", ":", "param", "args", ":", "参数", ":", "return", ":", "返回的都是数组对象" ]
train
https://github.com/shi-cong/PYSTUDY/blob/c8da7128ea18ecaa5849f2066d321e70d6f97f70/PYSTUDY/middleware/mysqllib.py#L116-L144
GMadorell/abris
abris_transform/configuration/data_model.py
DataModel.set_features_types_from_dataframe
def set_features_types_from_dataframe(self, data_frame): """ Sets the features types from the given data_frame. All the calls except the first one are ignored. """ if self.__feature_types_set: return self.__feature_types_set = True dtypes = data_frame...
python
def set_features_types_from_dataframe(self, data_frame): """ Sets the features types from the given data_frame. All the calls except the first one are ignored. """ if self.__feature_types_set: return self.__feature_types_set = True dtypes = data_frame...
[ "def", "set_features_types_from_dataframe", "(", "self", ",", "data_frame", ")", ":", "if", "self", ".", "__feature_types_set", ":", "return", "self", ".", "__feature_types_set", "=", "True", "dtypes", "=", "data_frame", ".", "dtypes", "for", "feature", "in", "s...
Sets the features types from the given data_frame. All the calls except the first one are ignored.
[ "Sets", "the", "features", "types", "from", "the", "given", "data_frame", ".", "All", "the", "calls", "except", "the", "first", "one", "are", "ignored", "." ]
train
https://github.com/GMadorell/abris/blob/0d8ab7ec506835a45fae6935d129f5d7e6937bb2/abris_transform/configuration/data_model.py#L12-L25
MagicGreenDragon/winvers
winvers/util.py
print_version
def print_version(): """ Print get_version() return value in a readable format. Params: None Returns: None """ v = get_version() try: s = _STR_WIN[v] except KeyError: s = "Unknow OS" print("-----------------------------------------...
python
def print_version(): """ Print get_version() return value in a readable format. Params: None Returns: None """ v = get_version() try: s = _STR_WIN[v] except KeyError: s = "Unknow OS" print("-----------------------------------------...
[ "def", "print_version", "(", ")", ":", "v", "=", "get_version", "(", ")", "try", ":", "s", "=", "_STR_WIN", "[", "v", "]", "except", "KeyError", ":", "s", "=", "\"Unknow OS\"", "print", "(", "\"-----------------------------------------------------------\"", ")",...
Print get_version() return value in a readable format. Params: None Returns: None
[ "Print", "get_version", "()", "return", "value", "in", "a", "readable", "format", ".", "Params", ":", "None", "Returns", ":", "None" ]
train
https://github.com/MagicGreenDragon/winvers/blob/4f4bcf56234d7021344b5a4384ecb4bcbb14094e/winvers/util.py#L78-L104
luismasuelli/python-cantrips
cantrips/iteration.py
items
def items(iterable): """ Iterates over the items of a sequence. If the sequence supports the dictionary protocol (iteritems/items) then we use that. Otherwise we use the enumerate built-in function. """ if hasattr(iterable, 'iteritems'): return (p for p in iterable.iteritems()) e...
python
def items(iterable): """ Iterates over the items of a sequence. If the sequence supports the dictionary protocol (iteritems/items) then we use that. Otherwise we use the enumerate built-in function. """ if hasattr(iterable, 'iteritems'): return (p for p in iterable.iteritems()) e...
[ "def", "items", "(", "iterable", ")", ":", "if", "hasattr", "(", "iterable", ",", "'iteritems'", ")", ":", "return", "(", "p", "for", "p", "in", "iterable", ".", "iteritems", "(", ")", ")", "elif", "hasattr", "(", "iterable", ",", "'items'", ")", ":"...
Iterates over the items of a sequence. If the sequence supports the dictionary protocol (iteritems/items) then we use that. Otherwise we use the enumerate built-in function.
[ "Iterates", "over", "the", "items", "of", "a", "sequence", ".", "If", "the", "sequence", "supports", "the", "dictionary", "protocol", "(", "iteritems", "/", "items", ")", "then", "we", "use", "that", ".", "Otherwise", "we", "use", "the", "enumerate", "buil...
train
https://github.com/luismasuelli/python-cantrips/blob/dba2742c1d1a60863bb65f4a291464f6e68eb2ee/cantrips/iteration.py#L9-L20
luismasuelli/python-cantrips
cantrips/iteration.py
labeled_accumulate
def labeled_accumulate(sequence, keygetter=operator.itemgetter(0), valuegetter=operator.itemgetter(1), accumulator=operator.add): """ Accumulates input elements according to accumulate(), but keeping certain data (per element, from the original sequence/iterable) in the target elements, like behaving as k...
python
def labeled_accumulate(sequence, keygetter=operator.itemgetter(0), valuegetter=operator.itemgetter(1), accumulator=operator.add): """ Accumulates input elements according to accumulate(), but keeping certain data (per element, from the original sequence/iterable) in the target elements, like behaving as k...
[ "def", "labeled_accumulate", "(", "sequence", ",", "keygetter", "=", "operator", ".", "itemgetter", "(", "0", ")", ",", "valuegetter", "=", "operator", ".", "itemgetter", "(", "1", ")", ",", "accumulator", "=", "operator", ".", "add", ")", ":", "return", ...
Accumulates input elements according to accumulate(), but keeping certain data (per element, from the original sequence/iterable) in the target elements, like behaving as keys or legends. :param sequence: :param keygetter: :param valuegetter: :return:
[ "Accumulates", "input", "elements", "according", "to", "accumulate", "()", "but", "keeping", "certain", "data", "(", "per", "element", "from", "the", "original", "sequence", "/", "iterable", ")", "in", "the", "target", "elements", "like", "behaving", "as", "ke...
train
https://github.com/luismasuelli/python-cantrips/blob/dba2742c1d1a60863bb65f4a291464f6e68eb2ee/cantrips/iteration.py#L54-L64
lextoumbourou/txstripe
txstripe/util.py
handle_api_error
def handle_api_error(resp): """Stolen straight from the Stripe Python source.""" content = yield resp.json() headers = HeaderWrapper(resp.headers) try: err = content['error'] except (KeyError, TypeError): raise error.APIError( "Invalid response object from API: %r (HTTP...
python
def handle_api_error(resp): """Stolen straight from the Stripe Python source.""" content = yield resp.json() headers = HeaderWrapper(resp.headers) try: err = content['error'] except (KeyError, TypeError): raise error.APIError( "Invalid response object from API: %r (HTTP...
[ "def", "handle_api_error", "(", "resp", ")", ":", "content", "=", "yield", "resp", ".", "json", "(", ")", "headers", "=", "HeaderWrapper", "(", "resp", ".", "headers", ")", "try", ":", "err", "=", "content", "[", "'error'", "]", "except", "(", "KeyErro...
Stolen straight from the Stripe Python source.
[ "Stolen", "straight", "from", "the", "Stripe", "Python", "source", "." ]
train
https://github.com/lextoumbourou/txstripe/blob/a69e67f524258026fd1840655a0578311bba3b89/txstripe/util.py#L11-L39
DaveMcEwan/ndim
ndim_base.py
vectors_between_pts
def vectors_between_pts(pts=[]): '''Return vectors between points on N dimensions. Last vector is the path between the first and last point, creating a loop. ''' assert isinstance(pts, list) and len(pts) > 0 l_pts = len(pts) l_pt_prev = None for pt in pts: assert isinstance(pt, tuple) ...
python
def vectors_between_pts(pts=[]): '''Return vectors between points on N dimensions. Last vector is the path between the first and last point, creating a loop. ''' assert isinstance(pts, list) and len(pts) > 0 l_pts = len(pts) l_pt_prev = None for pt in pts: assert isinstance(pt, tuple) ...
[ "def", "vectors_between_pts", "(", "pts", "=", "[", "]", ")", ":", "assert", "isinstance", "(", "pts", ",", "list", ")", "and", "len", "(", "pts", ")", ">", "0", "l_pts", "=", "len", "(", "pts", ")", "l_pt_prev", "=", "None", "for", "pt", "in", "...
Return vectors between points on N dimensions. Last vector is the path between the first and last point, creating a loop.
[ "Return", "vectors", "between", "points", "on", "N", "dimensions", ".", "Last", "vector", "is", "the", "path", "between", "the", "first", "and", "last", "point", "creating", "a", "loop", "." ]
train
https://github.com/DaveMcEwan/ndim/blob/f1ea023d3e597160fc1e9e11921de07af659f9d2/ndim_base.py#L8-L26
DaveMcEwan/ndim
ndim_base.py
dir_between_pts
def dir_between_pts(a=(0.0, 0.0), b=(0.0, 0.0)): '''Return direction between two points on N dimensions. List of vectors per pair of dimensions are returned in radians. E.g. Where X is "right", Y is "up", Z is "in" on a computer screen, and returned value is [pi/4, -pi/4], then the vector will be coming out the ...
python
def dir_between_pts(a=(0.0, 0.0), b=(0.0, 0.0)): '''Return direction between two points on N dimensions. List of vectors per pair of dimensions are returned in radians. E.g. Where X is "right", Y is "up", Z is "in" on a computer screen, and returned value is [pi/4, -pi/4], then the vector will be coming out the ...
[ "def", "dir_between_pts", "(", "a", "=", "(", "0.0", ",", "0.0", ")", ",", "b", "=", "(", "0.0", ",", "0.0", ")", ")", ":", "assert", "isinstance", "(", "a", ",", "tuple", ")", "assert", "isinstance", "(", "b", ",", "tuple", ")", "l_pt", "=", "...
Return direction between two points on N dimensions. List of vectors per pair of dimensions are returned in radians. E.g. Where X is "right", Y is "up", Z is "in" on a computer screen, and returned value is [pi/4, -pi/4], then the vector will be coming out the screen over the viewer's right shoulder.
[ "Return", "direction", "between", "two", "points", "on", "N", "dimensions", ".", "List", "of", "vectors", "per", "pair", "of", "dimensions", "are", "returned", "in", "radians", ".", "E", ".", "g", ".", "Where", "X", "is", "right", "Y", "is", "up", "Z",...
train
https://github.com/DaveMcEwan/ndim/blob/f1ea023d3e597160fc1e9e11921de07af659f9d2/ndim_base.py#L29-L53
DaveMcEwan/ndim
ndim_base.py
pt_between_pts
def pt_between_pts(a=(0.0, 0.0), b=(0.0, 0.0), t=0.5): '''Return the point between two points on N dimensions. ''' assert isinstance(a, tuple) assert isinstance(b, tuple) l_pt = len(a) assert l_pt > 1 assert l_pt == len(b) for i in a: assert isinstance(i, float) for i in b: ...
python
def pt_between_pts(a=(0.0, 0.0), b=(0.0, 0.0), t=0.5): '''Return the point between two points on N dimensions. ''' assert isinstance(a, tuple) assert isinstance(b, tuple) l_pt = len(a) assert l_pt > 1 assert l_pt == len(b) for i in a: assert isinstance(i, float) for i in b: ...
[ "def", "pt_between_pts", "(", "a", "=", "(", "0.0", ",", "0.0", ")", ",", "b", "=", "(", "0.0", ",", "0.0", ")", ",", "t", "=", "0.5", ")", ":", "assert", "isinstance", "(", "a", ",", "tuple", ")", "assert", "isinstance", "(", "b", ",", "tuple"...
Return the point between two points on N dimensions.
[ "Return", "the", "point", "between", "two", "points", "on", "N", "dimensions", "." ]
train
https://github.com/DaveMcEwan/ndim/blob/f1ea023d3e597160fc1e9e11921de07af659f9d2/ndim_base.py#L56-L71
DaveMcEwan/ndim
ndim_base.py
distance_between_pts
def distance_between_pts(a=(0.0, 0.0), b=(0.0, 0.0)): '''Return the distance between two points on N dimensions (Euclidean distance). ''' assert isinstance(a, tuple) assert isinstance(b, tuple) l_pt = len(a) assert l_pt > 1 assert l_pt == len(b) for i in a: assert isinstance(i, f...
python
def distance_between_pts(a=(0.0, 0.0), b=(0.0, 0.0)): '''Return the distance between two points on N dimensions (Euclidean distance). ''' assert isinstance(a, tuple) assert isinstance(b, tuple) l_pt = len(a) assert l_pt > 1 assert l_pt == len(b) for i in a: assert isinstance(i, f...
[ "def", "distance_between_pts", "(", "a", "=", "(", "0.0", ",", "0.0", ")", ",", "b", "=", "(", "0.0", ",", "0.0", ")", ")", ":", "assert", "isinstance", "(", "a", ",", "tuple", ")", "assert", "isinstance", "(", "b", ",", "tuple", ")", "l_pt", "="...
Return the distance between two points on N dimensions (Euclidean distance).
[ "Return", "the", "distance", "between", "two", "points", "on", "N", "dimensions", "(", "Euclidean", "distance", ")", "." ]
train
https://github.com/DaveMcEwan/ndim/blob/f1ea023d3e597160fc1e9e11921de07af659f9d2/ndim_base.py#L74-L87
DaveMcEwan/ndim
ndim_base.py
pt_change_axis
def pt_change_axis(pt=(0.0, 0.0), flip=[False, False], offset=[0.0, 0.0]): '''Return given point with axes flipped and offset, converting points between cartesian axis layouts. For example, SVG Y-axis increases top to bottom but DXF is bottom to top. ''' assert isinstance(pt, tuple) l_pt = len(pt) a...
python
def pt_change_axis(pt=(0.0, 0.0), flip=[False, False], offset=[0.0, 0.0]): '''Return given point with axes flipped and offset, converting points between cartesian axis layouts. For example, SVG Y-axis increases top to bottom but DXF is bottom to top. ''' assert isinstance(pt, tuple) l_pt = len(pt) a...
[ "def", "pt_change_axis", "(", "pt", "=", "(", "0.0", ",", "0.0", ")", ",", "flip", "=", "[", "False", ",", "False", "]", ",", "offset", "=", "[", "0.0", ",", "0.0", "]", ")", ":", "assert", "isinstance", "(", "pt", ",", "tuple", ")", "l_pt", "=...
Return given point with axes flipped and offset, converting points between cartesian axis layouts. For example, SVG Y-axis increases top to bottom but DXF is bottom to top.
[ "Return", "given", "point", "with", "axes", "flipped", "and", "offset", "converting", "points", "between", "cartesian", "axis", "layouts", ".", "For", "example", "SVG", "Y", "-", "axis", "increases", "top", "to", "bottom", "but", "DXF", "is", "bottom", "to",...
train
https://github.com/DaveMcEwan/ndim/blob/f1ea023d3e597160fc1e9e11921de07af659f9d2/ndim_base.py#L90-L113
DaveMcEwan/ndim
ndim_base.py
pts_change_axis
def pts_change_axis(pts=[], flip=[False, False], offset=[0.0, 0.0]): '''Return given point with axes flipped and offset, converting points between cartesian axis layouts. For example, SVG Y-axis increases top to bottom but DXF is bottom to top. ''' assert isinstance(pts, list) and len(pts) > 0 l_pt_prev...
python
def pts_change_axis(pts=[], flip=[False, False], offset=[0.0, 0.0]): '''Return given point with axes flipped and offset, converting points between cartesian axis layouts. For example, SVG Y-axis increases top to bottom but DXF is bottom to top. ''' assert isinstance(pts, list) and len(pts) > 0 l_pt_prev...
[ "def", "pts_change_axis", "(", "pts", "=", "[", "]", ",", "flip", "=", "[", "False", ",", "False", "]", ",", "offset", "=", "[", "0.0", ",", "0.0", "]", ")", ":", "assert", "isinstance", "(", "pts", ",", "list", ")", "and", "len", "(", "pts", "...
Return given point with axes flipped and offset, converting points between cartesian axis layouts. For example, SVG Y-axis increases top to bottom but DXF is bottom to top.
[ "Return", "given", "point", "with", "axes", "flipped", "and", "offset", "converting", "points", "between", "cartesian", "axis", "layouts", ".", "For", "example", "SVG", "Y", "-", "axis", "increases", "top", "to", "bottom", "but", "DXF", "is", "bottom", "to",...
train
https://github.com/DaveMcEwan/ndim/blob/f1ea023d3e597160fc1e9e11921de07af659f9d2/ndim_base.py#L116-L142
DaveMcEwan/ndim
ndim_base.py
pt_rotate
def pt_rotate(pt=(0.0, 0.0), angle=[0.0], center=(0.0, 0.0)): '''Return given point rotated around a center point in N dimensions. Angle is list of rotation in radians for each pair of axis. ''' assert isinstance(pt, tuple) l_pt = len(pt) assert l_pt > 1 for i in pt: assert isinstance(i,...
python
def pt_rotate(pt=(0.0, 0.0), angle=[0.0], center=(0.0, 0.0)): '''Return given point rotated around a center point in N dimensions. Angle is list of rotation in radians for each pair of axis. ''' assert isinstance(pt, tuple) l_pt = len(pt) assert l_pt > 1 for i in pt: assert isinstance(i,...
[ "def", "pt_rotate", "(", "pt", "=", "(", "0.0", ",", "0.0", ")", ",", "angle", "=", "[", "0.0", "]", ",", "center", "=", "(", "0.0", ",", "0.0", ")", ")", ":", "assert", "isinstance", "(", "pt", ",", "tuple", ")", "l_pt", "=", "len", "(", "pt...
Return given point rotated around a center point in N dimensions. Angle is list of rotation in radians for each pair of axis.
[ "Return", "given", "point", "rotated", "around", "a", "center", "point", "in", "N", "dimensions", ".", "Angle", "is", "list", "of", "rotation", "in", "radians", "for", "each", "pair", "of", "axis", "." ]
train
https://github.com/DaveMcEwan/ndim/blob/f1ea023d3e597160fc1e9e11921de07af659f9d2/ndim_base.py#L145-L180
DaveMcEwan/ndim
ndim_base.py
pts_rotate
def pts_rotate(pts=[], angle=[0.0], center=(0.0, 0.0)): '''Return given points rotated around a center point in N dimensions. Angle is list of rotation in radians for each pair of axis. ''' assert isinstance(pts, list) and len(pts) > 0 l_pt_prev = None for pt in pts: assert isinstance(pt, tu...
python
def pts_rotate(pts=[], angle=[0.0], center=(0.0, 0.0)): '''Return given points rotated around a center point in N dimensions. Angle is list of rotation in radians for each pair of axis. ''' assert isinstance(pts, list) and len(pts) > 0 l_pt_prev = None for pt in pts: assert isinstance(pt, tu...
[ "def", "pts_rotate", "(", "pts", "=", "[", "]", ",", "angle", "=", "[", "0.0", "]", ",", "center", "=", "(", "0.0", ",", "0.0", ")", ")", ":", "assert", "isinstance", "(", "pts", ",", "list", ")", "and", "len", "(", "pts", ")", ">", "0", "l_p...
Return given points rotated around a center point in N dimensions. Angle is list of rotation in radians for each pair of axis.
[ "Return", "given", "points", "rotated", "around", "a", "center", "point", "in", "N", "dimensions", ".", "Angle", "is", "list", "of", "rotation", "in", "radians", "for", "each", "pair", "of", "axis", "." ]
train
https://github.com/DaveMcEwan/ndim/blob/f1ea023d3e597160fc1e9e11921de07af659f9d2/ndim_base.py#L183-L209
DaveMcEwan/ndim
ndim_base.py
pt_shift
def pt_shift(pt=(0.0, 0.0), shift=[0.0, 0.0]): '''Return given point shifted in N dimensions. ''' assert isinstance(pt, tuple) l_pt = len(pt) assert l_pt > 1 for i in pt: assert isinstance(i, float) assert isinstance(shift, list) l_sh = len(shift) assert l_sh == l_pt for ...
python
def pt_shift(pt=(0.0, 0.0), shift=[0.0, 0.0]): '''Return given point shifted in N dimensions. ''' assert isinstance(pt, tuple) l_pt = len(pt) assert l_pt > 1 for i in pt: assert isinstance(i, float) assert isinstance(shift, list) l_sh = len(shift) assert l_sh == l_pt for ...
[ "def", "pt_shift", "(", "pt", "=", "(", "0.0", ",", "0.0", ")", ",", "shift", "=", "[", "0.0", ",", "0.0", "]", ")", ":", "assert", "isinstance", "(", "pt", ",", "tuple", ")", "l_pt", "=", "len", "(", "pt", ")", "assert", "l_pt", ">", "1", "f...
Return given point shifted in N dimensions.
[ "Return", "given", "point", "shifted", "in", "N", "dimensions", "." ]
train
https://github.com/DaveMcEwan/ndim/blob/f1ea023d3e597160fc1e9e11921de07af659f9d2/ndim_base.py#L212-L226
DaveMcEwan/ndim
ndim_base.py
pts_shift
def pts_shift(pts=[], shift=[0.0, 0.0]): '''Return given points shifted in N dimensions. ''' assert isinstance(pts, list) and len(pts) > 0 l_pt_prev = None for pt in pts: assert isinstance(pt, tuple) l_pt = len(pt) assert l_pt > 1 for i in pt: assert isins...
python
def pts_shift(pts=[], shift=[0.0, 0.0]): '''Return given points shifted in N dimensions. ''' assert isinstance(pts, list) and len(pts) > 0 l_pt_prev = None for pt in pts: assert isinstance(pt, tuple) l_pt = len(pt) assert l_pt > 1 for i in pt: assert isins...
[ "def", "pts_shift", "(", "pts", "=", "[", "]", ",", "shift", "=", "[", "0.0", ",", "0.0", "]", ")", ":", "assert", "isinstance", "(", "pts", ",", "list", ")", "and", "len", "(", "pts", ")", ">", "0", "l_pt_prev", "=", "None", "for", "pt", "in",...
Return given points shifted in N dimensions.
[ "Return", "given", "points", "shifted", "in", "N", "dimensions", "." ]
train
https://github.com/DaveMcEwan/ndim/blob/f1ea023d3e597160fc1e9e11921de07af659f9d2/ndim_base.py#L229-L249
DaveMcEwan/ndim
ndim_base.py
pt_relative
def pt_relative(pt=(0.0, 0.0), shift=[0.0, 0.0], angle=[0.0]): '''Convenience shift+rotate combination. ''' assert isinstance(pt, tuple) l_pt = len(pt) assert l_pt > 1 for i in pt: assert isinstance(i, float) assert isinstance(shift, list) l_sh = len(shift) assert l_sh == l_p...
python
def pt_relative(pt=(0.0, 0.0), shift=[0.0, 0.0], angle=[0.0]): '''Convenience shift+rotate combination. ''' assert isinstance(pt, tuple) l_pt = len(pt) assert l_pt > 1 for i in pt: assert isinstance(i, float) assert isinstance(shift, list) l_sh = len(shift) assert l_sh == l_p...
[ "def", "pt_relative", "(", "pt", "=", "(", "0.0", ",", "0.0", ")", ",", "shift", "=", "[", "0.0", ",", "0.0", "]", ",", "angle", "=", "[", "0.0", "]", ")", ":", "assert", "isinstance", "(", "pt", ",", "tuple", ")", "l_pt", "=", "len", "(", "p...
Convenience shift+rotate combination.
[ "Convenience", "shift", "+", "rotate", "combination", "." ]
train
https://github.com/DaveMcEwan/ndim/blob/f1ea023d3e597160fc1e9e11921de07af659f9d2/ndim_base.py#L252-L272
DaveMcEwan/ndim
ndim_base.py
pts_relative
def pts_relative(pts=[], shift=[0.0, 0.0], angle=[0.0]): '''Convenience shift+rotate combination. ''' assert isinstance(pts, list) and len(pts) > 0 l_pt_prev = None for pt in pts: assert isinstance(pt, tuple) l_pt = len(pt) assert l_pt > 1 for i in pt: ass...
python
def pts_relative(pts=[], shift=[0.0, 0.0], angle=[0.0]): '''Convenience shift+rotate combination. ''' assert isinstance(pts, list) and len(pts) > 0 l_pt_prev = None for pt in pts: assert isinstance(pt, tuple) l_pt = len(pt) assert l_pt > 1 for i in pt: ass...
[ "def", "pts_relative", "(", "pts", "=", "[", "]", ",", "shift", "=", "[", "0.0", ",", "0.0", "]", ",", "angle", "=", "[", "0.0", "]", ")", ":", "assert", "isinstance", "(", "pts", ",", "list", ")", "and", "len", "(", "pts", ")", ">", "0", "l_...
Convenience shift+rotate combination.
[ "Convenience", "shift", "+", "rotate", "combination", "." ]
train
https://github.com/DaveMcEwan/ndim/blob/f1ea023d3e597160fc1e9e11921de07af659f9d2/ndim_base.py#L275-L301
DaveMcEwan/ndim
ndim_base.py
pt_reflect
def pt_reflect(pt=(0.0, 0.0), plane=[None, None]): '''Return given point reflected around planes in N dimensions. There must be the same number of planes as dimensions, but the value of each plane may be None to indicate no reflection. ''' assert isinstance(pt, tuple) l_pt = len(pt) assert l_pt > ...
python
def pt_reflect(pt=(0.0, 0.0), plane=[None, None]): '''Return given point reflected around planes in N dimensions. There must be the same number of planes as dimensions, but the value of each plane may be None to indicate no reflection. ''' assert isinstance(pt, tuple) l_pt = len(pt) assert l_pt > ...
[ "def", "pt_reflect", "(", "pt", "=", "(", "0.0", ",", "0.0", ")", ",", "plane", "=", "[", "None", ",", "None", "]", ")", ":", "assert", "isinstance", "(", "pt", ",", "tuple", ")", "l_pt", "=", "len", "(", "pt", ")", "assert", "l_pt", ">", "1", ...
Return given point reflected around planes in N dimensions. There must be the same number of planes as dimensions, but the value of each plane may be None to indicate no reflection.
[ "Return", "given", "point", "reflected", "around", "planes", "in", "N", "dimensions", ".", "There", "must", "be", "the", "same", "number", "of", "planes", "as", "dimensions", "but", "the", "value", "of", "each", "plane", "may", "be", "None", "to", "indicat...
train
https://github.com/DaveMcEwan/ndim/blob/f1ea023d3e597160fc1e9e11921de07af659f9d2/ndim_base.py#L304-L320
DaveMcEwan/ndim
ndim_base.py
pts_reflect
def pts_reflect(pts=[], plane=[None, None]): '''Return given point reflected around planes in N dimensions. There must be the same number of planes as dimensions, but the value of each plane may be None to indicate no reflection. ''' assert isinstance(pts, list) and len(pts) > 0 l_pt_prev = None f...
python
def pts_reflect(pts=[], plane=[None, None]): '''Return given point reflected around planes in N dimensions. There must be the same number of planes as dimensions, but the value of each plane may be None to indicate no reflection. ''' assert isinstance(pts, list) and len(pts) > 0 l_pt_prev = None f...
[ "def", "pts_reflect", "(", "pts", "=", "[", "]", ",", "plane", "=", "[", "None", ",", "None", "]", ")", ":", "assert", "isinstance", "(", "pts", ",", "list", ")", "and", "len", "(", "pts", ")", ">", "0", "l_pt_prev", "=", "None", "for", "pt", "...
Return given point reflected around planes in N dimensions. There must be the same number of planes as dimensions, but the value of each plane may be None to indicate no reflection.
[ "Return", "given", "point", "reflected", "around", "planes", "in", "N", "dimensions", ".", "There", "must", "be", "the", "same", "number", "of", "planes", "as", "dimensions", "but", "the", "value", "of", "each", "plane", "may", "be", "None", "to", "indicat...
train
https://github.com/DaveMcEwan/ndim/blob/f1ea023d3e597160fc1e9e11921de07af659f9d2/ndim_base.py#L323-L345
DaveMcEwan/ndim
ndim_base.py
pt_scale
def pt_scale(pt=(0.0, 0.0), f=1.0): '''Return given point scaled by factor f from origin. ''' assert isinstance(pt, tuple) l_pt = len(pt) assert l_pt > 1 for i in pt: assert isinstance(i, float) assert isinstance(f, float) return tuple([pt[i]*f for i in range(l_pt)])
python
def pt_scale(pt=(0.0, 0.0), f=1.0): '''Return given point scaled by factor f from origin. ''' assert isinstance(pt, tuple) l_pt = len(pt) assert l_pt > 1 for i in pt: assert isinstance(i, float) assert isinstance(f, float) return tuple([pt[i]*f for i in range(l_pt)])
[ "def", "pt_scale", "(", "pt", "=", "(", "0.0", ",", "0.0", ")", ",", "f", "=", "1.0", ")", ":", "assert", "isinstance", "(", "pt", ",", "tuple", ")", "l_pt", "=", "len", "(", "pt", ")", "assert", "l_pt", ">", "1", "for", "i", "in", "pt", ":",...
Return given point scaled by factor f from origin.
[ "Return", "given", "point", "scaled", "by", "factor", "f", "from", "origin", "." ]
train
https://github.com/DaveMcEwan/ndim/blob/f1ea023d3e597160fc1e9e11921de07af659f9d2/ndim_base.py#L348-L358
DaveMcEwan/ndim
ndim_base.py
pts_scale
def pts_scale(pts=[], f=1.0): '''Return given points scaled by factor f from origin. ''' assert isinstance(pts, list) and len(pts) > 0 l_pt_prev = None for pt in pts: assert isinstance(pt, tuple) l_pt = len(pt) assert l_pt > 1 for i in pt: assert isinstanc...
python
def pts_scale(pts=[], f=1.0): '''Return given points scaled by factor f from origin. ''' assert isinstance(pts, list) and len(pts) > 0 l_pt_prev = None for pt in pts: assert isinstance(pt, tuple) l_pt = len(pt) assert l_pt > 1 for i in pt: assert isinstanc...
[ "def", "pts_scale", "(", "pts", "=", "[", "]", ",", "f", "=", "1.0", ")", ":", "assert", "isinstance", "(", "pts", ",", "list", ")", "and", "len", "(", "pts", ")", ">", "0", "l_pt_prev", "=", "None", "for", "pt", "in", "pts", ":", "assert", "is...
Return given points scaled by factor f from origin.
[ "Return", "given", "points", "scaled", "by", "factor", "f", "from", "origin", "." ]
train
https://github.com/DaveMcEwan/ndim/blob/f1ea023d3e597160fc1e9e11921de07af659f9d2/ndim_base.py#L361-L377
DaveMcEwan/ndim
ndim_base.py
angle_diff
def angle_diff(start_a=[0.0], end_a=[0.0], direction=True): '''Return difference in angle from start_a to end_a. Direction follows the right-hand-rule so positive is counter-clockwise. ''' assert isinstance(start_a, list) assert isinstance(end_a, list) l_angle = len(start_a) assert l_angle > 0 ...
python
def angle_diff(start_a=[0.0], end_a=[0.0], direction=True): '''Return difference in angle from start_a to end_a. Direction follows the right-hand-rule so positive is counter-clockwise. ''' assert isinstance(start_a, list) assert isinstance(end_a, list) l_angle = len(start_a) assert l_angle > 0 ...
[ "def", "angle_diff", "(", "start_a", "=", "[", "0.0", "]", ",", "end_a", "=", "[", "0.0", "]", ",", "direction", "=", "True", ")", ":", "assert", "isinstance", "(", "start_a", ",", "list", ")", "assert", "isinstance", "(", "end_a", ",", "list", ")", ...
Return difference in angle from start_a to end_a. Direction follows the right-hand-rule so positive is counter-clockwise.
[ "Return", "difference", "in", "angle", "from", "start_a", "to", "end_a", ".", "Direction", "follows", "the", "right", "-", "hand", "-", "rule", "so", "positive", "is", "counter", "-", "clockwise", "." ]
train
https://github.com/DaveMcEwan/ndim/blob/f1ea023d3e597160fc1e9e11921de07af659f9d2/ndim_base.py#L380-L402
DaveMcEwan/ndim
ndim_base.py
gen_polygon_pts
def gen_polygon_pts(n_pts=3, radius=[1.0]): '''Generate points for a polygon with a number of radiuses. This makes it easy to generate shapes with an arbitrary number of sides, regularly angled around the origin. A single radius will give a simple shape such as a square, hexagon, etc. Multiple radiuses will give ...
python
def gen_polygon_pts(n_pts=3, radius=[1.0]): '''Generate points for a polygon with a number of radiuses. This makes it easy to generate shapes with an arbitrary number of sides, regularly angled around the origin. A single radius will give a simple shape such as a square, hexagon, etc. Multiple radiuses will give ...
[ "def", "gen_polygon_pts", "(", "n_pts", "=", "3", ",", "radius", "=", "[", "1.0", "]", ")", ":", "assert", "isinstance", "(", "n_pts", ",", "int", ")", "and", "n_pts", ">", "0", "assert", "isinstance", "(", "radius", ",", "list", ")", "l_rad", "=", ...
Generate points for a polygon with a number of radiuses. This makes it easy to generate shapes with an arbitrary number of sides, regularly angled around the origin. A single radius will give a simple shape such as a square, hexagon, etc. Multiple radiuses will give complex shapes like stars, gear wheels, ratchet w...
[ "Generate", "points", "for", "a", "polygon", "with", "a", "number", "of", "radiuses", ".", "This", "makes", "it", "easy", "to", "generate", "shapes", "with", "an", "arbitrary", "number", "of", "sides", "regularly", "angled", "around", "the", "origin", ".", ...
train
https://github.com/DaveMcEwan/ndim/blob/f1ea023d3e597160fc1e9e11921de07af659f9d2/ndim_base.py#L405-L421
redbridge/molnctrl
molnctrl/__init__.py
_add_params_docstring
def _add_params_docstring(params): """ Add params to doc string """ p_string = "\nAccepts the following paramters: \n" for param in params: p_string += "name: %s, required: %s, description: %s \n" % (param['name'], param['required'], param['description']) return p_string
python
def _add_params_docstring(params): """ Add params to doc string """ p_string = "\nAccepts the following paramters: \n" for param in params: p_string += "name: %s, required: %s, description: %s \n" % (param['name'], param['required'], param['description']) return p_string
[ "def", "_add_params_docstring", "(", "params", ")", ":", "p_string", "=", "\"\\nAccepts the following paramters: \\n\"", "for", "param", "in", "params", ":", "p_string", "+=", "\"name: %s, required: %s, description: %s \\n\"", "%", "(", "param", "[", "'name'", "]", ",",...
Add params to doc string
[ "Add", "params", "to", "doc", "string" ]
train
https://github.com/redbridge/molnctrl/blob/9990ae7e522ce364bb61a735f774dc28de5f8e60/molnctrl/__init__.py#L40-L46
redbridge/molnctrl
molnctrl/__init__.py
_create_api_method
def _create_api_method(cls, name, api_method): """ Create dynamic class methods based on the Cloudmonkey precached_verbs """ def _api_method(self, **kwargs): # lookup the command command = api_method['name'] if kwargs: return self._make_request(command, kwargs) el...
python
def _create_api_method(cls, name, api_method): """ Create dynamic class methods based on the Cloudmonkey precached_verbs """ def _api_method(self, **kwargs): # lookup the command command = api_method['name'] if kwargs: return self._make_request(command, kwargs) el...
[ "def", "_create_api_method", "(", "cls", ",", "name", ",", "api_method", ")", ":", "def", "_api_method", "(", "self", ",", "*", "*", "kwargs", ")", ":", "# lookup the command", "command", "=", "api_method", "[", "'name'", "]", "if", "kwargs", ":", "return"...
Create dynamic class methods based on the Cloudmonkey precached_verbs
[ "Create", "dynamic", "class", "methods", "based", "on", "the", "Cloudmonkey", "precached_verbs" ]
train
https://github.com/redbridge/molnctrl/blob/9990ae7e522ce364bb61a735f774dc28de5f8e60/molnctrl/__init__.py#L48-L62
redbridge/molnctrl
molnctrl/__init__.py
Initialize
def Initialize(api_key, api_secret, api_host="localhost", api_port=443, api_ssl=True, asyncblock=False, timeout=10, req_method="get"): """ Initializes the Cloudstack API Accepts arguments: api_host (localhost) api_port (443) api_ssl (True) api_key ...
python
def Initialize(api_key, api_secret, api_host="localhost", api_port=443, api_ssl=True, asyncblock=False, timeout=10, req_method="get"): """ Initializes the Cloudstack API Accepts arguments: api_host (localhost) api_port (443) api_ssl (True) api_key ...
[ "def", "Initialize", "(", "api_key", ",", "api_secret", ",", "api_host", "=", "\"localhost\"", ",", "api_port", "=", "443", ",", "api_ssl", "=", "True", ",", "asyncblock", "=", "False", ",", "timeout", "=", "10", ",", "req_method", "=", "\"get\"", ")", "...
Initializes the Cloudstack API Accepts arguments: api_host (localhost) api_port (443) api_ssl (True) api_key api_secret
[ "Initializes", "the", "Cloudstack", "API", "Accepts", "arguments", ":", "api_host", "(", "localhost", ")", "api_port", "(", "443", ")", "api_ssl", "(", "True", ")", "api_key", "api_secret" ]
train
https://github.com/redbridge/molnctrl/blob/9990ae7e522ce364bb61a735f774dc28de5f8e60/molnctrl/__init__.py#L65-L109
deviantony/valigator
valigator/valigator.py
validate
def validate(backup): """Use this endpoint to start a backup validation. You must specify the backup type in the endpoint. Specify JSON data for backup archive info. { 'archive_path': '/path/to/archive' } Data must be valid, otherwise it will abort with a 400 code. First, it will ...
python
def validate(backup): """Use this endpoint to start a backup validation. You must specify the backup type in the endpoint. Specify JSON data for backup archive info. { 'archive_path': '/path/to/archive' } Data must be valid, otherwise it will abort with a 400 code. First, it will ...
[ "def", "validate", "(", "backup", ")", ":", "data", "=", "request", ".", "json", "if", "not", "data", ":", "abort", "(", "400", ",", "'No data received'", ")", "try", ":", "archive_path", "=", "data", "[", "'archive_path'", "]", "except", "KeyError", ":"...
Use this endpoint to start a backup validation. You must specify the backup type in the endpoint. Specify JSON data for backup archive info. { 'archive_path': '/path/to/archive' } Data must be valid, otherwise it will abort with a 400 code. First, it will try to search for an existing...
[ "Use", "this", "endpoint", "to", "start", "a", "backup", "validation", ".", "You", "must", "specify", "the", "backup", "type", "in", "the", "endpoint", ".", "Specify", "JSON", "data", "for", "backup", "archive", "info", "." ]
train
https://github.com/deviantony/valigator/blob/0557029bc58ea1270e358c14ca382d3807ed5b6f/valigator/valigator.py#L10-L47
deviantony/valigator
valigator/valigator.py
main
def main(conf): """Main function, entry point of the program.""" global config config = load_configuration(conf) app.conf.update(config['celery']) run(host=config['valigator']['bind'], port=config['valigator']['port'])
python
def main(conf): """Main function, entry point of the program.""" global config config = load_configuration(conf) app.conf.update(config['celery']) run(host=config['valigator']['bind'], port=config['valigator']['port'])
[ "def", "main", "(", "conf", ")", ":", "global", "config", "config", "=", "load_configuration", "(", "conf", ")", "app", ".", "conf", ".", "update", "(", "config", "[", "'celery'", "]", ")", "run", "(", "host", "=", "config", "[", "'valigator'", "]", ...
Main function, entry point of the program.
[ "Main", "function", "entry", "point", "of", "the", "program", "." ]
train
https://github.com/deviantony/valigator/blob/0557029bc58ea1270e358c14ca382d3807ed5b6f/valigator/valigator.py#L54-L59
Raynes/quarantine
quarantine/__main__.py
install
def install(name, pip_args): """Install the package. Pip args specified with --.""" cdc = CDC(name) try: cdc.install(pip_args) except ErrorReturnCode as e: print_pretty("<FG_RED>Something went wrong! Rolling back...<END>") cdc.uninstall()
python
def install(name, pip_args): """Install the package. Pip args specified with --.""" cdc = CDC(name) try: cdc.install(pip_args) except ErrorReturnCode as e: print_pretty("<FG_RED>Something went wrong! Rolling back...<END>") cdc.uninstall()
[ "def", "install", "(", "name", ",", "pip_args", ")", ":", "cdc", "=", "CDC", "(", "name", ")", "try", ":", "cdc", ".", "install", "(", "pip_args", ")", "except", "ErrorReturnCode", "as", "e", ":", "print_pretty", "(", "\"<FG_RED>Something went wrong! Rolling...
Install the package. Pip args specified with --.
[ "Install", "the", "package", ".", "Pip", "args", "specified", "with", "--", "." ]
train
https://github.com/Raynes/quarantine/blob/742a318fcb7d34dbdf4fac388daff03a36872d8b/quarantine/__main__.py#L15-L22
shi-cong/PYSTUDY
PYSTUDY/net/fingerlib.py
get_host_finger
def get_host_finger(protocol, ip, port, timeout=5): """ 获取远程主机特定端口下服务的指纹 :param protocol: 协议,tcp / udp :params ip: ip :params port: 端口 :return: 服务器指纹 """ client = None msg = b"Hello, Server\r\n" if protocol == 'tcp': # tcp 协议 client = socket.socket(socket.AF_INET,...
python
def get_host_finger(protocol, ip, port, timeout=5): """ 获取远程主机特定端口下服务的指纹 :param protocol: 协议,tcp / udp :params ip: ip :params port: 端口 :return: 服务器指纹 """ client = None msg = b"Hello, Server\r\n" if protocol == 'tcp': # tcp 协议 client = socket.socket(socket.AF_INET,...
[ "def", "get_host_finger", "(", "protocol", ",", "ip", ",", "port", ",", "timeout", "=", "5", ")", ":", "client", "=", "None", "msg", "=", "b\"Hello, Server\\r\\n\"", "if", "protocol", "==", "'tcp'", ":", "# tcp 协议", "client", "=", "socket", ".", "socket", ...
获取远程主机特定端口下服务的指纹 :param protocol: 协议,tcp / udp :params ip: ip :params port: 端口 :return: 服务器指纹
[ "获取远程主机特定端口下服务的指纹", ":", "param", "protocol", ":", "协议,tcp", "/", "udp", ":", "params", "ip", ":", "ip", ":", "params", "port", ":", "端口", ":", "return", ":", "服务器指纹" ]
train
https://github.com/shi-cong/PYSTUDY/blob/c8da7128ea18ecaa5849f2066d321e70d6f97f70/PYSTUDY/net/fingerlib.py#L7-L33
cdeboever3/cdpybio
cdpybio/variants.py
record_variant_id
def record_variant_id(record): """Get variant ID from pyvcf.model._Record""" if record.ID: return record.ID else: return record.CHROM + ':' + str(record.POS)
python
def record_variant_id(record): """Get variant ID from pyvcf.model._Record""" if record.ID: return record.ID else: return record.CHROM + ':' + str(record.POS)
[ "def", "record_variant_id", "(", "record", ")", ":", "if", "record", ".", "ID", ":", "return", "record", ".", "ID", "else", ":", "return", "record", ".", "CHROM", "+", "':'", "+", "str", "(", "record", ".", "POS", ")" ]
Get variant ID from pyvcf.model._Record
[ "Get", "variant", "ID", "from", "pyvcf", ".", "model", ".", "_Record" ]
train
https://github.com/cdeboever3/cdpybio/blob/38efdf0e11d01bc00a135921cb91a19c03db5d5c/cdpybio/variants.py#L7-L12
cdeboever3/cdpybio
cdpybio/variants.py
wasp_snp_directory
def wasp_snp_directory(vcf, directory, sample_name=None): """ Convert VCF file into input for WASP. Only bi-allelic heterozygous sites are used. Parameters: ----------- vcf : str Path to VCF file. directory : str Output directory. This is the directory that will hold the fi...
python
def wasp_snp_directory(vcf, directory, sample_name=None): """ Convert VCF file into input for WASP. Only bi-allelic heterozygous sites are used. Parameters: ----------- vcf : str Path to VCF file. directory : str Output directory. This is the directory that will hold the fi...
[ "def", "wasp_snp_directory", "(", "vcf", ",", "directory", ",", "sample_name", "=", "None", ")", ":", "chrom", "=", "[", "]", "pos", "=", "[", "]", "ref", "=", "[", "]", "alt", "=", "[", "]", "vcf_reader", "=", "pyvcf", ".", "Reader", "(", "open", ...
Convert VCF file into input for WASP. Only bi-allelic heterozygous sites are used. Parameters: ----------- vcf : str Path to VCF file. directory : str Output directory. This is the directory that will hold the files for WASP. sample_name : str If provided, use ...
[ "Convert", "VCF", "file", "into", "input", "for", "WASP", ".", "Only", "bi", "-", "allelic", "heterozygous", "sites", "are", "used", "." ]
train
https://github.com/cdeboever3/cdpybio/blob/38efdf0e11d01bc00a135921cb91a19c03db5d5c/cdpybio/variants.py#L32-L81
cdeboever3/cdpybio
cdpybio/variants.py
vcf_as_df
def vcf_as_df(fn): """ Read VCF file into pandas DataFrame. Parameters: ----------- fn : str Path to VCF file. Returns ------- df : pandas.DataFrame The VCF file as a data frame. Note that all header information is thrown away. """ header_lines = 0 ...
python
def vcf_as_df(fn): """ Read VCF file into pandas DataFrame. Parameters: ----------- fn : str Path to VCF file. Returns ------- df : pandas.DataFrame The VCF file as a data frame. Note that all header information is thrown away. """ header_lines = 0 ...
[ "def", "vcf_as_df", "(", "fn", ")", ":", "header_lines", "=", "0", "with", "open", "(", "fn", ",", "'r'", ")", "as", "f", ":", "line", "=", "f", ".", "readline", "(", ")", ".", "strip", "(", ")", "header_lines", "+=", "1", "while", "line", "[", ...
Read VCF file into pandas DataFrame. Parameters: ----------- fn : str Path to VCF file. Returns ------- df : pandas.DataFrame The VCF file as a data frame. Note that all header information is thrown away.
[ "Read", "VCF", "file", "into", "pandas", "DataFrame", "." ]
train
https://github.com/cdeboever3/cdpybio/blob/38efdf0e11d01bc00a135921cb91a19c03db5d5c/cdpybio/variants.py#L83-L110
cdeboever3/cdpybio
cdpybio/variants.py
make_het_matrix
def make_het_matrix(fn): """ Make boolean matrix of samples by variants. One indicates that the sample is heterozygous for that variant. Parameters: ----------- vcf : str Path to VCF file. """ # TODO: parallelize? vcf_df = vcf_as_df(fn) variant_ids = vcf_df.apply(lambda...
python
def make_het_matrix(fn): """ Make boolean matrix of samples by variants. One indicates that the sample is heterozygous for that variant. Parameters: ----------- vcf : str Path to VCF file. """ # TODO: parallelize? vcf_df = vcf_as_df(fn) variant_ids = vcf_df.apply(lambda...
[ "def", "make_het_matrix", "(", "fn", ")", ":", "# TODO: parallelize?", "vcf_df", "=", "vcf_as_df", "(", "fn", ")", "variant_ids", "=", "vcf_df", ".", "apply", "(", "lambda", "x", ":", "df_variant_id", "(", "x", ")", ",", "axis", "=", "1", ")", "vcf_reade...
Make boolean matrix of samples by variants. One indicates that the sample is heterozygous for that variant. Parameters: ----------- vcf : str Path to VCF file.
[ "Make", "boolean", "matrix", "of", "samples", "by", "variants", ".", "One", "indicates", "that", "the", "sample", "is", "heterozygous", "for", "that", "variant", "." ]
train
https://github.com/cdeboever3/cdpybio/blob/38efdf0e11d01bc00a135921cb91a19c03db5d5c/cdpybio/variants.py#L112-L137
shi-cong/PYSTUDY
PYSTUDY/oslib.py
write_image
def write_image(r, filename): """ 将流式数据存储在文件中 :param r: 响应 :param filename: 文件名 :return: """ with open(filename, 'wb') as fd: for chunk in r.iter_content(1024): fd.write(chunk)
python
def write_image(r, filename): """ 将流式数据存储在文件中 :param r: 响应 :param filename: 文件名 :return: """ with open(filename, 'wb') as fd: for chunk in r.iter_content(1024): fd.write(chunk)
[ "def", "write_image", "(", "r", ",", "filename", ")", ":", "with", "open", "(", "filename", ",", "'wb'", ")", "as", "fd", ":", "for", "chunk", "in", "r", ".", "iter_content", "(", "1024", ")", ":", "fd", ".", "write", "(", "chunk", ")" ]
将流式数据存储在文件中 :param r: 响应 :param filename: 文件名 :return:
[ "将流式数据存储在文件中", ":", "param", "r", ":", "响应", ":", "param", "filename", ":", "文件名", ":", "return", ":" ]
train
https://github.com/shi-cong/PYSTUDY/blob/c8da7128ea18ecaa5849f2066d321e70d6f97f70/PYSTUDY/oslib.py#L123-L132
shi-cong/PYSTUDY
PYSTUDY/oslib.py
listdir
def listdir(directory): """ 列出文件夹中的内容 :param directory: 文件夹名 :return: 文件名数组 """ tmp = [] for f in os.listdir(directory): tmp.append(f) return tmp
python
def listdir(directory): """ 列出文件夹中的内容 :param directory: 文件夹名 :return: 文件名数组 """ tmp = [] for f in os.listdir(directory): tmp.append(f) return tmp
[ "def", "listdir", "(", "directory", ")", ":", "tmp", "=", "[", "]", "for", "f", "in", "os", ".", "listdir", "(", "directory", ")", ":", "tmp", ".", "append", "(", "f", ")", "return", "tmp" ]
列出文件夹中的内容 :param directory: 文件夹名 :return: 文件名数组
[ "列出文件夹中的内容", ":", "param", "directory", ":", "文件夹名", ":", "return", ":", "文件名数组" ]
train
https://github.com/shi-cong/PYSTUDY/blob/c8da7128ea18ecaa5849f2066d321e70d6f97f70/PYSTUDY/oslib.py#L134-L143
shi-cong/PYSTUDY
PYSTUDY/oslib.py
set_env
def set_env(envName, envValue): """ 设置环境变量 :params envName: env名字 :params envValue: 值 """ os.environ[envName] = os.environ[envName] + ':' + envValue
python
def set_env(envName, envValue): """ 设置环境变量 :params envName: env名字 :params envValue: 值 """ os.environ[envName] = os.environ[envName] + ':' + envValue
[ "def", "set_env", "(", "envName", ",", "envValue", ")", ":", "os", ".", "environ", "[", "envName", "]", "=", "os", ".", "environ", "[", "envName", "]", "+", "':'", "+", "envValue" ]
设置环境变量 :params envName: env名字 :params envValue: 值
[ "设置环境变量", ":", "params", "envName", ":", "env名字", ":", "params", "envValue", ":", "值" ]
train
https://github.com/shi-cong/PYSTUDY/blob/c8da7128ea18ecaa5849f2066d321e70d6f97f70/PYSTUDY/oslib.py#L152-L158
frascoweb/frasco-users
frasco_users/__init__.py
UsersFeature.current
def current(self): """Returns the current user """ if not has_request_context(): return self.no_req_ctx_user_stack.top user_stack = getattr(_request_ctx_stack.top, 'user_stack', None) if user_stack and user_stack.top: return user_stack.top return _...
python
def current(self): """Returns the current user """ if not has_request_context(): return self.no_req_ctx_user_stack.top user_stack = getattr(_request_ctx_stack.top, 'user_stack', None) if user_stack and user_stack.top: return user_stack.top return _...
[ "def", "current", "(", "self", ")", ":", "if", "not", "has_request_context", "(", ")", ":", "return", "self", ".", "no_req_ctx_user_stack", ".", "top", "user_stack", "=", "getattr", "(", "_request_ctx_stack", ".", "top", ",", "'user_stack'", ",", "None", ")"...
Returns the current user
[ "Returns", "the", "current", "user" ]
train
https://github.com/frascoweb/frasco-users/blob/16591ca466de5b7c80d7a2384327d9cf2d919c41/frasco_users/__init__.py#L233-L241
frascoweb/frasco-users
frasco_users/__init__.py
UsersFeature.generate_user_token
def generate_user_token(self, user, salt=None): """Generates a unique token associated to the user """ return self.token_serializer.dumps(str(user.id), salt=salt)
python
def generate_user_token(self, user, salt=None): """Generates a unique token associated to the user """ return self.token_serializer.dumps(str(user.id), salt=salt)
[ "def", "generate_user_token", "(", "self", ",", "user", ",", "salt", "=", "None", ")", ":", "return", "self", ".", "token_serializer", ".", "dumps", "(", "str", "(", "user", ".", "id", ")", ",", "salt", "=", "salt", ")" ]
Generates a unique token associated to the user
[ "Generates", "a", "unique", "token", "associated", "to", "the", "user" ]
train
https://github.com/frascoweb/frasco-users/blob/16591ca466de5b7c80d7a2384327d9cf2d919c41/frasco_users/__init__.py#L285-L288
frascoweb/frasco-users
frasco_users/__init__.py
UsersFeature.find_by_token
def find_by_token(self, token, salt=None, max_age=None): """Loads a user instance identified by the token generated using generate_user_token() """ model = current_app.features.models[self.options["model"]] try: id = self.token_serializer.loads(token, salt=salt, max_age=max_a...
python
def find_by_token(self, token, salt=None, max_age=None): """Loads a user instance identified by the token generated using generate_user_token() """ model = current_app.features.models[self.options["model"]] try: id = self.token_serializer.loads(token, salt=salt, max_age=max_a...
[ "def", "find_by_token", "(", "self", ",", "token", ",", "salt", "=", "None", ",", "max_age", "=", "None", ")", ":", "model", "=", "current_app", ".", "features", ".", "models", "[", "self", ".", "options", "[", "\"model\"", "]", "]", "try", ":", "id"...
Loads a user instance identified by the token generated using generate_user_token()
[ "Loads", "a", "user", "instance", "identified", "by", "the", "token", "generated", "using", "generate_user_token", "()" ]
train
https://github.com/frascoweb/frasco-users/blob/16591ca466de5b7c80d7a2384327d9cf2d919c41/frasco_users/__init__.py#L290-L300
frascoweb/frasco-users
frasco_users/__init__.py
UsersFeature.update_password
def update_password(self, user, password, skip_validation=False): """Updates the password of a user """ pwcol = self.options["password_column"] pwhash = self.bcrypt.generate_password_hash(password) if not skip_validation: self.validate_password(user, password, pwhash)...
python
def update_password(self, user, password, skip_validation=False): """Updates the password of a user """ pwcol = self.options["password_column"] pwhash = self.bcrypt.generate_password_hash(password) if not skip_validation: self.validate_password(user, password, pwhash)...
[ "def", "update_password", "(", "self", ",", "user", ",", "password", ",", "skip_validation", "=", "False", ")", ":", "pwcol", "=", "self", ".", "options", "[", "\"password_column\"", "]", "pwhash", "=", "self", ".", "bcrypt", ".", "generate_password_hash", "...
Updates the password of a user
[ "Updates", "the", "password", "of", "a", "user" ]
train
https://github.com/frascoweb/frasco-users/blob/16591ca466de5b7c80d7a2384327d9cf2d919c41/frasco_users/__init__.py#L339-L352
frascoweb/frasco-users
frasco_users/__init__.py
UsersFeature.login_required
def login_required(self, fresh=False, redirect_to=None): """Ensures that a user is authenticated """ if not self.logged_in() or (fresh and not self.login_manager.login_fresh()): if redirect_to: resp = redirect(redirect_to) else: resp = self...
python
def login_required(self, fresh=False, redirect_to=None): """Ensures that a user is authenticated """ if not self.logged_in() or (fresh and not self.login_manager.login_fresh()): if redirect_to: resp = redirect(redirect_to) else: resp = self...
[ "def", "login_required", "(", "self", ",", "fresh", "=", "False", ",", "redirect_to", "=", "None", ")", ":", "if", "not", "self", ".", "logged_in", "(", ")", "or", "(", "fresh", "and", "not", "self", ".", "login_manager", ".", "login_fresh", "(", ")", ...
Ensures that a user is authenticated
[ "Ensures", "that", "a", "user", "is", "authenticated" ]
train
https://github.com/frascoweb/frasco-users/blob/16591ca466de5b7c80d7a2384327d9cf2d919c41/frasco_users/__init__.py#L364-L372
frascoweb/frasco-users
frasco_users/__init__.py
UsersFeature._login
def _login(self, user, provider=None, remember=False, force=False, **attrs): """Updates user attributes and login the user in flask-login """ user.last_login_at = datetime.datetime.now() user.last_login_provider = provider or self.options["default_auth_provider_name"] user.last_l...
python
def _login(self, user, provider=None, remember=False, force=False, **attrs): """Updates user attributes and login the user in flask-login """ user.last_login_at = datetime.datetime.now() user.last_login_provider = provider or self.options["default_auth_provider_name"] user.last_l...
[ "def", "_login", "(", "self", ",", "user", ",", "provider", "=", "None", ",", "remember", "=", "False", ",", "force", "=", "False", ",", "*", "*", "attrs", ")", ":", "user", ".", "last_login_at", "=", "datetime", ".", "datetime", ".", "now", "(", "...
Updates user attributes and login the user in flask-login
[ "Updates", "user", "attributes", "and", "login", "the", "user", "in", "flask", "-", "login" ]
train
https://github.com/frascoweb/frasco-users/blob/16591ca466de5b7c80d7a2384327d9cf2d919c41/frasco_users/__init__.py#L431-L439
frascoweb/frasco-users
frasco_users/__init__.py
UsersFeature.check_password_confirm
def check_password_confirm(self, form, trigger_action_group=None): """Checks that the password and the confirm password match in the provided form. Won't do anything if any of the password fields are not in the form. """ pwcol = self.options['password_column'] pwconfirmfi...
python
def check_password_confirm(self, form, trigger_action_group=None): """Checks that the password and the confirm password match in the provided form. Won't do anything if any of the password fields are not in the form. """ pwcol = self.options['password_column'] pwconfirmfi...
[ "def", "check_password_confirm", "(", "self", ",", "form", ",", "trigger_action_group", "=", "None", ")", ":", "pwcol", "=", "self", ".", "options", "[", "'password_column'", "]", "pwconfirmfield", "=", "pwcol", "+", "\"_confirm\"", "if", "pwcol", "in", "form"...
Checks that the password and the confirm password match in the provided form. Won't do anything if any of the password fields are not in the form.
[ "Checks", "that", "the", "password", "and", "the", "confirm", "password", "match", "in", "the", "provided", "form", ".", "Won", "t", "do", "anything", "if", "any", "of", "the", "password", "fields", "are", "not", "in", "the", "form", "." ]
train
https://github.com/frascoweb/frasco-users/blob/16591ca466de5b7c80d7a2384327d9cf2d919c41/frasco_users/__init__.py#L528-L538
frascoweb/frasco-users
frasco_users/__init__.py
UsersFeature.validate_user
def validate_user(self, user=None, username=None, email=None, password=None, ignore_user_id=None, must_provide_password=False, flash_messages=True, raise_error=True, is_signup=False): """Validates a new user object before saving it in the database. Checks if a password is present u...
python
def validate_user(self, user=None, username=None, email=None, password=None, ignore_user_id=None, must_provide_password=False, flash_messages=True, raise_error=True, is_signup=False): """Validates a new user object before saving it in the database. Checks if a password is present u...
[ "def", "validate_user", "(", "self", ",", "user", "=", "None", ",", "username", "=", "None", ",", "email", "=", "None", ",", "password", "=", "None", ",", "ignore_user_id", "=", "None", ",", "must_provide_password", "=", "False", ",", "flash_messages", "="...
Validates a new user object before saving it in the database. Checks if a password is present unless must_provide_password is False. Checks if the username is unique unless the option username_is_unique is set to False. If the email column exists on the user object and the option email_is_unique...
[ "Validates", "a", "new", "user", "object", "before", "saving", "it", "in", "the", "database", ".", "Checks", "if", "a", "password", "is", "present", "unless", "must_provide_password", "is", "False", ".", "Checks", "if", "the", "username", "is", "unique", "un...
train
https://github.com/frascoweb/frasco-users/blob/16591ca466de5b7c80d7a2384327d9cf2d919c41/frasco_users/__init__.py#L553-L644
frascoweb/frasco-users
frasco_users/__init__.py
UsersFeature.post_signup
def post_signup(self, user, login_user=None, send_email=None): """Executes post signup actions: sending the signal, logging in the user and sending the welcome email """ self.signup_signal.send(self, user=user) if (login_user is None and self.options["login_user_on_signup"]) or ...
python
def post_signup(self, user, login_user=None, send_email=None): """Executes post signup actions: sending the signal, logging in the user and sending the welcome email """ self.signup_signal.send(self, user=user) if (login_user is None and self.options["login_user_on_signup"]) or ...
[ "def", "post_signup", "(", "self", ",", "user", ",", "login_user", "=", "None", ",", "send_email", "=", "None", ")", ":", "self", ".", "signup_signal", ".", "send", "(", "self", ",", "user", "=", "user", ")", "if", "(", "login_user", "is", "None", "a...
Executes post signup actions: sending the signal, logging in the user and sending the welcome email
[ "Executes", "post", "signup", "actions", ":", "sending", "the", "signal", "logging", "in", "the", "user", "and", "sending", "the", "welcome", "email" ]
train
https://github.com/frascoweb/frasco-users/blob/16591ca466de5b7c80d7a2384327d9cf2d919c41/frasco_users/__init__.py#L646-L658
frascoweb/frasco-users
frasco_users/__init__.py
UsersFeature.gen_reset_password_token
def gen_reset_password_token(self, user=None, send_email=None): """Generates a reset password token and optionnaly (default to yes) send the reset password email """ if not user and "form" in current_context.data and request.method == "POST": form = current_context.data.form ...
python
def gen_reset_password_token(self, user=None, send_email=None): """Generates a reset password token and optionnaly (default to yes) send the reset password email """ if not user and "form" in current_context.data and request.method == "POST": form = current_context.data.form ...
[ "def", "gen_reset_password_token", "(", "self", ",", "user", "=", "None", ",", "send_email", "=", "None", ")", ":", "if", "not", "user", "and", "\"form\"", "in", "current_context", ".", "data", "and", "request", ".", "method", "==", "\"POST\"", ":", "form"...
Generates a reset password token and optionnaly (default to yes) send the reset password email
[ "Generates", "a", "reset", "password", "token", "and", "optionnaly", "(", "default", "to", "yes", ")", "send", "the", "reset", "password", "email" ]
train
https://github.com/frascoweb/frasco-users/blob/16591ca466de5b7c80d7a2384327d9cf2d919c41/frasco_users/__init__.py#L664-L684
frascoweb/frasco-users
frasco_users/__init__.py
UsersFeature.reset_password
def reset_password(self, token=None, login_user=None): """Resets the password of the user identified by the token """ pwcol = self.options['password_column'] if not token: if "token" in request.view_args: token = request.view_args["token"] elif "to...
python
def reset_password(self, token=None, login_user=None): """Resets the password of the user identified by the token """ pwcol = self.options['password_column'] if not token: if "token" in request.view_args: token = request.view_args["token"] elif "to...
[ "def", "reset_password", "(", "self", ",", "token", "=", "None", ",", "login_user", "=", "None", ")", ":", "pwcol", "=", "self", ".", "options", "[", "'password_column'", "]", "if", "not", "token", ":", "if", "\"token\"", "in", "request", ".", "view_args...
Resets the password of the user identified by the token
[ "Resets", "the", "password", "of", "the", "user", "identified", "by", "the", "token" ]
train
https://github.com/frascoweb/frasco-users/blob/16591ca466de5b7c80d7a2384327d9cf2d919c41/frasco_users/__init__.py#L695-L718
frascoweb/frasco-users
frasco_users/__init__.py
UsersFeature.update_password_from_form
def update_password_from_form(self, user=None, form=None): """Updates the user password using a form """ user = user or self.current if not form and "form" in current_context.data and request.method == "POST": form = current_context.data.form elif not form: ...
python
def update_password_from_form(self, user=None, form=None): """Updates the user password using a form """ user = user or self.current if not form and "form" in current_context.data and request.method == "POST": form = current_context.data.form elif not form: ...
[ "def", "update_password_from_form", "(", "self", ",", "user", "=", "None", ",", "form", "=", "None", ")", ":", "user", "=", "user", "or", "self", ".", "current", "if", "not", "form", "and", "\"form\"", "in", "current_context", ".", "data", "and", "reques...
Updates the user password using a form
[ "Updates", "the", "user", "password", "using", "a", "form" ]
train
https://github.com/frascoweb/frasco-users/blob/16591ca466de5b7c80d7a2384327d9cf2d919c41/frasco_users/__init__.py#L731-L742
frascoweb/frasco-users
frasco_users/__init__.py
UsersFeature.check_user_password
def check_user_password(self, user, password=None, form=None): """Checks if the password matches the one of the user. If no password is provided, the current form will be used """ pwcol = self.options['password_column'] if password is None: if not form and "form" in c...
python
def check_user_password(self, user, password=None, form=None): """Checks if the password matches the one of the user. If no password is provided, the current form will be used """ pwcol = self.options['password_column'] if password is None: if not form and "form" in c...
[ "def", "check_user_password", "(", "self", ",", "user", ",", "password", "=", "None", ",", "form", "=", "None", ")", ":", "pwcol", "=", "self", ".", "options", "[", "'password_column'", "]", "if", "password", "is", "None", ":", "if", "not", "form", "an...
Checks if the password matches the one of the user. If no password is provided, the current form will be used
[ "Checks", "if", "the", "password", "matches", "the", "one", "of", "the", "user", ".", "If", "no", "password", "is", "provided", "the", "current", "form", "will", "be", "used" ]
train
https://github.com/frascoweb/frasco-users/blob/16591ca466de5b7c80d7a2384327d9cf2d919c41/frasco_users/__init__.py#L762-L776
frascoweb/frasco-users
frasco_users/__init__.py
UsersFeature.check_unique_attr
def check_unique_attr(self, attrs, user=None, form=None, flash_msg=None): """Checks that an attribute of the current user is unique amongst all users. If no value is provided, the current form will be used. """ user = user or self.current ucol = self.options["username_column"] ...
python
def check_unique_attr(self, attrs, user=None, form=None, flash_msg=None): """Checks that an attribute of the current user is unique amongst all users. If no value is provided, the current form will be used. """ user = user or self.current ucol = self.options["username_column"] ...
[ "def", "check_unique_attr", "(", "self", ",", "attrs", ",", "user", "=", "None", ",", "form", "=", "None", ",", "flash_msg", "=", "None", ")", ":", "user", "=", "user", "or", "self", ".", "current", "ucol", "=", "self", ".", "options", "[", "\"userna...
Checks that an attribute of the current user is unique amongst all users. If no value is provided, the current form will be used.
[ "Checks", "that", "an", "attribute", "of", "the", "current", "user", "is", "unique", "amongst", "all", "users", ".", "If", "no", "value", "is", "provided", "the", "current", "form", "will", "be", "used", "." ]
train
https://github.com/frascoweb/frasco-users/blob/16591ca466de5b7c80d7a2384327d9cf2d919c41/frasco_users/__init__.py#L810-L841
frascoweb/frasco-users
frasco_users/__init__.py
UsersFeature.oauth_login
def oauth_login(self, provider, id_column, id, attrs, defaults, redirect_url=None): """Execute a login via oauth. If no user exists, oauth_signup() will be called """ user = self.query.filter(**dict([(id_column, id)])).first() if not redirect_url: redirect_url = request.args....
python
def oauth_login(self, provider, id_column, id, attrs, defaults, redirect_url=None): """Execute a login via oauth. If no user exists, oauth_signup() will be called """ user = self.query.filter(**dict([(id_column, id)])).first() if not redirect_url: redirect_url = request.args....
[ "def", "oauth_login", "(", "self", ",", "provider", ",", "id_column", ",", "id", ",", "attrs", ",", "defaults", ",", "redirect_url", "=", "None", ")", ":", "user", "=", "self", ".", "query", ".", "filter", "(", "*", "*", "dict", "(", "[", "(", "id_...
Execute a login via oauth. If no user exists, oauth_signup() will be called
[ "Execute", "a", "login", "via", "oauth", ".", "If", "no", "user", "exists", "oauth_signup", "()", "will", "be", "called" ]
train
https://github.com/frascoweb/frasco-users/blob/16591ca466de5b7c80d7a2384327d9cf2d919c41/frasco_users/__init__.py#L843-L861
frascoweb/frasco-users
frasco_users/__init__.py
UsersFeature.oauth_signup
def oauth_signup(self, provider, attrs, defaults, redirect_url=None): """Start the signup process after having logged in via oauth """ session["oauth_user_defaults"] = defaults session["oauth_user_attrs"] = dict(provider=provider, **attrs) if not redirect_url: redirec...
python
def oauth_signup(self, provider, attrs, defaults, redirect_url=None): """Start the signup process after having logged in via oauth """ session["oauth_user_defaults"] = defaults session["oauth_user_attrs"] = dict(provider=provider, **attrs) if not redirect_url: redirec...
[ "def", "oauth_signup", "(", "self", ",", "provider", ",", "attrs", ",", "defaults", ",", "redirect_url", "=", "None", ")", ":", "session", "[", "\"oauth_user_defaults\"", "]", "=", "defaults", "session", "[", "\"oauth_user_attrs\"", "]", "=", "dict", "(", "p...
Start the signup process after having logged in via oauth
[ "Start", "the", "signup", "process", "after", "having", "logged", "in", "via", "oauth" ]
train
https://github.com/frascoweb/frasco-users/blob/16591ca466de5b7c80d7a2384327d9cf2d919c41/frasco_users/__init__.py#L863-L870
leonidessaguisagjr/pseudol10nutil
pseudol10nutil/transforms.py
pad_length
def pad_length(s): """ Appends characters to the end of the string to increase the string length per IBM Globalization Design Guideline A3: UI Expansion. https://www-01.ibm.com/software/globalization/guidelines/a3.html :param s: String to pad. :returns: Padded string. """ padding_chars...
python
def pad_length(s): """ Appends characters to the end of the string to increase the string length per IBM Globalization Design Guideline A3: UI Expansion. https://www-01.ibm.com/software/globalization/guidelines/a3.html :param s: String to pad. :returns: Padded string. """ padding_chars...
[ "def", "pad_length", "(", "s", ")", ":", "padding_chars", "=", "[", "u'\\ufe4e'", ",", "# ﹎: CENTRELINE LOW LINE", "u'\\u040d'", ",", "# Ѝ: CYRILLIC CAPITAL LETTER I WITH GRAVE", "u'\\u05d0'", ",", "# א: HEBREW LETTER ALEF", "u'\\u01c6'", ",", "# dž: LATIN SMALL LETTER DZ WITH...
Appends characters to the end of the string to increase the string length per IBM Globalization Design Guideline A3: UI Expansion. https://www-01.ibm.com/software/globalization/guidelines/a3.html :param s: String to pad. :returns: Padded string.
[ "Appends", "characters", "to", "the", "end", "of", "the", "string", "to", "increase", "the", "string", "length", "per", "IBM", "Globalization", "Design", "Guideline", "A3", ":", "UI", "Expansion", "." ]
train
https://github.com/leonidessaguisagjr/pseudol10nutil/blob/39cb0ae8cc5c1df5690816a18472e0366a49ab8d/pseudol10nutil/transforms.py#L262-L302
AndresMWeber/Nomenclate
nomenclate/core/formatter.py
FormatString.parse_format_order
def parse_format_order(cls, format_target): """ Dissects the format string and gets the order of the tokens as it finds them l->r Splits on camel case or periods/underscores Modified version from this: http://stackoverflow.com/questions/2277352/python-split-a-string-at-upperc...
python
def parse_format_order(cls, format_target): """ Dissects the format string and gets the order of the tokens as it finds them l->r Splits on camel case or periods/underscores Modified version from this: http://stackoverflow.com/questions/2277352/python-split-a-string-at-upperc...
[ "def", "parse_format_order", "(", "cls", ",", "format_target", ")", ":", "try", ":", "pattern", "=", "re", ".", "compile", "(", "settings", ".", "FORMAT_STRING_REGEX", ")", "return", "[", "match", ".", "group", "(", ")", "for", "match", "in", "pattern", ...
Dissects the format string and gets the order of the tokens as it finds them l->r Splits on camel case or periods/underscores Modified version from this: http://stackoverflow.com/questions/2277352/python-split-a-string-at-uppercase-letters :param format_target: str, format s...
[ "Dissects", "the", "format", "string", "and", "gets", "the", "order", "of", "the", "tokens", "as", "it", "finds", "them", "l", "-", ">", "r", "Splits", "on", "camel", "case", "or", "periods", "/", "underscores", "Modified", "version", "from", "this", ":"...
train
https://github.com/AndresMWeber/Nomenclate/blob/e6d6fc28beac042bad588e56fbe77531d2de6b6f/nomenclate/core/formatter.py#L35-L49
AndresMWeber/Nomenclate
nomenclate/core/formatter.py
FormatString.get_valid_format_order
def get_valid_format_order(cls, format_target, format_order=None): """ Checks to see if the target format string follows the proper style """ format_order = format_order or cls.parse_format_order(format_target) cls.validate_no_token_duplicates(format_order) format_target = cls.re...
python
def get_valid_format_order(cls, format_target, format_order=None): """ Checks to see if the target format string follows the proper style """ format_order = format_order or cls.parse_format_order(format_target) cls.validate_no_token_duplicates(format_order) format_target = cls.re...
[ "def", "get_valid_format_order", "(", "cls", ",", "format_target", ",", "format_order", "=", "None", ")", ":", "format_order", "=", "format_order", "or", "cls", ".", "parse_format_order", "(", "format_target", ")", "cls", ".", "validate_no_token_duplicates", "(", ...
Checks to see if the target format string follows the proper style
[ "Checks", "to", "see", "if", "the", "target", "format", "string", "follows", "the", "proper", "style" ]
train
https://github.com/AndresMWeber/Nomenclate/blob/e6d6fc28beac042bad588e56fbe77531d2de6b6f/nomenclate/core/formatter.py#L52-L61
AndresMWeber/Nomenclate
nomenclate/core/formatter.py
FormatString.validate_matched_parenthesis
def validate_matched_parenthesis(cls, format_target): """ Adapted from https://stackoverflow.com/questions/6701853/parentheses-pairing-issue :param format_order: :return: """ iparens = iter('(){}[]<>') parens = dict(zip(iparens, iparens)) closing = parens.values(...
python
def validate_matched_parenthesis(cls, format_target): """ Adapted from https://stackoverflow.com/questions/6701853/parentheses-pairing-issue :param format_order: :return: """ iparens = iter('(){}[]<>') parens = dict(zip(iparens, iparens)) closing = parens.values(...
[ "def", "validate_matched_parenthesis", "(", "cls", ",", "format_target", ")", ":", "iparens", "=", "iter", "(", "'(){}[]<>'", ")", "parens", "=", "dict", "(", "zip", "(", "iparens", ",", "iparens", ")", ")", "closing", "=", "parens", ".", "values", "(", ...
Adapted from https://stackoverflow.com/questions/6701853/parentheses-pairing-issue :param format_order: :return:
[ "Adapted", "from", "https", ":", "//", "stackoverflow", ".", "com", "/", "questions", "/", "6701853", "/", "parentheses", "-", "pairing", "-", "issue" ]
train
https://github.com/AndresMWeber/Nomenclate/blob/e6d6fc28beac042bad588e56fbe77531d2de6b6f/nomenclate/core/formatter.py#L88-L111
scieloorg/porteira
porteira/porteira.py
Schema._handle_errors
def _handle_errors(self, errors_list): """ Handles errors list Output Format: [(DOMIAN, LINE, COLUMN, LEVEL, TYPE_NAME, MESSAGE),] Ex.: [(PARSER, 3, 51, FATAL, ERR_TAG_NAME_MISMATCH, Opening and ending tag mismatch: statpage line 3 and startpage), (SCHEM...
python
def _handle_errors(self, errors_list): """ Handles errors list Output Format: [(DOMIAN, LINE, COLUMN, LEVEL, TYPE_NAME, MESSAGE),] Ex.: [(PARSER, 3, 51, FATAL, ERR_TAG_NAME_MISMATCH, Opening and ending tag mismatch: statpage line 3 and startpage), (SCHEM...
[ "def", "_handle_errors", "(", "self", ",", "errors_list", ")", ":", "errors", "=", "[", "]", "for", "error", "in", "errors_list", ":", "errors", ".", "append", "(", "(", "error", ".", "domain_name", ",", "error", ".", "line", ",", "error", ".", "column...
Handles errors list Output Format: [(DOMIAN, LINE, COLUMN, LEVEL, TYPE_NAME, MESSAGE),] Ex.: [(PARSER, 3, 51, FATAL, ERR_TAG_NAME_MISMATCH, Opening and ending tag mismatch: statpage line 3 and startpage), (SCHEMASV, 2, 0, ERROR, SCHEMAV_CVC_ELT_1, Element 'wizard': ...
[ "Handles", "errors", "list" ]
train
https://github.com/scieloorg/porteira/blob/e61f7d248b16848e63b2f85f37125aa77aba0366/porteira/porteira.py#L23-L39
scieloorg/porteira
porteira/porteira.py
Schema.get_validation_errors
def get_validation_errors(self, xml_input): """ This method returns a list of validation errors. If there are no errors an empty list is returned """ errors = [] try: parsed_xml = etree.parse(self._handle_xml(xml_input)) self.xmlschema.assertValid(...
python
def get_validation_errors(self, xml_input): """ This method returns a list of validation errors. If there are no errors an empty list is returned """ errors = [] try: parsed_xml = etree.parse(self._handle_xml(xml_input)) self.xmlschema.assertValid(...
[ "def", "get_validation_errors", "(", "self", ",", "xml_input", ")", ":", "errors", "=", "[", "]", "try", ":", "parsed_xml", "=", "etree", ".", "parse", "(", "self", ".", "_handle_xml", "(", "xml_input", ")", ")", "self", ".", "xmlschema", ".", "assertVal...
This method returns a list of validation errors. If there are no errors an empty list is returned
[ "This", "method", "returns", "a", "list", "of", "validation", "errors", ".", "If", "there", "are", "no", "errors", "an", "empty", "list", "is", "returned" ]
train
https://github.com/scieloorg/porteira/blob/e61f7d248b16848e63b2f85f37125aa77aba0366/porteira/porteira.py#L50-L63
scieloorg/porteira
porteira/porteira.py
Schema.validate
def validate(self, xml_input): """ This method validate the parsing and schema, return a boolean """ parsed_xml = etree.parse(self._handle_xml(xml_input)) try: return self.xmlschema.validate(parsed_xml) except AttributeError: raise CannotValidate('...
python
def validate(self, xml_input): """ This method validate the parsing and schema, return a boolean """ parsed_xml = etree.parse(self._handle_xml(xml_input)) try: return self.xmlschema.validate(parsed_xml) except AttributeError: raise CannotValidate('...
[ "def", "validate", "(", "self", ",", "xml_input", ")", ":", "parsed_xml", "=", "etree", ".", "parse", "(", "self", ".", "_handle_xml", "(", "xml_input", ")", ")", "try", ":", "return", "self", ".", "xmlschema", ".", "validate", "(", "parsed_xml", ")", ...
This method validate the parsing and schema, return a boolean
[ "This", "method", "validate", "the", "parsing", "and", "schema", "return", "a", "boolean" ]
train
https://github.com/scieloorg/porteira/blob/e61f7d248b16848e63b2f85f37125aa77aba0366/porteira/porteira.py#L65-L73
scieloorg/porteira
porteira/porteira.py
Schema.deserialize
def deserialize(self, xml_input, *args, **kwargs): """ Convert XML to dict object """ return xmltodict.parse(xml_input, *args, **kwargs)
python
def deserialize(self, xml_input, *args, **kwargs): """ Convert XML to dict object """ return xmltodict.parse(xml_input, *args, **kwargs)
[ "def", "deserialize", "(", "self", ",", "xml_input", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "xmltodict", ".", "parse", "(", "xml_input", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Convert XML to dict object
[ "Convert", "XML", "to", "dict", "object" ]
train
https://github.com/scieloorg/porteira/blob/e61f7d248b16848e63b2f85f37125aa77aba0366/porteira/porteira.py#L75-L79
chamrc/to
to/__init__.py
_import_all_modules
def _import_all_modules(): """dynamically imports all modules in the package""" import traceback import os global results globals_, locals_ = globals(), locals() def load_module(modulename, package_module): try: names = [] module = __import__(package_module, glob...
python
def _import_all_modules(): """dynamically imports all modules in the package""" import traceback import os global results globals_, locals_ = globals(), locals() def load_module(modulename, package_module): try: names = [] module = __import__(package_module, glob...
[ "def", "_import_all_modules", "(", ")", ":", "import", "traceback", "import", "os", "global", "results", "globals_", ",", "locals_", "=", "globals", "(", ")", ",", "locals", "(", ")", "def", "load_module", "(", "modulename", ",", "package_module", ")", ":", ...
dynamically imports all modules in the package
[ "dynamically", "imports", "all", "modules", "in", "the", "package" ]
train
https://github.com/chamrc/to/blob/ea1122bef08615b6c19904dadf2608e10c20c960/to/__init__.py#L1-L42
yograterol/zoort
zoort.py
compress_folder_dump
def compress_folder_dump(path, target): ''' Compress folder dump to tar.gz file ''' import tarfile if not path or not os.path.isdir(path): raise SystemExit(_error_codes.get(105)) name_out_file = (target + 'dump-' + datetime.datetime.now().strftime('%Y-%m-%d-%H-%M-%S'...
python
def compress_folder_dump(path, target): ''' Compress folder dump to tar.gz file ''' import tarfile if not path or not os.path.isdir(path): raise SystemExit(_error_codes.get(105)) name_out_file = (target + 'dump-' + datetime.datetime.now().strftime('%Y-%m-%d-%H-%M-%S'...
[ "def", "compress_folder_dump", "(", "path", ",", "target", ")", ":", "import", "tarfile", "if", "not", "path", "or", "not", "os", ".", "path", ".", "isdir", "(", "path", ")", ":", "raise", "SystemExit", "(", "_error_codes", ".", "get", "(", "105", ")",...
Compress folder dump to tar.gz file
[ "Compress", "folder", "dump", "to", "tar", ".", "gz", "file" ]
train
https://github.com/yograterol/zoort/blob/ed6669ab945007c20a83f6d468856c4eb585c752/zoort.py#L665-L677
yograterol/zoort
zoort.py
encrypt_file
def encrypt_file(path, output, password=None): ''' Encrypt file with AES method and password. ''' if not password: password = PASSWORD_FILE query = 'openssl aes-128-cbc -salt -in {0} -out {1} -k {2}' with hide('output'): local(query.format(path, output, password)) os.remo...
python
def encrypt_file(path, output, password=None): ''' Encrypt file with AES method and password. ''' if not password: password = PASSWORD_FILE query = 'openssl aes-128-cbc -salt -in {0} -out {1} -k {2}' with hide('output'): local(query.format(path, output, password)) os.remo...
[ "def", "encrypt_file", "(", "path", ",", "output", ",", "password", "=", "None", ")", ":", "if", "not", "password", ":", "password", "=", "PASSWORD_FILE", "query", "=", "'openssl aes-128-cbc -salt -in {0} -out {1} -k {2}'", "with", "hide", "(", "'output'", ")", ...
Encrypt file with AES method and password.
[ "Encrypt", "file", "with", "AES", "method", "and", "password", "." ]
train
https://github.com/yograterol/zoort/blob/ed6669ab945007c20a83f6d468856c4eb585c752/zoort.py#L680-L689
yograterol/zoort
zoort.py
decrypt_file
def decrypt_file(path, password=None): ''' Decrypt file with AES method and password. ''' global PASSWORD_FILE if not password: password = PASSWORD_FILE if path and not os.path.isfile(path): raise SystemExit(_error_codes.get(106)) query = 'openssl aes-128-cbc -d -salt -in {0}...
python
def decrypt_file(path, password=None): ''' Decrypt file with AES method and password. ''' global PASSWORD_FILE if not password: password = PASSWORD_FILE if path and not os.path.isfile(path): raise SystemExit(_error_codes.get(106)) query = 'openssl aes-128-cbc -d -salt -in {0}...
[ "def", "decrypt_file", "(", "path", ",", "password", "=", "None", ")", ":", "global", "PASSWORD_FILE", "if", "not", "password", ":", "password", "=", "PASSWORD_FILE", "if", "path", "and", "not", "os", ".", "path", ".", "isfile", "(", "path", ")", ":", ...
Decrypt file with AES method and password.
[ "Decrypt", "file", "with", "AES", "method", "and", "password", "." ]
train
https://github.com/yograterol/zoort/blob/ed6669ab945007c20a83f6d468856c4eb585c752/zoort.py#L692-L703
yograterol/zoort
zoort.py
optional_actions
def optional_actions(encrypt, path, compress_file, **kwargs): ''' Optional actions about of AWS S3 and encrypt file. ''' yes = ('y', 'Y') file_to_upload = normalize_path(path) + compress_file[1] if encrypt in yes: encrypt_file(compress_file[1], compress_file[0]) file_to_upload = ...
python
def optional_actions(encrypt, path, compress_file, **kwargs): ''' Optional actions about of AWS S3 and encrypt file. ''' yes = ('y', 'Y') file_to_upload = normalize_path(path) + compress_file[1] if encrypt in yes: encrypt_file(compress_file[1], compress_file[0]) file_to_upload = ...
[ "def", "optional_actions", "(", "encrypt", ",", "path", ",", "compress_file", ",", "*", "*", "kwargs", ")", ":", "yes", "=", "(", "'y'", ",", "'Y'", ")", "file_to_upload", "=", "normalize_path", "(", "path", ")", "+", "compress_file", "[", "1", "]", "i...
Optional actions about of AWS S3 and encrypt file.
[ "Optional", "actions", "about", "of", "AWS", "S3", "and", "encrypt", "file", "." ]
train
https://github.com/yograterol/zoort/blob/ed6669ab945007c20a83f6d468856c4eb585c752/zoort.py#L706-L731
yograterol/zoort
zoort.py
main
def main(): '''Main entry point for the mongo_backups CLI.''' args = docopt(__doc__, version=__version__) if args.get('backup'): backup_database(args) if args.get('backup_all'): backup_all(args) if args.get('decrypt'): decrypt_file(args.get('<path>')) if args.get('configu...
python
def main(): '''Main entry point for the mongo_backups CLI.''' args = docopt(__doc__, version=__version__) if args.get('backup'): backup_database(args) if args.get('backup_all'): backup_all(args) if args.get('decrypt'): decrypt_file(args.get('<path>')) if args.get('configu...
[ "def", "main", "(", ")", ":", "args", "=", "docopt", "(", "__doc__", ",", "version", "=", "__version__", ")", "if", "args", ".", "get", "(", "'backup'", ")", ":", "backup_database", "(", "args", ")", "if", "args", ".", "get", "(", "'backup_all'", ")"...
Main entry point for the mongo_backups CLI.
[ "Main", "entry", "point", "for", "the", "mongo_backups", "CLI", "." ]
train
https://github.com/yograterol/zoort/blob/ed6669ab945007c20a83f6d468856c4eb585c752/zoort.py#L735-L753
yograterol/zoort
zoort.py
backup_database
def backup_database(args): ''' Backup one database from CLI ''' username = args.get('<user>') password = args.get('<password>') database = args['<database>'] host = args.get('<host>') or '127.0.0.1' path = args.get('--path') or os.getcwd() s3 = args.get('--upload_s3') glacier = a...
python
def backup_database(args): ''' Backup one database from CLI ''' username = args.get('<user>') password = args.get('<password>') database = args['<database>'] host = args.get('<host>') or '127.0.0.1' path = args.get('--path') or os.getcwd() s3 = args.get('--upload_s3') glacier = a...
[ "def", "backup_database", "(", "args", ")", ":", "username", "=", "args", ".", "get", "(", "'<user>'", ")", "password", "=", "args", ".", "get", "(", "'<password>'", ")", "database", "=", "args", "[", "'<database>'", "]", "host", "=", "args", ".", "get...
Backup one database from CLI
[ "Backup", "one", "database", "from", "CLI" ]
train
https://github.com/yograterol/zoort/blob/ed6669ab945007c20a83f6d468856c4eb585c752/zoort.py#L760-L801
yograterol/zoort
zoort.py
backup_all
def backup_all(args): ''' Backup all databases with access user. ''' username = None password = None auth = args.get('--auth') path = args.get('--path') s3 = args.get('--upload_s3') glacier = args.get('--upload_glacier') dropbox = args.get('--upload_dropbox') swift = args.get...
python
def backup_all(args): ''' Backup all databases with access user. ''' username = None password = None auth = args.get('--auth') path = args.get('--path') s3 = args.get('--upload_s3') glacier = args.get('--upload_glacier') dropbox = args.get('--upload_dropbox') swift = args.get...
[ "def", "backup_all", "(", "args", ")", ":", "username", "=", "None", "password", "=", "None", "auth", "=", "args", ".", "get", "(", "'--auth'", ")", "path", "=", "args", ".", "get", "(", "'--path'", ")", "s3", "=", "args", ".", "get", "(", "'--uplo...
Backup all databases with access user.
[ "Backup", "all", "databases", "with", "access", "user", "." ]
train
https://github.com/yograterol/zoort/blob/ed6669ab945007c20a83f6d468856c4eb585c752/zoort.py#L804-L844
bitlabstudio/django-unshorten
unshorten/rate_limit.py
SimpleRateLimit.get_history
def get_history(self): """Returns the history from cache or DB or a newly created one.""" if hasattr(self, '_history'): return self._history try: self._history = APICallDayHistory.objects.get( user=self.user, creation_date=now().date()) except APIC...
python
def get_history(self): """Returns the history from cache or DB or a newly created one.""" if hasattr(self, '_history'): return self._history try: self._history = APICallDayHistory.objects.get( user=self.user, creation_date=now().date()) except APIC...
[ "def", "get_history", "(", "self", ")", ":", "if", "hasattr", "(", "self", ",", "'_history'", ")", ":", "return", "self", ".", "_history", "try", ":", "self", ".", "_history", "=", "APICallDayHistory", ".", "objects", ".", "get", "(", "user", "=", "sel...
Returns the history from cache or DB or a newly created one.
[ "Returns", "the", "history", "from", "cache", "or", "DB", "or", "a", "newly", "created", "one", "." ]
train
https://github.com/bitlabstudio/django-unshorten/blob/6d184de908bb9df3aad5ac3fd9732d976afb6953/unshorten/rate_limit.py#L14-L24
bitlabstudio/django-unshorten
unshorten/rate_limit.py
SimpleRateLimit.is_rate_limit_exceeded
def is_rate_limit_exceeded(self): """Returns ``True`` if the rate limit is exceeded, otherwise False.""" history = self.get_history() if history.amount_api_calls >= settings.UNSHORTEN_DAILY_LIMIT: return True return False
python
def is_rate_limit_exceeded(self): """Returns ``True`` if the rate limit is exceeded, otherwise False.""" history = self.get_history() if history.amount_api_calls >= settings.UNSHORTEN_DAILY_LIMIT: return True return False
[ "def", "is_rate_limit_exceeded", "(", "self", ")", ":", "history", "=", "self", ".", "get_history", "(", ")", "if", "history", ".", "amount_api_calls", ">=", "settings", ".", "UNSHORTEN_DAILY_LIMIT", ":", "return", "True", "return", "False" ]
Returns ``True`` if the rate limit is exceeded, otherwise False.
[ "Returns", "True", "if", "the", "rate", "limit", "is", "exceeded", "otherwise", "False", "." ]
train
https://github.com/bitlabstudio/django-unshorten/blob/6d184de908bb9df3aad5ac3fd9732d976afb6953/unshorten/rate_limit.py#L26-L31
bitlabstudio/django-unshorten
unshorten/rate_limit.py
SimpleRateLimit.log_api_call
def log_api_call(self): """Increases the amount of logged API calls for the user by 1.""" history = self.get_history() history.amount_api_calls += 1 self._history = history.save() return history
python
def log_api_call(self): """Increases the amount of logged API calls for the user by 1.""" history = self.get_history() history.amount_api_calls += 1 self._history = history.save() return history
[ "def", "log_api_call", "(", "self", ")", ":", "history", "=", "self", ".", "get_history", "(", ")", "history", ".", "amount_api_calls", "+=", "1", "self", ".", "_history", "=", "history", ".", "save", "(", ")", "return", "history" ]
Increases the amount of logged API calls for the user by 1.
[ "Increases", "the", "amount", "of", "logged", "API", "calls", "for", "the", "user", "by", "1", "." ]
train
https://github.com/bitlabstudio/django-unshorten/blob/6d184de908bb9df3aad5ac3fd9732d976afb6953/unshorten/rate_limit.py#L33-L38
jalanb/pysyte
pysyte/lists.py
de_duplicate
def de_duplicate(items): """Remove any duplicate item, preserving order >>> de_duplicate([1, 2, 1, 2]) [1, 2] """ result = [] for item in items: if item not in result: result.append(item) return result
python
def de_duplicate(items): """Remove any duplicate item, preserving order >>> de_duplicate([1, 2, 1, 2]) [1, 2] """ result = [] for item in items: if item not in result: result.append(item) return result
[ "def", "de_duplicate", "(", "items", ")", ":", "result", "=", "[", "]", "for", "item", "in", "items", ":", "if", "item", "not", "in", "result", ":", "result", ".", "append", "(", "item", ")", "return", "result" ]
Remove any duplicate item, preserving order >>> de_duplicate([1, 2, 1, 2]) [1, 2]
[ "Remove", "any", "duplicate", "item", "preserving", "order" ]
train
https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/lists.py#L4-L14
luismasuelli/python-cantrips
cantrips/functions.py
is_method
def is_method(method, flags=METHOD_ALL): """ Determines whether the passed value is a method satisfying certain conditions: * Being instance method. * Being class method. * Being bound method. * Being unbound method. Flag check is considered or-wise. The default is to consider every ...
python
def is_method(method, flags=METHOD_ALL): """ Determines whether the passed value is a method satisfying certain conditions: * Being instance method. * Being class method. * Being bound method. * Being unbound method. Flag check is considered or-wise. The default is to consider every ...
[ "def", "is_method", "(", "method", ",", "flags", "=", "METHOD_ALL", ")", ":", "if", "isinstance", "(", "method", ",", "types", ".", "UnboundMethodType", ")", ":", "if", "flags", "&", "METHOD_CLASS", "and", "issubclass", "(", "method", ".", "im_class", ",",...
Determines whether the passed value is a method satisfying certain conditions: * Being instance method. * Being class method. * Being bound method. * Being unbound method. Flag check is considered or-wise. The default is to consider every option. :param method: :param flags: :ret...
[ "Determines", "whether", "the", "passed", "value", "is", "a", "method", "satisfying", "certain", "conditions", ":", "*", "Being", "instance", "method", ".", "*", "Being", "class", "method", ".", "*", "Being", "bound", "method", ".", "*", "Being", "unbound", ...
train
https://github.com/luismasuelli/python-cantrips/blob/dba2742c1d1a60863bb65f4a291464f6e68eb2ee/cantrips/functions.py#L11-L32
JNRowe/jnrbase
jnrbase/config.py
read_configs
def read_configs(__pkg: str, __name: str = 'config', *, local: bool = True) -> ConfigParser: """Process configuration file stack. We export the time parsing functionality of ``jnrbase`` as custom converters for :class:`configparser.ConfigParser`: =================== =================...
python
def read_configs(__pkg: str, __name: str = 'config', *, local: bool = True) -> ConfigParser: """Process configuration file stack. We export the time parsing functionality of ``jnrbase`` as custom converters for :class:`configparser.ConfigParser`: =================== =================...
[ "def", "read_configs", "(", "__pkg", ":", "str", ",", "__name", ":", "str", "=", "'config'", ",", "*", ",", "local", ":", "bool", "=", "True", ")", "->", "ConfigParser", ":", "configs", "=", "get_configs", "(", "__pkg", ",", "__name", ")", "if", "loc...
Process configuration file stack. We export the time parsing functionality of ``jnrbase`` as custom converters for :class:`configparser.ConfigParser`: =================== =========================================== Method Function =================== ===============================...
[ "Process", "configuration", "file", "stack", "." ]
train
https://github.com/JNRowe/jnrbase/blob/ae505ef69a9feb739b5f4e62c5a8e6533104d3ea/jnrbase/config.py#L29-L75
CitrineInformatics/dftparse
dftparse/wien2k/reflectivity_parser.py
_parse_reflectivity
def _parse_reflectivity(line, lines): """Parse Energy [eV] reflect_xx reflect_zz""" split_line = line.split() energy = float(split_line[0]) reflect_xx = float(split_line[1]) reflect_zz = float(split_line[2]) return {"energy": energy, "reflect_xx": reflect_xx, "reflect_zz": reflect_zz}
python
def _parse_reflectivity(line, lines): """Parse Energy [eV] reflect_xx reflect_zz""" split_line = line.split() energy = float(split_line[0]) reflect_xx = float(split_line[1]) reflect_zz = float(split_line[2]) return {"energy": energy, "reflect_xx": reflect_xx, "reflect_zz": reflect_zz}
[ "def", "_parse_reflectivity", "(", "line", ",", "lines", ")", ":", "split_line", "=", "line", ".", "split", "(", ")", "energy", "=", "float", "(", "split_line", "[", "0", "]", ")", "reflect_xx", "=", "float", "(", "split_line", "[", "1", "]", ")", "r...
Parse Energy [eV] reflect_xx reflect_zz
[ "Parse", "Energy", "[", "eV", "]", "reflect_xx", "reflect_zz" ]
train
https://github.com/CitrineInformatics/dftparse/blob/53a1bf19945cf1c195d6af9beccb3d1b7f4a4c1d/dftparse/wien2k/reflectivity_parser.py#L4-L13
webkom/django-auth-abakus
abakus/auth.py
AbakusBackend.authenticate
def authenticate(self, username, password): """ Should try to login with abakus.no (NERD). """ if getattr(settings, 'ABAKUS_DUMMY_AUTH', False): return self.dummy_authenticate(username, password) response = requests.post(url=path, data={'username': username, 'password...
python
def authenticate(self, username, password): """ Should try to login with abakus.no (NERD). """ if getattr(settings, 'ABAKUS_DUMMY_AUTH', False): return self.dummy_authenticate(username, password) response = requests.post(url=path, data={'username': username, 'password...
[ "def", "authenticate", "(", "self", ",", "username", ",", "password", ")", ":", "if", "getattr", "(", "settings", ",", "'ABAKUS_DUMMY_AUTH'", ",", "False", ")", ":", "return", "self", ".", "dummy_authenticate", "(", "username", ",", "password", ")", "respons...
Should try to login with abakus.no (NERD).
[ "Should", "try", "to", "login", "with", "abakus", ".", "no", "(", "NERD", ")", "." ]
train
https://github.com/webkom/django-auth-abakus/blob/26779ad8e9f520835c2665f8a4d6731ca6f4ca18/abakus/auth.py#L25-L71
klmitch/tendril
tendril/tcp.py
TCPTendril._start
def _start(self): """ Starts the underlying send and receive threads. """ # Initialize the locks self._recv_lock = coros.Semaphore(0) self._send_lock = coros.Semaphore(0) # Boot the threads self._recv_thread = gevent.spawn(self._recv) self._send_...
python
def _start(self): """ Starts the underlying send and receive threads. """ # Initialize the locks self._recv_lock = coros.Semaphore(0) self._send_lock = coros.Semaphore(0) # Boot the threads self._recv_thread = gevent.spawn(self._recv) self._send_...
[ "def", "_start", "(", "self", ")", ":", "# Initialize the locks", "self", ".", "_recv_lock", "=", "coros", ".", "Semaphore", "(", "0", ")", "self", ".", "_send_lock", "=", "coros", ".", "Semaphore", "(", "0", ")", "# Boot the threads", "self", ".", "_recv_...
Starts the underlying send and receive threads.
[ "Starts", "the", "underlying", "send", "and", "receive", "threads", "." ]
train
https://github.com/klmitch/tendril/blob/207102c83e88f8f1fa7ba605ef0aab2ae9078b36/tendril/tcp.py#L76-L92
klmitch/tendril
tendril/tcp.py
TCPTendril._recv
def _recv(self): """ Implementation of the receive thread. Waits for data to arrive on the socket, then passes the data through the defined receive framer and sends it on to the application. """ # Outer loop: receive some data while True: # Wait unti...
python
def _recv(self): """ Implementation of the receive thread. Waits for data to arrive on the socket, then passes the data through the defined receive framer and sends it on to the application. """ # Outer loop: receive some data while True: # Wait unti...
[ "def", "_recv", "(", "self", ")", ":", "# Outer loop: receive some data", "while", "True", ":", "# Wait until we can go", "self", ".", "_recv_lock", ".", "release", "(", ")", "gevent", ".", "sleep", "(", ")", "# Yield to another thread", "self", ".", "_recv_lock",...
Implementation of the receive thread. Waits for data to arrive on the socket, then passes the data through the defined receive framer and sends it on to the application.
[ "Implementation", "of", "the", "receive", "thread", ".", "Waits", "for", "data", "to", "arrive", "on", "the", "socket", "then", "passes", "the", "data", "through", "the", "defined", "receive", "framer", "and", "sends", "it", "on", "to", "the", "application",...
train
https://github.com/klmitch/tendril/blob/207102c83e88f8f1fa7ba605ef0aab2ae9078b36/tendril/tcp.py#L94-L137
klmitch/tendril
tendril/tcp.py
TCPTendril._send
def _send(self): """ Implementation of the send thread. Waits for data to be added to the send buffer, then passes as much of the buffered data to the socket ``send()`` method as possible. """ # Outer loop: wait for data to send while True: # Release...
python
def _send(self): """ Implementation of the send thread. Waits for data to be added to the send buffer, then passes as much of the buffered data to the socket ``send()`` method as possible. """ # Outer loop: wait for data to send while True: # Release...
[ "def", "_send", "(", "self", ")", ":", "# Outer loop: wait for data to send", "while", "True", ":", "# Release the send lock and wait for data, then reacquire", "# the send lock", "self", ".", "_send_lock", ".", "release", "(", ")", "self", ".", "_sendbuf_event", ".", "...
Implementation of the send thread. Waits for data to be added to the send buffer, then passes as much of the buffered data to the socket ``send()`` method as possible.
[ "Implementation", "of", "the", "send", "thread", ".", "Waits", "for", "data", "to", "be", "added", "to", "the", "send", "buffer", "then", "passes", "as", "much", "of", "the", "buffered", "data", "to", "the", "socket", "send", "()", "method", "as", "possi...
train
https://github.com/klmitch/tendril/blob/207102c83e88f8f1fa7ba605ef0aab2ae9078b36/tendril/tcp.py#L139-L163
klmitch/tendril
tendril/tcp.py
TCPTendril._thread_error
def _thread_error(self, thread): """ Handles the case that the send or receive thread exit or throw an exception. """ # Avoid double-killing the thread if thread == self._send_thread: self._send_thread = None if thread == self._recv_thread: ...
python
def _thread_error(self, thread): """ Handles the case that the send or receive thread exit or throw an exception. """ # Avoid double-killing the thread if thread == self._send_thread: self._send_thread = None if thread == self._recv_thread: ...
[ "def", "_thread_error", "(", "self", ",", "thread", ")", ":", "# Avoid double-killing the thread", "if", "thread", "==", "self", ".", "_send_thread", ":", "self", ".", "_send_thread", "=", "None", "if", "thread", "==", "self", ".", "_recv_thread", ":", "self",...
Handles the case that the send or receive thread exit or throw an exception.
[ "Handles", "the", "case", "that", "the", "send", "or", "receive", "thread", "exit", "or", "throw", "an", "exception", "." ]
train
https://github.com/klmitch/tendril/blob/207102c83e88f8f1fa7ba605ef0aab2ae9078b36/tendril/tcp.py#L165-L191
klmitch/tendril
tendril/tcp.py
TCPTendril.wrap
def wrap(self, wrapper): """ Allows the underlying socket to be wrapped, as by an SSL connection. :param wrapper: A callable taking, as its first argument, a socket.socket object. The callable must return a valid proxy for the socket.sock...
python
def wrap(self, wrapper): """ Allows the underlying socket to be wrapped, as by an SSL connection. :param wrapper: A callable taking, as its first argument, a socket.socket object. The callable must return a valid proxy for the socket.sock...
[ "def", "wrap", "(", "self", ",", "wrapper", ")", ":", "if", "self", ".", "_recv_thread", "and", "self", ".", "_send_thread", ":", "# Have to suspend the send/recv threads", "self", ".", "_recv_lock", ".", "acquire", "(", ")", "self", ".", "_send_lock", ".", ...
Allows the underlying socket to be wrapped, as by an SSL connection. :param wrapper: A callable taking, as its first argument, a socket.socket object. The callable must return a valid proxy for the socket.socket object, which will...
[ "Allows", "the", "underlying", "socket", "to", "be", "wrapped", "as", "by", "an", "SSL", "connection", "." ]
train
https://github.com/klmitch/tendril/blob/207102c83e88f8f1fa7ba605ef0aab2ae9078b36/tendril/tcp.py#L193-L224
klmitch/tendril
tendril/tcp.py
TCPTendril.send_frame
def send_frame(self, frame): """ Sends a frame to the other end of the connection. """ self._sendbuf += self._send_streamify(frame) self._sendbuf_event.set()
python
def send_frame(self, frame): """ Sends a frame to the other end of the connection. """ self._sendbuf += self._send_streamify(frame) self._sendbuf_event.set()
[ "def", "send_frame", "(", "self", ",", "frame", ")", ":", "self", ".", "_sendbuf", "+=", "self", ".", "_send_streamify", "(", "frame", ")", "self", ".", "_sendbuf_event", ".", "set", "(", ")" ]
Sends a frame to the other end of the connection.
[ "Sends", "a", "frame", "to", "the", "other", "end", "of", "the", "connection", "." ]
train
https://github.com/klmitch/tendril/blob/207102c83e88f8f1fa7ba605ef0aab2ae9078b36/tendril/tcp.py#L234-L240
klmitch/tendril
tendril/tcp.py
TCPTendril.close
def close(self): """ Close the connection. Kills the send and receive threads, as well as closing the underlying socket. """ if self._recv_thread: self._recv_thread.kill() self._recv_thread = None if self._send_thread: self._send_thr...
python
def close(self): """ Close the connection. Kills the send and receive threads, as well as closing the underlying socket. """ if self._recv_thread: self._recv_thread.kill() self._recv_thread = None if self._send_thread: self._send_thr...
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "_recv_thread", ":", "self", ".", "_recv_thread", ".", "kill", "(", ")", "self", ".", "_recv_thread", "=", "None", "if", "self", ".", "_send_thread", ":", "self", ".", "_send_thread", ".", "kill...
Close the connection. Kills the send and receive threads, as well as closing the underlying socket.
[ "Close", "the", "connection", ".", "Kills", "the", "send", "and", "receive", "threads", "as", "well", "as", "closing", "the", "underlying", "socket", "." ]
train
https://github.com/klmitch/tendril/blob/207102c83e88f8f1fa7ba605ef0aab2ae9078b36/tendril/tcp.py#L242-L261
klmitch/tendril
tendril/tcp.py
TCPTendrilManager.connect
def connect(self, target, acceptor, wrapper=None): """ Initiate a connection from the tendril manager's endpoint. Once the connection is completed, a TCPTendril object will be created and passed to the given acceptor. :param target: The target of the connection attempt. ...
python
def connect(self, target, acceptor, wrapper=None): """ Initiate a connection from the tendril manager's endpoint. Once the connection is completed, a TCPTendril object will be created and passed to the given acceptor. :param target: The target of the connection attempt. ...
[ "def", "connect", "(", "self", ",", "target", ",", "acceptor", ",", "wrapper", "=", "None", ")", ":", "# Call some common sanity-checks", "super", "(", "TCPTendrilManager", ",", "self", ")", ".", "connect", "(", "target", ",", "acceptor", ",", "wrapper", ")"...
Initiate a connection from the tendril manager's endpoint. Once the connection is completed, a TCPTendril object will be created and passed to the given acceptor. :param target: The target of the connection attempt. :param acceptor: A callable which will initialize the state of ...
[ "Initiate", "a", "connection", "from", "the", "tendril", "manager", "s", "endpoint", ".", "Once", "the", "connection", "is", "completed", "a", "TCPTendril", "object", "will", "be", "created", "and", "passed", "to", "the", "given", "acceptor", "." ]
train
https://github.com/klmitch/tendril/blob/207102c83e88f8f1fa7ba605ef0aab2ae9078b36/tendril/tcp.py#L276-L330
klmitch/tendril
tendril/tcp.py
TCPTendrilManager.listener
def listener(self, acceptor, wrapper): """ Listens for new connections to the manager's endpoint. Once a new connection is received, a TCPTendril object is generated for it and it is passed to the acceptor, which must initialize the state of the connection. If no acceptor is gi...
python
def listener(self, acceptor, wrapper): """ Listens for new connections to the manager's endpoint. Once a new connection is received, a TCPTendril object is generated for it and it is passed to the acceptor, which must initialize the state of the connection. If no acceptor is gi...
[ "def", "listener", "(", "self", ",", "acceptor", ",", "wrapper", ")", ":", "# If we have no acceptor, there's nothing for us to do here", "if", "not", "acceptor", ":", "# Not listening on anything", "self", ".", "local_addr", "=", "None", "# Just sleep in a loop", "while"...
Listens for new connections to the manager's endpoint. Once a new connection is received, a TCPTendril object is generated for it and it is passed to the acceptor, which must initialize the state of the connection. If no acceptor is given, no new connections can be initialized. ...
[ "Listens", "for", "new", "connections", "to", "the", "manager", "s", "endpoint", ".", "Once", "a", "new", "connection", "is", "received", "a", "TCPTendril", "object", "is", "generated", "for", "it", "and", "it", "is", "passed", "to", "the", "acceptor", "wh...
train
https://github.com/klmitch/tendril/blob/207102c83e88f8f1fa7ba605ef0aab2ae9078b36/tendril/tcp.py#L332-L404
jambonrose/django-decorator-plus
decorator_plus/view_decorators.py
require_http_methods
def require_http_methods(request_methods): """ Decorator to make a function view only accept particular request methods. Usage:: @require_http_methods(["GET", "POST"]) def function_view(request): # HTTP methods != GET or POST results in 405 error code response """ if not...
python
def require_http_methods(request_methods): """ Decorator to make a function view only accept particular request methods. Usage:: @require_http_methods(["GET", "POST"]) def function_view(request): # HTTP methods != GET or POST results in 405 error code response """ if not...
[ "def", "require_http_methods", "(", "request_methods", ")", ":", "if", "not", "isinstance", "(", "request_methods", ",", "(", "list", ",", "tuple", ")", ")", ":", "raise", "ImproperlyConfigured", "(", "\"require_http_methods decorator must be called \"", "\"with a list ...
Decorator to make a function view only accept particular request methods. Usage:: @require_http_methods(["GET", "POST"]) def function_view(request): # HTTP methods != GET or POST results in 405 error code response
[ "Decorator", "to", "make", "a", "function", "view", "only", "accept", "particular", "request", "methods", ".", "Usage", "::" ]
train
https://github.com/jambonrose/django-decorator-plus/blob/2039ef7a4b5f8abb29e455e8218c207fcae24e2c/decorator_plus/view_decorators.py#L24-L78
noobermin/lspreader
lspreader/dotlsp.py
getdim
def getdim(lsp): ''' Obtain the dimensionality of a .lsp file. This should work for all well formatted .lsp files. Parameters: ----------- lsp : .lsp string Returns a list of dimensions. ''' dims= ['x','y', 'z']; rxs = ['{}-cells *([0-9]+)'.format(x) for x in ['x','y','...
python
def getdim(lsp): ''' Obtain the dimensionality of a .lsp file. This should work for all well formatted .lsp files. Parameters: ----------- lsp : .lsp string Returns a list of dimensions. ''' dims= ['x','y', 'z']; rxs = ['{}-cells *([0-9]+)'.format(x) for x in ['x','y','...
[ "def", "getdim", "(", "lsp", ")", ":", "dims", "=", "[", "'x'", ",", "'y'", ",", "'z'", "]", "rxs", "=", "[", "'{}-cells *([0-9]+)'", ".", "format", "(", "x", ")", "for", "x", "in", "[", "'x'", ",", "'y'", ",", "'z'", "]", "]", "return", "[", ...
Obtain the dimensionality of a .lsp file. This should work for all well formatted .lsp files. Parameters: ----------- lsp : .lsp string Returns a list of dimensions.
[ "Obtain", "the", "dimensionality", "of", "a", ".", "lsp", "file", ".", "This", "should", "work", "for", "all", "well", "formatted", ".", "lsp", "files", "." ]
train
https://github.com/noobermin/lspreader/blob/903b9d6427513b07986ffacf76cbca54e18d8be6/lspreader/dotlsp.py#L26-L41
noobermin/lspreader
lspreader/dotlsp.py
getpexts
def getpexts(lsp): ''' Get information from pext planes. This might or might not work, use with caution! Parameters: ----------- lsp : .lsp string Returns a list of dicts with information for all pext planes ''' lines=lsp.split('\n'); #unfortunately regex doesn't work ...
python
def getpexts(lsp): ''' Get information from pext planes. This might or might not work, use with caution! Parameters: ----------- lsp : .lsp string Returns a list of dicts with information for all pext planes ''' lines=lsp.split('\n'); #unfortunately regex doesn't work ...
[ "def", "getpexts", "(", "lsp", ")", ":", "lines", "=", "lsp", ".", "split", "(", "'\\n'", ")", "#unfortunately regex doesn't work here", "lns", ",", "planens", "=", "zip", "(", "*", "[", "(", "i", ",", "int", "(", "re", ".", "search", "(", "'^ *extract...
Get information from pext planes. This might or might not work, use with caution! Parameters: ----------- lsp : .lsp string Returns a list of dicts with information for all pext planes
[ "Get", "information", "from", "pext", "planes", ".", "This", "might", "or", "might", "not", "work", "use", "with", "caution!" ]
train
https://github.com/noobermin/lspreader/blob/903b9d6427513b07986ffacf76cbca54e18d8be6/lspreader/dotlsp.py#L43-L92
shaypal5/comath
comath/array/array.py
percentile
def percentile(sorted_list, percent, key=lambda x: x): """Find the percentile of a sorted list of values. Arguments --------- sorted_list : list A sorted (ascending) list of values. percent : float A float value from 0.0 to 1.0. key : function, optional An optional funct...
python
def percentile(sorted_list, percent, key=lambda x: x): """Find the percentile of a sorted list of values. Arguments --------- sorted_list : list A sorted (ascending) list of values. percent : float A float value from 0.0 to 1.0. key : function, optional An optional funct...
[ "def", "percentile", "(", "sorted_list", ",", "percent", ",", "key", "=", "lambda", "x", ":", "x", ")", ":", "if", "not", "sorted_list", ":", "return", "None", "if", "percent", "==", "1", ":", "return", "float", "(", "sorted_list", "[", "-", "1", "]"...
Find the percentile of a sorted list of values. Arguments --------- sorted_list : list A sorted (ascending) list of values. percent : float A float value from 0.0 to 1.0. key : function, optional An optional function to compute a value from each element of N. Returns ...
[ "Find", "the", "percentile", "of", "a", "sorted", "list", "of", "values", "." ]
train
https://github.com/shaypal5/comath/blob/1333e3b96242a5bad9d3e699ffd58a1597fdc89f/comath/array/array.py#L24-L68