repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
solocompt/plugs-filter
plugs_filter/utils.py
class_lookups
def class_lookups(model_field): """ Return list of available lookups for the passed in (model) field type """ field_class = type(model_field) field_type = match_field(field_class) return get_field_lookups(field_type, model_field.null)
python
def class_lookups(model_field): """ Return list of available lookups for the passed in (model) field type """ field_class = type(model_field) field_type = match_field(field_class) return get_field_lookups(field_type, model_field.null)
[ "def", "class_lookups", "(", "model_field", ")", ":", "field_class", "=", "type", "(", "model_field", ")", "field_type", "=", "match_field", "(", "field_class", ")", "return", "get_field_lookups", "(", "field_type", ",", "model_field", ".", "null", ")" ]
Return list of available lookups for the passed in (model) field type
[ "Return", "list", "of", "available", "lookups", "for", "the", "passed", "in", "(", "model", ")", "field", "type" ]
train
https://github.com/solocompt/plugs-filter/blob/cb34c7d662d3f96c07c10b3ed0a34bafef78b52c/plugs_filter/utils.py#L32-L39
lehins/python-wepay
wepay/calls/withdrawal.py
Withdrawal.__modify
def __modify(self, withdrawal_id, **kwargs): """Call documentation: `/withdrawal/modify <https://www.wepay.com/developer/reference/withdrawal#modify>`_, plus extra keyword parameters: :keyword str access_token: will be used instead of instance's ``access_token``, with...
python
def __modify(self, withdrawal_id, **kwargs): """Call documentation: `/withdrawal/modify <https://www.wepay.com/developer/reference/withdrawal#modify>`_, plus extra keyword parameters: :keyword str access_token: will be used instead of instance's ``access_token``, with...
[ "def", "__modify", "(", "self", ",", "withdrawal_id", ",", "*", "*", "kwargs", ")", ":", "params", "=", "{", "'withdrawal_id'", ":", "withdrawal_id", "}", "return", "self", ".", "make_call", "(", "self", ".", "__modify", ",", "params", ",", "kwargs", ")"...
Call documentation: `/withdrawal/modify <https://www.wepay.com/developer/reference/withdrawal#modify>`_, plus extra keyword parameters: :keyword str access_token: will be used instead of instance's ``access_token``, with ``batch_mode=True`` will set `authorization` ...
[ "Call", "documentation", ":", "/", "withdrawal", "/", "modify", "<https", ":", "//", "www", ".", "wepay", ".", "com", "/", "developer", "/", "reference", "/", "withdrawal#modify", ">", "_", "plus", "extra", "keyword", "parameters", ":", ":", "keyword", "st...
train
https://github.com/lehins/python-wepay/blob/414d25a1a8d0ecb22a3ddd1f16c60b805bb52a1f/wepay/calls/withdrawal.py#L59-L81
lehins/python-wepay
wepay/calls/withdrawal.py
Withdrawal.__create
def __create(self, account_id, **kwargs): """Call documentation: `/withdrawal/create <https://www.wepay.com/developer/reference/withdrawal#create>`_, plus extra keyword parameters: :keyword str access_token: will be used instead of instance's ``access_token``, with ``...
python
def __create(self, account_id, **kwargs): """Call documentation: `/withdrawal/create <https://www.wepay.com/developer/reference/withdrawal#create>`_, plus extra keyword parameters: :keyword str access_token: will be used instead of instance's ``access_token``, with ``...
[ "def", "__create", "(", "self", ",", "account_id", ",", "*", "*", "kwargs", ")", ":", "params", "=", "{", "'account_id'", ":", "account_id", "}", "return", "self", ".", "make_call", "(", "self", ".", "__create", ",", "params", ",", "kwargs", ")" ]
Call documentation: `/withdrawal/create <https://www.wepay.com/developer/reference/withdrawal#create>`_, plus extra keyword parameters: :keyword str access_token: will be used instead of instance's ``access_token``, with ``batch_mode=True`` will set `authorization` ...
[ "Call", "documentation", ":", "/", "withdrawal", "/", "create", "<https", ":", "//", "www", ".", "wepay", ".", "com", "/", "developer", "/", "reference", "/", "withdrawal#create", ">", "_", "plus", "extra", "keyword", "parameters", ":", ":", "keyword", "st...
train
https://github.com/lehins/python-wepay/blob/414d25a1a8d0ecb22a3ddd1f16c60b805bb52a1f/wepay/calls/withdrawal.py#L87-L113
chrisnorman7/confmanager
confmanager/parser.py
parse_template
def parse_template(template, target): """Given a dictionary template containing at least most of the relevant information and a dictionary target containing sections, options and values, consolidate target into a new confmanager object and return it.""" c = ConfManager('') for section in template: c.add_sectio...
python
def parse_template(template, target): """Given a dictionary template containing at least most of the relevant information and a dictionary target containing sections, options and values, consolidate target into a new confmanager object and return it.""" c = ConfManager('') for section in template: c.add_sectio...
[ "def", "parse_template", "(", "template", ",", "target", ")", ":", "c", "=", "ConfManager", "(", "''", ")", "for", "section", "in", "template", ":", "c", ".", "add_section", "(", "section", ")", "for", "option", ",", "o", "in", "template", "[", "sectio...
Given a dictionary template containing at least most of the relevant information and a dictionary target containing sections, options and values, consolidate target into a new confmanager object and return it.
[ "Given", "a", "dictionary", "template", "containing", "at", "least", "most", "of", "the", "relevant", "information", "and", "a", "dictionary", "target", "containing", "sections", "options", "and", "values", "consolidate", "target", "into", "a", "new", "confmanager...
train
https://github.com/chrisnorman7/confmanager/blob/54a3ce0b596f9da32ae82fd4ff4cb46bb1cf23b1/confmanager/parser.py#L6-L20
chrisnorman7/confmanager
confmanager/parser.py
parse_json
def parse_json(target, json, create_sections = False, create_options = False): """Given a confmanager object and a dictionary object, import the values from the dictionary into the object, optionally adding sections and options as it goes.""" is_dict = isinstance(json, dict) for o in json: if is_dict: sect...
python
def parse_json(target, json, create_sections = False, create_options = False): """Given a confmanager object and a dictionary object, import the values from the dictionary into the object, optionally adding sections and options as it goes.""" is_dict = isinstance(json, dict) for o in json: if is_dict: sect...
[ "def", "parse_json", "(", "target", ",", "json", ",", "create_sections", "=", "False", ",", "create_options", "=", "False", ")", ":", "is_dict", "=", "isinstance", "(", "json", ",", "dict", ")", "for", "o", "in", "json", ":", "if", "is_dict", ":", "sec...
Given a confmanager object and a dictionary object, import the values from the dictionary into the object, optionally adding sections and options as it goes.
[ "Given", "a", "confmanager", "object", "and", "a", "dictionary", "object", "import", "the", "values", "from", "the", "dictionary", "into", "the", "object", "optionally", "adding", "sections", "and", "options", "as", "it", "goes", "." ]
train
https://github.com/chrisnorman7/confmanager/blob/54a3ce0b596f9da32ae82fd4ff4cb46bb1cf23b1/confmanager/parser.py#L22-L38
rackerlabs/silverberg
silverberg/logger.py
LoggingCQLClient.execute
def execute(self, query, args, consistency): """ See :py:func:`silverberg.client.CQLClient.execute` """ start_seconds = self._clock.seconds() def record_time(result): seconds_taken = self._clock.seconds() - start_seconds kwargs = dict(query=query, data=ar...
python
def execute(self, query, args, consistency): """ See :py:func:`silverberg.client.CQLClient.execute` """ start_seconds = self._clock.seconds() def record_time(result): seconds_taken = self._clock.seconds() - start_seconds kwargs = dict(query=query, data=ar...
[ "def", "execute", "(", "self", ",", "query", ",", "args", ",", "consistency", ")", ":", "start_seconds", "=", "self", ".", "_clock", ".", "seconds", "(", ")", "def", "record_time", "(", "result", ")", ":", "seconds_taken", "=", "self", ".", "_clock", "...
See :py:func:`silverberg.client.CQLClient.execute`
[ "See", ":", "py", ":", "func", ":", "silverberg", ".", "client", ".", "CQLClient", ".", "execute" ]
train
https://github.com/rackerlabs/silverberg/blob/c6fae78923a019f1615e9516ab30fa105c72a542/silverberg/logger.py#L36-L53
DanCardin/tawdry
tawdry/tawdry.py
generate_sitemap
def generate_sitemap(sitemap: typing.Mapping, prefix: list=None): """Create a sitemap template from the given sitemap. The `sitemap` should be a mapping where the key is a string which represents a single URI segment, and the value is either another mapping or a callable (e.g. function) object. Ar...
python
def generate_sitemap(sitemap: typing.Mapping, prefix: list=None): """Create a sitemap template from the given sitemap. The `sitemap` should be a mapping where the key is a string which represents a single URI segment, and the value is either another mapping or a callable (e.g. function) object. Ar...
[ "def", "generate_sitemap", "(", "sitemap", ":", "typing", ".", "Mapping", ",", "prefix", ":", "list", "=", "None", ")", ":", "# Ensures all generated urls are prefixed with a the prefix string", "if", "prefix", "is", "None", ":", "prefix", "=", "[", "]", "for", ...
Create a sitemap template from the given sitemap. The `sitemap` should be a mapping where the key is a string which represents a single URI segment, and the value is either another mapping or a callable (e.g. function) object. Args: sitemap: The definition of the routes and their views ...
[ "Create", "a", "sitemap", "template", "from", "the", "given", "sitemap", "." ]
train
https://github.com/DanCardin/tawdry/blob/6683b9c54eb9205f7179a854aac1cc0e6ba34be6/tawdry/tawdry.py#L13-L58
coghost/izen
izen/slnm.py
gen_find_method
def gen_find_method(ele_type, multiple=True, extra_maps=None): """ 将 ele_type 转换成对应的元素查找方法 e.g:: make_elt(ele_type=name, False) => find_element_by_name make_elt(ele_type=name, True) => find_elements_by_name :param ele_type: :type ele_type: :param multiple: :type multiple: ...
python
def gen_find_method(ele_type, multiple=True, extra_maps=None): """ 将 ele_type 转换成对应的元素查找方法 e.g:: make_elt(ele_type=name, False) => find_element_by_name make_elt(ele_type=name, True) => find_elements_by_name :param ele_type: :type ele_type: :param multiple: :type multiple: ...
[ "def", "gen_find_method", "(", "ele_type", ",", "multiple", "=", "True", ",", "extra_maps", "=", "None", ")", ":", "_", "=", "'elements'", "if", "multiple", "else", "'element'", "d", "=", "{", "'class'", ":", "'class_name'", "}", "if", "isinstance", "(", ...
将 ele_type 转换成对应的元素查找方法 e.g:: make_elt(ele_type=name, False) => find_element_by_name make_elt(ele_type=name, True) => find_elements_by_name :param ele_type: :type ele_type: :param multiple: :type multiple: :param extra_maps: :type extra_maps: :return:
[ "将", "ele_type", "转换成对应的元素查找方法", "e", ".", "g", "::" ]
train
https://github.com/coghost/izen/blob/432db017f99dd2ba809e1ba1792145ab6510263d/izen/slnm.py#L43-L65
coghost/izen
izen/slnm.py
Robot.get_elements
def get_elements(self, dat, multiple=False, retry=1, **kwargs): """ 映射 dat:dict => ``find_element_by_dat.key`` 来查找元素 :param dat: a dict like {'name': <the ele name>} :type dat: dict :param multiple: :type multiple: bool :param retry: :type retry: int ...
python
def get_elements(self, dat, multiple=False, retry=1, **kwargs): """ 映射 dat:dict => ``find_element_by_dat.key`` 来查找元素 :param dat: a dict like {'name': <the ele name>} :type dat: dict :param multiple: :type multiple: bool :param retry: :type retry: int ...
[ "def", "get_elements", "(", "self", ",", "dat", ",", "multiple", "=", "False", ",", "retry", "=", "1", ",", "*", "*", "kwargs", ")", ":", "if", "not", "isinstance", "(", "dat", ",", "dict", ")", ":", "return", "dat", "while", "retry", ">", "0", "...
映射 dat:dict => ``find_element_by_dat.key`` 来查找元素 :param dat: a dict like {'name': <the ele name>} :type dat: dict :param multiple: :type multiple: bool :param retry: :type retry: int :return: :rtype:
[ "映射", "dat", ":", "dict", "=", ">", "find_element_by_dat", ".", "key", "来查找元素" ]
train
https://github.com/coghost/izen/blob/432db017f99dd2ba809e1ba1792145ab6510263d/izen/slnm.py#L94-L120
coghost/izen
izen/slnm.py
Robot.has_element
def has_element(self, dat, skip_log=False): """ :param dat: dict like {'name': <the ele name>} :type dat: dict :param skip_log: skip log at your wish :type skip_log: :return: :rtype: """ try: if self.get_elements(dat, skip_log=skip_log)...
python
def has_element(self, dat, skip_log=False): """ :param dat: dict like {'name': <the ele name>} :type dat: dict :param skip_log: skip log at your wish :type skip_log: :return: :rtype: """ try: if self.get_elements(dat, skip_log=skip_log)...
[ "def", "has_element", "(", "self", ",", "dat", ",", "skip_log", "=", "False", ")", ":", "try", ":", "if", "self", ".", "get_elements", "(", "dat", ",", "skip_log", "=", "skip_log", ")", ":", "return", "True", "except", "Exception", "as", "_", ":", "i...
:param dat: dict like {'name': <the ele name>} :type dat: dict :param skip_log: skip log at your wish :type skip_log: :return: :rtype:
[ ":", "param", "dat", ":", "dict", "like", "{", "name", ":", "<the", "ele", "name", ">", "}", ":", "type", "dat", ":", "dict", ":", "param", "skip_log", ":", "skip", "log", "at", "your", "wish", ":", "type", "skip_log", ":", ":", "return", ":", ":...
train
https://github.com/coghost/izen/blob/432db017f99dd2ba809e1ba1792145ab6510263d/izen/slnm.py#L122-L137
coghost/izen
izen/slnm.py
Robot._mock_input
def _mock_input(self, target, content): """ mock human input :param target: the element to input to :param content: the content :return: """ content = helper.to_str(content) for w in content: target.send_keys(w) rand_block(0.01...
python
def _mock_input(self, target, content): """ mock human input :param target: the element to input to :param content: the content :return: """ content = helper.to_str(content) for w in content: target.send_keys(w) rand_block(0.01...
[ "def", "_mock_input", "(", "self", ",", "target", ",", "content", ")", ":", "content", "=", "helper", ".", "to_str", "(", "content", ")", "for", "w", "in", "content", ":", "target", ".", "send_keys", "(", "w", ")", "rand_block", "(", "0.01", ",", "0....
mock human input :param target: the element to input to :param content: the content :return:
[ "mock", "human", "input" ]
train
https://github.com/coghost/izen/blob/432db017f99dd2ba809e1ba1792145ab6510263d/izen/slnm.py#L164-L175
coghost/izen
izen/slnm.py
Robot.mock_click
def mock_click(self, target, ele_num=None): """ 将 ``target`` 转换为 web 元素, 并模拟点击 ele_num 为指定点击哪个元素, 如果为 any, 则触发任意一个 :param ele_num: :param target: :return: """ # 如果是 multiple 将首先获取满足条件的所有元素, 并倒序获取最后一个元素. if ele_num: # 获取所有元素 ...
python
def mock_click(self, target, ele_num=None): """ 将 ``target`` 转换为 web 元素, 并模拟点击 ele_num 为指定点击哪个元素, 如果为 any, 则触发任意一个 :param ele_num: :param target: :return: """ # 如果是 multiple 将首先获取满足条件的所有元素, 并倒序获取最后一个元素. if ele_num: # 获取所有元素 ...
[ "def", "mock_click", "(", "self", ",", "target", ",", "ele_num", "=", "None", ")", ":", "# 如果是 multiple 将首先获取满足条件的所有元素, 并倒序获取最后一个元素.", "if", "ele_num", ":", "# 获取所有元素", "elements", "=", "self", ".", "get_elements", "(", "target", ",", "multiple", "=", "True", ...
将 ``target`` 转换为 web 元素, 并模拟点击 ele_num 为指定点击哪个元素, 如果为 any, 则触发任意一个 :param ele_num: :param target: :return:
[ "将", "target", "转换为", "web", "元素", "并模拟点击", "ele_num", "为指定点击哪个元素", "如果为", "any", "则触发任意一个" ]
train
https://github.com/coghost/izen/blob/432db017f99dd2ba809e1ba1792145ab6510263d/izen/slnm.py#L177-L219
coghost/izen
izen/slnm.py
Robot.mock_key_down
def mock_key_down(self, target, key_press_times): """ key_press_times => >= 0 则 DOWN, 否则 UP :param target: :type target: :param key_press_times: :type key_press_times: int :return: :rtype: """ key = Keys.DOWN if key_press_times...
python
def mock_key_down(self, target, key_press_times): """ key_press_times => >= 0 则 DOWN, 否则 UP :param target: :type target: :param key_press_times: :type key_press_times: int :return: :rtype: """ key = Keys.DOWN if key_press_times...
[ "def", "mock_key_down", "(", "self", ",", "target", ",", "key_press_times", ")", ":", "key", "=", "Keys", ".", "DOWN", "if", "key_press_times", "<", "0", ":", "key", "=", "Keys", ".", "UP", "for", "i", "in", "range", "(", "abs", "(", "key_press_times",...
key_press_times => >= 0 则 DOWN, 否则 UP :param target: :type target: :param key_press_times: :type key_press_times: int :return: :rtype:
[ "key_press_times", "=", ">", ">", "=", "0", "则", "DOWN", "否则", "UP" ]
train
https://github.com/coghost/izen/blob/432db017f99dd2ba809e1ba1792145ab6510263d/izen/slnm.py#L226-L243
coghost/izen
izen/slnm.py
Robot.mock_input
def mock_input(self, dat, term='', clear=True, mock_input_change='', submit=False, multiple=0): """ 输入 term 到 input:ele(dat) 元素 如果 ``mock_input_change`` 不为空, 则该 input 不能保留原始值, 可以输入一个值, 然后清空. - clear 清空input的元素 - submit 提交 :param dat: :...
python
def mock_input(self, dat, term='', clear=True, mock_input_change='', submit=False, multiple=0): """ 输入 term 到 input:ele(dat) 元素 如果 ``mock_input_change`` 不为空, 则该 input 不能保留原始值, 可以输入一个值, 然后清空. - clear 清空input的元素 - submit 提交 :param dat: :...
[ "def", "mock_input", "(", "self", ",", "dat", ",", "term", "=", "''", ",", "clear", "=", "True", ",", "mock_input_change", "=", "''", ",", "submit", "=", "False", ",", "multiple", "=", "0", ")", ":", "target", "=", "self", ".", "get_elements", "(", ...
输入 term 到 input:ele(dat) 元素 如果 ``mock_input_change`` 不为空, 则该 input 不能保留原始值, 可以输入一个值, 然后清空. - clear 清空input的元素 - submit 提交 :param dat: :type dat: dict :param term: :type term: str :param submit: :type submit: bool :param clear: ...
[ "输入", "term", "到", "input", ":", "ele", "(", "dat", ")", "元素", "如果", "mock_input_change", "不为空", "则该", "input", "不能保留原始值", "可以输入一个值", "然后清空", "." ]
train
https://github.com/coghost/izen/blob/432db017f99dd2ba809e1ba1792145ab6510263d/izen/slnm.py#L251-L292
coghost/izen
izen/slnm.py
Robot.scroll_by_key_down
def scroll_by_key_down(self, dat, distance_togo): """ 模拟 page_up/down 方式来滚动 :param dat: :type dat: :param distance_togo: :type distance_togo: :return: :rtype: """ try: target = self.get_elements(dat) distance_done = 0 ...
python
def scroll_by_key_down(self, dat, distance_togo): """ 模拟 page_up/down 方式来滚动 :param dat: :type dat: :param distance_togo: :type distance_togo: :return: :rtype: """ try: target = self.get_elements(dat) distance_done = 0 ...
[ "def", "scroll_by_key_down", "(", "self", ",", "dat", ",", "distance_togo", ")", ":", "try", ":", "target", "=", "self", ".", "get_elements", "(", "dat", ")", "distance_done", "=", "0", "while", "distance_done", "<", "distance_togo", ":", "chance", "=", "r...
模拟 page_up/down 方式来滚动 :param dat: :type dat: :param distance_togo: :type distance_togo: :return: :rtype:
[ "模拟", "page_up", "/", "down", "方式来滚动" ]
train
https://github.com/coghost/izen/blob/432db017f99dd2ba809e1ba1792145ab6510263d/izen/slnm.py#L294-L320
coghost/izen
izen/slnm.py
ChromeRobot.chrome_driver
def chrome_driver(self, **kwargs): """ supported: to = timeout, 30 images = load images, 0 """ options = webdriver.ChromeOptions() options.add_argument('--no-sandbox') prefs = {"profile.managed_default_content_settings.images": kwargs.get('images'...
python
def chrome_driver(self, **kwargs): """ supported: to = timeout, 30 images = load images, 0 """ options = webdriver.ChromeOptions() options.add_argument('--no-sandbox') prefs = {"profile.managed_default_content_settings.images": kwargs.get('images'...
[ "def", "chrome_driver", "(", "self", ",", "*", "*", "kwargs", ")", ":", "options", "=", "webdriver", ".", "ChromeOptions", "(", ")", "options", ".", "add_argument", "(", "'--no-sandbox'", ")", "prefs", "=", "{", "\"profile.managed_default_content_settings.images\"...
supported: to = timeout, 30 images = load images, 0
[ "supported", ":", "to", "=", "timeout", "30", "images", "=", "load", "images", "0" ]
train
https://github.com/coghost/izen/blob/432db017f99dd2ba809e1ba1792145ab6510263d/izen/slnm.py#L417-L432
coghost/izen
izen/slnm.py
ASite.__has_next_page
def __has_next_page(self, current_page_num=0): """ this is an example for debug purpose only... """ try: next_page = self.robot.get_elements( self.base.get('next_page'), multiple=True ) log.debug('<Site> has {} next page elems'....
python
def __has_next_page(self, current_page_num=0): """ this is an example for debug purpose only... """ try: next_page = self.robot.get_elements( self.base.get('next_page'), multiple=True ) log.debug('<Site> has {} next page elems'....
[ "def", "__has_next_page", "(", "self", ",", "current_page_num", "=", "0", ")", ":", "try", ":", "next_page", "=", "self", ".", "robot", ".", "get_elements", "(", "self", ".", "base", ".", "get", "(", "'next_page'", ")", ",", "multiple", "=", "True", ")...
this is an example for debug purpose only...
[ "this", "is", "an", "example", "for", "debug", "purpose", "only", "..." ]
train
https://github.com/coghost/izen/blob/432db017f99dd2ba809e1ba1792145ab6510263d/izen/slnm.py#L478-L497
coghost/izen
izen/slnm.py
ASite._check_params
def _check_params(self, *args, **kwargs): """ 检查参数信息是否匹配 """ terms = kwargs.get('terms') if not terms: raise crawler.CrawlerParamsError('Terms needed!') if not isinstance(terms, list): terms = [terms] if len(terms) != len(self.base['terms']): ...
python
def _check_params(self, *args, **kwargs): """ 检查参数信息是否匹配 """ terms = kwargs.get('terms') if not terms: raise crawler.CrawlerParamsError('Terms needed!') if not isinstance(terms, list): terms = [terms] if len(terms) != len(self.base['terms']): ...
[ "def", "_check_params", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "terms", "=", "kwargs", ".", "get", "(", "'terms'", ")", "if", "not", "terms", ":", "raise", "crawler", ".", "CrawlerParamsError", "(", "'Terms needed!'", ")", "i...
检查参数信息是否匹配
[ "检查参数信息是否匹配" ]
train
https://github.com/coghost/izen/blob/432db017f99dd2ba809e1ba1792145ab6510263d/izen/slnm.py#L548-L558
coghost/izen
izen/slnm.py
ASite.mock_input_submit
def mock_input_submit(self, *args, **kwargs): """ 模拟输入参数, 然后提交 """ self.robot.load_page(self.base['homepage']) if kwargs.get('force_window_topper'): self.force_window_topper() if self.base.get('popovers'): self.mock_popovers() if self.base.get('activate_...
python
def mock_input_submit(self, *args, **kwargs): """ 模拟输入参数, 然后提交 """ self.robot.load_page(self.base['homepage']) if kwargs.get('force_window_topper'): self.force_window_topper() if self.base.get('popovers'): self.mock_popovers() if self.base.get('activate_...
[ "def", "mock_input_submit", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "robot", ".", "load_page", "(", "self", ".", "base", "[", "'homepage'", "]", ")", "if", "kwargs", ".", "get", "(", "'force_window_topper'", ")", ...
模拟输入参数, 然后提交
[ "模拟输入参数", "然后提交" ]
train
https://github.com/coghost/izen/blob/432db017f99dd2ba809e1ba1792145ab6510263d/izen/slnm.py#L568-L601
coghost/izen
izen/slnm.py
ASite.mock_human_crawl
def mock_human_crawl(self, *args, **kwargs): """ 模拟 human 操作方式爬取站点 """ self._check_params(*args, **kwargs) self.mock_input_submit(*args, **kwargs) return self.response_result(**kwargs)
python
def mock_human_crawl(self, *args, **kwargs): """ 模拟 human 操作方式爬取站点 """ self._check_params(*args, **kwargs) self.mock_input_submit(*args, **kwargs) return self.response_result(**kwargs)
[ "def", "mock_human_crawl", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_check_params", "(", "*", "args", ",", "*", "*", "kwargs", ")", "self", ".", "mock_input_submit", "(", "*", "args", ",", "*", "*", "kwargs", ...
模拟 human 操作方式爬取站点
[ "模拟", "human", "操作方式爬取站点" ]
train
https://github.com/coghost/izen/blob/432db017f99dd2ba809e1ba1792145ab6510263d/izen/slnm.py#L603-L607
coghost/izen
izen/slnm.py
ASite.response_result
def response_result(self, **kwargs): """ default will fetch MAX_AP pages yield `self.driver.page_source, self.driver.current_url, 1` after mock submit, the first page is crawled. so start@ index of 1, and yield first page first when running over, use else to yield the last page....
python
def response_result(self, **kwargs): """ default will fetch MAX_AP pages yield `self.driver.page_source, self.driver.current_url, 1` after mock submit, the first page is crawled. so start@ index of 1, and yield first page first when running over, use else to yield the last page....
[ "def", "response_result", "(", "self", ",", "*", "*", "kwargs", ")", ":", "page_togo", "=", "kwargs", ".", "get", "(", "'page_togo'", ",", "self", ".", "max_page_togo", ")", "if", "page_togo", "<=", "1", ":", "return", "self", ".", "robot", ".", "drive...
default will fetch MAX_AP pages yield `self.driver.page_source, self.driver.current_url, 1` after mock submit, the first page is crawled. so start@ index of 1, and yield first page first when running over, use else to yield the last page. 程序运行到此, 已经load 了第一页, 故在进行操作 `点击下一页` 之前,...
[ "default", "will", "fetch", "MAX_AP", "pages", "yield", "self", ".", "driver", ".", "page_source", "self", ".", "driver", ".", "current_url", "1" ]
train
https://github.com/coghost/izen/blob/432db017f99dd2ba809e1ba1792145ab6510263d/izen/slnm.py#L609-L648
tBaxter/tango-comments
build/lib/tango_comments/admin.py
CommentsAdmin._bulk_flag
def _bulk_flag(self, request, queryset, action, done_message): """ Flag, approve, or remove some comments from an admin action. Actually calls the `action` argument to perform the heavy lifting. """ n_comments = 0 for comment in queryset: action(request, comme...
python
def _bulk_flag(self, request, queryset, action, done_message): """ Flag, approve, or remove some comments from an admin action. Actually calls the `action` argument to perform the heavy lifting. """ n_comments = 0 for comment in queryset: action(request, comme...
[ "def", "_bulk_flag", "(", "self", ",", "request", ",", "queryset", ",", "action", ",", "done_message", ")", ":", "n_comments", "=", "0", "for", "comment", "in", "queryset", ":", "action", "(", "request", ",", "comment", ")", "n_comments", "+=", "1", "msg...
Flag, approve, or remove some comments from an admin action. Actually calls the `action` argument to perform the heavy lifting.
[ "Flag", "approve", "or", "remove", "some", "comments", "from", "an", "admin", "action", ".", "Actually", "calls", "the", "action", "argument", "to", "perform", "the", "heavy", "lifting", "." ]
train
https://github.com/tBaxter/tango-comments/blob/1fd335c6fc9e81bba158e42e1483f1a149622ab4/build/lib/tango_comments/admin.py#L72-L85
cariad/py-wpconfigr
wpconfigr/wp_config_file.py
WpConfigFile.set
def set(self, key, value): """ Updates the value of the given key in the file. Args: key (str): Key of the property to update. value (str): New value of the property. Return: bool: Indicates whether or not a change was made. """ chan...
python
def set(self, key, value): """ Updates the value of the given key in the file. Args: key (str): Key of the property to update. value (str): New value of the property. Return: bool: Indicates whether or not a change was made. """ chan...
[ "def", "set", "(", "self", ",", "key", ",", "value", ")", ":", "changed", "=", "super", "(", ")", ".", "set", "(", "key", "=", "key", ",", "value", "=", "value", ")", "if", "not", "changed", ":", "return", "False", "self", ".", "_log", ".", "in...
Updates the value of the given key in the file. Args: key (str): Key of the property to update. value (str): New value of the property. Return: bool: Indicates whether or not a change was made.
[ "Updates", "the", "value", "of", "the", "given", "key", "in", "the", "file", "." ]
train
https://github.com/cariad/py-wpconfigr/blob/8f25bb849b72ce95957566544a2be8445316c818/wpconfigr/wp_config_file.py#L29-L52
mitakas/wallpaper
wallpaper/cubic.py
Cubic.next_color
def next_color(self): """ Returns the next color. Currently returns a random color from the Colorbrewer 11-class diverging BrBG palette. Returns ------- next_rgb_color: tuple of ImageColor """ next_rgb_color = ImageColor.getrgb(random.choice(BrBG_11.hex_...
python
def next_color(self): """ Returns the next color. Currently returns a random color from the Colorbrewer 11-class diverging BrBG palette. Returns ------- next_rgb_color: tuple of ImageColor """ next_rgb_color = ImageColor.getrgb(random.choice(BrBG_11.hex_...
[ "def", "next_color", "(", "self", ")", ":", "next_rgb_color", "=", "ImageColor", ".", "getrgb", "(", "random", ".", "choice", "(", "BrBG_11", ".", "hex_colors", ")", ")", "return", "next_rgb_color" ]
Returns the next color. Currently returns a random color from the Colorbrewer 11-class diverging BrBG palette. Returns ------- next_rgb_color: tuple of ImageColor
[ "Returns", "the", "next", "color", ".", "Currently", "returns", "a", "random", "color", "from", "the", "Colorbrewer", "11", "-", "class", "diverging", "BrBG", "palette", "." ]
train
https://github.com/mitakas/wallpaper/blob/83d90f56cf888d39c98aeb84e0e64d1289e4d0c0/wallpaper/cubic.py#L40-L51
mitakas/wallpaper
wallpaper/cubic.py
Cubic.paint_cube
def paint_cube(self, x, y): """ Paints a cube at a certain position a color. Parameters ---------- x: int Horizontal position of the upper left corner of the cube. y: int Vertical position of the upper left corner of the cube. """ ...
python
def paint_cube(self, x, y): """ Paints a cube at a certain position a color. Parameters ---------- x: int Horizontal position of the upper left corner of the cube. y: int Vertical position of the upper left corner of the cube. """ ...
[ "def", "paint_cube", "(", "self", ",", "x", ",", "y", ")", ":", "# get the color", "color", "=", "self", ".", "next_color", "(", ")", "# calculate the position", "cube_pos", "=", "[", "x", ",", "y", ",", "x", "+", "self", ".", "cube_size", ",", "y", ...
Paints a cube at a certain position a color. Parameters ---------- x: int Horizontal position of the upper left corner of the cube. y: int Vertical position of the upper left corner of the cube.
[ "Paints", "a", "cube", "at", "a", "certain", "position", "a", "color", "." ]
train
https://github.com/mitakas/wallpaper/blob/83d90f56cf888d39c98aeb84e0e64d1289e4d0c0/wallpaper/cubic.py#L53-L71
mitakas/wallpaper
wallpaper/cubic.py
Cubic.paint_pattern
def paint_pattern(self): """ Paints all the cubes. """ x = 0 while x < self.width: y = 0 while y < self.height: self.paint_cube(x, y) y += self.cube_size x += self.cube_size
python
def paint_pattern(self): """ Paints all the cubes. """ x = 0 while x < self.width: y = 0 while y < self.height: self.paint_cube(x, y) y += self.cube_size x += self.cube_size
[ "def", "paint_pattern", "(", "self", ")", ":", "x", "=", "0", "while", "x", "<", "self", ".", "width", ":", "y", "=", "0", "while", "y", "<", "self", ".", "height", ":", "self", ".", "paint_cube", "(", "x", ",", "y", ")", "y", "+=", "self", "...
Paints all the cubes.
[ "Paints", "all", "the", "cubes", "." ]
train
https://github.com/mitakas/wallpaper/blob/83d90f56cf888d39c98aeb84e0e64d1289e4d0c0/wallpaper/cubic.py#L73-L84
akissa/sachannelupdate
sachannelupdate/transports.py
get_key_files
def get_key_files(kfiles, dirname, names): """Return key files""" for name in names: fullname = os.path.join(dirname, name) if os.path.isfile(fullname) and \ fullname.endswith('_rsa') or \ fullname.endswith('_dsa'): kfiles.put(fullname)
python
def get_key_files(kfiles, dirname, names): """Return key files""" for name in names: fullname = os.path.join(dirname, name) if os.path.isfile(fullname) and \ fullname.endswith('_rsa') or \ fullname.endswith('_dsa'): kfiles.put(fullname)
[ "def", "get_key_files", "(", "kfiles", ",", "dirname", ",", "names", ")", ":", "for", "name", "in", "names", ":", "fullname", "=", "os", ".", "path", ".", "join", "(", "dirname", ",", "name", ")", "if", "os", ".", "path", ".", "isfile", "(", "fulln...
Return key files
[ "Return", "key", "files" ]
train
https://github.com/akissa/sachannelupdate/blob/a1c3c3d86b874f9c92c2407e2608963165d3ae98/sachannelupdate/transports.py#L35-L42
akissa/sachannelupdate
sachannelupdate/transports.py
get_ssh_keys
def get_ssh_keys(sshdir): """Get SSH keys""" keys = Queue() for root, _, files in os.walk(os.path.abspath(sshdir)): if not files: continue for filename in files: fullname = os.path.join(root, filename) if (os.path.isfile(fullname) and fullname.endswith('_r...
python
def get_ssh_keys(sshdir): """Get SSH keys""" keys = Queue() for root, _, files in os.walk(os.path.abspath(sshdir)): if not files: continue for filename in files: fullname = os.path.join(root, filename) if (os.path.isfile(fullname) and fullname.endswith('_r...
[ "def", "get_ssh_keys", "(", "sshdir", ")", ":", "keys", "=", "Queue", "(", ")", "for", "root", ",", "_", ",", "files", "in", "os", ".", "walk", "(", "os", ".", "path", ".", "abspath", "(", "sshdir", ")", ")", ":", "if", "not", "files", ":", "co...
Get SSH keys
[ "Get", "SSH", "keys" ]
train
https://github.com/akissa/sachannelupdate/blob/a1c3c3d86b874f9c92c2407e2608963165d3ae98/sachannelupdate/transports.py#L45-L56
akissa/sachannelupdate
sachannelupdate/transports.py
get_ssh_dir
def get_ssh_dir(config, username): """Get the users ssh dir""" sshdir = config.get('ssh_config_dir') if not sshdir: sshdir = os.path.expanduser('~/.ssh') if not os.path.isdir(sshdir): pwentry = getpwnam(username) sshdir = os.path.join(pwentry.pw_dir, '.ssh') ...
python
def get_ssh_dir(config, username): """Get the users ssh dir""" sshdir = config.get('ssh_config_dir') if not sshdir: sshdir = os.path.expanduser('~/.ssh') if not os.path.isdir(sshdir): pwentry = getpwnam(username) sshdir = os.path.join(pwentry.pw_dir, '.ssh') ...
[ "def", "get_ssh_dir", "(", "config", ",", "username", ")", ":", "sshdir", "=", "config", ".", "get", "(", "'ssh_config_dir'", ")", "if", "not", "sshdir", ":", "sshdir", "=", "os", ".", "path", ".", "expanduser", "(", "'~/.ssh'", ")", "if", "not", "os",...
Get the users ssh dir
[ "Get", "the", "users", "ssh", "dir" ]
train
https://github.com/akissa/sachannelupdate/blob/a1c3c3d86b874f9c92c2407e2608963165d3ae98/sachannelupdate/transports.py#L65-L75
akissa/sachannelupdate
sachannelupdate/transports.py
get_local_user
def get_local_user(username): """Get the local username""" try: _ = getpwnam(username) luser = username except KeyError: luser = getuser() return luser
python
def get_local_user(username): """Get the local username""" try: _ = getpwnam(username) luser = username except KeyError: luser = getuser() return luser
[ "def", "get_local_user", "(", "username", ")", ":", "try", ":", "_", "=", "getpwnam", "(", "username", ")", "luser", "=", "username", "except", "KeyError", ":", "luser", "=", "getuser", "(", ")", "return", "luser" ]
Get the local username
[ "Get", "the", "local", "username" ]
train
https://github.com/akissa/sachannelupdate/blob/a1c3c3d86b874f9c92c2407e2608963165d3ae98/sachannelupdate/transports.py#L78-L85
akissa/sachannelupdate
sachannelupdate/transports.py
get_host_keys
def get_host_keys(hostname, sshdir): """get host key""" hostkey = None try: host_keys = load_host_keys(os.path.join(sshdir, 'known_hosts')) except IOError: host_keys = {} if hostname in host_keys: hostkeytype = host_keys[hostname].keys()[0] hostkey = host_keys[hostn...
python
def get_host_keys(hostname, sshdir): """get host key""" hostkey = None try: host_keys = load_host_keys(os.path.join(sshdir, 'known_hosts')) except IOError: host_keys = {} if hostname in host_keys: hostkeytype = host_keys[hostname].keys()[0] hostkey = host_keys[hostn...
[ "def", "get_host_keys", "(", "hostname", ",", "sshdir", ")", ":", "hostkey", "=", "None", "try", ":", "host_keys", "=", "load_host_keys", "(", "os", ".", "path", ".", "join", "(", "sshdir", ",", "'known_hosts'", ")", ")", "except", "IOError", ":", "host_...
get host key
[ "get", "host", "key" ]
train
https://github.com/akissa/sachannelupdate/blob/a1c3c3d86b874f9c92c2407e2608963165d3ae98/sachannelupdate/transports.py#L88-L101
akissa/sachannelupdate
sachannelupdate/transports.py
get_sftp_conn
def get_sftp_conn(config): """Make a SFTP connection, returns sftp client and connection objects""" remote = config.get('remote_location') parts = urlparse(remote) if ':' in parts.netloc: hostname, port = parts.netloc.split(':') else: hostname = parts.netloc port = 22 po...
python
def get_sftp_conn(config): """Make a SFTP connection, returns sftp client and connection objects""" remote = config.get('remote_location') parts = urlparse(remote) if ':' in parts.netloc: hostname, port = parts.netloc.split(':') else: hostname = parts.netloc port = 22 po...
[ "def", "get_sftp_conn", "(", "config", ")", ":", "remote", "=", "config", ".", "get", "(", "'remote_location'", ")", "parts", "=", "urlparse", "(", "remote", ")", "if", "':'", "in", "parts", ".", "netloc", ":", "hostname", ",", "port", "=", "parts", "....
Make a SFTP connection, returns sftp client and connection objects
[ "Make", "a", "SFTP", "connection", "returns", "sftp", "client", "and", "connection", "objects" ]
train
https://github.com/akissa/sachannelupdate/blob/a1c3c3d86b874f9c92c2407e2608963165d3ae98/sachannelupdate/transports.py#L104-L141
chartbeat-labs/swailing
swailing/token_bucket.py
TokenBucket.check_and_consume
def check_and_consume(self): """Returns True if there is currently at least one token, and reduces it by one. """ if self._count < 1.0: self._fill() consumable = self._count >= 1.0 if consumable: self._count -= 1.0 self.throttle_coun...
python
def check_and_consume(self): """Returns True if there is currently at least one token, and reduces it by one. """ if self._count < 1.0: self._fill() consumable = self._count >= 1.0 if consumable: self._count -= 1.0 self.throttle_coun...
[ "def", "check_and_consume", "(", "self", ")", ":", "if", "self", ".", "_count", "<", "1.0", ":", "self", ".", "_fill", "(", ")", "consumable", "=", "self", ".", "_count", ">=", "1.0", "if", "consumable", ":", "self", ".", "_count", "-=", "1.0", "self...
Returns True if there is currently at least one token, and reduces it by one.
[ "Returns", "True", "if", "there", "is", "currently", "at", "least", "one", "token", "and", "reduces", "it", "by", "one", "." ]
train
https://github.com/chartbeat-labs/swailing/blob/d55e0dd7af59a2ba93f7c9c46ff56f6a4080b222/swailing/token_bucket.py#L19-L35
chartbeat-labs/swailing
swailing/token_bucket.py
TokenBucket._fill
def _fill(self): """Fills bucket with accrued tokens since last fill.""" right_now = time.time() time_diff = right_now - self._last_fill if time_diff < 0: return self._count = min( self._count + self._fill_rate * time_diff, self._capacity, ...
python
def _fill(self): """Fills bucket with accrued tokens since last fill.""" right_now = time.time() time_diff = right_now - self._last_fill if time_diff < 0: return self._count = min( self._count + self._fill_rate * time_diff, self._capacity, ...
[ "def", "_fill", "(", "self", ")", ":", "right_now", "=", "time", ".", "time", "(", ")", "time_diff", "=", "right_now", "-", "self", ".", "_last_fill", "if", "time_diff", "<", "0", ":", "return", "self", ".", "_count", "=", "min", "(", "self", ".", ...
Fills bucket with accrued tokens since last fill.
[ "Fills", "bucket", "with", "accrued", "tokens", "since", "last", "fill", "." ]
train
https://github.com/chartbeat-labs/swailing/blob/d55e0dd7af59a2ba93f7c9c46ff56f6a4080b222/swailing/token_bucket.py#L42-L54
ulf1/oxyba
oxyba/mysql_batch_and_fetch.py
mysql_batch_and_fetch
def mysql_batch_and_fetch(mysql_config, *sql_queries): """ Excute a series of SQL statements before the final Select query Parameters ---------- mysql_config : dict The user credentials as defined in MySQLdb.connect, e.g. mysql_conig = {'user': 'myname', 'passwd': 'supersecret', ...
python
def mysql_batch_and_fetch(mysql_config, *sql_queries): """ Excute a series of SQL statements before the final Select query Parameters ---------- mysql_config : dict The user credentials as defined in MySQLdb.connect, e.g. mysql_conig = {'user': 'myname', 'passwd': 'supersecret', ...
[ "def", "mysql_batch_and_fetch", "(", "mysql_config", ",", "*", "sql_queries", ")", ":", "# load modules", "import", "MySQLdb", "as", "mydb", "import", "sys", "import", "gc", "# ensure that `sqlqueries` is a list/tuple", "# split a string into a list", "if", "len", "(", ...
Excute a series of SQL statements before the final Select query Parameters ---------- mysql_config : dict The user credentials as defined in MySQLdb.connect, e.g. mysql_conig = {'user': 'myname', 'passwd': 'supersecret', 'host': '<ip adress or domain>', 'db': '<myschema>'} sql_...
[ "Excute", "a", "series", "of", "SQL", "statements", "before", "the", "final", "Select", "query" ]
train
https://github.com/ulf1/oxyba/blob/b3043116050de275124365cb11e7df91fb40169d/oxyba/mysql_batch_and_fetch.py#L2-L57
henrysher/kotocore
kotocore/utils/mangle.py
to_camel_case
def to_camel_case(snake_case_name): """ Converts snake_cased_names to CamelCaseNames. :param snake_case_name: The name you'd like to convert from. :type snake_case_name: string :returns: A converted string :rtype: string """ bits = snake_case_name.split('_') return ''.join([bit.cap...
python
def to_camel_case(snake_case_name): """ Converts snake_cased_names to CamelCaseNames. :param snake_case_name: The name you'd like to convert from. :type snake_case_name: string :returns: A converted string :rtype: string """ bits = snake_case_name.split('_') return ''.join([bit.cap...
[ "def", "to_camel_case", "(", "snake_case_name", ")", ":", "bits", "=", "snake_case_name", ".", "split", "(", "'_'", ")", "return", "''", ".", "join", "(", "[", "bit", ".", "capitalize", "(", ")", "for", "bit", "in", "bits", "]", ")" ]
Converts snake_cased_names to CamelCaseNames. :param snake_case_name: The name you'd like to convert from. :type snake_case_name: string :returns: A converted string :rtype: string
[ "Converts", "snake_cased_names", "to", "CamelCaseNames", "." ]
train
https://github.com/henrysher/kotocore/blob/c52d2f3878b924ceabca07f61c91abcb1b230ecc/kotocore/utils/mangle.py#L19-L30
henrysher/kotocore
kotocore/utils/mangle.py
html_to_rst
def html_to_rst(html): """ Converts the service HTML docs to reStructured Text, for use in docstrings. :param html: The raw HTML to convert :type html: string :returns: A reStructured Text formatted version of the text :rtype: string """ doc = ReSTDocument() doc.include_doc_string(...
python
def html_to_rst(html): """ Converts the service HTML docs to reStructured Text, for use in docstrings. :param html: The raw HTML to convert :type html: string :returns: A reStructured Text formatted version of the text :rtype: string """ doc = ReSTDocument() doc.include_doc_string(...
[ "def", "html_to_rst", "(", "html", ")", ":", "doc", "=", "ReSTDocument", "(", ")", "doc", ".", "include_doc_string", "(", "html", ")", "raw_doc", "=", "doc", ".", "getvalue", "(", ")", "return", "raw_doc", ".", "decode", "(", "'utf-8'", ")" ]
Converts the service HTML docs to reStructured Text, for use in docstrings. :param html: The raw HTML to convert :type html: string :returns: A reStructured Text formatted version of the text :rtype: string
[ "Converts", "the", "service", "HTML", "docs", "to", "reStructured", "Text", "for", "use", "in", "docstrings", "." ]
train
https://github.com/henrysher/kotocore/blob/c52d2f3878b924ceabca07f61c91abcb1b230ecc/kotocore/utils/mangle.py#L33-L46
dirkcuys/s3imageresize
s3imageresize/s3imageresize.py
resize_image_folder
def resize_image_folder(bucket, key_prefix, pil_size): """ This function resizes all the images in a folder """ con = boto.connect_s3() b = con.get_bucket(bucket) for key in b.list(key_prefix): key = b.get_key(key.name) if 'image' not in key.content_type: continue siz...
python
def resize_image_folder(bucket, key_prefix, pil_size): """ This function resizes all the images in a folder """ con = boto.connect_s3() b = con.get_bucket(bucket) for key in b.list(key_prefix): key = b.get_key(key.name) if 'image' not in key.content_type: continue siz...
[ "def", "resize_image_folder", "(", "bucket", ",", "key_prefix", ",", "pil_size", ")", ":", "con", "=", "boto", ".", "connect_s3", "(", ")", "b", "=", "con", ".", "get_bucket", "(", "bucket", ")", "for", "key", "in", "b", ".", "list", "(", "key_prefix",...
This function resizes all the images in a folder
[ "This", "function", "resizes", "all", "the", "images", "in", "a", "folder" ]
train
https://github.com/dirkcuys/s3imageresize/blob/eb70147ce7d92892b93f29612c695e63b513b3a3/s3imageresize/s3imageresize.py#L6-L29
chrisnorman7/confmanager
confmanager/__init__.py
ConfManager.add_section
def add_section(self, section, friendly_name = None): """Adds a section and optionally gives it a friendly name..""" if not isinstance(section, BASESTRING): # Make sure the user isn't expecting to use something stupid as a key. raise ValueError(section) # See if we've got this section already: if sectio...
python
def add_section(self, section, friendly_name = None): """Adds a section and optionally gives it a friendly name..""" if not isinstance(section, BASESTRING): # Make sure the user isn't expecting to use something stupid as a key. raise ValueError(section) # See if we've got this section already: if sectio...
[ "def", "add_section", "(", "self", ",", "section", ",", "friendly_name", "=", "None", ")", ":", "if", "not", "isinstance", "(", "section", ",", "BASESTRING", ")", ":", "# Make sure the user isn't expecting to use something stupid as a key.\r", "raise", "ValueError", "...
Adds a section and optionally gives it a friendly name..
[ "Adds", "a", "section", "and", "optionally", "gives", "it", "a", "friendly", "name", ".." ]
train
https://github.com/chrisnorman7/confmanager/blob/54a3ce0b596f9da32ae82fd4ff4cb46bb1cf23b1/confmanager/__init__.py#L39-L52
chrisnorman7/confmanager
confmanager/__init__.py
ConfManager.set
def set(self, section, option, value = None, title = None, validate = None, help = None, control = None, args = None, kwargs = None, include = None): """ set(self, section, option, value = None, title = None, validate = lambda value: None, help = '', control = None, args = [], kwargs = {}, include = True) Stor...
python
def set(self, section, option, value = None, title = None, validate = None, help = None, control = None, args = None, kwargs = None, include = None): """ set(self, section, option, value = None, title = None, validate = lambda value: None, help = '', control = None, args = [], kwargs = {}, include = True) Stor...
[ "def", "set", "(", "self", ",", "section", ",", "option", ",", "value", "=", "None", ",", "title", "=", "None", ",", "validate", "=", "None", ",", "help", "=", "None", ",", "control", "=", "None", ",", "args", "=", "None", ",", "kwargs", "=", "No...
set(self, section, option, value = None, title = None, validate = lambda value: None, help = '', control = None, args = [], kwargs = {}, include = True) Store the value to the configuration with all it's associated data. * title is the friendly name for the value (will be used for textual labels etc). * va...
[ "set", "(", "self", "section", "option", "value", "=", "None", "title", "=", "None", "validate", "=", "lambda", "value", ":", "None", "help", "=", "control", "=", "None", "args", "=", "[]", "kwargs", "=", "{}", "include", "=", "True", ")", "Store", "...
train
https://github.com/chrisnorman7/confmanager/blob/54a3ce0b596f9da32ae82fd4ff4cb46bb1cf23b1/confmanager/__init__.py#L54-L115
chrisnorman7/confmanager
confmanager/__init__.py
ConfManager.toggle
def toggle(self, section, option): """Toggles option in section.""" self.set(section, option, not self.get(section, option))
python
def toggle(self, section, option): """Toggles option in section.""" self.set(section, option, not self.get(section, option))
[ "def", "toggle", "(", "self", ",", "section", ",", "option", ")", ":", "self", ".", "set", "(", "section", ",", "option", ",", "not", "self", ".", "get", "(", "section", ",", "option", ")", ")" ]
Toggles option in section.
[ "Toggles", "option", "in", "section", "." ]
train
https://github.com/chrisnorman7/confmanager/blob/54a3ce0b596f9da32ae82fd4ff4cb46bb1cf23b1/confmanager/__init__.py#L125-L127
chrisnorman7/confmanager
confmanager/__init__.py
ConfManager.get
def get(self, section, option, default = None): """Returns the option's value converted into it's intended type. If default is specified, return that on failure, else raise NoOptionError.""" if self.has_section(section): try: return self.config[section][option].get('value', None) except KeyError: ...
python
def get(self, section, option, default = None): """Returns the option's value converted into it's intended type. If default is specified, return that on failure, else raise NoOptionError.""" if self.has_section(section): try: return self.config[section][option].get('value', None) except KeyError: ...
[ "def", "get", "(", "self", ",", "section", ",", "option", ",", "default", "=", "None", ")", ":", "if", "self", ".", "has_section", "(", "section", ")", ":", "try", ":", "return", "self", ".", "config", "[", "section", "]", "[", "option", "]", ".", ...
Returns the option's value converted into it's intended type. If default is specified, return that on failure, else raise NoOptionError.
[ "Returns", "the", "option", "s", "value", "converted", "into", "it", "s", "intended", "type", ".", "If", "default", "is", "specified", "return", "that", "on", "failure", "else", "raise", "NoOptionError", "." ]
train
https://github.com/chrisnorman7/confmanager/blob/54a3ce0b596f9da32ae82fd4ff4cb46bb1cf23b1/confmanager/__init__.py#L137-L148
chrisnorman7/confmanager
confmanager/__init__.py
ConfManager.get_dump
def get_dump(self): """Returns options and values.""" res = [] for section in self.sections(): sec = [] for option in self.options(section): sec.append([option, self.get(section, option)]) res.append([section, sec]) return res
python
def get_dump(self): """Returns options and values.""" res = [] for section in self.sections(): sec = [] for option in self.options(section): sec.append([option, self.get(section, option)]) res.append([section, sec]) return res
[ "def", "get_dump", "(", "self", ")", ":", "res", "=", "[", "]", "for", "section", "in", "self", ".", "sections", "(", ")", ":", "sec", "=", "[", "]", "for", "option", "in", "self", ".", "options", "(", "section", ")", ":", "sec", ".", "append", ...
Returns options and values.
[ "Returns", "options", "and", "values", "." ]
train
https://github.com/chrisnorman7/confmanager/blob/54a3ce0b596f9da32ae82fd4ff4cb46bb1cf23b1/confmanager/__init__.py#L165-L173
bmuller/txairbrake
txairbrake/observers.py
AirbrakeLogObserver._onError
def _onError(self, error): """ Stop observer, raise exception, then restart. This prevents an infinite ping pong game of exceptions. """ self.stop() self._logModule.err( error, "Unhandled error logging exception to %s" % (self.airbrakeURL,)) self....
python
def _onError(self, error): """ Stop observer, raise exception, then restart. This prevents an infinite ping pong game of exceptions. """ self.stop() self._logModule.err( error, "Unhandled error logging exception to %s" % (self.airbrakeURL,)) self....
[ "def", "_onError", "(", "self", ",", "error", ")", ":", "self", ".", "stop", "(", ")", "self", ".", "_logModule", ".", "err", "(", "error", ",", "\"Unhandled error logging exception to %s\"", "%", "(", "self", ".", "airbrakeURL", ",", ")", ")", "self", "...
Stop observer, raise exception, then restart. This prevents an infinite ping pong game of exceptions.
[ "Stop", "observer", "raise", "exception", "then", "restart", ".", "This", "prevents", "an", "infinite", "ping", "pong", "game", "of", "exceptions", "." ]
train
https://github.com/bmuller/txairbrake/blob/38e65fe2330c6ce7fb788bad0cff0a85cceb1943/txairbrake/observers.py#L62-L70
pbrisk/unicum
unicum/datarange.py
DataRange.row_append
def row_append(self, row_key, value_list): """ append a new row to a DataRange :param row_key: a string :param value_list: a list """ if row_key in self._row_keys: raise KeyError('Key %s already exists in row keys.' % row_key) if not len(value_list) =...
python
def row_append(self, row_key, value_list): """ append a new row to a DataRange :param row_key: a string :param value_list: a list """ if row_key in self._row_keys: raise KeyError('Key %s already exists in row keys.' % row_key) if not len(value_list) =...
[ "def", "row_append", "(", "self", ",", "row_key", ",", "value_list", ")", ":", "if", "row_key", "in", "self", ".", "_row_keys", ":", "raise", "KeyError", "(", "'Key %s already exists in row keys.'", "%", "row_key", ")", "if", "not", "len", "(", "value_list", ...
append a new row to a DataRange :param row_key: a string :param value_list: a list
[ "append", "a", "new", "row", "to", "a", "DataRange" ]
train
https://github.com/pbrisk/unicum/blob/24bfa7355f36847a06646c58e9fd75bd3b689bfe/unicum/datarange.py#L229-L242
pbrisk/unicum
unicum/datarange.py
DataRange.col_append
def col_append(self, col_key, value_list): """ append a new row to a DataRange :param row_key: a string :param value_list: a list """ if col_key in self._col_keys: raise KeyError('Key %s already exists col keys.' % col_key) if not isinstance(value_lis...
python
def col_append(self, col_key, value_list): """ append a new row to a DataRange :param row_key: a string :param value_list: a list """ if col_key in self._col_keys: raise KeyError('Key %s already exists col keys.' % col_key) if not isinstance(value_lis...
[ "def", "col_append", "(", "self", ",", "col_key", ",", "value_list", ")", ":", "if", "col_key", "in", "self", ".", "_col_keys", ":", "raise", "KeyError", "(", "'Key %s already exists col keys.'", "%", "col_key", ")", "if", "not", "isinstance", "(", "value_list...
append a new row to a DataRange :param row_key: a string :param value_list: a list
[ "append", "a", "new", "row", "to", "a", "DataRange" ]
train
https://github.com/pbrisk/unicum/blob/24bfa7355f36847a06646c58e9fd75bd3b689bfe/unicum/datarange.py#L244-L259
SanketDG/mexe
mexe.py
parse_arguments
def parse_arguments(): """ Parses all the command line arguments using argparse and returns them. """ parser = argparse.ArgumentParser() parser.add_argument('file', metavar="FILE", nargs='+', help='file to be made executable') parser.add_argument("-p", "--python", metava...
python
def parse_arguments(): """ Parses all the command line arguments using argparse and returns them. """ parser = argparse.ArgumentParser() parser.add_argument('file', metavar="FILE", nargs='+', help='file to be made executable') parser.add_argument("-p", "--python", metava...
[ "def", "parse_arguments", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", ")", "parser", ".", "add_argument", "(", "'file'", ",", "metavar", "=", "\"FILE\"", ",", "nargs", "=", "'+'", ",", "help", "=", "'file to be made executable'", ")...
Parses all the command line arguments using argparse and returns them.
[ "Parses", "all", "the", "command", "line", "arguments", "using", "argparse", "and", "returns", "them", "." ]
train
https://github.com/SanketDG/mexe/blob/ad24507b34eabaa1c849de49cba99cc97c2cd759/mexe.py#L17-L33
SanketDG/mexe
mexe.py
contains_shebang
def contains_shebang(f): """ Returns true if any shebang line is present in the first line of the file. """ first_line = f.readline() if first_line in shebangs.values(): return True return False
python
def contains_shebang(f): """ Returns true if any shebang line is present in the first line of the file. """ first_line = f.readline() if first_line in shebangs.values(): return True return False
[ "def", "contains_shebang", "(", "f", ")", ":", "first_line", "=", "f", ".", "readline", "(", ")", "if", "first_line", "in", "shebangs", ".", "values", "(", ")", ":", "return", "True", "return", "False" ]
Returns true if any shebang line is present in the first line of the file.
[ "Returns", "true", "if", "any", "shebang", "line", "is", "present", "in", "the", "first", "line", "of", "the", "file", "." ]
train
https://github.com/SanketDG/mexe/blob/ad24507b34eabaa1c849de49cba99cc97c2cd759/mexe.py#L36-L43
SanketDG/mexe
mexe.py
put_shebang
def put_shebang(f, version): """ Writes a shebang to the first line of the file according to the specified version. (2 | 3 | default) """ if not contains_shebang(f): f.seek(0) original_text = f.read() f.seek(0) f.write(shebangs[version] + original_text)
python
def put_shebang(f, version): """ Writes a shebang to the first line of the file according to the specified version. (2 | 3 | default) """ if not contains_shebang(f): f.seek(0) original_text = f.read() f.seek(0) f.write(shebangs[version] + original_text)
[ "def", "put_shebang", "(", "f", ",", "version", ")", ":", "if", "not", "contains_shebang", "(", "f", ")", ":", "f", ".", "seek", "(", "0", ")", "original_text", "=", "f", ".", "read", "(", ")", "f", ".", "seek", "(", "0", ")", "f", ".", "write"...
Writes a shebang to the first line of the file according to the specified version. (2 | 3 | default)
[ "Writes", "a", "shebang", "to", "the", "first", "line", "of", "the", "file", "according", "to", "the", "specified", "version", ".", "(", "2", "|", "3", "|", "default", ")" ]
train
https://github.com/SanketDG/mexe/blob/ad24507b34eabaa1c849de49cba99cc97c2cd759/mexe.py#L46-L55
SanketDG/mexe
mexe.py
make_exec
def make_exec(fname, version): """ Writes the shebang and makes the file executable. """ # if no version is specified, use system default. if version is None: version = 'default' # write the shebang and then make the file executable. with open(fname, 'rb+') as f: put_shebang...
python
def make_exec(fname, version): """ Writes the shebang and makes the file executable. """ # if no version is specified, use system default. if version is None: version = 'default' # write the shebang and then make the file executable. with open(fname, 'rb+') as f: put_shebang...
[ "def", "make_exec", "(", "fname", ",", "version", ")", ":", "# if no version is specified, use system default.", "if", "version", "is", "None", ":", "version", "=", "'default'", "# write the shebang and then make the file executable.", "with", "open", "(", "fname", ",", ...
Writes the shebang and makes the file executable.
[ "Writes", "the", "shebang", "and", "makes", "the", "file", "executable", "." ]
train
https://github.com/SanketDG/mexe/blob/ad24507b34eabaa1c849de49cba99cc97c2cd759/mexe.py#L58-L71
heikomuller/sco-datastore
scodata/subject.py
SubjectHandle.data_file
def data_file(self): """Original uploaded data file the subject was created from. Returns ------- File-type object Reference to file on local disk """ return os.path.join(self.upload_directory, self.properties[datastore.PROPERTY_FILENAME])
python
def data_file(self): """Original uploaded data file the subject was created from. Returns ------- File-type object Reference to file on local disk """ return os.path.join(self.upload_directory, self.properties[datastore.PROPERTY_FILENAME])
[ "def", "data_file", "(", "self", ")", ":", "return", "os", ".", "path", ".", "join", "(", "self", ".", "upload_directory", ",", "self", ".", "properties", "[", "datastore", ".", "PROPERTY_FILENAME", "]", ")" ]
Original uploaded data file the subject was created from. Returns ------- File-type object Reference to file on local disk
[ "Original", "uploaded", "data", "file", "the", "subject", "was", "created", "from", "." ]
train
https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/subject.py#L106-L114
heikomuller/sco-datastore
scodata/subject.py
DefaultSubjectManager.upload_file
def upload_file(self, filename, file_type=FILE_TYPE_FREESURFER_DIRECTORY): """Create an anatomy object on local disk from the given file. Currently, only Freesurfer anatomy directories are supported. Expects a tar file. Parameters ---------- filename : string ...
python
def upload_file(self, filename, file_type=FILE_TYPE_FREESURFER_DIRECTORY): """Create an anatomy object on local disk from the given file. Currently, only Freesurfer anatomy directories are supported. Expects a tar file. Parameters ---------- filename : string ...
[ "def", "upload_file", "(", "self", ",", "filename", ",", "file_type", "=", "FILE_TYPE_FREESURFER_DIRECTORY", ")", ":", "# We currently only support one file type (i.e., FREESURFER_DIRECTORY).", "if", "file_type", "!=", "FILE_TYPE_FREESURFER_DIRECTORY", ":", "raise", "ValueError...
Create an anatomy object on local disk from the given file. Currently, only Freesurfer anatomy directories are supported. Expects a tar file. Parameters ---------- filename : string Name of the (uploaded) file file_type : string File type (current...
[ "Create", "an", "anatomy", "object", "on", "local", "disk", "from", "the", "given", "file", ".", "Currently", "only", "Freesurfer", "anatomy", "directories", "are", "supported", ".", "Expects", "a", "tar", "file", "." ]
train
https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/subject.py#L193-L213
heikomuller/sco-datastore
scodata/subject.py
DefaultSubjectManager.upload_freesurfer_archive
def upload_freesurfer_archive(self, filename, object_identifier=None, read_only=False): """Create an anatomy object on local disk from a Freesurfer anatomy tar file. If the given file is a Freesurfer file it will be copied to the created subject's upload directory. Parameters --...
python
def upload_freesurfer_archive(self, filename, object_identifier=None, read_only=False): """Create an anatomy object on local disk from a Freesurfer anatomy tar file. If the given file is a Freesurfer file it will be copied to the created subject's upload directory. Parameters --...
[ "def", "upload_freesurfer_archive", "(", "self", ",", "filename", ",", "object_identifier", "=", "None", ",", "read_only", "=", "False", ")", ":", "# At this point we expect the file to be a (compressed) tar archive.", "# Extract the archive contents into a new temporary directory"...
Create an anatomy object on local disk from a Freesurfer anatomy tar file. If the given file is a Freesurfer file it will be copied to the created subject's upload directory. Parameters ---------- filename : string Name of the (uploaded) file object_identifie...
[ "Create", "an", "anatomy", "object", "on", "local", "disk", "from", "a", "Freesurfer", "anatomy", "tar", "file", ".", "If", "the", "given", "file", "is", "a", "Freesurfer", "file", "it", "will", "be", "copied", "to", "the", "created", "subject", "s", "up...
train
https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/subject.py#L215-L303
pjuren/pyokit
src/pyokit/scripts/genomicIntersection.py
getUI
def getUI(args): """ build and return a UI object for this script. :param args: raw arguments to parse """ programName = os.path.basename(sys.argv[0]) longDescription = "takes a file with a list of p-values and applies " +\ "Benjamini and Hochberg FDR to convert to q-values " shortDes...
python
def getUI(args): """ build and return a UI object for this script. :param args: raw arguments to parse """ programName = os.path.basename(sys.argv[0]) longDescription = "takes a file with a list of p-values and applies " +\ "Benjamini and Hochberg FDR to convert to q-values " shortDes...
[ "def", "getUI", "(", "args", ")", ":", "programName", "=", "os", ".", "path", ".", "basename", "(", "sys", ".", "argv", "[", "0", "]", ")", "longDescription", "=", "\"takes a file with a list of p-values and applies \"", "+", "\"Benjamini and Hochberg FDR to convert...
build and return a UI object for this script. :param args: raw arguments to parse
[ "build", "and", "return", "a", "UI", "object", "for", "this", "script", "." ]
train
https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/scripts/genomicIntersection.py#L47-L78
pjuren/pyokit
src/pyokit/scripts/genomicIntersection.py
main
def main(args): """ main entry point for the GenomicIntIntersection script. :param args: the arguments for this script, as a list of string. Should already have had things like the script name stripped. That is, if there are no args provided, this should be an empty l...
python
def main(args): """ main entry point for the GenomicIntIntersection script. :param args: the arguments for this script, as a list of string. Should already have had things like the script name stripped. That is, if there are no args provided, this should be an empty l...
[ "def", "main", "(", "args", ")", ":", "# get options and arguments", "ui", "=", "getUI", "(", "args", ")", "if", "ui", ".", "optionIsSet", "(", "\"test\"", ")", ":", "# just run unit tests", "unittest", ".", "main", "(", "argv", "=", "[", "sys", ".", "ar...
main entry point for the GenomicIntIntersection script. :param args: the arguments for this script, as a list of string. Should already have had things like the script name stripped. That is, if there are no args provided, this should be an empty list.
[ "main", "entry", "point", "for", "the", "GenomicIntIntersection", "script", "." ]
train
https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/scripts/genomicIntersection.py#L85-L123
elkan1788/ppytools
ppytools/cfgreader.py
ConfReader.getAsTuple
def getAsTuple(self, section): """Get section name tuple :param section: section name :return: tuple object """ keys = self.getKeys(section) value_dict = self.getValues(section) return namedtuple(section, keys)(**value_dict)
python
def getAsTuple(self, section): """Get section name tuple :param section: section name :return: tuple object """ keys = self.getKeys(section) value_dict = self.getValues(section) return namedtuple(section, keys)(**value_dict)
[ "def", "getAsTuple", "(", "self", ",", "section", ")", ":", "keys", "=", "self", ".", "getKeys", "(", "section", ")", "value_dict", "=", "self", ".", "getValues", "(", "section", ")", "return", "namedtuple", "(", "section", ",", "keys", ")", "(", "*", ...
Get section name tuple :param section: section name :return: tuple object
[ "Get", "section", "name", "tuple" ]
train
https://github.com/elkan1788/ppytools/blob/117aeed9f669ae46e0dd6cb11c5687a5f797816c/ppytools/cfgreader.py#L81-L89
KnowledgeLinks/rdfframework
rdfframework/configuration/rdfwconfig.py
update_req
def update_req(name, old_req, config={}): """ Takes a requirement and updates it based on a specific attribute key args: name: the name of the attribute old_req: the requirement definition """ if not name: return old_req new_req = copy.deepcopy(old_req) del_idxs = []...
python
def update_req(name, old_req, config={}): """ Takes a requirement and updates it based on a specific attribute key args: name: the name of the attribute old_req: the requirement definition """ if not name: return old_req new_req = copy.deepcopy(old_req) del_idxs = []...
[ "def", "update_req", "(", "name", ",", "old_req", ",", "config", "=", "{", "}", ")", ":", "if", "not", "name", ":", "return", "old_req", "new_req", "=", "copy", ".", "deepcopy", "(", "old_req", ")", "del_idxs", "=", "[", "]", "if", "\"req_items\"", "...
Takes a requirement and updates it based on a specific attribute key args: name: the name of the attribute old_req: the requirement definition
[ "Takes", "a", "requirement", "and", "updates", "it", "based", "on", "a", "specific", "attribute", "key" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/configuration/rdfwconfig.py#L1388-L1413
KnowledgeLinks/rdfframework
rdfframework/configuration/rdfwconfig.py
get_options_from_str
def get_options_from_str(obj_str, **kwargs): """ Returns a list of options from a python object string args: obj_str: python list of options or a python object path Example: "rdfframework.connections.ConnManager[{param1}]" kwargs: * kwargs used to format the 'obj_str'...
python
def get_options_from_str(obj_str, **kwargs): """ Returns a list of options from a python object string args: obj_str: python list of options or a python object path Example: "rdfframework.connections.ConnManager[{param1}]" kwargs: * kwargs used to format the 'obj_str'...
[ "def", "get_options_from_str", "(", "obj_str", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "obj_str", ",", "list", ")", ":", "return", "obj_str", "try", ":", "obj", "=", "get_obj_frm_str", "(", "obj_str", ",", "*", "*", "kwargs", ")", "...
Returns a list of options from a python object string args: obj_str: python list of options or a python object path Example: "rdfframework.connections.ConnManager[{param1}]" kwargs: * kwargs used to format the 'obj_str'
[ "Returns", "a", "list", "of", "options", "from", "a", "python", "object", "string" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/configuration/rdfwconfig.py#L1417-L1436
KnowledgeLinks/rdfframework
rdfframework/configuration/rdfwconfig.py
strip_errors
def strip_errors(obj): """ Reads through and error object and replaces the error dict with the value args: obj: the error object/dictionary """ rtn_obj = copy.deepcopy(obj) try: del rtn_obj["__error_keys__"] except KeyError: pass for key in obj.get('__error_k...
python
def strip_errors(obj): """ Reads through and error object and replaces the error dict with the value args: obj: the error object/dictionary """ rtn_obj = copy.deepcopy(obj) try: del rtn_obj["__error_keys__"] except KeyError: pass for key in obj.get('__error_k...
[ "def", "strip_errors", "(", "obj", ")", ":", "rtn_obj", "=", "copy", ".", "deepcopy", "(", "obj", ")", "try", ":", "del", "rtn_obj", "[", "\"__error_keys__\"", "]", "except", "KeyError", ":", "pass", "for", "key", "in", "obj", ".", "get", "(", "'__erro...
Reads through and error object and replaces the error dict with the value args: obj: the error object/dictionary
[ "Reads", "through", "and", "error", "object", "and", "replaces", "the", "error", "dict", "with", "the", "value" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/configuration/rdfwconfig.py#L1439-L1454
gabrielfalcao/dominic
dominic/xpath/yappsrt.py
Parser._peek
def _peek(self, *types): """Returns the token type for lookahead; if there are any args then the list of args is the set of token types to allow""" tok = self._scanner.token(self._pos, types) return tok[2]
python
def _peek(self, *types): """Returns the token type for lookahead; if there are any args then the list of args is the set of token types to allow""" tok = self._scanner.token(self._pos, types) return tok[2]
[ "def", "_peek", "(", "self", ",", "*", "types", ")", ":", "tok", "=", "self", ".", "_scanner", ".", "token", "(", "self", ".", "_pos", ",", "types", ")", "return", "tok", "[", "2", "]" ]
Returns the token type for lookahead; if there are any args then the list of args is the set of token types to allow
[ "Returns", "the", "token", "type", "for", "lookahead", ";", "if", "there", "are", "any", "args", "then", "the", "list", "of", "args", "is", "the", "set", "of", "token", "types", "to", "allow" ]
train
https://github.com/gabrielfalcao/dominic/blob/a42f418fc288f3b70cb95847b405eaf7b83bb3a0/dominic/xpath/yappsrt.py#L109-L113
uw-it-aca/uw-restclients-hfs
uw_hfs/util.py
past_datetime_str
def past_datetime_str(adatetime): """ For adatetime is since 12:00AM, return: "Today at H:MM [A]PM" For adatetime is between 12:00AM and 11:59PM on yesterday: "Yesterday at 6:23 PM" For adatetime is between 2 and 6 days ago: "[2-6] days ago" For adatetime is 7 day...
python
def past_datetime_str(adatetime): """ For adatetime is since 12:00AM, return: "Today at H:MM [A]PM" For adatetime is between 12:00AM and 11:59PM on yesterday: "Yesterday at 6:23 PM" For adatetime is between 2 and 6 days ago: "[2-6] days ago" For adatetime is 7 day...
[ "def", "past_datetime_str", "(", "adatetime", ")", ":", "if", "is_today", "(", "adatetime", ")", ":", "return", "\"today at {}\"", ".", "format", "(", "time_str", "(", "adatetime", ")", ")", "if", "last_midnight", "(", ")", "-", "adatetime", "<=", "timedelta...
For adatetime is since 12:00AM, return: "Today at H:MM [A]PM" For adatetime is between 12:00AM and 11:59PM on yesterday: "Yesterday at 6:23 PM" For adatetime is between 2 and 6 days ago: "[2-6] days ago" For adatetime is 7 days ago: "1 week ago" For adatetime is 8-14 ...
[ "For", "adatetime", "is", "since", "12", ":", "00AM", "return", ":", "Today", "at", "H", ":", "MM", "[", "A", "]", "PM", "For", "adatetime", "is", "between", "12", ":", "00AM", "and", "11", ":", "59PM", "on", "yesterday", ":", "Yesterday", "at", "6...
train
https://github.com/uw-it-aca/uw-restclients-hfs/blob/685c3b16280d9e8b11b0d295c8852fa876f55ad0/uw_hfs/util.py#L17-L64
uw-it-aca/uw-restclients-hfs
uw_hfs/util.py
is_days_ago
def is_days_ago(adatetime, days): """ :param days: a positive integer. Return true if the adatetime is on the specified days ago """ if days == 1: end_time = last_midnight() start_time = end_time - timedelta(days=1) else: start_time = last_midnight() - timedelta(days=days...
python
def is_days_ago(adatetime, days): """ :param days: a positive integer. Return true if the adatetime is on the specified days ago """ if days == 1: end_time = last_midnight() start_time = end_time - timedelta(days=1) else: start_time = last_midnight() - timedelta(days=days...
[ "def", "is_days_ago", "(", "adatetime", ",", "days", ")", ":", "if", "days", "==", "1", ":", "end_time", "=", "last_midnight", "(", ")", "start_time", "=", "end_time", "-", "timedelta", "(", "days", "=", "1", ")", "else", ":", "start_time", "=", "last_...
:param days: a positive integer. Return true if the adatetime is on the specified days ago
[ ":", "param", "days", ":", "a", "positive", "integer", ".", "Return", "true", "if", "the", "adatetime", "is", "on", "the", "specified", "days", "ago" ]
train
https://github.com/uw-it-aca/uw-restclients-hfs/blob/685c3b16280d9e8b11b0d295c8852fa876f55ad0/uw_hfs/util.py#L67-L78
uw-it-aca/uw-restclients-hfs
uw_hfs/util.py
last_midnight
def last_midnight(): """ return a datetime of last mid-night """ now = datetime.now() return datetime(now.year, now.month, now.day)
python
def last_midnight(): """ return a datetime of last mid-night """ now = datetime.now() return datetime(now.year, now.month, now.day)
[ "def", "last_midnight", "(", ")", ":", "now", "=", "datetime", ".", "now", "(", ")", "return", "datetime", "(", "now", ".", "year", ",", "now", ".", "month", ",", "now", ".", "day", ")" ]
return a datetime of last mid-night
[ "return", "a", "datetime", "of", "last", "mid", "-", "night" ]
train
https://github.com/uw-it-aca/uw-restclients-hfs/blob/685c3b16280d9e8b11b0d295c8852fa876f55ad0/uw_hfs/util.py#L116-L121
PSU-OIT-ARC/django-cloak
cloak/management/commands/login.py
Command.handle
def handle(self, *args, **options): """ With no arguments, find the first user in the system with the is_superuser or is_staff flag set to true, or just the first user in the system period. With a single argument, look for the user with that value as the USERNAME_FIELD v...
python
def handle(self, *args, **options): """ With no arguments, find the first user in the system with the is_superuser or is_staff flag set to true, or just the first user in the system period. With a single argument, look for the user with that value as the USERNAME_FIELD v...
[ "def", "handle", "(", "self", ",", "*", "args", ",", "*", "*", "options", ")", ":", "user_model", "=", "get_user_model", "(", ")", "if", "len", "(", "args", ")", "==", "0", ":", "# find the first superuser, or staff member or user", "filters", "=", "[", "{...
With no arguments, find the first user in the system with the is_superuser or is_staff flag set to true, or just the first user in the system period. With a single argument, look for the user with that value as the USERNAME_FIELD value. When a user is found, print out a URL slu...
[ "With", "no", "arguments", "find", "the", "first", "user", "in", "the", "system", "with", "the", "is_superuser", "or", "is_staff", "flag", "set", "to", "true", "or", "just", "the", "first", "user", "in", "the", "system", "period", "." ]
train
https://github.com/PSU-OIT-ARC/django-cloak/blob/3f09711837f4fe7b1813692daa064e536135ffa3/cloak/management/commands/login.py#L13-L55
renalreg/cornflake
cornflake/sqlalchemy_orm.py
ModelSerializer.get_model_fields
def get_model_fields(self): """ List of model fields to include (defaults to all) """ model_fields = getattr(self.Meta, 'fields', None) if model_fields is not None: model_fields = set(model_fields) return model_fields
python
def get_model_fields(self): """ List of model fields to include (defaults to all) """ model_fields = getattr(self.Meta, 'fields', None) if model_fields is not None: model_fields = set(model_fields) return model_fields
[ "def", "get_model_fields", "(", "self", ")", ":", "model_fields", "=", "getattr", "(", "self", ".", "Meta", ",", "'fields'", ",", "None", ")", "if", "model_fields", "is", "not", "None", ":", "model_fields", "=", "set", "(", "model_fields", ")", "return", ...
List of model fields to include (defaults to all)
[ "List", "of", "model", "fields", "to", "include", "(", "defaults", "to", "all", ")" ]
train
https://github.com/renalreg/cornflake/blob/ce0c0b260c95e84046f108d05773f1f130ae886c/cornflake/sqlalchemy_orm.py#L31-L39
marhag87/pyyamlconfig
pyyamlconfig/pyyamlconfig.py
load_config
def load_config(configfile): """ Return a dict with configuration from the supplied yaml file """ try: with open(configfile, 'r') as ymlfile: try: config = yaml.load(ymlfile) return config except yaml.parser.ParserError: rai...
python
def load_config(configfile): """ Return a dict with configuration from the supplied yaml file """ try: with open(configfile, 'r') as ymlfile: try: config = yaml.load(ymlfile) return config except yaml.parser.ParserError: rai...
[ "def", "load_config", "(", "configfile", ")", ":", "try", ":", "with", "open", "(", "configfile", ",", "'r'", ")", "as", "ymlfile", ":", "try", ":", "config", "=", "yaml", ".", "load", "(", "ymlfile", ")", "return", "config", "except", "yaml", ".", "...
Return a dict with configuration from the supplied yaml file
[ "Return", "a", "dict", "with", "configuration", "from", "the", "supplied", "yaml", "file" ]
train
https://github.com/marhag87/pyyamlconfig/blob/4476eb1aadc14bda2ee4af76c996551df4363936/pyyamlconfig/pyyamlconfig.py#L16-L32
marhag87/pyyamlconfig
pyyamlconfig/pyyamlconfig.py
write_config
def write_config(configfile, content): """ Write dict to a file in yaml format """ with open(configfile, 'w+') as ymlfile: yaml.dump( content, ymlfile, default_flow_style=False, )
python
def write_config(configfile, content): """ Write dict to a file in yaml format """ with open(configfile, 'w+') as ymlfile: yaml.dump( content, ymlfile, default_flow_style=False, )
[ "def", "write_config", "(", "configfile", ",", "content", ")", ":", "with", "open", "(", "configfile", ",", "'w+'", ")", "as", "ymlfile", ":", "yaml", ".", "dump", "(", "content", ",", "ymlfile", ",", "default_flow_style", "=", "False", ",", ")" ]
Write dict to a file in yaml format
[ "Write", "dict", "to", "a", "file", "in", "yaml", "format" ]
train
https://github.com/marhag87/pyyamlconfig/blob/4476eb1aadc14bda2ee4af76c996551df4363936/pyyamlconfig/pyyamlconfig.py#L35-L44
storborg/replaylib
replaylib/__init__.py
start_record
def start_record(): """ Install an httplib wrapper that records but does not modify calls. """ global record, playback, current if record: raise StateError("Already recording.") if playback: raise StateError("Currently playing back.") record = True current = ReplayData() ...
python
def start_record(): """ Install an httplib wrapper that records but does not modify calls. """ global record, playback, current if record: raise StateError("Already recording.") if playback: raise StateError("Currently playing back.") record = True current = ReplayData() ...
[ "def", "start_record", "(", ")", ":", "global", "record", ",", "playback", ",", "current", "if", "record", ":", "raise", "StateError", "(", "\"Already recording.\"", ")", "if", "playback", ":", "raise", "StateError", "(", "\"Currently playing back.\"", ")", "rec...
Install an httplib wrapper that records but does not modify calls.
[ "Install", "an", "httplib", "wrapper", "that", "records", "but", "does", "not", "modify", "calls", "." ]
train
https://github.com/storborg/replaylib/blob/16bc3752bb992e3fb364fce9bd7c3f95e887a42d/replaylib/__init__.py#L43-L54
zyga/call
examples/example1.py
check_types
def check_types(func): """ Check if annotated function arguments are of the correct type """ call = PythonCall(func) @wraps(func) def decorator(*args, **kwargs): parameters = call.bind(args, kwargs) for arg_name, expected_type in func.__annotations__.items(): if not ...
python
def check_types(func): """ Check if annotated function arguments are of the correct type """ call = PythonCall(func) @wraps(func) def decorator(*args, **kwargs): parameters = call.bind(args, kwargs) for arg_name, expected_type in func.__annotations__.items(): if not ...
[ "def", "check_types", "(", "func", ")", ":", "call", "=", "PythonCall", "(", "func", ")", "@", "wraps", "(", "func", ")", "def", "decorator", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "parameters", "=", "call", ".", "bind", "(", "args", ...
Check if annotated function arguments are of the correct type
[ "Check", "if", "annotated", "function", "arguments", "are", "of", "the", "correct", "type" ]
train
https://github.com/zyga/call/blob/dcef9a5aac7f9085bd4829dd6bcedc5fc2945d87/examples/example1.py#L20-L34
devricks/soft_drf
soft_drf/api/serializers/base.py
AbsoluteUriMixin.build_absolute_uri
def build_absolute_uri(self, uri): """ Return a fully qualified absolute url for the given uri. """ request = self.context.get('request', None) return ( request.build_absolute_uri(uri) if request is not None else uri )
python
def build_absolute_uri(self, uri): """ Return a fully qualified absolute url for the given uri. """ request = self.context.get('request', None) return ( request.build_absolute_uri(uri) if request is not None else uri )
[ "def", "build_absolute_uri", "(", "self", ",", "uri", ")", ":", "request", "=", "self", ".", "context", ".", "get", "(", "'request'", ",", "None", ")", "return", "(", "request", ".", "build_absolute_uri", "(", "uri", ")", "if", "request", "is", "not", ...
Return a fully qualified absolute url for the given uri.
[ "Return", "a", "fully", "qualified", "absolute", "url", "for", "the", "given", "uri", "." ]
train
https://github.com/devricks/soft_drf/blob/1869b13f9341bfcebd931059e93de2bc38570da3/soft_drf/api/serializers/base.py#L11-L19
devricks/soft_drf
soft_drf/api/serializers/base.py
ModelSerializer.get_resource_uri
def get_resource_uri(self, obj): """ Return the uri of the given object. """ url = 'api:%s:%s-detail' % ( self.api_version, getattr( self, 'resource_view_name', self.Meta.model._meta.model_name ) ) retur...
python
def get_resource_uri(self, obj): """ Return the uri of the given object. """ url = 'api:%s:%s-detail' % ( self.api_version, getattr( self, 'resource_view_name', self.Meta.model._meta.model_name ) ) retur...
[ "def", "get_resource_uri", "(", "self", ",", "obj", ")", ":", "url", "=", "'api:%s:%s-detail'", "%", "(", "self", ".", "api_version", ",", "getattr", "(", "self", ",", "'resource_view_name'", ",", "self", ".", "Meta", ".", "model", ".", "_meta", ".", "mo...
Return the uri of the given object.
[ "Return", "the", "uri", "of", "the", "given", "object", "." ]
train
https://github.com/devricks/soft_drf/blob/1869b13f9341bfcebd931059e93de2bc38570da3/soft_drf/api/serializers/base.py#L78-L92
asphalt-framework/asphalt-templating
asphalt/templating/api.py
TemplateRendererProxy.render
def render(self, template: str, **vars) -> str: """ Render the named template. The current context will be available to the template as the ``ctx`` variable. :param template: name of the template file :param vars: extra template variables :return: the rendered results ...
python
def render(self, template: str, **vars) -> str: """ Render the named template. The current context will be available to the template as the ``ctx`` variable. :param template: name of the template file :param vars: extra template variables :return: the rendered results ...
[ "def", "render", "(", "self", ",", "template", ":", "str", ",", "*", "*", "vars", ")", "->", "str", ":", "vars", ".", "setdefault", "(", "'ctx'", ",", "self", ".", "_ctx", ")", "return", "self", ".", "_renderer", ".", "render", "(", "template", ","...
Render the named template. The current context will be available to the template as the ``ctx`` variable. :param template: name of the template file :param vars: extra template variables :return: the rendered results
[ "Render", "the", "named", "template", "." ]
train
https://github.com/asphalt-framework/asphalt-templating/blob/e5f836290820aa295b048b17b96d3896d5f1eeac/asphalt/templating/api.py#L53-L65
asphalt-framework/asphalt-templating
asphalt/templating/api.py
TemplateRendererProxy.render_string
def render_string(self, source: str, **vars) -> str: """ Render the template contained in the given string. The current context will be available to the template as the ``ctx`` variable. :param source: content of the template to render :param vars: extra variables made availabl...
python
def render_string(self, source: str, **vars) -> str: """ Render the template contained in the given string. The current context will be available to the template as the ``ctx`` variable. :param source: content of the template to render :param vars: extra variables made availabl...
[ "def", "render_string", "(", "self", ",", "source", ":", "str", ",", "*", "*", "vars", ")", "->", "str", ":", "vars", ".", "setdefault", "(", "'ctx'", ",", "self", ".", "_ctx", ")", "return", "self", ".", "_renderer", ".", "render_string", "(", "sour...
Render the template contained in the given string. The current context will be available to the template as the ``ctx`` variable. :param source: content of the template to render :param vars: extra variables made available to the template :return: the rendered results
[ "Render", "the", "template", "contained", "in", "the", "given", "string", "." ]
train
https://github.com/asphalt-framework/asphalt-templating/blob/e5f836290820aa295b048b17b96d3896d5f1eeac/asphalt/templating/api.py#L67-L79
jmgilman/Neolib
neolib/pyamf/remoting/__init__.py
_read_header
def _read_header(stream, decoder, strict=False): """ Read AMF L{Message} header from the stream. @type stream: L{BufferedByteStream<pyamf.util.BufferedByteStream>} @param decoder: An AMF0 decoder. @param strict: Use strict decoding policy. Default is C{False}. Will raise a L{pyamf.DecodeErr...
python
def _read_header(stream, decoder, strict=False): """ Read AMF L{Message} header from the stream. @type stream: L{BufferedByteStream<pyamf.util.BufferedByteStream>} @param decoder: An AMF0 decoder. @param strict: Use strict decoding policy. Default is C{False}. Will raise a L{pyamf.DecodeErr...
[ "def", "_read_header", "(", "stream", ",", "decoder", ",", "strict", "=", "False", ")", ":", "name_len", "=", "stream", ".", "read_ushort", "(", ")", "name", "=", "stream", ".", "read_utf8_string", "(", "name_len", ")", "required", "=", "bool", "(", "str...
Read AMF L{Message} header from the stream. @type stream: L{BufferedByteStream<pyamf.util.BufferedByteStream>} @param decoder: An AMF0 decoder. @param strict: Use strict decoding policy. Default is C{False}. Will raise a L{pyamf.DecodeError} if the data that was read from the stream does not ...
[ "Read", "AMF", "L", "{", "Message", "}", "header", "from", "the", "stream", "." ]
train
https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/remoting/__init__.py#L342-L370
jmgilman/Neolib
neolib/pyamf/remoting/__init__.py
_write_header
def _write_header(name, header, required, stream, encoder, strict=False): """ Write AMF message header. @param name: Name of the header. @param header: Header value. @param required: Whether understanding this header is required (?). @param stream: L{BufferedByteStream<pyamf.util.BufferedByteSt...
python
def _write_header(name, header, required, stream, encoder, strict=False): """ Write AMF message header. @param name: Name of the header. @param header: Header value. @param required: Whether understanding this header is required (?). @param stream: L{BufferedByteStream<pyamf.util.BufferedByteSt...
[ "def", "_write_header", "(", "name", ",", "header", ",", "required", ",", "stream", ",", "encoder", ",", "strict", "=", "False", ")", ":", "stream", ".", "write_ushort", "(", "len", "(", "name", ")", ")", "stream", ".", "write_utf8_string", "(", "name", ...
Write AMF message header. @param name: Name of the header. @param header: Header value. @param required: Whether understanding this header is required (?). @param stream: L{BufferedByteStream<pyamf.util.BufferedByteStream>} that will receive the encoded header. @param encoder: An encoder ca...
[ "Write", "AMF", "message", "header", "." ]
train
https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/remoting/__init__.py#L373-L400
jmgilman/Neolib
neolib/pyamf/remoting/__init__.py
_read_body
def _read_body(stream, decoder, strict=False, logger=None): """ Read an AMF message body from the stream. @type stream: L{BufferedByteStream<pyamf.util.BufferedByteStream>} @param decoder: An AMF0 decoder. @param strict: Use strict decoding policy. Default is `False`. @param logger: Used to log...
python
def _read_body(stream, decoder, strict=False, logger=None): """ Read an AMF message body from the stream. @type stream: L{BufferedByteStream<pyamf.util.BufferedByteStream>} @param decoder: An AMF0 decoder. @param strict: Use strict decoding policy. Default is `False`. @param logger: Used to log...
[ "def", "_read_body", "(", "stream", ",", "decoder", ",", "strict", "=", "False", ",", "logger", "=", "None", ")", ":", "def", "_read_args", "(", ")", ":", "# we have to go through this insanity because it seems that amf0", "# does not keep the array of args in the object ...
Read an AMF message body from the stream. @type stream: L{BufferedByteStream<pyamf.util.BufferedByteStream>} @param decoder: An AMF0 decoder. @param strict: Use strict decoding policy. Default is `False`. @param logger: Used to log interesting events whilst reading a remoting body. @type lo...
[ "Read", "an", "AMF", "message", "body", "from", "the", "stream", "." ]
train
https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/remoting/__init__.py#L403-L471
jmgilman/Neolib
neolib/pyamf/remoting/__init__.py
_write_body
def _write_body(name, message, stream, encoder, strict=False): """ Write AMF message body. @param name: The name of the request. @param message: The AMF L{Message} @type stream: L{BufferedByteStream<pyamf.util.BufferedByteStream>} @param encoder: An AMF0 encoder. @param strict: Use strict e...
python
def _write_body(name, message, stream, encoder, strict=False): """ Write AMF message body. @param name: The name of the request. @param message: The AMF L{Message} @type stream: L{BufferedByteStream<pyamf.util.BufferedByteStream>} @param encoder: An AMF0 encoder. @param strict: Use strict e...
[ "def", "_write_body", "(", "name", ",", "message", ",", "stream", ",", "encoder", ",", "strict", "=", "False", ")", ":", "def", "_encode_body", "(", "message", ")", ":", "if", "isinstance", "(", "message", ",", "Response", ")", ":", "encoder", ".", "wr...
Write AMF message body. @param name: The name of the request. @param message: The AMF L{Message} @type stream: L{BufferedByteStream<pyamf.util.BufferedByteStream>} @param encoder: An AMF0 encoder. @param strict: Use strict encoding policy. Default is `False`.
[ "Write", "AMF", "message", "body", "." ]
train
https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/remoting/__init__.py#L474-L533
jmgilman/Neolib
neolib/pyamf/remoting/__init__.py
decode
def decode(stream, strict=False, logger=None, timezone_offset=None): """ Decodes the incoming stream as a remoting message. @type stream: L{BufferedByteStream<pyamf.util.BufferedByteStream>} @param strict: Enforce strict decoding. Default is `False`. @param logger: Used to log interesting events wh...
python
def decode(stream, strict=False, logger=None, timezone_offset=None): """ Decodes the incoming stream as a remoting message. @type stream: L{BufferedByteStream<pyamf.util.BufferedByteStream>} @param strict: Enforce strict decoding. Default is `False`. @param logger: Used to log interesting events wh...
[ "def", "decode", "(", "stream", ",", "strict", "=", "False", ",", "logger", "=", "None", ",", "timezone_offset", "=", "None", ")", ":", "if", "not", "isinstance", "(", "stream", ",", "util", ".", "BufferedByteStream", ")", ":", "stream", "=", "util", "...
Decodes the incoming stream as a remoting message. @type stream: L{BufferedByteStream<pyamf.util.BufferedByteStream>} @param strict: Enforce strict decoding. Default is `False`. @param logger: Used to log interesting events whilst decoding a remoting message. @type logger: U{logging.Logger<http...
[ "Decodes", "the", "incoming", "stream", "as", "a", "remoting", "message", "." ]
train
https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/remoting/__init__.py#L574-L635
jmgilman/Neolib
neolib/pyamf/remoting/__init__.py
encode
def encode(msg, strict=False, logger=None, timezone_offset=None): """ Encodes and returns the L{msg<Envelope>} as an AMF stream. @param strict: Enforce strict encoding. Default is C{False}. Specifically header/body lengths will be written correctly, instead of the default 0. Default is `Fal...
python
def encode(msg, strict=False, logger=None, timezone_offset=None): """ Encodes and returns the L{msg<Envelope>} as an AMF stream. @param strict: Enforce strict encoding. Default is C{False}. Specifically header/body lengths will be written correctly, instead of the default 0. Default is `Fal...
[ "def", "encode", "(", "msg", ",", "strict", "=", "False", ",", "logger", "=", "None", ",", "timezone_offset", "=", "None", ")", ":", "stream", "=", "util", ".", "BufferedByteStream", "(", ")", "encoder", "=", "pyamf", ".", "get_encoder", "(", "pyamf", ...
Encodes and returns the L{msg<Envelope>} as an AMF stream. @param strict: Enforce strict encoding. Default is C{False}. Specifically header/body lengths will be written correctly, instead of the default 0. Default is `False`. Introduced in 0.4. @param logger: Used to log interesting events whil...
[ "Encodes", "and", "returns", "the", "L", "{", "msg<Envelope", ">", "}", "as", "an", "AMF", "stream", "." ]
train
https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/remoting/__init__.py#L638-L680
tomnor/channelpack
channelpack/pack.py
txtpack
def txtpack(fn, **kwargs): """Return a ChannelPack instance loaded with text data file fn. Attempt to read out custom channel names from the file and call instance.set_channel_names(). Then return the pack. This is a lazy function to get a loaded instance, using the cleverness provided by pulltxt ...
python
def txtpack(fn, **kwargs): """Return a ChannelPack instance loaded with text data file fn. Attempt to read out custom channel names from the file and call instance.set_channel_names(). Then return the pack. This is a lazy function to get a loaded instance, using the cleverness provided by pulltxt ...
[ "def", "txtpack", "(", "fn", ",", "*", "*", "kwargs", ")", ":", "loadfunc", "=", "pulltxt", ".", "loadtxt_asdict", "cp", "=", "ChannelPack", "(", "loadfunc", ")", "cp", ".", "load", "(", "fn", ",", "*", "*", "kwargs", ")", "names", "=", "pulltxt", ...
Return a ChannelPack instance loaded with text data file fn. Attempt to read out custom channel names from the file and call instance.set_channel_names(). Then return the pack. This is a lazy function to get a loaded instance, using the cleverness provided by pulltxt module. No delimiter or rows-to-sk...
[ "Return", "a", "ChannelPack", "instance", "loaded", "with", "text", "data", "file", "fn", "." ]
train
https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pack.py#L1206-L1237
tomnor/channelpack
channelpack/pack.py
dbfpack
def dbfpack(fn, usecols=None): """Return a ChannelPack instance loaded with dbf data file fn. This is a lazy function to get a loaded instance, using pulldbf module.""" loadfunc = pulldbf.dbf_asdict cp = ChannelPack(loadfunc) cp.load(fn, usecols) names = pulldbf.channel_names(fn, usecols) ...
python
def dbfpack(fn, usecols=None): """Return a ChannelPack instance loaded with dbf data file fn. This is a lazy function to get a loaded instance, using pulldbf module.""" loadfunc = pulldbf.dbf_asdict cp = ChannelPack(loadfunc) cp.load(fn, usecols) names = pulldbf.channel_names(fn, usecols) ...
[ "def", "dbfpack", "(", "fn", ",", "usecols", "=", "None", ")", ":", "loadfunc", "=", "pulldbf", ".", "dbf_asdict", "cp", "=", "ChannelPack", "(", "loadfunc", ")", "cp", ".", "load", "(", "fn", ",", "usecols", ")", "names", "=", "pulldbf", ".", "chann...
Return a ChannelPack instance loaded with dbf data file fn. This is a lazy function to get a loaded instance, using pulldbf module.
[ "Return", "a", "ChannelPack", "instance", "loaded", "with", "dbf", "data", "file", "fn", "." ]
train
https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pack.py#L1240-L1252
tomnor/channelpack
channelpack/pack.py
sheetpack
def sheetpack(fn, sheet=0, header=True, startcell=None, stopcell=None, usecols=None): """Return a ChannelPack instance loaded with data from the spread sheet file fn, (xls, xlsx). fn: str The file to read from. sheet: int or str If int, it is the index for the sheet 0-bas...
python
def sheetpack(fn, sheet=0, header=True, startcell=None, stopcell=None, usecols=None): """Return a ChannelPack instance loaded with data from the spread sheet file fn, (xls, xlsx). fn: str The file to read from. sheet: int or str If int, it is the index for the sheet 0-bas...
[ "def", "sheetpack", "(", "fn", ",", "sheet", "=", "0", ",", "header", "=", "True", ",", "startcell", "=", "None", ",", "stopcell", "=", "None", ",", "usecols", "=", "None", ")", ":", "cp", "=", "ChannelPack", "(", "pullxl", ".", "sheet_asdict", ")", ...
Return a ChannelPack instance loaded with data from the spread sheet file fn, (xls, xlsx). fn: str The file to read from. sheet: int or str If int, it is the index for the sheet 0-based. Else the sheet name. header: bool or str True if the defined data range includes a...
[ "Return", "a", "ChannelPack", "instance", "loaded", "with", "data", "from", "the", "spread", "sheet", "file", "fn", "(", "xls", "xlsx", ")", "." ]
train
https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pack.py#L1255-L1298
tomnor/channelpack
channelpack/pack.py
ChannelPack.load
def load(self, *args, **kwargs): """Load data using loadfunc. args, kwargs: forward to the loadfunc. args[0] must be the filename, so it means that loadfunc must take the filename as it's first argument. Set the filename attribute. .. note:: ...
python
def load(self, *args, **kwargs): """Load data using loadfunc. args, kwargs: forward to the loadfunc. args[0] must be the filename, so it means that loadfunc must take the filename as it's first argument. Set the filename attribute. .. note:: ...
[ "def", "load", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "D", "=", "self", ".", "loadfunc", "(", "*", "args", ",", "*", "*", "kwargs", ")", "if", "self", ".", "chnames", "is", "not", "None", ":", "if", "set", "(", "D",...
Load data using loadfunc. args, kwargs: forward to the loadfunc. args[0] must be the filename, so it means that loadfunc must take the filename as it's first argument. Set the filename attribute. .. note:: Updates the mask if not no_auto. ...
[ "Load", "data", "using", "loadfunc", "." ]
train
https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pack.py#L220-L277
tomnor/channelpack
channelpack/pack.py
ChannelPack.append_load
def append_load(self, *args, **kwargs): """Append data using loadfunc. args, kwargs: forward to the loadfunc. args[0] must be the filename, so it means that loadfunc must take the filename as it's first argument. If self is not already a loaded instance, cal...
python
def append_load(self, *args, **kwargs): """Append data using loadfunc. args, kwargs: forward to the loadfunc. args[0] must be the filename, so it means that loadfunc must take the filename as it's first argument. If self is not already a loaded instance, cal...
[ "def", "append_load", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".", "D", ":", "self", ".", "load", "(", "*", "args", ",", "*", "*", "kwargs", ")", "return", "newD", "=", "self", ".", "loadfunc", "("...
Append data using loadfunc. args, kwargs: forward to the loadfunc. args[0] must be the filename, so it means that loadfunc must take the filename as it's first argument. If self is not already a loaded instance, call load and return. Make error if there is ...
[ "Append", "data", "using", "loadfunc", "." ]
train
https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pack.py#L279-L342
tomnor/channelpack
channelpack/pack.py
ChannelPack.rebase
def rebase(self, key, start=None, decimals=5): """Rebase a channel (key) on start. The step (between elements) need to be constant all through, else ValueError is raised. The exception to this is the border step between data loaded from two different files. key: int or str ...
python
def rebase(self, key, start=None, decimals=5): """Rebase a channel (key) on start. The step (between elements) need to be constant all through, else ValueError is raised. The exception to this is the border step between data loaded from two different files. key: int or str ...
[ "def", "rebase", "(", "self", ",", "key", ",", "start", "=", "None", ",", "decimals", "=", "5", ")", ":", "diffs", "=", "[", "]", "def", "diffsappend", "(", "d", ",", "sc", ")", ":", "diff", "=", "np", ".", "around", "(", "np", ".", "diff", "...
Rebase a channel (key) on start. The step (between elements) need to be constant all through, else ValueError is raised. The exception to this is the border step between data loaded from two different files. key: int or str The key for the channel to rebase. start:...
[ "Rebase", "a", "channel", "(", "key", ")", "on", "start", "." ]
train
https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pack.py#L344-L402
tomnor/channelpack
channelpack/pack.py
ChannelPack._set_filename
def _set_filename(self, fn): """Set the filename attributes. (They are multiple for personal reasons).""" try: self.filename = self.fs = self.fn = os.path.abspath(fn.name) except AttributeError: self.filename = self.fs = self.fn = os.path.abspath(fn)
python
def _set_filename(self, fn): """Set the filename attributes. (They are multiple for personal reasons).""" try: self.filename = self.fs = self.fn = os.path.abspath(fn.name) except AttributeError: self.filename = self.fs = self.fn = os.path.abspath(fn)
[ "def", "_set_filename", "(", "self", ",", "fn", ")", ":", "try", ":", "self", ".", "filename", "=", "self", ".", "fs", "=", "self", ".", "fn", "=", "os", ".", "path", ".", "abspath", "(", "fn", ".", "name", ")", "except", "AttributeError", ":", "...
Set the filename attributes. (They are multiple for personal reasons).
[ "Set", "the", "filename", "attributes", ".", "(", "They", "are", "multiple", "for", "personal", "reasons", ")", "." ]
train
https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pack.py#L404-L410
tomnor/channelpack
channelpack/pack.py
ChannelPack.set_samplerate
def set_samplerate(self, rate): """Set sample rate to rate. rate: int or float rate is given as samples / timeunit. If sample rate is set, it will have an impact on the duration rule conditions. If duration is set to 2.5 and samplerate is 100, a duration of 250 records ...
python
def set_samplerate(self, rate): """Set sample rate to rate. rate: int or float rate is given as samples / timeunit. If sample rate is set, it will have an impact on the duration rule conditions. If duration is set to 2.5 and samplerate is 100, a duration of 250 records ...
[ "def", "set_samplerate", "(", "self", ",", "rate", ")", ":", "# Test and set value:", "float", "(", "rate", ")", "self", ".", "conconf", ".", "set_condition", "(", "'samplerate'", ",", "rate", ")", "if", "not", "self", ".", "no_auto", ":", "self", ".", "...
Set sample rate to rate. rate: int or float rate is given as samples / timeunit. If sample rate is set, it will have an impact on the duration rule conditions. If duration is set to 2.5 and samplerate is 100, a duration of 250 records is required for the logical conditions to b...
[ "Set", "sample", "rate", "to", "rate", "." ]
train
https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pack.py#L412-L429
tomnor/channelpack
channelpack/pack.py
ChannelPack.add_condition
def add_condition(self, conkey, cond): """Add a condition, one of the addable ones. conkey: str One of 'cond', startcond' or 'stopcond'. 'start' or 'stop' is accepted as shorts for 'startcond' or 'stopcond'. If the conkey is given with an explicit number (like 'stopc...
python
def add_condition(self, conkey, cond): """Add a condition, one of the addable ones. conkey: str One of 'cond', startcond' or 'stopcond'. 'start' or 'stop' is accepted as shorts for 'startcond' or 'stopcond'. If the conkey is given with an explicit number (like 'stopc...
[ "def", "add_condition", "(", "self", ",", "conkey", ",", "cond", ")", ":", "# Audit:", "if", "conkey", "==", "'start'", "or", "conkey", "==", "'stop'", ":", "conkey", "+=", "'cond'", "if", "not", "any", "(", "conkey", ".", "startswith", "(", "addable", ...
Add a condition, one of the addable ones. conkey: str One of 'cond', startcond' or 'stopcond'. 'start' or 'stop' is accepted as shorts for 'startcond' or 'stopcond'. If the conkey is given with an explicit number (like 'stopcond3') and already exist, it will be o...
[ "Add", "a", "condition", "one", "of", "the", "addable", "ones", "." ]
train
https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pack.py#L431-L472
tomnor/channelpack
channelpack/pack.py
ChannelPack._parse_cond
def _parse_cond(self, cond): """Replace the format strings in cond with ``self.D[i]`` so it can be used in eval calls. Use ``CHANNEL_RX`` as pattern. Return the parsed string. This method should be exposed so that one can experiment with conditions and see that they are properly...
python
def _parse_cond(self, cond): """Replace the format strings in cond with ``self.D[i]`` so it can be used in eval calls. Use ``CHANNEL_RX`` as pattern. Return the parsed string. This method should be exposed so that one can experiment with conditions and see that they are properly...
[ "def", "_parse_cond", "(", "self", ",", "cond", ")", ":", "CHANNEL_RX", "=", "CHANNEL_FMT_RX", ".", "format", "(", "CHANNEL_IDENTIFIER_RX", ")", "res", "=", "re", ".", "findall", "(", "CHANNEL_RX", ",", "cond", ")", "for", "ident", "in", "res", ":", "rx"...
Replace the format strings in cond with ``self.D[i]`` so it can be used in eval calls. Use ``CHANNEL_RX`` as pattern. Return the parsed string. This method should be exposed so that one can experiment with conditions and see that they are properly parsed.
[ "Replace", "the", "format", "strings", "in", "cond", "with", "self", ".", "D", "[", "i", "]", "so", "it", "can", "be", "used", "in", "eval", "calls", ".", "Use", "CHANNEL_RX", "as", "pattern", ".", "Return", "the", "parsed", "string", "." ]
train
https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pack.py#L474-L496
tomnor/channelpack
channelpack/pack.py
ChannelPack.spit_config
def spit_config(self, conf_file=None, firstwordonly=False): """Write a config_file based on this instance. conf_file: str (or Falseish) If conf_file is Falseish, write the file to the directory where self.filename sits, if self is not already associated with such a f...
python
def spit_config(self, conf_file=None, firstwordonly=False): """Write a config_file based on this instance. conf_file: str (or Falseish) If conf_file is Falseish, write the file to the directory where self.filename sits, if self is not already associated with such a f...
[ "def", "spit_config", "(", "self", ",", "conf_file", "=", "None", ",", "firstwordonly", "=", "False", ")", ":", "chroot", "=", "os", ".", "path", ".", "dirname", "(", "self", ".", "filename", ")", "chroot", "=", "os", ".", "path", ".", "abspath", "("...
Write a config_file based on this instance. conf_file: str (or Falseish) If conf_file is Falseish, write the file to the directory where self.filename sits, if self is not already associated with such a file. If associated, and conf_file is Falseish, use self.con...
[ "Write", "a", "config_file", "based", "on", "this", "instance", "." ]
train
https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pack.py#L506-L548
tomnor/channelpack
channelpack/pack.py
ChannelPack.eat_config
def eat_config(self, conf_file=None): """ Read the the conf_file and update this instance accordingly. conf_file: str or Falseish If conf_file is Falseish, look in the directory where self.filename sits if self is not already associated with a conf_file. If a...
python
def eat_config(self, conf_file=None): """ Read the the conf_file and update this instance accordingly. conf_file: str or Falseish If conf_file is Falseish, look in the directory where self.filename sits if self is not already associated with a conf_file. If a...
[ "def", "eat_config", "(", "self", ",", "conf_file", "=", "None", ")", ":", "chroot", "=", "os", ".", "path", ".", "dirname", "(", "self", ".", "filename", ")", "# \"channels root dir\"", "chroot", "=", "os", ".", "path", ".", "abspath", "(", "chroot", ...
Read the the conf_file and update this instance accordingly. conf_file: str or Falseish If conf_file is Falseish, look in the directory where self.filename sits if self is not already associated with a conf_file. If associated, and conf_file arg is Falseish, read...
[ "Read", "the", "the", "conf_file", "and", "update", "this", "instance", "accordingly", "." ]
train
https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pack.py#L550-L599
tomnor/channelpack
channelpack/pack.py
ChannelPack.set_stopextend
def set_stopextend(self, n): """Extend the True elements by n when setting the conditions based on a 'stopcond' condition. n is an integer >= 0. .. note:: Updates the mask if not no_auto. """ self.conconf.set_condition('stopextend', n) if not self.no_...
python
def set_stopextend(self, n): """Extend the True elements by n when setting the conditions based on a 'stopcond' condition. n is an integer >= 0. .. note:: Updates the mask if not no_auto. """ self.conconf.set_condition('stopextend', n) if not self.no_...
[ "def", "set_stopextend", "(", "self", ",", "n", ")", ":", "self", ".", "conconf", ".", "set_condition", "(", "'stopextend'", ",", "n", ")", "if", "not", "self", ".", "no_auto", ":", "self", ".", "make_mask", "(", ")" ]
Extend the True elements by n when setting the conditions based on a 'stopcond' condition. n is an integer >= 0. .. note:: Updates the mask if not no_auto.
[ "Extend", "the", "True", "elements", "by", "n", "when", "setting", "the", "conditions", "based", "on", "a", "stopcond", "condition", "." ]
train
https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pack.py#L613-L624
tomnor/channelpack
channelpack/pack.py
ChannelPack.set_duration
def set_duration(self, rule): """Set the duration according to rule. rule: str The rule operating on the variable ``dur``. rule is an expression like:: >>> rule = 'dur == 150 or dur > 822' setting a duration rule assuming a pack sp:: >>> sp.set_du...
python
def set_duration(self, rule): """Set the duration according to rule. rule: str The rule operating on the variable ``dur``. rule is an expression like:: >>> rule = 'dur == 150 or dur > 822' setting a duration rule assuming a pack sp:: >>> sp.set_du...
[ "def", "set_duration", "(", "self", ",", "rule", ")", ":", "self", ".", "conconf", ".", "set_condition", "(", "'duration'", ",", "rule", ")", "if", "not", "self", ".", "no_auto", ":", "self", ".", "make_mask", "(", ")" ]
Set the duration according to rule. rule: str The rule operating on the variable ``dur``. rule is an expression like:: >>> rule = 'dur == 150 or dur > 822' setting a duration rule assuming a pack sp:: >>> sp.set_duration(rule) The identifier ``du...
[ "Set", "the", "duration", "according", "to", "rule", "." ]
train
https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pack.py#L626-L658
tomnor/channelpack
channelpack/pack.py
ChannelPack.clear_conditions
def clear_conditions(self, *conkeys, **noclear): """Clear conditions. Clear only the conditions conkeys if specified. Clear only the conditions not specified by conkeys if noclear is True (False default). .. note:: Updates the mask if not no_auto. """ ...
python
def clear_conditions(self, *conkeys, **noclear): """Clear conditions. Clear only the conditions conkeys if specified. Clear only the conditions not specified by conkeys if noclear is True (False default). .. note:: Updates the mask if not no_auto. """ ...
[ "def", "clear_conditions", "(", "self", ",", "*", "conkeys", ",", "*", "*", "noclear", ")", ":", "offenders", "=", "set", "(", "conkeys", ")", "-", "set", "(", "self", ".", "conconf", ".", "conditions", ".", "keys", "(", ")", ")", "if", "offenders", ...
Clear conditions. Clear only the conditions conkeys if specified. Clear only the conditions not specified by conkeys if noclear is True (False default). .. note:: Updates the mask if not no_auto.
[ "Clear", "conditions", "." ]
train
https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pack.py#L660-L693
tomnor/channelpack
channelpack/pack.py
ChannelPack.make_mask
def make_mask(self, clean=True, dry=False): """Set the attribute self.mask to a mask based on the conditions. clean: bool If not True, let the current mask be a condition as well. If True, the mask is set solely on the pack's current conditions dry: ...
python
def make_mask(self, clean=True, dry=False): """Set the attribute self.mask to a mask based on the conditions. clean: bool If not True, let the current mask be a condition as well. If True, the mask is set solely on the pack's current conditions dry: ...
[ "def", "make_mask", "(", "self", ",", "clean", "=", "True", ",", "dry", "=", "False", ")", ":", "cc", "=", "self", ".", "conconf", "# All True initially.", "mask", "=", "np", ".", "ones", "(", "self", ".", "rec_cnt", ")", "==", "True", "# NOQA", "for...
Set the attribute self.mask to a mask based on the conditions. clean: bool If not True, let the current mask be a condition as well. If True, the mask is set solely on the pack's current conditions dry: bool If True, only try to make a mask, but ...
[ "Set", "the", "attribute", "self", ".", "mask", "to", "a", "mask", "based", "on", "the", "conditions", "." ]
train
https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pack.py#L695-L738
tomnor/channelpack
channelpack/pack.py
ChannelPack.set_channel_names
def set_channel_names(self, names): """ Set self.chnames. Custom channel names that can be used in calls on this object and in condition strings. names: list or None It is the callers responsibility to make sure the list is in column order. self.chnames will be a...
python
def set_channel_names(self, names): """ Set self.chnames. Custom channel names that can be used in calls on this object and in condition strings. names: list or None It is the callers responsibility to make sure the list is in column order. self.chnames will be a...
[ "def", "set_channel_names", "(", "self", ",", "names", ")", ":", "if", "not", "names", ":", "self", ".", "chnames", "=", "None", "return", "if", "len", "(", "names", ")", "!=", "len", "(", "self", ".", "keys", ")", ":", "raise", "ValueError", "(", ...
Set self.chnames. Custom channel names that can be used in calls on this object and in condition strings. names: list or None It is the callers responsibility to make sure the list is in column order. self.chnames will be a dict with channel integer indexes as keys. ...
[ "Set", "self", ".", "chnames", ".", "Custom", "channel", "names", "that", "can", "be", "used", "in", "calls", "on", "this", "object", "and", "in", "condition", "strings", "." ]
train
https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pack.py#L740-L759
tomnor/channelpack
channelpack/pack.py
ChannelPack.counter
def counter(self, ch, part=None): """Return a counter on the channel ch. ch: string or integer. The channel index number or channel name. part: int or None The 0-based enumeration of a True part to return. This has an effect whether or not the mask or filter...
python
def counter(self, ch, part=None): """Return a counter on the channel ch. ch: string or integer. The channel index number or channel name. part: int or None The 0-based enumeration of a True part to return. This has an effect whether or not the mask or filter...
[ "def", "counter", "(", "self", ",", "ch", ",", "part", "=", "None", ")", ":", "return", "Counter", "(", "self", "(", "self", ".", "_key", "(", "ch", ")", ",", "part", "=", "part", ")", ")" ]
Return a counter on the channel ch. ch: string or integer. The channel index number or channel name. part: int or None The 0-based enumeration of a True part to return. This has an effect whether or not the mask or filter is turned on. Raise IndexError i...
[ "Return", "a", "counter", "on", "the", "channel", "ch", "." ]
train
https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pack.py#L791-L807
tomnor/channelpack
channelpack/pack.py
ChannelPack.records
def records(self, part=None, fallback=True): """Return an iterator over the records in the pack. Each record is supplied as a namedtuple with the channel names as field names. This is useful if each record make a meaningful data set on its own. part: int or None Sam...
python
def records(self, part=None, fallback=True): """Return an iterator over the records in the pack. Each record is supplied as a namedtuple with the channel names as field names. This is useful if each record make a meaningful data set on its own. part: int or None Sam...
[ "def", "records", "(", "self", ",", "part", "=", "None", ",", "fallback", "=", "True", ")", ":", "names_0", "=", "[", "self", ".", "chnames_0", "[", "k", "]", "for", "k", "in", "sorted", "(", "self", ".", "chnames_0", ".", "keys", "(", ")", ")", ...
Return an iterator over the records in the pack. Each record is supplied as a namedtuple with the channel names as field names. This is useful if each record make a meaningful data set on its own. part: int or None Same meaning as in :meth:`~channelpack.ChannelP...
[ "Return", "an", "iterator", "over", "the", "records", "in", "the", "pack", "." ]
train
https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pack.py#L837-L878
tomnor/channelpack
channelpack/pack.py
ChannelPack._key
def _key(self, ch): """Return the integer key for ch. It is the key for the first value found in chnames and chnames_0, that matches ch. Or if ch is an int, ch is returned if it is a key in self.D""" if ch in self.D: return ch if isinstance(ch, int): rai...
python
def _key(self, ch): """Return the integer key for ch. It is the key for the first value found in chnames and chnames_0, that matches ch. Or if ch is an int, ch is returned if it is a key in self.D""" if ch in self.D: return ch if isinstance(ch, int): rai...
[ "def", "_key", "(", "self", ",", "ch", ")", ":", "if", "ch", "in", "self", ".", "D", ":", "return", "ch", "if", "isinstance", "(", "ch", ",", "int", ")", ":", "raise", "KeyError", "(", "ch", ")", "# dont accept integers as custom names", "if", "self", ...
Return the integer key for ch. It is the key for the first value found in chnames and chnames_0, that matches ch. Or if ch is an int, ch is returned if it is a key in self.D
[ "Return", "the", "integer", "key", "for", "ch", ".", "It", "is", "the", "key", "for", "the", "first", "value", "found", "in", "chnames", "and", "chnames_0", "that", "matches", "ch", ".", "Or", "if", "ch", "is", "an", "int", "ch", "is", "returned", "i...
train
https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pack.py#L880-L908
tomnor/channelpack
channelpack/pack.py
ChannelPack.name
def name(self, ch, firstwordonly=False): """Return channel name for ch. ch is the channel name or the index number for the channel name, 0-based. ch: str or int. The channel name or indexed number. firstwordonly: bool or "pattern". If True, return only the first...
python
def name(self, ch, firstwordonly=False): """Return channel name for ch. ch is the channel name or the index number for the channel name, 0-based. ch: str or int. The channel name or indexed number. firstwordonly: bool or "pattern". If True, return only the first...
[ "def", "name", "(", "self", ",", "ch", ",", "firstwordonly", "=", "False", ")", ":", "names", "=", "self", ".", "chnames", "or", "self", ".", "chnames_0", "i", "=", "self", ".", "_key", "(", "ch", ")", "if", "not", "firstwordonly", ":", "return", "...
Return channel name for ch. ch is the channel name or the index number for the channel name, 0-based. ch: str or int. The channel name or indexed number. firstwordonly: bool or "pattern". If True, return only the first non-spaced word in the name. If a strin...
[ "Return", "channel", "name", "for", "ch", ".", "ch", "is", "the", "channel", "name", "or", "the", "index", "number", "for", "the", "channel", "name", "0", "-", "based", "." ]
train
https://github.com/tomnor/channelpack/blob/9ad3cd11c698aed4c0fc178385b2ba38a7d0efae/channelpack/pack.py#L910-L938