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
inveniosoftware-attic/invenio-knowledge
invenio_knowledge/api.py
add_kb_mapping
def add_kb_mapping(kb_name, key, value=""): """Add a new mapping to given kb. :param kb_name: the name of the kb where to insert the new value :param key: the key of the mapping :param value: the value of the mapping """ kb = get_kb_by_name(kb_name) if key in kb.kbrvals: # update ...
python
def add_kb_mapping(kb_name, key, value=""): """Add a new mapping to given kb. :param kb_name: the name of the kb where to insert the new value :param key: the key of the mapping :param value: the value of the mapping """ kb = get_kb_by_name(kb_name) if key in kb.kbrvals: # update ...
[ "def", "add_kb_mapping", "(", "kb_name", ",", "key", ",", "value", "=", "\"\"", ")", ":", "kb", "=", "get_kb_by_name", "(", "kb_name", ")", "if", "key", "in", "kb", ".", "kbrvals", ":", "# update", "kb", ".", "kbrvals", "[", "key", "]", ".", "m_value...
Add a new mapping to given kb. :param kb_name: the name of the kb where to insert the new value :param key: the key of the mapping :param value: the value of the mapping
[ "Add", "a", "new", "mapping", "to", "given", "kb", "." ]
train
https://github.com/inveniosoftware-attic/invenio-knowledge/blob/b31722dc14243ca8f626f8b3bce9718d0119de55/invenio_knowledge/api.py#L191-L204
inveniosoftware-attic/invenio-knowledge
invenio_knowledge/api.py
update_kb_mapping
def update_kb_mapping(kb_name, old_key, key, value): """Update an existing kb mapping with key old_key with a new key and value. :param kb_name: the name of the kb where to insert the new value :param old_key: the key of the mapping in the kb :param key: the new key of the mapping :param value: the...
python
def update_kb_mapping(kb_name, old_key, key, value): """Update an existing kb mapping with key old_key with a new key and value. :param kb_name: the name of the kb where to insert the new value :param old_key: the key of the mapping in the kb :param key: the new key of the mapping :param value: the...
[ "def", "update_kb_mapping", "(", "kb_name", ",", "old_key", ",", "key", ",", "value", ")", ":", "db", ".", "session", ".", "query", "(", "models", ".", "KnwKBRVAL", ")", ".", "join", "(", "models", ".", "KnwKB", ")", ".", "filter", "(", "models", "."...
Update an existing kb mapping with key old_key with a new key and value. :param kb_name: the name of the kb where to insert the new value :param old_key: the key of the mapping in the kb :param key: the new key of the mapping :param value: the new value of the mapping
[ "Update", "an", "existing", "kb", "mapping", "with", "key", "old_key", "with", "a", "new", "key", "and", "value", "." ]
train
https://github.com/inveniosoftware-attic/invenio-knowledge/blob/b31722dc14243ca8f626f8b3bce9718d0119de55/invenio_knowledge/api.py#L219-L230
inveniosoftware-attic/invenio-knowledge
invenio_knowledge/api.py
get_kb_mappings_json
def get_kb_mappings_json(kb_name="", key="", value="", match_type="s", limit=None): """Get leftside/rightside mappings from kb kb_name formatted as json dict. If key given, give only those with left side (mapFrom) = key. If value given, give only those with right side (mapTo) = val...
python
def get_kb_mappings_json(kb_name="", key="", value="", match_type="s", limit=None): """Get leftside/rightside mappings from kb kb_name formatted as json dict. If key given, give only those with left side (mapFrom) = key. If value given, give only those with right side (mapTo) = val...
[ "def", "get_kb_mappings_json", "(", "kb_name", "=", "\"\"", ",", "key", "=", "\"\"", ",", "value", "=", "\"\"", ",", "match_type", "=", "\"s\"", ",", "limit", "=", "None", ")", ":", "mappings", "=", "get_kb_mappings", "(", "kb_name", ",", "key", ",", "...
Get leftside/rightside mappings from kb kb_name formatted as json dict. If key given, give only those with left side (mapFrom) = key. If value given, give only those with right side (mapTo) = value. :param kb_name: the name of the kb :param key: include only lines matching this on left side in the res...
[ "Get", "leftside", "/", "rightside", "mappings", "from", "kb", "kb_name", "formatted", "as", "json", "dict", "." ]
train
https://github.com/inveniosoftware-attic/invenio-knowledge/blob/b31722dc14243ca8f626f8b3bce9718d0119de55/invenio_knowledge/api.py#L233-L255
inveniosoftware-attic/invenio-knowledge
invenio_knowledge/api.py
update_kb_attributes
def update_kb_attributes(kb_name, new_name, new_description=''): """Update kb kb_name with a new name and (optionally) description. :param kb_name: the name of the kb to update :param new_name: the new name for the kb :param new_description: the new description for the kb """ models.KnwKB.query...
python
def update_kb_attributes(kb_name, new_name, new_description=''): """Update kb kb_name with a new name and (optionally) description. :param kb_name: the name of the kb to update :param new_name: the new name for the kb :param new_description: the new description for the kb """ models.KnwKB.query...
[ "def", "update_kb_attributes", "(", "kb_name", ",", "new_name", ",", "new_description", "=", "''", ")", ":", "models", ".", "KnwKB", ".", "query", ".", "filter_by", "(", "name", "=", "kb_name", ")", ".", "update", "(", "{", "\"name\"", ":", "new_name", "...
Update kb kb_name with a new name and (optionally) description. :param kb_name: the name of the kb to update :param new_name: the new name for the kb :param new_description: the new description for the kb
[ "Update", "kb", "kb_name", "with", "a", "new", "name", "and", "(", "optionally", ")", "description", "." ]
train
https://github.com/inveniosoftware-attic/invenio-knowledge/blob/b31722dc14243ca8f626f8b3bce9718d0119de55/invenio_knowledge/api.py#L304-L312
inveniosoftware-attic/invenio-knowledge
invenio_knowledge/api.py
add_kb
def add_kb(kb_name=u"Untitled", kb_type=None, tries=10): """Add a new kb in database, return the id. Add a new kb in database, and returns its id The name of the kb will be 'Untitled#' such that it is unique. :param kb_name: the name of the kb :param kb_type: the type of the kb, incl 'taxonomy...
python
def add_kb(kb_name=u"Untitled", kb_type=None, tries=10): """Add a new kb in database, return the id. Add a new kb in database, and returns its id The name of the kb will be 'Untitled#' such that it is unique. :param kb_name: the name of the kb :param kb_type: the type of the kb, incl 'taxonomy...
[ "def", "add_kb", "(", "kb_name", "=", "u\"Untitled\"", ",", "kb_type", "=", "None", ",", "tries", "=", "10", ")", ":", "created", "=", "False", "name", "=", "kb_name", "i", "=", "0", "while", "(", "i", "<", "tries", "and", "created", "is", "False", ...
Add a new kb in database, return the id. Add a new kb in database, and returns its id The name of the kb will be 'Untitled#' such that it is unique. :param kb_name: the name of the kb :param kb_type: the type of the kb, incl 'taxonomy' and 'dynamic'. None for typical (leftside-r...
[ "Add", "a", "new", "kb", "in", "database", "return", "the", "id", "." ]
train
https://github.com/inveniosoftware-attic/invenio-knowledge/blob/b31722dc14243ca8f626f8b3bce9718d0119de55/invenio_knowledge/api.py#L315-L358
inveniosoftware-attic/invenio-knowledge
invenio_knowledge/api.py
add_dynamic_kb
def add_dynamic_kb(kbname, tag, collection="", searchwith=""): """A convenience method.""" kb_id = add_kb(kb_name=kbname, kb_type='dynamic') save_kb_dyn_config(kb_id, tag, searchwith, collection) return kb_id
python
def add_dynamic_kb(kbname, tag, collection="", searchwith=""): """A convenience method.""" kb_id = add_kb(kb_name=kbname, kb_type='dynamic') save_kb_dyn_config(kb_id, tag, searchwith, collection) return kb_id
[ "def", "add_dynamic_kb", "(", "kbname", ",", "tag", ",", "collection", "=", "\"\"", ",", "searchwith", "=", "\"\"", ")", ":", "kb_id", "=", "add_kb", "(", "kb_name", "=", "kbname", ",", "kb_type", "=", "'dynamic'", ")", "save_kb_dyn_config", "(", "kb_id", ...
A convenience method.
[ "A", "convenience", "method", "." ]
train
https://github.com/inveniosoftware-attic/invenio-knowledge/blob/b31722dc14243ca8f626f8b3bce9718d0119de55/invenio_knowledge/api.py#L361-L365
inveniosoftware-attic/invenio-knowledge
invenio_knowledge/api.py
save_kb_dyn_config
def save_kb_dyn_config(kb_id, field, expression, collection=None): """Save a dynamic knowledge base configuration. :param kb_id: the id :param field: the field where values are extracted :param expression: ..using this expression :param collection: ..in a certain collection (default is all) """...
python
def save_kb_dyn_config(kb_id, field, expression, collection=None): """Save a dynamic knowledge base configuration. :param kb_id: the id :param field: the field where values are extracted :param expression: ..using this expression :param collection: ..in a certain collection (default is all) """...
[ "def", "save_kb_dyn_config", "(", "kb_id", ",", "field", ",", "expression", ",", "collection", "=", "None", ")", ":", "# check that collection exists", "if", "collection", ":", "collection", "=", "Collection", ".", "query", ".", "filter_by", "(", "name", "=", ...
Save a dynamic knowledge base configuration. :param kb_id: the id :param field: the field where values are extracted :param expression: ..using this expression :param collection: ..in a certain collection (default is all)
[ "Save", "a", "dynamic", "knowledge", "base", "configuration", "." ]
train
https://github.com/inveniosoftware-attic/invenio-knowledge/blob/b31722dc14243ca8f626f8b3bce9718d0119de55/invenio_knowledge/api.py#L368-L381
inveniosoftware-attic/invenio-knowledge
invenio_knowledge/api.py
kb_mapping_exists
def kb_mapping_exists(kb_name, key): """Return the information if a mapping exists. :param kb_name: knowledge base name :param key: left side (mapFrom) """ try: kb = get_kb_by_name(kb_name) except NoResultFound: return False return key in kb.kbrvals
python
def kb_mapping_exists(kb_name, key): """Return the information if a mapping exists. :param kb_name: knowledge base name :param key: left side (mapFrom) """ try: kb = get_kb_by_name(kb_name) except NoResultFound: return False return key in kb.kbrvals
[ "def", "kb_mapping_exists", "(", "kb_name", ",", "key", ")", ":", "try", ":", "kb", "=", "get_kb_by_name", "(", "kb_name", ")", "except", "NoResultFound", ":", "return", "False", "return", "key", "in", "kb", ".", "kbrvals" ]
Return the information if a mapping exists. :param kb_name: knowledge base name :param key: left side (mapFrom)
[ "Return", "the", "information", "if", "a", "mapping", "exists", "." ]
train
https://github.com/inveniosoftware-attic/invenio-knowledge/blob/b31722dc14243ca8f626f8b3bce9718d0119de55/invenio_knowledge/api.py#L384-L394
inveniosoftware-attic/invenio-knowledge
invenio_knowledge/api.py
delete_kb
def delete_kb(kb_name): """Delete given kb from database. :param kb_name: knowledge base name """ db.session.delete(models.KnwKB.query.filter_by( name=kb_name).one())
python
def delete_kb(kb_name): """Delete given kb from database. :param kb_name: knowledge base name """ db.session.delete(models.KnwKB.query.filter_by( name=kb_name).one())
[ "def", "delete_kb", "(", "kb_name", ")", ":", "db", ".", "session", ".", "delete", "(", "models", ".", "KnwKB", ".", "query", ".", "filter_by", "(", "name", "=", "kb_name", ")", ".", "one", "(", ")", ")" ]
Delete given kb from database. :param kb_name: knowledge base name
[ "Delete", "given", "kb", "from", "database", "." ]
train
https://github.com/inveniosoftware-attic/invenio-knowledge/blob/b31722dc14243ca8f626f8b3bce9718d0119de55/invenio_knowledge/api.py#L398-L404
inveniosoftware-attic/invenio-knowledge
invenio_knowledge/api.py
get_kbs_info
def get_kbs_info(kbtype="", searchkbname=""): """A convenience method. :param kbtype: type of kb -- get only kb's of this type :param searchkbname: get only kb's where this sting appears in the name """ # query + order by query = models.KnwKB.query.order_by( models.KnwKB.name) # fil...
python
def get_kbs_info(kbtype="", searchkbname=""): """A convenience method. :param kbtype: type of kb -- get only kb's of this type :param searchkbname: get only kb's where this sting appears in the name """ # query + order by query = models.KnwKB.query.order_by( models.KnwKB.name) # fil...
[ "def", "get_kbs_info", "(", "kbtype", "=", "\"\"", ",", "searchkbname", "=", "\"\"", ")", ":", "# query + order by", "query", "=", "models", ".", "KnwKB", ".", "query", ".", "order_by", "(", "models", ".", "KnwKB", ".", "name", ")", "# filters", "if", "k...
A convenience method. :param kbtype: type of kb -- get only kb's of this type :param searchkbname: get only kb's where this sting appears in the name
[ "A", "convenience", "method", "." ]
train
https://github.com/inveniosoftware-attic/invenio-knowledge/blob/b31722dc14243ca8f626f8b3bce9718d0119de55/invenio_knowledge/api.py#L409-L424
inveniosoftware-attic/invenio-knowledge
invenio_knowledge/api.py
get_kba_values
def get_kba_values(kb_name, searchname="", searchtype="s"): """Return an array of values "authority file" type = just values. :param kb_name: name of kb :param searchname: get these values, according to searchtype :param searchtype: s=substring, e=exact, , sw=startswith """ if searchtype == 's'...
python
def get_kba_values(kb_name, searchname="", searchtype="s"): """Return an array of values "authority file" type = just values. :param kb_name: name of kb :param searchname: get these values, according to searchtype :param searchtype: s=substring, e=exact, , sw=startswith """ if searchtype == 's'...
[ "def", "get_kba_values", "(", "kb_name", ",", "searchname", "=", "\"\"", ",", "searchtype", "=", "\"s\"", ")", ":", "if", "searchtype", "==", "'s'", "and", "searchname", ":", "searchname", "=", "'%'", "+", "searchname", "+", "'%'", "if", "searchtype", "=="...
Return an array of values "authority file" type = just values. :param kb_name: name of kb :param searchname: get these values, according to searchtype :param searchtype: s=substring, e=exact, , sw=startswith
[ "Return", "an", "array", "of", "values", "authority", "file", "type", "=", "just", "values", "." ]
train
https://github.com/inveniosoftware-attic/invenio-knowledge/blob/b31722dc14243ca8f626f8b3bce9718d0119de55/invenio_knowledge/api.py#L427-L446
inveniosoftware-attic/invenio-knowledge
invenio_knowledge/api.py
get_kbr_keys
def get_kbr_keys(kb_name, searchkey="", searchvalue="", searchtype='s'): """Return an array of keys. :param kb_name: the name of the knowledge base :param searchkey: search using this key :param searchvalue: search using this value :param searchtype: s = substring, e=exact """ if searchtype...
python
def get_kbr_keys(kb_name, searchkey="", searchvalue="", searchtype='s'): """Return an array of keys. :param kb_name: the name of the knowledge base :param searchkey: search using this key :param searchvalue: search using this value :param searchtype: s = substring, e=exact """ if searchtype...
[ "def", "get_kbr_keys", "(", "kb_name", ",", "searchkey", "=", "\"\"", ",", "searchvalue", "=", "\"\"", ",", "searchtype", "=", "'s'", ")", ":", "if", "searchtype", "==", "'s'", "and", "searchkey", ":", "searchkey", "=", "'%'", "+", "searchkey", "+", "'%'...
Return an array of keys. :param kb_name: the name of the knowledge base :param searchkey: search using this key :param searchvalue: search using this value :param searchtype: s = substring, e=exact
[ "Return", "an", "array", "of", "keys", "." ]
train
https://github.com/inveniosoftware-attic/invenio-knowledge/blob/b31722dc14243ca8f626f8b3bce9718d0119de55/invenio_knowledge/api.py#L449-L473
inveniosoftware-attic/invenio-knowledge
invenio_knowledge/api.py
get_kbr_values
def get_kbr_values(kb_name, searchkey="", searchvalue="", searchtype='s', use_memoise=False): """Return a tuple of values from key-value mapping kb. :param kb_name: the name of the knowledge base :param searchkey: search using this key :param searchvalue: search using this valu...
python
def get_kbr_values(kb_name, searchkey="", searchvalue="", searchtype='s', use_memoise=False): """Return a tuple of values from key-value mapping kb. :param kb_name: the name of the knowledge base :param searchkey: search using this key :param searchvalue: search using this valu...
[ "def", "get_kbr_values", "(", "kb_name", ",", "searchkey", "=", "\"\"", ",", "searchvalue", "=", "\"\"", ",", "searchtype", "=", "'s'", ",", "use_memoise", "=", "False", ")", ":", "try", ":", "if", "use_memoise", ":", "kb", "=", "get_kb_by_name_memoised", ...
Return a tuple of values from key-value mapping kb. :param kb_name: the name of the knowledge base :param searchkey: search using this key :param searchvalue: search using this value :param searchtype: s=substring; e=exact :param use_memoise: can we memoise while doing lookups? :type use...
[ "Return", "a", "tuple", "of", "values", "from", "key", "-", "value", "mapping", "kb", "." ]
train
https://github.com/inveniosoftware-attic/invenio-knowledge/blob/b31722dc14243ca8f626f8b3bce9718d0119de55/invenio_knowledge/api.py#L476-L494
inveniosoftware-attic/invenio-knowledge
invenio_knowledge/api.py
get_kbr_items
def get_kbr_items(kb_name, searchkey="", searchvalue="", searchtype='s'): """Return a list of dictionaries that match the search. :param kb_name: the name of the knowledge base :param searchkey: search using this key :param searchvalue: search using this value :param searchtype: s = substring, e=ex...
python
def get_kbr_items(kb_name, searchkey="", searchvalue="", searchtype='s'): """Return a list of dictionaries that match the search. :param kb_name: the name of the knowledge base :param searchkey: search using this key :param searchvalue: search using this value :param searchtype: s = substring, e=ex...
[ "def", "get_kbr_items", "(", "kb_name", ",", "searchkey", "=", "\"\"", ",", "searchvalue", "=", "\"\"", ",", "searchtype", "=", "'s'", ")", ":", "kb", "=", "get_kb_by_name", "(", "kb_name", ")", "return", "kb", ".", "get_kbr_items", "(", "searchkey", ",", ...
Return a list of dictionaries that match the search. :param kb_name: the name of the knowledge base :param searchkey: search using this key :param searchvalue: search using this value :param searchtype: s = substring, e=exact :return: a list of dictionaries [{'key'=>x, 'value'=>y},..]
[ "Return", "a", "list", "of", "dictionaries", "that", "match", "the", "search", "." ]
train
https://github.com/inveniosoftware-attic/invenio-knowledge/blob/b31722dc14243ca8f626f8b3bce9718d0119de55/invenio_knowledge/api.py#L497-L507
inveniosoftware-attic/invenio-knowledge
invenio_knowledge/api.py
get_kbd_values
def get_kbd_values(kbname, searchwith=""): """Return a list of values by searching a dynamic kb. :param kbname: name of the knowledge base :param searchwith: a term to search with :return: list of values """ kb = get_kb_by_name(kbname) kbid = kb.id if not kbid: return [] ...
python
def get_kbd_values(kbname, searchwith=""): """Return a list of values by searching a dynamic kb. :param kbname: name of the knowledge base :param searchwith: a term to search with :return: list of values """ kb = get_kb_by_name(kbname) kbid = kb.id if not kbid: return [] ...
[ "def", "get_kbd_values", "(", "kbname", ",", "searchwith", "=", "\"\"", ")", ":", "kb", "=", "get_kb_by_name", "(", "kbname", ")", "kbid", "=", "kb", ".", "id", "if", "not", "kbid", ":", "return", "[", "]", "kbtype", "=", "kb", ".", "kbtype", "if", ...
Return a list of values by searching a dynamic kb. :param kbname: name of the knowledge base :param searchwith: a term to search with :return: list of values
[ "Return", "a", "list", "of", "values", "by", "searching", "a", "dynamic", "kb", "." ]
train
https://github.com/inveniosoftware-attic/invenio-knowledge/blob/b31722dc14243ca8f626f8b3bce9718d0119de55/invenio_knowledge/api.py#L510-L526
inveniosoftware-attic/invenio-knowledge
invenio_knowledge/api.py
get_kbd_values_by_def
def get_kbd_values_by_def(confdict, searchwith=""): """Return a list of values by searching a dynamic kb. :param confdict: dictionary with keys "field", "expression" and "collection" name :param searchwith: a term to search with :return: list of values """ from invenio_search.api import...
python
def get_kbd_values_by_def(confdict, searchwith=""): """Return a list of values by searching a dynamic kb. :param confdict: dictionary with keys "field", "expression" and "collection" name :param searchwith: a term to search with :return: list of values """ from invenio_search.api import...
[ "def", "get_kbd_values_by_def", "(", "confdict", ",", "searchwith", "=", "\"\"", ")", ":", "from", "invenio_search", ".", "api", "import", "Query", "# get the configuration so that we see what the field is", "if", "not", "confdict", ":", "return", "[", "]", "if", "'...
Return a list of values by searching a dynamic kb. :param confdict: dictionary with keys "field", "expression" and "collection" name :param searchwith: a term to search with :return: list of values
[ "Return", "a", "list", "of", "values", "by", "searching", "a", "dynamic", "kb", "." ]
train
https://github.com/inveniosoftware-attic/invenio-knowledge/blob/b31722dc14243ca8f626f8b3bce9718d0119de55/invenio_knowledge/api.py#L529-L577
inveniosoftware-attic/invenio-knowledge
invenio_knowledge/api.py
get_kbd_values_json
def get_kbd_values_json(kbname, searchwith=""): """Return values from searching a dynamic kb as a json-formatted string. This IS probably the method you want. :param kbname: name of the knowledge base :param searchwith: a term to search with """ res = get_kbd_values(kbname, searchwith) ...
python
def get_kbd_values_json(kbname, searchwith=""): """Return values from searching a dynamic kb as a json-formatted string. This IS probably the method you want. :param kbname: name of the knowledge base :param searchwith: a term to search with """ res = get_kbd_values(kbname, searchwith) ...
[ "def", "get_kbd_values_json", "(", "kbname", ",", "searchwith", "=", "\"\"", ")", ":", "res", "=", "get_kbd_values", "(", "kbname", ",", "searchwith", ")", "return", "json", ".", "dumps", "(", "res", ")" ]
Return values from searching a dynamic kb as a json-formatted string. This IS probably the method you want. :param kbname: name of the knowledge base :param searchwith: a term to search with
[ "Return", "values", "from", "searching", "a", "dynamic", "kb", "as", "a", "json", "-", "formatted", "string", "." ]
train
https://github.com/inveniosoftware-attic/invenio-knowledge/blob/b31722dc14243ca8f626f8b3bce9718d0119de55/invenio_knowledge/api.py#L580-L589
inveniosoftware-attic/invenio-knowledge
invenio_knowledge/api.py
get_kbt_items
def get_kbt_items(taxonomyfilename, templatefilename, searchwith=""): """ Get items from taxonomy file using a templatefile. If searchwith is defined, return only items that match with it. :param taxonomyfilename: full path+name of the RDF file :param templatefile: full path+name of the XSLT file ...
python
def get_kbt_items(taxonomyfilename, templatefilename, searchwith=""): """ Get items from taxonomy file using a templatefile. If searchwith is defined, return only items that match with it. :param taxonomyfilename: full path+name of the RDF file :param templatefile: full path+name of the XSLT file ...
[ "def", "get_kbt_items", "(", "taxonomyfilename", ",", "templatefilename", ",", "searchwith", "=", "\"\"", ")", ":", "if", "processor_type", "==", "1", ":", "# lxml", "doc", "=", "etree", ".", "XML", "(", "taxonomyfilename", ")", "styledoc", "=", "etree", "."...
Get items from taxonomy file using a templatefile. If searchwith is defined, return only items that match with it. :param taxonomyfilename: full path+name of the RDF file :param templatefile: full path+name of the XSLT file :param searchwith: a term to search with
[ "Get", "items", "from", "taxonomy", "file", "using", "a", "templatefile", "." ]
train
https://github.com/inveniosoftware-attic/invenio-knowledge/blob/b31722dc14243ca8f626f8b3bce9718d0119de55/invenio_knowledge/api.py#L592-L639
campbellr/smashrun-client
smashrun/client.py
to_timestamp
def to_timestamp(dt): """Convert a datetime object to a unix timestamp. Note that unlike a typical unix timestamp, this is seconds since 1970 *local time*, not UTC. If the passed in object is already a timestamp, then that value is simply returned unmodified. """ if isinstance(dt, int): ...
python
def to_timestamp(dt): """Convert a datetime object to a unix timestamp. Note that unlike a typical unix timestamp, this is seconds since 1970 *local time*, not UTC. If the passed in object is already a timestamp, then that value is simply returned unmodified. """ if isinstance(dt, int): ...
[ "def", "to_timestamp", "(", "dt", ")", ":", "if", "isinstance", "(", "dt", ",", "int", ")", ":", "return", "dt", "return", "int", "(", "total_seconds", "(", "dt", ".", "replace", "(", "tzinfo", "=", "None", ")", "-", "datetime", ".", "datetime", "(",...
Convert a datetime object to a unix timestamp. Note that unlike a typical unix timestamp, this is seconds since 1970 *local time*, not UTC. If the passed in object is already a timestamp, then that value is simply returned unmodified.
[ "Convert", "a", "datetime", "object", "to", "a", "unix", "timestamp", "." ]
train
https://github.com/campbellr/smashrun-client/blob/2522cb4d0545cf482a49a9533f12aac94c5aecdc/smashrun/client.py#L257-L269
campbellr/smashrun-client
smashrun/client.py
Smashrun.fetch_token
def fetch_token(self, **kwargs): """Fetch a new token using the supplied code. :param str code: A previously obtained auth code. """ if 'client_secret' not in kwargs: kwargs.update(client_secret=self.client_secret) return self.session.fetch_token(token_url, **kwargs...
python
def fetch_token(self, **kwargs): """Fetch a new token using the supplied code. :param str code: A previously obtained auth code. """ if 'client_secret' not in kwargs: kwargs.update(client_secret=self.client_secret) return self.session.fetch_token(token_url, **kwargs...
[ "def", "fetch_token", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "'client_secret'", "not", "in", "kwargs", ":", "kwargs", ".", "update", "(", "client_secret", "=", "self", ".", "client_secret", ")", "return", "self", ".", "session", ".", "fetc...
Fetch a new token using the supplied code. :param str code: A previously obtained auth code.
[ "Fetch", "a", "new", "token", "using", "the", "supplied", "code", "." ]
train
https://github.com/campbellr/smashrun-client/blob/2522cb4d0545cf482a49a9533f12aac94c5aecdc/smashrun/client.py#L43-L51
campbellr/smashrun-client
smashrun/client.py
Smashrun.refresh_token
def refresh_token(self, **kwargs): """Refresh the authentication token. :param str refresh_token: The refresh token to use. May be empty if retrieved with ``fetch_token``. """ if 'client_secret' not in kwargs: kwargs.update(client_secret=se...
python
def refresh_token(self, **kwargs): """Refresh the authentication token. :param str refresh_token: The refresh token to use. May be empty if retrieved with ``fetch_token``. """ if 'client_secret' not in kwargs: kwargs.update(client_secret=se...
[ "def", "refresh_token", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "'client_secret'", "not", "in", "kwargs", ":", "kwargs", ".", "update", "(", "client_secret", "=", "self", ".", "client_secret", ")", "if", "'client_id'", "not", "in", "kwargs", ...
Refresh the authentication token. :param str refresh_token: The refresh token to use. May be empty if retrieved with ``fetch_token``.
[ "Refresh", "the", "authentication", "token", "." ]
train
https://github.com/campbellr/smashrun-client/blob/2522cb4d0545cf482a49a9533f12aac94c5aecdc/smashrun/client.py#L53-L64
campbellr/smashrun-client
smashrun/client.py
Smashrun.get_activity
def get_activity(self, id_num): """Return the activity with the given id. Note that this contains more detailed information than returned by `get_activities`. """ url = self._build_url('my', 'activities', id_num) return self._json(url)
python
def get_activity(self, id_num): """Return the activity with the given id. Note that this contains more detailed information than returned by `get_activities`. """ url = self._build_url('my', 'activities', id_num) return self._json(url)
[ "def", "get_activity", "(", "self", ",", "id_num", ")", ":", "url", "=", "self", ".", "_build_url", "(", "'my'", ",", "'activities'", ",", "id_num", ")", "return", "self", ".", "_json", "(", "url", ")" ]
Return the activity with the given id. Note that this contains more detailed information than returned by `get_activities`.
[ "Return", "the", "activity", "with", "the", "given", "id", "." ]
train
https://github.com/campbellr/smashrun-client/blob/2522cb4d0545cf482a49a9533f12aac94c5aecdc/smashrun/client.py#L66-L74
campbellr/smashrun-client
smashrun/client.py
Smashrun.get_activities
def get_activities(self, count=10, since=None, style='summary', limit=None): """Iterate over all activities, from newest to oldest. :param count: The number of results to retrieve per page. If set to ``None``, pagination is disabled. :param since: R...
python
def get_activities(self, count=10, since=None, style='summary', limit=None): """Iterate over all activities, from newest to oldest. :param count: The number of results to retrieve per page. If set to ``None``, pagination is disabled. :param since: R...
[ "def", "get_activities", "(", "self", ",", "count", "=", "10", ",", "since", "=", "None", ",", "style", "=", "'summary'", ",", "limit", "=", "None", ")", ":", "params", "=", "{", "}", "if", "since", ":", "params", ".", "update", "(", "fromDate", "=...
Iterate over all activities, from newest to oldest. :param count: The number of results to retrieve per page. If set to ``None``, pagination is disabled. :param since: Return only activities since this date. Can be either a timestamp or a datetime object. ...
[ "Iterate", "over", "all", "activities", "from", "newest", "to", "oldest", "." ]
train
https://github.com/campbellr/smashrun-client/blob/2522cb4d0545cf482a49a9533f12aac94c5aecdc/smashrun/client.py#L76-L102
campbellr/smashrun-client
smashrun/client.py
Smashrun.get_notables
def get_notables(self, id_num): """Return the notables of the activity with the given id. """ url = self._build_url('my', 'activities', id_num, 'notables') return self._json(url)
python
def get_notables(self, id_num): """Return the notables of the activity with the given id. """ url = self._build_url('my', 'activities', id_num, 'notables') return self._json(url)
[ "def", "get_notables", "(", "self", ",", "id_num", ")", ":", "url", "=", "self", ".", "_build_url", "(", "'my'", ",", "'activities'", ",", "id_num", ",", "'notables'", ")", "return", "self", ".", "_json", "(", "url", ")" ]
Return the notables of the activity with the given id.
[ "Return", "the", "notables", "of", "the", "activity", "with", "the", "given", "id", "." ]
train
https://github.com/campbellr/smashrun-client/blob/2522cb4d0545cf482a49a9533f12aac94c5aecdc/smashrun/client.py#L109-L113
campbellr/smashrun-client
smashrun/client.py
Smashrun.get_polyline
def get_polyline(self, id_num, style='google'): """Return the polyline of the activity with the given id. :param style: The type of polyline to return. May be one of 'google', 'svg', or 'geojson'. """ parts = ['my', 'activities', id_num, 'polyline'] if sty...
python
def get_polyline(self, id_num, style='google'): """Return the polyline of the activity with the given id. :param style: The type of polyline to return. May be one of 'google', 'svg', or 'geojson'. """ parts = ['my', 'activities', id_num, 'polyline'] if sty...
[ "def", "get_polyline", "(", "self", ",", "id_num", ",", "style", "=", "'google'", ")", ":", "parts", "=", "[", "'my'", ",", "'activities'", ",", "id_num", ",", "'polyline'", "]", "if", "style", "!=", "'google'", ":", "parts", ".", "append", "(", "style...
Return the polyline of the activity with the given id. :param style: The type of polyline to return. May be one of 'google', 'svg', or 'geojson'.
[ "Return", "the", "polyline", "of", "the", "activity", "with", "the", "given", "id", "." ]
train
https://github.com/campbellr/smashrun-client/blob/2522cb4d0545cf482a49a9533f12aac94c5aecdc/smashrun/client.py#L115-L127
campbellr/smashrun-client
smashrun/client.py
Smashrun.get_splits
def get_splits(self, id_num, unit='mi'): """Return the splits of the activity with the given id. :param unit: The unit to use for splits. May be one of 'mi' or 'km'. """ url = self._build_url('my', 'activities', id_num, 'splits', unit) return self._json(u...
python
def get_splits(self, id_num, unit='mi'): """Return the splits of the activity with the given id. :param unit: The unit to use for splits. May be one of 'mi' or 'km'. """ url = self._build_url('my', 'activities', id_num, 'splits', unit) return self._json(u...
[ "def", "get_splits", "(", "self", ",", "id_num", ",", "unit", "=", "'mi'", ")", ":", "url", "=", "self", ".", "_build_url", "(", "'my'", ",", "'activities'", ",", "id_num", ",", "'splits'", ",", "unit", ")", "return", "self", ".", "_json", "(", "url"...
Return the splits of the activity with the given id. :param unit: The unit to use for splits. May be one of 'mi' or 'km'.
[ "Return", "the", "splits", "of", "the", "activity", "with", "the", "given", "id", "." ]
train
https://github.com/campbellr/smashrun-client/blob/2522cb4d0545cf482a49a9533f12aac94c5aecdc/smashrun/client.py#L129-L138
campbellr/smashrun-client
smashrun/client.py
Smashrun.get_stats
def get_stats(self, year=None, month=None): """Return stats for the given year and month.""" parts = ['my', 'stats'] if month and not year: raise ValueError("month cannot be specified without year") if year: parts.append(year) if month: parts.a...
python
def get_stats(self, year=None, month=None): """Return stats for the given year and month.""" parts = ['my', 'stats'] if month and not year: raise ValueError("month cannot be specified without year") if year: parts.append(year) if month: parts.a...
[ "def", "get_stats", "(", "self", ",", "year", "=", "None", ",", "month", "=", "None", ")", ":", "parts", "=", "[", "'my'", ",", "'stats'", "]", "if", "month", "and", "not", "year", ":", "raise", "ValueError", "(", "\"month cannot be specified without year\...
Return stats for the given year and month.
[ "Return", "stats", "for", "the", "given", "year", "and", "month", "." ]
train
https://github.com/campbellr/smashrun-client/blob/2522cb4d0545cf482a49a9533f12aac94c5aecdc/smashrun/client.py#L140-L150
campbellr/smashrun-client
smashrun/client.py
Smashrun.create_weight
def create_weight(self, weight, date=None): """Submit a new weight record. :param weight: The weight, in kilograms. :param date: The date the weight was recorded. If not specified, the current date will be used. """ url = self._build_url('my', 'body', 'weig...
python
def create_weight(self, weight, date=None): """Submit a new weight record. :param weight: The weight, in kilograms. :param date: The date the weight was recorded. If not specified, the current date will be used. """ url = self._build_url('my', 'body', 'weig...
[ "def", "create_weight", "(", "self", ",", "weight", ",", "date", "=", "None", ")", ":", "url", "=", "self", ".", "_build_url", "(", "'my'", ",", "'body'", ",", "'weight'", ")", "data", "=", "{", "'weightInKilograms'", ":", "weight", "}", "if", "date", ...
Submit a new weight record. :param weight: The weight, in kilograms. :param date: The date the weight was recorded. If not specified, the current date will be used.
[ "Submit", "a", "new", "weight", "record", "." ]
train
https://github.com/campbellr/smashrun-client/blob/2522cb4d0545cf482a49a9533f12aac94c5aecdc/smashrun/client.py#L167-L184
campbellr/smashrun-client
smashrun/client.py
Smashrun.create_activity
def create_activity(self, data): """Create a new activity (run). :param data: The data representing the activity you want to upload. May be either JSON, GPX, or TCX. """ url = self._build_url('my', 'activities') if isinstance(data, dict): data =...
python
def create_activity(self, data): """Create a new activity (run). :param data: The data representing the activity you want to upload. May be either JSON, GPX, or TCX. """ url = self._build_url('my', 'activities') if isinstance(data, dict): data =...
[ "def", "create_activity", "(", "self", ",", "data", ")", ":", "url", "=", "self", ".", "_build_url", "(", "'my'", ",", "'activities'", ")", "if", "isinstance", "(", "data", ",", "dict", ")", ":", "data", "=", "json", ".", "dumps", "(", "data", ")", ...
Create a new activity (run). :param data: The data representing the activity you want to upload. May be either JSON, GPX, or TCX.
[ "Create", "a", "new", "activity", "(", "run", ")", "." ]
train
https://github.com/campbellr/smashrun-client/blob/2522cb4d0545cf482a49a9533f12aac94c5aecdc/smashrun/client.py#L186-L198
campbellr/smashrun-client
smashrun/client.py
Smashrun.update_activity
def update_activity(self, id_num, data): """Update an existing activity (run). :param id_num: The activity ID to update :param data: The data representing the activity you want to upload. May be either JSON, GPX, or TCX. """ url = self._build_url('my', 'act...
python
def update_activity(self, id_num, data): """Update an existing activity (run). :param id_num: The activity ID to update :param data: The data representing the activity you want to upload. May be either JSON, GPX, or TCX. """ url = self._build_url('my', 'act...
[ "def", "update_activity", "(", "self", ",", "id_num", ",", "data", ")", ":", "url", "=", "self", ".", "_build_url", "(", "'my'", ",", "'activities'", ")", "if", "isinstance", "(", "data", ",", "dict", ")", ":", "data", "=", "json", ".", "dumps", "(",...
Update an existing activity (run). :param id_num: The activity ID to update :param data: The data representing the activity you want to upload. May be either JSON, GPX, or TCX.
[ "Update", "an", "existing", "activity", "(", "run", ")", "." ]
train
https://github.com/campbellr/smashrun-client/blob/2522cb4d0545cf482a49a9533f12aac94c5aecdc/smashrun/client.py#L200-L213
campbellr/smashrun-client
smashrun/client.py
Smashrun.delete_activity
def delete_activity(self, id_num): """Delete an activity (run). :param id_num: The activity ID to delete """ url = self._build_url('my', 'activities', id_num) r = self.session.delete(url) r.raise_for_status() return r
python
def delete_activity(self, id_num): """Delete an activity (run). :param id_num: The activity ID to delete """ url = self._build_url('my', 'activities', id_num) r = self.session.delete(url) r.raise_for_status() return r
[ "def", "delete_activity", "(", "self", ",", "id_num", ")", ":", "url", "=", "self", ".", "_build_url", "(", "'my'", ",", "'activities'", ",", "id_num", ")", "r", "=", "self", ".", "session", ".", "delete", "(", "url", ")", "r", ".", "raise_for_status",...
Delete an activity (run). :param id_num: The activity ID to delete
[ "Delete", "an", "activity", "(", "run", ")", "." ]
train
https://github.com/campbellr/smashrun-client/blob/2522cb4d0545cf482a49a9533f12aac94c5aecdc/smashrun/client.py#L215-L225
kyan001/PyConsoleIOTools
consoleiotools.py
as_session
def as_session(name_or_func): # decorator """print start/title/end info before and after the function call Args: title: title will show after the start, if has any """ if callable(name_or_func): # no name provided func = name_or_func name = func.__name__ name = "".join...
python
def as_session(name_or_func): # decorator """print start/title/end info before and after the function call Args: title: title will show after the start, if has any """ if callable(name_or_func): # no name provided func = name_or_func name = func.__name__ name = "".join...
[ "def", "as_session", "(", "name_or_func", ")", ":", "# decorator", "if", "callable", "(", "name_or_func", ")", ":", "# no name provided", "func", "=", "name_or_func", "name", "=", "func", ".", "__name__", "name", "=", "\"\"", ".", "join", "(", "[", "(", "'...
print start/title/end info before and after the function call Args: title: title will show after the start, if has any
[ "print", "start", "/", "title", "/", "end", "info", "before", "and", "after", "the", "function", "call" ]
train
https://github.com/kyan001/PyConsoleIOTools/blob/cc0cc2b9caf62a0fd1a9a72952a6f8c4d17694c4/consoleiotools.py#L10-L34
kyan001/PyConsoleIOTools
consoleiotools.py
title
def title(msg, **options): """print something like a title""" return echo(Style.BRIGHT + Fore.CYAN + "__{}__________________________".format(msg.upper().strip()) + Style.RESET_ALL + Fore.RESET, **options)
python
def title(msg, **options): """print something like a title""" return echo(Style.BRIGHT + Fore.CYAN + "__{}__________________________".format(msg.upper().strip()) + Style.RESET_ALL + Fore.RESET, **options)
[ "def", "title", "(", "msg", ",", "*", "*", "options", ")", ":", "return", "echo", "(", "Style", ".", "BRIGHT", "+", "Fore", ".", "CYAN", "+", "\"__{}__________________________\"", ".", "format", "(", "msg", ".", "upper", "(", ")", ".", "strip", "(", ...
print something like a title
[ "print", "something", "like", "a", "title" ]
train
https://github.com/kyan001/PyConsoleIOTools/blob/cc0cc2b9caf62a0fd1a9a72952a6f8c4d17694c4/consoleiotools.py#L55-L57
kyan001/PyConsoleIOTools
consoleiotools.py
pause
def pause(msg="Press Enter to Continue..."): """press to continue""" print('\n' + Fore.YELLOW + msg + Fore.RESET, end='') input()
python
def pause(msg="Press Enter to Continue..."): """press to continue""" print('\n' + Fore.YELLOW + msg + Fore.RESET, end='') input()
[ "def", "pause", "(", "msg", "=", "\"Press Enter to Continue...\"", ")", ":", "print", "(", "'\\n'", "+", "Fore", ".", "YELLOW", "+", "msg", "+", "Fore", ".", "RESET", ",", "end", "=", "''", ")", "input", "(", ")" ]
press to continue
[ "press", "to", "continue" ]
train
https://github.com/kyan001/PyConsoleIOTools/blob/cc0cc2b9caf62a0fd1a9a72952a6f8c4d17694c4/consoleiotools.py#L76-L79
fangpenlin/pyramid-handy
pyramid_handy/tweens/allow_origin.py
allow_origin_tween_factory
def allow_origin_tween_factory(handler, registry): """Allow cross origin XHR requests """ def allow_origin_tween(request): settings = request.registry.settings request_origin = request.headers.get('origin') def is_origin_allowed(origin): allowed_origins = ( ...
python
def allow_origin_tween_factory(handler, registry): """Allow cross origin XHR requests """ def allow_origin_tween(request): settings = request.registry.settings request_origin = request.headers.get('origin') def is_origin_allowed(origin): allowed_origins = ( ...
[ "def", "allow_origin_tween_factory", "(", "handler", ",", "registry", ")", ":", "def", "allow_origin_tween", "(", "request", ")", ":", "settings", "=", "request", ".", "registry", ".", "settings", "request_origin", "=", "request", ".", "headers", ".", "get", "...
Allow cross origin XHR requests
[ "Allow", "cross", "origin", "XHR", "requests" ]
train
https://github.com/fangpenlin/pyramid-handy/blob/e3cbc19224ab1f0a14aab556990bceabd2d1f658/pyramid_handy/tweens/allow_origin.py#L6-L70
fr33jc/bang
bang/providers/hpcloud/reddwarf.py
DBSecurityGroup.grant
def grant(self, source_cidr): """ Allows connections from :attr:`source_cidr`. :param str source_cidr: The source IP range from which to allow connections. """ self.manager.api.secgroup_rules.create(self.id, source_cidr)
python
def grant(self, source_cidr): """ Allows connections from :attr:`source_cidr`. :param str source_cidr: The source IP range from which to allow connections. """ self.manager.api.secgroup_rules.create(self.id, source_cidr)
[ "def", "grant", "(", "self", ",", "source_cidr", ")", ":", "self", ".", "manager", ".", "api", ".", "secgroup_rules", ".", "create", "(", "self", ".", "id", ",", "source_cidr", ")" ]
Allows connections from :attr:`source_cidr`. :param str source_cidr: The source IP range from which to allow connections.
[ "Allows", "connections", "from", ":", "attr", ":", "source_cidr", "." ]
train
https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/providers/hpcloud/reddwarf.py#L26-L34
fr33jc/bang
bang/providers/hpcloud/reddwarf.py
DBSecurityGroupRules.create
def create(self, dbsecgroup_id, source_cidr, port=3306): """ Creates a security group rule. :param str dbsecgroup_id: The ID of the security group in which this rule should be created. :param str source_cidr: The source IP address range from which access should...
python
def create(self, dbsecgroup_id, source_cidr, port=3306): """ Creates a security group rule. :param str dbsecgroup_id: The ID of the security group in which this rule should be created. :param str source_cidr: The source IP address range from which access should...
[ "def", "create", "(", "self", ",", "dbsecgroup_id", ",", "source_cidr", ",", "port", "=", "3306", ")", ":", "body", "=", "{", "\"security_group_rule\"", ":", "{", "\"security_group_id\"", ":", "dbsecgroup_id", ",", "\"cidr\"", ":", "source_cidr", ",", "\"from_...
Creates a security group rule. :param str dbsecgroup_id: The ID of the security group in which this rule should be created. :param str source_cidr: The source IP address range from which access should be allowed. :param int port: The port number used by db clients to ...
[ "Creates", "a", "security", "group", "rule", "." ]
train
https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/providers/hpcloud/reddwarf.py#L65-L89
dusty-phillips/opterator
examples/cp.py
main
def main(filename1, filename2, recursive=False, backup=False, suffix='~', *other_filenames): '''An example copy script with some example parameters that might be used in a file or directory copy command. :param recursive: -r --recursive copy directories recursively :param backup: -b --...
python
def main(filename1, filename2, recursive=False, backup=False, suffix='~', *other_filenames): '''An example copy script with some example parameters that might be used in a file or directory copy command. :param recursive: -r --recursive copy directories recursively :param backup: -b --...
[ "def", "main", "(", "filename1", ",", "filename2", ",", "recursive", "=", "False", ",", "backup", "=", "False", ",", "suffix", "=", "'~'", ",", "*", "other_filenames", ")", ":", "filenames", "=", "[", "filename1", ",", "filename2", "]", "+", "list", "(...
An example copy script with some example parameters that might be used in a file or directory copy command. :param recursive: -r --recursive copy directories recursively :param backup: -b --backup backup any files you copy over :param suffix: -S --suffix override the usual backup suffix
[ "An", "example", "copy", "script", "with", "some", "example", "parameters", "that", "might", "be", "used", "in", "a", "file", "or", "directory", "copy", "command", "." ]
train
https://github.com/dusty-phillips/opterator/blob/84fe31f22c73dc0a3666ed82c179461b1799c257/examples/cp.py#L5-L23
emin63/eyap
eyap/core/github_comments.py
GitHubCommentGroup.parse_date
def parse_date(my_date): """Parse a date into canonical format of datetime.dateime. :param my_date: Either datetime.datetime or string in '%Y-%m-%dT%H:%M:%SZ' format. ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- :return: A datetime.datetime. ...
python
def parse_date(my_date): """Parse a date into canonical format of datetime.dateime. :param my_date: Either datetime.datetime or string in '%Y-%m-%dT%H:%M:%SZ' format. ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- :return: A datetime.datetime. ...
[ "def", "parse_date", "(", "my_date", ")", ":", "if", "isinstance", "(", "my_date", ",", "datetime", ".", "datetime", ")", ":", "result", "=", "my_date", "elif", "isinstance", "(", "my_date", ",", "str", ")", ":", "result", "=", "datetime", ".", "datetime...
Parse a date into canonical format of datetime.dateime. :param my_date: Either datetime.datetime or string in '%Y-%m-%dT%H:%M:%SZ' format. ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- :return: A datetime.datetime. ~-~-~-~-~-~-~-~-~-~-~-~-~-~-...
[ "Parse", "a", "date", "into", "canonical", "format", "of", "datetime", ".", "dateime", "." ]
train
https://github.com/emin63/eyap/blob/a610761973b478ca0e864e970be05ce29d5994a5/eyap/core/github_comments.py#L70-L94
emin63/eyap
eyap/core/github_comments.py
GitHubCommentGroup.get_thread_info
def get_thread_info(self, enforce_re=True, latest_date=None): """Return a json list with information about threads in the group. :param enforce_re=True: Whether to require titles to match regexp in self.topic_re. :param latest_date=None: Opti...
python
def get_thread_info(self, enforce_re=True, latest_date=None): """Return a json list with information about threads in the group. :param enforce_re=True: Whether to require titles to match regexp in self.topic_re. :param latest_date=None: Opti...
[ "def", "get_thread_info", "(", "self", ",", "enforce_re", "=", "True", ",", "latest_date", "=", "None", ")", ":", "result", "=", "[", "]", "my_re", "=", "re", ".", "compile", "(", "self", ".", "topic_re", ")", "url", "=", "'%s/issues?sort=updated'", "%",...
Return a json list with information about threads in the group. :param enforce_re=True: Whether to require titles to match regexp in self.topic_re. :param latest_date=None: Optional datetime.datetime for latest ...
[ "Return", "a", "json", "list", "with", "information", "about", "threads", "in", "the", "group", "." ]
train
https://github.com/emin63/eyap/blob/a610761973b478ca0e864e970be05ce29d5994a5/eyap/core/github_comments.py#L96-L147
emin63/eyap
eyap/core/github_comments.py
GitHubCommentGroup.export
def export(self, out_filename): """Export desired threads as a zipfile to out_filename. """ with zipfile.ZipFile(out_filename, 'w', zipfile.ZIP_DEFLATED) as arc: id_list = list(self.get_thread_info()) for num, my_info in enumerate(id_list): logging.info('W...
python
def export(self, out_filename): """Export desired threads as a zipfile to out_filename. """ with zipfile.ZipFile(out_filename, 'w', zipfile.ZIP_DEFLATED) as arc: id_list = list(self.get_thread_info()) for num, my_info in enumerate(id_list): logging.info('W...
[ "def", "export", "(", "self", ",", "out_filename", ")", ":", "with", "zipfile", ".", "ZipFile", "(", "out_filename", ",", "'w'", ",", "zipfile", ".", "ZIP_DEFLATED", ")", "as", "arc", ":", "id_list", "=", "list", "(", "self", ".", "get_thread_info", "(",...
Export desired threads as a zipfile to out_filename.
[ "Export", "desired", "threads", "as", "a", "zipfile", "to", "out_filename", "." ]
train
https://github.com/emin63/eyap/blob/a610761973b478ca0e864e970be05ce29d5994a5/eyap/core/github_comments.py#L149-L164
emin63/eyap
eyap/core/github_comments.py
GitHubCommentThread.sleep_if_necessary
def sleep_if_necessary(cls, user, token, endpoint='search', msg=''): """Sleep a little if hit github recently to honor rate limit. """ my_kw = {'auth': (user, token)} if user else {} info = requests.get('https://api.github.com/rate_limit', **my_kw) info_dict = info.json() ...
python
def sleep_if_necessary(cls, user, token, endpoint='search', msg=''): """Sleep a little if hit github recently to honor rate limit. """ my_kw = {'auth': (user, token)} if user else {} info = requests.get('https://api.github.com/rate_limit', **my_kw) info_dict = info.json() ...
[ "def", "sleep_if_necessary", "(", "cls", ",", "user", ",", "token", ",", "endpoint", "=", "'search'", ",", "msg", "=", "''", ")", ":", "my_kw", "=", "{", "'auth'", ":", "(", "user", ",", "token", ")", "}", "if", "user", "else", "{", "}", "info", ...
Sleep a little if hit github recently to honor rate limit.
[ "Sleep", "a", "little", "if", "hit", "github", "recently", "to", "honor", "rate", "limit", "." ]
train
https://github.com/emin63/eyap/blob/a610761973b478ca0e864e970be05ce29d5994a5/eyap/core/github_comments.py#L217-L236
emin63/eyap
eyap/core/github_comments.py
GitHubCommentThread.update_cache_key
def update_cache_key(cls, cache_key, item=None): """Get item in cache for cache_key and add item if item is not None. """ contents = cls.__thread_id_cache.get(cache_key, None) if item is not None: cls.__thread_id_cache[cache_key] = item return contents
python
def update_cache_key(cls, cache_key, item=None): """Get item in cache for cache_key and add item if item is not None. """ contents = cls.__thread_id_cache.get(cache_key, None) if item is not None: cls.__thread_id_cache[cache_key] = item return contents
[ "def", "update_cache_key", "(", "cls", ",", "cache_key", ",", "item", "=", "None", ")", ":", "contents", "=", "cls", ".", "__thread_id_cache", ".", "get", "(", "cache_key", ",", "None", ")", "if", "item", "is", "not", "None", ":", "cls", ".", "__thread...
Get item in cache for cache_key and add item if item is not None.
[ "Get", "item", "in", "cache", "for", "cache_key", "and", "add", "item", "if", "item", "is", "not", "None", "." ]
train
https://github.com/emin63/eyap/blob/a610761973b478ca0e864e970be05ce29d5994a5/eyap/core/github_comments.py#L239-L246
emin63/eyap
eyap/core/github_comments.py
GitHubCommentThread.lookup_thread_id
def lookup_thread_id(self): """Lookup thread id as required by CommentThread.lookup_thread_id. This implementation will query GitHub with the required parameters to try and find the topic for the owner, realm, topic, etc., specified in init. """ query_string = 'in:title...
python
def lookup_thread_id(self): """Lookup thread id as required by CommentThread.lookup_thread_id. This implementation will query GitHub with the required parameters to try and find the topic for the owner, realm, topic, etc., specified in init. """ query_string = 'in:title...
[ "def", "lookup_thread_id", "(", "self", ")", ":", "query_string", "=", "'in:title \"%s\" repo:%s/%s'", "%", "(", "self", ".", "topic", ",", "self", ".", "owner", ",", "self", ".", "realm", ")", "cache_key", "=", "(", "self", ".", "owner", ",", "self", "....
Lookup thread id as required by CommentThread.lookup_thread_id. This implementation will query GitHub with the required parameters to try and find the topic for the owner, realm, topic, etc., specified in init.
[ "Lookup", "thread", "id", "as", "required", "by", "CommentThread", ".", "lookup_thread_id", "." ]
train
https://github.com/emin63/eyap/blob/a610761973b478ca0e864e970be05ce29d5994a5/eyap/core/github_comments.py#L254-L300
emin63/eyap
eyap/core/github_comments.py
GitHubCommentThread.raw_search
def raw_search(cls, user, token, query, page=0): """Do a raw search for github issues. :arg user: Username to use in accessing github. :arg token: Token to use in accessing github. :arg query: String query to use in searching github. :arg page=0: Numbe...
python
def raw_search(cls, user, token, query, page=0): """Do a raw search for github issues. :arg user: Username to use in accessing github. :arg token: Token to use in accessing github. :arg query: String query to use in searching github. :arg page=0: Numbe...
[ "def", "raw_search", "(", "cls", ",", "user", ",", "token", ",", "query", ",", "page", "=", "0", ")", ":", "page", "=", "int", "(", "page", ")", "kwargs", "=", "{", "}", "if", "not", "user", "else", "{", "'auth'", ":", "(", "user", ",", "token"...
Do a raw search for github issues. :arg user: Username to use in accessing github. :arg token: Token to use in accessing github. :arg query: String query to use in searching github. :arg page=0: Number of pages to automatically paginate. ~-~-~-~-~-~-~...
[ "Do", "a", "raw", "search", "for", "github", "issues", "." ]
train
https://github.com/emin63/eyap/blob/a610761973b478ca0e864e970be05ce29d5994a5/eyap/core/github_comments.py#L303-L354
emin63/eyap
eyap/core/github_comments.py
GitHubCommentThread.raw_pull
def raw_pull(self, topic): """Do a raw pull of data for given topic down from github. :arg topic: String topic (i.e., issue title). ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- :returns: Result of request data from github API. ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~...
python
def raw_pull(self, topic): """Do a raw pull of data for given topic down from github. :arg topic: String topic (i.e., issue title). ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- :returns: Result of request data from github API. ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~...
[ "def", "raw_pull", "(", "self", ",", "topic", ")", ":", "assert", "topic", "is", "not", "None", ",", "'A topic of None is not allowed'", "kwargs", "=", "{", "}", "if", "not", "self", ".", "user", "else", "{", "'auth'", ":", "(", "self", ".", "user", ",...
Do a raw pull of data for given topic down from github. :arg topic: String topic (i.e., issue title). ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- :returns: Result of request data from github API. ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- PURPO...
[ "Do", "a", "raw", "pull", "of", "data", "for", "given", "topic", "down", "from", "github", "." ]
train
https://github.com/emin63/eyap/blob/a610761973b478ca0e864e970be05ce29d5994a5/eyap/core/github_comments.py#L356-L374
emin63/eyap
eyap/core/github_comments.py
GitHubCommentThread.lookup_comment_list
def lookup_comment_list(self): """Lookup list of comments for an issue. ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- :returns: The pair (ISSUE, COMMENTS) where ISSUE is a dict for the main issue and COMMENTS is a list of comments on the issue. ~-~-~-~-~-~...
python
def lookup_comment_list(self): """Lookup list of comments for an issue. ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- :returns: The pair (ISSUE, COMMENTS) where ISSUE is a dict for the main issue and COMMENTS is a list of comments on the issue. ~-~-~-~-~-~...
[ "def", "lookup_comment_list", "(", "self", ")", ":", "if", "self", ".", "thread_id", "is", "None", ":", "return", "None", ",", "None", "# Just pulling a single issue here so pagination shouldn't be problem", "my_req", "=", "self", ".", "raw_pull", "(", "self", ".", ...
Lookup list of comments for an issue. ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- :returns: The pair (ISSUE, COMMENTS) where ISSUE is a dict for the main issue and COMMENTS is a list of comments on the issue. ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~...
[ "Lookup", "list", "of", "comments", "for", "an", "issue", "." ]
train
https://github.com/emin63/eyap/blob/a610761973b478ca0e864e970be05ce29d5994a5/eyap/core/github_comments.py#L376-L417
emin63/eyap
eyap/core/github_comments.py
GitHubCommentThread.add_comment
def add_comment(self, body, allow_create=False, allow_hashes=True, summary=None, hash_create=False): """Implement as required by CommentThread.add_comment. :arg body: String/text of comment to add. :arg allow_create=False: Whether to automatically create a new thread ...
python
def add_comment(self, body, allow_create=False, allow_hashes=True, summary=None, hash_create=False): """Implement as required by CommentThread.add_comment. :arg body: String/text of comment to add. :arg allow_create=False: Whether to automatically create a new thread ...
[ "def", "add_comment", "(", "self", ",", "body", ",", "allow_create", "=", "False", ",", "allow_hashes", "=", "True", ",", "summary", "=", "None", ",", "hash_create", "=", "False", ")", ":", "if", "self", ".", "thread_id", "is", "None", ":", "self", "."...
Implement as required by CommentThread.add_comment. :arg body: String/text of comment to add. :arg allow_create=False: Whether to automatically create a new thread if a thread does not exist (usually by calling self.create_thread). ...
[ "Implement", "as", "required", "by", "CommentThread", ".", "add_comment", "." ]
train
https://github.com/emin63/eyap/blob/a610761973b478ca0e864e970be05ce29d5994a5/eyap/core/github_comments.py#L445-L504
emin63/eyap
eyap/core/github_comments.py
GitHubCommentThread.process_hashes
def process_hashes(self, body, allow_create=False): """Process any hashes mentioned and push them to related topics. :arg body: Body of the comment to check for hashes and push out. :arg allow_create=False: Whether to allow creating new topics from hash ta...
python
def process_hashes(self, body, allow_create=False): """Process any hashes mentioned and push them to related topics. :arg body: Body of the comment to check for hashes and push out. :arg allow_create=False: Whether to allow creating new topics from hash ta...
[ "def", "process_hashes", "(", "self", ",", "body", ",", "allow_create", "=", "False", ")", ":", "hash_re", "=", "re", ".", "compile", "(", "self", ".", "hashtag_re", ")", "hashes", "=", "hash_re", ".", "findall", "(", "body", ")", "done", "=", "{", "...
Process any hashes mentioned and push them to related topics. :arg body: Body of the comment to check for hashes and push out. :arg allow_create=False: Whether to allow creating new topics from hash tag mentions. ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-...
[ "Process", "any", "hashes", "mentioned", "and", "push", "them", "to", "related", "topics", "." ]
train
https://github.com/emin63/eyap/blob/a610761973b478ca0e864e970be05ce29d5994a5/eyap/core/github_comments.py#L506-L534
emin63/eyap
eyap/core/github_comments.py
GitHubCommentThread.upload_attachment
def upload_attachment(self, location, data): """Upload attachment as required by CommentThread class. See CommentThread.upload_attachment for details. """ self.validate_attachment_location(location) content = data.read() if hasattr(data, 'read') else data orig_content = ...
python
def upload_attachment(self, location, data): """Upload attachment as required by CommentThread class. See CommentThread.upload_attachment for details. """ self.validate_attachment_location(location) content = data.read() if hasattr(data, 'read') else data orig_content = ...
[ "def", "upload_attachment", "(", "self", ",", "location", ",", "data", ")", ":", "self", ".", "validate_attachment_location", "(", "location", ")", "content", "=", "data", ".", "read", "(", ")", "if", "hasattr", "(", "data", ",", "'read'", ")", "else", "...
Upload attachment as required by CommentThread class. See CommentThread.upload_attachment for details.
[ "Upload", "attachment", "as", "required", "by", "CommentThread", "class", "." ]
train
https://github.com/emin63/eyap/blob/a610761973b478ca0e864e970be05ce29d5994a5/eyap/core/github_comments.py#L547-L570
stevepeak/tornpsql
tornpsql/__init__.py
_Connection._reconnect
def _reconnect(self): """Closes the existing database connection and re-opens it.""" self.close() self._db = psycopg2.connect(**self._db_args) if self._search_path: self.execute('set search_path=%s;' % self._search_path) if self._timezone: self.execute("...
python
def _reconnect(self): """Closes the existing database connection and re-opens it.""" self.close() self._db = psycopg2.connect(**self._db_args) if self._search_path: self.execute('set search_path=%s;' % self._search_path) if self._timezone: self.execute("...
[ "def", "_reconnect", "(", "self", ")", ":", "self", ".", "close", "(", ")", "self", ".", "_db", "=", "psycopg2", ".", "connect", "(", "*", "*", "self", ".", "_db_args", ")", "if", "self", ".", "_search_path", ":", "self", ".", "execute", "(", "'set...
Closes the existing database connection and re-opens it.
[ "Closes", "the", "existing", "database", "connection", "and", "re", "-", "opens", "it", "." ]
train
https://github.com/stevepeak/tornpsql/blob/a109d0f95d6432d0e3b5eba1c9854357ba527f27/tornpsql/__init__.py#L134-L143
stevepeak/tornpsql
tornpsql/__init__.py
_Connection._reregister_types
def _reregister_types(self): """Registers existing types for a new connection""" for _type in self._register_types: psycopg2.extensions.register_type(psycopg2.extensions.new_type(*_type))
python
def _reregister_types(self): """Registers existing types for a new connection""" for _type in self._register_types: psycopg2.extensions.register_type(psycopg2.extensions.new_type(*_type))
[ "def", "_reregister_types", "(", "self", ")", ":", "for", "_type", "in", "self", ".", "_register_types", ":", "psycopg2", ".", "extensions", ".", "register_type", "(", "psycopg2", ".", "extensions", ".", "new_type", "(", "*", "_type", ")", ")" ]
Registers existing types for a new connection
[ "Registers", "existing", "types", "for", "a", "new", "connection" ]
train
https://github.com/stevepeak/tornpsql/blob/a109d0f95d6432d0e3b5eba1c9854357ba527f27/tornpsql/__init__.py#L145-L148
stevepeak/tornpsql
tornpsql/__init__.py
_Connection.register_type
def register_type(self, oids, name, casting): """Callback to register data types when reconnect """ assert type(oids) is tuple assert isinstance(name, basestring) assert hasattr(casting, '__call__') self._register_types.append((oids, name, casting)) psycopg2.exten...
python
def register_type(self, oids, name, casting): """Callback to register data types when reconnect """ assert type(oids) is tuple assert isinstance(name, basestring) assert hasattr(casting, '__call__') self._register_types.append((oids, name, casting)) psycopg2.exten...
[ "def", "register_type", "(", "self", ",", "oids", ",", "name", ",", "casting", ")", ":", "assert", "type", "(", "oids", ")", "is", "tuple", "assert", "isinstance", "(", "name", ",", "basestring", ")", "assert", "hasattr", "(", "casting", ",", "'__call__'...
Callback to register data types when reconnect
[ "Callback", "to", "register", "data", "types", "when", "reconnect" ]
train
https://github.com/stevepeak/tornpsql/blob/a109d0f95d6432d0e3b5eba1c9854357ba527f27/tornpsql/__init__.py#L158-L165
stevepeak/tornpsql
tornpsql/__init__.py
_Connection.mogrify
def mogrify(self, query, *parameters, **kwargs): """From http://initd.org/psycopg/docs/cursor.html?highlight=mogrify#cursor.mogrify Return a query string after arguments binding. The string returned is exactly the one that would be sent to the database running the execute() method or sim...
python
def mogrify(self, query, *parameters, **kwargs): """From http://initd.org/psycopg/docs/cursor.html?highlight=mogrify#cursor.mogrify Return a query string after arguments binding. The string returned is exactly the one that would be sent to the database running the execute() method or sim...
[ "def", "mogrify", "(", "self", ",", "query", ",", "*", "parameters", ",", "*", "*", "kwargs", ")", ":", "cursor", "=", "self", ".", "_cursor", "(", ")", "try", ":", "if", "kwargs", ":", "res", "=", "cursor", ".", "mogrify", "(", "query", "%", "di...
From http://initd.org/psycopg/docs/cursor.html?highlight=mogrify#cursor.mogrify Return a query string after arguments binding. The string returned is exactly the one that would be sent to the database running the execute() method or similar.
[ "From", "http", ":", "//", "initd", ".", "org", "/", "psycopg", "/", "docs", "/", "cursor", ".", "html?highlight", "=", "mogrify#cursor", ".", "mogrify", "Return", "a", "query", "string", "after", "arguments", "binding", ".", "The", "string", "returned", "...
train
https://github.com/stevepeak/tornpsql/blob/a109d0f95d6432d0e3b5eba1c9854357ba527f27/tornpsql/__init__.py#L167-L185
stevepeak/tornpsql
tornpsql/__init__.py
_Connection.query
def query(self, query, *parameters, **kwargs): """Returns a row list for the given query and parameters.""" cursor = self._cursor() try: self._execute(cursor, query, parameters or None, kwargs) if cursor.description: column_names = [column.name for column ...
python
def query(self, query, *parameters, **kwargs): """Returns a row list for the given query and parameters.""" cursor = self._cursor() try: self._execute(cursor, query, parameters or None, kwargs) if cursor.description: column_names = [column.name for column ...
[ "def", "query", "(", "self", ",", "query", ",", "*", "parameters", ",", "*", "*", "kwargs", ")", ":", "cursor", "=", "self", ".", "_cursor", "(", ")", "try", ":", "self", ".", "_execute", "(", "cursor", ",", "query", ",", "parameters", "or", "None"...
Returns a row list for the given query and parameters.
[ "Returns", "a", "row", "list", "for", "the", "given", "query", "and", "parameters", "." ]
train
https://github.com/stevepeak/tornpsql/blob/a109d0f95d6432d0e3b5eba1c9854357ba527f27/tornpsql/__init__.py#L187-L199
stevepeak/tornpsql
tornpsql/__init__.py
_Connection.iter
def iter(self, query, *parameters, **kwargs): """Returns a generator for records from the query.""" cursor = self._cursor() try: self._execute(cursor, query, parameters or None, kwargs) if cursor.description: column_names = [column.name for column in curso...
python
def iter(self, query, *parameters, **kwargs): """Returns a generator for records from the query.""" cursor = self._cursor() try: self._execute(cursor, query, parameters or None, kwargs) if cursor.description: column_names = [column.name for column in curso...
[ "def", "iter", "(", "self", ",", "query", ",", "*", "parameters", ",", "*", "*", "kwargs", ")", ":", "cursor", "=", "self", ".", "_cursor", "(", ")", "try", ":", "self", ".", "_execute", "(", "cursor", ",", "query", ",", "parameters", "or", "None",...
Returns a generator for records from the query.
[ "Returns", "a", "generator", "for", "records", "from", "the", "query", "." ]
train
https://github.com/stevepeak/tornpsql/blob/a109d0f95d6432d0e3b5eba1c9854357ba527f27/tornpsql/__init__.py#L201-L217
stevepeak/tornpsql
tornpsql/__init__.py
_Connection.execute
def execute(self, query, *parameters, **kwargs): """Same as query, but do not process results. Always returns `None`.""" cursor = self._cursor() try: self._execute(cursor, query, parameters, kwargs) except: raise finally: cursor.close()
python
def execute(self, query, *parameters, **kwargs): """Same as query, but do not process results. Always returns `None`.""" cursor = self._cursor() try: self._execute(cursor, query, parameters, kwargs) except: raise finally: cursor.close()
[ "def", "execute", "(", "self", ",", "query", ",", "*", "parameters", ",", "*", "*", "kwargs", ")", ":", "cursor", "=", "self", ".", "_cursor", "(", ")", "try", ":", "self", ".", "_execute", "(", "cursor", ",", "query", ",", "parameters", ",", "kwar...
Same as query, but do not process results. Always returns `None`.
[ "Same", "as", "query", "but", "do", "not", "process", "results", ".", "Always", "returns", "None", "." ]
train
https://github.com/stevepeak/tornpsql/blob/a109d0f95d6432d0e3b5eba1c9854357ba527f27/tornpsql/__init__.py#L219-L229
stevepeak/tornpsql
tornpsql/__init__.py
_Connection.get
def get(self, query, *parameters, **kwargs): """Returns the first row returned for the given query.""" rows = self.query(query, *parameters, **kwargs) if not rows: return None elif len(rows) > 1: raise ValueError('Multiple rows returned for get() query') e...
python
def get(self, query, *parameters, **kwargs): """Returns the first row returned for the given query.""" rows = self.query(query, *parameters, **kwargs) if not rows: return None elif len(rows) > 1: raise ValueError('Multiple rows returned for get() query') e...
[ "def", "get", "(", "self", ",", "query", ",", "*", "parameters", ",", "*", "*", "kwargs", ")", ":", "rows", "=", "self", ".", "query", "(", "query", ",", "*", "parameters", ",", "*", "*", "kwargs", ")", "if", "not", "rows", ":", "return", "None",...
Returns the first row returned for the given query.
[ "Returns", "the", "first", "row", "returned", "for", "the", "given", "query", "." ]
train
https://github.com/stevepeak/tornpsql/blob/a109d0f95d6432d0e3b5eba1c9854357ba527f27/tornpsql/__init__.py#L231-L239
stevepeak/tornpsql
tornpsql/__init__.py
_Connection.executemany
def executemany(self, query, *parameters): """Executes the given query against all the given param sequences. """ cursor = self._cursor() try: self._executemany(cursor, query, parameters) if cursor.description: column_names = [column.name for colum...
python
def executemany(self, query, *parameters): """Executes the given query against all the given param sequences. """ cursor = self._cursor() try: self._executemany(cursor, query, parameters) if cursor.description: column_names = [column.name for colum...
[ "def", "executemany", "(", "self", ",", "query", ",", "*", "parameters", ")", ":", "cursor", "=", "self", ".", "_cursor", "(", ")", "try", ":", "self", ".", "_executemany", "(", "cursor", ",", "query", ",", "parameters", ")", "if", "cursor", ".", "de...
Executes the given query against all the given param sequences.
[ "Executes", "the", "given", "query", "against", "all", "the", "given", "param", "sequences", "." ]
train
https://github.com/stevepeak/tornpsql/blob/a109d0f95d6432d0e3b5eba1c9854357ba527f27/tornpsql/__init__.py#L241-L255
stevepeak/tornpsql
tornpsql/__init__.py
_Connection._executemany
def _executemany(self, cursor, query, parameters): """The function is mostly useful for commands that update the database: any result set returned by the query is discarded.""" try: self._log(query) cursor.executemany(query, parameters) except OperationalError ...
python
def _executemany(self, cursor, query, parameters): """The function is mostly useful for commands that update the database: any result set returned by the query is discarded.""" try: self._log(query) cursor.executemany(query, parameters) except OperationalError ...
[ "def", "_executemany", "(", "self", ",", "cursor", ",", "query", ",", "parameters", ")", ":", "try", ":", "self", ".", "_log", "(", "query", ")", "cursor", ".", "executemany", "(", "query", ",", "parameters", ")", "except", "OperationalError", "as", "e",...
The function is mostly useful for commands that update the database: any result set returned by the query is discarded.
[ "The", "function", "is", "mostly", "useful", "for", "commands", "that", "update", "the", "database", ":", "any", "result", "set", "returned", "by", "the", "query", "is", "discarded", "." ]
train
https://github.com/stevepeak/tornpsql/blob/a109d0f95d6432d0e3b5eba1c9854357ba527f27/tornpsql/__init__.py#L291-L300
stevepeak/tornpsql
tornpsql/__init__.py
_Connection.notices
def notices(self): """pops and returns all notices http://initd.org/psycopg/docs/connection.html#connection.notices """ return [self._db.notices.pop()[8:].strip() for x in range(len(self._db.notices))]
python
def notices(self): """pops and returns all notices http://initd.org/psycopg/docs/connection.html#connection.notices """ return [self._db.notices.pop()[8:].strip() for x in range(len(self._db.notices))]
[ "def", "notices", "(", "self", ")", ":", "return", "[", "self", ".", "_db", ".", "notices", ".", "pop", "(", ")", "[", "8", ":", "]", ".", "strip", "(", ")", "for", "x", "in", "range", "(", "len", "(", "self", ".", "_db", ".", "notices", ")",...
pops and returns all notices http://initd.org/psycopg/docs/connection.html#connection.notices
[ "pops", "and", "returns", "all", "notices", "http", ":", "//", "initd", ".", "org", "/", "psycopg", "/", "docs", "/", "connection", ".", "html#connection", ".", "notices" ]
train
https://github.com/stevepeak/tornpsql/blob/a109d0f95d6432d0e3b5eba1c9854357ba527f27/tornpsql/__init__.py#L317-L321
MacHu-GWU/pyknackhq-project
pyknackhq/zzz_manual_install.py
install
def install(): """Install your package to all Python version you have installed on Windows. """ import os, shutil _ROOT = os.getcwd() _PACKAGE_NAME = os.path.basename(_ROOT) print("Installing [%s] to all python version..." % _PACKAGE_NAME) # find all Python release installed on thi...
python
def install(): """Install your package to all Python version you have installed on Windows. """ import os, shutil _ROOT = os.getcwd() _PACKAGE_NAME = os.path.basename(_ROOT) print("Installing [%s] to all python version..." % _PACKAGE_NAME) # find all Python release installed on thi...
[ "def", "install", "(", ")", ":", "import", "os", ",", "shutil", "_ROOT", "=", "os", ".", "getcwd", "(", ")", "_PACKAGE_NAME", "=", "os", ".", "path", ".", "basename", "(", "_ROOT", ")", "print", "(", "\"Installing [%s] to all python version...\"", "%", "_P...
Install your package to all Python version you have installed on Windows.
[ "Install", "your", "package", "to", "all", "Python", "version", "you", "have", "installed", "on", "Windows", "." ]
train
https://github.com/MacHu-GWU/pyknackhq-project/blob/dd937f24d7b0a351ba3818eb746c31b29a8cc341/pyknackhq/zzz_manual_install.py#L100-L141
romaryd/python-jsonrepo
jsonrepo/record.py
namedtuple_asdict
def namedtuple_asdict(obj): """ Serializing a nested namedtuple into a Python dict """ if obj is None: return obj if hasattr(obj, "_asdict"): # detect namedtuple return OrderedDict(zip(obj._fields, (namedtuple_asdict(item) for item in obj...
python
def namedtuple_asdict(obj): """ Serializing a nested namedtuple into a Python dict """ if obj is None: return obj if hasattr(obj, "_asdict"): # detect namedtuple return OrderedDict(zip(obj._fields, (namedtuple_asdict(item) for item in obj...
[ "def", "namedtuple_asdict", "(", "obj", ")", ":", "if", "obj", "is", "None", ":", "return", "obj", "if", "hasattr", "(", "obj", ",", "\"_asdict\"", ")", ":", "# detect namedtuple", "return", "OrderedDict", "(", "zip", "(", "obj", ".", "_fields", ",", "("...
Serializing a nested namedtuple into a Python dict
[ "Serializing", "a", "nested", "namedtuple", "into", "a", "Python", "dict" ]
train
https://github.com/romaryd/python-jsonrepo/blob/08a9c039a5bd21e93e9a6d1bce77d43e6e10b57d/jsonrepo/record.py#L11-L28
romaryd/python-jsonrepo
jsonrepo/record.py
DictRecord.from_json
def from_json(cls, json_dump): """ How to get a context from a json dump """ context = cls() if json_dump is None: return None ctxt = json.loads(json_dump) for k in ctxt: context[k] = ctxt[k] return context
python
def from_json(cls, json_dump): """ How to get a context from a json dump """ context = cls() if json_dump is None: return None ctxt = json.loads(json_dump) for k in ctxt: context[k] = ctxt[k] return context
[ "def", "from_json", "(", "cls", ",", "json_dump", ")", ":", "context", "=", "cls", "(", ")", "if", "json_dump", "is", "None", ":", "return", "None", "ctxt", "=", "json", ".", "loads", "(", "json_dump", ")", "for", "k", "in", "ctxt", ":", "context", ...
How to get a context from a json dump
[ "How", "to", "get", "a", "context", "from", "a", "json", "dump" ]
train
https://github.com/romaryd/python-jsonrepo/blob/08a9c039a5bd21e93e9a6d1bce77d43e6e10b57d/jsonrepo/record.py#L54-L64
Basic-Components/msgpack-rpc-protocol
python/pymprpc/server/server.py
BaseServer.clean
def clean(self): """服务结束后清理服务器.""" # 服务结束阶段 if self.running is False: return False logger.info("Stopping worker [%s]", self.pid) # 关闭server self.rpc_server.close() self.loop.run_until_complete(self.rpc_server.wait_closed()) # 关闭连接 # 完成所...
python
def clean(self): """服务结束后清理服务器.""" # 服务结束阶段 if self.running is False: return False logger.info("Stopping worker [%s]", self.pid) # 关闭server self.rpc_server.close() self.loop.run_until_complete(self.rpc_server.wait_closed()) # 关闭连接 # 完成所...
[ "def", "clean", "(", "self", ")", ":", "# 服务结束阶段", "if", "self", ".", "running", "is", "False", ":", "return", "False", "logger", ".", "info", "(", "\"Stopping worker [%s]\"", ",", "self", ".", "pid", ")", "# 关闭server", "self", ".", "rpc_server", ".", "c...
服务结束后清理服务器.
[ "服务结束后清理服务器", "." ]
train
https://github.com/Basic-Components/msgpack-rpc-protocol/blob/7983ace5d5cfd7214df6803f9b1de458df5fe3b1/python/pymprpc/server/server.py#L138-L169
Basic-Components/msgpack-rpc-protocol
python/pymprpc/server/server.py
BaseServer.run_forever
def run_forever(self): """执行服务器.""" server_coroutine = self.loop.create_server( self._protocol, self.addr[0], self.addr[1], ssl=self.ssl, backlog=self.backlog ) try: self.rpc_server = self.loop.run_until_complete(ser...
python
def run_forever(self): """执行服务器.""" server_coroutine = self.loop.create_server( self._protocol, self.addr[0], self.addr[1], ssl=self.ssl, backlog=self.backlog ) try: self.rpc_server = self.loop.run_until_complete(ser...
[ "def", "run_forever", "(", "self", ")", ":", "server_coroutine", "=", "self", ".", "loop", ".", "create_server", "(", "self", ".", "_protocol", ",", "self", ".", "addr", "[", "0", "]", ",", "self", ".", "addr", "[", "1", "]", ",", "ssl", "=", "self...
执行服务器.
[ "执行服务器", "." ]
train
https://github.com/Basic-Components/msgpack-rpc-protocol/blob/7983ace5d5cfd7214df6803f9b1de458df5fe3b1/python/pymprpc/server/server.py#L171-L208
Basic-Components/msgpack-rpc-protocol
python/pymprpc/server/server.py
BaseServer.register_introspection_functions
def register_introspection_functions(self)->None: """注册自省函数到函数字典.""" self.funcs.update({ 'system.listMethods': self.system_listMethods, 'system.methodSignature': self.system_methodSignature, 'system.methodHelp': self.system_methodHelp, 'system.lenConnectio...
python
def register_introspection_functions(self)->None: """注册自省函数到函数字典.""" self.funcs.update({ 'system.listMethods': self.system_listMethods, 'system.methodSignature': self.system_methodSignature, 'system.methodHelp': self.system_methodHelp, 'system.lenConnectio...
[ "def", "register_introspection_functions", "(", "self", ")", "->", "None", ":", "self", ".", "funcs", ".", "update", "(", "{", "'system.listMethods'", ":", "self", ".", "system_listMethods", ",", "'system.methodSignature'", ":", "self", ".", "system_methodSignature"...
注册自省函数到函数字典.
[ "注册自省函数到函数字典", "." ]
train
https://github.com/Basic-Components/msgpack-rpc-protocol/blob/7983ace5d5cfd7214df6803f9b1de458df5fe3b1/python/pymprpc/server/server.py#L217-L225
Basic-Components/msgpack-rpc-protocol
python/pymprpc/server/server.py
BaseServer.system_lenUndoneTasks
def system_lenUndoneTasks(self)->int: """获取未完成的任务数目.""" return len([i for i in MPProtocolServer.TASKS if not i.done()])
python
def system_lenUndoneTasks(self)->int: """获取未完成的任务数目.""" return len([i for i in MPProtocolServer.TASKS if not i.done()])
[ "def", "system_lenUndoneTasks", "(", "self", ")", "->", "int", ":", "return", "len", "(", "[", "i", "for", "i", "in", "MPProtocolServer", ".", "TASKS", "if", "not", "i", ".", "done", "(", ")", "]", ")" ]
获取未完成的任务数目.
[ "获取未完成的任务数目", "." ]
train
https://github.com/Basic-Components/msgpack-rpc-protocol/blob/7983ace5d5cfd7214df6803f9b1de458df5fe3b1/python/pymprpc/server/server.py#L231-L233
Basic-Components/msgpack-rpc-protocol
python/pymprpc/server/server.py
BaseServer.system_methodSignature
def system_methodSignature(self, method_name: str)->str: """获取函数的签名. system.methodSignature('add') => [double, int, int] Parameters: method_name (str): - 要查看的函数名 Returns: (str): - 签名文本 """ method = None if method_name in self.funcs: ...
python
def system_methodSignature(self, method_name: str)->str: """获取函数的签名. system.methodSignature('add') => [double, int, int] Parameters: method_name (str): - 要查看的函数名 Returns: (str): - 签名文本 """ method = None if method_name in self.funcs: ...
[ "def", "system_methodSignature", "(", "self", ",", "method_name", ":", "str", ")", "->", "str", ":", "method", "=", "None", "if", "method_name", "in", "self", ".", "funcs", ":", "method", "=", "self", ".", "funcs", "[", "method_name", "]", "elif", "self"...
获取函数的签名. system.methodSignature('add') => [double, int, int] Parameters: method_name (str): - 要查看的函数名 Returns: (str): - 签名文本
[ "获取函数的签名", "." ]
train
https://github.com/Basic-Components/msgpack-rpc-protocol/blob/7983ace5d5cfd7214df6803f9b1de458df5fe3b1/python/pymprpc/server/server.py#L252-L279
Basic-Components/msgpack-rpc-protocol
python/pymprpc/server/server.py
BaseServer.system_methodHelp
def system_methodHelp(self, method_name: str)->str: """将docstring返回. system.methodHelp('add') => "Adds two integers together" Return: (str): - 函数的帮助文本 """ method = None if method_name in self.funcs: method = self.funcs[method_name] elif ...
python
def system_methodHelp(self, method_name: str)->str: """将docstring返回. system.methodHelp('add') => "Adds two integers together" Return: (str): - 函数的帮助文本 """ method = None if method_name in self.funcs: method = self.funcs[method_name] elif ...
[ "def", "system_methodHelp", "(", "self", ",", "method_name", ":", "str", ")", "->", "str", ":", "method", "=", "None", "if", "method_name", "in", "self", ".", "funcs", ":", "method", "=", "self", ".", "funcs", "[", "method_name", "]", "elif", "self", "...
将docstring返回. system.methodHelp('add') => "Adds two integers together" Return: (str): - 函数的帮助文本
[ "将docstring返回", "." ]
train
https://github.com/Basic-Components/msgpack-rpc-protocol/blob/7983ace5d5cfd7214df6803f9b1de458df5fe3b1/python/pymprpc/server/server.py#L281-L305
Basic-Components/msgpack-rpc-protocol
python/pymprpc/server/server.py
BaseServer.register_instance
def register_instance(self, instance: Any, allow_dotted_names: bool=False): """注册一个实例用于执行,注意只能注册一个. Parameters: instance (Any): - 将一个类的实例注册到rpc allow_dotted_names (bool): 是否允许带`.`号的名字 """ if self.instance: raise RuntimeError("can only register one in...
python
def register_instance(self, instance: Any, allow_dotted_names: bool=False): """注册一个实例用于执行,注意只能注册一个. Parameters: instance (Any): - 将一个类的实例注册到rpc allow_dotted_names (bool): 是否允许带`.`号的名字 """ if self.instance: raise RuntimeError("can only register one in...
[ "def", "register_instance", "(", "self", ",", "instance", ":", "Any", ",", "allow_dotted_names", ":", "bool", "=", "False", ")", ":", "if", "self", ".", "instance", ":", "raise", "RuntimeError", "(", "\"can only register one instance\"", ")", "self", ".", "ins...
注册一个实例用于执行,注意只能注册一个. Parameters: instance (Any): - 将一个类的实例注册到rpc allow_dotted_names (bool): 是否允许带`.`号的名字
[ "注册一个实例用于执行", "注意只能注册一个", "." ]
train
https://github.com/Basic-Components/msgpack-rpc-protocol/blob/7983ace5d5cfd7214df6803f9b1de458df5fe3b1/python/pymprpc/server/server.py#L309-L321
Basic-Components/msgpack-rpc-protocol
python/pymprpc/server/server.py
BaseServer.register_function
def register_function(self, name: Optional[str]=None): """注册函数. Parameters: name (Optional[str]): - 将函数注册到的名字,如果为None,name就用其原来的名字 """ def wrap(function: Callable)->Any: nonlocal name if name is None: name = function.__name__ ...
python
def register_function(self, name: Optional[str]=None): """注册函数. Parameters: name (Optional[str]): - 将函数注册到的名字,如果为None,name就用其原来的名字 """ def wrap(function: Callable)->Any: nonlocal name if name is None: name = function.__name__ ...
[ "def", "register_function", "(", "self", ",", "name", ":", "Optional", "[", "str", "]", "=", "None", ")", ":", "def", "wrap", "(", "function", ":", "Callable", ")", "->", "Any", ":", "nonlocal", "name", "if", "name", "is", "None", ":", "name", "=", ...
注册函数. Parameters: name (Optional[str]): - 将函数注册到的名字,如果为None,name就用其原来的名字
[ "注册函数", "." ]
train
https://github.com/Basic-Components/msgpack-rpc-protocol/blob/7983ace5d5cfd7214df6803f9b1de458df5fe3b1/python/pymprpc/server/server.py#L323-L336
Basic-Components/msgpack-rpc-protocol
python/pymprpc/server/server.py
BaseServer.set_executor
def set_executor(self, executor: futures.Executor): """设置计算密集型任务的执行器. Parameters: executor (futures.Executor): - 函数调用的执行器 """ self.loop.set_default_executor(executor) self._func_executor = executor return True
python
def set_executor(self, executor: futures.Executor): """设置计算密集型任务的执行器. Parameters: executor (futures.Executor): - 函数调用的执行器 """ self.loop.set_default_executor(executor) self._func_executor = executor return True
[ "def", "set_executor", "(", "self", ",", "executor", ":", "futures", ".", "Executor", ")", ":", "self", ".", "loop", ".", "set_default_executor", "(", "executor", ")", "self", ".", "_func_executor", "=", "executor", "return", "True" ]
设置计算密集型任务的执行器. Parameters: executor (futures.Executor): - 函数调用的执行器
[ "设置计算密集型任务的执行器", "." ]
train
https://github.com/Basic-Components/msgpack-rpc-protocol/blob/7983ace5d5cfd7214df6803f9b1de458df5fe3b1/python/pymprpc/server/server.py#L338-L347
Basic-Components/msgpack-rpc-protocol
python/pymprpc/server/server.py
BaseServer.apply
async def apply(self, ID: str, method: str, *args: Any, **kwargs: Any): """执行注册的函数或者实例的方法. 如果函数或者方法是协程则执行协程,如果是函数则使用执行器执行,默认使用的是多进程. Parameters: ID (str): 任务的ID method (str): 任务调用的函数名 args (Any): 位置参数 kwargs (Any): 关键字参数 Raise: ...
python
async def apply(self, ID: str, method: str, *args: Any, **kwargs: Any): """执行注册的函数或者实例的方法. 如果函数或者方法是协程则执行协程,如果是函数则使用执行器执行,默认使用的是多进程. Parameters: ID (str): 任务的ID method (str): 任务调用的函数名 args (Any): 位置参数 kwargs (Any): 关键字参数 Raise: ...
[ "async", "def", "apply", "(", "self", ",", "ID", ":", "str", ",", "method", ":", "str", ",", "*", "args", ":", "Any", ",", "*", "*", "kwargs", ":", "Any", ")", ":", "func", "=", "None", "try", ":", "# check to see if a matching function has been register...
执行注册的函数或者实例的方法. 如果函数或者方法是协程则执行协程,如果是函数则使用执行器执行,默认使用的是多进程. Parameters: ID (str): 任务的ID method (str): 任务调用的函数名 args (Any): 位置参数 kwargs (Any): 关键字参数 Raise: (RPCRuntimeError): - 当执行调用后抛出了异常,那就算做RPC运行时异常 Return: (Any)...
[ "执行注册的函数或者实例的方法", "." ]
train
https://github.com/Basic-Components/msgpack-rpc-protocol/blob/7983ace5d5cfd7214df6803f9b1de458df5fe3b1/python/pymprpc/server/server.py#L349-L434
klmitch/tendril
tendril/manager.py
TendrilManager.get_manager
def get_manager(cls, proto, endpoint=None): """ Find a manager matching the given protocol and endpoint. If no matching manager currently exists, creates a new one. (Manager classes are looked up using the ``tendril.manager`` entrypoint, and the name of the entrypoint correspond...
python
def get_manager(cls, proto, endpoint=None): """ Find a manager matching the given protocol and endpoint. If no matching manager currently exists, creates a new one. (Manager classes are looked up using the ``tendril.manager`` entrypoint, and the name of the entrypoint correspond...
[ "def", "get_manager", "(", "cls", ",", "proto", ",", "endpoint", "=", "None", ")", ":", "# First, normalize the proto and endpoint", "proto", "=", "proto", ".", "lower", "(", ")", "endpoint", "=", "endpoint", "or", "(", "''", ",", "0", ")", "# See if the man...
Find a manager matching the given protocol and endpoint. If no matching manager currently exists, creates a new one. (Manager classes are looked up using the ``tendril.manager`` entrypoint, and the name of the entrypoint corresponds to the ``proto``. This method makes no guarantees abo...
[ "Find", "a", "manager", "matching", "the", "given", "protocol", "and", "endpoint", ".", "If", "no", "matching", "manager", "currently", "exists", "creates", "a", "new", "one", ".", "(", "Manager", "classes", "are", "looked", "up", "using", "the", "tendril", ...
train
https://github.com/klmitch/tendril/blob/207102c83e88f8f1fa7ba605ef0aab2ae9078b36/tendril/manager.py#L52-L96
klmitch/tendril
tendril/manager.py
TendrilManager.find_tendril
def find_tendril(cls, proto, addr): """ Finds the tendril corresponding to the protocol and address tuple. Returns the Tendril object, or raises KeyError if the tendril is not tracked. The address tuple is the tuple of the local address and the remote address for the te...
python
def find_tendril(cls, proto, addr): """ Finds the tendril corresponding to the protocol and address tuple. Returns the Tendril object, or raises KeyError if the tendril is not tracked. The address tuple is the tuple of the local address and the remote address for the te...
[ "def", "find_tendril", "(", "cls", ",", "proto", ",", "addr", ")", ":", "# First, normalize the proto", "proto", "=", "proto", ".", "lower", "(", ")", "# Now, find and return the tendril", "return", "cls", ".", "_tendrils", "[", "proto", "]", "[", "addr", "]" ...
Finds the tendril corresponding to the protocol and address tuple. Returns the Tendril object, or raises KeyError if the tendril is not tracked. The address tuple is the tuple of the local address and the remote address for the tendril.
[ "Finds", "the", "tendril", "corresponding", "to", "the", "protocol", "and", "address", "tuple", ".", "Returns", "the", "Tendril", "object", "or", "raises", "KeyError", "if", "the", "tendril", "is", "not", "tracked", "." ]
train
https://github.com/klmitch/tendril/blob/207102c83e88f8f1fa7ba605ef0aab2ae9078b36/tendril/manager.py#L99-L113
klmitch/tendril
tendril/manager.py
TendrilManager._track_tendril
def _track_tendril(self, tendril): """ Adds the tendril to the set of tracked tendrils. """ self.tendrils[tendril._tendril_key] = tendril # Also add to _tendrils self._tendrils.setdefault(tendril.proto, weakref.WeakValueDictionary()) self._tendrils[tendril.proto...
python
def _track_tendril(self, tendril): """ Adds the tendril to the set of tracked tendrils. """ self.tendrils[tendril._tendril_key] = tendril # Also add to _tendrils self._tendrils.setdefault(tendril.proto, weakref.WeakValueDictionary()) self._tendrils[tendril.proto...
[ "def", "_track_tendril", "(", "self", ",", "tendril", ")", ":", "self", ".", "tendrils", "[", "tendril", ".", "_tendril_key", "]", "=", "tendril", "# Also add to _tendrils", "self", ".", "_tendrils", ".", "setdefault", "(", "tendril", ".", "proto", ",", "wea...
Adds the tendril to the set of tracked tendrils.
[ "Adds", "the", "tendril", "to", "the", "set", "of", "tracked", "tendrils", "." ]
train
https://github.com/klmitch/tendril/blob/207102c83e88f8f1fa7ba605ef0aab2ae9078b36/tendril/manager.py#L173-L182
klmitch/tendril
tendril/manager.py
TendrilManager._untrack_tendril
def _untrack_tendril(self, tendril): """ Removes the tendril from the set of tracked tendrils. """ try: del self.tendrils[tendril._tendril_key] except KeyError: pass # Also remove from _tendrils try: del self._tendrils[tendril...
python
def _untrack_tendril(self, tendril): """ Removes the tendril from the set of tracked tendrils. """ try: del self.tendrils[tendril._tendril_key] except KeyError: pass # Also remove from _tendrils try: del self._tendrils[tendril...
[ "def", "_untrack_tendril", "(", "self", ",", "tendril", ")", ":", "try", ":", "del", "self", ".", "tendrils", "[", "tendril", ".", "_tendril_key", "]", "except", "KeyError", ":", "pass", "# Also remove from _tendrils", "try", ":", "del", "self", ".", "_tendr...
Removes the tendril from the set of tracked tendrils.
[ "Removes", "the", "tendril", "from", "the", "set", "of", "tracked", "tendrils", "." ]
train
https://github.com/klmitch/tendril/blob/207102c83e88f8f1fa7ba605ef0aab2ae9078b36/tendril/manager.py#L184-L198
klmitch/tendril
tendril/manager.py
TendrilManager.start
def start(self, acceptor=None, wrapper=None): """ Starts the TendrilManager. :param acceptor: If given, specifies a callable that will be called with each newly received Tendril; that callable is responsible for initial ...
python
def start(self, acceptor=None, wrapper=None): """ Starts the TendrilManager. :param acceptor: If given, specifies a callable that will be called with each newly received Tendril; that callable is responsible for initial ...
[ "def", "start", "(", "self", ",", "acceptor", "=", "None", ",", "wrapper", "=", "None", ")", ":", "# Don't allow a double-start", "if", "self", ".", "running", ":", "raise", "ValueError", "(", "\"TendrilManager already running\"", ")", "# Look out for conflicts", ...
Starts the TendrilManager. :param acceptor: If given, specifies a callable that will be called with each newly received Tendril; that callable is responsible for initial acceptance of the connection and for setting ...
[ "Starts", "the", "TendrilManager", "." ]
train
https://github.com/klmitch/tendril/blob/207102c83e88f8f1fa7ba605ef0aab2ae9078b36/tendril/manager.py#L200-L243
klmitch/tendril
tendril/manager.py
TendrilManager.stop
def stop(self, *args): """ Stops the TendrilManager. Requires cooperation from the listener implementation, which must watch the ``running`` attribute and ensure that it stops accepting connections should that attribute become False. Note that some tendril managers will...
python
def stop(self, *args): """ Stops the TendrilManager. Requires cooperation from the listener implementation, which must watch the ``running`` attribute and ensure that it stops accepting connections should that attribute become False. Note that some tendril managers will...
[ "def", "stop", "(", "self", ",", "*", "args", ")", ":", "# Remove ourself from the dictionary of running managers", "try", ":", "del", "self", ".", "_running_managers", "[", "self", ".", "_manager_key", "]", "except", "KeyError", ":", "pass", "self", ".", "runni...
Stops the TendrilManager. Requires cooperation from the listener implementation, which must watch the ``running`` attribute and ensure that it stops accepting connections should that attribute become False. Note that some tendril managers will not exit from the listening thread until a...
[ "Stops", "the", "TendrilManager", ".", "Requires", "cooperation", "from", "the", "listener", "implementation", "which", "must", "watch", "the", "running", "attribute", "and", "ensure", "that", "it", "stops", "accepting", "connections", "should", "that", "attribute",...
train
https://github.com/klmitch/tendril/blob/207102c83e88f8f1fa7ba605ef0aab2ae9078b36/tendril/manager.py#L245-L263
klmitch/tendril
tendril/manager.py
TendrilManager.shutdown
def shutdown(self): """ Unconditionally shuts the TendrilManager down, killing all threads and closing all tendrils. """ # Remove ourself from the dictionary of running managers try: del self._running_managers[self._manager_key] except KeyError: ...
python
def shutdown(self): """ Unconditionally shuts the TendrilManager down, killing all threads and closing all tendrils. """ # Remove ourself from the dictionary of running managers try: del self._running_managers[self._manager_key] except KeyError: ...
[ "def", "shutdown", "(", "self", ")", ":", "# Remove ourself from the dictionary of running managers", "try", ":", "del", "self", ".", "_running_managers", "[", "self", ".", "_manager_key", "]", "except", "KeyError", ":", "pass", "# Kill the listening thread", "self", ...
Unconditionally shuts the TendrilManager down, killing all threads and closing all tendrils.
[ "Unconditionally", "shuts", "the", "TendrilManager", "down", "killing", "all", "threads", "and", "closing", "all", "tendrils", "." ]
train
https://github.com/klmitch/tendril/blob/207102c83e88f8f1fa7ba605ef0aab2ae9078b36/tendril/manager.py#L265-L289
klmitch/tendril
tendril/manager.py
TendrilManager.get_local_addr
def get_local_addr(self, timeout=None): """ Retrieve the current local address. :param timeout: If not given or given as ``None``, waits until the local address is available. Otherwise, waits for as long as specified. If the local ...
python
def get_local_addr(self, timeout=None): """ Retrieve the current local address. :param timeout: If not given or given as ``None``, waits until the local address is available. Otherwise, waits for as long as specified. If the local ...
[ "def", "get_local_addr", "(", "self", ",", "timeout", "=", "None", ")", ":", "# If we're not running, just return None", "if", "not", "self", ".", "running", ":", "return", "None", "# OK, we're running; wait on the _local_addr_event", "if", "not", "self", ".", "_local...
Retrieve the current local address. :param timeout: If not given or given as ``None``, waits until the local address is available. Otherwise, waits for as long as specified. If the local address is not set by the time the timeout ...
[ "Retrieve", "the", "current", "local", "address", "." ]
train
https://github.com/klmitch/tendril/blob/207102c83e88f8f1fa7ba605ef0aab2ae9078b36/tendril/manager.py#L291-L312
klmitch/tendril
tendril/manager.py
TendrilManager.connect
def connect(self, target, acceptor, wrapper=None): """ Initiate a connection from the tendril manager's endpoint. Once the connection is completed, a Tendril object will be created and passed to the given acceptor. :param target: The target of the connection attempt. :pa...
python
def connect(self, target, acceptor, wrapper=None): """ Initiate a connection from the tendril manager's endpoint. Once the connection is completed, a Tendril object will be created and passed to the given acceptor. :param target: The target of the connection attempt. :pa...
[ "def", "connect", "(", "self", ",", "target", ",", "acceptor", ",", "wrapper", "=", "None", ")", ":", "if", "not", "self", ".", "running", ":", "raise", "ValueError", "(", "\"TendrilManager not running\"", ")", "# Check the target address", "fam", "=", "utils"...
Initiate a connection from the tendril manager's endpoint. Once the connection is completed, a Tendril object will be created and passed to the given acceptor. :param target: The target of the connection attempt. :param acceptor: A callable which will initialize the state of ...
[ "Initiate", "a", "connection", "from", "the", "tendril", "manager", "s", "endpoint", ".", "Once", "the", "connection", "is", "completed", "a", "Tendril", "object", "will", "be", "created", "and", "passed", "to", "the", "given", "acceptor", "." ]
train
https://github.com/klmitch/tendril/blob/207102c83e88f8f1fa7ba605ef0aab2ae9078b36/tendril/manager.py#L341-L369
bagrat/pyerarchy
pyerarchy/core/node.py
Node.read
def read(self, *args, **kwargs): """Reads the node as a file """ with self.open('r') as f: return f.read(*args, **kwargs)
python
def read(self, *args, **kwargs): """Reads the node as a file """ with self.open('r') as f: return f.read(*args, **kwargs)
[ "def", "read", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "with", "self", ".", "open", "(", "'r'", ")", "as", "f", ":", "return", "f", ".", "read", "(", "*", "args", ",", "*", "*", "kwargs", ")" ]
Reads the node as a file
[ "Reads", "the", "node", "as", "a", "file" ]
train
https://github.com/bagrat/pyerarchy/blob/75d71408af72c583b104d27ac02fbe164354ee91/pyerarchy/core/node.py#L43-L47
bagrat/pyerarchy
pyerarchy/core/node.py
Node.ls
def ls(self): """List the children entities of the directory. Raises exception if the object is a file. :return: """ if self.isfile(): raise NotDirectoryError('Cannot ls() on non-directory node: {path}'.format(path=self._pyerarchy_path)) return os.listdir(s...
python
def ls(self): """List the children entities of the directory. Raises exception if the object is a file. :return: """ if self.isfile(): raise NotDirectoryError('Cannot ls() on non-directory node: {path}'.format(path=self._pyerarchy_path)) return os.listdir(s...
[ "def", "ls", "(", "self", ")", ":", "if", "self", ".", "isfile", "(", ")", ":", "raise", "NotDirectoryError", "(", "'Cannot ls() on non-directory node: {path}'", ".", "format", "(", "path", "=", "self", ".", "_pyerarchy_path", ")", ")", "return", "os", ".", ...
List the children entities of the directory. Raises exception if the object is a file. :return:
[ "List", "the", "children", "entities", "of", "the", "directory", "." ]
train
https://github.com/bagrat/pyerarchy/blob/75d71408af72c583b104d27ac02fbe164354ee91/pyerarchy/core/node.py#L54-L64
bagrat/pyerarchy
pyerarchy/core/node.py
Node.mkdir
def mkdir(self, children, mode=0o0755, return_node=True): """Creates child entities in directory. Raises exception if the object is a file. :param children: The list of children to be created. :return: The child object, if one child is provided. None, otherwise. """ res...
python
def mkdir(self, children, mode=0o0755, return_node=True): """Creates child entities in directory. Raises exception if the object is a file. :param children: The list of children to be created. :return: The child object, if one child is provided. None, otherwise. """ res...
[ "def", "mkdir", "(", "self", ",", "children", ",", "mode", "=", "0o0755", ",", "return_node", "=", "True", ")", ":", "result", "=", "None", "if", "isinstance", "(", "children", ",", "(", "str", ",", "unicode", ")", ")", ":", "if", "os", ".", "path"...
Creates child entities in directory. Raises exception if the object is a file. :param children: The list of children to be created. :return: The child object, if one child is provided. None, otherwise.
[ "Creates", "child", "entities", "in", "directory", "." ]
train
https://github.com/bagrat/pyerarchy/blob/75d71408af72c583b104d27ac02fbe164354ee91/pyerarchy/core/node.py#L75-L98
sxslex/capitalize-name
capitalize_name/__init__.py
capitalize
def capitalize( full_name, articles=None, separator_characters=None, ignore_worls=None, ): """Returns the correct writing of a compound name, respecting the first letters of the names in upper case.""" if articles is None: articles = _ARTICLES if separator_characters is None: ...
python
def capitalize( full_name, articles=None, separator_characters=None, ignore_worls=None, ): """Returns the correct writing of a compound name, respecting the first letters of the names in upper case.""" if articles is None: articles = _ARTICLES if separator_characters is None: ...
[ "def", "capitalize", "(", "full_name", ",", "articles", "=", "None", ",", "separator_characters", "=", "None", ",", "ignore_worls", "=", "None", ",", ")", ":", "if", "articles", "is", "None", ":", "articles", "=", "_ARTICLES", "if", "separator_characters", "...
Returns the correct writing of a compound name, respecting the first letters of the names in upper case.
[ "Returns", "the", "correct", "writing", "of", "a", "compound", "name", "respecting", "the", "first", "letters", "of", "the", "names", "in", "upper", "case", "." ]
train
https://github.com/sxslex/capitalize-name/blob/98f288a3cffaecdb8aaee5154e783ba46849bccd/capitalize_name/__init__.py#L28-L69
sxslex/capitalize-name
capitalize_name/__init__.py
deep_unicode
def deep_unicode(s, encodings=None): """decode "DEEP" S using the codec registered for encoding.""" if encodings is None: encodings = ['utf-8', 'latin-1'] if isinstance(s, (list, tuple)): return [deep_unicode(i) for i in s] if isinstance(s, dict): return dict([ (deep_...
python
def deep_unicode(s, encodings=None): """decode "DEEP" S using the codec registered for encoding.""" if encodings is None: encodings = ['utf-8', 'latin-1'] if isinstance(s, (list, tuple)): return [deep_unicode(i) for i in s] if isinstance(s, dict): return dict([ (deep_...
[ "def", "deep_unicode", "(", "s", ",", "encodings", "=", "None", ")", ":", "if", "encodings", "is", "None", ":", "encodings", "=", "[", "'utf-8'", ",", "'latin-1'", "]", "if", "isinstance", "(", "s", ",", "(", "list", ",", "tuple", ")", ")", ":", "r...
decode "DEEP" S using the codec registered for encoding.
[ "decode", "DEEP", "S", "using", "the", "codec", "registered", "for", "encoding", "." ]
train
https://github.com/sxslex/capitalize-name/blob/98f288a3cffaecdb8aaee5154e783ba46849bccd/capitalize_name/__init__.py#L86-L107
sxslex/capitalize-name
capitalize_name/__init__.py
deep_encode
def deep_encode(s, encoding='utf-8', errors='strict'): """Encode "DEEP" S using the codec registered for encoding.""" # encoding defaults to the default encoding. errors may be given to set # a different error handling scheme. Default is 'strict' meaning # that encoding errors raise # a UnicodeEncod...
python
def deep_encode(s, encoding='utf-8', errors='strict'): """Encode "DEEP" S using the codec registered for encoding.""" # encoding defaults to the default encoding. errors may be given to set # a different error handling scheme. Default is 'strict' meaning # that encoding errors raise # a UnicodeEncod...
[ "def", "deep_encode", "(", "s", ",", "encoding", "=", "'utf-8'", ",", "errors", "=", "'strict'", ")", ":", "# encoding defaults to the default encoding. errors may be given to set", "# a different error handling scheme. Default is 'strict' meaning", "# that encoding errors raise", ...
Encode "DEEP" S using the codec registered for encoding.
[ "Encode", "DEEP", "S", "using", "the", "codec", "registered", "for", "encoding", "." ]
train
https://github.com/sxslex/capitalize-name/blob/98f288a3cffaecdb8aaee5154e783ba46849bccd/capitalize_name/__init__.py#L110-L136
bretth/djset
djset/djset.py
DjBase.namespace
def namespace(self, key, glob=False): """Return a namespace for keyring""" if not self.name: self.name = os.environ['DJANGO_SETTINGS_MODULE'] ns = '.'.join([key, self._glob]) if glob else '.'.join([self.name, self._glob]) return ns
python
def namespace(self, key, glob=False): """Return a namespace for keyring""" if not self.name: self.name = os.environ['DJANGO_SETTINGS_MODULE'] ns = '.'.join([key, self._glob]) if glob else '.'.join([self.name, self._glob]) return ns
[ "def", "namespace", "(", "self", ",", "key", ",", "glob", "=", "False", ")", ":", "if", "not", "self", ".", "name", ":", "self", ".", "name", "=", "os", ".", "environ", "[", "'DJANGO_SETTINGS_MODULE'", "]", "ns", "=", "'.'", ".", "join", "(", "[", ...
Return a namespace for keyring
[ "Return", "a", "namespace", "for", "keyring" ]
train
https://github.com/bretth/djset/blob/e04cbcadc311f6edec50a718415d0004aa304034/djset/djset.py#L31-L36
bretth/djset
djset/djset.py
DjBase.get
def get(self, key, prompt_default='', prompt_help=''): """Return a value from the environ or keyring""" value = os.getenv(key) if not value: ns = self.namespace(key) value = self.keyring.get_password(ns, key) else: ns = 'environ' if not value...
python
def get(self, key, prompt_default='', prompt_help=''): """Return a value from the environ or keyring""" value = os.getenv(key) if not value: ns = self.namespace(key) value = self.keyring.get_password(ns, key) else: ns = 'environ' if not value...
[ "def", "get", "(", "self", ",", "key", ",", "prompt_default", "=", "''", ",", "prompt_help", "=", "''", ")", ":", "value", "=", "os", ".", "getenv", "(", "key", ")", "if", "not", "value", ":", "ns", "=", "self", ".", "namespace", "(", "key", ")",...
Return a value from the environ or keyring
[ "Return", "a", "value", "from", "the", "environ", "or", "keyring" ]
train
https://github.com/bretth/djset/blob/e04cbcadc311f6edec50a718415d0004aa304034/djset/djset.py#L38-L57
bretth/djset
djset/djset.py
DjBase.set
def set(self, key, value, glob=False): """Set the key value pair in a local or global namespace""" ns = self.namespace(key, glob) self.keyring.set_password(ns, key, value)
python
def set(self, key, value, glob=False): """Set the key value pair in a local or global namespace""" ns = self.namespace(key, glob) self.keyring.set_password(ns, key, value)
[ "def", "set", "(", "self", ",", "key", ",", "value", ",", "glob", "=", "False", ")", ":", "ns", "=", "self", ".", "namespace", "(", "key", ",", "glob", ")", "self", ".", "keyring", ".", "set_password", "(", "ns", ",", "key", ",", "value", ")" ]
Set the key value pair in a local or global namespace
[ "Set", "the", "key", "value", "pair", "in", "a", "local", "or", "global", "namespace" ]
train
https://github.com/bretth/djset/blob/e04cbcadc311f6edec50a718415d0004aa304034/djset/djset.py#L59-L62
bretth/djset
djset/djset.py
DjBase.remove
def remove(self, key, glob=False): """Remove key value pair in a local or global namespace.""" ns = self.namespace(key, glob) try: self.keyring.delete_password(ns, key) except PasswordDeleteError: # OSX and gnome have no delete method self.set(key, '', glob)
python
def remove(self, key, glob=False): """Remove key value pair in a local or global namespace.""" ns = self.namespace(key, glob) try: self.keyring.delete_password(ns, key) except PasswordDeleteError: # OSX and gnome have no delete method self.set(key, '', glob)
[ "def", "remove", "(", "self", ",", "key", ",", "glob", "=", "False", ")", ":", "ns", "=", "self", ".", "namespace", "(", "key", ",", "glob", ")", "try", ":", "self", ".", "keyring", ".", "delete_password", "(", "ns", ",", "key", ")", "except", "P...
Remove key value pair in a local or global namespace.
[ "Remove", "key", "value", "pair", "in", "a", "local", "or", "global", "namespace", "." ]
train
https://github.com/bretth/djset/blob/e04cbcadc311f6edec50a718415d0004aa304034/djset/djset.py#L64-L70
bretth/djset
djset/djset.py
DjSecret.get
def get(self, key, prompt_default='', prompt_help=''): """ Return the value for key from the environment or keyring. The keyring value is resolved from a local namespace or a global one. """ value = super(DjSecret, self).get(key, prompt_default, prompt_help='') if not val...
python
def get(self, key, prompt_default='', prompt_help=''): """ Return the value for key from the environment or keyring. The keyring value is resolved from a local namespace or a global one. """ value = super(DjSecret, self).get(key, prompt_default, prompt_help='') if not val...
[ "def", "get", "(", "self", ",", "key", ",", "prompt_default", "=", "''", ",", "prompt_help", "=", "''", ")", ":", "value", "=", "super", "(", "DjSecret", ",", "self", ")", ".", "get", "(", "key", ",", "prompt_default", ",", "prompt_help", "=", "''", ...
Return the value for key from the environment or keyring. The keyring value is resolved from a local namespace or a global one.
[ "Return", "the", "value", "for", "key", "from", "the", "environment", "or", "keyring", ".", "The", "keyring", "value", "is", "resolved", "from", "a", "local", "namespace", "or", "a", "global", "one", "." ]
train
https://github.com/bretth/djset/blob/e04cbcadc311f6edec50a718415d0004aa304034/djset/djset.py#L88-L97
IrvKalb/pygwidgets
pygwidgets/pygwidgets.py
PygWidget.setLoc
def setLoc(self, loc): # loc must be a tuple or list of x,y coordinates """Sets a new location (and changes the rect loc) for this widget.""" self.loc = loc self.rect[0] = self.loc[0] self.rect[1] = self.loc[1]
python
def setLoc(self, loc): # loc must be a tuple or list of x,y coordinates """Sets a new location (and changes the rect loc) for this widget.""" self.loc = loc self.rect[0] = self.loc[0] self.rect[1] = self.loc[1]
[ "def", "setLoc", "(", "self", ",", "loc", ")", ":", "# loc must be a tuple or list of x,y coordinates\r", "self", ".", "loc", "=", "loc", "self", ".", "rect", "[", "0", "]", "=", "self", ".", "loc", "[", "0", "]", "self", ".", "rect", "[", "1", "]", ...
Sets a new location (and changes the rect loc) for this widget.
[ "Sets", "a", "new", "location", "(", "and", "changes", "the", "rect", "loc", ")", "for", "this", "widget", "." ]
train
https://github.com/IrvKalb/pygwidgets/blob/a830d8885d4d209e471cb53816277d30db56273c/pygwidgets/pygwidgets.py#L270-L274
IrvKalb/pygwidgets
pygwidgets/pygwidgets.py
PygWidgetsButton.handleEvent
def handleEvent(self, eventObj): """This method should be called every time through the main loop. It handles showing the up, over, and down states of the button. Parameters: | eventObj - the event object obtained by calling pygame.event.get() Returns: ...
python
def handleEvent(self, eventObj): """This method should be called every time through the main loop. It handles showing the up, over, and down states of the button. Parameters: | eventObj - the event object obtained by calling pygame.event.get() Returns: ...
[ "def", "handleEvent", "(", "self", ",", "eventObj", ")", ":", "if", "self", ".", "enterToActivate", ":", "if", "eventObj", ".", "type", "==", "pygame", ".", "KEYDOWN", ":", "# Return or Enter key\r", "if", "eventObj", ".", "key", "==", "pygame", ".", "K_RE...
This method should be called every time through the main loop. It handles showing the up, over, and down states of the button. Parameters: | eventObj - the event object obtained by calling pygame.event.get() Returns: | False most of the time | True...
[ "This", "method", "should", "be", "called", "every", "time", "through", "the", "main", "loop", ".", "It", "handles", "showing", "the", "up", "over", "and", "down", "states", "of", "the", "button", ".", "Parameters", ":", "|", "eventObj", "-", "the", "eve...
train
https://github.com/IrvKalb/pygwidgets/blob/a830d8885d4d209e471cb53816277d30db56273c/pygwidgets/pygwidgets.py#L366-L442
IrvKalb/pygwidgets
pygwidgets/pygwidgets.py
PygWidgetsButton.draw
def draw(self): """Draws the button in its current state. Should be called every time through the main loop """ if not self.visible: return # Blit the button's current appearance to the surface. if self.isEnabled: if self.mouseIsDown:...
python
def draw(self): """Draws the button in its current state. Should be called every time through the main loop """ if not self.visible: return # Blit the button's current appearance to the surface. if self.isEnabled: if self.mouseIsDown:...
[ "def", "draw", "(", "self", ")", ":", "if", "not", "self", ".", "visible", ":", "return", "# Blit the button's current appearance to the surface.\r", "if", "self", ".", "isEnabled", ":", "if", "self", ".", "mouseIsDown", ":", "if", "self", ".", "mouseOverButton"...
Draws the button in its current state. Should be called every time through the main loop
[ "Draws", "the", "button", "in", "its", "current", "state", ".", "Should", "be", "called", "every", "time", "through", "the", "main", "loop" ]
train
https://github.com/IrvKalb/pygwidgets/blob/a830d8885d4d209e471cb53816277d30db56273c/pygwidgets/pygwidgets.py#L444-L467
IrvKalb/pygwidgets
pygwidgets/pygwidgets.py
PygWidgetsButton._debug
def _debug(self): """This is just for debugging, so we can see what buttons would be drawn. Not intended to be used in production.""" self.window.blit(self.surfaceUp, (self.loc[0], 10)) self.window.blit(self.surfaceOver, (self.loc[0], 60)) self.window.blit(self.surfaceDown...
python
def _debug(self): """This is just for debugging, so we can see what buttons would be drawn. Not intended to be used in production.""" self.window.blit(self.surfaceUp, (self.loc[0], 10)) self.window.blit(self.surfaceOver, (self.loc[0], 60)) self.window.blit(self.surfaceDown...
[ "def", "_debug", "(", "self", ")", ":", "self", ".", "window", ".", "blit", "(", "self", ".", "surfaceUp", ",", "(", "self", ".", "loc", "[", "0", "]", ",", "10", ")", ")", "self", ".", "window", ".", "blit", "(", "self", ".", "surfaceOver", ",...
This is just for debugging, so we can see what buttons would be drawn. Not intended to be used in production.
[ "This", "is", "just", "for", "debugging", "so", "we", "can", "see", "what", "buttons", "would", "be", "drawn", ".", "Not", "intended", "to", "be", "used", "in", "production", "." ]
train
https://github.com/IrvKalb/pygwidgets/blob/a830d8885d4d209e471cb53816277d30db56273c/pygwidgets/pygwidgets.py#L470-L477
IrvKalb/pygwidgets
pygwidgets/pygwidgets.py
PygWidgetsCheckBox.handleEvent
def handleEvent(self, eventObj): """This method should be called every time through the main loop. It handles showing the up, over, and down states of the button. Parameters: | eventObj - the event object obtained by calling pygame.event.get() Returns: ...
python
def handleEvent(self, eventObj): """This method should be called every time through the main loop. It handles showing the up, over, and down states of the button. Parameters: | eventObj - the event object obtained by calling pygame.event.get() Returns: ...
[ "def", "handleEvent", "(", "self", ",", "eventObj", ")", ":", "if", "eventObj", ".", "type", "not", "in", "(", "MOUSEMOTION", ",", "MOUSEBUTTONUP", ",", "MOUSEBUTTONDOWN", ")", "or", "not", "self", ".", "visible", ":", "# The checkBox only cares bout mouse-relat...
This method should be called every time through the main loop. It handles showing the up, over, and down states of the button. Parameters: | eventObj - the event object obtained by calling pygame.event.get() Returns: | False most of the time | True...
[ "This", "method", "should", "be", "called", "every", "time", "through", "the", "main", "loop", ".", "It", "handles", "showing", "the", "up", "over", "and", "down", "states", "of", "the", "button", ".", "Parameters", ":", "|", "eventObj", "-", "the", "eve...
train
https://github.com/IrvKalb/pygwidgets/blob/a830d8885d4d209e471cb53816277d30db56273c/pygwidgets/pygwidgets.py#L770-L837
IrvKalb/pygwidgets
pygwidgets/pygwidgets.py
PygWidgetsCheckBox.draw
def draw(self): """Draws the checkbox.""" if not self.visible: return # Blit the current checkbox's image. if self.isEnabled: if self.mouseIsDown and self.lastMouseDownOverButton and self.mouseOverButton: if self.value: ...
python
def draw(self): """Draws the checkbox.""" if not self.visible: return # Blit the current checkbox's image. if self.isEnabled: if self.mouseIsDown and self.lastMouseDownOverButton and self.mouseOverButton: if self.value: ...
[ "def", "draw", "(", "self", ")", ":", "if", "not", "self", ".", "visible", ":", "return", "# Blit the current checkbox's image.\r", "if", "self", ".", "isEnabled", ":", "if", "self", ".", "mouseIsDown", "and", "self", ".", "lastMouseDownOverButton", "and", "se...
Draws the checkbox.
[ "Draws", "the", "checkbox", "." ]
train
https://github.com/IrvKalb/pygwidgets/blob/a830d8885d4d209e471cb53816277d30db56273c/pygwidgets/pygwidgets.py#L839-L863