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 |
|---|---|---|---|---|---|---|---|---|---|---|
NAMD/pypln.api | pypln/api.py | Corpus.add_document | def add_document(self, document):
'''
Add a document to this corpus
`document' is passed to `requests.post', so it can be a file-like
object, a string (that will be sent as the file content) or a tuple
containing a filename followed by any of these two options.
'''
... | python | def add_document(self, document):
'''
Add a document to this corpus
`document' is passed to `requests.post', so it can be a file-like
object, a string (that will be sent as the file content) or a tuple
containing a filename followed by any of these two options.
'''
... | [
"def",
"add_document",
"(",
"self",
",",
"document",
")",
":",
"documents_url",
"=",
"urljoin",
"(",
"self",
".",
"base_url",
",",
"self",
".",
"DOCUMENTS_PAGE",
")",
"data",
"=",
"{",
"\"corpus\"",
":",
"self",
".",
"url",
"}",
"files",
"=",
"{",
"\"b... | Add a document to this corpus
`document' is passed to `requests.post', so it can be a file-like
object, a string (that will be sent as the file content) or a tuple
containing a filename followed by any of these two options. | [
"Add",
"a",
"document",
"to",
"this",
"corpus"
] | train | https://github.com/NAMD/pypln.api/blob/ccb73fd80ca094669a85bd3991dc84a8564ab016/pypln/api.py#L175-L193 |
NAMD/pypln.api | pypln/api.py | Corpus.add_documents | def add_documents(self, documents):
'''
Adds more than one document using the same API call
Returns two lists: the first one contains the successfully uploaded
documents, and the second one tuples with documents that failed to be
uploaded and the exceptions raised.
'''
... | python | def add_documents(self, documents):
'''
Adds more than one document using the same API call
Returns two lists: the first one contains the successfully uploaded
documents, and the second one tuples with documents that failed to be
uploaded and the exceptions raised.
'''
... | [
"def",
"add_documents",
"(",
"self",
",",
"documents",
")",
":",
"result",
",",
"errors",
"=",
"[",
"]",
",",
"[",
"]",
"for",
"document",
"in",
"documents",
":",
"try",
":",
"result",
".",
"append",
"(",
"self",
".",
"add_document",
"(",
"document",
... | Adds more than one document using the same API call
Returns two lists: the first one contains the successfully uploaded
documents, and the second one tuples with documents that failed to be
uploaded and the exceptions raised. | [
"Adds",
"more",
"than",
"one",
"document",
"using",
"the",
"same",
"API",
"call"
] | train | https://github.com/NAMD/pypln.api/blob/ccb73fd80ca094669a85bd3991dc84a8564ab016/pypln/api.py#L195-L210 |
NAMD/pypln.api | pypln/api.py | PyPLN.add_corpus | def add_corpus(self, name, description):
'''Add a corpus to your account'''
corpora_url = self.base_url + self.CORPORA_PAGE
data = {'name': name, 'description': description}
result = self.session.post(corpora_url, data=data)
if result.status_code == 201:
return Corpus... | python | def add_corpus(self, name, description):
'''Add a corpus to your account'''
corpora_url = self.base_url + self.CORPORA_PAGE
data = {'name': name, 'description': description}
result = self.session.post(corpora_url, data=data)
if result.status_code == 201:
return Corpus... | [
"def",
"add_corpus",
"(",
"self",
",",
"name",
",",
"description",
")",
":",
"corpora_url",
"=",
"self",
".",
"base_url",
"+",
"self",
".",
"CORPORA_PAGE",
"data",
"=",
"{",
"'name'",
":",
"name",
",",
"'description'",
":",
"description",
"}",
"result",
... | Add a corpus to your account | [
"Add",
"a",
"corpus",
"to",
"your",
"account"
] | train | https://github.com/NAMD/pypln.api/blob/ccb73fd80ca094669a85bd3991dc84a8564ab016/pypln/api.py#L227-L237 |
NAMD/pypln.api | pypln/api.py | PyPLN._retrieve_resources | def _retrieve_resources(self, url, class_, full):
'''Retrieve HTTP resources, return related objects (with pagination)'''
objects_to_return = []
response = self.session.get(url)
if response.status_code == 200:
result = response.json()
resources = result['results']... | python | def _retrieve_resources(self, url, class_, full):
'''Retrieve HTTP resources, return related objects (with pagination)'''
objects_to_return = []
response = self.session.get(url)
if response.status_code == 200:
result = response.json()
resources = result['results']... | [
"def",
"_retrieve_resources",
"(",
"self",
",",
"url",
",",
"class_",
",",
"full",
")",
":",
"objects_to_return",
"=",
"[",
"]",
"response",
"=",
"self",
".",
"session",
".",
"get",
"(",
"url",
")",
"if",
"response",
".",
"status_code",
"==",
"200",
":... | Retrieve HTTP resources, return related objects (with pagination) | [
"Retrieve",
"HTTP",
"resources",
"return",
"related",
"objects",
"(",
"with",
"pagination",
")"
] | train | https://github.com/NAMD/pypln.api/blob/ccb73fd80ca094669a85bd3991dc84a8564ab016/pypln/api.py#L239-L264 |
NAMD/pypln.api | pypln/api.py | PyPLN.corpora | def corpora(self, full=False):
'''Return list of corpora owned by user.
If `full=True`, it'll download all pages returned by the HTTP server'''
url = self.base_url + self.CORPORA_PAGE
class_ = Corpus
results = self._retrieve_resources(url, class_, full)
return results | python | def corpora(self, full=False):
'''Return list of corpora owned by user.
If `full=True`, it'll download all pages returned by the HTTP server'''
url = self.base_url + self.CORPORA_PAGE
class_ = Corpus
results = self._retrieve_resources(url, class_, full)
return results | [
"def",
"corpora",
"(",
"self",
",",
"full",
"=",
"False",
")",
":",
"url",
"=",
"self",
".",
"base_url",
"+",
"self",
".",
"CORPORA_PAGE",
"class_",
"=",
"Corpus",
"results",
"=",
"self",
".",
"_retrieve_resources",
"(",
"url",
",",
"class_",
",",
"ful... | Return list of corpora owned by user.
If `full=True`, it'll download all pages returned by the HTTP server | [
"Return",
"list",
"of",
"corpora",
"owned",
"by",
"user",
"."
] | train | https://github.com/NAMD/pypln.api/blob/ccb73fd80ca094669a85bd3991dc84a8564ab016/pypln/api.py#L266-L273 |
NAMD/pypln.api | pypln/api.py | PyPLN.documents | def documents(self, full=False):
'''Return list of documents owned by user.
If `full=True`, it'll download all pages returned by the HTTP server'''
url = self.base_url + self.DOCUMENTS_PAGE
class_ = Document
results = self._retrieve_resources(url, class_, full)
return re... | python | def documents(self, full=False):
'''Return list of documents owned by user.
If `full=True`, it'll download all pages returned by the HTTP server'''
url = self.base_url + self.DOCUMENTS_PAGE
class_ = Document
results = self._retrieve_resources(url, class_, full)
return re... | [
"def",
"documents",
"(",
"self",
",",
"full",
"=",
"False",
")",
":",
"url",
"=",
"self",
".",
"base_url",
"+",
"self",
".",
"DOCUMENTS_PAGE",
"class_",
"=",
"Document",
"results",
"=",
"self",
".",
"_retrieve_resources",
"(",
"url",
",",
"class_",
",",
... | Return list of documents owned by user.
If `full=True`, it'll download all pages returned by the HTTP server | [
"Return",
"list",
"of",
"documents",
"owned",
"by",
"user",
"."
] | train | https://github.com/NAMD/pypln.api/blob/ccb73fd80ca094669a85bd3991dc84a8564ab016/pypln/api.py#L275-L282 |
jkenlooper/chill | src/chill/database.py | init_db | def init_db():
"""Initialize a new database with the default tables for chill.
Creates the following tables:
Chill
Node
Node_Node
Route
Query
Template
"""
with current_app.app_context():
for filename in CHILL_CREATE_TABLE_FILES:
db.execute(text(fetch_query_str... | python | def init_db():
"""Initialize a new database with the default tables for chill.
Creates the following tables:
Chill
Node
Node_Node
Route
Query
Template
"""
with current_app.app_context():
for filename in CHILL_CREATE_TABLE_FILES:
db.execute(text(fetch_query_str... | [
"def",
"init_db",
"(",
")",
":",
"with",
"current_app",
".",
"app_context",
"(",
")",
":",
"for",
"filename",
"in",
"CHILL_CREATE_TABLE_FILES",
":",
"db",
".",
"execute",
"(",
"text",
"(",
"fetch_query_string",
"(",
"filename",
")",
")",
")"
] | Initialize a new database with the default tables for chill.
Creates the following tables:
Chill
Node
Node_Node
Route
Query
Template | [
"Initialize",
"a",
"new",
"database",
"with",
"the",
"default",
"tables",
"for",
"chill",
".",
"Creates",
"the",
"following",
"tables",
":",
"Chill",
"Node",
"Node_Node",
"Route",
"Query",
"Template"
] | train | https://github.com/jkenlooper/chill/blob/35360c17c2a3b769ecb5406c6dabcf4cc70bd76f/src/chill/database.py#L16-L28 |
jkenlooper/chill | src/chill/database.py | insert_node | def insert_node(**kw):
"Insert a node with a name and optional value. Return the node id."
with current_app.app_context():
result = db.execute(text(fetch_query_string('insert_node.sql')), **kw)
# TODO: support for postgres may require using a RETURNING id; sql
# statement and using the i... | python | def insert_node(**kw):
"Insert a node with a name and optional value. Return the node id."
with current_app.app_context():
result = db.execute(text(fetch_query_string('insert_node.sql')), **kw)
# TODO: support for postgres may require using a RETURNING id; sql
# statement and using the i... | [
"def",
"insert_node",
"(",
"*",
"*",
"kw",
")",
":",
"with",
"current_app",
".",
"app_context",
"(",
")",
":",
"result",
"=",
"db",
".",
"execute",
"(",
"text",
"(",
"fetch_query_string",
"(",
"'insert_node.sql'",
")",
")",
",",
"*",
"*",
"kw",
")",
... | Insert a node with a name and optional value. Return the node id. | [
"Insert",
"a",
"node",
"with",
"a",
"name",
"and",
"optional",
"value",
".",
"Return",
"the",
"node",
"id",
"."
] | train | https://github.com/jkenlooper/chill/blob/35360c17c2a3b769ecb5406c6dabcf4cc70bd76f/src/chill/database.py#L60-L71 |
jkenlooper/chill | src/chill/database.py | insert_node_node | def insert_node_node(**kw):
"""
Link a node to another node. node_id -> target_node_id. Where `node_id` is
the parent and `target_node_id` is the child.
"""
with current_app.app_context():
insert_query(name='select_link_node_from_node.sql', node_id=kw.get('node_id'))
db.execute(text... | python | def insert_node_node(**kw):
"""
Link a node to another node. node_id -> target_node_id. Where `node_id` is
the parent and `target_node_id` is the child.
"""
with current_app.app_context():
insert_query(name='select_link_node_from_node.sql', node_id=kw.get('node_id'))
db.execute(text... | [
"def",
"insert_node_node",
"(",
"*",
"*",
"kw",
")",
":",
"with",
"current_app",
".",
"app_context",
"(",
")",
":",
"insert_query",
"(",
"name",
"=",
"'select_link_node_from_node.sql'",
",",
"node_id",
"=",
"kw",
".",
"get",
"(",
"'node_id'",
")",
")",
"db... | Link a node to another node. node_id -> target_node_id. Where `node_id` is
the parent and `target_node_id` is the child. | [
"Link",
"a",
"node",
"to",
"another",
"node",
".",
"node_id",
"-",
">",
"target_node_id",
".",
"Where",
"node_id",
"is",
"the",
"parent",
"and",
"target_node_id",
"is",
"the",
"child",
"."
] | train | https://github.com/jkenlooper/chill/blob/35360c17c2a3b769ecb5406c6dabcf4cc70bd76f/src/chill/database.py#L73-L80 |
jkenlooper/chill | src/chill/database.py | select_node | def select_node(**kw):
"""
Select node by id.
"""
with current_app.app_context():
result = db.execute(text(fetch_query_string('select_node_from_id.sql')), **kw).fetchall()
return result | python | def select_node(**kw):
"""
Select node by id.
"""
with current_app.app_context():
result = db.execute(text(fetch_query_string('select_node_from_id.sql')), **kw).fetchall()
return result | [
"def",
"select_node",
"(",
"*",
"*",
"kw",
")",
":",
"with",
"current_app",
".",
"app_context",
"(",
")",
":",
"result",
"=",
"db",
".",
"execute",
"(",
"text",
"(",
"fetch_query_string",
"(",
"'select_node_from_id.sql'",
")",
")",
",",
"*",
"*",
"kw",
... | Select node by id. | [
"Select",
"node",
"by",
"id",
"."
] | train | https://github.com/jkenlooper/chill/blob/35360c17c2a3b769ecb5406c6dabcf4cc70bd76f/src/chill/database.py#L89-L95 |
jkenlooper/chill | src/chill/database.py | insert_route | def insert_route(**kw):
"""
`path` - '/', '/some/other/path/', '/test/<int:index>/'
`node_id`
`weight` - How this path is selected before other similar paths
`method` - 'GET' is default.
"""
binding = {
'path': None,
'node_id': None,
'weight': None,
... | python | def insert_route(**kw):
"""
`path` - '/', '/some/other/path/', '/test/<int:index>/'
`node_id`
`weight` - How this path is selected before other similar paths
`method` - 'GET' is default.
"""
binding = {
'path': None,
'node_id': None,
'weight': None,
... | [
"def",
"insert_route",
"(",
"*",
"*",
"kw",
")",
":",
"binding",
"=",
"{",
"'path'",
":",
"None",
",",
"'node_id'",
":",
"None",
",",
"'weight'",
":",
"None",
",",
"'method'",
":",
"\"GET\"",
"}",
"binding",
".",
"update",
"(",
"kw",
")",
"with",
"... | `path` - '/', '/some/other/path/', '/test/<int:index>/'
`node_id`
`weight` - How this path is selected before other similar paths
`method` - 'GET' is default. | [
"path",
"-",
"/",
"/",
"some",
"/",
"other",
"/",
"path",
"/",
"/",
"test",
"/",
"<int",
":",
"index",
">",
"/",
"node_id",
"weight",
"-",
"How",
"this",
"path",
"is",
"selected",
"before",
"other",
"similar",
"paths",
"method",
"-",
"GET",
"is",
"... | train | https://github.com/jkenlooper/chill/blob/35360c17c2a3b769ecb5406c6dabcf4cc70bd76f/src/chill/database.py#L97-L112 |
jkenlooper/chill | src/chill/database.py | add_template_for_node | def add_template_for_node(name, node_id):
"Set the template to use to display the node"
with current_app.app_context():
db.execute(text(fetch_query_string('insert_template.sql')),
name=name, node_id=node_id)
result = db.execute(text(fetch_query_string('select_template.sql')),
... | python | def add_template_for_node(name, node_id):
"Set the template to use to display the node"
with current_app.app_context():
db.execute(text(fetch_query_string('insert_template.sql')),
name=name, node_id=node_id)
result = db.execute(text(fetch_query_string('select_template.sql')),
... | [
"def",
"add_template_for_node",
"(",
"name",
",",
"node_id",
")",
":",
"with",
"current_app",
".",
"app_context",
"(",
")",
":",
"db",
".",
"execute",
"(",
"text",
"(",
"fetch_query_string",
"(",
"'insert_template.sql'",
")",
")",
",",
"name",
"=",
"name",
... | Set the template to use to display the node | [
"Set",
"the",
"template",
"to",
"use",
"to",
"display",
"the",
"node"
] | train | https://github.com/jkenlooper/chill/blob/35360c17c2a3b769ecb5406c6dabcf4cc70bd76f/src/chill/database.py#L114-L124 |
jkenlooper/chill | src/chill/database.py | insert_query | def insert_query(**kw):
"""
Insert a query name for a node_id.
`name`
`node_id`
Adds the name to the Query table if not already there. Sets the query field
in Node table.
"""
with current_app.app_context():
result = db.execute(text(fetch_query_string('select_query_where_name.sql... | python | def insert_query(**kw):
"""
Insert a query name for a node_id.
`name`
`node_id`
Adds the name to the Query table if not already there. Sets the query field
in Node table.
"""
with current_app.app_context():
result = db.execute(text(fetch_query_string('select_query_where_name.sql... | [
"def",
"insert_query",
"(",
"*",
"*",
"kw",
")",
":",
"with",
"current_app",
".",
"app_context",
"(",
")",
":",
"result",
"=",
"db",
".",
"execute",
"(",
"text",
"(",
"fetch_query_string",
"(",
"'select_query_where_name.sql'",
")",
")",
",",
"*",
"*",
"k... | Insert a query name for a node_id.
`name`
`node_id`
Adds the name to the Query table if not already there. Sets the query field
in Node table. | [
"Insert",
"a",
"query",
"name",
"for",
"a",
"node_id",
".",
"name",
"node_id"
] | train | https://github.com/jkenlooper/chill/blob/35360c17c2a3b769ecb5406c6dabcf4cc70bd76f/src/chill/database.py#L127-L146 |
uw-it-aca/uw-restclients-libraries | uw_libraries/subject_guides.py | get_subject_guide_for_section_params | def get_subject_guide_for_section_params(
year, quarter, curriculum_abbr, course_number, section_id=None):
"""
Returns a SubjectGuide model for the passed section params:
year: year for the section term (4-digits)
quarter: quarter (AUT, WIN, SPR, or SUM)
curriculum_abbr: curriculum abbrevia... | python | def get_subject_guide_for_section_params(
year, quarter, curriculum_abbr, course_number, section_id=None):
"""
Returns a SubjectGuide model for the passed section params:
year: year for the section term (4-digits)
quarter: quarter (AUT, WIN, SPR, or SUM)
curriculum_abbr: curriculum abbrevia... | [
"def",
"get_subject_guide_for_section_params",
"(",
"year",
",",
"quarter",
",",
"curriculum_abbr",
",",
"course_number",
",",
"section_id",
"=",
"None",
")",
":",
"quarter",
"=",
"quarter",
".",
"upper",
"(",
")",
"[",
":",
"3",
"]",
"url",
"=",
"\"{}/{}/{}... | Returns a SubjectGuide model for the passed section params:
year: year for the section term (4-digits)
quarter: quarter (AUT, WIN, SPR, or SUM)
curriculum_abbr: curriculum abbreviation
course_number: course number
section_id: course section identifier (optional) | [
"Returns",
"a",
"SubjectGuide",
"model",
"for",
"the",
"passed",
"section",
"params",
":"
] | train | https://github.com/uw-it-aca/uw-restclients-libraries/blob/2fa2e38be4516d7853c2802e2f23b17fbf4bac3d/uw_libraries/subject_guides.py#L17-L41 |
uw-it-aca/uw-restclients-libraries | uw_libraries/subject_guides.py | get_subject_guide_for_section | def get_subject_guide_for_section(section):
"""
Returns a SubjectGuide model for the passed SWS section model.
"""
return get_subject_guide_for_section_params(
section.term.year, section.term.quarter, section.curriculum_abbr,
section.course_number, section.section_id) | python | def get_subject_guide_for_section(section):
"""
Returns a SubjectGuide model for the passed SWS section model.
"""
return get_subject_guide_for_section_params(
section.term.year, section.term.quarter, section.curriculum_abbr,
section.course_number, section.section_id) | [
"def",
"get_subject_guide_for_section",
"(",
"section",
")",
":",
"return",
"get_subject_guide_for_section_params",
"(",
"section",
".",
"term",
".",
"year",
",",
"section",
".",
"term",
".",
"quarter",
",",
"section",
".",
"curriculum_abbr",
",",
"section",
".",
... | Returns a SubjectGuide model for the passed SWS section model. | [
"Returns",
"a",
"SubjectGuide",
"model",
"for",
"the",
"passed",
"SWS",
"section",
"model",
"."
] | train | https://github.com/uw-it-aca/uw-restclients-libraries/blob/2fa2e38be4516d7853c2802e2f23b17fbf4bac3d/uw_libraries/subject_guides.py#L44-L50 |
uw-it-aca/uw-restclients-libraries | uw_libraries/subject_guides.py | get_subject_guide_for_canvas_course_sis_id | def get_subject_guide_for_canvas_course_sis_id(course_sis_id):
"""
Returns a SubjectGuide model for the passed Canvas course SIS ID.
"""
(year, quarter, curriculum_abbr, course_number,
section_id) = course_sis_id.split('-', 4)
return get_subject_guide_for_section_params(
year, quarte... | python | def get_subject_guide_for_canvas_course_sis_id(course_sis_id):
"""
Returns a SubjectGuide model for the passed Canvas course SIS ID.
"""
(year, quarter, curriculum_abbr, course_number,
section_id) = course_sis_id.split('-', 4)
return get_subject_guide_for_section_params(
year, quarte... | [
"def",
"get_subject_guide_for_canvas_course_sis_id",
"(",
"course_sis_id",
")",
":",
"(",
"year",
",",
"quarter",
",",
"curriculum_abbr",
",",
"course_number",
",",
"section_id",
")",
"=",
"course_sis_id",
".",
"split",
"(",
"'-'",
",",
"4",
")",
"return",
"get_... | Returns a SubjectGuide model for the passed Canvas course SIS ID. | [
"Returns",
"a",
"SubjectGuide",
"model",
"for",
"the",
"passed",
"Canvas",
"course",
"SIS",
"ID",
"."
] | train | https://github.com/uw-it-aca/uw-restclients-libraries/blob/2fa2e38be4516d7853c2802e2f23b17fbf4bac3d/uw_libraries/subject_guides.py#L53-L60 |
uw-it-aca/uw-restclients-libraries | uw_libraries/subject_guides.py | get_default_subject_guide | def get_default_subject_guide(campus='seattle'):
"""
Returns a default SubjectGuide model for the passed campus:
seattle, bothell, tacoma
"""
url = "{}/{}/{}".format(subject_guide_url_prefix, 'defaultGuide', campus)
headers = {'Accept': 'application/json'}
response = SubjectGuide_DAO().... | python | def get_default_subject_guide(campus='seattle'):
"""
Returns a default SubjectGuide model for the passed campus:
seattle, bothell, tacoma
"""
url = "{}/{}/{}".format(subject_guide_url_prefix, 'defaultGuide', campus)
headers = {'Accept': 'application/json'}
response = SubjectGuide_DAO().... | [
"def",
"get_default_subject_guide",
"(",
"campus",
"=",
"'seattle'",
")",
":",
"url",
"=",
"\"{}/{}/{}\"",
".",
"format",
"(",
"subject_guide_url_prefix",
",",
"'defaultGuide'",
",",
"campus",
")",
"headers",
"=",
"{",
"'Accept'",
":",
"'application/json'",
"}",
... | Returns a default SubjectGuide model for the passed campus:
seattle, bothell, tacoma | [
"Returns",
"a",
"default",
"SubjectGuide",
"model",
"for",
"the",
"passed",
"campus",
":",
"seattle",
"bothell",
"tacoma"
] | train | https://github.com/uw-it-aca/uw-restclients-libraries/blob/2fa2e38be4516d7853c2802e2f23b17fbf4bac3d/uw_libraries/subject_guides.py#L63-L77 |
FujiMakoto/IPS-Vagrant | ips_vagrant/common/progress.py | ProgressBar.update | def update(self, value=None, label=None):
"""
Update the progress bar
@type value: int
@type label: str
"""
if label:
self.label = label
super(ProgressBar, self).update(value) | python | def update(self, value=None, label=None):
"""
Update the progress bar
@type value: int
@type label: str
"""
if label:
self.label = label
super(ProgressBar, self).update(value) | [
"def",
"update",
"(",
"self",
",",
"value",
"=",
"None",
",",
"label",
"=",
"None",
")",
":",
"if",
"label",
":",
"self",
".",
"label",
"=",
"label",
"super",
"(",
"ProgressBar",
",",
"self",
")",
".",
"update",
"(",
"value",
")"
] | Update the progress bar
@type value: int
@type label: str | [
"Update",
"the",
"progress",
"bar"
] | train | https://github.com/FujiMakoto/IPS-Vagrant/blob/7b1d6d095034dd8befb026d9315ecc6494d52269/ips_vagrant/common/progress.py#L54-L63 |
FujiMakoto/IPS-Vagrant | ips_vagrant/common/progress.py | Label.update | def update(self, pbar):
"""
Handle progress bar updates
@type pbar: ProgressBar
@rtype: str
"""
if pbar.label != self._label:
self.label = pbar.label
return self.label | python | def update(self, pbar):
"""
Handle progress bar updates
@type pbar: ProgressBar
@rtype: str
"""
if pbar.label != self._label:
self.label = pbar.label
return self.label | [
"def",
"update",
"(",
"self",
",",
"pbar",
")",
":",
"if",
"pbar",
".",
"label",
"!=",
"self",
".",
"_label",
":",
"self",
".",
"label",
"=",
"pbar",
".",
"label",
"return",
"self",
".",
"label"
] | Handle progress bar updates
@type pbar: ProgressBar
@rtype: str | [
"Handle",
"progress",
"bar",
"updates"
] | train | https://github.com/FujiMakoto/IPS-Vagrant/blob/7b1d6d095034dd8befb026d9315ecc6494d52269/ips_vagrant/common/progress.py#L88-L97 |
FujiMakoto/IPS-Vagrant | ips_vagrant/common/progress.py | Label.label | def label(self, value):
"""
Set the label and generate the formatted value
@type value: str
"""
# Fixed width label formatting
value = value[:self.pad_size] if self.pad_size else value
try:
padding = ' ' * (self.pad_size - len(value)) if self.pa... | python | def label(self, value):
"""
Set the label and generate the formatted value
@type value: str
"""
# Fixed width label formatting
value = value[:self.pad_size] if self.pad_size else value
try:
padding = ' ' * (self.pad_size - len(value)) if self.pa... | [
"def",
"label",
"(",
"self",
",",
"value",
")",
":",
"# Fixed width label formatting",
"value",
"=",
"value",
"[",
":",
"self",
".",
"pad_size",
"]",
"if",
"self",
".",
"pad_size",
"else",
"value",
"try",
":",
"padding",
"=",
"' '",
"*",
"(",
"self",
"... | Set the label and generate the formatted value
@type value: str | [
"Set",
"the",
"label",
"and",
"generate",
"the",
"formatted",
"value"
] | train | https://github.com/FujiMakoto/IPS-Vagrant/blob/7b1d6d095034dd8befb026d9315ecc6494d52269/ips_vagrant/common/progress.py#L111-L123 |
FujiMakoto/IPS-Vagrant | ips_vagrant/common/progress.py | MarkerProgressBar.finish | def finish(self):
"""
Update widgets on finish
"""
os.system('setterm -cursor on')
if self.nl:
Echo(self.label).done() | python | def finish(self):
"""
Update widgets on finish
"""
os.system('setterm -cursor on')
if self.nl:
Echo(self.label).done() | [
"def",
"finish",
"(",
"self",
")",
":",
"os",
".",
"system",
"(",
"'setterm -cursor on'",
")",
"if",
"self",
".",
"nl",
":",
"Echo",
"(",
"self",
".",
"label",
")",
".",
"done",
"(",
")"
] | Update widgets on finish | [
"Update",
"widgets",
"on",
"finish"
] | train | https://github.com/FujiMakoto/IPS-Vagrant/blob/7b1d6d095034dd8befb026d9315ecc6494d52269/ips_vagrant/common/progress.py#L155-L161 |
caspervg/pylex | src/pylex/search.py | SearchRoute.search | def search(self, start=0, amount=15, order='asc', concise=False, user=True, dependencies=True, comments=True,
votes=True, filters=None):
"""
Search the LEX
:param start: Start at this result number
:param amount: Number of results to return
:param order: Ordering o... | python | def search(self, start=0, amount=15, order='asc', concise=False, user=True, dependencies=True, comments=True,
votes=True, filters=None):
"""
Search the LEX
:param start: Start at this result number
:param amount: Number of results to return
:param order: Ordering o... | [
"def",
"search",
"(",
"self",
",",
"start",
"=",
"0",
",",
"amount",
"=",
"15",
",",
"order",
"=",
"'asc'",
",",
"concise",
"=",
"False",
",",
"user",
"=",
"True",
",",
"dependencies",
"=",
"True",
",",
"comments",
"=",
"True",
",",
"votes",
"=",
... | Search the LEX
:param start: Start at this result number
:param amount: Number of results to return
:param order: Ordering of the results ('asc' or 'desc')
:param concise: Return only concise results (name and id)
:param user: Should user (authenticated) information be returned (... | [
"Search",
"the",
"LEX",
":",
"param",
"start",
":",
"Start",
"at",
"this",
"result",
"number",
":",
"param",
"amount",
":",
"Number",
"of",
"results",
"to",
"return",
":",
"param",
"order",
":",
"Ordering",
"of",
"the",
"results",
"(",
"asc",
"or",
"de... | train | https://github.com/caspervg/pylex/blob/bae00c705b5331b0f784d42b27e19dc3541e1b5a/src/pylex/search.py#L6-L46 |
wooyek/django-powerbank | src/django_powerbank/views/mixins.py | ReturnUrlMx.dispatch | def dispatch(self, request, *args, **kwargs):
"""
Does request processing for return_url query parameter and redirects with it's missing
We can't do that in the get method, as it does not exist in the View base class
and child mixins implementing get do not call super().get
"""
... | python | def dispatch(self, request, *args, **kwargs):
"""
Does request processing for return_url query parameter and redirects with it's missing
We can't do that in the get method, as it does not exist in the View base class
and child mixins implementing get do not call super().get
"""
... | [
"def",
"dispatch",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"return_url",
"=",
"request",
".",
"GET",
".",
"get",
"(",
"'return_url'",
",",
"None",
")",
"referrer",
"=",
"request",
".",
"META",
... | Does request processing for return_url query parameter and redirects with it's missing
We can't do that in the get method, as it does not exist in the View base class
and child mixins implementing get do not call super().get | [
"Does",
"request",
"processing",
"for",
"return_url",
"query",
"parameter",
"and",
"redirects",
"with",
"it",
"s",
"missing"
] | train | https://github.com/wooyek/django-powerbank/blob/df91189f2ac18bacc545ccf3c81c4465fb993949/src/django_powerbank/views/mixins.py#L25-L50 |
AndreLouisCaron/runwith | runwith/__init__.py | main | def main(argv=None):
"""Program entry point."""
# If we're invoked directly (runwith ...), we'll get None here.
if argv is None:
argv = sys.argv[1:]
# Parse command-line arguments.
argv = cli.parse_args(argv)
# Translate CLI arguments to Popen options.
options = {}
for k in ('... | python | def main(argv=None):
"""Program entry point."""
# If we're invoked directly (runwith ...), we'll get None here.
if argv is None:
argv = sys.argv[1:]
# Parse command-line arguments.
argv = cli.parse_args(argv)
# Translate CLI arguments to Popen options.
options = {}
for k in ('... | [
"def",
"main",
"(",
"argv",
"=",
"None",
")",
":",
"# If we're invoked directly (runwith ...), we'll get None here.",
"if",
"argv",
"is",
"None",
":",
"argv",
"=",
"sys",
".",
"argv",
"[",
"1",
":",
"]",
"# Parse command-line arguments.",
"argv",
"=",
"cli",
"."... | Program entry point. | [
"Program",
"entry",
"point",
"."
] | train | https://github.com/AndreLouisCaron/runwith/blob/cfa2b6ae67d73ec5b24f1502a37060d838276e8b/runwith/__init__.py#L51-L94 |
miquelo/resort | packages/resort/component/resource.py | Set.insert | def insert(self, context):
"""
Resolve resoures.
:param resort.engine.execution.Context context:
Current execution context.
"""
self.__resolve(
context,
context.resolve(self.__source_path),
context.resolve(self.__target_path)
) | python | def insert(self, context):
"""
Resolve resoures.
:param resort.engine.execution.Context context:
Current execution context.
"""
self.__resolve(
context,
context.resolve(self.__source_path),
context.resolve(self.__target_path)
) | [
"def",
"insert",
"(",
"self",
",",
"context",
")",
":",
"self",
".",
"__resolve",
"(",
"context",
",",
"context",
".",
"resolve",
"(",
"self",
".",
"__source_path",
")",
",",
"context",
".",
"resolve",
"(",
"self",
".",
"__target_path",
")",
")"
] | Resolve resoures.
:param resort.engine.execution.Context context:
Current execution context. | [
"Resolve",
"resoures",
".",
":",
"param",
"resort",
".",
"engine",
".",
"execution",
".",
"Context",
"context",
":",
"Current",
"execution",
"context",
"."
] | train | https://github.com/miquelo/resort/blob/097a25d3257c91a75c194fd44c2797ab356f85dd/packages/resort/component/resource.py#L89-L102 |
fotonauts/fwissr-python | fwissr/fwissr.py | FwissrModule.global_registry | def global_registry(self):
"""Global Registry
NOTE: Parses main conf files (/etc/fwissr/fwissr.json
and ~/.fwissr/fwissr.json)
then uses 'fwissr_sources' setting to setup additional sources
Example of /etc/fwissr/fwissr.json file:
{
'fwissr_sources': ... | python | def global_registry(self):
"""Global Registry
NOTE: Parses main conf files (/etc/fwissr/fwissr.json
and ~/.fwissr/fwissr.json)
then uses 'fwissr_sources' setting to setup additional sources
Example of /etc/fwissr/fwissr.json file:
{
'fwissr_sources': ... | [
"def",
"global_registry",
"(",
"self",
")",
":",
"if",
"self",
".",
"_global_registry",
"is",
"None",
":",
"if",
"'fwissr_refresh_period'",
"in",
"self",
".",
"main_conf",
":",
"result",
"=",
"Registry",
"(",
"refresh_period",
"=",
"self",
".",
"main_conf",
... | Global Registry
NOTE: Parses main conf files (/etc/fwissr/fwissr.json
and ~/.fwissr/fwissr.json)
then uses 'fwissr_sources' setting to setup additional sources
Example of /etc/fwissr/fwissr.json file:
{
'fwissr_sources': [
{ 'filepath': '/mnt/my_... | [
"Global",
"Registry"
] | train | https://github.com/fotonauts/fwissr-python/blob/4314aa53ca45b4534cd312f6343a88596b4416d4/fwissr/fwissr.py#L70-L117 |
opinkerfi/nago | nago/extensions/info.py | get | def get(security_token=None, key=None):
""" Get information about this node """
if security_token is None:
security_token = nago.core.get_my_info()['host_name']
data = node_data.get(security_token, {})
if not key:
return data
else:
return data.get(key) | python | def get(security_token=None, key=None):
""" Get information about this node """
if security_token is None:
security_token = nago.core.get_my_info()['host_name']
data = node_data.get(security_token, {})
if not key:
return data
else:
return data.get(key) | [
"def",
"get",
"(",
"security_token",
"=",
"None",
",",
"key",
"=",
"None",
")",
":",
"if",
"security_token",
"is",
"None",
":",
"security_token",
"=",
"nago",
".",
"core",
".",
"get_my_info",
"(",
")",
"[",
"'host_name'",
"]",
"data",
"=",
"node_data",
... | Get information about this node | [
"Get",
"information",
"about",
"this",
"node"
] | train | https://github.com/opinkerfi/nago/blob/85e1bdd1de0122f56868a483e7599e1b36a439b0/nago/extensions/info.py#L15-L23 |
opinkerfi/nago | nago/extensions/info.py | post | def post(node_name, key, **kwargs):
""" Give the server information about this node
Arguments:
node -- node_name or token for the node this data belongs to
key -- identifiable key, that you use later to retrieve that piece of data
kwargs -- the data you need to store
"""
node =... | python | def post(node_name, key, **kwargs):
""" Give the server information about this node
Arguments:
node -- node_name or token for the node this data belongs to
key -- identifiable key, that you use later to retrieve that piece of data
kwargs -- the data you need to store
"""
node =... | [
"def",
"post",
"(",
"node_name",
",",
"key",
",",
"*",
"*",
"kwargs",
")",
":",
"node",
"=",
"nago",
".",
"core",
".",
"get_node",
"(",
"node_name",
")",
"if",
"not",
"node",
":",
"raise",
"ValueError",
"(",
"\"Node named %s not found\"",
"%",
"node_name... | Give the server information about this node
Arguments:
node -- node_name or token for the node this data belongs to
key -- identifiable key, that you use later to retrieve that piece of data
kwargs -- the data you need to store | [
"Give",
"the",
"server",
"information",
"about",
"this",
"node"
] | train | https://github.com/opinkerfi/nago/blob/85e1bdd1de0122f56868a483e7599e1b36a439b0/nago/extensions/info.py#L33-L47 |
opinkerfi/nago | nago/extensions/info.py | send | def send(node_name):
""" Send our information to a remote nago instance
Arguments:
node -- node_name or token for the node this data belongs to
"""
my_data = nago.core.get_my_info()
if not node_name:
node_name = nago.settings.get('server')
node = nago.core.get_node(node_name)
... | python | def send(node_name):
""" Send our information to a remote nago instance
Arguments:
node -- node_name or token for the node this data belongs to
"""
my_data = nago.core.get_my_info()
if not node_name:
node_name = nago.settings.get('server')
node = nago.core.get_node(node_name)
... | [
"def",
"send",
"(",
"node_name",
")",
":",
"my_data",
"=",
"nago",
".",
"core",
".",
"get_my_info",
"(",
")",
"if",
"not",
"node_name",
":",
"node_name",
"=",
"nago",
".",
"settings",
".",
"get",
"(",
"'server'",
")",
"node",
"=",
"nago",
".",
"core"... | Send our information to a remote nago instance
Arguments:
node -- node_name or token for the node this data belongs to | [
"Send",
"our",
"information",
"to",
"a",
"remote",
"nago",
"instance"
] | train | https://github.com/opinkerfi/nago/blob/85e1bdd1de0122f56868a483e7599e1b36a439b0/nago/extensions/info.py#L50-L66 |
sandwichcloud/ingredients.tasks | ingredients_tasks/vmware.py | VMWareClient.get_obj | def get_obj(self, vimtype, name, folder=None):
"""
Return an object by name, if name is None the
first found object is returned
"""
obj = None
content = self.service_instance.RetrieveContent()
if folder is None:
folder = content.rootFolder
co... | python | def get_obj(self, vimtype, name, folder=None):
"""
Return an object by name, if name is None the
first found object is returned
"""
obj = None
content = self.service_instance.RetrieveContent()
if folder is None:
folder = content.rootFolder
co... | [
"def",
"get_obj",
"(",
"self",
",",
"vimtype",
",",
"name",
",",
"folder",
"=",
"None",
")",
":",
"obj",
"=",
"None",
"content",
"=",
"self",
".",
"service_instance",
".",
"RetrieveContent",
"(",
")",
"if",
"folder",
"is",
"None",
":",
"folder",
"=",
... | Return an object by name, if name is None the
first found object is returned | [
"Return",
"an",
"object",
"by",
"name",
"if",
"name",
"is",
"None",
"the",
"first",
"found",
"object",
"is",
"returned"
] | train | https://github.com/sandwichcloud/ingredients.tasks/blob/23d2772536f07aa5e4787b7ee67dee2f1faedb08/ingredients_tasks/vmware.py#L220-L238 |
sandwichcloud/ingredients.tasks | ingredients_tasks/vmware.py | VMWareClient.wait_for_tasks | def wait_for_tasks(self, tasks):
"""Given the service instance si and tasks, it returns after all the
tasks are complete
"""
property_collector = self.service_instance.RetrieveContent().propertyCollector
task_list = [str(task) for task in tasks]
# Create filter
obj_... | python | def wait_for_tasks(self, tasks):
"""Given the service instance si and tasks, it returns after all the
tasks are complete
"""
property_collector = self.service_instance.RetrieveContent().propertyCollector
task_list = [str(task) for task in tasks]
# Create filter
obj_... | [
"def",
"wait_for_tasks",
"(",
"self",
",",
"tasks",
")",
":",
"property_collector",
"=",
"self",
".",
"service_instance",
".",
"RetrieveContent",
"(",
")",
".",
"propertyCollector",
"task_list",
"=",
"[",
"str",
"(",
"task",
")",
"for",
"task",
"in",
"tasks"... | Given the service instance si and tasks, it returns after all the
tasks are complete | [
"Given",
"the",
"service",
"instance",
"si",
"and",
"tasks",
"it",
"returns",
"after",
"all",
"the",
"tasks",
"are",
"complete"
] | train | https://github.com/sandwichcloud/ingredients.tasks/blob/23d2772536f07aa5e4787b7ee67dee2f1faedb08/ingredients_tasks/vmware.py#L240-L284 |
Deathnerd/pyterp | pyterp/__init__.py | Brainfuck._run | def _run(self):
"""
This is the logic to run it all.
Heavily influenced by this post: http://nickdesaulniers.github.io/blog/2015/05/25/interpreter-compiler-jit/
:return:
"""
i = 0
try:
while i < len(self.program):
if self.program[i] == ... | python | def _run(self):
"""
This is the logic to run it all.
Heavily influenced by this post: http://nickdesaulniers.github.io/blog/2015/05/25/interpreter-compiler-jit/
:return:
"""
i = 0
try:
while i < len(self.program):
if self.program[i] == ... | [
"def",
"_run",
"(",
"self",
")",
":",
"i",
"=",
"0",
"try",
":",
"while",
"i",
"<",
"len",
"(",
"self",
".",
"program",
")",
":",
"if",
"self",
".",
"program",
"[",
"i",
"]",
"==",
"\">\"",
":",
"self",
".",
"_increment_pointer",
"(",
")",
"eli... | This is the logic to run it all.
Heavily influenced by this post: http://nickdesaulniers.github.io/blog/2015/05/25/interpreter-compiler-jit/
:return: | [
"This",
"is",
"the",
"logic",
"to",
"run",
"it",
"all",
".",
"Heavily",
"influenced",
"by",
"this",
"post",
":",
"http",
":",
"//",
"nickdesaulniers",
".",
"github",
".",
"io",
"/",
"blog",
"/",
"2015",
"/",
"05",
"/",
"25",
"/",
"interpreter",
"-",
... | train | https://github.com/Deathnerd/pyterp/blob/baf2957263685f03873f368226f5752da4e51f08/pyterp/__init__.py#L75-L132 |
Deathnerd/pyterp | pyterp/__init__.py | Brainfuck._increment_pointer | def _increment_pointer(self):
"""
Increments the internal tape counter by 1
:raises PointerOutOfProgramRange: Raises an error if the result of incrementing the pointer would bring
it outside of the tape space on the right
"""
self.pointer += 1
if self.pointer >= l... | python | def _increment_pointer(self):
"""
Increments the internal tape counter by 1
:raises PointerOutOfProgramRange: Raises an error if the result of incrementing the pointer would bring
it outside of the tape space on the right
"""
self.pointer += 1
if self.pointer >= l... | [
"def",
"_increment_pointer",
"(",
"self",
")",
":",
"self",
".",
"pointer",
"+=",
"1",
"if",
"self",
".",
"pointer",
">=",
"len",
"(",
"self",
".",
"tape",
")",
":",
"raise",
"PointerOutOfProgramRange",
"(",
"\"Pointer exceeded right-hand bound of tape\"",
")"
] | Increments the internal tape counter by 1
:raises PointerOutOfProgramRange: Raises an error if the result of incrementing the pointer would bring
it outside of the tape space on the right | [
"Increments",
"the",
"internal",
"tape",
"counter",
"by",
"1",
":",
"raises",
"PointerOutOfProgramRange",
":",
"Raises",
"an",
"error",
"if",
"the",
"result",
"of",
"incrementing",
"the",
"pointer",
"would",
"bring",
"it",
"outside",
"of",
"the",
"tape",
"spac... | train | https://github.com/Deathnerd/pyterp/blob/baf2957263685f03873f368226f5752da4e51f08/pyterp/__init__.py#L134-L142 |
Deathnerd/pyterp | pyterp/__init__.py | Brainfuck._increment_current_byte | def _increment_current_byte(self):
"""
Increments the value of the current byte at the pointer. If the result is over 255,
then it will overflow to 0
"""
# If the current byte is uninitialized, then incrementing it will make it 1
if self.tape[self.pointer] is None:
... | python | def _increment_current_byte(self):
"""
Increments the value of the current byte at the pointer. If the result is over 255,
then it will overflow to 0
"""
# If the current byte is uninitialized, then incrementing it will make it 1
if self.tape[self.pointer] is None:
... | [
"def",
"_increment_current_byte",
"(",
"self",
")",
":",
"# If the current byte is uninitialized, then incrementing it will make it 1",
"if",
"self",
".",
"tape",
"[",
"self",
".",
"pointer",
"]",
"is",
"None",
":",
"self",
".",
"tape",
"[",
"self",
".",
"pointer",
... | Increments the value of the current byte at the pointer. If the result is over 255,
then it will overflow to 0 | [
"Increments",
"the",
"value",
"of",
"the",
"current",
"byte",
"at",
"the",
"pointer",
".",
"If",
"the",
"result",
"is",
"over",
"255",
"then",
"it",
"will",
"overflow",
"to",
"0"
] | train | https://github.com/Deathnerd/pyterp/blob/baf2957263685f03873f368226f5752da4e51f08/pyterp/__init__.py#L154-L165 |
Deathnerd/pyterp | pyterp/__init__.py | Brainfuck._decrement_current_byte | def _decrement_current_byte(self):
"""
Decrements the value of the current byte at the pointer. If the result is below 0,
then it will overflow to 255
"""
# If the current byte is uninitialized, then decrementing it will make it the max cell size
# Otherwise, if it's alre... | python | def _decrement_current_byte(self):
"""
Decrements the value of the current byte at the pointer. If the result is below 0,
then it will overflow to 255
"""
# If the current byte is uninitialized, then decrementing it will make it the max cell size
# Otherwise, if it's alre... | [
"def",
"_decrement_current_byte",
"(",
"self",
")",
":",
"# If the current byte is uninitialized, then decrementing it will make it the max cell size",
"# Otherwise, if it's already at the minimum cell size, then it will also make it the max cell size",
"if",
"self",
".",
"tape",
"[",
"sel... | Decrements the value of the current byte at the pointer. If the result is below 0,
then it will overflow to 255 | [
"Decrements",
"the",
"value",
"of",
"the",
"current",
"byte",
"at",
"the",
"pointer",
".",
"If",
"the",
"result",
"is",
"below",
"0",
"then",
"it",
"will",
"overflow",
"to",
"255"
] | train | https://github.com/Deathnerd/pyterp/blob/baf2957263685f03873f368226f5752da4e51f08/pyterp/__init__.py#L167-L177 |
Deathnerd/pyterp | pyterp/__init__.py | Brainfuck._output_current_byte | def _output_current_byte(self):
"""
Prints out the ASCII value of the current byte
"""
if self.tape[self.pointer] is None:
print "{}".format(chr(0)),
else:
print "{}".format(chr(int(self.tape[self.pointer]))), | python | def _output_current_byte(self):
"""
Prints out the ASCII value of the current byte
"""
if self.tape[self.pointer] is None:
print "{}".format(chr(0)),
else:
print "{}".format(chr(int(self.tape[self.pointer]))), | [
"def",
"_output_current_byte",
"(",
"self",
")",
":",
"if",
"self",
".",
"tape",
"[",
"self",
".",
"pointer",
"]",
"is",
"None",
":",
"print",
"\"{}\"",
".",
"format",
"(",
"chr",
"(",
"0",
")",
")",
",",
"else",
":",
"print",
"\"{}\"",
".",
"forma... | Prints out the ASCII value of the current byte | [
"Prints",
"out",
"the",
"ASCII",
"value",
"of",
"the",
"current",
"byte"
] | train | https://github.com/Deathnerd/pyterp/blob/baf2957263685f03873f368226f5752da4e51f08/pyterp/__init__.py#L179-L186 |
Deathnerd/pyterp | pyterp/__init__.py | Brainfuck._read_byte | def _read_byte(self):
"""
Read a single byte from the user without waiting for the \n character
"""
from .getch import _Getch
try:
g = _Getch()
self.tape[self.pointer] = ord(g())
except TypeError as e:
print "Here's what _Getch() is giv... | python | def _read_byte(self):
"""
Read a single byte from the user without waiting for the \n character
"""
from .getch import _Getch
try:
g = _Getch()
self.tape[self.pointer] = ord(g())
except TypeError as e:
print "Here's what _Getch() is giv... | [
"def",
"_read_byte",
"(",
"self",
")",
":",
"from",
".",
"getch",
"import",
"_Getch",
"try",
":",
"g",
"=",
"_Getch",
"(",
")",
"self",
".",
"tape",
"[",
"self",
".",
"pointer",
"]",
"=",
"ord",
"(",
"g",
"(",
")",
")",
"except",
"TypeError",
"as... | Read a single byte from the user without waiting for the \n character | [
"Read",
"a",
"single",
"byte",
"from",
"the",
"user",
"without",
"waiting",
"for",
"the",
"\\",
"n",
"character"
] | train | https://github.com/Deathnerd/pyterp/blob/baf2957263685f03873f368226f5752da4e51f08/pyterp/__init__.py#L188-L197 |
nicktgr15/sac | sac/methods/self_similarity.py | get_checkerboard_matrix | def get_checkerboard_matrix(kernel_width):
"""
example matrix for width = 2
-1 -1 1 1
-1 -1 1 1
1 1 -1 -1
1 1 -1 -1
:param kernel_width:
:return:
"""
return np.vstack((
np.hstack((
-1 * np.ones((kernel_width, kernel_width)), np.ones... | python | def get_checkerboard_matrix(kernel_width):
"""
example matrix for width = 2
-1 -1 1 1
-1 -1 1 1
1 1 -1 -1
1 1 -1 -1
:param kernel_width:
:return:
"""
return np.vstack((
np.hstack((
-1 * np.ones((kernel_width, kernel_width)), np.ones... | [
"def",
"get_checkerboard_matrix",
"(",
"kernel_width",
")",
":",
"return",
"np",
".",
"vstack",
"(",
"(",
"np",
".",
"hstack",
"(",
"(",
"-",
"1",
"*",
"np",
".",
"ones",
"(",
"(",
"kernel_width",
",",
"kernel_width",
")",
")",
",",
"np",
".",
"ones"... | example matrix for width = 2
-1 -1 1 1
-1 -1 1 1
1 1 -1 -1
1 1 -1 -1
:param kernel_width:
:return: | [
"example",
"matrix",
"for",
"width",
"=",
"2"
] | train | https://github.com/nicktgr15/sac/blob/4b1d5d8e6ca2c437972db34ddc72990860865159/sac/methods/self_similarity.py#L56-L77 |
nicktgr15/sac | sac/methods/self_similarity.py | checkerboard_matrix_filtering | def checkerboard_matrix_filtering(similarity_matrix, kernel_width, peak_range):
"""
Moving the checkerboard matrix over the main diagonal of the similarity matrix one sample at a time.
:param similarity_matrix:
:param peak_range: the number of samples in which the peak detection algorithms finds a peak... | python | def checkerboard_matrix_filtering(similarity_matrix, kernel_width, peak_range):
"""
Moving the checkerboard matrix over the main diagonal of the similarity matrix one sample at a time.
:param similarity_matrix:
:param peak_range: the number of samples in which the peak detection algorithms finds a peak... | [
"def",
"checkerboard_matrix_filtering",
"(",
"similarity_matrix",
",",
"kernel_width",
",",
"peak_range",
")",
":",
"checkerboard_matrix",
"=",
"get_checkerboard_matrix",
"(",
"kernel_width",
")",
"# The values calculated in this step are starting from the 'kernel_width' position and... | Moving the checkerboard matrix over the main diagonal of the similarity matrix one sample at a time.
:param similarity_matrix:
:param peak_range: the number of samples in which the peak detection algorithms finds a peak (TODO:clarify)
:param kernel_width: the size of one quarter of the checkerboard matrix
... | [
"Moving",
"the",
"checkerboard",
"matrix",
"over",
"the",
"main",
"diagonal",
"of",
"the",
"similarity",
"matrix",
"one",
"sample",
"at",
"a",
"time",
"."
] | train | https://github.com/nicktgr15/sac/blob/4b1d5d8e6ca2c437972db34ddc72990860865159/sac/methods/self_similarity.py#L80-L110 |
minhhoit/yacms | yacms/generic/forms.py | KeywordsWidget.decompress | def decompress(self, value):
"""
Takes the sequence of ``AssignedKeyword`` instances and splits
them into lists of keyword IDs and titles each mapping to one
of the form field widgets.
"""
if hasattr(value, "select_related"):
keywords = [a.keyword for a in val... | python | def decompress(self, value):
"""
Takes the sequence of ``AssignedKeyword`` instances and splits
them into lists of keyword IDs and titles each mapping to one
of the form field widgets.
"""
if hasattr(value, "select_related"):
keywords = [a.keyword for a in val... | [
"def",
"decompress",
"(",
"self",
",",
"value",
")",
":",
"if",
"hasattr",
"(",
"value",
",",
"\"select_related\"",
")",
":",
"keywords",
"=",
"[",
"a",
".",
"keyword",
"for",
"a",
"in",
"value",
".",
"select_related",
"(",
"\"keyword\"",
")",
"]",
"if... | Takes the sequence of ``AssignedKeyword`` instances and splits
them into lists of keyword IDs and titles each mapping to one
of the form field widgets. | [
"Takes",
"the",
"sequence",
"of",
"AssignedKeyword",
"instances",
"and",
"splits",
"them",
"into",
"lists",
"of",
"keyword",
"IDs",
"and",
"titles",
"each",
"mapping",
"to",
"one",
"of",
"the",
"form",
"field",
"widgets",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/generic/forms.py#L48-L60 |
minhhoit/yacms | yacms/generic/forms.py | KeywordsWidget.format_output | def format_output(self, rendered_widgets):
"""
Wraps the output HTML with a list of all available ``Keyword``
instances that can be clicked on to toggle a keyword.
"""
rendered = super(KeywordsWidget, self).format_output(rendered_widgets)
links = ""
for keyword in... | python | def format_output(self, rendered_widgets):
"""
Wraps the output HTML with a list of all available ``Keyword``
instances that can be clicked on to toggle a keyword.
"""
rendered = super(KeywordsWidget, self).format_output(rendered_widgets)
links = ""
for keyword in... | [
"def",
"format_output",
"(",
"self",
",",
"rendered_widgets",
")",
":",
"rendered",
"=",
"super",
"(",
"KeywordsWidget",
",",
"self",
")",
".",
"format_output",
"(",
"rendered_widgets",
")",
"links",
"=",
"\"\"",
"for",
"keyword",
"in",
"Keyword",
".",
"obje... | Wraps the output HTML with a list of all available ``Keyword``
instances that can be clicked on to toggle a keyword. | [
"Wraps",
"the",
"output",
"HTML",
"with",
"a",
"list",
"of",
"all",
"available",
"Keyword",
"instances",
"that",
"can",
"be",
"clicked",
"on",
"to",
"toggle",
"a",
"keyword",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/generic/forms.py#L62-L73 |
minhhoit/yacms | yacms/generic/forms.py | ThreadedCommentForm.save | def save(self, request):
"""
Saves a new comment and sends any notification emails.
"""
comment = self.get_comment_object()
obj = comment.content_object
if request.user.is_authenticated():
comment.user = request.user
comment.by_author = request.user ==... | python | def save(self, request):
"""
Saves a new comment and sends any notification emails.
"""
comment = self.get_comment_object()
obj = comment.content_object
if request.user.is_authenticated():
comment.user = request.user
comment.by_author = request.user ==... | [
"def",
"save",
"(",
"self",
",",
"request",
")",
":",
"comment",
"=",
"self",
".",
"get_comment_object",
"(",
")",
"obj",
"=",
"comment",
".",
"content_object",
"if",
"request",
".",
"user",
".",
"is_authenticated",
"(",
")",
":",
"comment",
".",
"user",... | Saves a new comment and sends any notification emails. | [
"Saves",
"a",
"new",
"comment",
"and",
"sends",
"any",
"notification",
"emails",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/generic/forms.py#L131-L172 |
minhhoit/yacms | yacms/generic/forms.py | RatingForm.clean | def clean(self):
"""
Check unauthenticated user's cookie as a light check to
prevent duplicate votes.
"""
bits = (self.data["content_type"], self.data["object_pk"])
request = self.request
self.current = "%s.%s" % bits
self.previous = request.COOKIES.get("y... | python | def clean(self):
"""
Check unauthenticated user's cookie as a light check to
prevent duplicate votes.
"""
bits = (self.data["content_type"], self.data["object_pk"])
request = self.request
self.current = "%s.%s" % bits
self.previous = request.COOKIES.get("y... | [
"def",
"clean",
"(",
"self",
")",
":",
"bits",
"=",
"(",
"self",
".",
"data",
"[",
"\"content_type\"",
"]",
",",
"self",
".",
"data",
"[",
"\"object_pk\"",
"]",
")",
"request",
"=",
"self",
".",
"request",
"self",
".",
"current",
"=",
"\"%s.%s\"",
"%... | Check unauthenticated user's cookie as a light check to
prevent duplicate votes. | [
"Check",
"unauthenticated",
"user",
"s",
"cookie",
"as",
"a",
"light",
"check",
"to",
"prevent",
"duplicate",
"votes",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/generic/forms.py#L197-L209 |
minhhoit/yacms | yacms/generic/forms.py | RatingForm.save | def save(self):
"""
Saves a new rating - authenticated users can update the
value if they've previously rated.
"""
user = self.request.user
self.undoing = False
rating_value = self.cleaned_data["value"]
manager = self.rating_manager
if user.is_aut... | python | def save(self):
"""
Saves a new rating - authenticated users can update the
value if they've previously rated.
"""
user = self.request.user
self.undoing = False
rating_value = self.cleaned_data["value"]
manager = self.rating_manager
if user.is_aut... | [
"def",
"save",
"(",
"self",
")",
":",
"user",
"=",
"self",
".",
"request",
".",
"user",
"self",
".",
"undoing",
"=",
"False",
"rating_value",
"=",
"self",
".",
"cleaned_data",
"[",
"\"value\"",
"]",
"manager",
"=",
"self",
".",
"rating_manager",
"if",
... | Saves a new rating - authenticated users can update the
value if they've previously rated. | [
"Saves",
"a",
"new",
"rating",
"-",
"authenticated",
"users",
"can",
"update",
"the",
"value",
"if",
"they",
"ve",
"previously",
"rated",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/generic/forms.py#L211-L235 |
veltzer/pylogconf | pylogconf/core.py | setup_scrapy | def setup_scrapy():
""" This is not needed as we pass 'LOG_ENABLED':False to scrapy at init time """
def replace_configure_logging(install_root_handler=False, settings=None):
fake_use(install_root_handler)
fake_use(settings)
def replace_log_scrapy_info(settings=None):
fake_use(sett... | python | def setup_scrapy():
""" This is not needed as we pass 'LOG_ENABLED':False to scrapy at init time """
def replace_configure_logging(install_root_handler=False, settings=None):
fake_use(install_root_handler)
fake_use(settings)
def replace_log_scrapy_info(settings=None):
fake_use(sett... | [
"def",
"setup_scrapy",
"(",
")",
":",
"def",
"replace_configure_logging",
"(",
"install_root_handler",
"=",
"False",
",",
"settings",
"=",
"None",
")",
":",
"fake_use",
"(",
"install_root_handler",
")",
"fake_use",
"(",
"settings",
")",
"def",
"replace_log_scrapy_... | This is not needed as we pass 'LOG_ENABLED':False to scrapy at init time | [
"This",
"is",
"not",
"needed",
"as",
"we",
"pass",
"LOG_ENABLED",
":",
"False",
"to",
"scrapy",
"at",
"init",
"time"
] | train | https://github.com/veltzer/pylogconf/blob/a3e230a073380b43b5d5096f40bb37ae28f3e430/pylogconf/core.py#L20-L40 |
veltzer/pylogconf | pylogconf/core.py | setup_exceptions | def setup_exceptions():
""" Only print the heart of the exception and not the stack trace """
# first set up the variables needed by the _excepthook function
global _print_traceback, _drill
local_print_traceback = os.getenv("PYLOGCONF_PRINT_TRACEBACK")
if local_print_traceback is not None:
_... | python | def setup_exceptions():
""" Only print the heart of the exception and not the stack trace """
# first set up the variables needed by the _excepthook function
global _print_traceback, _drill
local_print_traceback = os.getenv("PYLOGCONF_PRINT_TRACEBACK")
if local_print_traceback is not None:
_... | [
"def",
"setup_exceptions",
"(",
")",
":",
"# first set up the variables needed by the _excepthook function",
"global",
"_print_traceback",
",",
"_drill",
"local_print_traceback",
"=",
"os",
".",
"getenv",
"(",
"\"PYLOGCONF_PRINT_TRACEBACK\"",
")",
"if",
"local_print_traceback",... | Only print the heart of the exception and not the stack trace | [
"Only",
"print",
"the",
"heart",
"of",
"the",
"exception",
"and",
"not",
"the",
"stack",
"trace"
] | train | https://github.com/veltzer/pylogconf/blob/a3e230a073380b43b5d5096f40bb37ae28f3e430/pylogconf/core.py#L73-L84 |
veltzer/pylogconf | pylogconf/core.py | setup_logging | def setup_logging():
""" setup the logging system """
default_path_yaml = os.path.expanduser('~/.pylogconf.yaml')
default_path_conf = os.path.expanduser('~/.pylogconf.conf')
# this matches the default logging level of the logging
# library and makes sense...
default_level = logging.WARNING
... | python | def setup_logging():
""" setup the logging system """
default_path_yaml = os.path.expanduser('~/.pylogconf.yaml')
default_path_conf = os.path.expanduser('~/.pylogconf.conf')
# this matches the default logging level of the logging
# library and makes sense...
default_level = logging.WARNING
... | [
"def",
"setup_logging",
"(",
")",
":",
"default_path_yaml",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"'~/.pylogconf.yaml'",
")",
"default_path_conf",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"'~/.pylogconf.conf'",
")",
"# this matches the default loggi... | setup the logging system | [
"setup",
"the",
"logging",
"system"
] | train | https://github.com/veltzer/pylogconf/blob/a3e230a073380b43b5d5096f40bb37ae28f3e430/pylogconf/core.py#L87-L122 |
awacha/credolib | credolib/procedures.py | summarize | def summarize(reintegrate=True, dist_tolerance=3, qranges=None,
samples=None, raw=False, late_radavg=True, graph_ncols=3,
std_multiplier=3, graph_extension='png',
graph_dpi=80, correlmatrix_colormap='coolwarm',
image_colormap='viridis', correlmatrix_logarithmic=Tr... | python | def summarize(reintegrate=True, dist_tolerance=3, qranges=None,
samples=None, raw=False, late_radavg=True, graph_ncols=3,
std_multiplier=3, graph_extension='png',
graph_dpi=80, correlmatrix_colormap='coolwarm',
image_colormap='viridis', correlmatrix_logarithmic=Tr... | [
"def",
"summarize",
"(",
"reintegrate",
"=",
"True",
",",
"dist_tolerance",
"=",
"3",
",",
"qranges",
"=",
"None",
",",
"samples",
"=",
"None",
",",
"raw",
"=",
"False",
",",
"late_radavg",
"=",
"True",
",",
"graph_ncols",
"=",
"3",
",",
"std_multiplier"... | Summarize scattering patterns and curves for all samples defined
by the global `allsamplenames`.
Inputs:
reintegrate (bool, default=True): if the curves are to be obained
by reintegrating the patterns. Otherwise 1D curves are loaded.
dist_tolerance (float, default=3): sample-to... | [
"Summarize",
"scattering",
"patterns",
"and",
"curves",
"for",
"all",
"samples",
"defined",
"by",
"the",
"global",
"allsamplenames",
".",
"Inputs",
":",
"reintegrate",
"(",
"bool",
"default",
"=",
"True",
")",
":",
"if",
"the",
"curves",
"are",
"to",
"be",
... | train | https://github.com/awacha/credolib/blob/11c0be3eea7257d3d6e13697d3e76ce538f2f1b2/credolib/procedures.py#L136-L367 |
awacha/credolib | credolib/procedures.py | _merge_two_curves | def _merge_two_curves(curve1: Curve, curve2: Curve, qmin, qmax, qsep, use_additive_constant=False):
"""Merge two scattering curves
:param curve1: the first curve (longer distance)
:type curve1: sastool.classes.curve.GeneralCurve
:param curve2: the second curve (shorter distance)
:type curve2: sasto... | python | def _merge_two_curves(curve1: Curve, curve2: Curve, qmin, qmax, qsep, use_additive_constant=False):
"""Merge two scattering curves
:param curve1: the first curve (longer distance)
:type curve1: sastool.classes.curve.GeneralCurve
:param curve2: the second curve (shorter distance)
:type curve2: sasto... | [
"def",
"_merge_two_curves",
"(",
"curve1",
":",
"Curve",
",",
"curve2",
":",
"Curve",
",",
"qmin",
",",
"qmax",
",",
"qsep",
",",
"use_additive_constant",
"=",
"False",
")",
":",
"curve1",
"=",
"curve1",
".",
"sanitize",
"(",
")",
"curve2",
"=",
"curve2"... | Merge two scattering curves
:param curve1: the first curve (longer distance)
:type curve1: sastool.classes.curve.GeneralCurve
:param curve2: the second curve (shorter distance)
:type curve2: sastool.classes.curve.GeneralCurve
:param qmin: lower bound of the interval for determining the scaling fact... | [
"Merge",
"two",
"scattering",
"curves"
] | train | https://github.com/awacha/credolib/blob/11c0be3eea7257d3d6e13697d3e76ce538f2f1b2/credolib/procedures.py#L370-L401 |
awacha/credolib | credolib/procedures.py | subtract_bg | def subtract_bg(samplename, bgname, factor=1, distance=None, disttolerance=2,
subname=None, qrange=(), graph_extension='png', graph_dpi=80):
"""Subtract background from measurements.
Inputs:
samplename: the name of the sample
bgname: the name of the background measurements. Alte... | python | def subtract_bg(samplename, bgname, factor=1, distance=None, disttolerance=2,
subname=None, qrange=(), graph_extension='png', graph_dpi=80):
"""Subtract background from measurements.
Inputs:
samplename: the name of the sample
bgname: the name of the background measurements. Alte... | [
"def",
"subtract_bg",
"(",
"samplename",
",",
"bgname",
",",
"factor",
"=",
"1",
",",
"distance",
"=",
"None",
",",
"disttolerance",
"=",
"2",
",",
"subname",
"=",
"None",
",",
"qrange",
"=",
"(",
")",
",",
"graph_extension",
"=",
"'png'",
",",
"graph_... | Subtract background from measurements.
Inputs:
samplename: the name of the sample
bgname: the name of the background measurements. Alternatively, it can
be a numeric value (float or ErrorValue), which will be subtracted.
If None, this constant will be determined by integrati... | [
"Subtract",
"background",
"from",
"measurements",
"."
] | train | https://github.com/awacha/credolib/blob/11c0be3eea7257d3d6e13697d3e76ce538f2f1b2/credolib/procedures.py#L519-L602 |
monkeython/scriba | scriba/schemes/scriba_ftp.py | write | def write(url, content, **args):
"""Put an object into a ftp URL."""
with FTPResource(url, **args) as resource:
resource.write(content) | python | def write(url, content, **args):
"""Put an object into a ftp URL."""
with FTPResource(url, **args) as resource:
resource.write(content) | [
"def",
"write",
"(",
"url",
",",
"content",
",",
"*",
"*",
"args",
")",
":",
"with",
"FTPResource",
"(",
"url",
",",
"*",
"*",
"args",
")",
"as",
"resource",
":",
"resource",
".",
"write",
"(",
"content",
")"
] | Put an object into a ftp URL. | [
"Put",
"an",
"object",
"into",
"a",
"ftp",
"URL",
"."
] | train | https://github.com/monkeython/scriba/blob/fb8e7636ed07c3d035433fdd153599ac8b24dfc4/scriba/schemes/scriba_ftp.py#L84-L87 |
tylerbutler/propane | propane/filetools.py | calc_sha | def calc_sha(obj):
"""Calculates the base64-encoded SHA hash of a file."""
try:
pathfile = Path(obj)
except UnicodeDecodeError:
pathfile = None
sha = hashlib.sha256()
try:
if pathfile and pathfile.exists():
return base64.b64encode(pathfile.read_hash('SHA256'))
... | python | def calc_sha(obj):
"""Calculates the base64-encoded SHA hash of a file."""
try:
pathfile = Path(obj)
except UnicodeDecodeError:
pathfile = None
sha = hashlib.sha256()
try:
if pathfile and pathfile.exists():
return base64.b64encode(pathfile.read_hash('SHA256'))
... | [
"def",
"calc_sha",
"(",
"obj",
")",
":",
"try",
":",
"pathfile",
"=",
"Path",
"(",
"obj",
")",
"except",
"UnicodeDecodeError",
":",
"pathfile",
"=",
"None",
"sha",
"=",
"hashlib",
".",
"sha256",
"(",
")",
"try",
":",
"if",
"pathfile",
"and",
"pathfile"... | Calculates the base64-encoded SHA hash of a file. | [
"Calculates",
"the",
"base64",
"-",
"encoded",
"SHA",
"hash",
"of",
"a",
"file",
"."
] | train | https://github.com/tylerbutler/propane/blob/6c404285ab8d78865b7175a5c8adf8fae12d6be5/propane/filetools.py#L13-L44 |
minhhoit/yacms | yacms/blog/templatetags/blog_tags.py | blog_months | def blog_months(*args):
"""
Put a list of dates for blog posts into the template context.
"""
dates = BlogPost.objects.published().values_list("publish_date", flat=True)
date_dicts = [{"date": datetime(d.year, d.month, 1)} for d in dates]
month_dicts = []
for date_dict in date_dicts:
... | python | def blog_months(*args):
"""
Put a list of dates for blog posts into the template context.
"""
dates = BlogPost.objects.published().values_list("publish_date", flat=True)
date_dicts = [{"date": datetime(d.year, d.month, 1)} for d in dates]
month_dicts = []
for date_dict in date_dicts:
... | [
"def",
"blog_months",
"(",
"*",
"args",
")",
":",
"dates",
"=",
"BlogPost",
".",
"objects",
".",
"published",
"(",
")",
".",
"values_list",
"(",
"\"publish_date\"",
",",
"flat",
"=",
"True",
")",
"date_dicts",
"=",
"[",
"{",
"\"date\"",
":",
"datetime",
... | Put a list of dates for blog posts into the template context. | [
"Put",
"a",
"list",
"of",
"dates",
"for",
"blog",
"posts",
"into",
"the",
"template",
"context",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/blog/templatetags/blog_tags.py#L18-L30 |
minhhoit/yacms | yacms/blog/templatetags/blog_tags.py | blog_categories | def blog_categories(*args):
"""
Put a list of categories for blog posts into the template context.
"""
posts = BlogPost.objects.published()
categories = BlogCategory.objects.filter(blogposts__in=posts)
return list(categories.annotate(post_count=Count("blogposts"))) | python | def blog_categories(*args):
"""
Put a list of categories for blog posts into the template context.
"""
posts = BlogPost.objects.published()
categories = BlogCategory.objects.filter(blogposts__in=posts)
return list(categories.annotate(post_count=Count("blogposts"))) | [
"def",
"blog_categories",
"(",
"*",
"args",
")",
":",
"posts",
"=",
"BlogPost",
".",
"objects",
".",
"published",
"(",
")",
"categories",
"=",
"BlogCategory",
".",
"objects",
".",
"filter",
"(",
"blogposts__in",
"=",
"posts",
")",
"return",
"list",
"(",
... | Put a list of categories for blog posts into the template context. | [
"Put",
"a",
"list",
"of",
"categories",
"for",
"blog",
"posts",
"into",
"the",
"template",
"context",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/blog/templatetags/blog_tags.py#L34-L40 |
minhhoit/yacms | yacms/blog/templatetags/blog_tags.py | blog_authors | def blog_authors(*args):
"""
Put a list of authors (users) for blog posts into the template context.
"""
blog_posts = BlogPost.objects.published()
authors = User.objects.filter(blogposts__in=blog_posts)
return list(authors.annotate(post_count=Count("blogposts"))) | python | def blog_authors(*args):
"""
Put a list of authors (users) for blog posts into the template context.
"""
blog_posts = BlogPost.objects.published()
authors = User.objects.filter(blogposts__in=blog_posts)
return list(authors.annotate(post_count=Count("blogposts"))) | [
"def",
"blog_authors",
"(",
"*",
"args",
")",
":",
"blog_posts",
"=",
"BlogPost",
".",
"objects",
".",
"published",
"(",
")",
"authors",
"=",
"User",
".",
"objects",
".",
"filter",
"(",
"blogposts__in",
"=",
"blog_posts",
")",
"return",
"list",
"(",
"aut... | Put a list of authors (users) for blog posts into the template context. | [
"Put",
"a",
"list",
"of",
"authors",
"(",
"users",
")",
"for",
"blog",
"posts",
"into",
"the",
"template",
"context",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/blog/templatetags/blog_tags.py#L44-L50 |
minhhoit/yacms | yacms/blog/templatetags/blog_tags.py | blog_recent_posts | def blog_recent_posts(limit=5, tag=None, username=None, category=None):
"""
Put a list of recently published blog posts into the template
context. A tag title or slug, category title or slug or author's
username can also be specified to filter the recent posts returned.
Usage::
{% blog_rec... | python | def blog_recent_posts(limit=5, tag=None, username=None, category=None):
"""
Put a list of recently published blog posts into the template
context. A tag title or slug, category title or slug or author's
username can also be specified to filter the recent posts returned.
Usage::
{% blog_rec... | [
"def",
"blog_recent_posts",
"(",
"limit",
"=",
"5",
",",
"tag",
"=",
"None",
",",
"username",
"=",
"None",
",",
"category",
"=",
"None",
")",
":",
"blog_posts",
"=",
"BlogPost",
".",
"objects",
".",
"published",
"(",
")",
".",
"select_related",
"(",
"\... | Put a list of recently published blog posts into the template
context. A tag title or slug, category title or slug or author's
username can also be specified to filter the recent posts returned.
Usage::
{% blog_recent_posts 5 as recent_posts %}
{% blog_recent_posts limit=5 tag="django" as ... | [
"Put",
"a",
"list",
"of",
"recently",
"published",
"blog",
"posts",
"into",
"the",
"template",
"context",
".",
"A",
"tag",
"title",
"or",
"slug",
"category",
"title",
"or",
"slug",
"or",
"author",
"s",
"username",
"can",
"also",
"be",
"specified",
"to",
... | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/blog/templatetags/blog_tags.py#L54-L88 |
calvinku96/labreporthelper | labreporthelper/bestfit/expfit.py | ExpFit.do_bestfit | def do_bestfit(self):
"""
Method to get fit_args after getting necessary variables
"""
self.check_important_variables()
logx = np.log(self.args["x"])
logy = np.log(self.args["y"])
self.fit_args_log = np.polyfit(logx, logy, 1)
self.fit_args = self.fit_args_... | python | def do_bestfit(self):
"""
Method to get fit_args after getting necessary variables
"""
self.check_important_variables()
logx = np.log(self.args["x"])
logy = np.log(self.args["y"])
self.fit_args_log = np.polyfit(logx, logy, 1)
self.fit_args = self.fit_args_... | [
"def",
"do_bestfit",
"(",
"self",
")",
":",
"self",
".",
"check_important_variables",
"(",
")",
"logx",
"=",
"np",
".",
"log",
"(",
"self",
".",
"args",
"[",
"\"x\"",
"]",
")",
"logy",
"=",
"np",
".",
"log",
"(",
"self",
".",
"args",
"[",
"\"y\"",
... | Method to get fit_args after getting necessary variables | [
"Method",
"to",
"get",
"fit_args",
"after",
"getting",
"necessary",
"variables"
] | train | https://github.com/calvinku96/labreporthelper/blob/4d436241f389c02eb188c313190df62ab28c3763/labreporthelper/bestfit/expfit.py#L22-L33 |
calvinku96/labreporthelper | labreporthelper/bestfit/expfit.py | ExpFit.bestfit_func | def bestfit_func(self, bestfit_x):
"""
Returns bestfit_function
args:
bestfit_x: scalar, array_like
x value
return: scalar, array_like
bestfit y value
"""
if not self.done_bestfit:
raise KeyError("Do do_bestfit first")
... | python | def bestfit_func(self, bestfit_x):
"""
Returns bestfit_function
args:
bestfit_x: scalar, array_like
x value
return: scalar, array_like
bestfit y value
"""
if not self.done_bestfit:
raise KeyError("Do do_bestfit first")
... | [
"def",
"bestfit_func",
"(",
"self",
",",
"bestfit_x",
")",
":",
"if",
"not",
"self",
".",
"done_bestfit",
":",
"raise",
"KeyError",
"(",
"\"Do do_bestfit first\"",
")",
"bestfit_y",
"=",
"self",
".",
"fit_args",
"[",
"1",
"]",
"*",
"(",
"bestfit_x",
"**",
... | Returns bestfit_function
args:
bestfit_x: scalar, array_like
x value
return: scalar, array_like
bestfit y value | [
"Returns",
"bestfit_function"
] | train | https://github.com/calvinku96/labreporthelper/blob/4d436241f389c02eb188c313190df62ab28c3763/labreporthelper/bestfit/expfit.py#L35-L48 |
soasme/rio-client | rio_client/contrib/flask.py | Rio.emit | def emit(self, action, payload, level=Level.INSTANT):
"""Emit action."""
if level == self.Level.INSTANT:
return self.emit_instantly(action, payload)
elif level == self.Level.CONTEXTUAL:
return self.emit_contextually(action, payload)
elif level == self.Level.DELAY:... | python | def emit(self, action, payload, level=Level.INSTANT):
"""Emit action."""
if level == self.Level.INSTANT:
return self.emit_instantly(action, payload)
elif level == self.Level.CONTEXTUAL:
return self.emit_contextually(action, payload)
elif level == self.Level.DELAY:... | [
"def",
"emit",
"(",
"self",
",",
"action",
",",
"payload",
",",
"level",
"=",
"Level",
".",
"INSTANT",
")",
":",
"if",
"level",
"==",
"self",
".",
"Level",
".",
"INSTANT",
":",
"return",
"self",
".",
"emit_instantly",
"(",
"action",
",",
"payload",
"... | Emit action. | [
"Emit",
"action",
"."
] | train | https://github.com/soasme/rio-client/blob/c6d684c6f9deea5b43f2b05bcaf40714c48b5619/rio_client/contrib/flask.py#L66-L75 |
soasme/rio-client | rio_client/contrib/flask.py | Rio.emit_contextually | def emit_contextually(self, action, payload):
""" Emit on exiting request context."""
self.dump(action, payload)
return g.rio_client_contextual.append((action, payload, )) | python | def emit_contextually(self, action, payload):
""" Emit on exiting request context."""
self.dump(action, payload)
return g.rio_client_contextual.append((action, payload, )) | [
"def",
"emit_contextually",
"(",
"self",
",",
"action",
",",
"payload",
")",
":",
"self",
".",
"dump",
"(",
"action",
",",
"payload",
")",
"return",
"g",
".",
"rio_client_contextual",
".",
"append",
"(",
"(",
"action",
",",
"payload",
",",
")",
")"
] | Emit on exiting request context. | [
"Emit",
"on",
"exiting",
"request",
"context",
"."
] | train | https://github.com/soasme/rio-client/blob/c6d684c6f9deea5b43f2b05bcaf40714c48b5619/rio_client/contrib/flask.py#L81-L84 |
soasme/rio-client | rio_client/contrib/flask.py | Rio.current | def current(self):
"""A namedtuple contains `uuid`, `project`, `action`.
Example::
@app.route('/webhook/broadcast-news')
def broadcast_news():
if rio.current.action.startswith('news-'):
broadcast(request.get_json())
"""
event ... | python | def current(self):
"""A namedtuple contains `uuid`, `project`, `action`.
Example::
@app.route('/webhook/broadcast-news')
def broadcast_news():
if rio.current.action.startswith('news-'):
broadcast(request.get_json())
"""
event ... | [
"def",
"current",
"(",
"self",
")",
":",
"event",
"=",
"request",
".",
"headers",
".",
"get",
"(",
"'X-RIO-EVENT'",
")",
"data",
"=",
"dict",
"(",
"[",
"elem",
".",
"split",
"(",
"'='",
")",
"for",
"elem",
"in",
"event",
".",
"split",
"(",
"','",
... | A namedtuple contains `uuid`, `project`, `action`.
Example::
@app.route('/webhook/broadcast-news')
def broadcast_news():
if rio.current.action.startswith('news-'):
broadcast(request.get_json()) | [
"A",
"namedtuple",
"contains",
"uuid",
"project",
"action",
"."
] | train | https://github.com/soasme/rio-client/blob/c6d684c6f9deea5b43f2b05bcaf40714c48b5619/rio_client/contrib/flask.py#L111-L123 |
jkenlooper/chill | src/chill/script.py | init | def init():
"Initialize the current directory with base starting files and database."
if not os.path.exists('site.cfg'):
f = open('site.cfg', 'w')
f.write(SITECFG)
f.close()
try:
os.mkdir('queries')
except OSError:
pass
try:
os.mkdir('templates')
... | python | def init():
"Initialize the current directory with base starting files and database."
if not os.path.exists('site.cfg'):
f = open('site.cfg', 'w')
f.write(SITECFG)
f.close()
try:
os.mkdir('queries')
except OSError:
pass
try:
os.mkdir('templates')
... | [
"def",
"init",
"(",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"'site.cfg'",
")",
":",
"f",
"=",
"open",
"(",
"'site.cfg'",
",",
"'w'",
")",
"f",
".",
"write",
"(",
"SITECFG",
")",
"f",
".",
"close",
"(",
")",
"try",
":",
"... | Initialize the current directory with base starting files and database. | [
"Initialize",
"the",
"current",
"directory",
"with",
"base",
"starting",
"files",
"and",
"database",
"."
] | train | https://github.com/jkenlooper/chill/blob/35360c17c2a3b769ecb5406c6dabcf4cc70bd76f/src/chill/script.py#L170-L217 |
jkenlooper/chill | src/chill/script.py | operate | def operate(config):
"Interface to do simple operations on the database."
app = make_app(config=config)
print "Operate Mode"
with app.app_context():
operate_menu() | python | def operate(config):
"Interface to do simple operations on the database."
app = make_app(config=config)
print "Operate Mode"
with app.app_context():
operate_menu() | [
"def",
"operate",
"(",
"config",
")",
":",
"app",
"=",
"make_app",
"(",
"config",
"=",
"config",
")",
"print",
"\"Operate Mode\"",
"with",
"app",
".",
"app_context",
"(",
")",
":",
"operate_menu",
"(",
")"
] | Interface to do simple operations on the database. | [
"Interface",
"to",
"do",
"simple",
"operations",
"on",
"the",
"database",
"."
] | train | https://github.com/jkenlooper/chill/blob/35360c17c2a3b769ecb5406c6dabcf4cc70bd76f/src/chill/script.py#L219-L226 |
jkenlooper/chill | src/chill/script.py | run | def run(config):
"Start the web server in the foreground. Don't use for production."
app = make_app(config=config)
app.run(
host=app.config.get("HOST", '127.0.0.1'),
port=app.config.get("PORT", 5000),
use_reloader=True,
) | python | def run(config):
"Start the web server in the foreground. Don't use for production."
app = make_app(config=config)
app.run(
host=app.config.get("HOST", '127.0.0.1'),
port=app.config.get("PORT", 5000),
use_reloader=True,
) | [
"def",
"run",
"(",
"config",
")",
":",
"app",
"=",
"make_app",
"(",
"config",
"=",
"config",
")",
"app",
".",
"run",
"(",
"host",
"=",
"app",
".",
"config",
".",
"get",
"(",
"\"HOST\"",
",",
"'127.0.0.1'",
")",
",",
"port",
"=",
"app",
".",
"conf... | Start the web server in the foreground. Don't use for production. | [
"Start",
"the",
"web",
"server",
"in",
"the",
"foreground",
".",
"Don",
"t",
"use",
"for",
"production",
"."
] | train | https://github.com/jkenlooper/chill/blob/35360c17c2a3b769ecb5406c6dabcf4cc70bd76f/src/chill/script.py#L237-L245 |
jkenlooper/chill | src/chill/script.py | serve | def serve(config):
"Serve the app with Gevent"
from gevent.pywsgi import WSGIServer
app = make_app(config=config)
host = app.config.get("HOST", '127.0.0.1')
port = app.config.get("PORT", 5000)
http_server = WSGIServer((host, port), app)
http_server.serve_forever() | python | def serve(config):
"Serve the app with Gevent"
from gevent.pywsgi import WSGIServer
app = make_app(config=config)
host = app.config.get("HOST", '127.0.0.1')
port = app.config.get("PORT", 5000)
http_server = WSGIServer((host, port), app)
http_server.serve_forever() | [
"def",
"serve",
"(",
"config",
")",
":",
"from",
"gevent",
".",
"pywsgi",
"import",
"WSGIServer",
"app",
"=",
"make_app",
"(",
"config",
"=",
"config",
")",
"host",
"=",
"app",
".",
"config",
".",
"get",
"(",
"\"HOST\"",
",",
"'127.0.0.1'",
")",
"port"... | Serve the app with Gevent | [
"Serve",
"the",
"app",
"with",
"Gevent"
] | train | https://github.com/jkenlooper/chill/blob/35360c17c2a3b769ecb5406c6dabcf4cc70bd76f/src/chill/script.py#L248-L257 |
jkenlooper/chill | src/chill/script.py | freeze | def freeze(config, urls_file=None):
"""Freeze the application by creating a static version of it."""
if urls_file:
app = make_app(config=config, URLS_FILE=urls_file)
else:
app = make_app(config=config)
app.logger.info('freezing app to directory: %s' % app.config['FREEZER_DESTINATION'])
... | python | def freeze(config, urls_file=None):
"""Freeze the application by creating a static version of it."""
if urls_file:
app = make_app(config=config, URLS_FILE=urls_file)
else:
app = make_app(config=config)
app.logger.info('freezing app to directory: %s' % app.config['FREEZER_DESTINATION'])
... | [
"def",
"freeze",
"(",
"config",
",",
"urls_file",
"=",
"None",
")",
":",
"if",
"urls_file",
":",
"app",
"=",
"make_app",
"(",
"config",
"=",
"config",
",",
"URLS_FILE",
"=",
"urls_file",
")",
"else",
":",
"app",
"=",
"make_app",
"(",
"config",
"=",
"... | Freeze the application by creating a static version of it. | [
"Freeze",
"the",
"application",
"by",
"creating",
"a",
"static",
"version",
"of",
"it",
"."
] | train | https://github.com/jkenlooper/chill/blob/35360c17c2a3b769ecb5406c6dabcf4cc70bd76f/src/chill/script.py#L261-L355 |
nsavch/python-dpcolors | dpcolors/__init__.py | Color8Bit.to_irc | def to_irc(self) -> int:
"""
Convert to mIRC color Code
:return: IRC color code
"""
d = {
(self.BLACK, True): 14,
(self.BLACK, False): 1,
(self.RED, True): 4,
(self.RED, False): 5,
(self.GREEN, True): 9,
(sel... | python | def to_irc(self) -> int:
"""
Convert to mIRC color Code
:return: IRC color code
"""
d = {
(self.BLACK, True): 14,
(self.BLACK, False): 1,
(self.RED, True): 4,
(self.RED, False): 5,
(self.GREEN, True): 9,
(sel... | [
"def",
"to_irc",
"(",
"self",
")",
"->",
"int",
":",
"d",
"=",
"{",
"(",
"self",
".",
"BLACK",
",",
"True",
")",
":",
"14",
",",
"(",
"self",
".",
"BLACK",
",",
"False",
")",
":",
"1",
",",
"(",
"self",
".",
"RED",
",",
"True",
")",
":",
... | Convert to mIRC color Code
:return: IRC color code | [
"Convert",
"to",
"mIRC",
"color",
"Code",
":",
"return",
":",
"IRC",
"color",
"code"
] | train | https://github.com/nsavch/python-dpcolors/blob/9bca11416a21eca1c5a84b7dcc852d231d911981/dpcolors/__init__.py#L30-L53 |
nsavch/python-dpcolors | dpcolors/__init__.py | Color8Bit.to_name | def to_name(self) -> str:
"""
Convert to ANSI color name
:return: ANSI color name
"""
return {
self.BLACK: 'black',
self.RED: 'red',
self.GREEN: 'green',
self.YELLOW: 'yellow',
self.BLUE: 'blue',
self.MAGENTA... | python | def to_name(self) -> str:
"""
Convert to ANSI color name
:return: ANSI color name
"""
return {
self.BLACK: 'black',
self.RED: 'red',
self.GREEN: 'green',
self.YELLOW: 'yellow',
self.BLUE: 'blue',
self.MAGENTA... | [
"def",
"to_name",
"(",
"self",
")",
"->",
"str",
":",
"return",
"{",
"self",
".",
"BLACK",
":",
"'black'",
",",
"self",
".",
"RED",
":",
"'red'",
",",
"self",
".",
"GREEN",
":",
"'green'",
",",
"self",
".",
"YELLOW",
":",
"'yellow'",
",",
"self",
... | Convert to ANSI color name
:return: ANSI color name | [
"Convert",
"to",
"ANSI",
"color",
"name",
":",
"return",
":",
"ANSI",
"color",
"name"
] | train | https://github.com/nsavch/python-dpcolors/blob/9bca11416a21eca1c5a84b7dcc852d231d911981/dpcolors/__init__.py#L55-L69 |
nsavch/python-dpcolors | dpcolors/__init__.py | ColorRGB.scale | def scale(self, new_max_value=1):
"""
Scale R, G and B parameters
:param new_max_value: how much to scale
:return: a new ColorRGB instance
"""
f = new_max_value / self.max
return ColorRGB(self.r * f,
self.g * f,
self... | python | def scale(self, new_max_value=1):
"""
Scale R, G and B parameters
:param new_max_value: how much to scale
:return: a new ColorRGB instance
"""
f = new_max_value / self.max
return ColorRGB(self.r * f,
self.g * f,
self... | [
"def",
"scale",
"(",
"self",
",",
"new_max_value",
"=",
"1",
")",
":",
"f",
"=",
"new_max_value",
"/",
"self",
".",
"max",
"return",
"ColorRGB",
"(",
"self",
".",
"r",
"*",
"f",
",",
"self",
".",
"g",
"*",
"f",
",",
"self",
".",
"b",
"*",
"f",
... | Scale R, G and B parameters
:param new_max_value: how much to scale
:return: a new ColorRGB instance | [
"Scale",
"R",
"G",
"and",
"B",
"parameters",
":",
"param",
"new_max_value",
":",
"how",
"much",
"to",
"scale",
":",
"return",
":",
"a",
"new",
"ColorRGB",
"instance"
] | train | https://github.com/nsavch/python-dpcolors/blob/9bca11416a21eca1c5a84b7dcc852d231d911981/dpcolors/__init__.py#L91-L101 |
nsavch/python-dpcolors | dpcolors/__init__.py | ColorRGB.to_8bit | def to_8bit(self):
"""
Convert to 8-bit color
:return: Color8Bit instance
"""
h, s, v = colorsys.rgb_to_hsv(*self.scale(1))
# Check if the color is a shade of grey
if s * v < 0.3:
if v < 0.3:
return Color8Bit(Color8Bit.BLACK, False)
... | python | def to_8bit(self):
"""
Convert to 8-bit color
:return: Color8Bit instance
"""
h, s, v = colorsys.rgb_to_hsv(*self.scale(1))
# Check if the color is a shade of grey
if s * v < 0.3:
if v < 0.3:
return Color8Bit(Color8Bit.BLACK, False)
... | [
"def",
"to_8bit",
"(",
"self",
")",
":",
"h",
",",
"s",
",",
"v",
"=",
"colorsys",
".",
"rgb_to_hsv",
"(",
"*",
"self",
".",
"scale",
"(",
"1",
")",
")",
"# Check if the color is a shade of grey",
"if",
"s",
"*",
"v",
"<",
"0.3",
":",
"if",
"v",
"<... | Convert to 8-bit color
:return: Color8Bit instance | [
"Convert",
"to",
"8",
"-",
"bit",
"color",
":",
"return",
":",
"Color8Bit",
"instance"
] | train | https://github.com/nsavch/python-dpcolors/blob/9bca11416a21eca1c5a84b7dcc852d231d911981/dpcolors/__init__.py#L110-L142 |
nsavch/python-dpcolors | dpcolors/__init__.py | ColorPart.to_dp | def to_dp(self):
"""
Convert to darkplaces color format
:return:
"""
text = self.text.replace('^', '^^')
return '%s%s' % (self.color.to_dp(), text) | python | def to_dp(self):
"""
Convert to darkplaces color format
:return:
"""
text = self.text.replace('^', '^^')
return '%s%s' % (self.color.to_dp(), text) | [
"def",
"to_dp",
"(",
"self",
")",
":",
"text",
"=",
"self",
".",
"text",
".",
"replace",
"(",
"'^'",
",",
"'^^'",
")",
"return",
"'%s%s'",
"%",
"(",
"self",
".",
"color",
".",
"to_dp",
"(",
")",
",",
"text",
")"
] | Convert to darkplaces color format
:return: | [
"Convert",
"to",
"darkplaces",
"color",
"format",
":",
"return",
":"
] | train | https://github.com/nsavch/python-dpcolors/blob/9bca11416a21eca1c5a84b7dcc852d231d911981/dpcolors/__init__.py#L187-L193 |
nsavch/python-dpcolors | dpcolors/__init__.py | ColorPart.to_irc | def to_irc(self):
"""
Convert to mIRC color format
:return:
"""
ignore_re = re.compile('[\x03\x02\x1D\x1F\x16\x0F]')
text = ignore_re.sub('', self.text)
if self.color and self.bg_color:
return '\x03%02d,%02d%s' % (self.color.to_8bit().to_irc(),
... | python | def to_irc(self):
"""
Convert to mIRC color format
:return:
"""
ignore_re = re.compile('[\x03\x02\x1D\x1F\x16\x0F]')
text = ignore_re.sub('', self.text)
if self.color and self.bg_color:
return '\x03%02d,%02d%s' % (self.color.to_8bit().to_irc(),
... | [
"def",
"to_irc",
"(",
"self",
")",
":",
"ignore_re",
"=",
"re",
".",
"compile",
"(",
"'[\\x03\\x02\\x1D\\x1F\\x16\\x0F]'",
")",
"text",
"=",
"ignore_re",
".",
"sub",
"(",
"''",
",",
"self",
".",
"text",
")",
"if",
"self",
".",
"color",
"and",
"self",
"... | Convert to mIRC color format
:return: | [
"Convert",
"to",
"mIRC",
"color",
"format",
":",
"return",
":"
] | train | https://github.com/nsavch/python-dpcolors/blob/9bca11416a21eca1c5a84b7dcc852d231d911981/dpcolors/__init__.py#L195-L215 |
nsavch/python-dpcolors | dpcolors/__init__.py | ColorPart.to_ansi_8bit | def to_ansi_8bit(self):
"""
Convert to ANSI 8-bit color format
:return:
"""
text = self.text.replace('\x1b', '')
if self.color and self.bg_color:
c = self.color.to_8bit()
return ansicolor(text,
fg=c.to_name(),
... | python | def to_ansi_8bit(self):
"""
Convert to ANSI 8-bit color format
:return:
"""
text = self.text.replace('\x1b', '')
if self.color and self.bg_color:
c = self.color.to_8bit()
return ansicolor(text,
fg=c.to_name(),
... | [
"def",
"to_ansi_8bit",
"(",
"self",
")",
":",
"text",
"=",
"self",
".",
"text",
".",
"replace",
"(",
"'\\x1b'",
",",
"''",
")",
"if",
"self",
".",
"color",
"and",
"self",
".",
"bg_color",
":",
"c",
"=",
"self",
".",
"color",
".",
"to_8bit",
"(",
... | Convert to ANSI 8-bit color format
:return: | [
"Convert",
"to",
"ANSI",
"8",
"-",
"bit",
"color",
"format",
":",
"return",
":"
] | train | https://github.com/nsavch/python-dpcolors/blob/9bca11416a21eca1c5a84b7dcc852d231d911981/dpcolors/__init__.py#L217-L238 |
nsavch/python-dpcolors | dpcolors/__init__.py | ColorPart.to_ansi_24bit | def to_ansi_24bit(self):
"""
Convert to ANSI 24-bit color format
:return:
"""
text = self.text.replace('\x1b', '')
if self.color and self.bg_color:
c = self.color.scale(255)
bg_c = self.bg_color.scale(255)
return ansicolor(text,
... | python | def to_ansi_24bit(self):
"""
Convert to ANSI 24-bit color format
:return:
"""
text = self.text.replace('\x1b', '')
if self.color and self.bg_color:
c = self.color.scale(255)
bg_c = self.bg_color.scale(255)
return ansicolor(text,
... | [
"def",
"to_ansi_24bit",
"(",
"self",
")",
":",
"text",
"=",
"self",
".",
"text",
".",
"replace",
"(",
"'\\x1b'",
",",
"''",
")",
"if",
"self",
".",
"color",
"and",
"self",
".",
"bg_color",
":",
"c",
"=",
"self",
".",
"color",
".",
"scale",
"(",
"... | Convert to ANSI 24-bit color format
:return: | [
"Convert",
"to",
"ANSI",
"24",
"-",
"bit",
"color",
"format",
":",
"return",
":"
] | train | https://github.com/nsavch/python-dpcolors/blob/9bca11416a21eca1c5a84b7dcc852d231d911981/dpcolors/__init__.py#L240-L261 |
nsavch/python-dpcolors | dpcolors/__init__.py | ColorString.from_dp | def from_dp(cls, text, use_unicode_for_glyphs=True):
"""
Create a new instance of ColorString from a darkplaces-formatted text
:param text: darkplaces text string (either str or bytes)
:param use_unicode_for_glyphs: convert unicode glyphs to ascii
:return: ColorString instance
... | python | def from_dp(cls, text, use_unicode_for_glyphs=True):
"""
Create a new instance of ColorString from a darkplaces-formatted text
:param text: darkplaces text string (either str or bytes)
:param use_unicode_for_glyphs: convert unicode glyphs to ascii
:return: ColorString instance
... | [
"def",
"from_dp",
"(",
"cls",
",",
"text",
",",
"use_unicode_for_glyphs",
"=",
"True",
")",
":",
"from",
".",
"grammars",
".",
"dp",
"import",
"parse",
"as",
"parse_dp",
"if",
"isinstance",
"(",
"text",
",",
"bytes",
")",
":",
"original_bytes",
"=",
"tex... | Create a new instance of ColorString from a darkplaces-formatted text
:param text: darkplaces text string (either str or bytes)
:param use_unicode_for_glyphs: convert unicode glyphs to ascii
:return: ColorString instance | [
"Create",
"a",
"new",
"instance",
"of",
"ColorString",
"from",
"a",
"darkplaces",
"-",
"formatted",
"text",
":",
"param",
"text",
":",
"darkplaces",
"text",
"string",
"(",
"either",
"str",
"or",
"bytes",
")",
":",
"param",
"use_unicode_for_glyphs",
":",
"con... | train | https://github.com/nsavch/python-dpcolors/blob/9bca11416a21eca1c5a84b7dcc852d231d911981/dpcolors/__init__.py#L277-L293 |
nsavch/python-dpcolors | dpcolors/__init__.py | ColorString.from_irc | def from_irc(cls, text):
"""
Create a new instance of ColorString from a mIRC-formatted text
:param text: mIRC-formatted text
:return:
"""
from .grammars.irc import parse as parse_irc
if isinstance(text, bytes):
original_bytes = text
text =... | python | def from_irc(cls, text):
"""
Create a new instance of ColorString from a mIRC-formatted text
:param text: mIRC-formatted text
:return:
"""
from .grammars.irc import parse as parse_irc
if isinstance(text, bytes):
original_bytes = text
text =... | [
"def",
"from_irc",
"(",
"cls",
",",
"text",
")",
":",
"from",
".",
"grammars",
".",
"irc",
"import",
"parse",
"as",
"parse_irc",
"if",
"isinstance",
"(",
"text",
",",
"bytes",
")",
":",
"original_bytes",
"=",
"text",
"text",
"=",
"text",
".",
"decode",... | Create a new instance of ColorString from a mIRC-formatted text
:param text: mIRC-formatted text
:return: | [
"Create",
"a",
"new",
"instance",
"of",
"ColorString",
"from",
"a",
"mIRC",
"-",
"formatted",
"text",
":",
"param",
"text",
":",
"mIRC",
"-",
"formatted",
"text",
":",
"return",
":"
] | train | https://github.com/nsavch/python-dpcolors/blob/9bca11416a21eca1c5a84b7dcc852d231d911981/dpcolors/__init__.py#L311-L326 |
nsavch/python-dpcolors | dpcolors/__init__.py | ColorString.to_irc | def to_irc(self, preserve_original=True):
"""
Convert to mIRC format
:param preserve_original: if the current ColorString instance was created from mIRC text,
then just return the original string
:return:
"""
if preserve_original and self.original_type == '... | python | def to_irc(self, preserve_original=True):
"""
Convert to mIRC format
:param preserve_original: if the current ColorString instance was created from mIRC text,
then just return the original string
:return:
"""
if preserve_original and self.original_type == '... | [
"def",
"to_irc",
"(",
"self",
",",
"preserve_original",
"=",
"True",
")",
":",
"if",
"preserve_original",
"and",
"self",
".",
"original_type",
"==",
"'irc'",
":",
"return",
"self",
".",
"original_bytes",
"res",
"=",
"[",
"]",
"for",
"i",
"in",
"self",
".... | Convert to mIRC format
:param preserve_original: if the current ColorString instance was created from mIRC text,
then just return the original string
:return: | [
"Convert",
"to",
"mIRC",
"format",
":",
"param",
"preserve_original",
":",
"if",
"the",
"current",
"ColorString",
"instance",
"was",
"created",
"from",
"mIRC",
"text",
"then",
"just",
"return",
"the",
"original",
"string",
":",
"return",
":"
] | train | https://github.com/nsavch/python-dpcolors/blob/9bca11416a21eca1c5a84b7dcc852d231d911981/dpcolors/__init__.py#L328-L341 |
nsavch/python-dpcolors | dpcolors/__init__.py | ColorString.to_ansi_8bit | def to_ansi_8bit(self):
"""
Convert to ANSI 8-bit
:return:
"""
res = []
for i in self.parts:
res.append(i.to_ansi_8bit())
return ''.join(res).encode('utf8') | python | def to_ansi_8bit(self):
"""
Convert to ANSI 8-bit
:return:
"""
res = []
for i in self.parts:
res.append(i.to_ansi_8bit())
return ''.join(res).encode('utf8') | [
"def",
"to_ansi_8bit",
"(",
"self",
")",
":",
"res",
"=",
"[",
"]",
"for",
"i",
"in",
"self",
".",
"parts",
":",
"res",
".",
"append",
"(",
"i",
".",
"to_ansi_8bit",
"(",
")",
")",
"return",
"''",
".",
"join",
"(",
"res",
")",
".",
"encode",
"(... | Convert to ANSI 8-bit
:return: | [
"Convert",
"to",
"ANSI",
"8",
"-",
"bit",
":",
"return",
":"
] | train | https://github.com/nsavch/python-dpcolors/blob/9bca11416a21eca1c5a84b7dcc852d231d911981/dpcolors/__init__.py#L343-L351 |
nsavch/python-dpcolors | dpcolors/__init__.py | ColorString.to_ansi_24bit | def to_ansi_24bit(self):
"""
Convert to ANSI 24-bit
:return:
"""
res = []
for i in self.parts:
res.append(i.to_ansi_24bit())
return ''.join(res).encode('utf8') | python | def to_ansi_24bit(self):
"""
Convert to ANSI 24-bit
:return:
"""
res = []
for i in self.parts:
res.append(i.to_ansi_24bit())
return ''.join(res).encode('utf8') | [
"def",
"to_ansi_24bit",
"(",
"self",
")",
":",
"res",
"=",
"[",
"]",
"for",
"i",
"in",
"self",
".",
"parts",
":",
"res",
".",
"append",
"(",
"i",
".",
"to_ansi_24bit",
"(",
")",
")",
"return",
"''",
".",
"join",
"(",
"res",
")",
".",
"encode",
... | Convert to ANSI 24-bit
:return: | [
"Convert",
"to",
"ANSI",
"24",
"-",
"bit",
":",
"return",
":"
] | train | https://github.com/nsavch/python-dpcolors/blob/9bca11416a21eca1c5a84b7dcc852d231d911981/dpcolors/__init__.py#L353-L361 |
naphatkrit/easyci | easyci/file_system_events/vcs_event_handler.py | VcsEventHandler.dispatch | def dispatch(self, event):
"""Only dispatch if the event does not correspond to an ignored file.
Args:
event (watchdog.events.FileSystemEvent)
"""
if event.is_directory:
return
paths = []
if has_attribute(event, 'dest_path'):
paths.appe... | python | def dispatch(self, event):
"""Only dispatch if the event does not correspond to an ignored file.
Args:
event (watchdog.events.FileSystemEvent)
"""
if event.is_directory:
return
paths = []
if has_attribute(event, 'dest_path'):
paths.appe... | [
"def",
"dispatch",
"(",
"self",
",",
"event",
")",
":",
"if",
"event",
".",
"is_directory",
":",
"return",
"paths",
"=",
"[",
"]",
"if",
"has_attribute",
"(",
"event",
",",
"'dest_path'",
")",
":",
"paths",
".",
"append",
"(",
"os",
".",
"path",
".",... | Only dispatch if the event does not correspond to an ignored file.
Args:
event (watchdog.events.FileSystemEvent) | [
"Only",
"dispatch",
"if",
"the",
"event",
"does",
"not",
"correspond",
"to",
"an",
"ignored",
"file",
".",
"Args",
":",
"event",
"(",
"watchdog",
".",
"events",
".",
"FileSystemEvent",
")"
] | train | https://github.com/naphatkrit/easyci/blob/7aee8d7694fe4e2da42ce35b0f700bc840c8b95f/easyci/file_system_events/vcs_event_handler.py#L14-L33 |
ulf1/oxyba | oxyba/clean_german_date.py | clean_german_date | def clean_german_date(x):
"""Convert a string with a German date 'DD.MM.YYYY' to Datetime objects
Parameters
----------
x : str, list, tuple, numpy.ndarray, pandas.DataFrame
A string with a German formated date,
or an array of these strings, e.g. list, ndarray, df.
Returns
----... | python | def clean_german_date(x):
"""Convert a string with a German date 'DD.MM.YYYY' to Datetime objects
Parameters
----------
x : str, list, tuple, numpy.ndarray, pandas.DataFrame
A string with a German formated date,
or an array of these strings, e.g. list, ndarray, df.
Returns
----... | [
"def",
"clean_german_date",
"(",
"x",
")",
":",
"import",
"numpy",
"as",
"np",
"import",
"pandas",
"as",
"pd",
"from",
"datetime",
"import",
"datetime",
"def",
"proc_elem",
"(",
"e",
")",
":",
"try",
":",
"return",
"datetime",
".",
"strptime",
"(",
"e",
... | Convert a string with a German date 'DD.MM.YYYY' to Datetime objects
Parameters
----------
x : str, list, tuple, numpy.ndarray, pandas.DataFrame
A string with a German formated date,
or an array of these strings, e.g. list, ndarray, df.
Returns
-------
y : str, list, tuple, num... | [
"Convert",
"a",
"string",
"with",
"a",
"German",
"date",
"DD",
".",
"MM",
".",
"YYYY",
"to",
"Datetime",
"objects"
] | train | https://github.com/ulf1/oxyba/blob/b3043116050de275124365cb11e7df91fb40169d/oxyba/clean_german_date.py#L2-L61 |
shaypal5/utilp | utilp/classes/classes.py | mro | def mro(*bases):
"""Calculate the Method Resolution Order of bases using the C3 algorithm.
Suppose you intended creating a class K with the given base classes. This
function returns the MRO which K would have, *excluding* K itself (since
it doesn't yet exist), as if you had actually created the class.
... | python | def mro(*bases):
"""Calculate the Method Resolution Order of bases using the C3 algorithm.
Suppose you intended creating a class K with the given base classes. This
function returns the MRO which K would have, *excluding* K itself (since
it doesn't yet exist), as if you had actually created the class.
... | [
"def",
"mro",
"(",
"*",
"bases",
")",
":",
"seqs",
"=",
"[",
"list",
"(",
"C",
".",
"__mro__",
")",
"for",
"C",
"in",
"bases",
"]",
"+",
"[",
"list",
"(",
"bases",
")",
"]",
"res",
"=",
"[",
"]",
"while",
"True",
":",
"non_empty",
"=",
"list"... | Calculate the Method Resolution Order of bases using the C3 algorithm.
Suppose you intended creating a class K with the given base classes. This
function returns the MRO which K would have, *excluding* K itself (since
it doesn't yet exist), as if you had actually created the class.
Another way of look... | [
"Calculate",
"the",
"Method",
"Resolution",
"Order",
"of",
"bases",
"using",
"the",
"C3",
"algorithm",
"."
] | train | https://github.com/shaypal5/utilp/blob/932abaf8ccfd06557632b7dbebc7775da1de8430/utilp/classes/classes.py#L81-L115 |
shaypal5/utilp | utilp/classes/classes.py | _copy_ancestor_docstring | def _copy_ancestor_docstring(mro_list, func): # pylint: disable=W0613
"""Decorator to set docstring for *func* from *mro*"""
if func.__doc__ is not None:
raise RuntimeError('Function already has docstring')
# Search for docstring in superclass
for cls in mro_list:
super_fn = getattr(cls... | python | def _copy_ancestor_docstring(mro_list, func): # pylint: disable=W0613
"""Decorator to set docstring for *func* from *mro*"""
if func.__doc__ is not None:
raise RuntimeError('Function already has docstring')
# Search for docstring in superclass
for cls in mro_list:
super_fn = getattr(cls... | [
"def",
"_copy_ancestor_docstring",
"(",
"mro_list",
",",
"func",
")",
":",
"# pylint: disable=W0613",
"if",
"func",
".",
"__doc__",
"is",
"not",
"None",
":",
"raise",
"RuntimeError",
"(",
"'Function already has docstring'",
")",
"# Search for docstring in superclass",
"... | Decorator to set docstring for *func* from *mro* | [
"Decorator",
"to",
"set",
"docstring",
"for",
"*",
"func",
"*",
"from",
"*",
"mro",
"*"
] | train | https://github.com/shaypal5/utilp/blob/932abaf8ccfd06557632b7dbebc7775da1de8430/utilp/classes/classes.py#L128-L142 |
shaypal5/utilp | utilp/classes/classes.py | PrintLogger.printlog | def printlog(self, string, verbose=None, flush=False):
"""Prints the given string to a logfile if logging is on, and to
screen if verbosity is on."""
if self.writelog:
self.logger.info(string)
if verbose or (self.verbose and verbose is None):
print(string, flush=f... | python | def printlog(self, string, verbose=None, flush=False):
"""Prints the given string to a logfile if logging is on, and to
screen if verbosity is on."""
if self.writelog:
self.logger.info(string)
if verbose or (self.verbose and verbose is None):
print(string, flush=f... | [
"def",
"printlog",
"(",
"self",
",",
"string",
",",
"verbose",
"=",
"None",
",",
"flush",
"=",
"False",
")",
":",
"if",
"self",
".",
"writelog",
":",
"self",
".",
"logger",
".",
"info",
"(",
"string",
")",
"if",
"verbose",
"or",
"(",
"self",
".",
... | Prints the given string to a logfile if logging is on, and to
screen if verbosity is on. | [
"Prints",
"the",
"given",
"string",
"to",
"a",
"logfile",
"if",
"logging",
"is",
"on",
"and",
"to",
"screen",
"if",
"verbosity",
"is",
"on",
"."
] | train | https://github.com/shaypal5/utilp/blob/932abaf8ccfd06557632b7dbebc7775da1de8430/utilp/classes/classes.py#L249-L255 |
shaypal5/utilp | utilp/classes/classes.py | PrintLogger.exception | def exception(self, exception):
"""Prints the stacktrace of the given exception."""
if self.writelog:
self.logger.exception(exception)
if self.verbose:
for line in traceback.format_exception(
None, exception, exception.__traceback__):
... | python | def exception(self, exception):
"""Prints the stacktrace of the given exception."""
if self.writelog:
self.logger.exception(exception)
if self.verbose:
for line in traceback.format_exception(
None, exception, exception.__traceback__):
... | [
"def",
"exception",
"(",
"self",
",",
"exception",
")",
":",
"if",
"self",
".",
"writelog",
":",
"self",
".",
"logger",
".",
"exception",
"(",
"exception",
")",
"if",
"self",
".",
"verbose",
":",
"for",
"line",
"in",
"traceback",
".",
"format_exception",... | Prints the stacktrace of the given exception. | [
"Prints",
"the",
"stacktrace",
"of",
"the",
"given",
"exception",
"."
] | train | https://github.com/shaypal5/utilp/blob/932abaf8ccfd06557632b7dbebc7775da1de8430/utilp/classes/classes.py#L257-L264 |
shaypal5/utilp | utilp/classes/classes.py | PrintLogger.tqdm | def tqdm(self, iterable, **kwargs):
"""Wraps the given iterable with a tqdm progress bar if this logger is
set to verbose. Otherwise, returns the iterable unchanged."""
if 'disable' in kwargs:
kwargs.pop('disable')
return tqdm(iterable, disable=not self.verbose, **kwargs) | python | def tqdm(self, iterable, **kwargs):
"""Wraps the given iterable with a tqdm progress bar if this logger is
set to verbose. Otherwise, returns the iterable unchanged."""
if 'disable' in kwargs:
kwargs.pop('disable')
return tqdm(iterable, disable=not self.verbose, **kwargs) | [
"def",
"tqdm",
"(",
"self",
",",
"iterable",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"'disable'",
"in",
"kwargs",
":",
"kwargs",
".",
"pop",
"(",
"'disable'",
")",
"return",
"tqdm",
"(",
"iterable",
",",
"disable",
"=",
"not",
"self",
".",
"verbose"... | Wraps the given iterable with a tqdm progress bar if this logger is
set to verbose. Otherwise, returns the iterable unchanged. | [
"Wraps",
"the",
"given",
"iterable",
"with",
"a",
"tqdm",
"progress",
"bar",
"if",
"this",
"logger",
"is",
"set",
"to",
"verbose",
".",
"Otherwise",
"returns",
"the",
"iterable",
"unchanged",
"."
] | train | https://github.com/shaypal5/utilp/blob/932abaf8ccfd06557632b7dbebc7775da1de8430/utilp/classes/classes.py#L273-L278 |
20c/xbahn | xbahn/connection/tcp.py | Handler.process_data | def process_data(self):
"""
Process data
Triggers raw-data-received event
"""
self.trigger("process-data", self.received_data)
self.received_data = ""
if self.dispatcher:
self.time = self.dispatcher.time | python | def process_data(self):
"""
Process data
Triggers raw-data-received event
"""
self.trigger("process-data", self.received_data)
self.received_data = ""
if self.dispatcher:
self.time = self.dispatcher.time | [
"def",
"process_data",
"(",
"self",
")",
":",
"self",
".",
"trigger",
"(",
"\"process-data\"",
",",
"self",
".",
"received_data",
")",
"self",
".",
"received_data",
"=",
"\"\"",
"if",
"self",
".",
"dispatcher",
":",
"self",
".",
"time",
"=",
"self",
".",... | Process data
Triggers raw-data-received event | [
"Process",
"data"
] | train | https://github.com/20c/xbahn/blob/afb27b0576841338a366d7cac0200a782bd84be6/xbahn/connection/tcp.py#L85-L95 |
20c/xbahn | xbahn/connection/tcp.py | Handler.respond | def respond(self, data):
"""
Respond to the connection accepted in this object
"""
self.push("%s%s" % (data, TERMINATOR))
if self.temporary:
self.close_when_done() | python | def respond(self, data):
"""
Respond to the connection accepted in this object
"""
self.push("%s%s" % (data, TERMINATOR))
if self.temporary:
self.close_when_done() | [
"def",
"respond",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"push",
"(",
"\"%s%s\"",
"%",
"(",
"data",
",",
"TERMINATOR",
")",
")",
"if",
"self",
".",
"temporary",
":",
"self",
".",
"close_when_done",
"(",
")"
] | Respond to the connection accepted in this object | [
"Respond",
"to",
"the",
"connection",
"accepted",
"in",
"this",
"object"
] | train | https://github.com/20c/xbahn/blob/afb27b0576841338a366d7cac0200a782bd84be6/xbahn/connection/tcp.py#L98-L105 |
spookey/photon | photon/tools/mail.py | Mail.text | def text(self, text):
'''
.. seealso:: :attr:`text`
'''
if text:
if not isinstance(text, str):
text = _pformat(text)
text += '\n\n'
self.m(
'add text to mail',
more=dict(len=len(text))
)
... | python | def text(self, text):
'''
.. seealso:: :attr:`text`
'''
if text:
if not isinstance(text, str):
text = _pformat(text)
text += '\n\n'
self.m(
'add text to mail',
more=dict(len=len(text))
)
... | [
"def",
"text",
"(",
"self",
",",
"text",
")",
":",
"if",
"text",
":",
"if",
"not",
"isinstance",
"(",
"text",
",",
"str",
")",
":",
"text",
"=",
"_pformat",
"(",
"text",
")",
"text",
"+=",
"'\\n\\n'",
"self",
".",
"m",
"(",
"'add text to mail'",
",... | .. seealso:: :attr:`text` | [
"..",
"seealso",
"::",
":",
"attr",
":",
"text"
] | train | https://github.com/spookey/photon/blob/57212a26ce713ab7723910ee49e3d0ba1697799f/photon/tools/mail.py#L82-L95 |
spookey/photon | photon/tools/mail.py | Mail.send | def send(self):
'''
:returns:
A dictionary with the following:
* 'sender': The `sender`
* 'recipients': All recipients, compiled from `to`, `cc` and `bcc`
* 'result': The :py:meth:`smtplib.SMTP.sendmail`-result
* 'exception': The exception mes... | python | def send(self):
'''
:returns:
A dictionary with the following:
* 'sender': The `sender`
* 'recipients': All recipients, compiled from `to`, `cc` and `bcc`
* 'result': The :py:meth:`smtplib.SMTP.sendmail`-result
* 'exception': The exception mes... | [
"def",
"send",
"(",
"self",
")",
":",
"res",
"=",
"dict",
"(",
"sender",
"=",
"self",
".",
"__sender",
",",
"recipients",
"=",
"self",
".",
"__recipients",
")",
"try",
":",
"s",
"=",
"_SMTP",
"(",
")",
"s",
".",
"connect",
"(",
"'localhost'",
")",
... | :returns:
A dictionary with the following:
* 'sender': The `sender`
* 'recipients': All recipients, compiled from `to`, `cc` and `bcc`
* 'result': The :py:meth:`smtplib.SMTP.sendmail`-result
* 'exception': The exception message (if any)
.. note::
... | [
":",
"returns",
":",
"A",
"dictionary",
"with",
"the",
"following",
":"
] | train | https://github.com/spookey/photon/blob/57212a26ce713ab7723910ee49e3d0ba1697799f/photon/tools/mail.py#L98-L126 |
ploneintranet/ploneintranet.workspace | src/ploneintranet/workspace/workspacefolder.py | WorkspaceFolder.participant_policy | def participant_policy(self, value):
""" Changing participation policy fires a
"ParticipationPolicyChanged" event
"""
old_policy = self.participant_policy
new_policy = value
self._participant_policy = new_policy
notify(ParticipationPolicyChangedEvent(self, old_pol... | python | def participant_policy(self, value):
""" Changing participation policy fires a
"ParticipationPolicyChanged" event
"""
old_policy = self.participant_policy
new_policy = value
self._participant_policy = new_policy
notify(ParticipationPolicyChangedEvent(self, old_pol... | [
"def",
"participant_policy",
"(",
"self",
",",
"value",
")",
":",
"old_policy",
"=",
"self",
".",
"participant_policy",
"new_policy",
"=",
"value",
"self",
".",
"_participant_policy",
"=",
"new_policy",
"notify",
"(",
"ParticipationPolicyChangedEvent",
"(",
"self",
... | Changing participation policy fires a
"ParticipationPolicyChanged" event | [
"Changing",
"participation",
"policy",
"fires",
"a",
"ParticipationPolicyChanged",
"event"
] | train | https://github.com/ploneintranet/ploneintranet.workspace/blob/a4fc7a5c61f9c6d4d4ad25478ff5250f342ffbba/src/ploneintranet/workspace/workspacefolder.py#L74-L81 |
nejucomo/concon | concon.py | define_constrained_subtype | def define_constrained_subtype(prefix, base, blockednames, clsdict=None):
"""
Define a subtype which blocks a list of methods.
@param prefix: The subtype name prefix. This is prepended to the
base type name. This convention is baked in for
API consistency.
@para... | python | def define_constrained_subtype(prefix, base, blockednames, clsdict=None):
"""
Define a subtype which blocks a list of methods.
@param prefix: The subtype name prefix. This is prepended to the
base type name. This convention is baked in for
API consistency.
@para... | [
"def",
"define_constrained_subtype",
"(",
"prefix",
",",
"base",
",",
"blockednames",
",",
"clsdict",
"=",
"None",
")",
":",
"name",
"=",
"prefix",
"+",
"base",
".",
"__name__",
"clsdict",
"=",
"clsdict",
"or",
"{",
"}",
"doc",
"=",
"clsdict",
".",
"get"... | Define a subtype which blocks a list of methods.
@param prefix: The subtype name prefix. This is prepended to the
base type name. This convention is baked in for
API consistency.
@param base: The base type to derive from.
@param blockednames: A list of method name ... | [
"Define",
"a",
"subtype",
"which",
"blocks",
"a",
"list",
"of",
"methods",
"."
] | train | https://github.com/nejucomo/concon/blob/0302475a86d25c53cd6ef50b0e4f6279ea73090d/concon.py#L42-L83 |
nejucomo/concon | concon.py | setitem_without_overwrite | def setitem_without_overwrite(d, key, value):
"""
@param d: An instance of dict, that is: isinstance(d, dict)
@param key: a key
@param value: a value to associate with the key
@return: None
@raise: OverwriteError if the key is already present in d.
"""
if key in d:
raise Overwr... | python | def setitem_without_overwrite(d, key, value):
"""
@param d: An instance of dict, that is: isinstance(d, dict)
@param key: a key
@param value: a value to associate with the key
@return: None
@raise: OverwriteError if the key is already present in d.
"""
if key in d:
raise Overwr... | [
"def",
"setitem_without_overwrite",
"(",
"d",
",",
"key",
",",
"value",
")",
":",
"if",
"key",
"in",
"d",
":",
"raise",
"OverwriteError",
"(",
"key",
",",
"value",
",",
"d",
"[",
"key",
"]",
")",
"else",
":",
"dict",
".",
"__setitem__",
"(",
"d",
"... | @param d: An instance of dict, that is: isinstance(d, dict)
@param key: a key
@param value: a value to associate with the key
@return: None
@raise: OverwriteError if the key is already present in d. | [
"@param",
"d",
":",
"An",
"instance",
"of",
"dict",
"that",
"is",
":",
"isinstance",
"(",
"d",
"dict",
")",
"@param",
"key",
":",
"a",
"key",
"@param",
"value",
":",
"a",
"value",
"to",
"associate",
"with",
"the",
"key"
] | train | https://github.com/nejucomo/concon/blob/0302475a86d25c53cd6ef50b0e4f6279ea73090d/concon.py#L101-L114 |
nejucomo/concon | concon.py | update_without_overwrite | def update_without_overwrite(d, *args, **kwds):
"""
This has the same interface as dict.update except it uses
setitem_without_overwrite for all updates.
Note: The implementation is derived from
collections.MutableMapping.update.
"""
if args:
assert len(args) == 1, \
'At ... | python | def update_without_overwrite(d, *args, **kwds):
"""
This has the same interface as dict.update except it uses
setitem_without_overwrite for all updates.
Note: The implementation is derived from
collections.MutableMapping.update.
"""
if args:
assert len(args) == 1, \
'At ... | [
"def",
"update_without_overwrite",
"(",
"d",
",",
"*",
"args",
",",
"*",
"*",
"kwds",
")",
":",
"if",
"args",
":",
"assert",
"len",
"(",
"args",
")",
"==",
"1",
",",
"'At most one positional parameter is allowed: {0!r}'",
".",
"format",
"(",
"args",
")",
"... | This has the same interface as dict.update except it uses
setitem_without_overwrite for all updates.
Note: The implementation is derived from
collections.MutableMapping.update. | [
"This",
"has",
"the",
"same",
"interface",
"as",
"dict",
".",
"update",
"except",
"it",
"uses",
"setitem_without_overwrite",
"for",
"all",
"updates",
"."
] | train | https://github.com/nejucomo/concon/blob/0302475a86d25c53cd6ef50b0e4f6279ea73090d/concon.py#L117-L141 |
nejucomo/concon | concon.py | ConstraintError.block | def block(cls, method):
"""
This decorator raises a ConstraintError (or subclass) on any
call to the given method.
"""
def blocked_method(self, *a, **kw):
raise cls(self, method.__name__, a, kw)
return blocked_method | python | def block(cls, method):
"""
This decorator raises a ConstraintError (or subclass) on any
call to the given method.
"""
def blocked_method(self, *a, **kw):
raise cls(self, method.__name__, a, kw)
return blocked_method | [
"def",
"block",
"(",
"cls",
",",
"method",
")",
":",
"def",
"blocked_method",
"(",
"self",
",",
"*",
"a",
",",
"*",
"*",
"kw",
")",
":",
"raise",
"cls",
"(",
"self",
",",
"method",
".",
"__name__",
",",
"a",
",",
"kw",
")",
"return",
"blocked_met... | This decorator raises a ConstraintError (or subclass) on any
call to the given method. | [
"This",
"decorator",
"raises",
"a",
"ConstraintError",
"(",
"or",
"subclass",
")",
"on",
"any",
"call",
"to",
"the",
"given",
"method",
"."
] | train | https://github.com/nejucomo/concon/blob/0302475a86d25c53cd6ef50b0e4f6279ea73090d/concon.py#L32-L39 |
markomanninen/abnum | romanize/heb.py | preprocess | def preprocess(string):
"""
Preprocess string to transform all diacritics and remove other special characters than appropriate
:param string:
:return:
"""
string = unicode(string, encoding="utf-8")
return regex.sub('', string).encode('utf-8') | python | def preprocess(string):
"""
Preprocess string to transform all diacritics and remove other special characters than appropriate
:param string:
:return:
"""
string = unicode(string, encoding="utf-8")
return regex.sub('', string).encode('utf-8') | [
"def",
"preprocess",
"(",
"string",
")",
":",
"string",
"=",
"unicode",
"(",
"string",
",",
"encoding",
"=",
"\"utf-8\"",
")",
"return",
"regex",
".",
"sub",
"(",
"''",
",",
"string",
")",
".",
"encode",
"(",
"'utf-8'",
")"
] | Preprocess string to transform all diacritics and remove other special characters than appropriate
:param string:
:return: | [
"Preprocess",
"string",
"to",
"transform",
"all",
"diacritics",
"and",
"remove",
"other",
"special",
"characters",
"than",
"appropriate",
":",
"param",
"string",
":",
":",
"return",
":"
] | train | https://github.com/markomanninen/abnum/blob/9bfc8f06f34d9a51aab038638f87e2bb5f9f4c99/romanize/heb.py#L95-L103 |
razor-x/dichalcogenides | dichalcogenides/dichalcogenide/topology.py | Topology.Ω( | def Ω(self, k, n, τ, σ):
"""Berry curvature.
:param k: Momentum :math:`k`.
:type k: float
:param n: Band index :math:`n = ±1`.
:type n: int
:param τ: Valley index :math:`τ = ±1`.
:type τ: int
:param σ: Spin index :math:`σ = ±1`.
:type σ: int
... | python | def Ω(self, k, n, τ, σ):
"""Berry curvature.
:param k: Momentum :math:`k`.
:type k: float
:param n: Band index :math:`n = ±1`.
:type n: int
:param τ: Valley index :math:`τ = ±1`.
:type τ: int
:param σ: Spin index :math:`σ = ±1`.
:type σ: int
... | [
"def",
"Ω(",
"s",
"elf,",
" ",
",",
" ",
",",
" ",
", ",
"σ",
":",
"",
"",
"d",
"=",
"self",
".",
"_dichalcogenide",
"at",
",",
"Δ,",
" ",
" =",
"d",
"a",
"t",
", ",
"d",
"Δ",
",",
" d",
".",
"",
"",
"",
"x",
"=",
"Δ ",
" ",
" *",
"τ"... | Berry curvature.
:param k: Momentum :math:`k`.
:type k: float
:param n: Band index :math:`n = ±1`.
:type n: int
:param τ: Valley index :math:`τ = ±1`.
:type τ: int
:param σ: Spin index :math:`σ = ±1`.
:type σ: int
:return: :math:`Ω^n_{τ σ} (k)`... | [
"Berry",
"curvature",
".",
":",
"param",
"k",
":",
"Momentum",
":",
"math",
":",
"k",
".",
":",
"type",
"k",
":",
"float"
] | train | https://github.com/razor-x/dichalcogenides/blob/0fa1995a3a328b679c9926f73239d0ecdc6e5d3d/dichalcogenides/dichalcogenide/topology.py#L15-L36 |
kervi/kervi-core | kervi/hal/__init__.py | ChannelPollingThread._step | def _step(self):
"""Private method do not call it directly or override it."""
try:
new_value = self._device.get(self._channel)
if new_value != self._value:
self._callback(new_value)
self._value = new_value
time.sleep(self._polling_time)... | python | def _step(self):
"""Private method do not call it directly or override it."""
try:
new_value = self._device.get(self._channel)
if new_value != self._value:
self._callback(new_value)
self._value = new_value
time.sleep(self._polling_time)... | [
"def",
"_step",
"(",
"self",
")",
":",
"try",
":",
"new_value",
"=",
"self",
".",
"_device",
".",
"get",
"(",
"self",
".",
"_channel",
")",
"if",
"new_value",
"!=",
"self",
".",
"_value",
":",
"self",
".",
"_callback",
"(",
"new_value",
")",
"self",
... | Private method do not call it directly or override it. | [
"Private",
"method",
"do",
"not",
"call",
"it",
"directly",
"or",
"override",
"it",
"."
] | train | https://github.com/kervi/kervi-core/blob/3c1e3c8a17a7b4d085d8a28b99180ff2a96b0e23/kervi/hal/__init__.py#L218-L227 |
minhhoit/yacms | yacms/blog/management/base.py | BaseImporterCommand.add_post | def add_post(self, title=None, content=None, old_url=None, pub_date=None,
tags=None, categories=None, comments=None):
"""
Adds a post to the post list for processing.
- ``title`` and ``content`` are strings for the post.
- ``old_url`` is a string that a redirect will be... | python | def add_post(self, title=None, content=None, old_url=None, pub_date=None,
tags=None, categories=None, comments=None):
"""
Adds a post to the post list for processing.
- ``title`` and ``content`` are strings for the post.
- ``old_url`` is a string that a redirect will be... | [
"def",
"add_post",
"(",
"self",
",",
"title",
"=",
"None",
",",
"content",
"=",
"None",
",",
"old_url",
"=",
"None",
",",
"pub_date",
"=",
"None",
",",
"tags",
"=",
"None",
",",
"categories",
"=",
"None",
",",
"comments",
"=",
"None",
")",
":",
"if... | Adds a post to the post list for processing.
- ``title`` and ``content`` are strings for the post.
- ``old_url`` is a string that a redirect will be created for.
- ``pub_date`` is assumed to be a ``datetime`` object.
- ``tags`` and ``categories`` are sequences of strings.
- ``co... | [
"Adds",
"a",
"post",
"to",
"the",
"post",
"list",
"for",
"processing",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/blog/management/base.py#L54-L84 |
minhhoit/yacms | yacms/blog/management/base.py | BaseImporterCommand.add_page | def add_page(self, title=None, content=None, old_url=None,
tags=None, old_id=None, old_parent_id=None):
"""
Adds a page to the list of pages to be imported - used by the
Wordpress importer.
"""
if not title:
text = decode_entities(strip_tags(content))... | python | def add_page(self, title=None, content=None, old_url=None,
tags=None, old_id=None, old_parent_id=None):
"""
Adds a page to the list of pages to be imported - used by the
Wordpress importer.
"""
if not title:
text = decode_entities(strip_tags(content))... | [
"def",
"add_page",
"(",
"self",
",",
"title",
"=",
"None",
",",
"content",
"=",
"None",
",",
"old_url",
"=",
"None",
",",
"tags",
"=",
"None",
",",
"old_id",
"=",
"None",
",",
"old_parent_id",
"=",
"None",
")",
":",
"if",
"not",
"title",
":",
"text... | Adds a page to the list of pages to be imported - used by the
Wordpress importer. | [
"Adds",
"a",
"page",
"to",
"the",
"list",
"of",
"pages",
"to",
"be",
"imported",
"-",
"used",
"by",
"the",
"Wordpress",
"importer",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/blog/management/base.py#L86-L104 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.