repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
3 values
summary
stringlengths
4
350
projectshift/shift-boiler
boiler/jinja/functions.py
asset
def asset(url=None): """ Asset helper Generates path to a static asset based on configuration base path and support for versioning. Will easily allow you to move your assets away to a CDN without changing templates. Versioning allows you to cache your asset changes forever by the webserver. ...
python
def asset(url=None): """ Asset helper Generates path to a static asset based on configuration base path and support for versioning. Will easily allow you to move your assets away to a CDN without changing templates. Versioning allows you to cache your asset changes forever by the webserver. ...
[ "def", "asset", "(", "url", "=", "None", ")", ":", "# fallback to url_for('static') if assets path not configured", "url", "=", "url", ".", "lstrip", "(", "'/'", ")", "assets_path", "=", "app", ".", "config", ".", "get", "(", "'ASSETS_PATH'", ")", "if", "not",...
Asset helper Generates path to a static asset based on configuration base path and support for versioning. Will easily allow you to move your assets away to a CDN without changing templates. Versioning allows you to cache your asset changes forever by the webserver. :param url: string - relative pa...
[ "Asset", "helper", "Generates", "path", "to", "a", "static", "asset", "based", "on", "configuration", "base", "path", "and", "support", "for", "versioning", ".", "Will", "easily", "allow", "you", "to", "move", "your", "assets", "away", "to", "a", "CDN", "w...
8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b
https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/jinja/functions.py#L6-L37
train
Asset helper generates path to a static asset based on the configuration base path and the ASSETS_PATH configuration variable.
Kortemme-Lab/klab
klab/fs/io.py
safe_gz_unzip
def safe_gz_unzip(contents): ''' Takes a file's contents passed as a string (contents) and either gz-unzips the contents and returns the uncompressed data or else returns the original contents. This function raises an exception if passed what appears to be gz-zipped data (from the magic number) but if gzip ...
python
def safe_gz_unzip(contents): ''' Takes a file's contents passed as a string (contents) and either gz-unzips the contents and returns the uncompressed data or else returns the original contents. This function raises an exception if passed what appears to be gz-zipped data (from the magic number) but if gzip ...
[ "def", "safe_gz_unzip", "(", "contents", ")", ":", "if", "len", "(", "contents", ")", ">", "1", "and", "ord", "(", "contents", "[", "0", "]", ")", "==", "31", "and", "ord", "(", "contents", "[", "1", "]", ")", "==", "139", ":", "#contents = zlib.de...
Takes a file's contents passed as a string (contents) and either gz-unzips the contents and returns the uncompressed data or else returns the original contents. This function raises an exception if passed what appears to be gz-zipped data (from the magic number) but if gzip fails to decompress the contents. ...
[ "Takes", "a", "file", "s", "contents", "passed", "as", "a", "string", "(", "contents", ")", "and", "either", "gz", "-", "unzips", "the", "contents", "and", "returns", "the", "uncompressed", "data", "or", "else", "returns", "the", "original", "contents", "....
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/fs/io.py#L48-L64
train
Takes a file s contents passed as a string and either gz - unzips the contents and returns the uncompressed data.
clement-alexandre/TotemBionet
totembionet/src/model_picker/model_picker.py
pick_a_model_randomly
def pick_a_model_randomly(models: List[Any]) -> Any: """ Naive picking function, return one of the models chosen randomly. """ try: return random.choice(models) except IndexError as e: raise ModelPickerException(cause=e)
python
def pick_a_model_randomly(models: List[Any]) -> Any: """ Naive picking function, return one of the models chosen randomly. """ try: return random.choice(models) except IndexError as e: raise ModelPickerException(cause=e)
[ "def", "pick_a_model_randomly", "(", "models", ":", "List", "[", "Any", "]", ")", "->", "Any", ":", "try", ":", "return", "random", ".", "choice", "(", "models", ")", "except", "IndexError", "as", "e", ":", "raise", "ModelPickerException", "(", "cause", ...
Naive picking function, return one of the models chosen randomly.
[ "Naive", "picking", "function", "return", "one", "of", "the", "models", "chosen", "randomly", "." ]
f37a2f9358c1ce49f21c4a868b904da5dcd4614f
https://github.com/clement-alexandre/TotemBionet/blob/f37a2f9358c1ce49f21c4a868b904da5dcd4614f/totembionet/src/model_picker/model_picker.py#L16-L21
train
Naive picking function returns one of the models chosen randomly.
uogbuji/versa
tools/py/pipeline/core_actions.py
link
def link(origin=None, rel=None, value=None, attributes=None, source=None): ''' Action function generator to create a link based on the context's current link, or on provided parameters :param origin: IRI/string, or list of same; origins for the created relationships. If None, the action context provide...
python
def link(origin=None, rel=None, value=None, attributes=None, source=None): ''' Action function generator to create a link based on the context's current link, or on provided parameters :param origin: IRI/string, or list of same; origins for the created relationships. If None, the action context provide...
[ "def", "link", "(", "origin", "=", "None", ",", "rel", "=", "None", ",", "value", "=", "None", ",", "attributes", "=", "None", ",", "source", "=", "None", ")", ":", "attributes", "=", "attributes", "or", "{", "}", "#rel = I(iri.absolutize(rel, ctx.base))",...
Action function generator to create a link based on the context's current link, or on provided parameters :param origin: IRI/string, or list of same; origins for the created relationships. If None, the action context provides the parameter. :param rel: IRI/string, or list of same; IDs for the created rela...
[ "Action", "function", "generator", "to", "create", "a", "link", "based", "on", "the", "context", "s", "current", "link", "or", "on", "provided", "parameters" ]
f092ffc7ed363a5b170890955168500f32de0dd5
https://github.com/uogbuji/versa/blob/f092ffc7ed363a5b170890955168500f32de0dd5/tools/py/pipeline/core_actions.py#L17-L64
train
This function returns a function that creates a link based on the context s current link.
uogbuji/versa
tools/py/pipeline/core_actions.py
attr
def attr(aid): ''' Action function generator to retrieve an attribute from the current link ''' def _attr(ctx): return ctx.current_link[ATTRIBUTES].get(aid) return _attr
python
def attr(aid): ''' Action function generator to retrieve an attribute from the current link ''' def _attr(ctx): return ctx.current_link[ATTRIBUTES].get(aid) return _attr
[ "def", "attr", "(", "aid", ")", ":", "def", "_attr", "(", "ctx", ")", ":", "return", "ctx", ".", "current_link", "[", "ATTRIBUTES", "]", ".", "get", "(", "aid", ")", "return", "_attr" ]
Action function generator to retrieve an attribute from the current link
[ "Action", "function", "generator", "to", "retrieve", "an", "attribute", "from", "the", "current", "link" ]
f092ffc7ed363a5b170890955168500f32de0dd5
https://github.com/uogbuji/versa/blob/f092ffc7ed363a5b170890955168500f32de0dd5/tools/py/pipeline/core_actions.py#L82-L88
train
Returns an attribute from the current link
uogbuji/versa
tools/py/pipeline/core_actions.py
values
def values(*rels): ''' Action function generator to compute a set of relationships from criteria :param rels: List of relationships to compute :return: Versa action function to do the actual work ''' #Action function generator to multiplex a relationship at processing time def _values(ctx):...
python
def values(*rels): ''' Action function generator to compute a set of relationships from criteria :param rels: List of relationships to compute :return: Versa action function to do the actual work ''' #Action function generator to multiplex a relationship at processing time def _values(ctx):...
[ "def", "values", "(", "*", "rels", ")", ":", "#Action function generator to multiplex a relationship at processing time", "def", "_values", "(", "ctx", ")", ":", "'''\n Versa action function Utility to specify a list of relationships\n\n :param ctx: Versa context used in pr...
Action function generator to compute a set of relationships from criteria :param rels: List of relationships to compute :return: Versa action function to do the actual work
[ "Action", "function", "generator", "to", "compute", "a", "set", "of", "relationships", "from", "criteria" ]
f092ffc7ed363a5b170890955168500f32de0dd5
https://github.com/uogbuji/versa/blob/f092ffc7ed363a5b170890955168500f32de0dd5/tools/py/pipeline/core_actions.py#L109-L126
train
Returns a function that computes a set of key - value tuples from the attributes of the link holding the given list of relationships.
uogbuji/versa
tools/py/pipeline/core_actions.py
ifexists
def ifexists(test, value, alt=None): ''' Action function generator providing an if/then/else type primitive :param test: Expression to be tested to determine the branch path :param value: Expression providing the result if test is true :param alt: Expression providing the result if test is false ...
python
def ifexists(test, value, alt=None): ''' Action function generator providing an if/then/else type primitive :param test: Expression to be tested to determine the branch path :param value: Expression providing the result if test is true :param alt: Expression providing the result if test is false ...
[ "def", "ifexists", "(", "test", ",", "value", ",", "alt", "=", "None", ")", ":", "def", "_ifexists", "(", "ctx", ")", ":", "'''\n Versa action function Utility to specify a list of relationships\n\n :param ctx: Versa context used in processing (e.g. includes the pro...
Action function generator providing an if/then/else type primitive :param test: Expression to be tested to determine the branch path :param value: Expression providing the result if test is true :param alt: Expression providing the result if test is false :return: Versa action function to do the actual ...
[ "Action", "function", "generator", "providing", "an", "if", "/", "then", "/", "else", "type", "primitive", ":", "param", "test", ":", "Expression", "to", "be", "tested", "to", "determine", "the", "branch", "path", ":", "param", "value", ":", "Expression", ...
f092ffc7ed363a5b170890955168500f32de0dd5
https://github.com/uogbuji/versa/blob/f092ffc7ed363a5b170890955168500f32de0dd5/tools/py/pipeline/core_actions.py#L129-L149
train
This function returns a function that returns the value of the value of the value of the value of the value of the value of the value of the alt expression if test is True otherwise the alt expression of the value of the value of the value of the alt expression.
uogbuji/versa
tools/py/pipeline/core_actions.py
foreach
def foreach(origin=None, rel=None, target=None, attributes=None): ''' Action function generator to compute a combination of links :return: Versa action function to do the actual work ''' def _foreach(ctx): ''' Versa action function utility to compute a list of values from a list of ...
python
def foreach(origin=None, rel=None, target=None, attributes=None): ''' Action function generator to compute a combination of links :return: Versa action function to do the actual work ''' def _foreach(ctx): ''' Versa action function utility to compute a list of values from a list of ...
[ "def", "foreach", "(", "origin", "=", "None", ",", "rel", "=", "None", ",", "target", "=", "None", ",", "attributes", "=", "None", ")", ":", "def", "_foreach", "(", "ctx", ")", ":", "'''\n Versa action function utility to compute a list of values from a lis...
Action function generator to compute a combination of links :return: Versa action function to do the actual work
[ "Action", "function", "generator", "to", "compute", "a", "combination", "of", "links" ]
f092ffc7ed363a5b170890955168500f32de0dd5
https://github.com/uogbuji/versa/blob/f092ffc7ed363a5b170890955168500f32de0dd5/tools/py/pipeline/core_actions.py#L152-L182
train
A generator function to compute a combination of links
uogbuji/versa
tools/py/pipeline/core_actions.py
materialize
def materialize(typ, rel=None, origin=None, unique=None, links=None, inverse=False, split=None, attributes=None): ''' Create a new resource related to the origin :param typ: IRI of the type for the resource to be materialized, which becomes the target of the main link, and the origin of any additio...
python
def materialize(typ, rel=None, origin=None, unique=None, links=None, inverse=False, split=None, attributes=None): ''' Create a new resource related to the origin :param typ: IRI of the type for the resource to be materialized, which becomes the target of the main link, and the origin of any additio...
[ "def", "materialize", "(", "typ", ",", "rel", "=", "None", ",", "origin", "=", "None", ",", "unique", "=", "None", ",", "links", "=", "None", ",", "inverse", "=", "False", ",", "split", "=", "None", ",", "attributes", "=", "None", ")", ":", "links"...
Create a new resource related to the origin :param typ: IRI of the type for the resource to be materialized, which becomes the target of the main link, and the origin of any additional links given in the links param :param rel: IRI of the relationship between the origin and the materialized target...
[ "Create", "a", "new", "resource", "related", "to", "the", "origin" ]
f092ffc7ed363a5b170890955168500f32de0dd5
https://github.com/uogbuji/versa/blob/f092ffc7ed363a5b170890955168500f32de0dd5/tools/py/pipeline/core_actions.py#L185-L319
train
This function creates a new resource related to the origin and materialize the main link between the origin and the materialized resource.
uogbuji/versa
tools/py/pipeline/core_actions.py
res
def res(arg): ''' Convert the argument into an IRI ref ''' def _res(ctx): _arg = arg(ctx) if callable(arg) else arg return I(arg) return _res
python
def res(arg): ''' Convert the argument into an IRI ref ''' def _res(ctx): _arg = arg(ctx) if callable(arg) else arg return I(arg) return _res
[ "def", "res", "(", "arg", ")", ":", "def", "_res", "(", "ctx", ")", ":", "_arg", "=", "arg", "(", "ctx", ")", "if", "callable", "(", "arg", ")", "else", "arg", "return", "I", "(", "arg", ")", "return", "_res" ]
Convert the argument into an IRI ref
[ "Convert", "the", "argument", "into", "an", "IRI", "ref" ]
f092ffc7ed363a5b170890955168500f32de0dd5
https://github.com/uogbuji/versa/blob/f092ffc7ed363a5b170890955168500f32de0dd5/tools/py/pipeline/core_actions.py#L322-L329
train
Convert the argument into an IRI ref
uogbuji/versa
tools/py/pipeline/core_actions.py
compose
def compose(*funcs): ''' Compose an ordered list of functions. Args of a,b,c,d evaluates as a(b(c(d(ctx)))) ''' def _compose(ctx): # last func gets context, rest get result of previous func _result = funcs[-1](ctx) for f in reversed(funcs[:-1]): _result = f(_result) ...
python
def compose(*funcs): ''' Compose an ordered list of functions. Args of a,b,c,d evaluates as a(b(c(d(ctx)))) ''' def _compose(ctx): # last func gets context, rest get result of previous func _result = funcs[-1](ctx) for f in reversed(funcs[:-1]): _result = f(_result) ...
[ "def", "compose", "(", "*", "funcs", ")", ":", "def", "_compose", "(", "ctx", ")", ":", "# last func gets context, rest get result of previous func", "_result", "=", "funcs", "[", "-", "1", "]", "(", "ctx", ")", "for", "f", "in", "reversed", "(", "funcs", ...
Compose an ordered list of functions. Args of a,b,c,d evaluates as a(b(c(d(ctx))))
[ "Compose", "an", "ordered", "list", "of", "functions", ".", "Args", "of", "a", "b", "c", "d", "evaluates", "as", "a", "(", "b", "(", "c", "(", "d", "(", "ctx", "))))" ]
f092ffc7ed363a5b170890955168500f32de0dd5
https://github.com/uogbuji/versa/blob/f092ffc7ed363a5b170890955168500f32de0dd5/tools/py/pipeline/core_actions.py#L332-L343
train
Returns a function that returns the result of the last function in the list.
ronhanson/python-tbx
tbx/code.py
static_singleton
def static_singleton(*args, **kwargs): """ STATIC Singleton Design Pattern Decorator Class is initialized with arguments passed into the decorator. :Usage: >>> @static_singleton('yop') class Bob(Person): def __init__(arg1): self.info = arg1 def says...
python
def static_singleton(*args, **kwargs): """ STATIC Singleton Design Pattern Decorator Class is initialized with arguments passed into the decorator. :Usage: >>> @static_singleton('yop') class Bob(Person): def __init__(arg1): self.info = arg1 def says...
[ "def", "static_singleton", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "def", "__static_singleton_wrapper", "(", "cls", ")", ":", "if", "cls", "not", "in", "__singleton_instances", ":", "__singleton_instances", "[", "cls", "]", "=", "cls", "(", "*...
STATIC Singleton Design Pattern Decorator Class is initialized with arguments passed into the decorator. :Usage: >>> @static_singleton('yop') class Bob(Person): def __init__(arg1): self.info = arg1 def says(self): print self.info b1 ...
[ "STATIC", "Singleton", "Design", "Pattern", "Decorator", "Class", "is", "initialized", "with", "arguments", "passed", "into", "the", "decorator", "." ]
87f72ae0cadecafbcd144f1e930181fba77f6b83
https://github.com/ronhanson/python-tbx/blob/87f72ae0cadecafbcd144f1e930181fba77f6b83/tbx/code.py#L19-L42
train
A static singleton design pattern decorator that creates a new object of the same name and returns it.
ronhanson/python-tbx
tbx/code.py
safe_dict
def safe_dict(obj_or_func, **kwargs): """ Create a dict from any object with all attributes, but not the ones starting with an underscore _ Useful for objects or function that return an object that have no __dict__ attribute, like psutil functions. """ if callable(obj_or_func): res = obj_or_...
python
def safe_dict(obj_or_func, **kwargs): """ Create a dict from any object with all attributes, but not the ones starting with an underscore _ Useful for objects or function that return an object that have no __dict__ attribute, like psutil functions. """ if callable(obj_or_func): res = obj_or_...
[ "def", "safe_dict", "(", "obj_or_func", ",", "*", "*", "kwargs", ")", ":", "if", "callable", "(", "obj_or_func", ")", ":", "res", "=", "obj_or_func", "(", "*", "*", "kwargs", ")", "else", ":", "res", "=", "obj_or_func", "if", "hasattr", "(", "res", "...
Create a dict from any object with all attributes, but not the ones starting with an underscore _ Useful for objects or function that return an object that have no __dict__ attribute, like psutil functions.
[ "Create", "a", "dict", "from", "any", "object", "with", "all", "attributes", "but", "not", "the", "ones", "starting", "with", "an", "underscore", "_", "Useful", "for", "objects", "or", "function", "that", "return", "an", "object", "that", "have", "no", "__...
87f72ae0cadecafbcd144f1e930181fba77f6b83
https://github.com/ronhanson/python-tbx/blob/87f72ae0cadecafbcd144f1e930181fba77f6b83/tbx/code.py#L104-L123
train
Create a dict from any object with all attributes but not the ones starting with an underscore
ronhanson/python-tbx
tbx/code.py
get_method_documentation
def get_method_documentation(method): """ This function uses "inspect" to retrieve information about a method. Also, if you place comment on the method, method can be docummented with "reStructured Text". :param method: method to describe :returns: { 'name' : <stri...
python
def get_method_documentation(method): """ This function uses "inspect" to retrieve information about a method. Also, if you place comment on the method, method can be docummented with "reStructured Text". :param method: method to describe :returns: { 'name' : <stri...
[ "def", "get_method_documentation", "(", "method", ")", ":", "from", "inspect", "import", "getargspec", "result", "=", "{", "'name'", ":", "method", ".", "__name__", ",", "'friendly_name'", ":", "' '", ".", "join", "(", "[", "name", ".", "capitalize", "(", ...
This function uses "inspect" to retrieve information about a method. Also, if you place comment on the method, method can be docummented with "reStructured Text". :param method: method to describe :returns: { 'name' : <string> - name of the method, 'friendly_na...
[ "This", "function", "uses", "inspect", "to", "retrieve", "information", "about", "a", "method", "." ]
87f72ae0cadecafbcd144f1e930181fba77f6b83
https://github.com/ronhanson/python-tbx/blob/87f72ae0cadecafbcd144f1e930181fba77f6b83/tbx/code.py#L145-L208
train
This function returns the documentation of a method.
ronhanson/python-tbx
tbx/code.py
sort_dictionary_list
def sort_dictionary_list(dict_list, sort_key): """ sorts a list of dictionaries based on the value of the sort_key dict_list - a list of dictionaries sort_key - a string that identifies the key to sort the dictionaries with. Test sorting a list of dictionaries: >>> sort_dictionary_list([{...
python
def sort_dictionary_list(dict_list, sort_key): """ sorts a list of dictionaries based on the value of the sort_key dict_list - a list of dictionaries sort_key - a string that identifies the key to sort the dictionaries with. Test sorting a list of dictionaries: >>> sort_dictionary_list([{...
[ "def", "sort_dictionary_list", "(", "dict_list", ",", "sort_key", ")", ":", "if", "not", "dict_list", "or", "len", "(", "dict_list", ")", "==", "0", ":", "return", "dict_list", "dict_list", ".", "sort", "(", "key", "=", "itemgetter", "(", "sort_key", ")", ...
sorts a list of dictionaries based on the value of the sort_key dict_list - a list of dictionaries sort_key - a string that identifies the key to sort the dictionaries with. Test sorting a list of dictionaries: >>> sort_dictionary_list([{'b' : 1, 'value' : 2}, {'c' : 2, 'value' : 3}, {'a' : 3, 'v...
[ "sorts", "a", "list", "of", "dictionaries", "based", "on", "the", "value", "of", "the", "sort_key" ]
87f72ae0cadecafbcd144f1e930181fba77f6b83
https://github.com/ronhanson/python-tbx/blob/87f72ae0cadecafbcd144f1e930181fba77f6b83/tbx/code.py#L313-L327
train
Sort a list of dictionaries based on the value of the sort_key
ronhanson/python-tbx
tbx/code.py
SerializableObject.safe_info
def safe_info(self, dic=None): """ Returns public information of the object """ if dic is None and dic != {}: dic = self.to_dict() output = {} for (key, value) in dic.items(): if key[0] != '_': if isinstance(value, SerializableObjec...
python
def safe_info(self, dic=None): """ Returns public information of the object """ if dic is None and dic != {}: dic = self.to_dict() output = {} for (key, value) in dic.items(): if key[0] != '_': if isinstance(value, SerializableObjec...
[ "def", "safe_info", "(", "self", ",", "dic", "=", "None", ")", ":", "if", "dic", "is", "None", "and", "dic", "!=", "{", "}", ":", "dic", "=", "self", ".", "to_dict", "(", ")", "output", "=", "{", "}", "for", "(", "key", ",", "value", ")", "in...
Returns public information of the object
[ "Returns", "public", "information", "of", "the", "object" ]
87f72ae0cadecafbcd144f1e930181fba77f6b83
https://github.com/ronhanson/python-tbx/blob/87f72ae0cadecafbcd144f1e930181fba77f6b83/tbx/code.py#L286-L310
train
Returns the public information of the object.
projectshift/shift-boiler
boiler/cli/cli.py
run
def run(host='0.0.0.0', port=5000, reload=True, debug=True): """ Run development server """ from werkzeug.serving import run_simple app = bootstrap.get_app() return run_simple( hostname=host, port=port, application=app, use_reloader=reload, use_debugger=debug, ...
python
def run(host='0.0.0.0', port=5000, reload=True, debug=True): """ Run development server """ from werkzeug.serving import run_simple app = bootstrap.get_app() return run_simple( hostname=host, port=port, application=app, use_reloader=reload, use_debugger=debug, ...
[ "def", "run", "(", "host", "=", "'0.0.0.0'", ",", "port", "=", "5000", ",", "reload", "=", "True", ",", "debug", "=", "True", ")", ":", "from", "werkzeug", ".", "serving", "import", "run_simple", "app", "=", "bootstrap", ".", "get_app", "(", ")", "re...
Run development server
[ "Run", "development", "server" ]
8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b
https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/cli/cli.py#L26-L37
train
Run development server
projectshift/shift-boiler
boiler/cli/cli.py
shell
def shell(): """ Start application-aware shell """ app = bootstrap.get_app() context = dict(app=app) # and push app context app_context = app.app_context() app_context.push() # got ipython? ipython = importlib.util.find_spec("IPython") # run now if ipython: from IPytho...
python
def shell(): """ Start application-aware shell """ app = bootstrap.get_app() context = dict(app=app) # and push app context app_context = app.app_context() app_context.push() # got ipython? ipython = importlib.util.find_spec("IPython") # run now if ipython: from IPytho...
[ "def", "shell", "(", ")", ":", "app", "=", "bootstrap", ".", "get_app", "(", ")", "context", "=", "dict", "(", "app", "=", "app", ")", "# and push app context", "app_context", "=", "app", ".", "app_context", "(", ")", "app_context", ".", "push", "(", "...
Start application-aware shell
[ "Start", "application", "-", "aware", "shell" ]
8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b
https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/cli/cli.py#L41-L59
train
Start application - aware shell
mardix/Mocha
mocha/render.py
_normalize_response_tuple
def _normalize_response_tuple(tuple_): """ Helper function to normalize view return values . It always returns (dict, status, headers). Missing values will be None. For example in such cases when tuple_ is (dict, status), (dict, headers), (dict, status, headers), (dict, headers, status) ...
python
def _normalize_response_tuple(tuple_): """ Helper function to normalize view return values . It always returns (dict, status, headers). Missing values will be None. For example in such cases when tuple_ is (dict, status), (dict, headers), (dict, status, headers), (dict, headers, status) ...
[ "def", "_normalize_response_tuple", "(", "tuple_", ")", ":", "v", "=", "tuple_", "+", "(", "None", ",", ")", "*", "(", "3", "-", "len", "(", "tuple_", ")", ")", "return", "v", "if", "isinstance", "(", "v", "[", "1", "]", ",", "int", ")", "else", ...
Helper function to normalize view return values . It always returns (dict, status, headers). Missing values will be None. For example in such cases when tuple_ is (dict, status), (dict, headers), (dict, status, headers), (dict, headers, status) It assumes what status is int, so this constructio...
[ "Helper", "function", "to", "normalize", "view", "return", "values", ".", "It", "always", "returns", "(", "dict", "status", "headers", ")", ".", "Missing", "values", "will", "be", "None", ".", "For", "example", "in", "such", "cases", "when", "tuple_", "is"...
bce481cb31a0972061dd99bc548701411dcb9de3
https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/render.py#L50-L63
train
Helper function to normalize response tuple.
mardix/Mocha
mocha/render.py
_build_response
def _build_response(data, renderer=None): """ Build a response using the renderer from the data :return: """ if isinstance(data, Response) or isinstance(data, BaseResponse): return data if not renderer: raise AttributeError(" Renderer is required") if isinstance(data, dict) o...
python
def _build_response(data, renderer=None): """ Build a response using the renderer from the data :return: """ if isinstance(data, Response) or isinstance(data, BaseResponse): return data if not renderer: raise AttributeError(" Renderer is required") if isinstance(data, dict) o...
[ "def", "_build_response", "(", "data", ",", "renderer", "=", "None", ")", ":", "if", "isinstance", "(", "data", ",", "Response", ")", "or", "isinstance", "(", "data", ",", "BaseResponse", ")", ":", "return", "data", "if", "not", "renderer", ":", "raise",...
Build a response using the renderer from the data :return:
[ "Build", "a", "response", "using", "the", "renderer", "from", "the", "data", ":", "return", ":" ]
bce481cb31a0972061dd99bc548701411dcb9de3
https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/render.py#L79-L98
train
Builds a response from the data.
mardix/Mocha
mocha/render.py
json
def json(func): """ Decorator to render as JSON :param func: :return: """ if inspect.isclass(func): apply_function_to_members(func, json) return func else: @functools.wraps(func) def decorated_view(*args, **kwargs): data = func(*args, **kwargs) ...
python
def json(func): """ Decorator to render as JSON :param func: :return: """ if inspect.isclass(func): apply_function_to_members(func, json) return func else: @functools.wraps(func) def decorated_view(*args, **kwargs): data = func(*args, **kwargs) ...
[ "def", "json", "(", "func", ")", ":", "if", "inspect", ".", "isclass", "(", "func", ")", ":", "apply_function_to_members", "(", "func", ",", "json", ")", "return", "func", "else", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "decorated...
Decorator to render as JSON :param func: :return:
[ "Decorator", "to", "render", "as", "JSON", ":", "param", "func", ":", ":", "return", ":" ]
bce481cb31a0972061dd99bc548701411dcb9de3
https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/render.py#L104-L118
train
Decorator to render as JSON
mardix/Mocha
mocha/render.py
xml
def xml(func): """ Decorator to render as XML :param func: :return: """ if inspect.isclass(func): apply_function_to_members(func, xml) return func else: @functools.wraps(func) def decorated_view(*args, **kwargs): data = func(*args, **kwargs) ...
python
def xml(func): """ Decorator to render as XML :param func: :return: """ if inspect.isclass(func): apply_function_to_members(func, xml) return func else: @functools.wraps(func) def decorated_view(*args, **kwargs): data = func(*args, **kwargs) ...
[ "def", "xml", "(", "func", ")", ":", "if", "inspect", ".", "isclass", "(", "func", ")", ":", "apply_function_to_members", "(", "func", ",", "xml", ")", "return", "func", "else", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "decorated_v...
Decorator to render as XML :param func: :return:
[ "Decorator", "to", "render", "as", "XML", ":", "param", "func", ":", ":", "return", ":" ]
bce481cb31a0972061dd99bc548701411dcb9de3
https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/render.py#L121-L135
train
Decorator to render as XML
mardix/Mocha
mocha/render.py
jsonp
def jsonp(func): """Wraps JSONified output for JSONP requests. http://flask.pocoo.org/snippets/79/ """ @functools.wraps(func) def decorated_view(*args, **kwargs): callback = request.args.get('callback', None) if callback: data = str(func(*args, **kwargs)) con...
python
def jsonp(func): """Wraps JSONified output for JSONP requests. http://flask.pocoo.org/snippets/79/ """ @functools.wraps(func) def decorated_view(*args, **kwargs): callback = request.args.get('callback', None) if callback: data = str(func(*args, **kwargs)) con...
[ "def", "jsonp", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "decorated_view", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "callback", "=", "request", ".", "args", ".", "get", "(", "'callback'", ",", "Non...
Wraps JSONified output for JSONP requests. http://flask.pocoo.org/snippets/79/
[ "Wraps", "JSONified", "output", "for", "JSONP", "requests", ".", "http", ":", "//", "flask", ".", "pocoo", ".", "org", "/", "snippets", "/", "79", "/" ]
bce481cb31a0972061dd99bc548701411dcb9de3
https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/render.py#L138-L153
train
Wraps JSONified output for JSONP requests.
mardix/Mocha
mocha/render.py
SiteNavigation.add
def add(self, title, obj, **kwargs): """ Add a title :param title: str: The title of the menu :param obj: class or method :param kwargs: :return: """ is_class = inspect.isclass(obj) self._push(title=title, view=obj, ...
python
def add(self, title, obj, **kwargs): """ Add a title :param title: str: The title of the menu :param obj: class or method :param kwargs: :return: """ is_class = inspect.isclass(obj) self._push(title=title, view=obj, ...
[ "def", "add", "(", "self", ",", "title", ",", "obj", ",", "*", "*", "kwargs", ")", ":", "is_class", "=", "inspect", ".", "isclass", "(", "obj", ")", "self", ".", "_push", "(", "title", "=", "title", ",", "view", "=", "obj", ",", "class_name", "="...
Add a title :param title: str: The title of the menu :param obj: class or method :param kwargs: :return:
[ "Add", "a", "title", ":", "param", "title", ":", "str", ":", "The", "title", "of", "the", "menu", ":", "param", "obj", ":", "class", "or", "method", ":", "param", "kwargs", ":", ":", "return", ":" ]
bce481cb31a0972061dd99bc548701411dcb9de3
https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/render.py#L311-L324
train
Add a title to the menu
mardix/Mocha
mocha/render.py
SiteNavigation._push
def _push(self, title, view, class_name, is_class, **kwargs): """ Push nav data stack """ # Set the page title set_view_attr(view, "title", title, cls_name=class_name) module_name = view.__module__ method_name = view.__name__ _endpoint = build_endpoint_route_name(view,...
python
def _push(self, title, view, class_name, is_class, **kwargs): """ Push nav data stack """ # Set the page title set_view_attr(view, "title", title, cls_name=class_name) module_name = view.__module__ method_name = view.__name__ _endpoint = build_endpoint_route_name(view,...
[ "def", "_push", "(", "self", ",", "title", ",", "view", ",", "class_name", ",", "is_class", ",", "*", "*", "kwargs", ")", ":", "# Set the page title", "set_view_attr", "(", "view", ",", "\"title\"", ",", "title", ",", "cls_name", "=", "class_name", ")", ...
Push nav data stack
[ "Push", "nav", "data", "stack" ]
bce481cb31a0972061dd99bc548701411dcb9de3
https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/render.py#L329-L400
train
Pushes a new nav data item onto the stack.
mardix/Mocha
mocha/render.py
SiteNavigation.render
def render(self): """ Render the menu into a sorted by order multi dict """ menu_list = [] menu_index = 0 for _, menu in copy.deepcopy(self.MENU).items(): subnav = [] menu["kwargs"]["_id"] = str(menu_index) menu["kwargs"]["active"] = False ...
python
def render(self): """ Render the menu into a sorted by order multi dict """ menu_list = [] menu_index = 0 for _, menu in copy.deepcopy(self.MENU).items(): subnav = [] menu["kwargs"]["_id"] = str(menu_index) menu["kwargs"]["active"] = False ...
[ "def", "render", "(", "self", ")", ":", "menu_list", "=", "[", "]", "menu_index", "=", "0", "for", "_", ",", "menu", "in", "copy", ".", "deepcopy", "(", "self", ".", "MENU", ")", ".", "items", "(", ")", ":", "subnav", "=", "[", "]", "menu", "["...
Render the menu into a sorted by order multi dict
[ "Render", "the", "menu", "into", "a", "sorted", "by", "order", "multi", "dict" ]
bce481cb31a0972061dd99bc548701411dcb9de3
https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/render.py#L425-L462
train
Render the menu into a sorted by order multi dict
PBR/MQ2
MQ2/add_qtl_to_map.py
add_qtl_to_marker
def add_qtl_to_marker(marker, qtls): """Add the number of QTLs found for a given marker. :arg marker, the marker we are looking for the QTL's. :arg qtls, the list of all QTLs found. """ cnt = 0 for qtl in qtls: if qtl[-1] == marker[0]: cnt = cnt + 1 marker.append(str(c...
python
def add_qtl_to_marker(marker, qtls): """Add the number of QTLs found for a given marker. :arg marker, the marker we are looking for the QTL's. :arg qtls, the list of all QTLs found. """ cnt = 0 for qtl in qtls: if qtl[-1] == marker[0]: cnt = cnt + 1 marker.append(str(c...
[ "def", "add_qtl_to_marker", "(", "marker", ",", "qtls", ")", ":", "cnt", "=", "0", "for", "qtl", "in", "qtls", ":", "if", "qtl", "[", "-", "1", "]", "==", "marker", "[", "0", "]", ":", "cnt", "=", "cnt", "+", "1", "marker", ".", "append", "(", ...
Add the number of QTLs found for a given marker. :arg marker, the marker we are looking for the QTL's. :arg qtls, the list of all QTLs found.
[ "Add", "the", "number", "of", "QTLs", "found", "for", "a", "given", "marker", "." ]
6d84dea47e6751333004743f588f03158e35c28d
https://github.com/PBR/MQ2/blob/6d84dea47e6751333004743f588f03158e35c28d/MQ2/add_qtl_to_map.py#L38-L51
train
Adds the number of QTLs found for a given marker.
PBR/MQ2
MQ2/add_qtl_to_map.py
add_qtl_to_map
def add_qtl_to_map(qtlfile, mapfile, outputfile='map_with_qtls.csv'): """ This function adds to a genetic map for each marker the number of significant QTLs found. :arg qtlfile, the output from MapQTL transformed to a csv file via 'parse_mapqtl_file' which contains the closest markers. :arg map...
python
def add_qtl_to_map(qtlfile, mapfile, outputfile='map_with_qtls.csv'): """ This function adds to a genetic map for each marker the number of significant QTLs found. :arg qtlfile, the output from MapQTL transformed to a csv file via 'parse_mapqtl_file' which contains the closest markers. :arg map...
[ "def", "add_qtl_to_map", "(", "qtlfile", ",", "mapfile", ",", "outputfile", "=", "'map_with_qtls.csv'", ")", ":", "qtl_list", "=", "read_input_file", "(", "qtlfile", ",", "','", ")", "map_list", "=", "read_input_file", "(", "mapfile", ",", "','", ")", "map_lis...
This function adds to a genetic map for each marker the number of significant QTLs found. :arg qtlfile, the output from MapQTL transformed to a csv file via 'parse_mapqtl_file' which contains the closest markers. :arg mapfile, the genetic map with all the markers. :kwarg outputfile, the name of...
[ "This", "function", "adds", "to", "a", "genetic", "map", "for", "each", "marker", "the", "number", "of", "significant", "QTLs", "found", "." ]
6d84dea47e6751333004743f588f03158e35c28d
https://github.com/PBR/MQ2/blob/6d84dea47e6751333004743f588f03158e35c28d/MQ2/add_qtl_to_map.py#L54-L76
train
This function adds QTLs to the genetic map.
franciscoruiz/python-elm
elm327/connection.py
SerialConnection.send_command
def send_command(self, data, read_delay=None): """Write "data" to the port and return the response form it""" self._write(data) if read_delay: time.sleep(read_delay) return self._read()
python
def send_command(self, data, read_delay=None): """Write "data" to the port and return the response form it""" self._write(data) if read_delay: time.sleep(read_delay) return self._read()
[ "def", "send_command", "(", "self", ",", "data", ",", "read_delay", "=", "None", ")", ":", "self", ".", "_write", "(", "data", ")", "if", "read_delay", ":", "time", ".", "sleep", "(", "read_delay", ")", "return", "self", ".", "_read", "(", ")" ]
Write "data" to the port and return the response form it
[ "Write", "data", "to", "the", "port", "and", "return", "the", "response", "form", "it" ]
cdcecfc363b1eb25d21659bc14cf68a4a19970b6
https://github.com/franciscoruiz/python-elm/blob/cdcecfc363b1eb25d21659bc14cf68a4a19970b6/elm327/connection.py#L45-L50
train
Send a command to the port and return the response form it
inveniosoftware/invenio-pidrelations
invenio_pidrelations/serializers/utils.py
serialize_relations
def serialize_relations(pid): """Serialize the relations for given PID.""" data = {} relations = PIDRelation.get_child_relations(pid).all() for relation in relations: rel_cfg = resolve_relation_type_config(relation.relation_type) dump_relation(rel_cfg.api(relation.parent), ...
python
def serialize_relations(pid): """Serialize the relations for given PID.""" data = {} relations = PIDRelation.get_child_relations(pid).all() for relation in relations: rel_cfg = resolve_relation_type_config(relation.relation_type) dump_relation(rel_cfg.api(relation.parent), ...
[ "def", "serialize_relations", "(", "pid", ")", ":", "data", "=", "{", "}", "relations", "=", "PIDRelation", ".", "get_child_relations", "(", "pid", ")", ".", "all", "(", ")", "for", "relation", "in", "relations", ":", "rel_cfg", "=", "resolve_relation_type_c...
Serialize the relations for given PID.
[ "Serialize", "the", "relations", "for", "given", "PID", "." ]
a49f3725cf595b663c5b04814280b231f88bc333
https://github.com/inveniosoftware/invenio-pidrelations/blob/a49f3725cf595b663c5b04814280b231f88bc333/invenio_pidrelations/serializers/utils.py#L32-L44
train
Serialize the relations for given PID.
inveniosoftware/invenio-pidrelations
invenio_pidrelations/serializers/utils.py
dump_relation
def dump_relation(api, rel_cfg, pid, data): """Dump a specific relation to a data dict.""" schema_class = rel_cfg.schema if schema_class is not None: schema = schema_class() schema.context['pid'] = pid result, errors = schema.dump(api) data.setdefault(rel_cfg.name, []).append...
python
def dump_relation(api, rel_cfg, pid, data): """Dump a specific relation to a data dict.""" schema_class = rel_cfg.schema if schema_class is not None: schema = schema_class() schema.context['pid'] = pid result, errors = schema.dump(api) data.setdefault(rel_cfg.name, []).append...
[ "def", "dump_relation", "(", "api", ",", "rel_cfg", ",", "pid", ",", "data", ")", ":", "schema_class", "=", "rel_cfg", ".", "schema", "if", "schema_class", "is", "not", "None", ":", "schema", "=", "schema_class", "(", ")", "schema", ".", "context", "[", ...
Dump a specific relation to a data dict.
[ "Dump", "a", "specific", "relation", "to", "a", "data", "dict", "." ]
a49f3725cf595b663c5b04814280b231f88bc333
https://github.com/inveniosoftware/invenio-pidrelations/blob/a49f3725cf595b663c5b04814280b231f88bc333/invenio_pidrelations/serializers/utils.py#L47-L54
train
Dump a specific relation to a data dict.
Kortemme-Lab/klab
klab/cluster_template/template-2.py
roundTime
def roundTime(dt=None, roundTo=1): """Round a datetime object to any time period (in seconds) dt : datetime.datetime object, default now. roundTo : Closest number of seconds to round to, default 1 second. Author: Thierry Husson 2012 - Use it as you want but don't blame me. http://stackoverflow.com/q...
python
def roundTime(dt=None, roundTo=1): """Round a datetime object to any time period (in seconds) dt : datetime.datetime object, default now. roundTo : Closest number of seconds to round to, default 1 second. Author: Thierry Husson 2012 - Use it as you want but don't blame me. http://stackoverflow.com/q...
[ "def", "roundTime", "(", "dt", "=", "None", ",", "roundTo", "=", "1", ")", ":", "if", "dt", "==", "None", ":", "dt", "=", "datetime", ".", "now", "(", ")", "seconds", "=", "total_seconds", "(", "dt", "-", "dt", ".", "min", ")", "# // is a floor div...
Round a datetime object to any time period (in seconds) dt : datetime.datetime object, default now. roundTo : Closest number of seconds to round to, default 1 second. Author: Thierry Husson 2012 - Use it as you want but don't blame me. http://stackoverflow.com/questions/3463930/how-to-round-the-minute-o...
[ "Round", "a", "datetime", "object", "to", "any", "time", "period", "(", "in", "seconds", ")", "dt", ":", "datetime", ".", "datetime", "object", "default", "now", ".", "roundTo", ":", "Closest", "number", "of", "seconds", "to", "round", "to", "default", "...
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/cluster_template/template-2.py#L92-L103
train
Round a datetime object to any time period in seconds.
mrtazz/InstapaperLibrary
instapaperlib/instapaperlib.py
Instapaper.add_item
def add_item(self, url, title=None, selection=None, jsonp=None, redirect=None, response_info=False): """ Method to add a new item to a instapaper account Parameters: url -> URL to add title -> optional title for the URL Returns: (status as int, s...
python
def add_item(self, url, title=None, selection=None, jsonp=None, redirect=None, response_info=False): """ Method to add a new item to a instapaper account Parameters: url -> URL to add title -> optional title for the URL Returns: (status as int, s...
[ "def", "add_item", "(", "self", ",", "url", ",", "title", "=", "None", ",", "selection", "=", "None", ",", "jsonp", "=", "None", ",", "redirect", "=", "None", ",", "response_info", "=", "False", ")", ":", "parameters", "=", "{", "'username'", ":", "s...
Method to add a new item to a instapaper account Parameters: url -> URL to add title -> optional title for the URL Returns: (status as int, status error message)
[ "Method", "to", "add", "a", "new", "item", "to", "a", "instapaper", "account" ]
bf273c02b468e523994d46def07f70902f596676
https://github.com/mrtazz/InstapaperLibrary/blob/bf273c02b468e523994d46def07f70902f596676/instapaperlib/instapaperlib.py#L75-L110
train
Method to add a new item to an instapaper account
mrtazz/InstapaperLibrary
instapaperlib/instapaperlib.py
Instapaper.auth
def auth(self, user=None, password=None, jsonp=None): """ authenticate with the instapaper.com service Parameters: user -> username password -> password Returns: (status as int, status error message) """ if not user: user = self.user ...
python
def auth(self, user=None, password=None, jsonp=None): """ authenticate with the instapaper.com service Parameters: user -> username password -> password Returns: (status as int, status error message) """ if not user: user = self.user ...
[ "def", "auth", "(", "self", ",", "user", "=", "None", ",", "password", "=", "None", ",", "jsonp", "=", "None", ")", ":", "if", "not", "user", ":", "user", "=", "self", ".", "user", "if", "not", "password", ":", "password", "=", "self", ".", "pass...
authenticate with the instapaper.com service Parameters: user -> username password -> password Returns: (status as int, status error message)
[ "authenticate", "with", "the", "instapaper", ".", "com", "service" ]
bf273c02b468e523994d46def07f70902f596676
https://github.com/mrtazz/InstapaperLibrary/blob/bf273c02b468e523994d46def07f70902f596676/instapaperlib/instapaperlib.py#L112-L133
train
authenticate with the instapaper. com service
mrtazz/InstapaperLibrary
instapaperlib/instapaperlib.py
Instapaper._query
def _query(self, url=None, params=""): """ method to query a URL with the given parameters Parameters: url -> URL to query params -> dictionary with parameter values Returns: HTTP response code, headers If an exception occurred, head...
python
def _query(self, url=None, params=""): """ method to query a URL with the given parameters Parameters: url -> URL to query params -> dictionary with parameter values Returns: HTTP response code, headers If an exception occurred, head...
[ "def", "_query", "(", "self", ",", "url", "=", "None", ",", "params", "=", "\"\"", ")", ":", "if", "url", "is", "None", ":", "raise", "NoUrlError", "(", "\"No URL was provided.\"", ")", "# return values", "headers", "=", "{", "'location'", ":", "None", "...
method to query a URL with the given parameters Parameters: url -> URL to query params -> dictionary with parameter values Returns: HTTP response code, headers If an exception occurred, headers fields are None
[ "method", "to", "query", "a", "URL", "with", "the", "given", "parameters" ]
bf273c02b468e523994d46def07f70902f596676
https://github.com/mrtazz/InstapaperLibrary/blob/bf273c02b468e523994d46def07f70902f596676/instapaperlib/instapaperlib.py#L135-L176
train
method to query a URL with the given parameters
mardix/Mocha
mocha/decorators.py
cors
def cors(*args, **kwargs): """ A wrapper around flask-cors cross_origin, to also act on classes **An extra note about cors, a response must be available before the cors is applied. Dynamic return is applied after the fact, so use the decorators, json, xml, or return self.render() for txt/html i...
python
def cors(*args, **kwargs): """ A wrapper around flask-cors cross_origin, to also act on classes **An extra note about cors, a response must be available before the cors is applied. Dynamic return is applied after the fact, so use the decorators, json, xml, or return self.render() for txt/html i...
[ "def", "cors", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "def", "decorator", "(", "fn", ")", ":", "cors_fn", "=", "flask_cors", ".", "cross_origin", "(", "automatic_options", "=", "False", ",", "*", "args", ",", "*", "*", "kwargs", ")", ...
A wrapper around flask-cors cross_origin, to also act on classes **An extra note about cors, a response must be available before the cors is applied. Dynamic return is applied after the fact, so use the decorators, json, xml, or return self.render() for txt/html ie: @cors() class Index(Mocha): ...
[ "A", "wrapper", "around", "flask", "-", "cors", "cross_origin", "to", "also", "act", "on", "classes" ]
bce481cb31a0972061dd99bc548701411dcb9de3
https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/decorators.py#L42-L78
train
A decorator around flask - cors cross_origin to act on classes
mardix/Mocha
mocha/decorators.py
headers
def headers(params={}): """This decorator adds the headers passed in to the response http://flask.pocoo.org/snippets/100/ """ def decorator(f): if inspect.isclass(f): h = headers(params) apply_function_to_members(f, h) return f @functools.wraps(f) ...
python
def headers(params={}): """This decorator adds the headers passed in to the response http://flask.pocoo.org/snippets/100/ """ def decorator(f): if inspect.isclass(f): h = headers(params) apply_function_to_members(f, h) return f @functools.wraps(f) ...
[ "def", "headers", "(", "params", "=", "{", "}", ")", ":", "def", "decorator", "(", "f", ")", ":", "if", "inspect", ".", "isclass", "(", "f", ")", ":", "h", "=", "headers", "(", "params", ")", "apply_function_to_members", "(", "f", ",", "h", ")", ...
This decorator adds the headers passed in to the response http://flask.pocoo.org/snippets/100/
[ "This", "decorator", "adds", "the", "headers", "passed", "in", "to", "the", "response", "http", ":", "//", "flask", ".", "pocoo", ".", "org", "/", "snippets", "/", "100", "/" ]
bce481cb31a0972061dd99bc548701411dcb9de3
https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/decorators.py#L81-L100
train
This decorator adds the headers passed in to the response http://www. pocoo. org / snippets / 100.
mardix/Mocha
mocha/decorators.py
emit_signal
def emit_signal(sender=None, namespace=None): """ @emit_signal A decorator to mark a method or function as a signal emitter It will turn the function into a decorator that can be used to receive signal with: $fn_name.pre.connect, $fn_name.post.connect *pre will execute before running the funct...
python
def emit_signal(sender=None, namespace=None): """ @emit_signal A decorator to mark a method or function as a signal emitter It will turn the function into a decorator that can be used to receive signal with: $fn_name.pre.connect, $fn_name.post.connect *pre will execute before running the funct...
[ "def", "emit_signal", "(", "sender", "=", "None", ",", "namespace", "=", "None", ")", ":", "if", "not", "namespace", ":", "namespace", "=", "__signals_namespace", "def", "decorator", "(", "fn", ")", ":", "fname", "=", "sender", "if", "not", "fname", ":",...
@emit_signal A decorator to mark a method or function as a signal emitter It will turn the function into a decorator that can be used to receive signal with: $fn_name.pre.connect, $fn_name.post.connect *pre will execute before running the function *post will run after running the function ...
[ "@emit_signal", "A", "decorator", "to", "mark", "a", "method", "or", "function", "as", "a", "signal", "emitter", "It", "will", "turn", "the", "function", "into", "a", "decorator", "that", "can", "be", "used", "to", "receive", "signal", "with", ":", "$fn_na...
bce481cb31a0972061dd99bc548701411dcb9de3
https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/decorators.py#L171-L230
train
A function decorator that can be used to mark a method or function as a signal emitter
Kortemme-Lab/klab
klab/bio/clustalo.py
SequenceAligner.add_sequence
def add_sequence(self, sequence_id, sequence, ignore_bad_chains = False): '''If ignore_bad_chains is True then any chains containing all Xs as the sequence will be silently skipped. The default behavior is to raise a MalformedSequenceException in this case.''' # This is a sanity check. Clust...
python
def add_sequence(self, sequence_id, sequence, ignore_bad_chains = False): '''If ignore_bad_chains is True then any chains containing all Xs as the sequence will be silently skipped. The default behavior is to raise a MalformedSequenceException in this case.''' # This is a sanity check. Clust...
[ "def", "add_sequence", "(", "self", ",", "sequence_id", ",", "sequence", ",", "ignore_bad_chains", "=", "False", ")", ":", "# This is a sanity check. ClustalO allows ':' in the chain ID but ClustalW replaces ':' with '_' which breaks our parsing", "# All callers to add_sequence now nee...
If ignore_bad_chains is True then any chains containing all Xs as the sequence will be silently skipped. The default behavior is to raise a MalformedSequenceException in this case.
[ "If", "ignore_bad_chains", "is", "True", "then", "any", "chains", "containing", "all", "Xs", "as", "the", "sequence", "will", "be", "silently", "skipped", ".", "The", "default", "behavior", "is", "to", "raise", "a", "MalformedSequenceException", "in", "this", ...
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/clustalo.py#L143-L159
train
Add a sequence to the list of records.
Kortemme-Lab/klab
klab/bio/clustalo.py
SequenceAligner.get_residue_mapping
def get_residue_mapping(self): '''Returns a mapping between the sequences ONLY IF there are exactly two. This restriction makes the code much simpler.''' if len(self.sequence_ids) == 2: if not self.alignment_output: self.align() assert(self.alignment_output) ...
python
def get_residue_mapping(self): '''Returns a mapping between the sequences ONLY IF there are exactly two. This restriction makes the code much simpler.''' if len(self.sequence_ids) == 2: if not self.alignment_output: self.align() assert(self.alignment_output) ...
[ "def", "get_residue_mapping", "(", "self", ")", ":", "if", "len", "(", "self", ".", "sequence_ids", ")", "==", "2", ":", "if", "not", "self", ".", "alignment_output", ":", "self", ".", "align", "(", ")", "assert", "(", "self", ".", "alignment_output", ...
Returns a mapping between the sequences ONLY IF there are exactly two. This restriction makes the code much simpler.
[ "Returns", "a", "mapping", "between", "the", "sequences", "ONLY", "IF", "there", "are", "exactly", "two", ".", "This", "restriction", "makes", "the", "code", "much", "simpler", "." ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/clustalo.py#L224-L232
train
Returns a mapping between the sequences ONLY IF there are exactly two. This restriction makes the code much simpler.
Kortemme-Lab/klab
klab/bio/clustalo.py
SequenceAligner._get_alignment_lines
def _get_alignment_lines(self): ''' This function parses the Clustal Omega alignment output and returns the aligned sequences in a dict: sequence_id -> sequence_string. The special key -1 is reserved for the match line (e.g. ' .:******* *').''' # Strip the boilerplate lines lines = ...
python
def _get_alignment_lines(self): ''' This function parses the Clustal Omega alignment output and returns the aligned sequences in a dict: sequence_id -> sequence_string. The special key -1 is reserved for the match line (e.g. ' .:******* *').''' # Strip the boilerplate lines lines = ...
[ "def", "_get_alignment_lines", "(", "self", ")", ":", "# Strip the boilerplate lines", "lines", "=", "self", ".", "alignment_output", ".", "split", "(", "\"\\n\"", ")", "assert", "(", "lines", "[", "0", "]", ".", "startswith", "(", "'CLUSTAL'", ")", ")", "li...
This function parses the Clustal Omega alignment output and returns the aligned sequences in a dict: sequence_id -> sequence_string. The special key -1 is reserved for the match line (e.g. ' .:******* *').
[ "This", "function", "parses", "the", "Clustal", "Omega", "alignment", "output", "and", "returns", "the", "aligned", "sequences", "in", "a", "dict", ":", "sequence_id", "-", ">", "sequence_string", ".", "The", "special", "key", "-", "1", "is", "reserved", "fo...
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/clustalo.py#L330-L395
train
This function parses the alignment output and returns the aligned sequences in a dict. The keys are the sequence IDs and the values are the sequence strings. The values are the sequences in the dictionary. The keys are the sequence IDs and the values are the sequences in the dictionary. The values are the sequences in ...
Kortemme-Lab/klab
klab/bio/clustalo.py
PDBUniParcSequenceAligner.realign
def realign(self, cut_off, chains_to_skip = set()): ''' Alter the cut-off and run alignment again. This is much quicker than creating a new PDBUniParcSequenceAligner object as the UniParcEntry creation etc. in the constructor does not need to be repeated. The chains_to_skip argument (a ...
python
def realign(self, cut_off, chains_to_skip = set()): ''' Alter the cut-off and run alignment again. This is much quicker than creating a new PDBUniParcSequenceAligner object as the UniParcEntry creation etc. in the constructor does not need to be repeated. The chains_to_skip argument (a ...
[ "def", "realign", "(", "self", ",", "cut_off", ",", "chains_to_skip", "=", "set", "(", ")", ")", ":", "if", "cut_off", "!=", "self", ".", "cut_off", ":", "self", ".", "cut_off", "=", "cut_off", "# Wipe any existing information for chains not in chains_to_skip", ...
Alter the cut-off and run alignment again. This is much quicker than creating a new PDBUniParcSequenceAligner object as the UniParcEntry creation etc. in the constructor does not need to be repeated. The chains_to_skip argument (a Set) allows us to skip chains that were already matched which sp...
[ "Alter", "the", "cut", "-", "off", "and", "run", "alignment", "again", ".", "This", "is", "much", "quicker", "than", "creating", "a", "new", "PDBUniParcSequenceAligner", "object", "as", "the", "UniParcEntry", "creation", "etc", ".", "in", "the", "constructor",...
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/clustalo.py#L527-L550
train
This method will realigns the sequence alignment for the specified set of chains.
Kortemme-Lab/klab
klab/bio/clustalo.py
PDBUniParcSequenceAligner._determine_representative_chains
def _determine_representative_chains(self): ''' Quotient the chains to get equivalence classes of chains. These will be used for the actual mapping.''' # todo: This logic should be moved into the FASTA class or a more general module (maybe a fast exists which uses a C/C++ library?) but at present it is ...
python
def _determine_representative_chains(self): ''' Quotient the chains to get equivalence classes of chains. These will be used for the actual mapping.''' # todo: This logic should be moved into the FASTA class or a more general module (maybe a fast exists which uses a C/C++ library?) but at present it is ...
[ "def", "_determine_representative_chains", "(", "self", ")", ":", "# todo: This logic should be moved into the FASTA class or a more general module (maybe a fast exists which uses a C/C++ library?) but at present it is easier to write here since we do not need to worry about other PDB IDs.", "equivale...
Quotient the chains to get equivalence classes of chains. These will be used for the actual mapping.
[ "Quotient", "the", "chains", "to", "get", "equivalence", "classes", "of", "chains", ".", "These", "will", "be", "used", "for", "the", "actual", "mapping", "." ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/clustalo.py#L569-L597
train
Quotient the chains to get equivalence classes of chains. These will be used for the actual mapping.
Kortemme-Lab/klab
klab/bio/clustalo.py
PDBUniParcSequenceAligner._get_uniparc_sequences_through_uniprot_ACs
def _get_uniparc_sequences_through_uniprot_ACs(self, mapping_pdb_id, uniprot_ACs, cache_dir): '''Get the UniParc sequences associated with the UniProt accession number.''' # Map the UniProt ACs to the UniParc IDs m = uniprot_map('ACC', 'UPARC', uniprot_ACs, cache_dir = cache_dir) UniPar...
python
def _get_uniparc_sequences_through_uniprot_ACs(self, mapping_pdb_id, uniprot_ACs, cache_dir): '''Get the UniParc sequences associated with the UniProt accession number.''' # Map the UniProt ACs to the UniParc IDs m = uniprot_map('ACC', 'UPARC', uniprot_ACs, cache_dir = cache_dir) UniPar...
[ "def", "_get_uniparc_sequences_through_uniprot_ACs", "(", "self", ",", "mapping_pdb_id", ",", "uniprot_ACs", ",", "cache_dir", ")", ":", "# Map the UniProt ACs to the UniParc IDs", "m", "=", "uniprot_map", "(", "'ACC'", ",", "'UPARC'", ",", "uniprot_ACs", ",", "cache_di...
Get the UniParc sequences associated with the UniProt accession number.
[ "Get", "the", "UniParc", "sequences", "associated", "with", "the", "UniProt", "accession", "number", "." ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/clustalo.py#L664-L679
train
Get the UniParc sequences associated with the UniProt accession number.
Kortemme-Lab/klab
klab/bio/clustalo.py
PDBUniParcSequenceAligner._align_with_substrings
def _align_with_substrings(self, chains_to_skip = set()): '''Simple substring-based matching''' for c in self.representative_chains: # Skip specified chains if c not in chains_to_skip: #colortext.pcyan(c) #colortext.warning(self.fasta[c]) ...
python
def _align_with_substrings(self, chains_to_skip = set()): '''Simple substring-based matching''' for c in self.representative_chains: # Skip specified chains if c not in chains_to_skip: #colortext.pcyan(c) #colortext.warning(self.fasta[c]) ...
[ "def", "_align_with_substrings", "(", "self", ",", "chains_to_skip", "=", "set", "(", ")", ")", ":", "for", "c", "in", "self", ".", "representative_chains", ":", "# Skip specified chains", "if", "c", "not", "in", "chains_to_skip", ":", "#colortext.pcyan(c)", "#c...
Simple substring-based matching
[ "Simple", "substring", "-", "based", "matching" ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/clustalo.py#L737-L791
train
Aligns the sequences in the representative chains with the substrings of the sequences in the representative chains.
Kortemme-Lab/klab
klab/bio/clustalo.py
PDBUniParcSequenceAligner._get_residue_mapping
def _get_residue_mapping(self, chains_to_skip = set()): '''Creates a mapping between the residues of the chains and the associated UniParc entries.''' for c in self.representative_chains: # Skip specified chains if c not in chains_to_skip: if self.alignment.get(c)...
python
def _get_residue_mapping(self, chains_to_skip = set()): '''Creates a mapping between the residues of the chains and the associated UniParc entries.''' for c in self.representative_chains: # Skip specified chains if c not in chains_to_skip: if self.alignment.get(c)...
[ "def", "_get_residue_mapping", "(", "self", ",", "chains_to_skip", "=", "set", "(", ")", ")", ":", "for", "c", "in", "self", ".", "representative_chains", ":", "# Skip specified chains", "if", "c", "not", "in", "chains_to_skip", ":", "if", "self", ".", "alig...
Creates a mapping between the residues of the chains and the associated UniParc entries.
[ "Creates", "a", "mapping", "between", "the", "residues", "of", "the", "chains", "and", "the", "associated", "UniParc", "entries", "." ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/clustalo.py#L833-L860
train
Creates a mapping between the residues of the chains and the associated UniParc entries.
Kortemme-Lab/klab
klab/bio/clustalo.py
PDBChainSequenceAligner.align
def align(self, alignment_tool = 'clustalw', gap_opening_penalty = 0.2, ignore_bad_chains = False): '''If ignore_bad_chains is True then any chains containing all Xs as the sequence will be silently skipped. The default behavior is to raise a MalformedSequenceException in this case.''' if len...
python
def align(self, alignment_tool = 'clustalw', gap_opening_penalty = 0.2, ignore_bad_chains = False): '''If ignore_bad_chains is True then any chains containing all Xs as the sequence will be silently skipped. The default behavior is to raise a MalformedSequenceException in this case.''' if len...
[ "def", "align", "(", "self", ",", "alignment_tool", "=", "'clustalw'", ",", "gap_opening_penalty", "=", "0.2", ",", "ignore_bad_chains", "=", "False", ")", ":", "if", "len", "(", "self", ".", "pdb_chains", ")", ">", "1", ":", "sa", "=", "SequenceAligner", ...
If ignore_bad_chains is True then any chains containing all Xs as the sequence will be silently skipped. The default behavior is to raise a MalformedSequenceException in this case.
[ "If", "ignore_bad_chains", "is", "True", "then", "any", "chains", "containing", "all", "Xs", "as", "the", "sequence", "will", "be", "silently", "skipped", ".", "The", "default", "behavior", "is", "to", "raise", "a", "MalformedSequenceException", "in", "this", ...
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/clustalo.py#L898-L908
train
Align the sequences in the PDB file.
Kortemme-Lab/klab
klab/bio/clustalo.py
SIFTSChainMutatorSequenceAligner.get_mutations
def get_mutations(self, pdb_id_1, pdb_id_2, alignment_tool = 'clustalw', gap_opening_penalty = 0.2): '''Returns a mapping chain_of_pdb_1 -> List[PDBMutationPair] representing the mutations needed to transform each chain of pdb_1 into the respective chains of pdb_2. This function also sets self.seqres...
python
def get_mutations(self, pdb_id_1, pdb_id_2, alignment_tool = 'clustalw', gap_opening_penalty = 0.2): '''Returns a mapping chain_of_pdb_1 -> List[PDBMutationPair] representing the mutations needed to transform each chain of pdb_1 into the respective chains of pdb_2. This function also sets self.seqres...
[ "def", "get_mutations", "(", "self", ",", "pdb_id_1", ",", "pdb_id_2", ",", "alignment_tool", "=", "'clustalw'", ",", "gap_opening_penalty", "=", "0.2", ")", ":", "# Set up the objects", "p1", "=", "self", ".", "add_pdb", "(", "pdb_id_1", ")", "p2", "=", "se...
Returns a mapping chain_of_pdb_1 -> List[PDBMutationPair] representing the mutations needed to transform each chain of pdb_1 into the respective chains of pdb_2. This function also sets self.seqres_sequence_maps, a mapping Tuple(pdb_id_1, chain ID in pdb_id_1) -> Tuple(pdb_id_2, chain ID in pdb_id_2) -> a Se...
[ "Returns", "a", "mapping", "chain_of_pdb_1", "-", ">", "List", "[", "PDBMutationPair", "]", "representing", "the", "mutations", "needed", "to", "transform", "each", "chain", "of", "pdb_1", "into", "the", "respective", "chains", "of", "pdb_2", ".", "This", "fun...
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/clustalo.py#L1204-L1278
train
Returns a mapping between chains of pdb_id_1 and pdb_id_2 and the set of mutations needed to transform each chain of pdb_id_1 into the respective chains of pdb_id_2.
Kortemme-Lab/klab
klab/bio/clustalo.py
SIFTSChainMutatorSequenceAligner.get_corresponding_chains
def get_corresponding_chains(self, from_pdb_id, from_chain_id, to_pdb_id): '''Should be called after get_mutations.''' chains = self.chain_map.get(from_pdb_id, {}).get(from_chain_id, {}).get(to_pdb_id, []) return sorted(chains)
python
def get_corresponding_chains(self, from_pdb_id, from_chain_id, to_pdb_id): '''Should be called after get_mutations.''' chains = self.chain_map.get(from_pdb_id, {}).get(from_chain_id, {}).get(to_pdb_id, []) return sorted(chains)
[ "def", "get_corresponding_chains", "(", "self", ",", "from_pdb_id", ",", "from_chain_id", ",", "to_pdb_id", ")", ":", "chains", "=", "self", ".", "chain_map", ".", "get", "(", "from_pdb_id", ",", "{", "}", ")", ".", "get", "(", "from_chain_id", ",", "{", ...
Should be called after get_mutations.
[ "Should", "be", "called", "after", "get_mutations", "." ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/clustalo.py#L1281-L1284
train
Should be called after get_mutations.
Kortemme-Lab/klab
klab/bio/fragments/post_processing.py
is_valid_fragment
def is_valid_fragment(original_residue_id, mapping, frag_sizes): '''A function which determines whether a residue ID (original_residue_id) should be included in the nmer files generated by the mapping.''' for r in mapping['segment_list']: r = sorted(r) if r[0] - frag_sizes + 1 <= original_residu...
python
def is_valid_fragment(original_residue_id, mapping, frag_sizes): '''A function which determines whether a residue ID (original_residue_id) should be included in the nmer files generated by the mapping.''' for r in mapping['segment_list']: r = sorted(r) if r[0] - frag_sizes + 1 <= original_residu...
[ "def", "is_valid_fragment", "(", "original_residue_id", ",", "mapping", ",", "frag_sizes", ")", ":", "for", "r", "in", "mapping", "[", "'segment_list'", "]", ":", "r", "=", "sorted", "(", "r", ")", "if", "r", "[", "0", "]", "-", "frag_sizes", "+", "1",...
A function which determines whether a residue ID (original_residue_id) should be included in the nmer files generated by the mapping.
[ "A", "function", "which", "determines", "whether", "a", "residue", "ID", "(", "original_residue_id", ")", "should", "be", "included", "in", "the", "nmer", "files", "generated", "by", "the", "mapping", "." ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/fragments/post_processing.py#L29-L35
train
A function which determines whether a residue ID should be included in the nmer files generated by the mapping.
Kortemme-Lab/klab
klab/biblio/ris.py
RISEntry.to_dict
def to_dict(self): '''A representation of that publication data that matches the schema we use in our databases.''' author_list = [] for author in self.authors: author_list.append( dict( AuthorOrder = author['AuthorOrder'] + 1, # we should always ...
python
def to_dict(self): '''A representation of that publication data that matches the schema we use in our databases.''' author_list = [] for author in self.authors: author_list.append( dict( AuthorOrder = author['AuthorOrder'] + 1, # we should always ...
[ "def", "to_dict", "(", "self", ")", ":", "author_list", "=", "[", "]", "for", "author", "in", "self", ".", "authors", ":", "author_list", ".", "append", "(", "dict", "(", "AuthorOrder", "=", "author", "[", "'AuthorOrder'", "]", "+", "1", ",", "# we sho...
A representation of that publication data that matches the schema we use in our databases.
[ "A", "representation", "of", "that", "publication", "data", "that", "matches", "the", "schema", "we", "use", "in", "our", "databases", "." ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/biblio/ris.py#L442-L477
train
A representation of that publication data that matches the schema we use in our databases.
Kortemme-Lab/klab
klab/rosetta/map_pdb_residues.py
get_pdb_contents_to_pose_residue_map
def get_pdb_contents_to_pose_residue_map(pdb_file_contents, rosetta_scripts_path, rosetta_database_path = None, pdb_id = None, extra_flags = ''): '''Takes a string containing a PDB file, the RosettaScripts executable, and the Rosetta database and then uses the features database to map PDB residue IDs to pose residu...
python
def get_pdb_contents_to_pose_residue_map(pdb_file_contents, rosetta_scripts_path, rosetta_database_path = None, pdb_id = None, extra_flags = ''): '''Takes a string containing a PDB file, the RosettaScripts executable, and the Rosetta database and then uses the features database to map PDB residue IDs to pose residu...
[ "def", "get_pdb_contents_to_pose_residue_map", "(", "pdb_file_contents", ",", "rosetta_scripts_path", ",", "rosetta_database_path", "=", "None", ",", "pdb_id", "=", "None", ",", "extra_flags", "=", "''", ")", ":", "filename", "=", "write_temp_file", "(", "\"/tmp\"", ...
Takes a string containing a PDB file, the RosettaScripts executable, and the Rosetta database and then uses the features database to map PDB residue IDs to pose residue IDs. On success, (True, the residue mapping) is returned. On failure, (False, a list of errors) is returned. Note: extra_flags should ty...
[ "Takes", "a", "string", "containing", "a", "PDB", "file", "the", "RosettaScripts", "executable", "and", "the", "Rosetta", "database", "and", "then", "uses", "the", "features", "database", "to", "map", "PDB", "residue", "IDs", "to", "pose", "residue", "IDs", ...
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/rosetta/map_pdb_residues.py#L62-L71
train
Takes a string containing a PDB file the RosettaScripts executable and the Rosetta database and uses the features database to map PDB residue IDs to Pose residue IDs.
Kortemme-Lab/klab
klab/rosetta/map_pdb_residues.py
get_pdb_to_pose_residue_map
def get_pdb_to_pose_residue_map(pdb_path, rosetta_scripts_path, rosetta_database_path = None, pdb_id = None, extra_flags = ''): '''Takes a path to a PDB file, the RosettaScripts executable, and the Rosetta database and then uses the features database to map PDB residue IDs to pose residue IDs. On success, (T...
python
def get_pdb_to_pose_residue_map(pdb_path, rosetta_scripts_path, rosetta_database_path = None, pdb_id = None, extra_flags = ''): '''Takes a path to a PDB file, the RosettaScripts executable, and the Rosetta database and then uses the features database to map PDB residue IDs to pose residue IDs. On success, (T...
[ "def", "get_pdb_to_pose_residue_map", "(", "pdb_path", ",", "rosetta_scripts_path", ",", "rosetta_database_path", "=", "None", ",", "pdb_id", "=", "None", ",", "extra_flags", "=", "''", ")", ":", "errors", "=", "[", "]", "exit_code", "=", "0", "F", ",", "scr...
Takes a path to a PDB file, the RosettaScripts executable, and the Rosetta database and then uses the features database to map PDB residue IDs to pose residue IDs. On success, (True, the residue mapping) is returned. On failure, (False, a list of errors) is returned. The mapping maps residue IDs to a dic...
[ "Takes", "a", "path", "to", "a", "PDB", "file", "the", "RosettaScripts", "executable", "and", "the", "Rosetta", "database", "and", "then", "uses", "the", "features", "database", "to", "map", "PDB", "residue", "IDs", "to", "pose", "residue", "IDs", ".", "On...
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/rosetta/map_pdb_residues.py#L74-L126
train
Takes a path to a PDB file the RosettaScripts executable and the Rosetta database and uses the features database to map residue IDs to Pose IDs.
Kortemme-Lab/klab
klab/rosetta/map_pdb_residues.py
get_mapping_from_db3_file
def get_mapping_from_db3_file( db_path ): ''' Does the work of reading the Rosetta SQLite3 .db3 file to retrieve the mapping ''' import sqlite3 # should be moved to the top but we do this here for CentOS 5 support conn = sqlite3.connect(db_path) results = conn.cursor().execute(''' SELECT ch...
python
def get_mapping_from_db3_file( db_path ): ''' Does the work of reading the Rosetta SQLite3 .db3 file to retrieve the mapping ''' import sqlite3 # should be moved to the top but we do this here for CentOS 5 support conn = sqlite3.connect(db_path) results = conn.cursor().execute(''' SELECT ch...
[ "def", "get_mapping_from_db3_file", "(", "db_path", ")", ":", "import", "sqlite3", "# should be moved to the top but we do this here for CentOS 5 support", "conn", "=", "sqlite3", ".", "connect", "(", "db_path", ")", "results", "=", "conn", ".", "cursor", "(", ")", "....
Does the work of reading the Rosetta SQLite3 .db3 file to retrieve the mapping
[ "Does", "the", "work", "of", "reading", "the", "Rosetta", "SQLite3", ".", "db3", "file", "to", "retrieve", "the", "mapping" ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/rosetta/map_pdb_residues.py#L128-L152
train
Reads the Rosetta SQLite3. db3 file and returns the mapping from the PDB residues to the Rosetta residues
Kortemme-Lab/klab
klab/rosetta/map_pdb_residues.py
strip_pdb
def strip_pdb(pdb_path, chains = [], strip_hetatms = False): '''Takes a PDB file and strips all lines except ATOM and HETATM records. If chains is specified, only those chains are kept. If strip_hetatms is True then HETATM lines are also stripped. Returns (True, a path to the stripped PDB file) on success an...
python
def strip_pdb(pdb_path, chains = [], strip_hetatms = False): '''Takes a PDB file and strips all lines except ATOM and HETATM records. If chains is specified, only those chains are kept. If strip_hetatms is True then HETATM lines are also stripped. Returns (True, a path to the stripped PDB file) on success an...
[ "def", "strip_pdb", "(", "pdb_path", ",", "chains", "=", "[", "]", ",", "strip_hetatms", "=", "False", ")", ":", "chains", "=", "set", "(", "chains", ")", "contents", "=", "open", "(", "pdb_path", ")", ".", "read", "(", ")", ".", "split", "(", "\"\...
Takes a PDB file and strips all lines except ATOM and HETATM records. If chains is specified, only those chains are kept. If strip_hetatms is True then HETATM lines are also stripped. Returns (True, a path to the stripped PDB file) on success and (False, a list of errors) on failure.
[ "Takes", "a", "PDB", "file", "and", "strips", "all", "lines", "except", "ATOM", "and", "HETATM", "records", ".", "If", "chains", "is", "specified", "only", "those", "chains", "are", "kept", ".", "If", "strip_hetatms", "is", "True", "then", "HETATM", "lines...
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/rosetta/map_pdb_residues.py#L154-L177
train
Takes a PDB file and strips all lines except ATOM and HETATM records.
Kortemme-Lab/klab
klab/rosetta/map_pdb_residues.py
get_stripped_pdb_to_pose_residue_map
def get_stripped_pdb_to_pose_residue_map(input_pdb_path, rosetta_scripts_path, rosetta_database_path, chains = [], strip_hetatms = False): '''Takes a path to an input PDB file, the path to the RosettaScripts executable and Rosetta database, an optional list of chains to strip the PDB down to, and an optional flag s...
python
def get_stripped_pdb_to_pose_residue_map(input_pdb_path, rosetta_scripts_path, rosetta_database_path, chains = [], strip_hetatms = False): '''Takes a path to an input PDB file, the path to the RosettaScripts executable and Rosetta database, an optional list of chains to strip the PDB down to, and an optional flag s...
[ "def", "get_stripped_pdb_to_pose_residue_map", "(", "input_pdb_path", ",", "rosetta_scripts_path", ",", "rosetta_database_path", ",", "chains", "=", "[", "]", ",", "strip_hetatms", "=", "False", ")", ":", "success", ",", "result", "=", "strip_pdb", "(", "input_pdb_p...
Takes a path to an input PDB file, the path to the RosettaScripts executable and Rosetta database, an optional list of chains to strip the PDB down to, and an optional flag specifying whether HETATM lines should be stripped from the PDB. On success, a pair (True, mapping between PDB and pose residues) is returne...
[ "Takes", "a", "path", "to", "an", "input", "PDB", "file", "the", "path", "to", "the", "RosettaScripts", "executable", "and", "Rosetta", "database", "an", "optional", "list", "of", "chains", "to", "strip", "the", "PDB", "down", "to", "and", "an", "optional"...
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/rosetta/map_pdb_residues.py#L179-L191
train
Takes a path to an input PDB file the path to the RosettaScripts executable and Rosetta database and returns a mapping between the PDB file and the pose residue.
Kortemme-Lab/klab
klab/google/gcalendar.py
BasicEvent.create_lab_meeting
def create_lab_meeting(self, event_type, presenters, foodie = None, locked = False): 'Presenters can be a comma-separated list of presenters.' e = self.initialize_tagged_copy() summary_texts = { 'Lab meeting' : 'Kortemme Lab meeting', 'Kortemme/DeGrado joint meeting' : 'D...
python
def create_lab_meeting(self, event_type, presenters, foodie = None, locked = False): 'Presenters can be a comma-separated list of presenters.' e = self.initialize_tagged_copy() summary_texts = { 'Lab meeting' : 'Kortemme Lab meeting', 'Kortemme/DeGrado joint meeting' : 'D...
[ "def", "create_lab_meeting", "(", "self", ",", "event_type", ",", "presenters", ",", "foodie", "=", "None", ",", "locked", "=", "False", ")", ":", "e", "=", "self", ".", "initialize_tagged_copy", "(", ")", "summary_texts", "=", "{", "'Lab meeting'", ":", "...
Presenters can be a comma-separated list of presenters.
[ "Presenters", "can", "be", "a", "comma", "-", "separated", "list", "of", "presenters", "." ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/google/gcalendar.py#L69-L91
train
Presenters can be a comma - separated list of presenters.
Kortemme-Lab/klab
klab/google/gcalendar.py
BasicEvent.create_journal_club_meeting
def create_journal_club_meeting(self, presenters, food_vendor, paper = None): 'Presenters can be a comma-separated list of presenters.' e = self.initialize_tagged_copy() e['extendedProperties']['shared']['event_type'] = 'Journal club' e['extendedProperties']['shared']['Presenters'] = pre...
python
def create_journal_club_meeting(self, presenters, food_vendor, paper = None): 'Presenters can be a comma-separated list of presenters.' e = self.initialize_tagged_copy() e['extendedProperties']['shared']['event_type'] = 'Journal club' e['extendedProperties']['shared']['Presenters'] = pre...
[ "def", "create_journal_club_meeting", "(", "self", ",", "presenters", ",", "food_vendor", ",", "paper", "=", "None", ")", ":", "e", "=", "self", ".", "initialize_tagged_copy", "(", ")", "e", "[", "'extendedProperties'", "]", "[", "'shared'", "]", "[", "'even...
Presenters can be a comma-separated list of presenters.
[ "Presenters", "can", "be", "a", "comma", "-", "separated", "list", "of", "presenters", "." ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/google/gcalendar.py#L94-L109
train
Presenters can be a comma - separated list of presenters.
Kortemme-Lab/klab
klab/google/gcalendar.py
GoogleCalendar.get_upcoming_event_lists_for_the_remainder_of_the_month
def get_upcoming_event_lists_for_the_remainder_of_the_month(self, year = None, month = None): '''Return the set of events as triple of (today's events, events for the remainder of the week, events for the remainder of the month).''' events = [] if year == None and month == None: now...
python
def get_upcoming_event_lists_for_the_remainder_of_the_month(self, year = None, month = None): '''Return the set of events as triple of (today's events, events for the remainder of the week, events for the remainder of the month).''' events = [] if year == None and month == None: now...
[ "def", "get_upcoming_event_lists_for_the_remainder_of_the_month", "(", "self", ",", "year", "=", "None", ",", "month", "=", "None", ")", ":", "events", "=", "[", "]", "if", "year", "==", "None", "and", "month", "==", "None", ":", "now", "=", "datetime", "....
Return the set of events as triple of (today's events, events for the remainder of the week, events for the remainder of the month).
[ "Return", "the", "set", "of", "events", "as", "triple", "of", "(", "today", "s", "events", "events", "for", "the", "remainder", "of", "the", "week", "events", "for", "the", "remainder", "of", "the", "month", ")", "." ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/google/gcalendar.py#L236-L277
train
Return the set of events as triple of ( today s events for the remainder of the month.
Kortemme-Lab/klab
klab/google/gcalendar.py
GoogleCalendar.get_upcoming_events_within_the_current_week
def get_upcoming_events_within_the_current_week(self): '''Returns the events from the calendar for the next days_to_look_ahead days.''' now = datetime.now(tz=self.timezone) # timezone? start_time = datetime(year=now.year, month=now.month, day=now.day, hour=now.hour, minute=now.minute, second=now...
python
def get_upcoming_events_within_the_current_week(self): '''Returns the events from the calendar for the next days_to_look_ahead days.''' now = datetime.now(tz=self.timezone) # timezone? start_time = datetime(year=now.year, month=now.month, day=now.day, hour=now.hour, minute=now.minute, second=now...
[ "def", "get_upcoming_events_within_the_current_week", "(", "self", ")", ":", "now", "=", "datetime", ".", "now", "(", "tz", "=", "self", ".", "timezone", ")", "# timezone?", "start_time", "=", "datetime", "(", "year", "=", "now", ".", "year", ",", "month", ...
Returns the events from the calendar for the next days_to_look_ahead days.
[ "Returns", "the", "events", "from", "the", "calendar", "for", "the", "next", "days_to_look_ahead", "days", "." ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/google/gcalendar.py#L280-L289
train
Returns the events from the calendar for the next days_to_look_ahead days.
Kortemme-Lab/klab
klab/google/gcalendar.py
GoogleCalendar.get_upcoming_events
def get_upcoming_events(self, days_to_look_ahead): '''Returns the events from the calendar for the next days_to_look_ahead days.''' now = datetime.now(tz=self.timezone) # timezone? start_time = datetime(year=now.year, month=now.month, day=now.day, hour=now.hour, minute=now.minute, second=now.sec...
python
def get_upcoming_events(self, days_to_look_ahead): '''Returns the events from the calendar for the next days_to_look_ahead days.''' now = datetime.now(tz=self.timezone) # timezone? start_time = datetime(year=now.year, month=now.month, day=now.day, hour=now.hour, minute=now.minute, second=now.sec...
[ "def", "get_upcoming_events", "(", "self", ",", "days_to_look_ahead", ")", ":", "now", "=", "datetime", ".", "now", "(", "tz", "=", "self", ".", "timezone", ")", "# timezone?", "start_time", "=", "datetime", "(", "year", "=", "now", ".", "year", ",", "mo...
Returns the events from the calendar for the next days_to_look_ahead days.
[ "Returns", "the", "events", "from", "the", "calendar", "for", "the", "next", "days_to_look_ahead", "days", "." ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/google/gcalendar.py#L296-L303
train
Returns the events from the calendar for the next days_to_look_ahead days.
Kortemme-Lab/klab
klab/google/gcalendar.py
GoogleCalendar.get_events
def get_events(self, start_time, end_time, ignore_cancelled = True, get_recurring_events_as_instances = True, restrict_to_calendars = []): '''A wrapper for events().list. Returns the events from the calendar within the specified times. Some of the interesting fields are: description, end, htmlLi...
python
def get_events(self, start_time, end_time, ignore_cancelled = True, get_recurring_events_as_instances = True, restrict_to_calendars = []): '''A wrapper for events().list. Returns the events from the calendar within the specified times. Some of the interesting fields are: description, end, htmlLi...
[ "def", "get_events", "(", "self", ",", "start_time", ",", "end_time", ",", "ignore_cancelled", "=", "True", ",", "get_recurring_events_as_instances", "=", "True", ",", "restrict_to_calendars", "=", "[", "]", ")", ":", "es", "=", "[", "]", "calendar_ids", "=", ...
A wrapper for events().list. Returns the events from the calendar within the specified times. Some of the interesting fields are: description, end, htmlLink, location, organizer, start, summary Note: "Cancelled instances of recurring events (but not the underlying recurring event) will ...
[ "A", "wrapper", "for", "events", "()", ".", "list", ".", "Returns", "the", "events", "from", "the", "calendar", "within", "the", "specified", "times", ".", "Some", "of", "the", "interesting", "fields", "are", ":", "description", "end", "htmlLink", "location"...
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/google/gcalendar.py#L321-L362
train
A wrapper for events. list. Returns the events from the calendar within the specified times.
Kortemme-Lab/klab
klab/google/gcalendar.py
GoogleCalendar.get_recurring_events
def get_recurring_events(self, calendar_id, event_id, start_time, end_time, maxResults = None): '''A wrapper for events().instances. Returns the list of recurring events for the given calendar alias within the specified timeframe.''' es = [] page_token = None while True: even...
python
def get_recurring_events(self, calendar_id, event_id, start_time, end_time, maxResults = None): '''A wrapper for events().instances. Returns the list of recurring events for the given calendar alias within the specified timeframe.''' es = [] page_token = None while True: even...
[ "def", "get_recurring_events", "(", "self", ",", "calendar_id", ",", "event_id", ",", "start_time", ",", "end_time", ",", "maxResults", "=", "None", ")", ":", "es", "=", "[", "]", "page_token", "=", "None", "while", "True", ":", "events", "=", "self", "....
A wrapper for events().instances. Returns the list of recurring events for the given calendar alias within the specified timeframe.
[ "A", "wrapper", "for", "events", "()", ".", "instances", ".", "Returns", "the", "list", "of", "recurring", "events", "for", "the", "given", "calendar", "alias", "within", "the", "specified", "timeframe", "." ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/google/gcalendar.py#L365-L386
train
A wrapper for events. instances. Returns the list of recurring events for the given calendar alias within the specified timeframe.
Kortemme-Lab/klab
klab/google/gcalendar.py
GoogleCalendar.add_company_quarter
def add_company_quarter(self, company_name, quarter_name, dt, calendar_id = 'notices'): '''Adds a company_name quarter event to the calendar. dt should be a date object. Returns True if the event was added.''' assert(calendar_id in self.configured_calendar_ids.keys()) calendarId = self.configur...
python
def add_company_quarter(self, company_name, quarter_name, dt, calendar_id = 'notices'): '''Adds a company_name quarter event to the calendar. dt should be a date object. Returns True if the event was added.''' assert(calendar_id in self.configured_calendar_ids.keys()) calendarId = self.configur...
[ "def", "add_company_quarter", "(", "self", ",", "company_name", ",", "quarter_name", ",", "dt", ",", "calendar_id", "=", "'notices'", ")", ":", "assert", "(", "calendar_id", "in", "self", ".", "configured_calendar_ids", ".", "keys", "(", ")", ")", "calendarId"...
Adds a company_name quarter event to the calendar. dt should be a date object. Returns True if the event was added.
[ "Adds", "a", "company_name", "quarter", "event", "to", "the", "calendar", ".", "dt", "should", "be", "a", "date", "object", ".", "Returns", "True", "if", "the", "event", "was", "added", "." ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/google/gcalendar.py#L393-L438
train
Adds a company_name quarter event to the calendar. dt should be a date object. Returns True if the event was added.
Kortemme-Lab/klab
klab/google/gcalendar.py
GoogleCalendar.add_holiday
def add_holiday(self, start_dt, holiday_name, end_dt = None, calendar_id = 'notices'): '''Adds a holiday event to the calendar. start_dt and end_dt (if supplied) should be date objects. Returns True if the event was added.''' assert(calendar_id in self.configured_calendar_ids.keys()) calendarId...
python
def add_holiday(self, start_dt, holiday_name, end_dt = None, calendar_id = 'notices'): '''Adds a holiday event to the calendar. start_dt and end_dt (if supplied) should be date objects. Returns True if the event was added.''' assert(calendar_id in self.configured_calendar_ids.keys()) calendarId...
[ "def", "add_holiday", "(", "self", ",", "start_dt", ",", "holiday_name", ",", "end_dt", "=", "None", ",", "calendar_id", "=", "'notices'", ")", ":", "assert", "(", "calendar_id", "in", "self", ".", "configured_calendar_ids", ".", "keys", "(", ")", ")", "ca...
Adds a holiday event to the calendar. start_dt and end_dt (if supplied) should be date objects. Returns True if the event was added.
[ "Adds", "a", "holiday", "event", "to", "the", "calendar", ".", "start_dt", "and", "end_dt", "(", "if", "supplied", ")", "should", "be", "date", "objects", ".", "Returns", "True", "if", "the", "event", "was", "added", "." ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/google/gcalendar.py#L441-L479
train
Adds a holiday event to the calendar. start_dt and end_dt should be date objects. Returns True if the event was added.
Kortemme-Lab/klab
klab/google/gcalendar.py
GoogleCalendar.remove_all_events
def remove_all_events(self, calendar_id): '''Removes all events from a calendar. WARNING: Be very careful using this.''' # todo: incomplete now = datetime.now(tz=self.timezone) # timezone? start_time = datetime(year=now.year - 1, month=now.month, day=now.day, hour=now.hour, minute=now.m...
python
def remove_all_events(self, calendar_id): '''Removes all events from a calendar. WARNING: Be very careful using this.''' # todo: incomplete now = datetime.now(tz=self.timezone) # timezone? start_time = datetime(year=now.year - 1, month=now.month, day=now.day, hour=now.hour, minute=now.m...
[ "def", "remove_all_events", "(", "self", ",", "calendar_id", ")", ":", "# todo: incomplete", "now", "=", "datetime", ".", "now", "(", "tz", "=", "self", ".", "timezone", ")", "# timezone?", "start_time", "=", "datetime", "(", "year", "=", "now", ".", "year...
Removes all events from a calendar. WARNING: Be very careful using this.
[ "Removes", "all", "events", "from", "a", "calendar", ".", "WARNING", ":", "Be", "very", "careful", "using", "this", "." ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/google/gcalendar.py#L482-L505
train
Removes all events from a calendar.
Kortemme-Lab/klab
klab/google/gcalendar.py
GoogleCalendar.tag_event
def tag_event(self, calendar_id, event_id, extendedProperties): '''Add extendedProperties to a meeting. Warning: extendedProperties must contain only shared and private dicts and their contents will overwrite anything in the event's extendedProperties i.e. we do *not* deep-merge the dicts. ''...
python
def tag_event(self, calendar_id, event_id, extendedProperties): '''Add extendedProperties to a meeting. Warning: extendedProperties must contain only shared and private dicts and their contents will overwrite anything in the event's extendedProperties i.e. we do *not* deep-merge the dicts. ''...
[ "def", "tag_event", "(", "self", ",", "calendar_id", ",", "event_id", ",", "extendedProperties", ")", ":", "event_body", "=", "self", ".", "service", ".", "events", "(", ")", ".", "get", "(", "calendarId", "=", "self", ".", "configured_calendar_ids", "[", ...
Add extendedProperties to a meeting. Warning: extendedProperties must contain only shared and private dicts and their contents will overwrite anything in the event's extendedProperties i.e. we do *not* deep-merge the dicts.
[ "Add", "extendedProperties", "to", "a", "meeting", ".", "Warning", ":", "extendedProperties", "must", "contain", "only", "shared", "and", "private", "dicts", "and", "their", "contents", "will", "overwrite", "anything", "in", "the", "event", "s", "extendedPropertie...
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/google/gcalendar.py#L511-L525
train
Add extendedProperties to a meeting.
uogbuji/versa
tools/py/driver/sqlite.py
connection.create_space
def create_space(self): '''Set up a new table space for the first time''' cur = self._conn.cursor() cur.executescript(SQL_MODEL) self._conn.commit() cur.close() return
python
def create_space(self): '''Set up a new table space for the first time''' cur = self._conn.cursor() cur.executescript(SQL_MODEL) self._conn.commit() cur.close() return
[ "def", "create_space", "(", "self", ")", ":", "cur", "=", "self", ".", "_conn", ".", "cursor", "(", ")", "cur", ".", "executescript", "(", "SQL_MODEL", ")", "self", ".", "_conn", ".", "commit", "(", ")", "cur", ".", "close", "(", ")", "return" ]
Set up a new table space for the first time
[ "Set", "up", "a", "new", "table", "space", "for", "the", "first", "time" ]
f092ffc7ed363a5b170890955168500f32de0dd5
https://github.com/uogbuji/versa/blob/f092ffc7ed363a5b170890955168500f32de0dd5/tools/py/driver/sqlite.py#L31-L37
train
Set up a new table space for the first time
uogbuji/versa
tools/py/driver/sqlite.py
connection.drop_space
def drop_space(self): '''Dismantle an existing table space''' cur = self._conn.cursor() cur.executescript(DROP_SQL_MODEL) self._conn.commit() cur.close() return
python
def drop_space(self): '''Dismantle an existing table space''' cur = self._conn.cursor() cur.executescript(DROP_SQL_MODEL) self._conn.commit() cur.close() return
[ "def", "drop_space", "(", "self", ")", ":", "cur", "=", "self", ".", "_conn", ".", "cursor", "(", ")", "cur", ".", "executescript", "(", "DROP_SQL_MODEL", ")", "self", ".", "_conn", ".", "commit", "(", ")", "cur", ".", "close", "(", ")", "return" ]
Dismantle an existing table space
[ "Dismantle", "an", "existing", "table", "space" ]
f092ffc7ed363a5b170890955168500f32de0dd5
https://github.com/uogbuji/versa/blob/f092ffc7ed363a5b170890955168500f32de0dd5/tools/py/driver/sqlite.py#L39-L45
train
Dismantle an existing table space
uogbuji/versa
tools/py/driver/sqlite.py
connection._process_db_rows_iter
def _process_db_rows_iter(self, cursor): ''' Turn the low-level rows from the result of a standard query join into higher-level statements, yielded iteratively. Note this might lead to idle transaction errors? ''' #Be aware of: http://packages.python.org/psycopg2/faq.htm...
python
def _process_db_rows_iter(self, cursor): ''' Turn the low-level rows from the result of a standard query join into higher-level statements, yielded iteratively. Note this might lead to idle transaction errors? ''' #Be aware of: http://packages.python.org/psycopg2/faq.htm...
[ "def", "_process_db_rows_iter", "(", "self", ",", "cursor", ")", ":", "#Be aware of: http://packages.python.org/psycopg2/faq.html#problems-with-transactions-handling", "#The results will come back grouped by the raw relationship IDs, in order", "for", "relid", ",", "relgroup", "in", "g...
Turn the low-level rows from the result of a standard query join into higher-level statements, yielded iteratively. Note this might lead to idle transaction errors?
[ "Turn", "the", "low", "-", "level", "rows", "from", "the", "result", "of", "a", "standard", "query", "join", "into", "higher", "-", "level", "statements", "yielded", "iteratively", ".", "Note", "this", "might", "lead", "to", "idle", "transaction", "errors?" ...
f092ffc7ed363a5b170890955168500f32de0dd5
https://github.com/uogbuji/versa/blob/f092ffc7ed363a5b170890955168500f32de0dd5/tools/py/driver/sqlite.py#L116-L142
train
Yields the low - level rows from the standard query join into the iteratively - nested list of statements yielded iteratively.
uogbuji/versa
tools/py/driver/sqlite.py
connection.add
def add(self, subj, pred, obj, attrs=None, rid=None): ''' Add one relationship to the extent subj - subject or origin of the relationship, an IRI coded as a unicode object pred - predicate or type of the relationship, an IRI coded as a unicode object obj - object of the relation...
python
def add(self, subj, pred, obj, attrs=None, rid=None): ''' Add one relationship to the extent subj - subject or origin of the relationship, an IRI coded as a unicode object pred - predicate or type of the relationship, an IRI coded as a unicode object obj - object of the relation...
[ "def", "add", "(", "self", ",", "subj", ",", "pred", ",", "obj", ",", "attrs", "=", "None", ",", "rid", "=", "None", ")", ":", "cur", "=", "self", ".", "_conn", ".", "cursor", "(", ")", "#relationship.", "if", "rid", ":", "querystr", "=", "u\"INS...
Add one relationship to the extent subj - subject or origin of the relationship, an IRI coded as a unicode object pred - predicate or type of the relationship, an IRI coded as a unicode object obj - object of the relationship, a boolean, floating point or unicode object attrs - optional...
[ "Add", "one", "relationship", "to", "the", "extent" ]
f092ffc7ed363a5b170890955168500f32de0dd5
https://github.com/uogbuji/versa/blob/f092ffc7ed363a5b170890955168500f32de0dd5/tools/py/driver/sqlite.py#L144-L170
train
Add one relationship to the extent ArcGIS object.
Ceasar/twosheds
twosheds/cli.py
CommandLineInterface.eval
def eval(self, text): """Respond to text entered by the user. :param text: the user's input """ program = Program(text, echo=self.echo, transforms=self.transforms) tokens = program.gen_tokens() for sentence in program.gen_sentences(tokens, self.aliases): if s...
python
def eval(self, text): """Respond to text entered by the user. :param text: the user's input """ program = Program(text, echo=self.echo, transforms=self.transforms) tokens = program.gen_tokens() for sentence in program.gen_sentences(tokens, self.aliases): if s...
[ "def", "eval", "(", "self", ",", "text", ")", ":", "program", "=", "Program", "(", "text", ",", "echo", "=", "self", ".", "echo", ",", "transforms", "=", "self", ".", "transforms", ")", "tokens", "=", "program", ".", "gen_tokens", "(", ")", "for", ...
Respond to text entered by the user. :param text: the user's input
[ "Respond", "to", "text", "entered", "by", "the", "user", "." ]
55b0a207e3a06b85e9a9567069b3822a651501a7
https://github.com/Ceasar/twosheds/blob/55b0a207e3a06b85e9a9567069b3822a651501a7/twosheds/cli.py#L36-L46
train
Respond to text entered by the user.
Ceasar/twosheds
twosheds/cli.py
CommandLineInterface.interact
def interact(self): """Get a command from the user and respond to it.""" lines = "" for line in self.read(): lines += line try: self.eval(lines) except ValueError: pass except KeyboardInterrupt as e: ...
python
def interact(self): """Get a command from the user and respond to it.""" lines = "" for line in self.read(): lines += line try: self.eval(lines) except ValueError: pass except KeyboardInterrupt as e: ...
[ "def", "interact", "(", "self", ")", ":", "lines", "=", "\"\"", "for", "line", "in", "self", ".", "read", "(", ")", ":", "lines", "+=", "line", "try", ":", "self", ".", "eval", "(", "lines", ")", "except", "ValueError", ":", "pass", "except", "Keyb...
Get a command from the user and respond to it.
[ "Get", "a", "command", "from", "the", "user", "and", "respond", "to", "it", "." ]
55b0a207e3a06b85e9a9567069b3822a651501a7
https://github.com/Ceasar/twosheds/blob/55b0a207e3a06b85e9a9567069b3822a651501a7/twosheds/cli.py#L48-L63
train
Get a command from the user and respond to it.
Ceasar/twosheds
twosheds/cli.py
CommandLineInterface.serve_forever
def serve_forever(self, banner=None): """Handle one interaction at a time until shutdown. :param banner: (optional) the banner to print before the first interaction. Defaults to ``None``. """ if banner: print(banner) while True: try...
python
def serve_forever(self, banner=None): """Handle one interaction at a time until shutdown. :param banner: (optional) the banner to print before the first interaction. Defaults to ``None``. """ if banner: print(banner) while True: try...
[ "def", "serve_forever", "(", "self", ",", "banner", "=", "None", ")", ":", "if", "banner", ":", "print", "(", "banner", ")", "while", "True", ":", "try", ":", "self", ".", "interact", "(", ")", "except", "KeyboardInterrupt", ":", "# program interrupted by ...
Handle one interaction at a time until shutdown. :param banner: (optional) the banner to print before the first interaction. Defaults to ``None``.
[ "Handle", "one", "interaction", "at", "a", "time", "until", "shutdown", "." ]
55b0a207e3a06b85e9a9567069b3822a651501a7
https://github.com/Ceasar/twosheds/blob/55b0a207e3a06b85e9a9567069b3822a651501a7/twosheds/cli.py#L65-L80
train
Handle one interaction at a time until shutdown.
TheGhouls/oct
oct/utilities/run.py
process_results
def process_results(output_dir, config): """Process results and output them """ print('\nanalyzing results...\n') res = output_results(output_dir, config) if res: print('created: %s/results.html\n' % output_dir) else: print('results cannot be processed')
python
def process_results(output_dir, config): """Process results and output them """ print('\nanalyzing results...\n') res = output_results(output_dir, config) if res: print('created: %s/results.html\n' % output_dir) else: print('results cannot be processed')
[ "def", "process_results", "(", "output_dir", ",", "config", ")", ":", "print", "(", "'\\nanalyzing results...\\n'", ")", "res", "=", "output_results", "(", "output_dir", ",", "config", ")", "if", "res", ":", "print", "(", "'created: %s/results.html\\n'", "%", "o...
Process results and output them
[ "Process", "results", "and", "output", "them" ]
7e9bddeb3b8495a26442b1c86744e9fb187fe88f
https://github.com/TheGhouls/oct/blob/7e9bddeb3b8495a26442b1c86744e9fb187fe88f/oct/utilities/run.py#L14-L22
train
Process results and output them
TheGhouls/oct
oct/utilities/run.py
copy_config
def copy_config(project_path, output_dir): """Copy current config file to output directory """ project_config = os.path.join(project_path, 'config.json') saved_config = os.path.join(output_dir, 'config.json') shutil.copy(project_config, saved_config)
python
def copy_config(project_path, output_dir): """Copy current config file to output directory """ project_config = os.path.join(project_path, 'config.json') saved_config = os.path.join(output_dir, 'config.json') shutil.copy(project_config, saved_config)
[ "def", "copy_config", "(", "project_path", ",", "output_dir", ")", ":", "project_config", "=", "os", ".", "path", ".", "join", "(", "project_path", ",", "'config.json'", ")", "saved_config", "=", "os", ".", "path", ".", "join", "(", "output_dir", ",", "'co...
Copy current config file to output directory
[ "Copy", "current", "config", "file", "to", "output", "directory" ]
7e9bddeb3b8495a26442b1c86744e9fb187fe88f
https://github.com/TheGhouls/oct/blob/7e9bddeb3b8495a26442b1c86744e9fb187fe88f/oct/utilities/run.py#L25-L30
train
Copy current config file to output directory
TheGhouls/oct
oct/utilities/run.py
start_hq
def start_hq(output_dir, config, topic, is_master=True, **kwargs): """Start a HQ """ HightQuarter = get_hq_class(config.get('hq_class')) hq = HightQuarter(output_dir, config, topic, **kwargs) hq.setup() if is_master: hq.wait_turrets(config.get("min_turrets", 1)) hq.run() hq.tear_...
python
def start_hq(output_dir, config, topic, is_master=True, **kwargs): """Start a HQ """ HightQuarter = get_hq_class(config.get('hq_class')) hq = HightQuarter(output_dir, config, topic, **kwargs) hq.setup() if is_master: hq.wait_turrets(config.get("min_turrets", 1)) hq.run() hq.tear_...
[ "def", "start_hq", "(", "output_dir", ",", "config", ",", "topic", ",", "is_master", "=", "True", ",", "*", "*", "kwargs", ")", ":", "HightQuarter", "=", "get_hq_class", "(", "config", ".", "get", "(", "'hq_class'", ")", ")", "hq", "=", "HightQuarter", ...
Start a HQ
[ "Start", "a", "HQ" ]
7e9bddeb3b8495a26442b1c86744e9fb187fe88f
https://github.com/TheGhouls/oct/blob/7e9bddeb3b8495a26442b1c86744e9fb187fe88f/oct/utilities/run.py#L33-L42
train
Start a HQ object
TheGhouls/oct
oct/utilities/run.py
generate_output_path
def generate_output_path(args, project_path): """Generate default output directory """ milisec = datetime.now().microsecond dirname = 'results_{}_{}'.format(time.strftime('%Y.%m.%d_%H.%M.%S', time.localtime()), str(milisec)) return os.path.join(project_path, 'results', dirname)
python
def generate_output_path(args, project_path): """Generate default output directory """ milisec = datetime.now().microsecond dirname = 'results_{}_{}'.format(time.strftime('%Y.%m.%d_%H.%M.%S', time.localtime()), str(milisec)) return os.path.join(project_path, 'results', dirname)
[ "def", "generate_output_path", "(", "args", ",", "project_path", ")", ":", "milisec", "=", "datetime", ".", "now", "(", ")", ".", "microsecond", "dirname", "=", "'results_{}_{}'", ".", "format", "(", "time", ".", "strftime", "(", "'%Y.%m.%d_%H.%M.%S'", ",", ...
Generate default output directory
[ "Generate", "default", "output", "directory" ]
7e9bddeb3b8495a26442b1c86744e9fb187fe88f
https://github.com/TheGhouls/oct/blob/7e9bddeb3b8495a26442b1c86744e9fb187fe88f/oct/utilities/run.py#L45-L50
train
Generate default output directory
TheGhouls/oct
oct/utilities/run.py
run
def run(args): """Start an oct project :param Namespace args: the commande-line arguments """ kwargs = vars(args) if 'func' in kwargs: del kwargs['func'] project_path = kwargs.pop('project_path') config = configure(project_path, kwargs.get('config_file')) output_dir = kwargs....
python
def run(args): """Start an oct project :param Namespace args: the commande-line arguments """ kwargs = vars(args) if 'func' in kwargs: del kwargs['func'] project_path = kwargs.pop('project_path') config = configure(project_path, kwargs.get('config_file')) output_dir = kwargs....
[ "def", "run", "(", "args", ")", ":", "kwargs", "=", "vars", "(", "args", ")", "if", "'func'", "in", "kwargs", ":", "del", "kwargs", "[", "'func'", "]", "project_path", "=", "kwargs", ".", "pop", "(", "'project_path'", ")", "config", "=", "configure", ...
Start an oct project :param Namespace args: the commande-line arguments
[ "Start", "an", "oct", "project" ]
7e9bddeb3b8495a26442b1c86744e9fb187fe88f
https://github.com/TheGhouls/oct/blob/7e9bddeb3b8495a26442b1c86744e9fb187fe88f/oct/utilities/run.py#L53-L79
train
Start an oct project
TheGhouls/oct
oct/utilities/run.py
run_command
def run_command(sp): """ Main function to run oct tests. """ parser = sp.add_parser('run', help="run an oct project") parser.add_argument('project_path', help="The project directory") parser.add_argument('-p', '--publisher-channel', dest='publisher_channel', help='the cha...
python
def run_command(sp): """ Main function to run oct tests. """ parser = sp.add_parser('run', help="run an oct project") parser.add_argument('project_path', help="The project directory") parser.add_argument('-p', '--publisher-channel', dest='publisher_channel', help='the cha...
[ "def", "run_command", "(", "sp", ")", ":", "parser", "=", "sp", ".", "add_parser", "(", "'run'", ",", "help", "=", "\"run an oct project\"", ")", "parser", ".", "add_argument", "(", "'project_path'", ",", "help", "=", "\"The project directory\"", ")", "parser"...
Main function to run oct tests.
[ "Main", "function", "to", "run", "oct", "tests", "." ]
7e9bddeb3b8495a26442b1c86744e9fb187fe88f
https://github.com/TheGhouls/oct/blob/7e9bddeb3b8495a26442b1c86744e9fb187fe88f/oct/utilities/run.py#L82-L100
train
Command line interface to run oct tests.
projectshift/shift-boiler
boiler/user/views_profile.py
guest_access
def guest_access(func): """ Guest access decorator Checks if public profiles option is enabled in config and checks access to profile pages based on that. """ def decorated(*_, **kwargs): public_profiles = current_app.config['USER_PUBLIC_PROFILES'] if not public_profiles: ...
python
def guest_access(func): """ Guest access decorator Checks if public profiles option is enabled in config and checks access to profile pages based on that. """ def decorated(*_, **kwargs): public_profiles = current_app.config['USER_PUBLIC_PROFILES'] if not public_profiles: ...
[ "def", "guest_access", "(", "func", ")", ":", "def", "decorated", "(", "*", "_", ",", "*", "*", "kwargs", ")", ":", "public_profiles", "=", "current_app", ".", "config", "[", "'USER_PUBLIC_PROFILES'", "]", "if", "not", "public_profiles", ":", "if", "not", ...
Guest access decorator Checks if public profiles option is enabled in config and checks access to profile pages based on that.
[ "Guest", "access", "decorator", "Checks", "if", "public", "profiles", "option", "is", "enabled", "in", "config", "and", "checks", "access", "to", "profile", "pages", "based", "on", "that", "." ]
8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b
https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/user/views_profile.py#L24-L39
train
Decorator to check if guest access is enabled in config and checks if public profiles option is enabled in config and checks if profile pages based on that.
projectshift/shift-boiler
boiler/user/views_profile.py
only_owner
def only_owner(func): """ Only owner decorator Restricts access to view ony to profile owner """ def decorated(*_, **kwargs): id = kwargs['id'] if not current_user.is_authenticated: abort(401) elif current_user.id != id: abort(403) return func(...
python
def only_owner(func): """ Only owner decorator Restricts access to view ony to profile owner """ def decorated(*_, **kwargs): id = kwargs['id'] if not current_user.is_authenticated: abort(401) elif current_user.id != id: abort(403) return func(...
[ "def", "only_owner", "(", "func", ")", ":", "def", "decorated", "(", "*", "_", ",", "*", "*", "kwargs", ")", ":", "id", "=", "kwargs", "[", "'id'", "]", "if", "not", "current_user", ".", "is_authenticated", ":", "abort", "(", "401", ")", "elif", "c...
Only owner decorator Restricts access to view ony to profile owner
[ "Only", "owner", "decorator", "Restricts", "access", "to", "view", "ony", "to", "profile", "owner" ]
8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b
https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/user/views_profile.py#L42-L55
train
Decorator that allows access to view ony to profile owner
CodersOfTheNight/oshino
oshino/config.py
load
def load(config_file): """ Processes and loads config file. """ with open(config_file, "r") as f: def env_get(): return dict(os.environ) tmpl = Template(f.read()) return Config(yaml.load(tmpl.render(**env_get())))
python
def load(config_file): """ Processes and loads config file. """ with open(config_file, "r") as f: def env_get(): return dict(os.environ) tmpl = Template(f.read()) return Config(yaml.load(tmpl.render(**env_get())))
[ "def", "load", "(", "config_file", ")", ":", "with", "open", "(", "config_file", ",", "\"r\"", ")", "as", "f", ":", "def", "env_get", "(", ")", ":", "return", "dict", "(", "os", ".", "environ", ")", "tmpl", "=", "Template", "(", "f", ".", "read", ...
Processes and loads config file.
[ "Processes", "and", "loads", "config", "file", "." ]
00f7e151e3ce1f3a7f43b353b695c4dba83c7f28
https://github.com/CodersOfTheNight/oshino/blob/00f7e151e3ce1f3a7f43b353b695c4dba83c7f28/oshino/config.py#L180-L189
train
Processes and loads config file.
uw-it-aca/uw-restclients-sws
uw_sws/term.py
get_term_by_year_and_quarter
def get_term_by_year_and_quarter(year, quarter): """ Returns a uw_sws.models.Term object, for the passed year and quarter. """ url = "{}/{},{}.json".format( term_res_url_prefix, year, quarter.lower()) return _json_to_term_model(get_resource(url))
python
def get_term_by_year_and_quarter(year, quarter): """ Returns a uw_sws.models.Term object, for the passed year and quarter. """ url = "{}/{},{}.json".format( term_res_url_prefix, year, quarter.lower()) return _json_to_term_model(get_resource(url))
[ "def", "get_term_by_year_and_quarter", "(", "year", ",", "quarter", ")", ":", "url", "=", "\"{}/{},{}.json\"", ".", "format", "(", "term_res_url_prefix", ",", "year", ",", "quarter", ".", "lower", "(", ")", ")", "return", "_json_to_term_model", "(", "get_resourc...
Returns a uw_sws.models.Term object, for the passed year and quarter.
[ "Returns", "a", "uw_sws", ".", "models", ".", "Term", "object", "for", "the", "passed", "year", "and", "quarter", "." ]
4d36776dcca36855fc15c1b8fe7650ae045194cf
https://github.com/uw-it-aca/uw-restclients-sws/blob/4d36776dcca36855fc15c1b8fe7650ae045194cf/uw_sws/term.py#L15-L22
train
Returns a uw_sws. models. Term object for the passed year and quarter.
uw-it-aca/uw-restclients-sws
uw_sws/term.py
get_current_term
def get_current_term(): """ Returns a uw_sws.models.Term object, for the current term. """ url = "{}/current.json".format(term_res_url_prefix) term = _json_to_term_model(get_resource(url)) # A term doesn't become "current" until 2 days before the start of # classes. That's too late to ...
python
def get_current_term(): """ Returns a uw_sws.models.Term object, for the current term. """ url = "{}/current.json".format(term_res_url_prefix) term = _json_to_term_model(get_resource(url)) # A term doesn't become "current" until 2 days before the start of # classes. That's too late to ...
[ "def", "get_current_term", "(", ")", ":", "url", "=", "\"{}/current.json\"", ".", "format", "(", "term_res_url_prefix", ")", "term", "=", "_json_to_term_model", "(", "get_resource", "(", "url", ")", ")", "# A term doesn't become \"current\" until 2 days before the start o...
Returns a uw_sws.models.Term object, for the current term.
[ "Returns", "a", "uw_sws", ".", "models", ".", "Term", "object", "for", "the", "current", "term", "." ]
4d36776dcca36855fc15c1b8fe7650ae045194cf
https://github.com/uw-it-aca/uw-restclients-sws/blob/4d36776dcca36855fc15c1b8fe7650ae045194cf/uw_sws/term.py#L25-L39
train
Returns a uw_sws. models. Term object for the current term.
uw-it-aca/uw-restclients-sws
uw_sws/term.py
get_term_before
def get_term_before(aterm): """ Returns a uw_sws.models.Term object, for the term before the term given. """ prev_year = aterm.year prev_quarter = QUARTER_SEQ[QUARTER_SEQ.index(aterm.quarter) - 1] if prev_quarter == "autumn": prev_year -= 1 return get_term_by_year_and_quarter(p...
python
def get_term_before(aterm): """ Returns a uw_sws.models.Term object, for the term before the term given. """ prev_year = aterm.year prev_quarter = QUARTER_SEQ[QUARTER_SEQ.index(aterm.quarter) - 1] if prev_quarter == "autumn": prev_year -= 1 return get_term_by_year_and_quarter(p...
[ "def", "get_term_before", "(", "aterm", ")", ":", "prev_year", "=", "aterm", ".", "year", "prev_quarter", "=", "QUARTER_SEQ", "[", "QUARTER_SEQ", ".", "index", "(", "aterm", ".", "quarter", ")", "-", "1", "]", "if", "prev_quarter", "==", "\"autumn\"", ":",...
Returns a uw_sws.models.Term object, for the term before the term given.
[ "Returns", "a", "uw_sws", ".", "models", ".", "Term", "object", "for", "the", "term", "before", "the", "term", "given", "." ]
4d36776dcca36855fc15c1b8fe7650ae045194cf
https://github.com/uw-it-aca/uw-restclients-sws/blob/4d36776dcca36855fc15c1b8fe7650ae045194cf/uw_sws/term.py#L60-L71
train
Returns a uw_sws. models. Term object for the term before the given term.
uw-it-aca/uw-restclients-sws
uw_sws/term.py
get_term_after
def get_term_after(aterm): """ Returns a uw_sws.models.Term object, for the term after the term given. """ next_year = aterm.year if aterm.quarter == "autumn": next_quarter = QUARTER_SEQ[0] else: next_quarter = QUARTER_SEQ[QUARTER_SEQ.index(aterm.quarter) + 1] if next_qu...
python
def get_term_after(aterm): """ Returns a uw_sws.models.Term object, for the term after the term given. """ next_year = aterm.year if aterm.quarter == "autumn": next_quarter = QUARTER_SEQ[0] else: next_quarter = QUARTER_SEQ[QUARTER_SEQ.index(aterm.quarter) + 1] if next_qu...
[ "def", "get_term_after", "(", "aterm", ")", ":", "next_year", "=", "aterm", ".", "year", "if", "aterm", ".", "quarter", "==", "\"autumn\"", ":", "next_quarter", "=", "QUARTER_SEQ", "[", "0", "]", "else", ":", "next_quarter", "=", "QUARTER_SEQ", "[", "QUART...
Returns a uw_sws.models.Term object, for the term after the term given.
[ "Returns", "a", "uw_sws", ".", "models", ".", "Term", "object", "for", "the", "term", "after", "the", "term", "given", "." ]
4d36776dcca36855fc15c1b8fe7650ae045194cf
https://github.com/uw-it-aca/uw-restclients-sws/blob/4d36776dcca36855fc15c1b8fe7650ae045194cf/uw_sws/term.py#L74-L88
train
Returns a uw_sws. models. Term object for the term after the given term.
uw-it-aca/uw-restclients-sws
uw_sws/term.py
get_term_by_date
def get_term_by_date(date): """ Returns a term for the datetime.date object given. """ year = date.year term = None for quarter in ('autumn', 'summer', 'spring', 'winter'): term = get_term_by_year_and_quarter(year, quarter) if date >= term.first_day_quarter: break ...
python
def get_term_by_date(date): """ Returns a term for the datetime.date object given. """ year = date.year term = None for quarter in ('autumn', 'summer', 'spring', 'winter'): term = get_term_by_year_and_quarter(year, quarter) if date >= term.first_day_quarter: break ...
[ "def", "get_term_by_date", "(", "date", ")", ":", "year", "=", "date", ".", "year", "term", "=", "None", "for", "quarter", "in", "(", "'autumn'", ",", "'summer'", ",", "'spring'", ",", "'winter'", ")", ":", "term", "=", "get_term_by_year_and_quarter", "(",...
Returns a term for the datetime.date object given.
[ "Returns", "a", "term", "for", "the", "datetime", ".", "date", "object", "given", "." ]
4d36776dcca36855fc15c1b8fe7650ae045194cf
https://github.com/uw-it-aca/uw-restclients-sws/blob/4d36776dcca36855fc15c1b8fe7650ae045194cf/uw_sws/term.py#L91-L118
train
Returns a term for the given datetime. date object given.
uw-it-aca/uw-restclients-sws
uw_sws/term.py
_json_to_term_model
def _json_to_term_model(term_data): """ Returns a term model created from the passed json data. param: term_data loaded json data """ strptime = datetime.strptime day_format = "%Y-%m-%d" datetime_format = "%Y-%m-%dT%H:%M:%S" term = TermModel() term.year = term_data["Year"] term...
python
def _json_to_term_model(term_data): """ Returns a term model created from the passed json data. param: term_data loaded json data """ strptime = datetime.strptime day_format = "%Y-%m-%d" datetime_format = "%Y-%m-%dT%H:%M:%S" term = TermModel() term.year = term_data["Year"] term...
[ "def", "_json_to_term_model", "(", "term_data", ")", ":", "strptime", "=", "datetime", ".", "strptime", "day_format", "=", "\"%Y-%m-%d\"", "datetime_format", "=", "\"%Y-%m-%dT%H:%M:%S\"", "term", "=", "TermModel", "(", ")", "term", ".", "year", "=", "term_data", ...
Returns a term model created from the passed json data. param: term_data loaded json data
[ "Returns", "a", "term", "model", "created", "from", "the", "passed", "json", "data", ".", "param", ":", "term_data", "loaded", "json", "data" ]
4d36776dcca36855fc15c1b8fe7650ae045194cf
https://github.com/uw-it-aca/uw-restclients-sws/blob/4d36776dcca36855fc15c1b8fe7650ae045194cf/uw_sws/term.py#L121-L233
train
Returns a TermModel object from the passed json data.
uw-it-aca/uw-restclients-sws
uw_sws/term.py
get_next_non_summer_term
def get_next_non_summer_term(term): """ Return the Term object for the quarter after as the given term (skip the summer quarter) """ next_term = get_term_after(term) if next_term.is_summer_quarter(): return get_next_autumn_term(next_term) return next_term
python
def get_next_non_summer_term(term): """ Return the Term object for the quarter after as the given term (skip the summer quarter) """ next_term = get_term_after(term) if next_term.is_summer_quarter(): return get_next_autumn_term(next_term) return next_term
[ "def", "get_next_non_summer_term", "(", "term", ")", ":", "next_term", "=", "get_term_after", "(", "term", ")", "if", "next_term", ".", "is_summer_quarter", "(", ")", ":", "return", "get_next_autumn_term", "(", "next_term", ")", "return", "next_term" ]
Return the Term object for the quarter after as the given term (skip the summer quarter)
[ "Return", "the", "Term", "object", "for", "the", "quarter", "after", "as", "the", "given", "term", "(", "skip", "the", "summer", "quarter", ")" ]
4d36776dcca36855fc15c1b8fe7650ae045194cf
https://github.com/uw-it-aca/uw-restclients-sws/blob/4d36776dcca36855fc15c1b8fe7650ae045194cf/uw_sws/term.py#L251-L259
train
Returns the next non - summer term in the quarter after as the given term
Kortemme-Lab/klab
klab/bio/pdbechem.py
pdbechem_parse
def pdbechem_parse(download = False, filename = '/kortemmelab/shared/mirror/PDBeChem/chem_comp.xml'): '''This is slower than using SAX but much easier to write/read. If you need this to perform well, rewrite with SAX.''' xml_data = None if download: # this URL will go out of date try: ...
python
def pdbechem_parse(download = False, filename = '/kortemmelab/shared/mirror/PDBeChem/chem_comp.xml'): '''This is slower than using SAX but much easier to write/read. If you need this to perform well, rewrite with SAX.''' xml_data = None if download: # this URL will go out of date try: ...
[ "def", "pdbechem_parse", "(", "download", "=", "False", ",", "filename", "=", "'/kortemmelab/shared/mirror/PDBeChem/chem_comp.xml'", ")", ":", "xml_data", "=", "None", "if", "download", ":", "# this URL will go out of date", "try", ":", "resource", "=", "[", "'ftp.ebi...
This is slower than using SAX but much easier to write/read. If you need this to perform well, rewrite with SAX.
[ "This", "is", "slower", "than", "using", "SAX", "but", "much", "easier", "to", "write", "/", "read", ".", "If", "you", "need", "this", "to", "perform", "well", "rewrite", "with", "SAX", "." ]
6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/pdbechem.py#L18-L60
train
This function parses the PDBECH XML file and returns a dictionary of the PDBECH XML entries.
projectshift/shift-boiler
boiler/feature/logging.py
logging_feature
def logging_feature(app): """ Add logging Accepts flask application and registers logging functionality within it """ # this is important because otherwise only log warn, err and crit app.logger.setLevel(logging.INFO) # enable loggers email_exceptions = app.config.get('LOGGING_EMAIL_EX...
python
def logging_feature(app): """ Add logging Accepts flask application and registers logging functionality within it """ # this is important because otherwise only log warn, err and crit app.logger.setLevel(logging.INFO) # enable loggers email_exceptions = app.config.get('LOGGING_EMAIL_EX...
[ "def", "logging_feature", "(", "app", ")", ":", "# this is important because otherwise only log warn, err and crit", "app", ".", "logger", ".", "setLevel", "(", "logging", ".", "INFO", ")", "# enable loggers", "email_exceptions", "=", "app", ".", "config", ".", "get",...
Add logging Accepts flask application and registers logging functionality within it
[ "Add", "logging", "Accepts", "flask", "application", "and", "registers", "logging", "functionality", "within", "it" ]
8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b
https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/feature/logging.py#L6-L24
train
Add logging feature for the application
jreese/aioslack
aioslack/core.py
Slack.rtm
async def rtm(self) -> AsyncIterator[Event]: """Connect to the realtime event API and start yielding events.""" response = cast(RTMStart, await self.api("rtm.start")) self.me = Auto.generate(response.self_, "Me", recursive=False) self.team = Auto.generate(response.team, "Team", recursiv...
python
async def rtm(self) -> AsyncIterator[Event]: """Connect to the realtime event API and start yielding events.""" response = cast(RTMStart, await self.api("rtm.start")) self.me = Auto.generate(response.self_, "Me", recursive=False) self.team = Auto.generate(response.team, "Team", recursiv...
[ "async", "def", "rtm", "(", "self", ")", "->", "AsyncIterator", "[", "Event", "]", ":", "response", "=", "cast", "(", "RTMStart", ",", "await", "self", ".", "api", "(", "\"rtm.start\"", ")", ")", "self", ".", "me", "=", "Auto", ".", "generate", "(", ...
Connect to the realtime event API and start yielding events.
[ "Connect", "to", "the", "realtime", "event", "API", "and", "start", "yielding", "events", "." ]
5e705f557dde9e81903d84ffb2896ec0a074ad5c
https://github.com/jreese/aioslack/blob/5e705f557dde9e81903d84ffb2896ec0a074ad5c/aioslack/core.py#L79-L101
train
Connect to the realtime event API and start yielding events.
jreese/aioslack
aioslack/core.py
Slack.decode
def decode(self, text: str, prefix: str = "@") -> str: """Decode <@id> and <!alias> into @username.""" def callback(match: Match) -> str: m = match.groupdict() if m["userid"]: user = self.users.get(m["userid"], None) if user is None: ...
python
def decode(self, text: str, prefix: str = "@") -> str: """Decode <@id> and <!alias> into @username.""" def callback(match: Match) -> str: m = match.groupdict() if m["userid"]: user = self.users.get(m["userid"], None) if user is None: ...
[ "def", "decode", "(", "self", ",", "text", ":", "str", ",", "prefix", ":", "str", "=", "\"@\"", ")", "->", "str", ":", "def", "callback", "(", "match", ":", "Match", ")", "->", "str", ":", "m", "=", "match", ".", "groupdict", "(", ")", "if", "m...
Decode <@id> and <!alias> into @username.
[ "Decode", "<" ]
5e705f557dde9e81903d84ffb2896ec0a074ad5c
https://github.com/jreese/aioslack/blob/5e705f557dde9e81903d84ffb2896ec0a074ad5c/aioslack/core.py#L103-L118
train
Decode <id > and <!alias > into username.
jreese/aioslack
aioslack/core.py
Slack.encode
def encode(self, text: str) -> str: """Encode @username into <@id> or <!alias>.""" def callback(match: Match) -> str: name = match.group("name").lower() if name in ["here", "everyone", "channel"]: return f"<!{name}>" else: for user in ...
python
def encode(self, text: str) -> str: """Encode @username into <@id> or <!alias>.""" def callback(match: Match) -> str: name = match.group("name").lower() if name in ["here", "everyone", "channel"]: return f"<!{name}>" else: for user in ...
[ "def", "encode", "(", "self", ",", "text", ":", "str", ")", "->", "str", ":", "def", "callback", "(", "match", ":", "Match", ")", "->", "str", ":", "name", "=", "match", ".", "group", "(", "\"name\"", ")", ".", "lower", "(", ")", "if", "name", ...
Encode @username into <@id> or <!alias>.
[ "Encode" ]
5e705f557dde9e81903d84ffb2896ec0a074ad5c
https://github.com/jreese/aioslack/blob/5e705f557dde9e81903d84ffb2896ec0a074ad5c/aioslack/core.py#L120-L133
train
Encode username into <@id or <!alias >.
thespacedoctor/HMpTy
HMpTy/mysql/add_htm_ids_to_mysql_database_table.py
add_htm_ids_to_mysql_database_table
def add_htm_ids_to_mysql_database_table( raColName, declColName, tableName, dbConn, log, primaryIdColumnName="primaryId", cartesian=False, batchSize=50000, reindex=False, dbSettings=False): """*Given a database connection, a name of a t...
python
def add_htm_ids_to_mysql_database_table( raColName, declColName, tableName, dbConn, log, primaryIdColumnName="primaryId", cartesian=False, batchSize=50000, reindex=False, dbSettings=False): """*Given a database connection, a name of a t...
[ "def", "add_htm_ids_to_mysql_database_table", "(", "raColName", ",", "declColName", ",", "tableName", ",", "dbConn", ",", "log", ",", "primaryIdColumnName", "=", "\"primaryId\"", ",", "cartesian", "=", "False", ",", "batchSize", "=", "50000", ",", "reindex", "=", ...
*Given a database connection, a name of a table and the column names for RA and DEC, generates ID for one or more HTM level in the table* **Key Arguments:** - ``raColName`` -- ra in sexegesimal - ``declColName`` -- dec in sexegesimal - ``tableName`` -- name of table to add htmid info to ...
[ "*", "Given", "a", "database", "connection", "a", "name", "of", "a", "table", "and", "the", "column", "names", "for", "RA", "and", "DEC", "generates", "ID", "for", "one", "or", "more", "HTM", "level", "in", "the", "table", "*" ]
3ce2bdb7ce3351468962ab907ede9a6074c15912
https://github.com/thespacedoctor/HMpTy/blob/3ce2bdb7ce3351468962ab907ede9a6074c15912/HMpTy/mysql/add_htm_ids_to_mysql_database_table.py#L25-L374
train
This function adds HTM IDs to the database table.
eventbrite/rebar
src/rebar/group.py
formgroup_factory
def formgroup_factory(form_classes, formgroup=None, state_validators=None, ): """Return a FormGroup class for the given form[set] form_classes. """ base_class = formgroup or FormGroup if state_validators is not None: base_class ...
python
def formgroup_factory(form_classes, formgroup=None, state_validators=None, ): """Return a FormGroup class for the given form[set] form_classes. """ base_class = formgroup or FormGroup if state_validators is not None: base_class ...
[ "def", "formgroup_factory", "(", "form_classes", ",", "formgroup", "=", "None", ",", "state_validators", "=", "None", ",", ")", ":", "base_class", "=", "formgroup", "or", "FormGroup", "if", "state_validators", "is", "not", "None", ":", "base_class", "=", "Stat...
Return a FormGroup class for the given form[set] form_classes.
[ "Return", "a", "FormGroup", "class", "for", "the", "given", "form", "[", "set", "]", "form_classes", "." ]
32f8914a2c5529519009d21c85f0d47cc6601901
https://github.com/eventbrite/rebar/blob/32f8914a2c5529519009d21c85f0d47cc6601901/src/rebar/group.py#L274-L296
train
Return a FormGroup class for the given form [ set ] form_classes.
eventbrite/rebar
src/rebar/group.py
FormGroup._apply
def _apply(self, method_name, *args, **kwargs): """Call ``method_name`` with args and kwargs on each member. Returns a sequence of return values. """ return [ getattr(member, method_name)(*args, **kwargs) for member in self.forms ]
python
def _apply(self, method_name, *args, **kwargs): """Call ``method_name`` with args and kwargs on each member. Returns a sequence of return values. """ return [ getattr(member, method_name)(*args, **kwargs) for member in self.forms ]
[ "def", "_apply", "(", "self", ",", "method_name", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "[", "getattr", "(", "member", ",", "method_name", ")", "(", "*", "args", ",", "*", "*", "kwargs", ")", "for", "member", "in", "self", ...
Call ``method_name`` with args and kwargs on each member. Returns a sequence of return values.
[ "Call", "method_name", "with", "args", "and", "kwargs", "on", "each", "member", "." ]
32f8914a2c5529519009d21c85f0d47cc6601901
https://github.com/eventbrite/rebar/blob/32f8914a2c5529519009d21c85f0d47cc6601901/src/rebar/group.py#L115-L125
train
Call method_name with args and kwargs on each member and return a sequence of return values.
eventbrite/rebar
src/rebar/group.py
FormGroup.html_id
def html_id(self, field_name, form=None): """Return the html ID for the given field_name.""" if form is None: form = self return form.auto_id % (form.add_prefix(field_name),)
python
def html_id(self, field_name, form=None): """Return the html ID for the given field_name.""" if form is None: form = self return form.auto_id % (form.add_prefix(field_name),)
[ "def", "html_id", "(", "self", ",", "field_name", ",", "form", "=", "None", ")", ":", "if", "form", "is", "None", ":", "form", "=", "self", "return", "form", ".", "auto_id", "%", "(", "form", ".", "add_prefix", "(", "field_name", ")", ",", ")" ]
Return the html ID for the given field_name.
[ "Return", "the", "html", "ID", "for", "the", "given", "field_name", "." ]
32f8914a2c5529519009d21c85f0d47cc6601901
https://github.com/eventbrite/rebar/blob/32f8914a2c5529519009d21c85f0d47cc6601901/src/rebar/group.py#L136-L142
train
Return the html ID for the given field_name.
eventbrite/rebar
src/rebar/group.py
FormGroup.save
def save(self): """Save the changes to the instance and any related objects.""" # first call save with commit=False for all Forms for form in self._forms: if isinstance(form, BaseForm): form.save(commit=False) # call save on the instance self.instanc...
python
def save(self): """Save the changes to the instance and any related objects.""" # first call save with commit=False for all Forms for form in self._forms: if isinstance(form, BaseForm): form.save(commit=False) # call save on the instance self.instanc...
[ "def", "save", "(", "self", ")", ":", "# first call save with commit=False for all Forms", "for", "form", "in", "self", ".", "_forms", ":", "if", "isinstance", "(", "form", ",", "BaseForm", ")", ":", "form", ".", "save", "(", "commit", "=", "False", ")", "...
Save the changes to the instance and any related objects.
[ "Save", "the", "changes", "to", "the", "instance", "and", "any", "related", "objects", "." ]
32f8914a2c5529519009d21c85f0d47cc6601901
https://github.com/eventbrite/rebar/blob/32f8914a2c5529519009d21c85f0d47cc6601901/src/rebar/group.py#L208-L232
train
Save the changes to the instance and any related objects.