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
1 value
hamidfzm/Flask-HTMLmin
flask_htmlmin/__init__.py
HTMLMIN.response_minify
def response_minify(self, response): """ minify response html to decrease traffic """ if response.content_type == u'text/html; charset=utf-8': endpoint = request.endpoint or '' view_func = current_app.view_functions.get(endpoint, None) name = ( ...
python
def response_minify(self, response): """ minify response html to decrease traffic """ if response.content_type == u'text/html; charset=utf-8': endpoint = request.endpoint or '' view_func = current_app.view_functions.get(endpoint, None) name = ( ...
[ "def", "response_minify", "(", "self", ",", "response", ")", ":", "if", "response", ".", "content_type", "==", "u'text/html; charset=utf-8'", ":", "endpoint", "=", "request", ".", "endpoint", "or", "''", "view_func", "=", "current_app", ".", "view_functions", "....
minify response html to decrease traffic
[ "minify", "response", "html", "to", "decrease", "traffic" ]
03de23347ac021da4011af36b57903a235268429
https://github.com/hamidfzm/Flask-HTMLmin/blob/03de23347ac021da4011af36b57903a235268429/flask_htmlmin/__init__.py#L29-L50
train
hamidfzm/Flask-HTMLmin
flask_htmlmin/__init__.py
HTMLMIN.exempt
def exempt(self, obj): """ decorator to mark a view as exempt from htmlmin. """ name = '%s.%s' % (obj.__module__, obj.__name__) @wraps(obj) def __inner(*a, **k): return obj(*a, **k) self._exempt_routes.add(name) return __inner
python
def exempt(self, obj): """ decorator to mark a view as exempt from htmlmin. """ name = '%s.%s' % (obj.__module__, obj.__name__) @wraps(obj) def __inner(*a, **k): return obj(*a, **k) self._exempt_routes.add(name) return __inner
[ "def", "exempt", "(", "self", ",", "obj", ")", ":", "name", "=", "'%s.%s'", "%", "(", "obj", ".", "__module__", ",", "obj", ".", "__name__", ")", "@", "wraps", "(", "obj", ")", "def", "__inner", "(", "*", "a", ",", "*", "*", "k", ")", ":", "r...
decorator to mark a view as exempt from htmlmin.
[ "decorator", "to", "mark", "a", "view", "as", "exempt", "from", "htmlmin", "." ]
03de23347ac021da4011af36b57903a235268429
https://github.com/hamidfzm/Flask-HTMLmin/blob/03de23347ac021da4011af36b57903a235268429/flask_htmlmin/__init__.py#L52-L63
train
refindlyllc/rets
rets/utils/search.py
DMQLHelper.dmql
def dmql(query): """Client supplied raw DMQL, ensure quote wrap.""" if isinstance(query, dict): raise ValueError("You supplied a dictionary to the dmql_query parameter, but a string is required." " Did you mean to pass this to the search_filter parameter? ") ...
python
def dmql(query): """Client supplied raw DMQL, ensure quote wrap.""" if isinstance(query, dict): raise ValueError("You supplied a dictionary to the dmql_query parameter, but a string is required." " Did you mean to pass this to the search_filter parameter? ") ...
[ "def", "dmql", "(", "query", ")", ":", "if", "isinstance", "(", "query", ",", "dict", ")", ":", "raise", "ValueError", "(", "\"You supplied a dictionary to the dmql_query parameter, but a string is required.\"", "\" Did you mean to pass this to the search_filter parameter? \"", ...
Client supplied raw DMQL, ensure quote wrap.
[ "Client", "supplied", "raw", "DMQL", "ensure", "quote", "wrap", "." ]
c615dfc272cff0825fd3b50863c46afc3e33916f
https://github.com/refindlyllc/rets/blob/c615dfc272cff0825fd3b50863c46afc3e33916f/rets/utils/search.py#L14-L23
train
refindlyllc/rets
rets/utils/search.py
DMQLHelper.filter_to_dmql
def filter_to_dmql(filter_dict): """Converts the filter dictionary into DMQL""" if not isinstance(filter_dict, (dict, collections.OrderedDict)): raise TypeError('Expected a dictionary type buy got {} instead.'.format(type(filter_dict))) def is_date_time_type(val): """Re...
python
def filter_to_dmql(filter_dict): """Converts the filter dictionary into DMQL""" if not isinstance(filter_dict, (dict, collections.OrderedDict)): raise TypeError('Expected a dictionary type buy got {} instead.'.format(type(filter_dict))) def is_date_time_type(val): """Re...
[ "def", "filter_to_dmql", "(", "filter_dict", ")", ":", "if", "not", "isinstance", "(", "filter_dict", ",", "(", "dict", ",", "collections", ".", "OrderedDict", ")", ")", ":", "raise", "TypeError", "(", "'Expected a dictionary type buy got {} instead.'", ".", "form...
Converts the filter dictionary into DMQL
[ "Converts", "the", "filter", "dictionary", "into", "DMQL" ]
c615dfc272cff0825fd3b50863c46afc3e33916f
https://github.com/refindlyllc/rets/blob/c615dfc272cff0825fd3b50863c46afc3e33916f/rets/utils/search.py#L26-L161
train
refindlyllc/rets
rets/parsers/base.py
Base.get_attributes
def get_attributes(input_dict): """ Get attributes of xml tags in input_dict and creates a dictionary with the attribute name as the key and the attribute value as the value :param input_dict: The xml tag with the attributes and values :return: dict """ return {k....
python
def get_attributes(input_dict): """ Get attributes of xml tags in input_dict and creates a dictionary with the attribute name as the key and the attribute value as the value :param input_dict: The xml tag with the attributes and values :return: dict """ return {k....
[ "def", "get_attributes", "(", "input_dict", ")", ":", "return", "{", "k", ".", "lstrip", "(", "\"@\"", ")", ":", "v", "for", "k", ",", "v", "in", "input_dict", ".", "items", "(", ")", "if", "k", "[", "0", "]", "==", "\"@\"", "}" ]
Get attributes of xml tags in input_dict and creates a dictionary with the attribute name as the key and the attribute value as the value :param input_dict: The xml tag with the attributes and values :return: dict
[ "Get", "attributes", "of", "xml", "tags", "in", "input_dict", "and", "creates", "a", "dictionary", "with", "the", "attribute", "name", "as", "the", "key", "and", "the", "attribute", "value", "as", "the", "value", ":", "param", "input_dict", ":", "The", "xm...
c615dfc272cff0825fd3b50863c46afc3e33916f
https://github.com/refindlyllc/rets/blob/c615dfc272cff0825fd3b50863c46afc3e33916f/rets/parsers/base.py#L12-L19
train
refindlyllc/rets
rets/parsers/base.py
Base.data_columns_to_dict
def data_columns_to_dict(columns_string, dict_string, delimiter=None): """ Turns column names in a single string into a dictionary with the key being the column name and the value being the value in that column for each row :param columns_string: A string of column names :param d...
python
def data_columns_to_dict(columns_string, dict_string, delimiter=None): """ Turns column names in a single string into a dictionary with the key being the column name and the value being the value in that column for each row :param columns_string: A string of column names :param d...
[ "def", "data_columns_to_dict", "(", "columns_string", ",", "dict_string", ",", "delimiter", "=", "None", ")", ":", "if", "delimiter", ":", "return", "{", "k", ":", "v", "for", "k", ",", "v", "in", "zip", "(", "columns_string", ".", "split", "(", "delimit...
Turns column names in a single string into a dictionary with the key being the column name and the value being the value in that column for each row :param columns_string: A string of column names :param dict_string: A string of values :param delimiter: The delimiter to use to split the ...
[ "Turns", "column", "names", "in", "a", "single", "string", "into", "a", "dictionary", "with", "the", "key", "being", "the", "column", "name", "and", "the", "value", "being", "the", "value", "in", "that", "column", "for", "each", "row", ":", "param", "col...
c615dfc272cff0825fd3b50863c46afc3e33916f
https://github.com/refindlyllc/rets/blob/c615dfc272cff0825fd3b50863c46afc3e33916f/rets/parsers/base.py#L22-L34
train
refindlyllc/rets
rets/parsers/base.py
Base.analyze_reply_code
def analyze_reply_code(self, xml_response_dict): """ Checks the RETS Response Code and handles non-zero answers. :param xml_response_dict: :return: None """ if 'RETS-STATUS' in xml_response_dict: attributes = self.get_attributes(xml_response_dict['RETS-STATUS'...
python
def analyze_reply_code(self, xml_response_dict): """ Checks the RETS Response Code and handles non-zero answers. :param xml_response_dict: :return: None """ if 'RETS-STATUS' in xml_response_dict: attributes = self.get_attributes(xml_response_dict['RETS-STATUS'...
[ "def", "analyze_reply_code", "(", "self", ",", "xml_response_dict", ")", ":", "if", "'RETS-STATUS'", "in", "xml_response_dict", ":", "attributes", "=", "self", ".", "get_attributes", "(", "xml_response_dict", "[", "'RETS-STATUS'", "]", ")", "reply_code", "=", "att...
Checks the RETS Response Code and handles non-zero answers. :param xml_response_dict: :return: None
[ "Checks", "the", "RETS", "Response", "Code", "and", "handles", "non", "-", "zero", "answers", ".", ":", "param", "xml_response_dict", ":", ":", "return", ":", "None" ]
c615dfc272cff0825fd3b50863c46afc3e33916f
https://github.com/refindlyllc/rets/blob/c615dfc272cff0825fd3b50863c46afc3e33916f/rets/parsers/base.py#L36-L64
train
refindlyllc/rets
rets/utils/get_object.py
GetObject.ids
def ids(self, content_ids, object_ids): """Appends the content and object ids how RETS expects them""" result = [] content_ids = self.split(content_ids, False) object_ids = self.split(object_ids) for cid in content_ids: result.append('{}:{}'.format(cid, ':'.join(obj...
python
def ids(self, content_ids, object_ids): """Appends the content and object ids how RETS expects them""" result = [] content_ids = self.split(content_ids, False) object_ids = self.split(object_ids) for cid in content_ids: result.append('{}:{}'.format(cid, ':'.join(obj...
[ "def", "ids", "(", "self", ",", "content_ids", ",", "object_ids", ")", ":", "result", "=", "[", "]", "content_ids", "=", "self", ".", "split", "(", "content_ids", ",", "False", ")", "object_ids", "=", "self", ".", "split", "(", "object_ids", ")", "for"...
Appends the content and object ids how RETS expects them
[ "Appends", "the", "content", "and", "object", "ids", "how", "RETS", "expects", "them" ]
c615dfc272cff0825fd3b50863c46afc3e33916f
https://github.com/refindlyllc/rets/blob/c615dfc272cff0825fd3b50863c46afc3e33916f/rets/utils/get_object.py#L7-L17
train
refindlyllc/rets
rets/utils/get_object.py
GetObject.split
def split(value, dash_ranges=True): """Splits """ if isinstance(value, list): value = [str(v) for v in value] else: str_value = str(value) dash_matches = re.match(pattern='(\d+)\-(\d+)', string=str_value) if ':' in str_value or ',' in str_value: ...
python
def split(value, dash_ranges=True): """Splits """ if isinstance(value, list): value = [str(v) for v in value] else: str_value = str(value) dash_matches = re.match(pattern='(\d+)\-(\d+)', string=str_value) if ':' in str_value or ',' in str_value: ...
[ "def", "split", "(", "value", ",", "dash_ranges", "=", "True", ")", ":", "if", "isinstance", "(", "value", ",", "list", ")", ":", "value", "=", "[", "str", "(", "v", ")", "for", "v", "in", "value", "]", "else", ":", "str_value", "=", "str", "(", ...
Splits
[ "Splits" ]
c615dfc272cff0825fd3b50863c46afc3e33916f
https://github.com/refindlyllc/rets/blob/c615dfc272cff0825fd3b50863c46afc3e33916f/rets/utils/get_object.py#L20-L38
train
roanuz/py-cricket
src/pycricket_storagehandler.py
RcaFileStorageHandler.set_value
def set_value(self, key, value): """ Set key value to the file. The fuction will be make the key and value to dictinary formate. If its exist then it will update the current new key value to the file. Arg: key : cache key value : cache value """ ...
python
def set_value(self, key, value): """ Set key value to the file. The fuction will be make the key and value to dictinary formate. If its exist then it will update the current new key value to the file. Arg: key : cache key value : cache value """ ...
[ "def", "set_value", "(", "self", ",", "key", ",", "value", ")", ":", "file_cache", "=", "self", ".", "read_file", "(", ")", "if", "file_cache", ":", "file_cache", "[", "key", "]", "=", "value", "else", ":", "file_cache", "=", "{", "}", "file_cache", ...
Set key value to the file. The fuction will be make the key and value to dictinary formate. If its exist then it will update the current new key value to the file. Arg: key : cache key value : cache value
[ "Set", "key", "value", "to", "the", "file", "." ]
fa47fe2e92915fc58db38898213e974742af55d4
https://github.com/roanuz/py-cricket/blob/fa47fe2e92915fc58db38898213e974742af55d4/src/pycricket_storagehandler.py#L56-L73
train
roanuz/py-cricket
src/pycricket_storagehandler.py
RcaFileStorageHandler.delete_value
def delete_value(self, key): """ Delete the key if the token is expired. Arg: key : cache key """ response = {} response['status'] = False response['msg'] = "key does not exist" file_cache = self.read_file() if key in file_cache: ...
python
def delete_value(self, key): """ Delete the key if the token is expired. Arg: key : cache key """ response = {} response['status'] = False response['msg'] = "key does not exist" file_cache = self.read_file() if key in file_cache: ...
[ "def", "delete_value", "(", "self", ",", "key", ")", ":", "response", "=", "{", "}", "response", "[", "'status'", "]", "=", "False", "response", "[", "'msg'", "]", "=", "\"key does not exist\"", "file_cache", "=", "self", ".", "read_file", "(", ")", "if"...
Delete the key if the token is expired. Arg: key : cache key
[ "Delete", "the", "key", "if", "the", "token", "is", "expired", "." ]
fa47fe2e92915fc58db38898213e974742af55d4
https://github.com/roanuz/py-cricket/blob/fa47fe2e92915fc58db38898213e974742af55d4/src/pycricket_storagehandler.py#L101-L118
train
roanuz/py-cricket
src/pycricket_storagehandler.py
RcaFileStorageHandler.read_file
def read_file(self): """ Open the file and assiging the permission to read/write and return the content in json formate. Return : json data """ file_obj = open(self.file, 'r') content = file_obj.read() file_obj.close() if content: cont...
python
def read_file(self): """ Open the file and assiging the permission to read/write and return the content in json formate. Return : json data """ file_obj = open(self.file, 'r') content = file_obj.read() file_obj.close() if content: cont...
[ "def", "read_file", "(", "self", ")", ":", "file_obj", "=", "open", "(", "self", ".", "file", ",", "'r'", ")", "content", "=", "file_obj", ".", "read", "(", ")", "file_obj", ".", "close", "(", ")", "if", "content", ":", "content", "=", "json", ".",...
Open the file and assiging the permission to read/write and return the content in json formate. Return : json data
[ "Open", "the", "file", "and", "assiging", "the", "permission", "to", "read", "/", "write", "and", "return", "the", "content", "in", "json", "formate", "." ]
fa47fe2e92915fc58db38898213e974742af55d4
https://github.com/roanuz/py-cricket/blob/fa47fe2e92915fc58db38898213e974742af55d4/src/pycricket_storagehandler.py#L128-L142
train
roanuz/py-cricket
src/pycricket_storagehandler.py
RcaFileStorageHandler.update_file
def update_file(self, content): """ It will convert json content to json string and update into file. Return: Boolean True/False """ updated_content = json.dumps(content) file_obj = open(self.file, 'r+') file_obj.write(str(updated_content)) file_o...
python
def update_file(self, content): """ It will convert json content to json string and update into file. Return: Boolean True/False """ updated_content = json.dumps(content) file_obj = open(self.file, 'r+') file_obj.write(str(updated_content)) file_o...
[ "def", "update_file", "(", "self", ",", "content", ")", ":", "updated_content", "=", "json", ".", "dumps", "(", "content", ")", "file_obj", "=", "open", "(", "self", ".", "file", ",", "'r+'", ")", "file_obj", ".", "write", "(", "str", "(", "updated_con...
It will convert json content to json string and update into file. Return: Boolean True/False
[ "It", "will", "convert", "json", "content", "to", "json", "string", "and", "update", "into", "file", "." ]
fa47fe2e92915fc58db38898213e974742af55d4
https://github.com/roanuz/py-cricket/blob/fa47fe2e92915fc58db38898213e974742af55d4/src/pycricket_storagehandler.py#L144-L155
train
refindlyllc/rets
rets/parsers/metadata.py
CompactMetadata.parse
def parse(self, response, metadata_type): """ Parses RETS metadata using the COMPACT-DECODED format :param response: :param metadata_type: :return: """ xml = xmltodict.parse(response.text) self.analyze_reply_code(xml_response_dict=xml) base = xml.g...
python
def parse(self, response, metadata_type): """ Parses RETS metadata using the COMPACT-DECODED format :param response: :param metadata_type: :return: """ xml = xmltodict.parse(response.text) self.analyze_reply_code(xml_response_dict=xml) base = xml.g...
[ "def", "parse", "(", "self", ",", "response", ",", "metadata_type", ")", ":", "xml", "=", "xmltodict", ".", "parse", "(", "response", ".", "text", ")", "self", ".", "analyze_reply_code", "(", "xml_response_dict", "=", "xml", ")", "base", "=", "xml", ".",...
Parses RETS metadata using the COMPACT-DECODED format :param response: :param metadata_type: :return:
[ "Parses", "RETS", "metadata", "using", "the", "COMPACT", "-", "DECODED", "format", ":", "param", "response", ":", ":", "param", "metadata_type", ":", ":", "return", ":" ]
c615dfc272cff0825fd3b50863c46afc3e33916f
https://github.com/refindlyllc/rets/blob/c615dfc272cff0825fd3b50863c46afc3e33916f/rets/parsers/metadata.py#L14-L56
train
refindlyllc/rets
rets/parsers/metadata.py
StandardXMLetadata.parse
def parse(self, response, metadata_type): """ Parses RETS metadata using the STANDARD-XML format :param response: requests Response object :param metadata_type: string :return parsed: list """ xml = xmltodict.parse(response.text) self.analyze_reply_code(xm...
python
def parse(self, response, metadata_type): """ Parses RETS metadata using the STANDARD-XML format :param response: requests Response object :param metadata_type: string :return parsed: list """ xml = xmltodict.parse(response.text) self.analyze_reply_code(xm...
[ "def", "parse", "(", "self", ",", "response", ",", "metadata_type", ")", ":", "xml", "=", "xmltodict", ".", "parse", "(", "response", ".", "text", ")", "self", ".", "analyze_reply_code", "(", "xml_response_dict", "=", "xml", ")", "base", "=", "xml", ".",...
Parses RETS metadata using the STANDARD-XML format :param response: requests Response object :param metadata_type: string :return parsed: list
[ "Parses", "RETS", "metadata", "using", "the", "STANDARD", "-", "XML", "format", ":", "param", "response", ":", "requests", "Response", "object", ":", "param", "metadata_type", ":", "string", ":", "return", "parsed", ":", "list" ]
c615dfc272cff0825fd3b50863c46afc3e33916f
https://github.com/refindlyllc/rets/blob/c615dfc272cff0825fd3b50863c46afc3e33916f/rets/parsers/metadata.py#L62-L116
train
refindlyllc/rets
rets/parsers/get_object.py
MultipleObjectParser._get_multiparts
def _get_multiparts(response): """ From this 'multipart/parallel; boundary="874e43d27ec6d83f30f37841bdaf90c7"; charset=utf-8' get this --874e43d27ec6d83f30f37841bdaf90c7 """ boundary = None for part in response.headers.get('Content-Type', '').split(';'): ...
python
def _get_multiparts(response): """ From this 'multipart/parallel; boundary="874e43d27ec6d83f30f37841bdaf90c7"; charset=utf-8' get this --874e43d27ec6d83f30f37841bdaf90c7 """ boundary = None for part in response.headers.get('Content-Type', '').split(';'): ...
[ "def", "_get_multiparts", "(", "response", ")", ":", "boundary", "=", "None", "for", "part", "in", "response", ".", "headers", ".", "get", "(", "'Content-Type'", ",", "''", ")", ".", "split", "(", "';'", ")", ":", "if", "'boundary='", "in", "part", ":"...
From this 'multipart/parallel; boundary="874e43d27ec6d83f30f37841bdaf90c7"; charset=utf-8' get this --874e43d27ec6d83f30f37841bdaf90c7
[ "From", "this", "multipart", "/", "parallel", ";", "boundary", "=", "874e43d27ec6d83f30f37841bdaf90c7", ";", "charset", "=", "utf", "-", "8", "get", "this", "--", "874e43d27ec6d83f30f37841bdaf90c7" ]
c615dfc272cff0825fd3b50863c46afc3e33916f
https://github.com/refindlyllc/rets/blob/c615dfc272cff0825fd3b50863c46afc3e33916f/rets/parsers/get_object.py#L39-L73
train
refindlyllc/rets
rets/parsers/get_object.py
MultipleObjectParser.parse_image_response
def parse_image_response(self, response): """ Parse multiple objects from the RETS feed. A lot of string methods are used to handle the response before encoding it back into bytes for the object. :param response: The response from the feed :return: list of SingleObjectParser ...
python
def parse_image_response(self, response): """ Parse multiple objects from the RETS feed. A lot of string methods are used to handle the response before encoding it back into bytes for the object. :param response: The response from the feed :return: list of SingleObjectParser ...
[ "def", "parse_image_response", "(", "self", ",", "response", ")", ":", "if", "'xml'", "in", "response", ".", "headers", ".", "get", "(", "'Content-Type'", ")", ":", "# Got an XML response, likely an error code.", "xml", "=", "xmltodict", ".", "parse", "(", "resp...
Parse multiple objects from the RETS feed. A lot of string methods are used to handle the response before encoding it back into bytes for the object. :param response: The response from the feed :return: list of SingleObjectParser
[ "Parse", "multiple", "objects", "from", "the", "RETS", "feed", ".", "A", "lot", "of", "string", "methods", "are", "used", "to", "handle", "the", "response", "before", "encoding", "it", "back", "into", "bytes", "for", "the", "object", ".", ":", "param", "...
c615dfc272cff0825fd3b50863c46afc3e33916f
https://github.com/refindlyllc/rets/blob/c615dfc272cff0825fd3b50863c46afc3e33916f/rets/parsers/get_object.py#L75-L120
train
refindlyllc/rets
rets/parsers/get_object.py
SingleObjectParser.parse_image_response
def parse_image_response(self, response): """ Parse a single object from the RETS feed :param response: The response from the RETS server :return: Object """ if 'xml' in response.headers.get('Content-Type'): # Got an XML response, likely an error code. ...
python
def parse_image_response(self, response): """ Parse a single object from the RETS feed :param response: The response from the RETS server :return: Object """ if 'xml' in response.headers.get('Content-Type'): # Got an XML response, likely an error code. ...
[ "def", "parse_image_response", "(", "self", ",", "response", ")", ":", "if", "'xml'", "in", "response", ".", "headers", ".", "get", "(", "'Content-Type'", ")", ":", "# Got an XML response, likely an error code.", "xml", "=", "xmltodict", ".", "parse", "(", "resp...
Parse a single object from the RETS feed :param response: The response from the RETS server :return: Object
[ "Parse", "a", "single", "object", "from", "the", "RETS", "feed", ":", "param", "response", ":", "The", "response", "from", "the", "RETS", "server", ":", "return", ":", "Object" ]
c615dfc272cff0825fd3b50863c46afc3e33916f
https://github.com/refindlyllc/rets/blob/c615dfc272cff0825fd3b50863c46afc3e33916f/rets/parsers/get_object.py#L125-L139
train
roanuz/py-cricket
src/pycricket.py
RcaApp.auth
def auth(self): """ Auth is used to call the AUTH API of CricketAPI. Access token required for every request call to CricketAPI. Auth functional will post user Cricket API app details to server and return the access token. Return: Access token ...
python
def auth(self): """ Auth is used to call the AUTH API of CricketAPI. Access token required for every request call to CricketAPI. Auth functional will post user Cricket API app details to server and return the access token. Return: Access token ...
[ "def", "auth", "(", "self", ")", ":", "if", "not", "self", ".", "store_handler", ".", "has_value", "(", "'access_token'", ")", ":", "params", "=", "{", "}", "params", "[", "\"access_key\"", "]", "=", "self", ".", "access_key", "params", "[", "\"secret_ke...
Auth is used to call the AUTH API of CricketAPI. Access token required for every request call to CricketAPI. Auth functional will post user Cricket API app details to server and return the access token. Return: Access token
[ "Auth", "is", "used", "to", "call", "the", "AUTH", "API", "of", "CricketAPI", ".", "Access", "token", "required", "for", "every", "request", "call", "to", "CricketAPI", ".", "Auth", "functional", "will", "post", "user", "Cricket", "API", "app", "details", ...
fa47fe2e92915fc58db38898213e974742af55d4
https://github.com/roanuz/py-cricket/blob/fa47fe2e92915fc58db38898213e974742af55d4/src/pycricket.py#L89-L117
train
roanuz/py-cricket
src/pycricket.py
RcaApp.get_response
def get_response(self, url, params={}, method="get"): """ It will return json response based on given url, params and methods. Arg: params: 'dictionary' url: 'url' format method: default 'get', support method 'post' Return: json data ...
python
def get_response(self, url, params={}, method="get"): """ It will return json response based on given url, params and methods. Arg: params: 'dictionary' url: 'url' format method: default 'get', support method 'post' Return: json data ...
[ "def", "get_response", "(", "self", ",", "url", ",", "params", "=", "{", "}", ",", "method", "=", "\"get\"", ")", ":", "if", "method", "==", "\"post\"", ":", "response_data", "=", "json", ".", "loads", "(", "requests", ".", "post", "(", "url", ",", ...
It will return json response based on given url, params and methods. Arg: params: 'dictionary' url: 'url' format method: default 'get', support method 'post' Return: json data
[ "It", "will", "return", "json", "response", "based", "on", "given", "url", "params", "and", "methods", ".", "Arg", ":", "params", ":", "dictionary", "url", ":", "url", "format", "method", ":", "default", "get", "support", "method", "post", "Return", ":", ...
fa47fe2e92915fc58db38898213e974742af55d4
https://github.com/roanuz/py-cricket/blob/fa47fe2e92915fc58db38898213e974742af55d4/src/pycricket.py#L119-L144
train
roanuz/py-cricket
src/pycricket.py
RcaApp.get_active_token
def get_active_token(self): """ Getting the valid access token. Access token expires every 24 hours, It will expires then it will generate a new token. Return: active access token """ expire_time = self.store_handler.has_value("expires") ...
python
def get_active_token(self): """ Getting the valid access token. Access token expires every 24 hours, It will expires then it will generate a new token. Return: active access token """ expire_time = self.store_handler.has_value("expires") ...
[ "def", "get_active_token", "(", "self", ")", ":", "expire_time", "=", "self", ".", "store_handler", ".", "has_value", "(", "\"expires\"", ")", "access_token", "=", "self", ".", "store_handler", ".", "has_value", "(", "\"access_token\"", ")", "if", "expire_time",...
Getting the valid access token. Access token expires every 24 hours, It will expires then it will generate a new token. Return: active access token
[ "Getting", "the", "valid", "access", "token", "." ]
fa47fe2e92915fc58db38898213e974742af55d4
https://github.com/roanuz/py-cricket/blob/fa47fe2e92915fc58db38898213e974742af55d4/src/pycricket.py#L146-L169
train
roanuz/py-cricket
src/pycricket.py
RcaApp.get_match
def get_match(self, match_key, card_type="full_card"): """ Calling the Match API. Arg: match_key: key of the match card_type: optional, default to full_card. Accepted values are micro_card, summary_card & full_card. Return: json data ...
python
def get_match(self, match_key, card_type="full_card"): """ Calling the Match API. Arg: match_key: key of the match card_type: optional, default to full_card. Accepted values are micro_card, summary_card & full_card. Return: json data ...
[ "def", "get_match", "(", "self", ",", "match_key", ",", "card_type", "=", "\"full_card\"", ")", ":", "match_url", "=", "self", ".", "api_path", "+", "\"match/\"", "+", "match_key", "+", "\"/\"", "params", "=", "{", "}", "params", "[", "\"card_type\"", "]",...
Calling the Match API. Arg: match_key: key of the match card_type: optional, default to full_card. Accepted values are micro_card, summary_card & full_card. Return: json data
[ "Calling", "the", "Match", "API", ".", "Arg", ":", "match_key", ":", "key", "of", "the", "match", "card_type", ":", "optional", "default", "to", "full_card", ".", "Accepted", "values", "are", "micro_card", "summary_card", "&", "full_card", ".", "Return", ":"...
fa47fe2e92915fc58db38898213e974742af55d4
https://github.com/roanuz/py-cricket/blob/fa47fe2e92915fc58db38898213e974742af55d4/src/pycricket.py#L171-L187
train
roanuz/py-cricket
src/pycricket.py
RcaApp.get_recent_matches
def get_recent_matches(self, card_type="micro_card"): """ Calling the Recent Matches API. Arg: card_type: optional, default to micro_card. Accepted values are micro_card & summary_card. Return: json data """ recent_matches_url = self.api...
python
def get_recent_matches(self, card_type="micro_card"): """ Calling the Recent Matches API. Arg: card_type: optional, default to micro_card. Accepted values are micro_card & summary_card. Return: json data """ recent_matches_url = self.api...
[ "def", "get_recent_matches", "(", "self", ",", "card_type", "=", "\"micro_card\"", ")", ":", "recent_matches_url", "=", "self", ".", "api_path", "+", "\"recent_matches/\"", "params", "=", "{", "}", "params", "[", "\"card_type\"", "]", "=", "card_type", "response...
Calling the Recent Matches API. Arg: card_type: optional, default to micro_card. Accepted values are micro_card & summary_card. Return: json data
[ "Calling", "the", "Recent", "Matches", "API", "." ]
fa47fe2e92915fc58db38898213e974742af55d4
https://github.com/roanuz/py-cricket/blob/fa47fe2e92915fc58db38898213e974742af55d4/src/pycricket.py#L189-L204
train
roanuz/py-cricket
src/pycricket.py
RcaApp.get_player_stats
def get_player_stats(self, player_key, board_key): """ Calling the Player Stats API Args: player_key: Key of the player board_key: key of the board Return: json data """ player_stats_url = self.api_path + 'player/' + player_key + '/leag...
python
def get_player_stats(self, player_key, board_key): """ Calling the Player Stats API Args: player_key: Key of the player board_key: key of the board Return: json data """ player_stats_url = self.api_path + 'player/' + player_key + '/leag...
[ "def", "get_player_stats", "(", "self", ",", "player_key", ",", "board_key", ")", ":", "player_stats_url", "=", "self", ".", "api_path", "+", "'player/'", "+", "player_key", "+", "'/league/'", "+", "board_key", "+", "'/stats/'", "response", "=", "self", ".", ...
Calling the Player Stats API Args: player_key: Key of the player board_key: key of the board Return: json data
[ "Calling", "the", "Player", "Stats", "API", "Args", ":", "player_key", ":", "Key", "of", "the", "player", "board_key", ":", "key", "of", "the", "board", "Return", ":", "json", "data" ]
fa47fe2e92915fc58db38898213e974742af55d4
https://github.com/roanuz/py-cricket/blob/fa47fe2e92915fc58db38898213e974742af55d4/src/pycricket.py#L206-L217
train
roanuz/py-cricket
src/pycricket.py
RcaApp.get_ball_by_ball
def get_ball_by_ball(self, match_key, over_key=None): """ match_key: key of the match over_key : key of the over Return: json data: """ if over_key: ball_by_ball_url = "{base_path}match/{match_key}/balls/{over_key}/".format(base_path=self....
python
def get_ball_by_ball(self, match_key, over_key=None): """ match_key: key of the match over_key : key of the over Return: json data: """ if over_key: ball_by_ball_url = "{base_path}match/{match_key}/balls/{over_key}/".format(base_path=self....
[ "def", "get_ball_by_ball", "(", "self", ",", "match_key", ",", "over_key", "=", "None", ")", ":", "if", "over_key", ":", "ball_by_ball_url", "=", "\"{base_path}match/{match_key}/balls/{over_key}/\"", ".", "format", "(", "base_path", "=", "self", ".", "api_path", "...
match_key: key of the match over_key : key of the over Return: json data:
[ "match_key", ":", "key", "of", "the", "match", "over_key", ":", "key", "of", "the", "over", "Return", ":", "json", "data", ":" ]
fa47fe2e92915fc58db38898213e974742af55d4
https://github.com/roanuz/py-cricket/blob/fa47fe2e92915fc58db38898213e974742af55d4/src/pycricket.py#L219-L233
train
roanuz/py-cricket
src/pycricket.py
RcaApp.get_recent_season_matches
def get_recent_season_matches(self, season_key): """ Calling specific season recent matches. Arg: season_key: key of the season. Return: json date """ season_recent_matches_url = self.api_path + "season/" + season_key + "/recent_matches/" r...
python
def get_recent_season_matches(self, season_key): """ Calling specific season recent matches. Arg: season_key: key of the season. Return: json date """ season_recent_matches_url = self.api_path + "season/" + season_key + "/recent_matches/" r...
[ "def", "get_recent_season_matches", "(", "self", ",", "season_key", ")", ":", "season_recent_matches_url", "=", "self", ".", "api_path", "+", "\"season/\"", "+", "season_key", "+", "\"/recent_matches/\"", "response", "=", "self", ".", "get_response", "(", "season_re...
Calling specific season recent matches. Arg: season_key: key of the season. Return: json date
[ "Calling", "specific", "season", "recent", "matches", "." ]
fa47fe2e92915fc58db38898213e974742af55d4
https://github.com/roanuz/py-cricket/blob/fa47fe2e92915fc58db38898213e974742af55d4/src/pycricket.py#L235-L247
train
roanuz/py-cricket
src/pycricket.py
RcaApp.get_recent_seasons
def get_recent_seasons(self): """ Calling the Recent Season API. Return: json data """ recent_seasons_url = self.api_path + "recent_seasons/" response = self.get_response(recent_seasons_url) return response
python
def get_recent_seasons(self): """ Calling the Recent Season API. Return: json data """ recent_seasons_url = self.api_path + "recent_seasons/" response = self.get_response(recent_seasons_url) return response
[ "def", "get_recent_seasons", "(", "self", ")", ":", "recent_seasons_url", "=", "self", ".", "api_path", "+", "\"recent_seasons/\"", "response", "=", "self", ".", "get_response", "(", "recent_seasons_url", ")", "return", "response" ]
Calling the Recent Season API. Return: json data
[ "Calling", "the", "Recent", "Season", "API", "." ]
fa47fe2e92915fc58db38898213e974742af55d4
https://github.com/roanuz/py-cricket/blob/fa47fe2e92915fc58db38898213e974742af55d4/src/pycricket.py#L249-L259
train
roanuz/py-cricket
src/pycricket.py
RcaApp.get_schedule
def get_schedule(self, date=None): """ Calling the Schedule API. Return: json data """ schedule_url = self.api_path + "schedule/" params = {} if date: params['date'] = date response = self.get_response(schedule_url, params) ...
python
def get_schedule(self, date=None): """ Calling the Schedule API. Return: json data """ schedule_url = self.api_path + "schedule/" params = {} if date: params['date'] = date response = self.get_response(schedule_url, params) ...
[ "def", "get_schedule", "(", "self", ",", "date", "=", "None", ")", ":", "schedule_url", "=", "self", ".", "api_path", "+", "\"schedule/\"", "params", "=", "{", "}", "if", "date", ":", "params", "[", "'date'", "]", "=", "date", "response", "=", "self", ...
Calling the Schedule API. Return: json data
[ "Calling", "the", "Schedule", "API", "." ]
fa47fe2e92915fc58db38898213e974742af55d4
https://github.com/roanuz/py-cricket/blob/fa47fe2e92915fc58db38898213e974742af55d4/src/pycricket.py#L261-L274
train
roanuz/py-cricket
src/pycricket.py
RcaApp.get_season_schedule
def get_season_schedule(self, season_key): """ Calling specific season schedule Arg: season_key: key of the season Return: json data """ schedule_url = self.api_path + "season/" + season_key + "/schedule/" response = self.get_response(sched...
python
def get_season_schedule(self, season_key): """ Calling specific season schedule Arg: season_key: key of the season Return: json data """ schedule_url = self.api_path + "season/" + season_key + "/schedule/" response = self.get_response(sched...
[ "def", "get_season_schedule", "(", "self", ",", "season_key", ")", ":", "schedule_url", "=", "self", ".", "api_path", "+", "\"season/\"", "+", "season_key", "+", "\"/schedule/\"", "response", "=", "self", ".", "get_response", "(", "schedule_url", ")", "return", ...
Calling specific season schedule Arg: season_key: key of the season Return: json data
[ "Calling", "specific", "season", "schedule" ]
fa47fe2e92915fc58db38898213e974742af55d4
https://github.com/roanuz/py-cricket/blob/fa47fe2e92915fc58db38898213e974742af55d4/src/pycricket.py#L276-L288
train
roanuz/py-cricket
src/pycricket.py
RcaApp.get_season
def get_season(self, season_key, card_type="micro_card"): """ Calling Season API. Arg: season_key: key of the season card_type: optional, default to micro_card. Accepted values are micro_card & summary_card Return: json data """ ...
python
def get_season(self, season_key, card_type="micro_card"): """ Calling Season API. Arg: season_key: key of the season card_type: optional, default to micro_card. Accepted values are micro_card & summary_card Return: json data """ ...
[ "def", "get_season", "(", "self", ",", "season_key", ",", "card_type", "=", "\"micro_card\"", ")", ":", "season_url", "=", "self", ".", "api_path", "+", "\"season/\"", "+", "season_key", "+", "\"/\"", "params", "=", "{", "}", "params", "[", "\"card_type\"", ...
Calling Season API. Arg: season_key: key of the season card_type: optional, default to micro_card. Accepted values are micro_card & summary_card Return: json data
[ "Calling", "Season", "API", "." ]
fa47fe2e92915fc58db38898213e974742af55d4
https://github.com/roanuz/py-cricket/blob/fa47fe2e92915fc58db38898213e974742af55d4/src/pycricket.py#L290-L306
train
roanuz/py-cricket
src/pycricket.py
RcaApp.get_season_stats
def get_season_stats(self, season_key): """ Calling Season Stats API. Arg: season_key: key of the season Return: json data """ season_stats_url = self.api_path + "season/" + season_key + "/stats/" response = self.get_response(season_stats_u...
python
def get_season_stats(self, season_key): """ Calling Season Stats API. Arg: season_key: key of the season Return: json data """ season_stats_url = self.api_path + "season/" + season_key + "/stats/" response = self.get_response(season_stats_u...
[ "def", "get_season_stats", "(", "self", ",", "season_key", ")", ":", "season_stats_url", "=", "self", ".", "api_path", "+", "\"season/\"", "+", "season_key", "+", "\"/stats/\"", "response", "=", "self", ".", "get_response", "(", "season_stats_url", ")", "return"...
Calling Season Stats API. Arg: season_key: key of the season Return: json data
[ "Calling", "Season", "Stats", "API", "." ]
fa47fe2e92915fc58db38898213e974742af55d4
https://github.com/roanuz/py-cricket/blob/fa47fe2e92915fc58db38898213e974742af55d4/src/pycricket.py#L308-L320
train
roanuz/py-cricket
src/pycricket.py
RcaApp.get_season_team
def get_season_team(self, season_key, season_team_key,stats_type=None): """ Calling Season teams API Arg: season_key: key of the season Return: json data """ params = {"stats_type": stats_type} season_team_url = self.api_path + 'season/' +...
python
def get_season_team(self, season_key, season_team_key,stats_type=None): """ Calling Season teams API Arg: season_key: key of the season Return: json data """ params = {"stats_type": stats_type} season_team_url = self.api_path + 'season/' +...
[ "def", "get_season_team", "(", "self", ",", "season_key", ",", "season_team_key", ",", "stats_type", "=", "None", ")", ":", "params", "=", "{", "\"stats_type\"", ":", "stats_type", "}", "season_team_url", "=", "self", ".", "api_path", "+", "'season/'", "+", ...
Calling Season teams API Arg: season_key: key of the season Return: json data
[ "Calling", "Season", "teams", "API" ]
fa47fe2e92915fc58db38898213e974742af55d4
https://github.com/roanuz/py-cricket/blob/fa47fe2e92915fc58db38898213e974742af55d4/src/pycricket.py#L322-L334
train
roanuz/py-cricket
src/pycricket.py
RcaApp.get_season_points
def get_season_points(self, season_key): """ Calling Season Points API. Arg: season_key: key of the season Return: json data """ season_points_url = self.api_path + "season/" + season_key + "/points/" response = self.get_response(season_poi...
python
def get_season_points(self, season_key): """ Calling Season Points API. Arg: season_key: key of the season Return: json data """ season_points_url = self.api_path + "season/" + season_key + "/points/" response = self.get_response(season_poi...
[ "def", "get_season_points", "(", "self", ",", "season_key", ")", ":", "season_points_url", "=", "self", ".", "api_path", "+", "\"season/\"", "+", "season_key", "+", "\"/points/\"", "response", "=", "self", ".", "get_response", "(", "season_points_url", ")", "ret...
Calling Season Points API. Arg: season_key: key of the season Return: json data
[ "Calling", "Season", "Points", "API", "." ]
fa47fe2e92915fc58db38898213e974742af55d4
https://github.com/roanuz/py-cricket/blob/fa47fe2e92915fc58db38898213e974742af55d4/src/pycricket.py#L336-L348
train
roanuz/py-cricket
src/pycricket.py
RcaApp.get_season_player_stats
def get_season_player_stats(self, season_key, player_key): """ Calling Season Player Stats API. Arg: season_key: key of the season player_key: key of the player Return: json data """ season_player_stats_url = self.api_path + "season/" + ...
python
def get_season_player_stats(self, season_key, player_key): """ Calling Season Player Stats API. Arg: season_key: key of the season player_key: key of the player Return: json data """ season_player_stats_url = self.api_path + "season/" + ...
[ "def", "get_season_player_stats", "(", "self", ",", "season_key", ",", "player_key", ")", ":", "season_player_stats_url", "=", "self", ".", "api_path", "+", "\"season/\"", "+", "season_key", "+", "\"/player/\"", "+", "player_key", "+", "\"/stats/\"", "response", "...
Calling Season Player Stats API. Arg: season_key: key of the season player_key: key of the player Return: json data
[ "Calling", "Season", "Player", "Stats", "API", "." ]
fa47fe2e92915fc58db38898213e974742af55d4
https://github.com/roanuz/py-cricket/blob/fa47fe2e92915fc58db38898213e974742af55d4/src/pycricket.py#L350-L363
train
roanuz/py-cricket
src/pycricket.py
RcaApp.get_overs_summary
def get_overs_summary(self, match_key): """ Calling Overs Summary API Arg: match_key: key of the match Return: json data """ overs_summary_url = self.api_path + "match/" + match_key + "/overs_summary/" response = self.get_response(overs_summ...
python
def get_overs_summary(self, match_key): """ Calling Overs Summary API Arg: match_key: key of the match Return: json data """ overs_summary_url = self.api_path + "match/" + match_key + "/overs_summary/" response = self.get_response(overs_summ...
[ "def", "get_overs_summary", "(", "self", ",", "match_key", ")", ":", "overs_summary_url", "=", "self", ".", "api_path", "+", "\"match/\"", "+", "match_key", "+", "\"/overs_summary/\"", "response", "=", "self", ".", "get_response", "(", "overs_summary_url", ")", ...
Calling Overs Summary API Arg: match_key: key of the match Return: json data
[ "Calling", "Overs", "Summary", "API" ]
fa47fe2e92915fc58db38898213e974742af55d4
https://github.com/roanuz/py-cricket/blob/fa47fe2e92915fc58db38898213e974742af55d4/src/pycricket.py#L365-L376
train
roanuz/py-cricket
src/pycricket.py
RcaApp.get_news_aggregation
def get_news_aggregation(self): """ Calling News Aggregation API Return: json data """ news_aggregation_url = self.api_path + "news_aggregation" + "/" response = self.get_response(news_aggregation_url) return response
python
def get_news_aggregation(self): """ Calling News Aggregation API Return: json data """ news_aggregation_url = self.api_path + "news_aggregation" + "/" response = self.get_response(news_aggregation_url) return response
[ "def", "get_news_aggregation", "(", "self", ")", ":", "news_aggregation_url", "=", "self", ".", "api_path", "+", "\"news_aggregation\"", "+", "\"/\"", "response", "=", "self", ".", "get_response", "(", "news_aggregation_url", ")", "return", "response" ]
Calling News Aggregation API Return: json data
[ "Calling", "News", "Aggregation", "API" ]
fa47fe2e92915fc58db38898213e974742af55d4
https://github.com/roanuz/py-cricket/blob/fa47fe2e92915fc58db38898213e974742af55d4/src/pycricket.py#L378-L388
train
roanuz/py-cricket
src/pycricket.py
RcaApp.get_fantasy_credits
def get_fantasy_credits(self, match_key): """ Calling Fantasy Credit API Arg: match_key: key of the match Return: json data """ fantasy_credit_url = self.api_path_v3 + "fantasy-match-credits/" + match_key + "/" response = self.get_respons...
python
def get_fantasy_credits(self, match_key): """ Calling Fantasy Credit API Arg: match_key: key of the match Return: json data """ fantasy_credit_url = self.api_path_v3 + "fantasy-match-credits/" + match_key + "/" response = self.get_respons...
[ "def", "get_fantasy_credits", "(", "self", ",", "match_key", ")", ":", "fantasy_credit_url", "=", "self", ".", "api_path_v3", "+", "\"fantasy-match-credits/\"", "+", "match_key", "+", "\"/\"", "response", "=", "self", ".", "get_response", "(", "fantasy_credit_url", ...
Calling Fantasy Credit API Arg: match_key: key of the match Return: json data
[ "Calling", "Fantasy", "Credit", "API" ]
fa47fe2e92915fc58db38898213e974742af55d4
https://github.com/roanuz/py-cricket/blob/fa47fe2e92915fc58db38898213e974742af55d4/src/pycricket.py#L390-L402
train
roanuz/py-cricket
src/pycricket.py
RcaApp.get_fantasy_points
def get_fantasy_points(self, match_key): """ Calling Fantasy Points API Arg: match_key: key of the match Return: json data """ fantasy_points_url = self.api_path_v3 + "fantasy-match-points/" + match_key + "/" response = self.get_response(...
python
def get_fantasy_points(self, match_key): """ Calling Fantasy Points API Arg: match_key: key of the match Return: json data """ fantasy_points_url = self.api_path_v3 + "fantasy-match-points/" + match_key + "/" response = self.get_response(...
[ "def", "get_fantasy_points", "(", "self", ",", "match_key", ")", ":", "fantasy_points_url", "=", "self", ".", "api_path_v3", "+", "\"fantasy-match-points/\"", "+", "match_key", "+", "\"/\"", "response", "=", "self", ".", "get_response", "(", "fantasy_points_url", ...
Calling Fantasy Points API Arg: match_key: key of the match Return: json data
[ "Calling", "Fantasy", "Points", "API" ]
fa47fe2e92915fc58db38898213e974742af55d4
https://github.com/roanuz/py-cricket/blob/fa47fe2e92915fc58db38898213e974742af55d4/src/pycricket.py#L404-L416
train
HarveyHunt/i3situation
i3situation/plugins/reddit.py
RedditPlugin.main
def main(self): """ Generates an output string by replacing the keywords in the format string with the corresponding values from a submission dictionary. """ self.manage_submissions() out_string = self.options['format'] # Pop until we get something which len(titl...
python
def main(self): """ Generates an output string by replacing the keywords in the format string with the corresponding values from a submission dictionary. """ self.manage_submissions() out_string = self.options['format'] # Pop until we get something which len(titl...
[ "def", "main", "(", "self", ")", ":", "self", ".", "manage_submissions", "(", ")", "out_string", "=", "self", ".", "options", "[", "'format'", "]", "# Pop until we get something which len(title) <= max-chars", "length", "=", "float", "(", "'inf'", ")", "while", ...
Generates an output string by replacing the keywords in the format string with the corresponding values from a submission dictionary.
[ "Generates", "an", "output", "string", "by", "replacing", "the", "keywords", "in", "the", "format", "string", "with", "the", "corresponding", "values", "from", "a", "submission", "dictionary", "." ]
3160a21006fcc6961f240988874e228a5ec6f18e
https://github.com/HarveyHunt/i3situation/blob/3160a21006fcc6961f240988874e228a5ec6f18e/i3situation/plugins/reddit.py#L66-L82
train
HarveyHunt/i3situation
i3situation/plugins/reddit.py
RedditPlugin.login
def login(self): """ Logs into Reddit in order to display a personalised front page. """ data = {'user': self.options['username'], 'passwd': self.options['password'], 'api_type': 'json'} response = self.client.post('http://www.reddit.com/api/login', data=data) ...
python
def login(self): """ Logs into Reddit in order to display a personalised front page. """ data = {'user': self.options['username'], 'passwd': self.options['password'], 'api_type': 'json'} response = self.client.post('http://www.reddit.com/api/login', data=data) ...
[ "def", "login", "(", "self", ")", ":", "data", "=", "{", "'user'", ":", "self", ".", "options", "[", "'username'", "]", ",", "'passwd'", ":", "self", ".", "options", "[", "'password'", "]", ",", "'api_type'", ":", "'json'", "}", "response", "=", "sel...
Logs into Reddit in order to display a personalised front page.
[ "Logs", "into", "Reddit", "in", "order", "to", "display", "a", "personalised", "front", "page", "." ]
3160a21006fcc6961f240988874e228a5ec6f18e
https://github.com/HarveyHunt/i3situation/blob/3160a21006fcc6961f240988874e228a5ec6f18e/i3situation/plugins/reddit.py#L84-L91
train
HarveyHunt/i3situation
i3situation/plugins/reddit.py
RedditPlugin.manage_submissions
def manage_submissions(self): """ If there are no or only one submissions left, get new submissions. This function manages URL creation and the specifics for front page or subreddit mode. """ if not hasattr(self, 'submissions') or len(self.submissions) == 1: s...
python
def manage_submissions(self): """ If there are no or only one submissions left, get new submissions. This function manages URL creation and the specifics for front page or subreddit mode. """ if not hasattr(self, 'submissions') or len(self.submissions) == 1: s...
[ "def", "manage_submissions", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'submissions'", ")", "or", "len", "(", "self", ".", "submissions", ")", "==", "1", ":", "self", ".", "submissions", "=", "[", "]", "if", "self", ".", "opti...
If there are no or only one submissions left, get new submissions. This function manages URL creation and the specifics for front page or subreddit mode.
[ "If", "there", "are", "no", "or", "only", "one", "submissions", "left", "get", "new", "submissions", ".", "This", "function", "manages", "URL", "creation", "and", "the", "specifics", "for", "front", "page", "or", "subreddit", "mode", "." ]
3160a21006fcc6961f240988874e228a5ec6f18e
https://github.com/HarveyHunt/i3situation/blob/3160a21006fcc6961f240988874e228a5ec6f18e/i3situation/plugins/reddit.py#L93-L114
train
HarveyHunt/i3situation
i3situation/plugins/reddit.py
RedditPlugin.get_submissions
def get_submissions(self, url): """ Connects to Reddit and gets a JSON representation of submissions. This JSON data is then processed and returned. url: A url that requests for submissions should be sent to. """ response = self.client.get(url, params={'limit': self.opti...
python
def get_submissions(self, url): """ Connects to Reddit and gets a JSON representation of submissions. This JSON data is then processed and returned. url: A url that requests for submissions should be sent to. """ response = self.client.get(url, params={'limit': self.opti...
[ "def", "get_submissions", "(", "self", ",", "url", ")", ":", "response", "=", "self", ".", "client", ".", "get", "(", "url", ",", "params", "=", "{", "'limit'", ":", "self", ".", "options", "[", "'limit'", "]", "}", ")", "submissions", "=", "[", "x...
Connects to Reddit and gets a JSON representation of submissions. This JSON data is then processed and returned. url: A url that requests for submissions should be sent to.
[ "Connects", "to", "Reddit", "and", "gets", "a", "JSON", "representation", "of", "submissions", ".", "This", "JSON", "data", "is", "then", "processed", "and", "returned", "." ]
3160a21006fcc6961f240988874e228a5ec6f18e
https://github.com/HarveyHunt/i3situation/blob/3160a21006fcc6961f240988874e228a5ec6f18e/i3situation/plugins/reddit.py#L116-L125
train
HarveyHunt/i3situation
i3situation/plugins/cmus.py
CmusPlugin.main
def main(self): """ A compulsary function that gets the output of the cmus-remote -Q command and converts it to unicode in order for it to be processed and finally output. """ try: # Setting stderr to subprocess.STDOUT seems to stop the error # mes...
python
def main(self): """ A compulsary function that gets the output of the cmus-remote -Q command and converts it to unicode in order for it to be processed and finally output. """ try: # Setting stderr to subprocess.STDOUT seems to stop the error # mes...
[ "def", "main", "(", "self", ")", ":", "try", ":", "# Setting stderr to subprocess.STDOUT seems to stop the error", "# message returned by the process from being output to STDOUT.", "cmus_output", "=", "subprocess", ".", "check_output", "(", "[", "'cmus-remote'", ",", "'-Q'", ...
A compulsary function that gets the output of the cmus-remote -Q command and converts it to unicode in order for it to be processed and finally output.
[ "A", "compulsary", "function", "that", "gets", "the", "output", "of", "the", "cmus", "-", "remote", "-", "Q", "command", "and", "converts", "it", "to", "unicode", "in", "order", "for", "it", "to", "be", "processed", "and", "finally", "output", "." ]
3160a21006fcc6961f240988874e228a5ec6f18e
https://github.com/HarveyHunt/i3situation/blob/3160a21006fcc6961f240988874e228a5ec6f18e/i3situation/plugins/cmus.py#L44-L64
train
HarveyHunt/i3situation
i3situation/plugins/cmus.py
CmusPlugin.convert_cmus_output
def convert_cmus_output(self, cmus_output): """ Change the newline separated string of output data into a dictionary which can then be used to replace the strings in the config format. cmus_output: A string with information about cmus that is newline seperated. Running c...
python
def convert_cmus_output(self, cmus_output): """ Change the newline separated string of output data into a dictionary which can then be used to replace the strings in the config format. cmus_output: A string with information about cmus that is newline seperated. Running c...
[ "def", "convert_cmus_output", "(", "self", ",", "cmus_output", ")", ":", "cmus_output", "=", "cmus_output", ".", "split", "(", "'\\n'", ")", "cmus_output", "=", "[", "x", ".", "replace", "(", "'tag '", ",", "''", ")", "for", "x", "in", "cmus_output", "if...
Change the newline separated string of output data into a dictionary which can then be used to replace the strings in the config format. cmus_output: A string with information about cmus that is newline seperated. Running cmus-remote -Q in a terminal will show you what you're de...
[ "Change", "the", "newline", "separated", "string", "of", "output", "data", "into", "a", "dictionary", "which", "can", "then", "be", "used", "to", "replace", "the", "strings", "in", "the", "config", "format", "." ]
3160a21006fcc6961f240988874e228a5ec6f18e
https://github.com/HarveyHunt/i3situation/blob/3160a21006fcc6961f240988874e228a5ec6f18e/i3situation/plugins/cmus.py#L66-L84
train
HarveyHunt/i3situation
i3situation/plugins/cmus.py
CmusPlugin.convert_time
def convert_time(self, time): """ A helper function to convert seconds into hh:mm:ss for better readability. time: A string representing time in seconds. """ time_string = str(datetime.timedelta(seconds=int(time))) if time_string.split(':')[0] == '0': ...
python
def convert_time(self, time): """ A helper function to convert seconds into hh:mm:ss for better readability. time: A string representing time in seconds. """ time_string = str(datetime.timedelta(seconds=int(time))) if time_string.split(':')[0] == '0': ...
[ "def", "convert_time", "(", "self", ",", "time", ")", ":", "time_string", "=", "str", "(", "datetime", ".", "timedelta", "(", "seconds", "=", "int", "(", "time", ")", ")", ")", "if", "time_string", ".", "split", "(", "':'", ")", "[", "0", "]", "=="...
A helper function to convert seconds into hh:mm:ss for better readability. time: A string representing time in seconds.
[ "A", "helper", "function", "to", "convert", "seconds", "into", "hh", ":", "mm", ":", "ss", "for", "better", "readability", "." ]
3160a21006fcc6961f240988874e228a5ec6f18e
https://github.com/HarveyHunt/i3situation/blob/3160a21006fcc6961f240988874e228a5ec6f18e/i3situation/plugins/cmus.py#L86-L96
train
HarveyHunt/i3situation
i3situation/plugins/_plugin.py
Plugin.output
def output(self, full_text, short_text): """ Output all of the options and data for a segment. full_text: A string representing the data that should be output to i3bar. short_text: A more concise version of full_text, in case there is minimal room on the i3bar. """ ...
python
def output(self, full_text, short_text): """ Output all of the options and data for a segment. full_text: A string representing the data that should be output to i3bar. short_text: A more concise version of full_text, in case there is minimal room on the i3bar. """ ...
[ "def", "output", "(", "self", ",", "full_text", ",", "short_text", ")", ":", "full_text", "=", "full_text", ".", "replace", "(", "'\\n'", ",", "''", ")", "short_text", "=", "short_text", ".", "replace", "(", "'\\n'", ",", "''", ")", "self", ".", "outpu...
Output all of the options and data for a segment. full_text: A string representing the data that should be output to i3bar. short_text: A more concise version of full_text, in case there is minimal room on the i3bar.
[ "Output", "all", "of", "the", "options", "and", "data", "for", "a", "segment", "." ]
3160a21006fcc6961f240988874e228a5ec6f18e
https://github.com/HarveyHunt/i3situation/blob/3160a21006fcc6961f240988874e228a5ec6f18e/i3situation/plugins/_plugin.py#L29-L41
train
HarveyHunt/i3situation
i3situation/plugins/_plugin.py
Plugin.on_click
def on_click(self, event): """ A function that should be overwritten by a plugin that wishes to react to events, if it wants to perform any action other than running the supplied command related to a button. event: A dictionary passed from i3bar (after being decoded from JSON) ...
python
def on_click(self, event): """ A function that should be overwritten by a plugin that wishes to react to events, if it wants to perform any action other than running the supplied command related to a button. event: A dictionary passed from i3bar (after being decoded from JSON) ...
[ "def", "on_click", "(", "self", ",", "event", ")", ":", "if", "event", "[", "'button'", "]", "==", "1", "and", "'button1'", "in", "self", ".", "options", ":", "subprocess", ".", "call", "(", "self", ".", "options", "[", "'button1'", "]", ".", "split"...
A function that should be overwritten by a plugin that wishes to react to events, if it wants to perform any action other than running the supplied command related to a button. event: A dictionary passed from i3bar (after being decoded from JSON) that has the folowing format: e...
[ "A", "function", "that", "should", "be", "overwritten", "by", "a", "plugin", "that", "wishes", "to", "react", "to", "events", "if", "it", "wants", "to", "perform", "any", "action", "other", "than", "running", "the", "supplied", "command", "related", "to", ...
3160a21006fcc6961f240988874e228a5ec6f18e
https://github.com/HarveyHunt/i3situation/blob/3160a21006fcc6961f240988874e228a5ec6f18e/i3situation/plugins/_plugin.py#L43-L61
train
nephila/django-ckeditor-filebrowser-filer
ckeditor_filebrowser_filer/views.py
url_reverse
def url_reverse(request): """ Reverse the requested URL (passed via GET / POST as `url_name` parameter) :param request: Request object :return: The reversed path """ if request.method in ('GET', 'POST'): data = getattr(request, request.method) url_name = data.get('url_name') ...
python
def url_reverse(request): """ Reverse the requested URL (passed via GET / POST as `url_name` parameter) :param request: Request object :return: The reversed path """ if request.method in ('GET', 'POST'): data = getattr(request, request.method) url_name = data.get('url_name') ...
[ "def", "url_reverse", "(", "request", ")", ":", "if", "request", ".", "method", "in", "(", "'GET'", ",", "'POST'", ")", ":", "data", "=", "getattr", "(", "request", ",", "request", ".", "method", ")", "url_name", "=", "data", ".", "get", "(", "'url_n...
Reverse the requested URL (passed via GET / POST as `url_name` parameter) :param request: Request object :return: The reversed path
[ "Reverse", "the", "requested", "URL", "(", "passed", "via", "GET", "/", "POST", "as", "url_name", "parameter", ")" ]
336ea259fbc6f9d338e3798375299f654a4d6995
https://github.com/nephila/django-ckeditor-filebrowser-filer/blob/336ea259fbc6f9d338e3798375299f654a4d6995/ckeditor_filebrowser_filer/views.py#L41-L57
train
nephila/django-ckeditor-filebrowser-filer
ckeditor_filebrowser_filer/views.py
url_image
def url_image(request, image_id, thumb_options=None, width=None, height=None): """ Converts a filer image ID in a complete path :param request: Request object :param image_id: Filer image ID :param thumb_options: ThumbnailOption ID :param width: user-provided width :param height: user-provi...
python
def url_image(request, image_id, thumb_options=None, width=None, height=None): """ Converts a filer image ID in a complete path :param request: Request object :param image_id: Filer image ID :param thumb_options: ThumbnailOption ID :param width: user-provided width :param height: user-provi...
[ "def", "url_image", "(", "request", ",", "image_id", ",", "thumb_options", "=", "None", ",", "width", "=", "None", ",", "height", "=", "None", ")", ":", "image", "=", "File", ".", "objects", ".", "get", "(", "pk", "=", "image_id", ")", "if", "getattr...
Converts a filer image ID in a complete path :param request: Request object :param image_id: Filer image ID :param thumb_options: ThumbnailOption ID :param width: user-provided width :param height: user-provided height :return: JSON serialized URL components ('url', 'width', 'height')
[ "Converts", "a", "filer", "image", "ID", "in", "a", "complete", "path" ]
336ea259fbc6f9d338e3798375299f654a4d6995
https://github.com/nephila/django-ckeditor-filebrowser-filer/blob/336ea259fbc6f9d338e3798375299f654a4d6995/ckeditor_filebrowser_filer/views.py#L79-L104
train
nephila/django-ckeditor-filebrowser-filer
ckeditor_filebrowser_filer/views.py
thumbnail_options
def thumbnail_options(request): """ Returns the requested ThumbnailOption as JSON :param request: Request object :return: JSON serialized ThumbnailOption """ response_data = [{'id': opt.pk, 'name': opt.name} for opt in ThumbnailOption.objects.all()] return http.HttpResponse(json.dumps(respo...
python
def thumbnail_options(request): """ Returns the requested ThumbnailOption as JSON :param request: Request object :return: JSON serialized ThumbnailOption """ response_data = [{'id': opt.pk, 'name': opt.name} for opt in ThumbnailOption.objects.all()] return http.HttpResponse(json.dumps(respo...
[ "def", "thumbnail_options", "(", "request", ")", ":", "response_data", "=", "[", "{", "'id'", ":", "opt", ".", "pk", ",", "'name'", ":", "opt", ".", "name", "}", "for", "opt", "in", "ThumbnailOption", ".", "objects", ".", "all", "(", ")", "]", "retur...
Returns the requested ThumbnailOption as JSON :param request: Request object :return: JSON serialized ThumbnailOption
[ "Returns", "the", "requested", "ThumbnailOption", "as", "JSON" ]
336ea259fbc6f9d338e3798375299f654a4d6995
https://github.com/nephila/django-ckeditor-filebrowser-filer/blob/336ea259fbc6f9d338e3798375299f654a4d6995/ckeditor_filebrowser_filer/views.py#L107-L115
train
nephila/django-ckeditor-filebrowser-filer
ckeditor_filebrowser_filer/views.py
serve_image
def serve_image(request, image_id, thumb_options=None, width=None, height=None): """ returns the content of an image sized according to the parameters :param request: Request object :param image_id: Filer image ID :param thumb_options: ThumbnailOption ID :param width: user-provided width :p...
python
def serve_image(request, image_id, thumb_options=None, width=None, height=None): """ returns the content of an image sized according to the parameters :param request: Request object :param image_id: Filer image ID :param thumb_options: ThumbnailOption ID :param width: user-provided width :p...
[ "def", "serve_image", "(", "request", ",", "image_id", ",", "thumb_options", "=", "None", ",", "width", "=", "None", ",", "height", "=", "None", ")", ":", "image", "=", "File", ".", "objects", ".", "get", "(", "pk", "=", "image_id", ")", "if", "getat...
returns the content of an image sized according to the parameters :param request: Request object :param image_id: Filer image ID :param thumb_options: ThumbnailOption ID :param width: user-provided width :param height: user-provided height :return: JSON serialized URL components ('url', 'width'...
[ "returns", "the", "content", "of", "an", "image", "sized", "according", "to", "the", "parameters" ]
336ea259fbc6f9d338e3798375299f654a4d6995
https://github.com/nephila/django-ckeditor-filebrowser-filer/blob/336ea259fbc6f9d338e3798375299f654a4d6995/ckeditor_filebrowser_filer/views.py#L118-L138
train
HarveyHunt/i3situation
i3situation/core/config.py
Config._touch_dir
def _touch_dir(self, path): """ A helper function to create a directory if it doesn't exist. path: A string containing a full path to the directory to be created. """ try: os.makedirs(path) except OSError as e: if e.errno != errno.EEXIST: ...
python
def _touch_dir(self, path): """ A helper function to create a directory if it doesn't exist. path: A string containing a full path to the directory to be created. """ try: os.makedirs(path) except OSError as e: if e.errno != errno.EEXIST: ...
[ "def", "_touch_dir", "(", "self", ",", "path", ")", ":", "try", ":", "os", ".", "makedirs", "(", "path", ")", "except", "OSError", "as", "e", ":", "if", "e", ".", "errno", "!=", "errno", ".", "EEXIST", ":", "raise" ]
A helper function to create a directory if it doesn't exist. path: A string containing a full path to the directory to be created.
[ "A", "helper", "function", "to", "create", "a", "directory", "if", "it", "doesn", "t", "exist", "." ]
3160a21006fcc6961f240988874e228a5ec6f18e
https://github.com/HarveyHunt/i3situation/blob/3160a21006fcc6961f240988874e228a5ec6f18e/i3situation/core/config.py#L32-L42
train
HarveyHunt/i3situation
i3situation/core/config.py
Config.reload
def reload(self): """ Reload the configuration from the file. This is in its own function so that it can be called at any time by another class. """ self._conf = configparser.ConfigParser() # Preserve the case of sections and keys. self._conf.optionxform = str ...
python
def reload(self): """ Reload the configuration from the file. This is in its own function so that it can be called at any time by another class. """ self._conf = configparser.ConfigParser() # Preserve the case of sections and keys. self._conf.optionxform = str ...
[ "def", "reload", "(", "self", ")", ":", "self", ".", "_conf", "=", "configparser", ".", "ConfigParser", "(", ")", "# Preserve the case of sections and keys.", "self", ".", "_conf", ".", "optionxform", "=", "str", "self", ".", "_conf", ".", "read", "(", "self...
Reload the configuration from the file. This is in its own function so that it can be called at any time by another class.
[ "Reload", "the", "configuration", "from", "the", "file", ".", "This", "is", "in", "its", "own", "function", "so", "that", "it", "can", "be", "called", "at", "any", "time", "by", "another", "class", "." ]
3160a21006fcc6961f240988874e228a5ec6f18e
https://github.com/HarveyHunt/i3situation/blob/3160a21006fcc6961f240988874e228a5ec6f18e/i3situation/core/config.py#L50-L68
train
HarveyHunt/i3situation
i3situation/core/config.py
Config._replace_data_types
def _replace_data_types(dictionary): """ Replaces strings with appropriate data types (int, boolean). Also replaces the human readable logging levels with the integer form. dictionary: A dictionary returned from the config file. """ logging_levels = {'NONE': 0, 'NULL': 0...
python
def _replace_data_types(dictionary): """ Replaces strings with appropriate data types (int, boolean). Also replaces the human readable logging levels with the integer form. dictionary: A dictionary returned from the config file. """ logging_levels = {'NONE': 0, 'NULL': 0...
[ "def", "_replace_data_types", "(", "dictionary", ")", ":", "logging_levels", "=", "{", "'NONE'", ":", "0", ",", "'NULL'", ":", "0", ",", "'DEBUG'", ":", "10", ",", "'INFO'", ":", "20", ",", "'WARNING'", ":", "30", ",", "'ERROR'", ":", "40", ",", "'CR...
Replaces strings with appropriate data types (int, boolean). Also replaces the human readable logging levels with the integer form. dictionary: A dictionary returned from the config file.
[ "Replaces", "strings", "with", "appropriate", "data", "types", "(", "int", "boolean", ")", ".", "Also", "replaces", "the", "human", "readable", "logging", "levels", "with", "the", "integer", "form", "." ]
3160a21006fcc6961f240988874e228a5ec6f18e
https://github.com/HarveyHunt/i3situation/blob/3160a21006fcc6961f240988874e228a5ec6f18e/i3situation/core/config.py#L71-L93
train
xolox/python-rotate-backups
rotate_backups/cli.py
main
def main(): """Command line interface for the ``rotate-backups`` program.""" coloredlogs.install(syslog=True) # Command line option defaults. rotation_scheme = {} kw = dict(include_list=[], exclude_list=[]) parallel = False use_sudo = False # Internal state. selected_locations = [] ...
python
def main(): """Command line interface for the ``rotate-backups`` program.""" coloredlogs.install(syslog=True) # Command line option defaults. rotation_scheme = {} kw = dict(include_list=[], exclude_list=[]) parallel = False use_sudo = False # Internal state. selected_locations = [] ...
[ "def", "main", "(", ")", ":", "coloredlogs", ".", "install", "(", "syslog", "=", "True", ")", "# Command line option defaults.", "rotation_scheme", "=", "{", "}", "kw", "=", "dict", "(", "include_list", "=", "[", "]", ",", "exclude_list", "=", "[", "]", ...
Command line interface for the ``rotate-backups`` program.
[ "Command", "line", "interface", "for", "the", "rotate", "-", "backups", "program", "." ]
611c72b2806952bf2bb84c38a4b5f856ea334707
https://github.com/xolox/python-rotate-backups/blob/611c72b2806952bf2bb84c38a4b5f856ea334707/rotate_backups/cli.py#L205-L303
train
HarveyHunt/i3situation
i3situation/plugins/battery.py
BatteryPlugin.get_battery_state
def get_battery_state(self, prop): """ Return the first line from the file located at battery_path/prop as a string. """ with open(os.path.join(self.options['battery_path'], prop), 'r') as f: return f.readline().strip()
python
def get_battery_state(self, prop): """ Return the first line from the file located at battery_path/prop as a string. """ with open(os.path.join(self.options['battery_path'], prop), 'r') as f: return f.readline().strip()
[ "def", "get_battery_state", "(", "self", ",", "prop", ")", ":", "with", "open", "(", "os", ".", "path", ".", "join", "(", "self", ".", "options", "[", "'battery_path'", "]", ",", "prop", ")", ",", "'r'", ")", "as", "f", ":", "return", "f", ".", "...
Return the first line from the file located at battery_path/prop as a string.
[ "Return", "the", "first", "line", "from", "the", "file", "located", "at", "battery_path", "/", "prop", "as", "a", "string", "." ]
3160a21006fcc6961f240988874e228a5ec6f18e
https://github.com/HarveyHunt/i3situation/blob/3160a21006fcc6961f240988874e228a5ec6f18e/i3situation/plugins/battery.py#L52-L58
train
xolox/python-rotate-backups
rotate_backups/__init__.py
coerce_location
def coerce_location(value, **options): """ Coerce a string to a :class:`Location` object. :param value: The value to coerce (a string or :class:`Location` object). :param options: Any keyword arguments are passed on to :func:`~executor.contexts.create_context()`. :returns: A :cl...
python
def coerce_location(value, **options): """ Coerce a string to a :class:`Location` object. :param value: The value to coerce (a string or :class:`Location` object). :param options: Any keyword arguments are passed on to :func:`~executor.contexts.create_context()`. :returns: A :cl...
[ "def", "coerce_location", "(", "value", ",", "*", "*", "options", ")", ":", "# Location objects pass through untouched.", "if", "not", "isinstance", "(", "value", ",", "Location", ")", ":", "# Other values are expected to be strings.", "if", "not", "isinstance", "(", ...
Coerce a string to a :class:`Location` object. :param value: The value to coerce (a string or :class:`Location` object). :param options: Any keyword arguments are passed on to :func:`~executor.contexts.create_context()`. :returns: A :class:`Location` object.
[ "Coerce", "a", "string", "to", "a", ":", "class", ":", "Location", "object", "." ]
611c72b2806952bf2bb84c38a4b5f856ea334707
https://github.com/xolox/python-rotate-backups/blob/611c72b2806952bf2bb84c38a4b5f856ea334707/rotate_backups/__init__.py#L93-L119
train
xolox/python-rotate-backups
rotate_backups/__init__.py
coerce_retention_period
def coerce_retention_period(value): """ Coerce a retention period to a Python value. :param value: A string containing the text 'always', a number or an expression that can be evaluated to a number. :returns: A number or the string 'always'. :raises: :exc:`~exceptions.ValueError` ...
python
def coerce_retention_period(value): """ Coerce a retention period to a Python value. :param value: A string containing the text 'always', a number or an expression that can be evaluated to a number. :returns: A number or the string 'always'. :raises: :exc:`~exceptions.ValueError` ...
[ "def", "coerce_retention_period", "(", "value", ")", ":", "# Numbers pass through untouched.", "if", "not", "isinstance", "(", "value", ",", "numbers", ".", "Number", ")", ":", "# Other values are expected to be strings.", "if", "not", "isinstance", "(", "value", ",",...
Coerce a retention period to a Python value. :param value: A string containing the text 'always', a number or an expression that can be evaluated to a number. :returns: A number or the string 'always'. :raises: :exc:`~exceptions.ValueError` when the string can't be coerced.
[ "Coerce", "a", "retention", "period", "to", "a", "Python", "value", "." ]
611c72b2806952bf2bb84c38a4b5f856ea334707
https://github.com/xolox/python-rotate-backups/blob/611c72b2806952bf2bb84c38a4b5f856ea334707/rotate_backups/__init__.py#L122-L147
train
xolox/python-rotate-backups
rotate_backups/__init__.py
load_config_file
def load_config_file(configuration_file=None, expand=True): """ Load a configuration file with backup directories and rotation schemes. :param configuration_file: Override the pathname of the configuration file to load (a string or :data:`None`). :param expand: :data:`Tru...
python
def load_config_file(configuration_file=None, expand=True): """ Load a configuration file with backup directories and rotation schemes. :param configuration_file: Override the pathname of the configuration file to load (a string or :data:`None`). :param expand: :data:`Tru...
[ "def", "load_config_file", "(", "configuration_file", "=", "None", ",", "expand", "=", "True", ")", ":", "expand_notice_given", "=", "False", "if", "configuration_file", ":", "loader", "=", "ConfigLoader", "(", "available_files", "=", "[", "configuration_file", "]...
Load a configuration file with backup directories and rotation schemes. :param configuration_file: Override the pathname of the configuration file to load (a string or :data:`None`). :param expand: :data:`True` to expand filename patterns to their matches, :dat...
[ "Load", "a", "configuration", "file", "with", "backup", "directories", "and", "rotation", "schemes", "." ]
611c72b2806952bf2bb84c38a4b5f856ea334707
https://github.com/xolox/python-rotate-backups/blob/611c72b2806952bf2bb84c38a4b5f856ea334707/rotate_backups/__init__.py#L150-L220
train
xolox/python-rotate-backups
rotate_backups/__init__.py
rotate_backups
def rotate_backups(directory, rotation_scheme, **options): """ Rotate the backups in a directory according to a flexible rotation scheme. .. note:: This function exists to preserve backwards compatibility with older versions of the `rotate-backups` package where all of the logic...
python
def rotate_backups(directory, rotation_scheme, **options): """ Rotate the backups in a directory according to a flexible rotation scheme. .. note:: This function exists to preserve backwards compatibility with older versions of the `rotate-backups` package where all of the logic...
[ "def", "rotate_backups", "(", "directory", ",", "rotation_scheme", ",", "*", "*", "options", ")", ":", "program", "=", "RotateBackups", "(", "rotation_scheme", "=", "rotation_scheme", ",", "*", "*", "options", ")", "program", ".", "rotate_backups", "(", "direc...
Rotate the backups in a directory according to a flexible rotation scheme. .. note:: This function exists to preserve backwards compatibility with older versions of the `rotate-backups` package where all of the logic was exposed as a single function. Please refer to the do...
[ "Rotate", "the", "backups", "in", "a", "directory", "according", "to", "a", "flexible", "rotation", "scheme", "." ]
611c72b2806952bf2bb84c38a4b5f856ea334707
https://github.com/xolox/python-rotate-backups/blob/611c72b2806952bf2bb84c38a4b5f856ea334707/rotate_backups/__init__.py#L223-L235
train
xolox/python-rotate-backups
rotate_backups/__init__.py
RotateBackups.rotate_concurrent
def rotate_concurrent(self, *locations, **kw): """ Rotate the backups in the given locations concurrently. :param locations: One or more values accepted by :func:`coerce_location()`. :param kw: Any keyword arguments are passed on to :func:`rotate_backups()`. This function uses ...
python
def rotate_concurrent(self, *locations, **kw): """ Rotate the backups in the given locations concurrently. :param locations: One or more values accepted by :func:`coerce_location()`. :param kw: Any keyword arguments are passed on to :func:`rotate_backups()`. This function uses ...
[ "def", "rotate_concurrent", "(", "self", ",", "*", "locations", ",", "*", "*", "kw", ")", ":", "timer", "=", "Timer", "(", ")", "pool", "=", "CommandPool", "(", "concurrency", "=", "10", ")", "logger", ".", "info", "(", "\"Scanning %s ..\"", ",", "plur...
Rotate the backups in the given locations concurrently. :param locations: One or more values accepted by :func:`coerce_location()`. :param kw: Any keyword arguments are passed on to :func:`rotate_backups()`. This function uses :func:`rotate_backups()` to prepare rotation commands for t...
[ "Rotate", "the", "backups", "in", "the", "given", "locations", "concurrently", "." ]
611c72b2806952bf2bb84c38a4b5f856ea334707
https://github.com/xolox/python-rotate-backups/blob/611c72b2806952bf2bb84c38a4b5f856ea334707/rotate_backups/__init__.py#L403-L431
train
xolox/python-rotate-backups
rotate_backups/__init__.py
RotateBackups.rotate_backups
def rotate_backups(self, location, load_config=True, prepare=False): """ Rotate the backups in a directory according to a flexible rotation scheme. :param location: Any value accepted by :func:`coerce_location()`. :param load_config: If :data:`True` (so by default) the rotation scheme ...
python
def rotate_backups(self, location, load_config=True, prepare=False): """ Rotate the backups in a directory according to a flexible rotation scheme. :param location: Any value accepted by :func:`coerce_location()`. :param load_config: If :data:`True` (so by default) the rotation scheme ...
[ "def", "rotate_backups", "(", "self", ",", "location", ",", "load_config", "=", "True", ",", "prepare", "=", "False", ")", ":", "rotation_commands", "=", "[", "]", "location", "=", "coerce_location", "(", "location", ")", "# Load configuration overrides by user?",...
Rotate the backups in a directory according to a flexible rotation scheme. :param location: Any value accepted by :func:`coerce_location()`. :param load_config: If :data:`True` (so by default) the rotation scheme and other options can be customized by the user in ...
[ "Rotate", "the", "backups", "in", "a", "directory", "according", "to", "a", "flexible", "rotation", "scheme", "." ]
611c72b2806952bf2bb84c38a4b5f856ea334707
https://github.com/xolox/python-rotate-backups/blob/611c72b2806952bf2bb84c38a4b5f856ea334707/rotate_backups/__init__.py#L433-L512
train
xolox/python-rotate-backups
rotate_backups/__init__.py
RotateBackups.load_config_file
def load_config_file(self, location): """ Load a rotation scheme and other options from a configuration file. :param location: Any value accepted by :func:`coerce_location()`. :returns: The configured or given :class:`Location` object. """ location = coerce_location(loca...
python
def load_config_file(self, location): """ Load a rotation scheme and other options from a configuration file. :param location: Any value accepted by :func:`coerce_location()`. :returns: The configured or given :class:`Location` object. """ location = coerce_location(loca...
[ "def", "load_config_file", "(", "self", ",", "location", ")", ":", "location", "=", "coerce_location", "(", "location", ")", "for", "configured_location", ",", "rotation_scheme", ",", "options", "in", "load_config_file", "(", "self", ".", "config_file", ",", "ex...
Load a rotation scheme and other options from a configuration file. :param location: Any value accepted by :func:`coerce_location()`. :returns: The configured or given :class:`Location` object.
[ "Load", "a", "rotation", "scheme", "and", "other", "options", "from", "a", "configuration", "file", "." ]
611c72b2806952bf2bb84c38a4b5f856ea334707
https://github.com/xolox/python-rotate-backups/blob/611c72b2806952bf2bb84c38a4b5f856ea334707/rotate_backups/__init__.py#L514-L544
train
xolox/python-rotate-backups
rotate_backups/__init__.py
RotateBackups.collect_backups
def collect_backups(self, location): """ Collect the backups at the given location. :param location: Any value accepted by :func:`coerce_location()`. :returns: A sorted :class:`list` of :class:`Backup` objects (the backups are sorted by their date). :raises: :e...
python
def collect_backups(self, location): """ Collect the backups at the given location. :param location: Any value accepted by :func:`coerce_location()`. :returns: A sorted :class:`list` of :class:`Backup` objects (the backups are sorted by their date). :raises: :e...
[ "def", "collect_backups", "(", "self", ",", "location", ")", ":", "backups", "=", "[", "]", "location", "=", "coerce_location", "(", "location", ")", "logger", ".", "info", "(", "\"Scanning %s for backups ..\"", ",", "location", ")", "location", ".", "ensure_r...
Collect the backups at the given location. :param location: Any value accepted by :func:`coerce_location()`. :returns: A sorted :class:`list` of :class:`Backup` objects (the backups are sorted by their date). :raises: :exc:`~exceptions.ValueError` when the given directory does...
[ "Collect", "the", "backups", "at", "the", "given", "location", "." ]
611c72b2806952bf2bb84c38a4b5f856ea334707
https://github.com/xolox/python-rotate-backups/blob/611c72b2806952bf2bb84c38a4b5f856ea334707/rotate_backups/__init__.py#L546-L579
train
xolox/python-rotate-backups
rotate_backups/__init__.py
RotateBackups.group_backups
def group_backups(self, backups): """ Group backups collected by :func:`collect_backups()` by rotation frequencies. :param backups: A :class:`set` of :class:`Backup` objects. :returns: A :class:`dict` whose keys are the names of rotation frequencies ('hourly', 'daily',...
python
def group_backups(self, backups): """ Group backups collected by :func:`collect_backups()` by rotation frequencies. :param backups: A :class:`set` of :class:`Backup` objects. :returns: A :class:`dict` whose keys are the names of rotation frequencies ('hourly', 'daily',...
[ "def", "group_backups", "(", "self", ",", "backups", ")", ":", "backups_by_frequency", "=", "dict", "(", "(", "frequency", ",", "collections", ".", "defaultdict", "(", "list", ")", ")", "for", "frequency", "in", "SUPPORTED_FREQUENCIES", ")", "for", "b", "in"...
Group backups collected by :func:`collect_backups()` by rotation frequencies. :param backups: A :class:`set` of :class:`Backup` objects. :returns: A :class:`dict` whose keys are the names of rotation frequencies ('hourly', 'daily', etc.) and whose values are dictiona...
[ "Group", "backups", "collected", "by", ":", "func", ":", "collect_backups", "()", "by", "rotation", "frequencies", "." ]
611c72b2806952bf2bb84c38a4b5f856ea334707
https://github.com/xolox/python-rotate-backups/blob/611c72b2806952bf2bb84c38a4b5f856ea334707/rotate_backups/__init__.py#L581-L601
train
xolox/python-rotate-backups
rotate_backups/__init__.py
RotateBackups.apply_rotation_scheme
def apply_rotation_scheme(self, backups_by_frequency, most_recent_backup): """ Apply the user defined rotation scheme to the result of :func:`group_backups()`. :param backups_by_frequency: A :class:`dict` in the format generated by :func:`group_backups()`. ...
python
def apply_rotation_scheme(self, backups_by_frequency, most_recent_backup): """ Apply the user defined rotation scheme to the result of :func:`group_backups()`. :param backups_by_frequency: A :class:`dict` in the format generated by :func:`group_backups()`. ...
[ "def", "apply_rotation_scheme", "(", "self", ",", "backups_by_frequency", ",", "most_recent_backup", ")", ":", "if", "not", "self", ".", "rotation_scheme", ":", "raise", "ValueError", "(", "\"Refusing to use empty rotation scheme! (all backups would be deleted)\"", ")", "fo...
Apply the user defined rotation scheme to the result of :func:`group_backups()`. :param backups_by_frequency: A :class:`dict` in the format generated by :func:`group_backups()`. :param most_recent_backup: The :class:`~datetime.datetime` of the most ...
[ "Apply", "the", "user", "defined", "rotation", "scheme", "to", "the", "result", "of", ":", "func", ":", "group_backups", "()", "." ]
611c72b2806952bf2bb84c38a4b5f856ea334707
https://github.com/xolox/python-rotate-backups/blob/611c72b2806952bf2bb84c38a4b5f856ea334707/rotate_backups/__init__.py#L603-L649
train
xolox/python-rotate-backups
rotate_backups/__init__.py
RotateBackups.find_preservation_criteria
def find_preservation_criteria(self, backups_by_frequency): """ Collect the criteria used to decide which backups to preserve. :param backups_by_frequency: A :class:`dict` in the format generated by :func:`group_backups()` which has been ...
python
def find_preservation_criteria(self, backups_by_frequency): """ Collect the criteria used to decide which backups to preserve. :param backups_by_frequency: A :class:`dict` in the format generated by :func:`group_backups()` which has been ...
[ "def", "find_preservation_criteria", "(", "self", ",", "backups_by_frequency", ")", ":", "backups_to_preserve", "=", "collections", ".", "defaultdict", "(", "list", ")", "for", "frequency", ",", "delta", "in", "ORDERED_FREQUENCIES", ":", "for", "period", "in", "ba...
Collect the criteria used to decide which backups to preserve. :param backups_by_frequency: A :class:`dict` in the format generated by :func:`group_backups()` which has been processed by :func:`apply_rotation_scheme()`. :returns:...
[ "Collect", "the", "criteria", "used", "to", "decide", "which", "backups", "to", "preserve", "." ]
611c72b2806952bf2bb84c38a4b5f856ea334707
https://github.com/xolox/python-rotate-backups/blob/611c72b2806952bf2bb84c38a4b5f856ea334707/rotate_backups/__init__.py#L651-L667
train
xolox/python-rotate-backups
rotate_backups/__init__.py
Location.mount_point
def mount_point(self): """ The pathname of the mount point of :attr:`directory` (a string or :data:`None`). If the ``stat --format=%m ...`` command that is used to determine the mount point fails, the value of this property defaults to :data:`None`. This enables graceful degrada...
python
def mount_point(self): """ The pathname of the mount point of :attr:`directory` (a string or :data:`None`). If the ``stat --format=%m ...`` command that is used to determine the mount point fails, the value of this property defaults to :data:`None`. This enables graceful degrada...
[ "def", "mount_point", "(", "self", ")", ":", "try", ":", "return", "self", ".", "context", ".", "capture", "(", "'stat'", ",", "'--format=%m'", ",", "self", ".", "directory", ",", "silent", "=", "True", ")", "except", "ExternalCommandFailed", ":", "return"...
The pathname of the mount point of :attr:`directory` (a string or :data:`None`). If the ``stat --format=%m ...`` command that is used to determine the mount point fails, the value of this property defaults to :data:`None`. This enables graceful degradation on e.g. Mac OS X whose ``stat`` ...
[ "The", "pathname", "of", "the", "mount", "point", "of", ":", "attr", ":", "directory", "(", "a", "string", "or", ":", "data", ":", "None", ")", "." ]
611c72b2806952bf2bb84c38a4b5f856ea334707
https://github.com/xolox/python-rotate-backups/blob/611c72b2806952bf2bb84c38a4b5f856ea334707/rotate_backups/__init__.py#L693-L705
train
xolox/python-rotate-backups
rotate_backups/__init__.py
Location.ensure_exists
def ensure_exists(self): """Make sure the location exists.""" if not self.context.is_directory(self.directory): # This can also happen when we don't have permission to one of the # parent directories so we'll point that out in the error message # when it seems applica...
python
def ensure_exists(self): """Make sure the location exists.""" if not self.context.is_directory(self.directory): # This can also happen when we don't have permission to one of the # parent directories so we'll point that out in the error message # when it seems applica...
[ "def", "ensure_exists", "(", "self", ")", ":", "if", "not", "self", ".", "context", ".", "is_directory", "(", "self", ".", "directory", ")", ":", "# This can also happen when we don't have permission to one of the", "# parent directories so we'll point that out in the error m...
Make sure the location exists.
[ "Make", "sure", "the", "location", "exists", "." ]
611c72b2806952bf2bb84c38a4b5f856ea334707
https://github.com/xolox/python-rotate-backups/blob/611c72b2806952bf2bb84c38a4b5f856ea334707/rotate_backups/__init__.py#L729-L744
train
xolox/python-rotate-backups
rotate_backups/__init__.py
Location.ensure_readable
def ensure_readable(self): """Make sure the location exists and is readable.""" self.ensure_exists() if not self.context.is_readable(self.directory): if self.context.have_superuser_privileges: msg = "The directory %s isn't readable!" raise ValueError(m...
python
def ensure_readable(self): """Make sure the location exists and is readable.""" self.ensure_exists() if not self.context.is_readable(self.directory): if self.context.have_superuser_privileges: msg = "The directory %s isn't readable!" raise ValueError(m...
[ "def", "ensure_readable", "(", "self", ")", ":", "self", ".", "ensure_exists", "(", ")", "if", "not", "self", ".", "context", ".", "is_readable", "(", "self", ".", "directory", ")", ":", "if", "self", ".", "context", ".", "have_superuser_privileges", ":", ...
Make sure the location exists and is readable.
[ "Make", "sure", "the", "location", "exists", "and", "is", "readable", "." ]
611c72b2806952bf2bb84c38a4b5f856ea334707
https://github.com/xolox/python-rotate-backups/blob/611c72b2806952bf2bb84c38a4b5f856ea334707/rotate_backups/__init__.py#L746-L758
train
xolox/python-rotate-backups
rotate_backups/__init__.py
Location.ensure_writable
def ensure_writable(self): """Make sure the directory exists and is writable.""" self.ensure_exists() if not self.context.is_writable(self.directory): if self.context.have_superuser_privileges: msg = "The directory %s isn't writable!" raise ValueError(...
python
def ensure_writable(self): """Make sure the directory exists and is writable.""" self.ensure_exists() if not self.context.is_writable(self.directory): if self.context.have_superuser_privileges: msg = "The directory %s isn't writable!" raise ValueError(...
[ "def", "ensure_writable", "(", "self", ")", ":", "self", ".", "ensure_exists", "(", ")", "if", "not", "self", ".", "context", ".", "is_writable", "(", "self", ".", "directory", ")", ":", "if", "self", ".", "context", ".", "have_superuser_privileges", ":", ...
Make sure the directory exists and is writable.
[ "Make", "sure", "the", "directory", "exists", "and", "is", "writable", "." ]
611c72b2806952bf2bb84c38a4b5f856ea334707
https://github.com/xolox/python-rotate-backups/blob/611c72b2806952bf2bb84c38a4b5f856ea334707/rotate_backups/__init__.py#L760-L771
train
xolox/python-rotate-backups
rotate_backups/__init__.py
Location.match
def match(self, location): """ Check if the given location "matches". :param location: The :class:`Location` object to try to match. :returns: :data:`True` if the two locations are on the same system and the :attr:`directory` can be matched as a filename pattern or ...
python
def match(self, location): """ Check if the given location "matches". :param location: The :class:`Location` object to try to match. :returns: :data:`True` if the two locations are on the same system and the :attr:`directory` can be matched as a filename pattern or ...
[ "def", "match", "(", "self", ",", "location", ")", ":", "if", "self", ".", "ssh_alias", "!=", "location", ".", "ssh_alias", ":", "# Never match locations on other systems.", "return", "False", "elif", "self", ".", "have_wildcards", ":", "# Match filename patterns us...
Check if the given location "matches". :param location: The :class:`Location` object to try to match. :returns: :data:`True` if the two locations are on the same system and the :attr:`directory` can be matched as a filename pattern or a literal match on the normalize...
[ "Check", "if", "the", "given", "location", "matches", "." ]
611c72b2806952bf2bb84c38a4b5f856ea334707
https://github.com/xolox/python-rotate-backups/blob/611c72b2806952bf2bb84c38a4b5f856ea334707/rotate_backups/__init__.py#L773-L792
train
HarveyHunt/i3situation
i3situation/core/status.py
setup_file_logger
def setup_file_logger(filename, formatting, log_level): """ A helper function for creating a file logger. Accepts arguments, as it is used in Status and LoggingWriter. """ logger = logging.getLogger() # If a stream handler has been attached, remove it. if logger.handlers: logger.remo...
python
def setup_file_logger(filename, formatting, log_level): """ A helper function for creating a file logger. Accepts arguments, as it is used in Status and LoggingWriter. """ logger = logging.getLogger() # If a stream handler has been attached, remove it. if logger.handlers: logger.remo...
[ "def", "setup_file_logger", "(", "filename", ",", "formatting", ",", "log_level", ")", ":", "logger", "=", "logging", ".", "getLogger", "(", ")", "# If a stream handler has been attached, remove it.", "if", "logger", ".", "handlers", ":", "logger", ".", "removeHandl...
A helper function for creating a file logger. Accepts arguments, as it is used in Status and LoggingWriter.
[ "A", "helper", "function", "for", "creating", "a", "file", "logger", ".", "Accepts", "arguments", "as", "it", "is", "used", "in", "Status", "and", "LoggingWriter", "." ]
3160a21006fcc6961f240988874e228a5ec6f18e
https://github.com/HarveyHunt/i3situation/blob/3160a21006fcc6961f240988874e228a5ec6f18e/i3situation/core/status.py#L12-L27
train
HarveyHunt/i3situation
i3situation/core/status.py
Status.output_to_bar
def output_to_bar(self, message, comma=True): """ Outputs data to stdout, without buffering. message: A string containing the data to be output. comma: Whether or not a comma should be placed at the end of the output. """ if comma: message += ',' sys....
python
def output_to_bar(self, message, comma=True): """ Outputs data to stdout, without buffering. message: A string containing the data to be output. comma: Whether or not a comma should be placed at the end of the output. """ if comma: message += ',' sys....
[ "def", "output_to_bar", "(", "self", ",", "message", ",", "comma", "=", "True", ")", ":", "if", "comma", ":", "message", "+=", "','", "sys", ".", "stdout", ".", "write", "(", "message", "+", "'\\n'", ")", "sys", ".", "stdout", ".", "flush", "(", ")...
Outputs data to stdout, without buffering. message: A string containing the data to be output. comma: Whether or not a comma should be placed at the end of the output.
[ "Outputs", "data", "to", "stdout", "without", "buffering", "." ]
3160a21006fcc6961f240988874e228a5ec6f18e
https://github.com/HarveyHunt/i3situation/blob/3160a21006fcc6961f240988874e228a5ec6f18e/i3situation/core/status.py#L76-L86
train
HarveyHunt/i3situation
i3situation/core/status.py
Status.reload
def reload(self): """ Reload the installed plugins and the configuration file. This is called when either the plugins or config get updated. """ logging.debug('Reloading config file as files have been modified.') self.config.plugin, self.config.general = self.config.reloa...
python
def reload(self): """ Reload the installed plugins and the configuration file. This is called when either the plugins or config get updated. """ logging.debug('Reloading config file as files have been modified.') self.config.plugin, self.config.general = self.config.reloa...
[ "def", "reload", "(", "self", ")", ":", "logging", ".", "debug", "(", "'Reloading config file as files have been modified.'", ")", "self", ".", "config", ".", "plugin", ",", "self", ".", "config", ".", "general", "=", "self", ".", "config", ".", "reload", "(...
Reload the installed plugins and the configuration file. This is called when either the plugins or config get updated.
[ "Reload", "the", "installed", "plugins", "and", "the", "configuration", "file", ".", "This", "is", "called", "when", "either", "the", "plugins", "or", "config", "get", "updated", "." ]
3160a21006fcc6961f240988874e228a5ec6f18e
https://github.com/HarveyHunt/i3situation/blob/3160a21006fcc6961f240988874e228a5ec6f18e/i3situation/core/status.py#L88-L99
train
HarveyHunt/i3situation
i3situation/core/status.py
Status.run_plugins
def run_plugins(self): """ Creates a thread for each plugin and lets the thread_manager handle it. """ for obj in self.loader.objects: # Reserve a slot in the output_dict in order to ensure that the # items are in the correct order. self.output_dict[ob...
python
def run_plugins(self): """ Creates a thread for each plugin and lets the thread_manager handle it. """ for obj in self.loader.objects: # Reserve a slot in the output_dict in order to ensure that the # items are in the correct order. self.output_dict[ob...
[ "def", "run_plugins", "(", "self", ")", ":", "for", "obj", "in", "self", ".", "loader", ".", "objects", ":", "# Reserve a slot in the output_dict in order to ensure that the", "# items are in the correct order.", "self", ".", "output_dict", "[", "obj", ".", "output_opti...
Creates a thread for each plugin and lets the thread_manager handle it.
[ "Creates", "a", "thread", "for", "each", "plugin", "and", "lets", "the", "thread_manager", "handle", "it", "." ]
3160a21006fcc6961f240988874e228a5ec6f18e
https://github.com/HarveyHunt/i3situation/blob/3160a21006fcc6961f240988874e228a5ec6f18e/i3situation/core/status.py#L101-L109
train
HarveyHunt/i3situation
i3situation/core/status.py
Status.run
def run(self): """ Monitors if the config file or plugins are updated. Also outputs the JSON data generated by the plugins, without needing to poll the threads. """ self.run_plugins() while True: # Reload plugins and config if either the config file or plugin ...
python
def run(self): """ Monitors if the config file or plugins are updated. Also outputs the JSON data generated by the plugins, without needing to poll the threads. """ self.run_plugins() while True: # Reload plugins and config if either the config file or plugin ...
[ "def", "run", "(", "self", ")", ":", "self", ".", "run_plugins", "(", ")", "while", "True", ":", "# Reload plugins and config if either the config file or plugin", "# directory are modified.", "if", "self", ".", "_config_mod_time", "!=", "os", ".", "path", ".", "get...
Monitors if the config file or plugins are updated. Also outputs the JSON data generated by the plugins, without needing to poll the threads.
[ "Monitors", "if", "the", "config", "file", "or", "plugins", "are", "updated", ".", "Also", "outputs", "the", "JSON", "data", "generated", "by", "the", "plugins", "without", "needing", "to", "poll", "the", "threads", "." ]
3160a21006fcc6961f240988874e228a5ec6f18e
https://github.com/HarveyHunt/i3situation/blob/3160a21006fcc6961f240988874e228a5ec6f18e/i3situation/core/status.py#L111-L127
train
HarveyHunt/i3situation
i3situation/core/status.py
Status._remove_empty_output
def _remove_empty_output(self): """ If plugins haven't been initialised and therefore not sending output or their output is None, there is no reason to take up extra room on the bar. """ output = [] for key in self.output_dict: if self.output_dict[key]...
python
def _remove_empty_output(self): """ If plugins haven't been initialised and therefore not sending output or their output is None, there is no reason to take up extra room on the bar. """ output = [] for key in self.output_dict: if self.output_dict[key]...
[ "def", "_remove_empty_output", "(", "self", ")", ":", "output", "=", "[", "]", "for", "key", "in", "self", ".", "output_dict", ":", "if", "self", ".", "output_dict", "[", "key", "]", "is", "not", "None", "and", "'full_text'", "in", "self", ".", "output...
If plugins haven't been initialised and therefore not sending output or their output is None, there is no reason to take up extra room on the bar.
[ "If", "plugins", "haven", "t", "been", "initialised", "and", "therefore", "not", "sending", "output", "or", "their", "output", "is", "None", "there", "is", "no", "reason", "to", "take", "up", "extra", "room", "on", "the", "bar", "." ]
3160a21006fcc6961f240988874e228a5ec6f18e
https://github.com/HarveyHunt/i3situation/blob/3160a21006fcc6961f240988874e228a5ec6f18e/i3situation/core/status.py#L129-L139
train
HarveyHunt/i3situation
i3situation/core/status.py
Status.handle_events
def handle_events(self): """ An event handler that processes events from stdin and calls the on_click function of the respective object. This function is run in another thread, so as to not stall the main thread. """ for event in sys.stdin: if event.startswith...
python
def handle_events(self): """ An event handler that processes events from stdin and calls the on_click function of the respective object. This function is run in another thread, so as to not stall the main thread. """ for event in sys.stdin: if event.startswith...
[ "def", "handle_events", "(", "self", ")", ":", "for", "event", "in", "sys", ".", "stdin", ":", "if", "event", ".", "startswith", "(", "'['", ")", ":", "continue", "name", "=", "json", ".", "loads", "(", "event", ".", "lstrip", "(", "','", ")", ")",...
An event handler that processes events from stdin and calls the on_click function of the respective object. This function is run in another thread, so as to not stall the main thread.
[ "An", "event", "handler", "that", "processes", "events", "from", "stdin", "and", "calls", "the", "on_click", "function", "of", "the", "respective", "object", ".", "This", "function", "is", "run", "in", "another", "thread", "so", "as", "to", "not", "stall", ...
3160a21006fcc6961f240988874e228a5ec6f18e
https://github.com/HarveyHunt/i3situation/blob/3160a21006fcc6961f240988874e228a5ec6f18e/i3situation/core/status.py#L141-L153
train
Alir3z4/django-databrowse
django_databrowse/plugins/fieldchoices.py
FieldChoicePlugin.field_dict
def field_dict(self, model): """ Helper function that returns a dictionary of all fields in the given model. If self.field_filter is set, it only includes the fields that match the filter. """ if self.field_filter: return dict( [(f.name, f) for...
python
def field_dict(self, model): """ Helper function that returns a dictionary of all fields in the given model. If self.field_filter is set, it only includes the fields that match the filter. """ if self.field_filter: return dict( [(f.name, f) for...
[ "def", "field_dict", "(", "self", ",", "model", ")", ":", "if", "self", ".", "field_filter", ":", "return", "dict", "(", "[", "(", "f", ".", "name", ",", "f", ")", "for", "f", "in", "model", ".", "_meta", ".", "fields", "if", "self", ".", "field_...
Helper function that returns a dictionary of all fields in the given model. If self.field_filter is set, it only includes the fields that match the filter.
[ "Helper", "function", "that", "returns", "a", "dictionary", "of", "all", "fields", "in", "the", "given", "model", ".", "If", "self", ".", "field_filter", "is", "set", "it", "only", "includes", "the", "fields", "that", "match", "the", "filter", "." ]
4469495cd47a0da506ddf4e8cc752c2f453e0339
https://github.com/Alir3z4/django-databrowse/blob/4469495cd47a0da506ddf4e8cc752c2f453e0339/django_databrowse/plugins/fieldchoices.py#L25-L43
train
HarveyHunt/i3situation
i3situation/core/plugin_manager.py
Thread.run
def run(self): """ Calls the main function of a plugin and mutates the output dict with its return value. Provides an easy way to change the output whilst not needing to constantly poll a queue in another thread and allowing plugin's to manage their own intervals. """ ...
python
def run(self): """ Calls the main function of a plugin and mutates the output dict with its return value. Provides an easy way to change the output whilst not needing to constantly poll a queue in another thread and allowing plugin's to manage their own intervals. """ ...
[ "def", "run", "(", "self", ")", ":", "self", ".", "running", "=", "True", "while", "self", ".", "running", ":", "ret", "=", "self", ".", "func", "(", ")", "self", ".", "output_dict", "[", "ret", "[", "'name'", "]", "]", "=", "ret", "time", ".", ...
Calls the main function of a plugin and mutates the output dict with its return value. Provides an easy way to change the output whilst not needing to constantly poll a queue in another thread and allowing plugin's to manage their own intervals.
[ "Calls", "the", "main", "function", "of", "a", "plugin", "and", "mutates", "the", "output", "dict", "with", "its", "return", "value", ".", "Provides", "an", "easy", "way", "to", "change", "the", "output", "whilst", "not", "needing", "to", "constantly", "po...
3160a21006fcc6961f240988874e228a5ec6f18e
https://github.com/HarveyHunt/i3situation/blob/3160a21006fcc6961f240988874e228a5ec6f18e/i3situation/core/plugin_manager.py#L43-L55
train
HarveyHunt/i3situation
i3situation/core/plugin_manager.py
ThreadManager.add_thread
def add_thread(self, func, interval): """ Creates a thread, starts it and then adds it to the thread pool. Func: Same as in the Thread class. Interval: Same as in the Thread class. """ t = Thread(func, interval, self.output_dict) t.start() self._thread_po...
python
def add_thread(self, func, interval): """ Creates a thread, starts it and then adds it to the thread pool. Func: Same as in the Thread class. Interval: Same as in the Thread class. """ t = Thread(func, interval, self.output_dict) t.start() self._thread_po...
[ "def", "add_thread", "(", "self", ",", "func", ",", "interval", ")", ":", "t", "=", "Thread", "(", "func", ",", "interval", ",", "self", ".", "output_dict", ")", "t", ".", "start", "(", ")", "self", ".", "_thread_pool", ".", "append", "(", "t", ")"...
Creates a thread, starts it and then adds it to the thread pool. Func: Same as in the Thread class. Interval: Same as in the Thread class.
[ "Creates", "a", "thread", "starts", "it", "and", "then", "adds", "it", "to", "the", "thread", "pool", "." ]
3160a21006fcc6961f240988874e228a5ec6f18e
https://github.com/HarveyHunt/i3situation/blob/3160a21006fcc6961f240988874e228a5ec6f18e/i3situation/core/plugin_manager.py#L84-L93
train
HarveyHunt/i3situation
i3situation/core/plugin_manager.py
PluginLoader._compile_files
def _compile_files(self): """ Compiles python plugin files in order to be processed by the loader. It compiles the plugins if they have been updated or haven't yet been compiled. """ for f in glob.glob(os.path.join(self.dir_path, '*.py')): # Check for compiled...
python
def _compile_files(self): """ Compiles python plugin files in order to be processed by the loader. It compiles the plugins if they have been updated or haven't yet been compiled. """ for f in glob.glob(os.path.join(self.dir_path, '*.py')): # Check for compiled...
[ "def", "_compile_files", "(", "self", ")", ":", "for", "f", "in", "glob", ".", "glob", "(", "os", ".", "path", ".", "join", "(", "self", ".", "dir_path", ",", "'*.py'", ")", ")", ":", "# Check for compiled Python files that aren't in the __pycache__.", "if", ...
Compiles python plugin files in order to be processed by the loader. It compiles the plugins if they have been updated or haven't yet been compiled.
[ "Compiles", "python", "plugin", "files", "in", "order", "to", "be", "processed", "by", "the", "loader", ".", "It", "compiles", "the", "plugins", "if", "they", "have", "been", "updated", "or", "haven", "t", "yet", "been", "compiled", "." ]
3160a21006fcc6961f240988874e228a5ec6f18e
https://github.com/HarveyHunt/i3situation/blob/3160a21006fcc6961f240988874e228a5ec6f18e/i3situation/core/plugin_manager.py#L125-L142
train
HarveyHunt/i3situation
i3situation/core/plugin_manager.py
PluginLoader._load_compiled
def _load_compiled(self, file_path): """ Accepts a path to a compiled plugin and returns a module object. file_path: A string that represents a complete file path to a compiled plugin. """ name = os.path.splitext(os.path.split(file_path)[-1])[0] plugin_directory ...
python
def _load_compiled(self, file_path): """ Accepts a path to a compiled plugin and returns a module object. file_path: A string that represents a complete file path to a compiled plugin. """ name = os.path.splitext(os.path.split(file_path)[-1])[0] plugin_directory ...
[ "def", "_load_compiled", "(", "self", ",", "file_path", ")", ":", "name", "=", "os", ".", "path", ".", "splitext", "(", "os", ".", "path", ".", "split", "(", "file_path", ")", "[", "-", "1", "]", ")", "[", "0", "]", "plugin_directory", "=", "os", ...
Accepts a path to a compiled plugin and returns a module object. file_path: A string that represents a complete file path to a compiled plugin.
[ "Accepts", "a", "path", "to", "a", "compiled", "plugin", "and", "returns", "a", "module", "object", "." ]
3160a21006fcc6961f240988874e228a5ec6f18e
https://github.com/HarveyHunt/i3situation/blob/3160a21006fcc6961f240988874e228a5ec6f18e/i3situation/core/plugin_manager.py#L144-L157
train
HarveyHunt/i3situation
i3situation/core/plugin_manager.py
PluginLoader.load_objects
def load_objects(self): """ Matches the plugins that have been specified in the config file with the available plugins. Returns instantiated objects based upon the classes defined in the plugins. """ objects = [] for settings in self._config: if settin...
python
def load_objects(self): """ Matches the plugins that have been specified in the config file with the available plugins. Returns instantiated objects based upon the classes defined in the plugins. """ objects = [] for settings in self._config: if settin...
[ "def", "load_objects", "(", "self", ")", ":", "objects", "=", "[", "]", "for", "settings", "in", "self", ".", "_config", ":", "if", "settings", "[", "'plugin'", "]", "in", "self", ".", "plugins", ":", "module", "=", "self", ".", "plugins", "[", "sett...
Matches the plugins that have been specified in the config file with the available plugins. Returns instantiated objects based upon the classes defined in the plugins.
[ "Matches", "the", "plugins", "that", "have", "been", "specified", "in", "the", "config", "file", "with", "the", "available", "plugins", ".", "Returns", "instantiated", "objects", "based", "upon", "the", "classes", "defined", "in", "the", "plugins", "." ]
3160a21006fcc6961f240988874e228a5ec6f18e
https://github.com/HarveyHunt/i3situation/blob/3160a21006fcc6961f240988874e228a5ec6f18e/i3situation/core/plugin_manager.py#L159-L180
train
HarveyHunt/i3situation
i3situation/core/plugin_manager.py
PluginLoader.refresh_files
def refresh_files(self): """ Discovers the available plugins and turns each into a module object. This is a seperate function to allow plugins to be updated dynamically by other parts of the application. """ plugins = {} _plugin_files = glob.glob(os.path.join(self...
python
def refresh_files(self): """ Discovers the available plugins and turns each into a module object. This is a seperate function to allow plugins to be updated dynamically by other parts of the application. """ plugins = {} _plugin_files = glob.glob(os.path.join(self...
[ "def", "refresh_files", "(", "self", ")", ":", "plugins", "=", "{", "}", "_plugin_files", "=", "glob", ".", "glob", "(", "os", ".", "path", ".", "join", "(", "self", ".", "dir_path", ",", "'[!_]*.pyc'", ")", ")", "for", "f", "in", "glob", ".", "glo...
Discovers the available plugins and turns each into a module object. This is a seperate function to allow plugins to be updated dynamically by other parts of the application.
[ "Discovers", "the", "available", "plugins", "and", "turns", "each", "into", "a", "module", "object", ".", "This", "is", "a", "seperate", "function", "to", "allow", "plugins", "to", "be", "updated", "dynamically", "by", "other", "parts", "of", "the", "applica...
3160a21006fcc6961f240988874e228a5ec6f18e
https://github.com/HarveyHunt/i3situation/blob/3160a21006fcc6961f240988874e228a5ec6f18e/i3situation/core/plugin_manager.py#L182-L199
train
Alir3z4/django-databrowse
django_databrowse/sites.py
ModelDatabrowse.root
def root(self, request, url): """ Handles main URL routing for the databrowse app. `url` is the remainder of the URL -- e.g. 'objects/3'. """ # Delegate to the appropriate method, based on the URL. if url is None: return self.main_view(request) try: ...
python
def root(self, request, url): """ Handles main URL routing for the databrowse app. `url` is the remainder of the URL -- e.g. 'objects/3'. """ # Delegate to the appropriate method, based on the URL. if url is None: return self.main_view(request) try: ...
[ "def", "root", "(", "self", ",", "request", ",", "url", ")", ":", "# Delegate to the appropriate method, based on the URL.", "if", "url", "is", "None", ":", "return", "self", ".", "main_view", "(", "request", ")", "try", ":", "plugin_name", ",", "rest_of_url", ...
Handles main URL routing for the databrowse app. `url` is the remainder of the URL -- e.g. 'objects/3'.
[ "Handles", "main", "URL", "routing", "for", "the", "databrowse", "app", "." ]
4469495cd47a0da506ddf4e8cc752c2f453e0339
https://github.com/Alir3z4/django-databrowse/blob/4469495cd47a0da506ddf4e8cc752c2f453e0339/django_databrowse/sites.py#L55-L73
train
Alir3z4/django-databrowse
django_databrowse/sites.py
DatabrowseSite.register
def register(self, *model_list, **options): """ Registers the given model(s) with the given databrowse site. The model(s) should be Model classes, not instances. If a databrowse class isn't given, it will use DefaultModelDatabrowse (the default databrowse options). If ...
python
def register(self, *model_list, **options): """ Registers the given model(s) with the given databrowse site. The model(s) should be Model classes, not instances. If a databrowse class isn't given, it will use DefaultModelDatabrowse (the default databrowse options). If ...
[ "def", "register", "(", "self", ",", "*", "model_list", ",", "*", "*", "options", ")", ":", "databrowse_class", "=", "options", ".", "pop", "(", "'databrowse_class'", ",", "DefaultModelDatabrowse", ")", "for", "model", "in", "model_list", ":", "if", "model",...
Registers the given model(s) with the given databrowse site. The model(s) should be Model classes, not instances. If a databrowse class isn't given, it will use DefaultModelDatabrowse (the default databrowse options). If a model is already registered, this will raise AlreadyRegistered...
[ "Registers", "the", "given", "model", "(", "s", ")", "with", "the", "given", "databrowse", "site", "." ]
4469495cd47a0da506ddf4e8cc752c2f453e0339
https://github.com/Alir3z4/django-databrowse/blob/4469495cd47a0da506ddf4e8cc752c2f453e0339/django_databrowse/sites.py#L119-L136
train
Alir3z4/django-databrowse
django_databrowse/sites.py
DatabrowseSite.unregister
def unregister(self, *model_list): """ Unregisters the given model(s). If a model isn't already registered, this will raise NotRegistered. """ for model in model_list: if model not in self.registry: raise NotRegistered('The model %s is not registered'...
python
def unregister(self, *model_list): """ Unregisters the given model(s). If a model isn't already registered, this will raise NotRegistered. """ for model in model_list: if model not in self.registry: raise NotRegistered('The model %s is not registered'...
[ "def", "unregister", "(", "self", ",", "*", "model_list", ")", ":", "for", "model", "in", "model_list", ":", "if", "model", "not", "in", "self", ".", "registry", ":", "raise", "NotRegistered", "(", "'The model %s is not registered'", "%", "model", ".", "__na...
Unregisters the given model(s). If a model isn't already registered, this will raise NotRegistered.
[ "Unregisters", "the", "given", "model", "(", "s", ")", "." ]
4469495cd47a0da506ddf4e8cc752c2f453e0339
https://github.com/Alir3z4/django-databrowse/blob/4469495cd47a0da506ddf4e8cc752c2f453e0339/django_databrowse/sites.py#L138-L148
train
Alir3z4/django-databrowse
django_databrowse/sites.py
DatabrowseSite.root
def root(self, request, url): """ Handles main URL routing for the databrowse app. `url` is the remainder of the URL -- e.g. 'comments/comment/'. """ self.root_url = request.path[:len(request.path) - len(url)] url = url.rstrip('/') # Trim trailing slash, if it exists. ...
python
def root(self, request, url): """ Handles main URL routing for the databrowse app. `url` is the remainder of the URL -- e.g. 'comments/comment/'. """ self.root_url = request.path[:len(request.path) - len(url)] url = url.rstrip('/') # Trim trailing slash, if it exists. ...
[ "def", "root", "(", "self", ",", "request", ",", "url", ")", ":", "self", ".", "root_url", "=", "request", ".", "path", "[", ":", "len", "(", "request", ".", "path", ")", "-", "len", "(", "url", ")", "]", "url", "=", "url", ".", "rstrip", "(", ...
Handles main URL routing for the databrowse app. `url` is the remainder of the URL -- e.g. 'comments/comment/'.
[ "Handles", "main", "URL", "routing", "for", "the", "databrowse", "app", "." ]
4469495cd47a0da506ddf4e8cc752c2f453e0339
https://github.com/Alir3z4/django-databrowse/blob/4469495cd47a0da506ddf4e8cc752c2f453e0339/django_databrowse/sites.py#L150-L164
train
Alir3z4/django-databrowse
django_databrowse/sites.py
DatabrowseSite.model_page
def model_page(self, request, app_label, model_name, rest_of_url=None): """ Handles the model-specific functionality of the databrowse site, delegating<to the appropriate ModelDatabrowse class. """ try: model = get_model(app_label, model_name) except LookupErr...
python
def model_page(self, request, app_label, model_name, rest_of_url=None): """ Handles the model-specific functionality of the databrowse site, delegating<to the appropriate ModelDatabrowse class. """ try: model = get_model(app_label, model_name) except LookupErr...
[ "def", "model_page", "(", "self", ",", "request", ",", "app_label", ",", "model_name", ",", "rest_of_url", "=", "None", ")", ":", "try", ":", "model", "=", "get_model", "(", "app_label", ",", "model_name", ")", "except", "LookupError", ":", "model", "=", ...
Handles the model-specific functionality of the databrowse site, delegating<to the appropriate ModelDatabrowse class.
[ "Handles", "the", "model", "-", "specific", "functionality", "of", "the", "databrowse", "site", "delegating<to", "the", "appropriate", "ModelDatabrowse", "class", "." ]
4469495cd47a0da506ddf4e8cc752c2f453e0339
https://github.com/Alir3z4/django-databrowse/blob/4469495cd47a0da506ddf4e8cc752c2f453e0339/django_databrowse/sites.py#L173-L191
train
Alir3z4/django-databrowse
django_databrowse/datastructures.py
EasyInstanceField.values
def values(self): """ Returns a list of values for this field for this instance. It's a list so we can accomodate many-to-many fields. """ # This import is deliberately inside the function because it causes # some settings to be imported, and we don't want to do that at t...
python
def values(self): """ Returns a list of values for this field for this instance. It's a list so we can accomodate many-to-many fields. """ # This import is deliberately inside the function because it causes # some settings to be imported, and we don't want to do that at t...
[ "def", "values", "(", "self", ")", ":", "# This import is deliberately inside the function because it causes", "# some settings to be imported, and we don't want to do that at the", "# module level.", "if", "self", ".", "field", ".", "rel", ":", "if", "isinstance", "(", "self",...
Returns a list of values for this field for this instance. It's a list so we can accomodate many-to-many fields.
[ "Returns", "a", "list", "of", "values", "for", "this", "field", "for", "this", "instance", ".", "It", "s", "a", "list", "so", "we", "can", "accomodate", "many", "-", "to", "-", "many", "fields", "." ]
4469495cd47a0da506ddf4e8cc752c2f453e0339
https://github.com/Alir3z4/django-databrowse/blob/4469495cd47a0da506ddf4e8cc752c2f453e0339/django_databrowse/datastructures.py#L194-L230
train
Alir3z4/django-databrowse
django_databrowse/datastructures.py
EasyInstanceField.urls
def urls(self): "Returns a list of (value, URL) tuples." # First, check the urls() method for each plugin. plugin_urls = [] for plugin_name, plugin in \ self.model.model_databrowse().plugins.items(): urls = plugin.urls(plugin_name, self) ...
python
def urls(self): "Returns a list of (value, URL) tuples." # First, check the urls() method for each plugin. plugin_urls = [] for plugin_name, plugin in \ self.model.model_databrowse().plugins.items(): urls = plugin.urls(plugin_name, self) ...
[ "def", "urls", "(", "self", ")", ":", "# First, check the urls() method for each plugin.", "plugin_urls", "=", "[", "]", "for", "plugin_name", ",", "plugin", "in", "self", ".", "model", ".", "model_databrowse", "(", ")", ".", "plugins", ".", "items", "(", ")",...
Returns a list of (value, URL) tuples.
[ "Returns", "a", "list", "of", "(", "value", "URL", ")", "tuples", "." ]
4469495cd47a0da506ddf4e8cc752c2f453e0339
https://github.com/Alir3z4/django-databrowse/blob/4469495cd47a0da506ddf4e8cc752c2f453e0339/django_databrowse/datastructures.py#L232-L273
train
Alir3z4/django-databrowse
django_databrowse/plugins/calendars.py
CalendarPlugin.field_dict
def field_dict(self, model): """ Helper function that returns a dictionary of all DateFields or DateTimeFields in the given model. If self.field_names is set, it takes that into account when building the dictionary. """ if self.field_names is None: return dict...
python
def field_dict(self, model): """ Helper function that returns a dictionary of all DateFields or DateTimeFields in the given model. If self.field_names is set, it takes that into account when building the dictionary. """ if self.field_names is None: return dict...
[ "def", "field_dict", "(", "self", ",", "model", ")", ":", "if", "self", ".", "field_names", "is", "None", ":", "return", "dict", "(", "[", "(", "f", ".", "name", ",", "f", ")", "for", "f", "in", "model", ".", "_meta", ".", "fields", "if", "isinst...
Helper function that returns a dictionary of all DateFields or DateTimeFields in the given model. If self.field_names is set, it takes that into account when building the dictionary.
[ "Helper", "function", "that", "returns", "a", "dictionary", "of", "all", "DateFields", "or", "DateTimeFields", "in", "the", "given", "model", ".", "If", "self", ".", "field_names", "is", "set", "it", "takes", "that", "into", "account", "when", "building", "t...
4469495cd47a0da506ddf4e8cc752c2f453e0339
https://github.com/Alir3z4/django-databrowse/blob/4469495cd47a0da506ddf4e8cc752c2f453e0339/django_databrowse/plugins/calendars.py#L51-L64
train
BD2KGenomics/toil-scripts
src/toil_scripts/adam_kmers/count_kmers.py
kmer_dag
def kmer_dag(job, input_file, output_path, kmer_length, spark_conf, workers, cores, memory, sudo): ''' Optionally launches a Spark cluster and then runs ADAM to count k-mers on an input file. :param ...
python
def kmer_dag(job, input_file, output_path, kmer_length, spark_conf, workers, cores, memory, sudo): ''' Optionally launches a Spark cluster and then runs ADAM to count k-mers on an input file. :param ...
[ "def", "kmer_dag", "(", "job", ",", "input_file", ",", "output_path", ",", "kmer_length", ",", "spark_conf", ",", "workers", ",", "cores", ",", "memory", ",", "sudo", ")", ":", "require", "(", "(", "spark_conf", "is", "not", "None", "and", "workers", "is...
Optionally launches a Spark cluster and then runs ADAM to count k-mers on an input file. :param job: Toil job :param input_file: URL/path to input file to count k-mers on :param output_path: URL/path to save k-mer counts at :param kmer_length: The length of k-mer substrings to count. :param spa...
[ "Optionally", "launches", "a", "Spark", "cluster", "and", "then", "runs", "ADAM", "to", "count", "k", "-", "mers", "on", "an", "input", "file", "." ]
f878d863defcdccaabb7fe06f991451b7a198fb7
https://github.com/BD2KGenomics/toil-scripts/blob/f878d863defcdccaabb7fe06f991451b7a198fb7/src/toil_scripts/adam_kmers/count_kmers.py#L20-L74
train
BD2KGenomics/toil-scripts
src/toil_scripts/adam_kmers/count_kmers.py
download_count_upload
def download_count_upload(job, master_ip, input_file, output_file, kmer_length, spark_conf, memory, sudo): ''' Runs k-mer counting...
python
def download_count_upload(job, master_ip, input_file, output_file, kmer_length, spark_conf, memory, sudo): ''' Runs k-mer counting...
[ "def", "download_count_upload", "(", "job", ",", "master_ip", ",", "input_file", ",", "output_file", ",", "kmer_length", ",", "spark_conf", ",", "memory", ",", "sudo", ")", ":", "if", "master_ip", "is", "not", "None", ":", "hdfs_dir", "=", "\"hdfs://{0}:{1}/\"...
Runs k-mer counting. 1. If the input file is located in S3, the file is copied into HDFS. 2. If the input file is not in Parquet format, the file is converted into Parquet. 3. The k-mers are counted and saved as text. 4. If the output path is an S3 URL, the file is copied back to S3. :param job: T...
[ "Runs", "k", "-", "mer", "counting", "." ]
f878d863defcdccaabb7fe06f991451b7a198fb7
https://github.com/BD2KGenomics/toil-scripts/blob/f878d863defcdccaabb7fe06f991451b7a198fb7/src/toil_scripts/adam_kmers/count_kmers.py#L76-L172
train
BD2KGenomics/toil-scripts
src/toil_scripts/adam_kmers/count_kmers.py
main
def main(): ''' Sets up command line parser for Toil/ADAM based k-mer counter, and launches k-mer counter with optional Spark cluster. ''' parser = argparse.ArgumentParser() # add parser arguments parser.add_argument('--input_path', help='The full path to the input ...
python
def main(): ''' Sets up command line parser for Toil/ADAM based k-mer counter, and launches k-mer counter with optional Spark cluster. ''' parser = argparse.ArgumentParser() # add parser arguments parser.add_argument('--input_path', help='The full path to the input ...
[ "def", "main", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", ")", "# add parser arguments", "parser", ".", "add_argument", "(", "'--input_path'", ",", "help", "=", "'The full path to the input SAM/BAM/ADAM/FASTQ file.'", ")", "parser", ".", "...
Sets up command line parser for Toil/ADAM based k-mer counter, and launches k-mer counter with optional Spark cluster.
[ "Sets", "up", "command", "line", "parser", "for", "Toil", "/", "ADAM", "based", "k", "-", "mer", "counter", "and", "launches", "k", "-", "mer", "counter", "with", "optional", "Spark", "cluster", "." ]
f878d863defcdccaabb7fe06f991451b7a198fb7
https://github.com/BD2KGenomics/toil-scripts/blob/f878d863defcdccaabb7fe06f991451b7a198fb7/src/toil_scripts/adam_kmers/count_kmers.py#L175-L223
train
BD2KGenomics/toil-scripts
src/toil_scripts/gatk_germline/germline.py
run_gatk_germline_pipeline
def run_gatk_germline_pipeline(job, samples, config): """ Downloads shared files and calls the GATK best practices germline pipeline for a cohort of samples :param JobFunctionWrappingJob job: passed automatically by Toil :param list[GermlineSample] samples: List of GermlineSample namedtuples :param...
python
def run_gatk_germline_pipeline(job, samples, config): """ Downloads shared files and calls the GATK best practices germline pipeline for a cohort of samples :param JobFunctionWrappingJob job: passed automatically by Toil :param list[GermlineSample] samples: List of GermlineSample namedtuples :param...
[ "def", "run_gatk_germline_pipeline", "(", "job", ",", "samples", ",", "config", ")", ":", "# Determine the available disk space on a worker node before any jobs have been run.", "work_dir", "=", "job", ".", "fileStore", ".", "getLocalTempDir", "(", ")", "st", "=", "os", ...
Downloads shared files and calls the GATK best practices germline pipeline for a cohort of samples :param JobFunctionWrappingJob job: passed automatically by Toil :param list[GermlineSample] samples: List of GermlineSample namedtuples :param Namespace config: Configuration options for pipeline Requ...
[ "Downloads", "shared", "files", "and", "calls", "the", "GATK", "best", "practices", "germline", "pipeline", "for", "a", "cohort", "of", "samples" ]
f878d863defcdccaabb7fe06f991451b7a198fb7
https://github.com/BD2KGenomics/toil-scripts/blob/f878d863defcdccaabb7fe06f991451b7a198fb7/src/toil_scripts/gatk_germline/germline.py#L88-L132
train
BD2KGenomics/toil-scripts
src/toil_scripts/gatk_germline/germline.py
gatk_germline_pipeline
def gatk_germline_pipeline(job, samples, config): """ Runs the GATK best practices pipeline for germline SNP and INDEL discovery. Steps in Pipeline 0: Generate and preprocess BAM - Uploads processed BAM to output directory 1: Call Variants using HaplotypeCaller - Uploads GVCF 2:...
python
def gatk_germline_pipeline(job, samples, config): """ Runs the GATK best practices pipeline for germline SNP and INDEL discovery. Steps in Pipeline 0: Generate and preprocess BAM - Uploads processed BAM to output directory 1: Call Variants using HaplotypeCaller - Uploads GVCF 2:...
[ "def", "gatk_germline_pipeline", "(", "job", ",", "samples", ",", "config", ")", ":", "require", "(", "len", "(", "samples", ")", ">", "0", ",", "'No samples were provided!'", ")", "# Get total size of genome reference files. This is used for configuring disk size.", "gen...
Runs the GATK best practices pipeline for germline SNP and INDEL discovery. Steps in Pipeline 0: Generate and preprocess BAM - Uploads processed BAM to output directory 1: Call Variants using HaplotypeCaller - Uploads GVCF 2: Genotype VCF - Uploads VCF 3: Filter Variants usi...
[ "Runs", "the", "GATK", "best", "practices", "pipeline", "for", "germline", "SNP", "and", "INDEL", "discovery", "." ]
f878d863defcdccaabb7fe06f991451b7a198fb7
https://github.com/BD2KGenomics/toil-scripts/blob/f878d863defcdccaabb7fe06f991451b7a198fb7/src/toil_scripts/gatk_germline/germline.py#L135-L233
train
BD2KGenomics/toil-scripts
src/toil_scripts/gatk_germline/germline.py
joint_genotype_and_filter
def joint_genotype_and_filter(job, gvcfs, config): """ Checks for enough disk space for joint genotyping, then calls the genotype and filter pipeline function. :param JobFunctionWrappingJob job: passed automatically by Toil :param dict gvcfs: Dictionary of GVCFs {Sample ID: FileStoreID} :param Name...
python
def joint_genotype_and_filter(job, gvcfs, config): """ Checks for enough disk space for joint genotyping, then calls the genotype and filter pipeline function. :param JobFunctionWrappingJob job: passed automatically by Toil :param dict gvcfs: Dictionary of GVCFs {Sample ID: FileStoreID} :param Name...
[ "def", "joint_genotype_and_filter", "(", "job", ",", "gvcfs", ",", "config", ")", ":", "# Get the total size of genome reference files", "genome_ref_size", "=", "config", ".", "genome_fasta", ".", "size", "+", "config", ".", "genome_fai", ".", "size", "+", "config",...
Checks for enough disk space for joint genotyping, then calls the genotype and filter pipeline function. :param JobFunctionWrappingJob job: passed automatically by Toil :param dict gvcfs: Dictionary of GVCFs {Sample ID: FileStoreID} :param Namespace config: Input parameters and reference FileStoreIDs ...
[ "Checks", "for", "enough", "disk", "space", "for", "joint", "genotyping", "then", "calls", "the", "genotype", "and", "filter", "pipeline", "function", "." ]
f878d863defcdccaabb7fe06f991451b7a198fb7
https://github.com/BD2KGenomics/toil-scripts/blob/f878d863defcdccaabb7fe06f991451b7a198fb7/src/toil_scripts/gatk_germline/germline.py#L236-L262
train