id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
49,400 | hharnisc/python-ddp | DDPClient.py | DDPClient.call | def call(self, method, params, callback=None):
"""Call a method on the server
Arguments:
method - the remote server method
params - an array of commands to send to the method
Keyword Arguments:
callback - a callback function containing the return data"""
cur_id ... | python | def call(self, method, params, callback=None):
"""Call a method on the server
Arguments:
method - the remote server method
params - an array of commands to send to the method
Keyword Arguments:
callback - a callback function containing the return data"""
cur_id ... | [
"def",
"call",
"(",
"self",
",",
"method",
",",
"params",
",",
"callback",
"=",
"None",
")",
":",
"cur_id",
"=",
"self",
".",
"_next_id",
"(",
")",
"if",
"callback",
":",
"self",
".",
"_callbacks",
"[",
"cur_id",
"]",
"=",
"callback",
"self",
".",
... | Call a method on the server
Arguments:
method - the remote server method
params - an array of commands to send to the method
Keyword Arguments:
callback - a callback function containing the return data | [
"Call",
"a",
"method",
"on",
"the",
"server"
] | 00bdf33c20ecba56623890515381154e14c5b757 | https://github.com/hharnisc/python-ddp/blob/00bdf33c20ecba56623890515381154e14c5b757/DDPClient.py#L229-L241 |
49,401 | arne-cl/discoursegraphs | src/discoursegraphs/readwrite/rst/dplp.py | DPLPRSTTree.extract_edus | def extract_edus(merge_file_str):
"""Extract EDUs from DPLPs .merge output files.
Returns
-------
edus : dict from EDU IDs (int) to words (list(str))
"""
lines = merge_file_str.splitlines()
edus = defaultdict(list)
for line in lines:
if line.... | python | def extract_edus(merge_file_str):
"""Extract EDUs from DPLPs .merge output files.
Returns
-------
edus : dict from EDU IDs (int) to words (list(str))
"""
lines = merge_file_str.splitlines()
edus = defaultdict(list)
for line in lines:
if line.... | [
"def",
"extract_edus",
"(",
"merge_file_str",
")",
":",
"lines",
"=",
"merge_file_str",
".",
"splitlines",
"(",
")",
"edus",
"=",
"defaultdict",
"(",
"list",
")",
"for",
"line",
"in",
"lines",
":",
"if",
"line",
".",
"strip",
"(",
")",
":",
"# ignore emp... | Extract EDUs from DPLPs .merge output files.
Returns
-------
edus : dict from EDU IDs (int) to words (list(str)) | [
"Extract",
"EDUs",
"from",
"DPLPs",
".",
"merge",
"output",
"files",
"."
] | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/rst/dplp.py#L67-L82 |
49,402 | arne-cl/discoursegraphs | src/discoursegraphs/readwrite/rst/dplp.py | DPLPRSTTree.dplptree2dgparentedtree | def dplptree2dgparentedtree(self):
"""Convert the tree from DPLP's format into a conventional binary tree,
which can be easily converted into output formats like RS3.
"""
def transform(dplp_tree):
"""Transform a DPLP parse tree into a more conventional parse tree."""
... | python | def dplptree2dgparentedtree(self):
"""Convert the tree from DPLP's format into a conventional binary tree,
which can be easily converted into output formats like RS3.
"""
def transform(dplp_tree):
"""Transform a DPLP parse tree into a more conventional parse tree."""
... | [
"def",
"dplptree2dgparentedtree",
"(",
"self",
")",
":",
"def",
"transform",
"(",
"dplp_tree",
")",
":",
"\"\"\"Transform a DPLP parse tree into a more conventional parse tree.\"\"\"",
"if",
"isinstance",
"(",
"dplp_tree",
",",
"basestring",
")",
"or",
"not",
"hasattr",
... | Convert the tree from DPLP's format into a conventional binary tree,
which can be easily converted into output formats like RS3. | [
"Convert",
"the",
"tree",
"from",
"DPLP",
"s",
"format",
"into",
"a",
"conventional",
"binary",
"tree",
"which",
"can",
"be",
"easily",
"converted",
"into",
"output",
"formats",
"like",
"RS3",
"."
] | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/rst/dplp.py#L93-L114 |
49,403 | arne-cl/discoursegraphs | src/discoursegraphs/readwrite/tiger.py | _get_terminals_and_nonterminals | def _get_terminals_and_nonterminals(sentence_graph):
"""
Given a TigerSentenceGraph, returns a sorted list of terminal node
IDs, as well as a sorted list of nonterminal node IDs.
Parameters
----------
sentence_graph : TigerSentenceGraph
a directed graph representing one syntax annotated... | python | def _get_terminals_and_nonterminals(sentence_graph):
"""
Given a TigerSentenceGraph, returns a sorted list of terminal node
IDs, as well as a sorted list of nonterminal node IDs.
Parameters
----------
sentence_graph : TigerSentenceGraph
a directed graph representing one syntax annotated... | [
"def",
"_get_terminals_and_nonterminals",
"(",
"sentence_graph",
")",
":",
"terminals",
"=",
"set",
"(",
")",
"nonterminals",
"=",
"set",
"(",
")",
"for",
"node_id",
"in",
"sentence_graph",
".",
"nodes_iter",
"(",
")",
":",
"if",
"sentence_graph",
".",
"out_de... | Given a TigerSentenceGraph, returns a sorted list of terminal node
IDs, as well as a sorted list of nonterminal node IDs.
Parameters
----------
sentence_graph : TigerSentenceGraph
a directed graph representing one syntax annotated sentence from
a TigerXML file
Returns
-------
... | [
"Given",
"a",
"TigerSentenceGraph",
"returns",
"a",
"sorted",
"list",
"of",
"terminal",
"node",
"IDs",
"as",
"well",
"as",
"a",
"sorted",
"list",
"of",
"nonterminal",
"node",
"IDs",
"."
] | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/tiger.py#L290-L316 |
49,404 | arne-cl/discoursegraphs | src/discoursegraphs/readwrite/tiger.py | get_unconnected_nodes | def get_unconnected_nodes(sentence_graph):
"""
Takes a TigerSentenceGraph and returns a list of node IDs of
unconnected nodes.
A node is unconnected, if it doesn't have any in- or outgoing edges.
A node is NOT considered unconnected, if the graph only consists of
that particular node.
Para... | python | def get_unconnected_nodes(sentence_graph):
"""
Takes a TigerSentenceGraph and returns a list of node IDs of
unconnected nodes.
A node is unconnected, if it doesn't have any in- or outgoing edges.
A node is NOT considered unconnected, if the graph only consists of
that particular node.
Para... | [
"def",
"get_unconnected_nodes",
"(",
"sentence_graph",
")",
":",
"return",
"[",
"node",
"for",
"node",
"in",
"sentence_graph",
".",
"nodes_iter",
"(",
")",
"if",
"sentence_graph",
".",
"degree",
"(",
"node",
")",
"==",
"0",
"and",
"sentence_graph",
".",
"num... | Takes a TigerSentenceGraph and returns a list of node IDs of
unconnected nodes.
A node is unconnected, if it doesn't have any in- or outgoing edges.
A node is NOT considered unconnected, if the graph only consists of
that particular node.
Parameters
----------
sentence_graph : TigerSentenc... | [
"Takes",
"a",
"TigerSentenceGraph",
"and",
"returns",
"a",
"list",
"of",
"node",
"IDs",
"of",
"unconnected",
"nodes",
"."
] | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/tiger.py#L319-L341 |
49,405 | arne-cl/discoursegraphs | src/discoursegraphs/readwrite/tiger.py | get_subordinate_clauses | def get_subordinate_clauses(tiger_docgraph):
"""
given a document graph of a TIGER syntax tree, return all
node IDs of nodes representing subordinate clause constituents.
Parameters
----------
tiger_docgraph : DiscourseDocumentGraph or TigerDocumentGraph
document graph from which subord... | python | def get_subordinate_clauses(tiger_docgraph):
"""
given a document graph of a TIGER syntax tree, return all
node IDs of nodes representing subordinate clause constituents.
Parameters
----------
tiger_docgraph : DiscourseDocumentGraph or TigerDocumentGraph
document graph from which subord... | [
"def",
"get_subordinate_clauses",
"(",
"tiger_docgraph",
")",
":",
"subord_clause_rels",
"=",
"dg",
".",
"select_edges_by_attribute",
"(",
"tiger_docgraph",
",",
"attribute",
"=",
"'tiger:label'",
",",
"value",
"=",
"[",
"'MO'",
",",
"'RC'",
",",
"'SB'",
"]",
")... | given a document graph of a TIGER syntax tree, return all
node IDs of nodes representing subordinate clause constituents.
Parameters
----------
tiger_docgraph : DiscourseDocumentGraph or TigerDocumentGraph
document graph from which subordinate clauses will be extracted
Returns
-------
... | [
"given",
"a",
"document",
"graph",
"of",
"a",
"TIGER",
"syntax",
"tree",
"return",
"all",
"node",
"IDs",
"of",
"nodes",
"representing",
"subordinate",
"clause",
"constituents",
"."
] | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/tiger.py#L344-L369 |
49,406 | arne-cl/discoursegraphs | src/discoursegraphs/readwrite/decour.py | DecourDocumentGraph._add_token_to_document | def _add_token_to_document(self, token_string, token_attrs=None):
"""add a token node to this document graph"""
token_feat = {self.ns+':token': token_string}
if token_attrs:
token_attrs.update(token_feat)
else:
token_attrs = token_feat
token_id = 'token_{}... | python | def _add_token_to_document(self, token_string, token_attrs=None):
"""add a token node to this document graph"""
token_feat = {self.ns+':token': token_string}
if token_attrs:
token_attrs.update(token_feat)
else:
token_attrs = token_feat
token_id = 'token_{}... | [
"def",
"_add_token_to_document",
"(",
"self",
",",
"token_string",
",",
"token_attrs",
"=",
"None",
")",
":",
"token_feat",
"=",
"{",
"self",
".",
"ns",
"+",
"':token'",
":",
"token_string",
"}",
"if",
"token_attrs",
":",
"token_attrs",
".",
"update",
"(",
... | add a token node to this document graph | [
"add",
"a",
"token",
"node",
"to",
"this",
"document",
"graph"
] | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/decour.py#L102-L114 |
49,407 | arne-cl/discoursegraphs | src/discoursegraphs/readwrite/decour.py | DecourDocumentGraph._add_dominance_relation | def _add_dominance_relation(self, source, target):
"""add a dominance relation to this docgraph"""
# TODO: fix #39, so we don't need to add nodes by hand
self.add_node(target, layers={self.ns, self.ns+':unit'})
self.add_edge(source, target,
layers={self.ns, self.ns+... | python | def _add_dominance_relation(self, source, target):
"""add a dominance relation to this docgraph"""
# TODO: fix #39, so we don't need to add nodes by hand
self.add_node(target, layers={self.ns, self.ns+':unit'})
self.add_edge(source, target,
layers={self.ns, self.ns+... | [
"def",
"_add_dominance_relation",
"(",
"self",
",",
"source",
",",
"target",
")",
":",
"# TODO: fix #39, so we don't need to add nodes by hand",
"self",
".",
"add_node",
"(",
"target",
",",
"layers",
"=",
"{",
"self",
".",
"ns",
",",
"self",
".",
"ns",
"+",
"'... | add a dominance relation to this docgraph | [
"add",
"a",
"dominance",
"relation",
"to",
"this",
"docgraph"
] | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/decour.py#L143-L149 |
49,408 | arne-cl/discoursegraphs | src/discoursegraphs/readwrite/decour.py | DecourDocumentGraph._add_spanning_relation | def _add_spanning_relation(self, source, target):
"""add a spanning relation to this docgraph"""
self.add_edge(source, target, layers={self.ns, self.ns+':unit'},
edge_type=EdgeTypes.spanning_relation) | python | def _add_spanning_relation(self, source, target):
"""add a spanning relation to this docgraph"""
self.add_edge(source, target, layers={self.ns, self.ns+':unit'},
edge_type=EdgeTypes.spanning_relation) | [
"def",
"_add_spanning_relation",
"(",
"self",
",",
"source",
",",
"target",
")",
":",
"self",
".",
"add_edge",
"(",
"source",
",",
"target",
",",
"layers",
"=",
"{",
"self",
".",
"ns",
",",
"self",
".",
"ns",
"+",
"':unit'",
"}",
",",
"edge_type",
"=... | add a spanning relation to this docgraph | [
"add",
"a",
"spanning",
"relation",
"to",
"this",
"docgraph"
] | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/decour.py#L151-L154 |
49,409 | operatingops/terraform_external_data | terraform_external_data/terraform_external_data.py | validate | def validate(data):
"""
Query data and result data must have keys who's values are strings.
"""
if not isinstance(data, dict):
error('Data must be a dictionary.')
for value in data.values():
if not isinstance(value, basestring):
error('Values must be strings.') | python | def validate(data):
"""
Query data and result data must have keys who's values are strings.
"""
if not isinstance(data, dict):
error('Data must be a dictionary.')
for value in data.values():
if not isinstance(value, basestring):
error('Values must be strings.') | [
"def",
"validate",
"(",
"data",
")",
":",
"if",
"not",
"isinstance",
"(",
"data",
",",
"dict",
")",
":",
"error",
"(",
"'Data must be a dictionary.'",
")",
"for",
"value",
"in",
"data",
".",
"values",
"(",
")",
":",
"if",
"not",
"isinstance",
"(",
"val... | Query data and result data must have keys who's values are strings. | [
"Query",
"data",
"and",
"result",
"data",
"must",
"have",
"keys",
"who",
"s",
"values",
"are",
"strings",
"."
] | 6b4c91ddb88143b974b18f982dd8d76789f166b4 | https://github.com/operatingops/terraform_external_data/blob/6b4c91ddb88143b974b18f982dd8d76789f166b4/terraform_external_data/terraform_external_data.py#L20-L28 |
49,410 | operatingops/terraform_external_data | terraform_external_data/terraform_external_data.py | terraform_external_data | def terraform_external_data(function):
"""
Query data is received on stdin as a JSON object.
Result data must be returned on stdout as a JSON object.
The wrapped function must expect its first positional argument to be a dictionary of the query data.
"""
@wraps(function)
def wrapper(*args, ... | python | def terraform_external_data(function):
"""
Query data is received on stdin as a JSON object.
Result data must be returned on stdout as a JSON object.
The wrapped function must expect its first positional argument to be a dictionary of the query data.
"""
@wraps(function)
def wrapper(*args, ... | [
"def",
"terraform_external_data",
"(",
"function",
")",
":",
"@",
"wraps",
"(",
"function",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"query",
"=",
"json",
".",
"loads",
"(",
"sys",
".",
"stdin",
".",
"read",
"(",
... | Query data is received on stdin as a JSON object.
Result data must be returned on stdout as a JSON object.
The wrapped function must expect its first positional argument to be a dictionary of the query data. | [
"Query",
"data",
"is",
"received",
"on",
"stdin",
"as",
"a",
"JSON",
"object",
".",
"Result",
"data",
"must",
"be",
"returned",
"on",
"stdout",
"as",
"a",
"JSON",
"object",
"."
] | 6b4c91ddb88143b974b18f982dd8d76789f166b4 | https://github.com/operatingops/terraform_external_data/blob/6b4c91ddb88143b974b18f982dd8d76789f166b4/terraform_external_data/terraform_external_data.py#L31-L49 |
49,411 | arne-cl/discoursegraphs | src/discoursegraphs/readwrite/rst/rs3/rs3tree.py | n_wrap | def n_wrap(tree, debug=False, root_id=None):
"""Ensure the given tree has a nucleus as its root.
If the root of the tree is a nucleus, return it.
If the root of the tree is a satellite, replace the satellite
with a nucleus and return the tree.
If the root of the tree is a relation, place a nucleus ... | python | def n_wrap(tree, debug=False, root_id=None):
"""Ensure the given tree has a nucleus as its root.
If the root of the tree is a nucleus, return it.
If the root of the tree is a satellite, replace the satellite
with a nucleus and return the tree.
If the root of the tree is a relation, place a nucleus ... | [
"def",
"n_wrap",
"(",
"tree",
",",
"debug",
"=",
"False",
",",
"root_id",
"=",
"None",
")",
":",
"root_label",
"=",
"tree",
".",
"label",
"(",
")",
"expected_n_root",
"=",
"debug_root_label",
"(",
"'N'",
",",
"debug",
"=",
"debug",
",",
"root_id",
"=",... | Ensure the given tree has a nucleus as its root.
If the root of the tree is a nucleus, return it.
If the root of the tree is a satellite, replace the satellite
with a nucleus and return the tree.
If the root of the tree is a relation, place a nucleus on top
and return the tree. | [
"Ensure",
"the",
"given",
"tree",
"has",
"a",
"nucleus",
"as",
"its",
"root",
"."
] | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/rst/rs3/rs3tree.py#L485-L505 |
49,412 | arne-cl/discoursegraphs | src/discoursegraphs/readwrite/rst/rs3/rs3tree.py | extract_relations | def extract_relations(dgtree, relations=None):
"""Extracts relations from a DGParentedTree.
Given a DGParentedTree, returns a (relation name, relation type) dict
of all the RST relations occurring in that tree.
"""
if hasattr(dgtree, 'reltypes'):
# dgtree is an RSTTree or a DisTree that con... | python | def extract_relations(dgtree, relations=None):
"""Extracts relations from a DGParentedTree.
Given a DGParentedTree, returns a (relation name, relation type) dict
of all the RST relations occurring in that tree.
"""
if hasattr(dgtree, 'reltypes'):
# dgtree is an RSTTree or a DisTree that con... | [
"def",
"extract_relations",
"(",
"dgtree",
",",
"relations",
"=",
"None",
")",
":",
"if",
"hasattr",
"(",
"dgtree",
",",
"'reltypes'",
")",
":",
"# dgtree is an RSTTree or a DisTree that contains a DGParentedTree",
"return",
"dgtree",
".",
"reltypes",
"if",
"relations... | Extracts relations from a DGParentedTree.
Given a DGParentedTree, returns a (relation name, relation type) dict
of all the RST relations occurring in that tree. | [
"Extracts",
"relations",
"from",
"a",
"DGParentedTree",
"."
] | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/rst/rs3/rs3tree.py#L531-L565 |
49,413 | arne-cl/discoursegraphs | src/discoursegraphs/readwrite/rst/rs3/rs3tree.py | RSTTree.elem_wrap | def elem_wrap(self, tree, debug=False, root_id=None):
"""takes a DGParentedTree and puts a nucleus or satellite on top,
depending on the nuclearity of the root element of the tree.
"""
if root_id is None:
root_id = tree.root_id
elem = self.elem_dict[root_id]
... | python | def elem_wrap(self, tree, debug=False, root_id=None):
"""takes a DGParentedTree and puts a nucleus or satellite on top,
depending on the nuclearity of the root element of the tree.
"""
if root_id is None:
root_id = tree.root_id
elem = self.elem_dict[root_id]
... | [
"def",
"elem_wrap",
"(",
"self",
",",
"tree",
",",
"debug",
"=",
"False",
",",
"root_id",
"=",
"None",
")",
":",
"if",
"root_id",
"is",
"None",
":",
"root_id",
"=",
"tree",
".",
"root_id",
"elem",
"=",
"self",
".",
"elem_dict",
"[",
"root_id",
"]",
... | takes a DGParentedTree and puts a nucleus or satellite on top,
depending on the nuclearity of the root element of the tree. | [
"takes",
"a",
"DGParentedTree",
"and",
"puts",
"a",
"nucleus",
"or",
"satellite",
"on",
"top",
"depending",
"on",
"the",
"nuclearity",
"of",
"the",
"root",
"element",
"of",
"the",
"tree",
"."
] | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/rst/rs3/rs3tree.py#L394-L405 |
49,414 | mattrobenolt/django-sudo | tasks.py | release | def release():
"Cut a new release"
version = run('python setup.py --version').stdout.strip()
assert version, 'No version found in setup.py?'
print('### Releasing new version: {0}'.format(version))
run('git tag {0}'.format(version))
run('git push --tags')
run('python setup.py sdist bdist_wh... | python | def release():
"Cut a new release"
version = run('python setup.py --version').stdout.strip()
assert version, 'No version found in setup.py?'
print('### Releasing new version: {0}'.format(version))
run('git tag {0}'.format(version))
run('git push --tags')
run('python setup.py sdist bdist_wh... | [
"def",
"release",
"(",
")",
":",
"version",
"=",
"run",
"(",
"'python setup.py --version'",
")",
".",
"stdout",
".",
"strip",
"(",
")",
"assert",
"version",
",",
"'No version found in setup.py?'",
"print",
"(",
"'### Releasing new version: {0}'",
".",
"format",
"(... | Cut a new release | [
"Cut",
"a",
"new",
"release"
] | 089e21a88bc3ebf9d76ea706f26707d2e4f3f729 | https://github.com/mattrobenolt/django-sudo/blob/089e21a88bc3ebf9d76ea706f26707d2e4f3f729/tasks.py#L28-L38 |
49,415 | kata198/python-nonblock | nonblock/BackgroundWrite.py | bgwrite | def bgwrite(fileObj, data, closeWhenFinished=False, chainAfter=None, ioPrio=4):
'''
bgwrite - Start a background writing process
@param fileObj <stream> - A stream backed by an fd
@param data <str/bytes/list> - The data to write. If a list is given, each successive element will ... | python | def bgwrite(fileObj, data, closeWhenFinished=False, chainAfter=None, ioPrio=4):
'''
bgwrite - Start a background writing process
@param fileObj <stream> - A stream backed by an fd
@param data <str/bytes/list> - The data to write. If a list is given, each successive element will ... | [
"def",
"bgwrite",
"(",
"fileObj",
",",
"data",
",",
"closeWhenFinished",
"=",
"False",
",",
"chainAfter",
"=",
"None",
",",
"ioPrio",
"=",
"4",
")",
":",
"thread",
"=",
"BackgroundWriteProcess",
"(",
"fileObj",
",",
"data",
",",
"closeWhenFinished",
",",
"... | bgwrite - Start a background writing process
@param fileObj <stream> - A stream backed by an fd
@param data <str/bytes/list> - The data to write. If a list is given, each successive element will be written to the fileObj and flushed. If a string/bytes is provided, it will be chunked accordi... | [
"bgwrite",
"-",
"Start",
"a",
"background",
"writing",
"process"
] | 3f011b3b3b494ccb44d48179e94167fb7382e4a4 | https://github.com/kata198/python-nonblock/blob/3f011b3b3b494ccb44d48179e94167fb7382e4a4/nonblock/BackgroundWrite.py#L30-L52 |
49,416 | kata198/python-nonblock | nonblock/BackgroundWrite.py | BackgroundWriteProcess.run | def run(self):
'''
run - Starts the thread. bgwrite and bgwrite_chunk automatically start the thread.
'''
# If we are chaining after another process, wait for it to complete.
# We use a flag here instead of joining the thread for various reasons
chainAfter = self.c... | python | def run(self):
'''
run - Starts the thread. bgwrite and bgwrite_chunk automatically start the thread.
'''
# If we are chaining after another process, wait for it to complete.
# We use a flag here instead of joining the thread for various reasons
chainAfter = self.c... | [
"def",
"run",
"(",
"self",
")",
":",
"# If we are chaining after another process, wait for it to complete.",
"# We use a flag here instead of joining the thread for various reasons",
"chainAfter",
"=",
"self",
".",
"chainAfter",
"if",
"chainAfter",
"is",
"not",
"None",
":",
"... | run - Starts the thread. bgwrite and bgwrite_chunk automatically start the thread. | [
"run",
"-",
"Starts",
"the",
"thread",
".",
"bgwrite",
"and",
"bgwrite_chunk",
"automatically",
"start",
"the",
"thread",
"."
] | 3f011b3b3b494ccb44d48179e94167fb7382e4a4 | https://github.com/kata198/python-nonblock/blob/3f011b3b3b494ccb44d48179e94167fb7382e4a4/nonblock/BackgroundWrite.py#L212-L340 |
49,417 | arne-cl/discoursegraphs | src/discoursegraphs/statistics.py | print_sorted_counter | def print_sorted_counter(counter, tab=1):
"""print all elements of a counter in descending order"""
for key, count in sorted(counter.items(), key=itemgetter(1), reverse=True):
print "{0}{1} - {2}".format('\t'*tab, key, count) | python | def print_sorted_counter(counter, tab=1):
"""print all elements of a counter in descending order"""
for key, count in sorted(counter.items(), key=itemgetter(1), reverse=True):
print "{0}{1} - {2}".format('\t'*tab, key, count) | [
"def",
"print_sorted_counter",
"(",
"counter",
",",
"tab",
"=",
"1",
")",
":",
"for",
"key",
",",
"count",
"in",
"sorted",
"(",
"counter",
".",
"items",
"(",
")",
",",
"key",
"=",
"itemgetter",
"(",
"1",
")",
",",
"reverse",
"=",
"True",
")",
":",
... | print all elements of a counter in descending order | [
"print",
"all",
"elements",
"of",
"a",
"counter",
"in",
"descending",
"order"
] | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/statistics.py#L16-L19 |
49,418 | arne-cl/discoursegraphs | src/discoursegraphs/statistics.py | print_most_common | def print_most_common(counter, number=5, tab=1):
"""print the most common elements of a counter"""
for key, count in counter.most_common(number):
print "{0}{1} - {2}".format('\t'*tab, key, count) | python | def print_most_common(counter, number=5, tab=1):
"""print the most common elements of a counter"""
for key, count in counter.most_common(number):
print "{0}{1} - {2}".format('\t'*tab, key, count) | [
"def",
"print_most_common",
"(",
"counter",
",",
"number",
"=",
"5",
",",
"tab",
"=",
"1",
")",
":",
"for",
"key",
",",
"count",
"in",
"counter",
".",
"most_common",
"(",
"number",
")",
":",
"print",
"\"{0}{1} - {2}\"",
".",
"format",
"(",
"'\\t'",
"*"... | print the most common elements of a counter | [
"print",
"the",
"most",
"common",
"elements",
"of",
"a",
"counter"
] | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/statistics.py#L22-L25 |
49,419 | arne-cl/discoursegraphs | src/discoursegraphs/statistics.py | info | def info(docgraph):
"""print node and edge statistics of a document graph"""
print networkx.info(docgraph), '\n'
node_statistics(docgraph)
print
edge_statistics(docgraph) | python | def info(docgraph):
"""print node and edge statistics of a document graph"""
print networkx.info(docgraph), '\n'
node_statistics(docgraph)
print
edge_statistics(docgraph) | [
"def",
"info",
"(",
"docgraph",
")",
":",
"print",
"networkx",
".",
"info",
"(",
"docgraph",
")",
",",
"'\\n'",
"node_statistics",
"(",
"docgraph",
")",
"print",
"edge_statistics",
"(",
"docgraph",
")"
] | print node and edge statistics of a document graph | [
"print",
"node",
"and",
"edge",
"statistics",
"of",
"a",
"document",
"graph"
] | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/statistics.py#L71-L76 |
49,420 | clintval/sample-sheet | sample_sheet/__init__.py | ReadStructure._sum_cycles_from_tokens | def _sum_cycles_from_tokens(self, tokens: List[str]) -> int:
"""Sum the total number of cycles over a list of tokens."""
return sum((int(self._nonnumber_pattern.sub('', t)) for t in tokens)) | python | def _sum_cycles_from_tokens(self, tokens: List[str]) -> int:
"""Sum the total number of cycles over a list of tokens."""
return sum((int(self._nonnumber_pattern.sub('', t)) for t in tokens)) | [
"def",
"_sum_cycles_from_tokens",
"(",
"self",
",",
"tokens",
":",
"List",
"[",
"str",
"]",
")",
"->",
"int",
":",
"return",
"sum",
"(",
"(",
"int",
"(",
"self",
".",
"_nonnumber_pattern",
".",
"sub",
"(",
"''",
",",
"t",
")",
")",
"for",
"t",
"in"... | Sum the total number of cycles over a list of tokens. | [
"Sum",
"the",
"total",
"number",
"of",
"cycles",
"over",
"a",
"list",
"of",
"tokens",
"."
] | 116ac6f26f6e61b57716c90f6e887d3d457756f3 | https://github.com/clintval/sample-sheet/blob/116ac6f26f6e61b57716c90f6e887d3d457756f3/sample_sheet/__init__.py#L118-L120 |
49,421 | clintval/sample-sheet | sample_sheet/__init__.py | ReadStructure.template_cycles | def template_cycles(self) -> int:
"""The number of cycles dedicated to template."""
return sum((int(re.sub(r'\D', '', op)) for op in self.template_tokens)) | python | def template_cycles(self) -> int:
"""The number of cycles dedicated to template."""
return sum((int(re.sub(r'\D', '', op)) for op in self.template_tokens)) | [
"def",
"template_cycles",
"(",
"self",
")",
"->",
"int",
":",
"return",
"sum",
"(",
"(",
"int",
"(",
"re",
".",
"sub",
"(",
"r'\\D'",
",",
"''",
",",
"op",
")",
")",
"for",
"op",
"in",
"self",
".",
"template_tokens",
")",
")"
] | The number of cycles dedicated to template. | [
"The",
"number",
"of",
"cycles",
"dedicated",
"to",
"template",
"."
] | 116ac6f26f6e61b57716c90f6e887d3d457756f3 | https://github.com/clintval/sample-sheet/blob/116ac6f26f6e61b57716c90f6e887d3d457756f3/sample_sheet/__init__.py#L168-L170 |
49,422 | clintval/sample-sheet | sample_sheet/__init__.py | ReadStructure.skip_cycles | def skip_cycles(self) -> int:
"""The number of cycles dedicated to skips."""
return sum((int(re.sub(r'\D', '', op)) for op in self.skip_tokens)) | python | def skip_cycles(self) -> int:
"""The number of cycles dedicated to skips."""
return sum((int(re.sub(r'\D', '', op)) for op in self.skip_tokens)) | [
"def",
"skip_cycles",
"(",
"self",
")",
"->",
"int",
":",
"return",
"sum",
"(",
"(",
"int",
"(",
"re",
".",
"sub",
"(",
"r'\\D'",
",",
"''",
",",
"op",
")",
")",
"for",
"op",
"in",
"self",
".",
"skip_tokens",
")",
")"
] | The number of cycles dedicated to skips. | [
"The",
"number",
"of",
"cycles",
"dedicated",
"to",
"skips",
"."
] | 116ac6f26f6e61b57716c90f6e887d3d457756f3 | https://github.com/clintval/sample-sheet/blob/116ac6f26f6e61b57716c90f6e887d3d457756f3/sample_sheet/__init__.py#L173-L175 |
49,423 | clintval/sample-sheet | sample_sheet/__init__.py | ReadStructure.umi_cycles | def umi_cycles(self) -> int:
"""The number of cycles dedicated to UMI."""
return sum((int(re.sub(r'\D', '', op)) for op in self.umi_tokens)) | python | def umi_cycles(self) -> int:
"""The number of cycles dedicated to UMI."""
return sum((int(re.sub(r'\D', '', op)) for op in self.umi_tokens)) | [
"def",
"umi_cycles",
"(",
"self",
")",
"->",
"int",
":",
"return",
"sum",
"(",
"(",
"int",
"(",
"re",
".",
"sub",
"(",
"r'\\D'",
",",
"''",
",",
"op",
")",
")",
"for",
"op",
"in",
"self",
".",
"umi_tokens",
")",
")"
] | The number of cycles dedicated to UMI. | [
"The",
"number",
"of",
"cycles",
"dedicated",
"to",
"UMI",
"."
] | 116ac6f26f6e61b57716c90f6e887d3d457756f3 | https://github.com/clintval/sample-sheet/blob/116ac6f26f6e61b57716c90f6e887d3d457756f3/sample_sheet/__init__.py#L178-L180 |
49,424 | clintval/sample-sheet | sample_sheet/__init__.py | ReadStructure.total_cycles | def total_cycles(self) -> int:
"""The number of total number of cycles in the structure."""
return sum((int(re.sub(r'\D', '', op)) for op in self.tokens)) | python | def total_cycles(self) -> int:
"""The number of total number of cycles in the structure."""
return sum((int(re.sub(r'\D', '', op)) for op in self.tokens)) | [
"def",
"total_cycles",
"(",
"self",
")",
"->",
"int",
":",
"return",
"sum",
"(",
"(",
"int",
"(",
"re",
".",
"sub",
"(",
"r'\\D'",
",",
"''",
",",
"op",
")",
")",
"for",
"op",
"in",
"self",
".",
"tokens",
")",
")"
] | The number of total number of cycles in the structure. | [
"The",
"number",
"of",
"total",
"number",
"of",
"cycles",
"in",
"the",
"structure",
"."
] | 116ac6f26f6e61b57716c90f6e887d3d457756f3 | https://github.com/clintval/sample-sheet/blob/116ac6f26f6e61b57716c90f6e887d3d457756f3/sample_sheet/__init__.py#L183-L185 |
49,425 | clintval/sample-sheet | sample_sheet/__init__.py | SampleSheet.experimental_design | def experimental_design(self) -> Any:
"""Return a markdown summary of the samples on this sample sheet.
This property supports displaying rendered markdown only when running
within an IPython interpreter. If we are not running in an IPython
interpreter, then print out a nicely formatted... | python | def experimental_design(self) -> Any:
"""Return a markdown summary of the samples on this sample sheet.
This property supports displaying rendered markdown only when running
within an IPython interpreter. If we are not running in an IPython
interpreter, then print out a nicely formatted... | [
"def",
"experimental_design",
"(",
"self",
")",
"->",
"Any",
":",
"if",
"not",
"self",
".",
"samples",
":",
"raise",
"ValueError",
"(",
"'No samples in sample sheet'",
")",
"markdown",
"=",
"tabulate",
"(",
"[",
"[",
"getattr",
"(",
"s",
",",
"h",
",",
"... | Return a markdown summary of the samples on this sample sheet.
This property supports displaying rendered markdown only when running
within an IPython interpreter. If we are not running in an IPython
interpreter, then print out a nicely formatted ASCII table.
Returns:
Markd... | [
"Return",
"a",
"markdown",
"summary",
"of",
"the",
"samples",
"on",
"this",
"sample",
"sheet",
"."
] | 116ac6f26f6e61b57716c90f6e887d3d457756f3 | https://github.com/clintval/sample-sheet/blob/116ac6f26f6e61b57716c90f6e887d3d457756f3/sample_sheet/__init__.py#L433-L453 |
49,426 | clintval/sample-sheet | sample_sheet/__init__.py | SampleSheet._repr_tty_ | def _repr_tty_(self) -> str:
"""Return a summary of this sample sheet in a TTY compatible codec."""
header_description = ['Sample_ID', 'Description']
header_samples = [
'Sample_ID',
'Sample_Name',
'Library_ID',
'index',
'index2',
... | python | def _repr_tty_(self) -> str:
"""Return a summary of this sample sheet in a TTY compatible codec."""
header_description = ['Sample_ID', 'Description']
header_samples = [
'Sample_ID',
'Sample_Name',
'Library_ID',
'index',
'index2',
... | [
"def",
"_repr_tty_",
"(",
"self",
")",
"->",
"str",
":",
"header_description",
"=",
"[",
"'Sample_ID'",
",",
"'Description'",
"]",
"header_samples",
"=",
"[",
"'Sample_ID'",
",",
"'Sample_Name'",
",",
"'Library_ID'",
",",
"'index'",
",",
"'index2'",
",",
"]",
... | Return a summary of this sample sheet in a TTY compatible codec. | [
"Return",
"a",
"summary",
"of",
"this",
"sample",
"sheet",
"in",
"a",
"TTY",
"compatible",
"codec",
"."
] | 116ac6f26f6e61b57716c90f6e887d3d457756f3 | https://github.com/clintval/sample-sheet/blob/116ac6f26f6e61b57716c90f6e887d3d457756f3/sample_sheet/__init__.py#L941-L998 |
49,427 | michaeljohnbarr/django-timezone-utils | timezone_utils/fields.py | TimeZoneField.get_prep_value | def get_prep_value(self, value):
"""Converts timezone instances to strings for db storage."""
# pylint: disable=newstyle
value = super(TimeZoneField, self).get_prep_value(value)
if isinstance(value, tzinfo):
return value.zone
return value | python | def get_prep_value(self, value):
"""Converts timezone instances to strings for db storage."""
# pylint: disable=newstyle
value = super(TimeZoneField, self).get_prep_value(value)
if isinstance(value, tzinfo):
return value.zone
return value | [
"def",
"get_prep_value",
"(",
"self",
",",
"value",
")",
":",
"# pylint: disable=newstyle",
"value",
"=",
"super",
"(",
"TimeZoneField",
",",
"self",
")",
".",
"get_prep_value",
"(",
"value",
")",
"if",
"isinstance",
"(",
"value",
",",
"tzinfo",
")",
":",
... | Converts timezone instances to strings for db storage. | [
"Converts",
"timezone",
"instances",
"to",
"strings",
"for",
"db",
"storage",
"."
] | 61c8b50c59049cb7eccd4e3892f332f88b890f00 | https://github.com/michaeljohnbarr/django-timezone-utils/blob/61c8b50c59049cb7eccd4e3892f332f88b890f00/timezone_utils/fields.py#L77-L85 |
49,428 | michaeljohnbarr/django-timezone-utils | timezone_utils/fields.py | TimeZoneField.to_python | def to_python(self, value):
"""Returns a datetime.tzinfo instance for the value."""
# pylint: disable=newstyle
value = super(TimeZoneField, self).to_python(value)
if not value:
return value
try:
return pytz.timezone(str(value))
except pytz.Unknow... | python | def to_python(self, value):
"""Returns a datetime.tzinfo instance for the value."""
# pylint: disable=newstyle
value = super(TimeZoneField, self).to_python(value)
if not value:
return value
try:
return pytz.timezone(str(value))
except pytz.Unknow... | [
"def",
"to_python",
"(",
"self",
",",
"value",
")",
":",
"# pylint: disable=newstyle",
"value",
"=",
"super",
"(",
"TimeZoneField",
",",
"self",
")",
".",
"to_python",
"(",
"value",
")",
"if",
"not",
"value",
":",
"return",
"value",
"try",
":",
"return",
... | Returns a datetime.tzinfo instance for the value. | [
"Returns",
"a",
"datetime",
".",
"tzinfo",
"instance",
"for",
"the",
"value",
"."
] | 61c8b50c59049cb7eccd4e3892f332f88b890f00 | https://github.com/michaeljohnbarr/django-timezone-utils/blob/61c8b50c59049cb7eccd4e3892f332f88b890f00/timezone_utils/fields.py#L108-L123 |
49,429 | michaeljohnbarr/django-timezone-utils | timezone_utils/fields.py | TimeZoneField.formfield | def formfield(self, **kwargs):
"""Returns a custom form field for the TimeZoneField."""
defaults = {'form_class': forms.TimeZoneField}
defaults.update(**kwargs)
return super(TimeZoneField, self).formfield(**defaults) | python | def formfield(self, **kwargs):
"""Returns a custom form field for the TimeZoneField."""
defaults = {'form_class': forms.TimeZoneField}
defaults.update(**kwargs)
return super(TimeZoneField, self).formfield(**defaults) | [
"def",
"formfield",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"defaults",
"=",
"{",
"'form_class'",
":",
"forms",
".",
"TimeZoneField",
"}",
"defaults",
".",
"update",
"(",
"*",
"*",
"kwargs",
")",
"return",
"super",
"(",
"TimeZoneField",
",",
"s... | Returns a custom form field for the TimeZoneField. | [
"Returns",
"a",
"custom",
"form",
"field",
"for",
"the",
"TimeZoneField",
"."
] | 61c8b50c59049cb7eccd4e3892f332f88b890f00 | https://github.com/michaeljohnbarr/django-timezone-utils/blob/61c8b50c59049cb7eccd4e3892f332f88b890f00/timezone_utils/fields.py#L126-L131 |
49,430 | michaeljohnbarr/django-timezone-utils | timezone_utils/fields.py | TimeZoneField.check | def check(self, **kwargs): # pragma: no cover
"""Calls the TimeZoneField's custom checks."""
errors = super(TimeZoneField, self).check(**kwargs)
errors.extend(self._check_timezone_max_length_attribute())
errors.extend(self._check_choices_attribute())
return errors | python | def check(self, **kwargs): # pragma: no cover
"""Calls the TimeZoneField's custom checks."""
errors = super(TimeZoneField, self).check(**kwargs)
errors.extend(self._check_timezone_max_length_attribute())
errors.extend(self._check_choices_attribute())
return errors | [
"def",
"check",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"# pragma: no cover",
"errors",
"=",
"super",
"(",
"TimeZoneField",
",",
"self",
")",
".",
"check",
"(",
"*",
"*",
"kwargs",
")",
"errors",
".",
"extend",
"(",
"self",
".",
"_check_timezon... | Calls the TimeZoneField's custom checks. | [
"Calls",
"the",
"TimeZoneField",
"s",
"custom",
"checks",
"."
] | 61c8b50c59049cb7eccd4e3892f332f88b890f00 | https://github.com/michaeljohnbarr/django-timezone-utils/blob/61c8b50c59049cb7eccd4e3892f332f88b890f00/timezone_utils/fields.py#L137-L143 |
49,431 | michaeljohnbarr/django-timezone-utils | timezone_utils/fields.py | TimeZoneField._check_timezone_max_length_attribute | def _check_timezone_max_length_attribute(self): # pragma: no cover
"""
Checks that the `max_length` attribute covers all possible pytz
timezone lengths.
"""
# Retrieve the maximum possible length for the time zone string
possible_max_length = max(map(len, pytz.all_ti... | python | def _check_timezone_max_length_attribute(self): # pragma: no cover
"""
Checks that the `max_length` attribute covers all possible pytz
timezone lengths.
"""
# Retrieve the maximum possible length for the time zone string
possible_max_length = max(map(len, pytz.all_ti... | [
"def",
"_check_timezone_max_length_attribute",
"(",
"self",
")",
":",
"# pragma: no cover",
"# Retrieve the maximum possible length for the time zone string",
"possible_max_length",
"=",
"max",
"(",
"map",
"(",
"len",
",",
"pytz",
".",
"all_timezones",
")",
")",
"# Make sur... | Checks that the `max_length` attribute covers all possible pytz
timezone lengths. | [
"Checks",
"that",
"the",
"max_length",
"attribute",
"covers",
"all",
"possible",
"pytz",
"timezone",
"lengths",
"."
] | 61c8b50c59049cb7eccd4e3892f332f88b890f00 | https://github.com/michaeljohnbarr/django-timezone-utils/blob/61c8b50c59049cb7eccd4e3892f332f88b890f00/timezone_utils/fields.py#L145-L177 |
49,432 | michaeljohnbarr/django-timezone-utils | timezone_utils/fields.py | TimeZoneField._check_choices_attribute | def _check_choices_attribute(self): # pragma: no cover
"""Checks to make sure that choices contains valid timezone choices."""
if self.choices:
warning_params = {
'msg': (
"'choices' contains an invalid time zone value '{value}' "
"w... | python | def _check_choices_attribute(self): # pragma: no cover
"""Checks to make sure that choices contains valid timezone choices."""
if self.choices:
warning_params = {
'msg': (
"'choices' contains an invalid time zone value '{value}' "
"w... | [
"def",
"_check_choices_attribute",
"(",
"self",
")",
":",
"# pragma: no cover",
"if",
"self",
".",
"choices",
":",
"warning_params",
"=",
"{",
"'msg'",
":",
"(",
"\"'choices' contains an invalid time zone value '{value}' \"",
"\"which was not found as a supported time zone by p... | Checks to make sure that choices contains valid timezone choices. | [
"Checks",
"to",
"make",
"sure",
"that",
"choices",
"contains",
"valid",
"timezone",
"choices",
"."
] | 61c8b50c59049cb7eccd4e3892f332f88b890f00 | https://github.com/michaeljohnbarr/django-timezone-utils/blob/61c8b50c59049cb7eccd4e3892f332f88b890f00/timezone_utils/fields.py#L179-L233 |
49,433 | michaeljohnbarr/django-timezone-utils | timezone_utils/fields.py | LinkedTZDateTimeField.to_python | def to_python(self, value):
"""Convert the value to the appropriate timezone."""
# pylint: disable=newstyle
value = super(LinkedTZDateTimeField, self).to_python(value)
if not value:
return value
return value.astimezone(self.timezone) | python | def to_python(self, value):
"""Convert the value to the appropriate timezone."""
# pylint: disable=newstyle
value = super(LinkedTZDateTimeField, self).to_python(value)
if not value:
return value
return value.astimezone(self.timezone) | [
"def",
"to_python",
"(",
"self",
",",
"value",
")",
":",
"# pylint: disable=newstyle",
"value",
"=",
"super",
"(",
"LinkedTZDateTimeField",
",",
"self",
")",
".",
"to_python",
"(",
"value",
")",
"if",
"not",
"value",
":",
"return",
"value",
"return",
"value"... | Convert the value to the appropriate timezone. | [
"Convert",
"the",
"value",
"to",
"the",
"appropriate",
"timezone",
"."
] | 61c8b50c59049cb7eccd4e3892f332f88b890f00 | https://github.com/michaeljohnbarr/django-timezone-utils/blob/61c8b50c59049cb7eccd4e3892f332f88b890f00/timezone_utils/fields.py#L266-L274 |
49,434 | michaeljohnbarr/django-timezone-utils | timezone_utils/fields.py | LinkedTZDateTimeField.pre_save | def pre_save(self, model_instance, add):
"""
Converts the value being saved based on `populate_from` and
`time_override`
"""
# pylint: disable=newstyle
# Retrieve the currently entered datetime
value = super(
LinkedTZDateTimeField,
self
... | python | def pre_save(self, model_instance, add):
"""
Converts the value being saved based on `populate_from` and
`time_override`
"""
# pylint: disable=newstyle
# Retrieve the currently entered datetime
value = super(
LinkedTZDateTimeField,
self
... | [
"def",
"pre_save",
"(",
"self",
",",
"model_instance",
",",
"add",
")",
":",
"# pylint: disable=newstyle",
"# Retrieve the currently entered datetime",
"value",
"=",
"super",
"(",
"LinkedTZDateTimeField",
",",
"self",
")",
".",
"pre_save",
"(",
"model_instance",
"=",
... | Converts the value being saved based on `populate_from` and
`time_override` | [
"Converts",
"the",
"value",
"being",
"saved",
"based",
"on",
"populate_from",
"and",
"time_override"
] | 61c8b50c59049cb7eccd4e3892f332f88b890f00 | https://github.com/michaeljohnbarr/django-timezone-utils/blob/61c8b50c59049cb7eccd4e3892f332f88b890f00/timezone_utils/fields.py#L276-L300 |
49,435 | michaeljohnbarr/django-timezone-utils | timezone_utils/fields.py | LinkedTZDateTimeField.deconstruct | def deconstruct(self): # pragma: no cover
"""Add our custom keyword arguments for migrations."""
# pylint: disable=newstyle
name, path, args, kwargs = super(
LinkedTZDateTimeField,
self
).deconstruct()
# Only include kwarg if it's not the default
... | python | def deconstruct(self): # pragma: no cover
"""Add our custom keyword arguments for migrations."""
# pylint: disable=newstyle
name, path, args, kwargs = super(
LinkedTZDateTimeField,
self
).deconstruct()
# Only include kwarg if it's not the default
... | [
"def",
"deconstruct",
"(",
"self",
")",
":",
"# pragma: no cover",
"# pylint: disable=newstyle",
"name",
",",
"path",
",",
"args",
",",
"kwargs",
"=",
"super",
"(",
"LinkedTZDateTimeField",
",",
"self",
")",
".",
"deconstruct",
"(",
")",
"# Only include kwarg if i... | Add our custom keyword arguments for migrations. | [
"Add",
"our",
"custom",
"keyword",
"arguments",
"for",
"migrations",
"."
] | 61c8b50c59049cb7eccd4e3892f332f88b890f00 | https://github.com/michaeljohnbarr/django-timezone-utils/blob/61c8b50c59049cb7eccd4e3892f332f88b890f00/timezone_utils/fields.py#L302-L325 |
49,436 | michaeljohnbarr/django-timezone-utils | timezone_utils/fields.py | LinkedTZDateTimeField._get_populate_from | def _get_populate_from(self, model_instance):
"""
Retrieves the timezone or None from the `populate_from` attribute.
"""
if hasattr(self.populate_from, '__call__'):
tz = self.populate_from(model_instance)
else:
from_attr = getattr(model_instance, self.pop... | python | def _get_populate_from(self, model_instance):
"""
Retrieves the timezone or None from the `populate_from` attribute.
"""
if hasattr(self.populate_from, '__call__'):
tz = self.populate_from(model_instance)
else:
from_attr = getattr(model_instance, self.pop... | [
"def",
"_get_populate_from",
"(",
"self",
",",
"model_instance",
")",
":",
"if",
"hasattr",
"(",
"self",
".",
"populate_from",
",",
"'__call__'",
")",
":",
"tz",
"=",
"self",
".",
"populate_from",
"(",
"model_instance",
")",
"else",
":",
"from_attr",
"=",
... | Retrieves the timezone or None from the `populate_from` attribute. | [
"Retrieves",
"the",
"timezone",
"or",
"None",
"from",
"the",
"populate_from",
"attribute",
"."
] | 61c8b50c59049cb7eccd4e3892f332f88b890f00 | https://github.com/michaeljohnbarr/django-timezone-utils/blob/61c8b50c59049cb7eccd4e3892f332f88b890f00/timezone_utils/fields.py#L327-L347 |
49,437 | michaeljohnbarr/django-timezone-utils | timezone_utils/fields.py | LinkedTZDateTimeField._get_time_override | def _get_time_override(self):
"""
Retrieves the datetime.time or None from the `time_override` attribute.
"""
if callable(self.time_override):
time_override = self.time_override()
else:
time_override = self.time_override
if not isinstance(time_ov... | python | def _get_time_override(self):
"""
Retrieves the datetime.time or None from the `time_override` attribute.
"""
if callable(self.time_override):
time_override = self.time_override()
else:
time_override = self.time_override
if not isinstance(time_ov... | [
"def",
"_get_time_override",
"(",
"self",
")",
":",
"if",
"callable",
"(",
"self",
".",
"time_override",
")",
":",
"time_override",
"=",
"self",
".",
"time_override",
"(",
")",
"else",
":",
"time_override",
"=",
"self",
".",
"time_override",
"if",
"not",
"... | Retrieves the datetime.time or None from the `time_override` attribute. | [
"Retrieves",
"the",
"datetime",
".",
"time",
"or",
"None",
"from",
"the",
"time_override",
"attribute",
"."
] | 61c8b50c59049cb7eccd4e3892f332f88b890f00 | https://github.com/michaeljohnbarr/django-timezone-utils/blob/61c8b50c59049cb7eccd4e3892f332f88b890f00/timezone_utils/fields.py#L349-L364 |
49,438 | michaeljohnbarr/django-timezone-utils | timezone_utils/fields.py | LinkedTZDateTimeField._convert_value | def _convert_value(self, value, model_instance, add):
"""
Converts the value to the appropriate timezone and time as declared by
the `time_override` and `populate_from` attributes.
"""
if not value:
return value
# Retrieve the default timezone as the default... | python | def _convert_value(self, value, model_instance, add):
"""
Converts the value to the appropriate timezone and time as declared by
the `time_override` and `populate_from` attributes.
"""
if not value:
return value
# Retrieve the default timezone as the default... | [
"def",
"_convert_value",
"(",
"self",
",",
"value",
",",
"model_instance",
",",
"add",
")",
":",
"if",
"not",
"value",
":",
"return",
"value",
"# Retrieve the default timezone as the default",
"tz",
"=",
"get_default_timezone",
"(",
")",
"# If populate_from exists, ov... | Converts the value to the appropriate timezone and time as declared by
the `time_override` and `populate_from` attributes. | [
"Converts",
"the",
"value",
"to",
"the",
"appropriate",
"timezone",
"and",
"time",
"as",
"declared",
"by",
"the",
"time_override",
"and",
"populate_from",
"attributes",
"."
] | 61c8b50c59049cb7eccd4e3892f332f88b890f00 | https://github.com/michaeljohnbarr/django-timezone-utils/blob/61c8b50c59049cb7eccd4e3892f332f88b890f00/timezone_utils/fields.py#L366-L407 |
49,439 | arne-cl/discoursegraphs | src/discoursegraphs/readwrite/rst/rstlatex.py | make_multinuc | def make_multinuc(relname, nucleii):
"""Creates a rst.sty Latex string representation of a multi-nuclear RST relation."""
nuc_strings = []
for nucleus in nucleii:
nuc_strings.append( MULTINUC_ELEMENT_TEMPLATE.substitute(nucleus=nucleus) )
nucleii_string = "\n\t" + "\n\t".join(nuc_strings)
re... | python | def make_multinuc(relname, nucleii):
"""Creates a rst.sty Latex string representation of a multi-nuclear RST relation."""
nuc_strings = []
for nucleus in nucleii:
nuc_strings.append( MULTINUC_ELEMENT_TEMPLATE.substitute(nucleus=nucleus) )
nucleii_string = "\n\t" + "\n\t".join(nuc_strings)
re... | [
"def",
"make_multinuc",
"(",
"relname",
",",
"nucleii",
")",
":",
"nuc_strings",
"=",
"[",
"]",
"for",
"nucleus",
"in",
"nucleii",
":",
"nuc_strings",
".",
"append",
"(",
"MULTINUC_ELEMENT_TEMPLATE",
".",
"substitute",
"(",
"nucleus",
"=",
"nucleus",
")",
")... | Creates a rst.sty Latex string representation of a multi-nuclear RST relation. | [
"Creates",
"a",
"rst",
".",
"sty",
"Latex",
"string",
"representation",
"of",
"a",
"multi",
"-",
"nuclear",
"RST",
"relation",
"."
] | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/rst/rstlatex.py#L77-L83 |
49,440 | arne-cl/discoursegraphs | src/discoursegraphs/readwrite/rst/rstlatex.py | make_multisat | def make_multisat(nucsat_tuples):
"""Creates a rst.sty Latex string representation of a multi-satellite RST subtree
(i.e. a set of nucleus-satellite relations that share the same nucleus.
"""
nucsat_tuples = [tup for tup in nucsat_tuples] # unpack the iterable, so we can check its length
assert len... | python | def make_multisat(nucsat_tuples):
"""Creates a rst.sty Latex string representation of a multi-satellite RST subtree
(i.e. a set of nucleus-satellite relations that share the same nucleus.
"""
nucsat_tuples = [tup for tup in nucsat_tuples] # unpack the iterable, so we can check its length
assert len... | [
"def",
"make_multisat",
"(",
"nucsat_tuples",
")",
":",
"nucsat_tuples",
"=",
"[",
"tup",
"for",
"tup",
"in",
"nucsat_tuples",
"]",
"# unpack the iterable, so we can check its length",
"assert",
"len",
"(",
"nucsat_tuples",
")",
">",
"1",
",",
"\"A multisat relation b... | Creates a rst.sty Latex string representation of a multi-satellite RST subtree
(i.e. a set of nucleus-satellite relations that share the same nucleus. | [
"Creates",
"a",
"rst",
".",
"sty",
"Latex",
"string",
"representation",
"of",
"a",
"multi",
"-",
"satellite",
"RST",
"subtree",
"(",
"i",
".",
"e",
".",
"a",
"set",
"of",
"nucleus",
"-",
"satellite",
"relations",
"that",
"share",
"the",
"same",
"nucleus"... | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/rst/rstlatex.py#L86-L119 |
49,441 | arne-cl/discoursegraphs | src/discoursegraphs/readwrite/rst/rstlatex.py | indent | def indent(text, amount, ch=' '):
"""Indents a string by the given amount of characters."""
padding = amount * ch
return ''.join(padding+line for line in text.splitlines(True)) | python | def indent(text, amount, ch=' '):
"""Indents a string by the given amount of characters."""
padding = amount * ch
return ''.join(padding+line for line in text.splitlines(True)) | [
"def",
"indent",
"(",
"text",
",",
"amount",
",",
"ch",
"=",
"' '",
")",
":",
"padding",
"=",
"amount",
"*",
"ch",
"return",
"''",
".",
"join",
"(",
"padding",
"+",
"line",
"for",
"line",
"in",
"text",
".",
"splitlines",
"(",
"True",
")",
")"
] | Indents a string by the given amount of characters. | [
"Indents",
"a",
"string",
"by",
"the",
"given",
"amount",
"of",
"characters",
"."
] | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/rst/rstlatex.py#L164-L167 |
49,442 | arne-cl/discoursegraphs | src/discoursegraphs/corpora.py | PCC.document_ids | def document_ids(self):
"""returns a list of document IDs used in the PCC"""
matches = [PCC_DOCID_RE.match(os.path.basename(fname))
for fname in pcc.tokenization]
return sorted(match.groups()[0] for match in matches) | python | def document_ids(self):
"""returns a list of document IDs used in the PCC"""
matches = [PCC_DOCID_RE.match(os.path.basename(fname))
for fname in pcc.tokenization]
return sorted(match.groups()[0] for match in matches) | [
"def",
"document_ids",
"(",
"self",
")",
":",
"matches",
"=",
"[",
"PCC_DOCID_RE",
".",
"match",
"(",
"os",
".",
"path",
".",
"basename",
"(",
"fname",
")",
")",
"for",
"fname",
"in",
"pcc",
".",
"tokenization",
"]",
"return",
"sorted",
"(",
"match",
... | returns a list of document IDs used in the PCC | [
"returns",
"a",
"list",
"of",
"document",
"IDs",
"used",
"in",
"the",
"PCC"
] | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/corpora.py#L79-L83 |
49,443 | arne-cl/discoursegraphs | src/discoursegraphs/corpora.py | PCC.get_document | def get_document(self, doc_id):
"""
given a document ID, returns a merged document graph containng all
available annotation layers.
"""
layer_graphs = []
for layer_name in self.layers:
layer_files, read_function = self.layers[layer_name]
for layer_... | python | def get_document(self, doc_id):
"""
given a document ID, returns a merged document graph containng all
available annotation layers.
"""
layer_graphs = []
for layer_name in self.layers:
layer_files, read_function = self.layers[layer_name]
for layer_... | [
"def",
"get_document",
"(",
"self",
",",
"doc_id",
")",
":",
"layer_graphs",
"=",
"[",
"]",
"for",
"layer_name",
"in",
"self",
".",
"layers",
":",
"layer_files",
",",
"read_function",
"=",
"self",
".",
"layers",
"[",
"layer_name",
"]",
"for",
"layer_file",... | given a document ID, returns a merged document graph containng all
available annotation layers. | [
"given",
"a",
"document",
"ID",
"returns",
"a",
"merged",
"document",
"graph",
"containng",
"all",
"available",
"annotation",
"layers",
"."
] | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/corpora.py#L89-L107 |
49,444 | arne-cl/discoursegraphs | src/discoursegraphs/corpora.py | PCC.get_files_by_layer | def get_files_by_layer(self, layer_name, file_pattern='*'):
"""
returns a list of all files with the given filename pattern in the
given PCC annotation layer
"""
layer_path = os.path.join(self.path, layer_name)
return list(dg.find_files(layer_path, file_pattern)) | python | def get_files_by_layer(self, layer_name, file_pattern='*'):
"""
returns a list of all files with the given filename pattern in the
given PCC annotation layer
"""
layer_path = os.path.join(self.path, layer_name)
return list(dg.find_files(layer_path, file_pattern)) | [
"def",
"get_files_by_layer",
"(",
"self",
",",
"layer_name",
",",
"file_pattern",
"=",
"'*'",
")",
":",
"layer_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"path",
",",
"layer_name",
")",
"return",
"list",
"(",
"dg",
".",
"find_files",
... | returns a list of all files with the given filename pattern in the
given PCC annotation layer | [
"returns",
"a",
"list",
"of",
"all",
"files",
"with",
"the",
"given",
"filename",
"pattern",
"in",
"the",
"given",
"PCC",
"annotation",
"layer"
] | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/corpora.py#L124-L130 |
49,445 | clintval/sample-sheet | sample_sheet/util.py | maybe_render_markdown | def maybe_render_markdown(string: str) -> Any:
"""Render a string as Markdown only if in an IPython interpreter."""
if is_ipython_interpreter(): # pragma: no cover
from IPython.display import Markdown # type: ignore # noqa: E501
return Markdown(string)
else:
return string | python | def maybe_render_markdown(string: str) -> Any:
"""Render a string as Markdown only if in an IPython interpreter."""
if is_ipython_interpreter(): # pragma: no cover
from IPython.display import Markdown # type: ignore # noqa: E501
return Markdown(string)
else:
return string | [
"def",
"maybe_render_markdown",
"(",
"string",
":",
"str",
")",
"->",
"Any",
":",
"if",
"is_ipython_interpreter",
"(",
")",
":",
"# pragma: no cover",
"from",
"IPython",
".",
"display",
"import",
"Markdown",
"# type: ignore # noqa: E501",
"return",
"Markdown",
"(",
... | Render a string as Markdown only if in an IPython interpreter. | [
"Render",
"a",
"string",
"as",
"Markdown",
"only",
"if",
"in",
"an",
"IPython",
"interpreter",
"."
] | 116ac6f26f6e61b57716c90f6e887d3d457756f3 | https://github.com/clintval/sample-sheet/blob/116ac6f26f6e61b57716c90f6e887d3d457756f3/sample_sheet/util.py#L14-L21 |
49,446 | arne-cl/discoursegraphs | src/discoursegraphs/readwrite/generic.py | generic_converter_cli | def generic_converter_cli(docgraph_class, file_descriptor=''):
"""
generic command line interface for importers. Will convert the file
specified on the command line into a dot representation of the
corresponding DiscourseDocumentGraph and write the output to stdout
or a file specified on the command... | python | def generic_converter_cli(docgraph_class, file_descriptor=''):
"""
generic command line interface for importers. Will convert the file
specified on the command line into a dot representation of the
corresponding DiscourseDocumentGraph and write the output to stdout
or a file specified on the command... | [
"def",
"generic_converter_cli",
"(",
"docgraph_class",
",",
"file_descriptor",
"=",
"''",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
")",
"parser",
".",
"add_argument",
"(",
"'input_file'",
",",
"help",
"=",
"'{} file to be converted'",
".",
... | generic command line interface for importers. Will convert the file
specified on the command line into a dot representation of the
corresponding DiscourseDocumentGraph and write the output to stdout
or a file specified on the command line.
Parameters
----------
docgraph_class : class
a ... | [
"generic",
"command",
"line",
"interface",
"for",
"importers",
".",
"Will",
"convert",
"the",
"file",
"specified",
"on",
"the",
"command",
"line",
"into",
"a",
"dot",
"representation",
"of",
"the",
"corresponding",
"DiscourseDocumentGraph",
"and",
"write",
"the",
... | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/generic.py#L42-L66 |
49,447 | IntegralDefense/cbinterface | cbinterface/modules/response.py | hyperLiveResponse.dump_sensor_memory | def dump_sensor_memory(self, cb_compress=False, custom_compress=False, custom_compress_file=None, auto_collect_result=False):
"""Customized function for dumping sensor memory.
:arguments cb_compress: If True, use CarbonBlack's built-in compression.
:arguments custom_compress_file: Supply path t... | python | def dump_sensor_memory(self, cb_compress=False, custom_compress=False, custom_compress_file=None, auto_collect_result=False):
"""Customized function for dumping sensor memory.
:arguments cb_compress: If True, use CarbonBlack's built-in compression.
:arguments custom_compress_file: Supply path t... | [
"def",
"dump_sensor_memory",
"(",
"self",
",",
"cb_compress",
"=",
"False",
",",
"custom_compress",
"=",
"False",
",",
"custom_compress_file",
"=",
"None",
",",
"auto_collect_result",
"=",
"False",
")",
":",
"print",
"(",
"\"~ dumping contents of memory on {}\"",
".... | Customized function for dumping sensor memory.
:arguments cb_compress: If True, use CarbonBlack's built-in compression.
:arguments custom_compress_file: Supply path to lr_tools/compress_file.bat to fork powershell compression
:collect_mem_file: If True, wait for memdump + and compression to com... | [
"Customized",
"function",
"for",
"dumping",
"sensor",
"memory",
"."
] | 30af06b56d723443b6fcf156756a2a20d395dd7f | https://github.com/IntegralDefense/cbinterface/blob/30af06b56d723443b6fcf156756a2a20d395dd7f/cbinterface/modules/response.py#L187-L249 |
49,448 | IntegralDefense/cbinterface | cbinterface/modules/response.py | hyperLiveResponse.dump_process_memory | def dump_process_memory(self, pid, working_dir="c:\\windows\\carbonblack\\", path_to_procdump=None):
"""Use sysinternals procdump to dump process memory on a specific process. If only the pid is specified, the default
behavior is to use the version of ProcDump supplied with cbinterface's pip3 installer.... | python | def dump_process_memory(self, pid, working_dir="c:\\windows\\carbonblack\\", path_to_procdump=None):
"""Use sysinternals procdump to dump process memory on a specific process. If only the pid is specified, the default
behavior is to use the version of ProcDump supplied with cbinterface's pip3 installer.... | [
"def",
"dump_process_memory",
"(",
"self",
",",
"pid",
",",
"working_dir",
"=",
"\"c:\\\\windows\\\\carbonblack\\\\\"",
",",
"path_to_procdump",
"=",
"None",
")",
":",
"self",
".",
"go_live",
"(",
")",
"print",
"(",
"\"~ dumping memory where pid={} for {}\"",
".",
"... | Use sysinternals procdump to dump process memory on a specific process. If only the pid is specified, the default
behavior is to use the version of ProcDump supplied with cbinterface's pip3 installer.
:requires: SysInternals ProcDump v9.0 included with cbinterface==1.1.0
:arguments pid: Process... | [
"Use",
"sysinternals",
"procdump",
"to",
"dump",
"process",
"memory",
"on",
"a",
"specific",
"process",
".",
"If",
"only",
"the",
"pid",
"is",
"specified",
"the",
"default",
"behavior",
"is",
"to",
"use",
"the",
"version",
"of",
"ProcDump",
"supplied",
"with... | 30af06b56d723443b6fcf156756a2a20d395dd7f | https://github.com/IntegralDefense/cbinterface/blob/30af06b56d723443b6fcf156756a2a20d395dd7f/cbinterface/modules/response.py#L252-L311 |
49,449 | arne-cl/discoursegraphs | src/discoursegraphs/readwrite/rst/urml.py | extract_relationtypes | def extract_relationtypes(urml_xml_tree):
"""
extracts the allowed RST relation names and relation types from
an URML XML file.
Parameters
----------
urml_xml_tree : lxml.etree._ElementTree
lxml ElementTree representation of an URML XML file
Returns
-------
relations : dict... | python | def extract_relationtypes(urml_xml_tree):
"""
extracts the allowed RST relation names and relation types from
an URML XML file.
Parameters
----------
urml_xml_tree : lxml.etree._ElementTree
lxml ElementTree representation of an URML XML file
Returns
-------
relations : dict... | [
"def",
"extract_relationtypes",
"(",
"urml_xml_tree",
")",
":",
"return",
"{",
"rel",
".",
"attrib",
"[",
"'name'",
"]",
":",
"rel",
".",
"attrib",
"[",
"'type'",
"]",
"for",
"rel",
"in",
"urml_xml_tree",
".",
"iterfind",
"(",
"'//header/reltypes/rel'",
")",... | extracts the allowed RST relation names and relation types from
an URML XML file.
Parameters
----------
urml_xml_tree : lxml.etree._ElementTree
lxml ElementTree representation of an URML XML file
Returns
-------
relations : dict of (str, str)
Returns a dictionary with RST r... | [
"extracts",
"the",
"allowed",
"RST",
"relation",
"names",
"and",
"relation",
"types",
"from",
"an",
"URML",
"XML",
"file",
"."
] | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/rst/urml.py#L366-L385 |
49,450 | jrderuiter/pybiomart | src/pybiomart/dataset.py | Dataset.filters | def filters(self):
"""List of filters available for the dataset."""
if self._filters is None:
self._filters, self._attributes = self._fetch_configuration()
return self._filters | python | def filters(self):
"""List of filters available for the dataset."""
if self._filters is None:
self._filters, self._attributes = self._fetch_configuration()
return self._filters | [
"def",
"filters",
"(",
"self",
")",
":",
"if",
"self",
".",
"_filters",
"is",
"None",
":",
"self",
".",
"_filters",
",",
"self",
".",
"_attributes",
"=",
"self",
".",
"_fetch_configuration",
"(",
")",
"return",
"self",
".",
"_filters"
] | List of filters available for the dataset. | [
"List",
"of",
"filters",
"available",
"for",
"the",
"dataset",
"."
] | 7802d45fe88549ab0512d6f37f815fc43b172b39 | https://github.com/jrderuiter/pybiomart/blob/7802d45fe88549ab0512d6f37f815fc43b172b39/src/pybiomart/dataset.py#L88-L92 |
49,451 | jrderuiter/pybiomart | src/pybiomart/dataset.py | Dataset.default_attributes | def default_attributes(self):
"""List of default attributes for the dataset."""
if self._default_attributes is None:
self._default_attributes = {
name: attr
for name, attr in self.attributes.items()
if attr.default is True
}
... | python | def default_attributes(self):
"""List of default attributes for the dataset."""
if self._default_attributes is None:
self._default_attributes = {
name: attr
for name, attr in self.attributes.items()
if attr.default is True
}
... | [
"def",
"default_attributes",
"(",
"self",
")",
":",
"if",
"self",
".",
"_default_attributes",
"is",
"None",
":",
"self",
".",
"_default_attributes",
"=",
"{",
"name",
":",
"attr",
"for",
"name",
",",
"attr",
"in",
"self",
".",
"attributes",
".",
"items",
... | List of default attributes for the dataset. | [
"List",
"of",
"default",
"attributes",
"for",
"the",
"dataset",
"."
] | 7802d45fe88549ab0512d6f37f815fc43b172b39 | https://github.com/jrderuiter/pybiomart/blob/7802d45fe88549ab0512d6f37f815fc43b172b39/src/pybiomart/dataset.py#L102-L110 |
49,452 | jrderuiter/pybiomart | src/pybiomart/dataset.py | Dataset.list_attributes | def list_attributes(self):
"""Lists available attributes in a readable DataFrame format.
Returns:
pd.DataFrame: Frame listing available attributes.
"""
def _row_gen(attributes):
for attr in attributes.values():
yield (attr.name, attr.display_name... | python | def list_attributes(self):
"""Lists available attributes in a readable DataFrame format.
Returns:
pd.DataFrame: Frame listing available attributes.
"""
def _row_gen(attributes):
for attr in attributes.values():
yield (attr.name, attr.display_name... | [
"def",
"list_attributes",
"(",
"self",
")",
":",
"def",
"_row_gen",
"(",
"attributes",
")",
":",
"for",
"attr",
"in",
"attributes",
".",
"values",
"(",
")",
":",
"yield",
"(",
"attr",
".",
"name",
",",
"attr",
".",
"display_name",
",",
"attr",
".",
"... | Lists available attributes in a readable DataFrame format.
Returns:
pd.DataFrame: Frame listing available attributes. | [
"Lists",
"available",
"attributes",
"in",
"a",
"readable",
"DataFrame",
"format",
"."
] | 7802d45fe88549ab0512d6f37f815fc43b172b39 | https://github.com/jrderuiter/pybiomart/blob/7802d45fe88549ab0512d6f37f815fc43b172b39/src/pybiomart/dataset.py#L112-L125 |
49,453 | jrderuiter/pybiomart | src/pybiomart/dataset.py | Dataset.list_filters | def list_filters(self):
"""Lists available filters in a readable DataFrame format.
Returns:
pd.DataFrame: Frame listing available filters.
"""
def _row_gen(attributes):
for attr in attributes.values():
yield (attr.name, attr.type, attr.descriptio... | python | def list_filters(self):
"""Lists available filters in a readable DataFrame format.
Returns:
pd.DataFrame: Frame listing available filters.
"""
def _row_gen(attributes):
for attr in attributes.values():
yield (attr.name, attr.type, attr.descriptio... | [
"def",
"list_filters",
"(",
"self",
")",
":",
"def",
"_row_gen",
"(",
"attributes",
")",
":",
"for",
"attr",
"in",
"attributes",
".",
"values",
"(",
")",
":",
"yield",
"(",
"attr",
".",
"name",
",",
"attr",
".",
"type",
",",
"attr",
".",
"description... | Lists available filters in a readable DataFrame format.
Returns:
pd.DataFrame: Frame listing available filters. | [
"Lists",
"available",
"filters",
"in",
"a",
"readable",
"DataFrame",
"format",
"."
] | 7802d45fe88549ab0512d6f37f815fc43b172b39 | https://github.com/jrderuiter/pybiomart/blob/7802d45fe88549ab0512d6f37f815fc43b172b39/src/pybiomart/dataset.py#L127-L139 |
49,454 | jrderuiter/pybiomart | src/pybiomart/dataset.py | Dataset.query | def query(self,
attributes=None,
filters=None,
only_unique=True,
use_attr_names=False,
dtypes = None
):
"""Queries the dataset to retrieve the contained data.
Args:
attributes (list[str]): Names of attribute... | python | def query(self,
attributes=None,
filters=None,
only_unique=True,
use_attr_names=False,
dtypes = None
):
"""Queries the dataset to retrieve the contained data.
Args:
attributes (list[str]): Names of attribute... | [
"def",
"query",
"(",
"self",
",",
"attributes",
"=",
"None",
",",
"filters",
"=",
"None",
",",
"only_unique",
"=",
"True",
",",
"use_attr_names",
"=",
"False",
",",
"dtypes",
"=",
"None",
")",
":",
"# Example query from Ensembl biomart:",
"#",
"# <?xml version... | Queries the dataset to retrieve the contained data.
Args:
attributes (list[str]): Names of attributes to fetch in query.
Attribute names must correspond to valid attributes. See
the attributes property for a list of valid attributes.
filters (dict[str,any... | [
"Queries",
"the",
"dataset",
"to",
"retrieve",
"the",
"contained",
"data",
"."
] | 7802d45fe88549ab0512d6f37f815fc43b172b39 | https://github.com/jrderuiter/pybiomart/blob/7802d45fe88549ab0512d6f37f815fc43b172b39/src/pybiomart/dataset.py#L181-L286 |
49,455 | jrderuiter/pybiomart | src/pybiomart/dataset.py | Dataset._add_filter_node | def _add_filter_node(root, filter_, value):
"""Adds filter xml node to root."""
filter_el = ElementTree.SubElement(root, 'Filter')
filter_el.set('name', filter_.name)
# Set filter value depending on type.
if filter_.type == 'boolean':
# Boolean case.
if v... | python | def _add_filter_node(root, filter_, value):
"""Adds filter xml node to root."""
filter_el = ElementTree.SubElement(root, 'Filter')
filter_el.set('name', filter_.name)
# Set filter value depending on type.
if filter_.type == 'boolean':
# Boolean case.
if v... | [
"def",
"_add_filter_node",
"(",
"root",
",",
"filter_",
",",
"value",
")",
":",
"filter_el",
"=",
"ElementTree",
".",
"SubElement",
"(",
"root",
",",
"'Filter'",
")",
"filter_el",
".",
"set",
"(",
"'name'",
",",
"filter_",
".",
"name",
")",
"# Set filter v... | Adds filter xml node to root. | [
"Adds",
"filter",
"xml",
"node",
"to",
"root",
"."
] | 7802d45fe88549ab0512d6f37f815fc43b172b39 | https://github.com/jrderuiter/pybiomart/blob/7802d45fe88549ab0512d6f37f815fc43b172b39/src/pybiomart/dataset.py#L294-L314 |
49,456 | arne-cl/discoursegraphs | src/discoursegraphs/readwrite/mmax2.py | get_potential_markables | def get_potential_markables(docgraph):
"""
returns a list of all NPs and PPs in the given docgraph.
Parameters
----------
docgraph : DiscourseDocumentGraph
a document graph that (at least) contains syntax trees
(imported from Tiger XML files)
Returns
-------
potential_m... | python | def get_potential_markables(docgraph):
"""
returns a list of all NPs and PPs in the given docgraph.
Parameters
----------
docgraph : DiscourseDocumentGraph
a document graph that (at least) contains syntax trees
(imported from Tiger XML files)
Returns
-------
potential_m... | [
"def",
"get_potential_markables",
"(",
"docgraph",
")",
":",
"potential_markables",
"=",
"[",
"]",
"for",
"node_id",
",",
"nattr",
"in",
"dg",
".",
"select_nodes_by_layer",
"(",
"docgraph",
",",
"'tiger:syntax'",
",",
"data",
"=",
"True",
")",
":",
"if",
"na... | returns a list of all NPs and PPs in the given docgraph.
Parameters
----------
docgraph : DiscourseDocumentGraph
a document graph that (at least) contains syntax trees
(imported from Tiger XML files)
Returns
-------
potential_markables : list of str or int
Node IDs of a... | [
"returns",
"a",
"list",
"of",
"all",
"NPs",
"and",
"PPs",
"in",
"the",
"given",
"docgraph",
"."
] | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/mmax2.py#L447-L480 |
49,457 | arne-cl/discoursegraphs | src/discoursegraphs/readwrite/mmax2.py | MMAXProject._parse_common_paths_file | def _parse_common_paths_file(project_path):
"""
Parses a common_paths.xml file and returns a dictionary of paths,
a dictionary of annotation level descriptions and the filename
of the style file.
Parameters
----------
project_path : str
path to the ro... | python | def _parse_common_paths_file(project_path):
"""
Parses a common_paths.xml file and returns a dictionary of paths,
a dictionary of annotation level descriptions and the filename
of the style file.
Parameters
----------
project_path : str
path to the ro... | [
"def",
"_parse_common_paths_file",
"(",
"project_path",
")",
":",
"common_paths_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"project_path",
",",
"'common_paths.xml'",
")",
"tree",
"=",
"etree",
".",
"parse",
"(",
"common_paths_file",
")",
"paths",
"=",
"{... | Parses a common_paths.xml file and returns a dictionary of paths,
a dictionary of annotation level descriptions and the filename
of the style file.
Parameters
----------
project_path : str
path to the root directory of the MMAX project
Returns
------... | [
"Parses",
"a",
"common_paths",
".",
"xml",
"file",
"and",
"returns",
"a",
"dictionary",
"of",
"paths",
"a",
"dictionary",
"of",
"annotation",
"level",
"descriptions",
"and",
"the",
"filename",
"of",
"the",
"style",
"file",
"."
] | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/mmax2.py#L33-L77 |
49,458 | arne-cl/discoursegraphs | src/discoursegraphs/readwrite/mmax2.py | MMAXDocumentGraph.get_sentences_and_token_nodes | def get_sentences_and_token_nodes(self):
"""
Returns a list of sentence root node IDs and a list of sentences,
where each list contains the token node IDs of that sentence.
Both lists will be empty if sentences were not annotated in the original
MMAX2 data.
TODO: Refacto... | python | def get_sentences_and_token_nodes(self):
"""
Returns a list of sentence root node IDs and a list of sentences,
where each list contains the token node IDs of that sentence.
Both lists will be empty if sentences were not annotated in the original
MMAX2 data.
TODO: Refacto... | [
"def",
"get_sentences_and_token_nodes",
"(",
"self",
")",
":",
"token_nodes",
"=",
"[",
"]",
"# if sentence annotations were ignored during MMAXDocumentGraph",
"# construction, we need to extract sentence/token node IDs manually",
"if",
"self",
".",
"ignore_sentence_annotations",
":"... | Returns a list of sentence root node IDs and a list of sentences,
where each list contains the token node IDs of that sentence.
Both lists will be empty if sentences were not annotated in the original
MMAX2 data.
TODO: Refactor this! There's code overlap with
self.add_annotation... | [
"Returns",
"a",
"list",
"of",
"sentence",
"root",
"node",
"IDs",
"and",
"a",
"list",
"of",
"sentences",
"where",
"each",
"list",
"contains",
"the",
"token",
"node",
"IDs",
"of",
"that",
"sentence",
".",
"Both",
"lists",
"will",
"be",
"empty",
"if",
"sent... | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/mmax2.py#L169-L223 |
49,459 | arne-cl/discoursegraphs | src/discoursegraphs/readwrite/mmax2.py | MMAXDocumentGraph.get_token_nodes_from_sentence | def get_token_nodes_from_sentence(self, sentence_root_node):
"""returns a list of token node IDs belonging to the given sentence"""
return spanstring2tokens(self, self.node[sentence_root_node][self.ns+':span']) | python | def get_token_nodes_from_sentence(self, sentence_root_node):
"""returns a list of token node IDs belonging to the given sentence"""
return spanstring2tokens(self, self.node[sentence_root_node][self.ns+':span']) | [
"def",
"get_token_nodes_from_sentence",
"(",
"self",
",",
"sentence_root_node",
")",
":",
"return",
"spanstring2tokens",
"(",
"self",
",",
"self",
".",
"node",
"[",
"sentence_root_node",
"]",
"[",
"self",
".",
"ns",
"+",
"':span'",
"]",
")"
] | returns a list of token node IDs belonging to the given sentence | [
"returns",
"a",
"list",
"of",
"token",
"node",
"IDs",
"belonging",
"to",
"the",
"given",
"sentence"
] | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/mmax2.py#L225-L227 |
49,460 | arne-cl/discoursegraphs | src/discoursegraphs/readwrite/mmax2.py | MMAXDocumentGraph.add_token_layer | def add_token_layer(self, words_file, connected):
"""
parses a _words.xml file, adds every token to the document graph
and adds an edge from the MMAX root node to it.
Parameters
----------
connected : bool
Make the graph connected, i.e. add an edge from root ... | python | def add_token_layer(self, words_file, connected):
"""
parses a _words.xml file, adds every token to the document graph
and adds an edge from the MMAX root node to it.
Parameters
----------
connected : bool
Make the graph connected, i.e. add an edge from root ... | [
"def",
"add_token_layer",
"(",
"self",
",",
"words_file",
",",
"connected",
")",
":",
"for",
"word",
"in",
"etree",
".",
"parse",
"(",
"words_file",
")",
".",
"iterfind",
"(",
"'//word'",
")",
":",
"token_node_id",
"=",
"word",
".",
"attrib",
"[",
"'id'"... | parses a _words.xml file, adds every token to the document graph
and adds an edge from the MMAX root node to it.
Parameters
----------
connected : bool
Make the graph connected, i.e. add an edge from root to each
token. | [
"parses",
"a",
"_words",
".",
"xml",
"file",
"adds",
"every",
"token",
"to",
"the",
"document",
"graph",
"and",
"adds",
"an",
"edge",
"from",
"the",
"MMAX",
"root",
"node",
"to",
"it",
"."
] | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/mmax2.py#L247-L268 |
49,461 | arne-cl/discoursegraphs | src/discoursegraphs/readwrite/mmax2.py | MMAXDocumentGraph.add_annotation_layer | def add_annotation_layer(self, annotation_file, layer_name):
"""
adds all markables from the given annotation layer to the discourse
graph.
"""
assert os.path.isfile(annotation_file), \
"Annotation file doesn't exist: {}".format(annotation_file)
tree = etree.p... | python | def add_annotation_layer(self, annotation_file, layer_name):
"""
adds all markables from the given annotation layer to the discourse
graph.
"""
assert os.path.isfile(annotation_file), \
"Annotation file doesn't exist: {}".format(annotation_file)
tree = etree.p... | [
"def",
"add_annotation_layer",
"(",
"self",
",",
"annotation_file",
",",
"layer_name",
")",
":",
"assert",
"os",
".",
"path",
".",
"isfile",
"(",
"annotation_file",
")",
",",
"\"Annotation file doesn't exist: {}\"",
".",
"format",
"(",
"annotation_file",
")",
"tre... | adds all markables from the given annotation layer to the discourse
graph. | [
"adds",
"all",
"markables",
"from",
"the",
"given",
"annotation",
"layer",
"to",
"the",
"discourse",
"graph",
"."
] | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/mmax2.py#L270-L338 |
49,462 | arne-cl/discoursegraphs | src/discoursegraphs/readwrite/rst/dis/common.py | get_edu_text | def get_edu_text(text_subtree):
"""return the text of the given EDU subtree, with '_!'-delimiters removed."""
assert text_subtree.label() == 'text', "text_subtree: {}".format(text_subtree)
edu_str = u' '.join(word for word in text_subtree.leaves())
return re.sub('_!(.*?)_!', '\g<1>', edu_str) | python | def get_edu_text(text_subtree):
"""return the text of the given EDU subtree, with '_!'-delimiters removed."""
assert text_subtree.label() == 'text', "text_subtree: {}".format(text_subtree)
edu_str = u' '.join(word for word in text_subtree.leaves())
return re.sub('_!(.*?)_!', '\g<1>', edu_str) | [
"def",
"get_edu_text",
"(",
"text_subtree",
")",
":",
"assert",
"text_subtree",
".",
"label",
"(",
")",
"==",
"'text'",
",",
"\"text_subtree: {}\"",
".",
"format",
"(",
"text_subtree",
")",
"edu_str",
"=",
"u' '",
".",
"join",
"(",
"word",
"for",
"word",
"... | return the text of the given EDU subtree, with '_!'-delimiters removed. | [
"return",
"the",
"text",
"of",
"the",
"given",
"EDU",
"subtree",
"with",
"_!",
"-",
"delimiters",
"removed",
"."
] | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/rst/dis/common.py#L65-L69 |
49,463 | arne-cl/discoursegraphs | src/discoursegraphs/readwrite/rst/dis/common.py | get_node_id | def get_node_id(nuc_or_sat, namespace=None):
"""return the node ID of the given nucleus or satellite"""
node_type = get_node_type(nuc_or_sat)
if node_type == 'leaf':
leaf_id = nuc_or_sat[0].leaves()[0]
if namespace is not None:
return '{0}:{1}'.format(namespace, leaf_id)
... | python | def get_node_id(nuc_or_sat, namespace=None):
"""return the node ID of the given nucleus or satellite"""
node_type = get_node_type(nuc_or_sat)
if node_type == 'leaf':
leaf_id = nuc_or_sat[0].leaves()[0]
if namespace is not None:
return '{0}:{1}'.format(namespace, leaf_id)
... | [
"def",
"get_node_id",
"(",
"nuc_or_sat",
",",
"namespace",
"=",
"None",
")",
":",
"node_type",
"=",
"get_node_type",
"(",
"nuc_or_sat",
")",
"if",
"node_type",
"==",
"'leaf'",
":",
"leaf_id",
"=",
"nuc_or_sat",
"[",
"0",
"]",
".",
"leaves",
"(",
")",
"["... | return the node ID of the given nucleus or satellite | [
"return",
"the",
"node",
"ID",
"of",
"the",
"given",
"nucleus",
"or",
"satellite"
] | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/rst/dis/common.py#L100-L116 |
49,464 | jrderuiter/pybiomart | src/pybiomart/mart.py | Mart.datasets | def datasets(self):
"""List of datasets in this mart."""
if self._datasets is None:
self._datasets = self._fetch_datasets()
return self._datasets | python | def datasets(self):
"""List of datasets in this mart."""
if self._datasets is None:
self._datasets = self._fetch_datasets()
return self._datasets | [
"def",
"datasets",
"(",
"self",
")",
":",
"if",
"self",
".",
"_datasets",
"is",
"None",
":",
"self",
".",
"_datasets",
"=",
"self",
".",
"_fetch_datasets",
"(",
")",
"return",
"self",
".",
"_datasets"
] | List of datasets in this mart. | [
"List",
"of",
"datasets",
"in",
"this",
"mart",
"."
] | 7802d45fe88549ab0512d6f37f815fc43b172b39 | https://github.com/jrderuiter/pybiomart/blob/7802d45fe88549ab0512d6f37f815fc43b172b39/src/pybiomart/mart.py#L84-L88 |
49,465 | jrderuiter/pybiomart | src/pybiomart/mart.py | Mart.list_datasets | def list_datasets(self):
"""Lists available datasets in a readable DataFrame format.
Returns:
pd.DataFrame: Frame listing available datasets.
"""
def _row_gen(attributes):
for attr in attributes.values():
yield (attr.name, attr.display_name)
... | python | def list_datasets(self):
"""Lists available datasets in a readable DataFrame format.
Returns:
pd.DataFrame: Frame listing available datasets.
"""
def _row_gen(attributes):
for attr in attributes.values():
yield (attr.name, attr.display_name)
... | [
"def",
"list_datasets",
"(",
"self",
")",
":",
"def",
"_row_gen",
"(",
"attributes",
")",
":",
"for",
"attr",
"in",
"attributes",
".",
"values",
"(",
")",
":",
"yield",
"(",
"attr",
".",
"name",
",",
"attr",
".",
"display_name",
")",
"return",
"pd",
... | Lists available datasets in a readable DataFrame format.
Returns:
pd.DataFrame: Frame listing available datasets. | [
"Lists",
"available",
"datasets",
"in",
"a",
"readable",
"DataFrame",
"format",
"."
] | 7802d45fe88549ab0512d6f37f815fc43b172b39 | https://github.com/jrderuiter/pybiomart/blob/7802d45fe88549ab0512d6f37f815fc43b172b39/src/pybiomart/mart.py#L90-L102 |
49,466 | arne-cl/discoursegraphs | src/discoursegraphs/readwrite/rst/rs3/common.py | extract_relationtypes | def extract_relationtypes(rs3_xml_tree):
"""
extracts the allowed RST relation names and relation types from
an RS3 XML file.
Parameters
----------
rs3_xml_tree : lxml.etree._ElementTree
lxml ElementTree representation of an RS3 XML file
Returns
-------
relations : dict of ... | python | def extract_relationtypes(rs3_xml_tree):
"""
extracts the allowed RST relation names and relation types from
an RS3 XML file.
Parameters
----------
rs3_xml_tree : lxml.etree._ElementTree
lxml ElementTree representation of an RS3 XML file
Returns
-------
relations : dict of ... | [
"def",
"extract_relationtypes",
"(",
"rs3_xml_tree",
")",
":",
"return",
"{",
"rel",
".",
"attrib",
"[",
"'name'",
"]",
":",
"rel",
".",
"attrib",
"[",
"'type'",
"]",
"for",
"rel",
"in",
"rs3_xml_tree",
".",
"iter",
"(",
"'rel'",
")",
"if",
"'type'",
"... | extracts the allowed RST relation names and relation types from
an RS3 XML file.
Parameters
----------
rs3_xml_tree : lxml.etree._ElementTree
lxml ElementTree representation of an RS3 XML file
Returns
-------
relations : dict of (str, str)
Returns a dictionary with RST rela... | [
"extracts",
"the",
"allowed",
"RST",
"relation",
"names",
"and",
"relation",
"types",
"from",
"an",
"RS3",
"XML",
"file",
"."
] | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/rst/rs3/common.py#L14-L33 |
49,467 | arne-cl/discoursegraphs | src/discoursegraphs/readwrite/salt/edges.py | get_node_id | def get_node_id(edge, node_type):
"""
returns the source or target node id of an edge, depending on the
node_type given.
"""
assert node_type in ('source', 'target')
_, node_id_str = edge.attrib[node_type].split('.') # e.g. //@nodes.251
return int(node_id_str) | python | def get_node_id(edge, node_type):
"""
returns the source or target node id of an edge, depending on the
node_type given.
"""
assert node_type in ('source', 'target')
_, node_id_str = edge.attrib[node_type].split('.') # e.g. //@nodes.251
return int(node_id_str) | [
"def",
"get_node_id",
"(",
"edge",
",",
"node_type",
")",
":",
"assert",
"node_type",
"in",
"(",
"'source'",
",",
"'target'",
")",
"_",
",",
"node_id_str",
"=",
"edge",
".",
"attrib",
"[",
"node_type",
"]",
".",
"split",
"(",
"'.'",
")",
"# e.g. //@nodes... | returns the source or target node id of an edge, depending on the
node_type given. | [
"returns",
"the",
"source",
"or",
"target",
"node",
"id",
"of",
"an",
"edge",
"depending",
"on",
"the",
"node_type",
"given",
"."
] | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/salt/edges.py#L196-L203 |
49,468 | arne-cl/discoursegraphs | src/discoursegraphs/readwrite/conll.py | traverse_dependencies_up | def traverse_dependencies_up(docgraph, node_id, node_attr=None):
"""
starting from the given node, traverse ingoing edges up to the root element
of the sentence. return the given node attribute from all the nodes visited
along the way.
"""
# there's only one, but we're in a multidigraph
sour... | python | def traverse_dependencies_up(docgraph, node_id, node_attr=None):
"""
starting from the given node, traverse ingoing edges up to the root element
of the sentence. return the given node attribute from all the nodes visited
along the way.
"""
# there's only one, but we're in a multidigraph
sour... | [
"def",
"traverse_dependencies_up",
"(",
"docgraph",
",",
"node_id",
",",
"node_attr",
"=",
"None",
")",
":",
"# there's only one, but we're in a multidigraph",
"source",
",",
"target",
"=",
"docgraph",
".",
"in_edges",
"(",
"node_id",
")",
"[",
"0",
"]",
"traverse... | starting from the given node, traverse ingoing edges up to the root element
of the sentence. return the given node attribute from all the nodes visited
along the way. | [
"starting",
"from",
"the",
"given",
"node",
"traverse",
"ingoing",
"edges",
"up",
"to",
"the",
"root",
"element",
"of",
"the",
"sentence",
".",
"return",
"the",
"given",
"node",
"attribute",
"from",
"all",
"the",
"nodes",
"visited",
"along",
"the",
"way",
... | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/conll.py#L480-L497 |
49,469 | arne-cl/discoursegraphs | src/discoursegraphs/readwrite/conll.py | ConllDocumentGraph.__add_dependency | def __add_dependency(self, word_instance, sent_id):
"""
adds an ingoing dependency relation from the projected head of a token
to the token itself.
"""
# 'head_attr': (projected) head
head = word_instance.__getattribute__(self.head_attr)
deprel = word_instance.__g... | python | def __add_dependency(self, word_instance, sent_id):
"""
adds an ingoing dependency relation from the projected head of a token
to the token itself.
"""
# 'head_attr': (projected) head
head = word_instance.__getattribute__(self.head_attr)
deprel = word_instance.__g... | [
"def",
"__add_dependency",
"(",
"self",
",",
"word_instance",
",",
"sent_id",
")",
":",
"# 'head_attr': (projected) head",
"head",
"=",
"word_instance",
".",
"__getattribute__",
"(",
"self",
".",
"head_attr",
")",
"deprel",
"=",
"word_instance",
".",
"__getattribute... | adds an ingoing dependency relation from the projected head of a token
to the token itself. | [
"adds",
"an",
"ingoing",
"dependency",
"relation",
"from",
"the",
"projected",
"head",
"of",
"a",
"token",
"to",
"the",
"token",
"itself",
"."
] | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/conll.py#L256-L282 |
49,470 | arne-cl/discoursegraphs | src/discoursegraphs/readwrite/conll.py | Conll2009File.__build_markable_token_mapper | def __build_markable_token_mapper(self, coreference_layer=None,
markable_layer=None):
"""
Creates mappings from tokens to the markable spans they belong to
and the coreference chains these markables are part of.
Returns
-------
tok2m... | python | def __build_markable_token_mapper(self, coreference_layer=None,
markable_layer=None):
"""
Creates mappings from tokens to the markable spans they belong to
and the coreference chains these markables are part of.
Returns
-------
tok2m... | [
"def",
"__build_markable_token_mapper",
"(",
"self",
",",
"coreference_layer",
"=",
"None",
",",
"markable_layer",
"=",
"None",
")",
":",
"tok2markables",
"=",
"defaultdict",
"(",
"set",
")",
"markable2toks",
"=",
"defaultdict",
"(",
"list",
")",
"markable2chains"... | Creates mappings from tokens to the markable spans they belong to
and the coreference chains these markables are part of.
Returns
-------
tok2markables : dict (str -> set of str)
Maps from a token (node ID) to all the markables (node IDs)
it is part of.
m... | [
"Creates",
"mappings",
"from",
"tokens",
"to",
"the",
"markable",
"spans",
"they",
"belong",
"to",
"and",
"the",
"coreference",
"chains",
"these",
"markables",
"are",
"part",
"of",
"."
] | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/conll.py#L358-L403 |
49,471 | arne-cl/discoursegraphs | src/discoursegraphs/readwrite/conll.py | Conll2009File.__gen_coref_str | def __gen_coref_str(self, token_id, markable_id, target_id):
"""
generates the string that represents the markables and coreference
chains that a token is part of.
Parameters
----------
token_id : str
the node ID of the token
markable_id : str
... | python | def __gen_coref_str(self, token_id, markable_id, target_id):
"""
generates the string that represents the markables and coreference
chains that a token is part of.
Parameters
----------
token_id : str
the node ID of the token
markable_id : str
... | [
"def",
"__gen_coref_str",
"(",
"self",
",",
"token_id",
",",
"markable_id",
",",
"target_id",
")",
":",
"span",
"=",
"self",
".",
"markable2toks",
"[",
"markable_id",
"]",
"coref_str",
"=",
"str",
"(",
"target_id",
")",
"if",
"span",
".",
"index",
"(",
"... | generates the string that represents the markables and coreference
chains that a token is part of.
Parameters
----------
token_id : str
the node ID of the token
markable_id : str
the node ID of the markable span
target_id : int
the ID ... | [
"generates",
"the",
"string",
"that",
"represents",
"the",
"markables",
"and",
"coreference",
"chains",
"that",
"a",
"token",
"is",
"part",
"of",
"."
] | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/conll.py#L438-L467 |
49,472 | arne-cl/discoursegraphs | src/discoursegraphs/readwrite/salt/nodes.py | extract_sentences | def extract_sentences(nodes, token_node_indices):
"""
given a list of ``SaltNode``\s, returns a list of lists, where each list
contains the indices of the nodes belonging to that sentence.
"""
sents = []
tokens = []
for i, node in enumerate(nodes):
if i in token_node_indices:
... | python | def extract_sentences(nodes, token_node_indices):
"""
given a list of ``SaltNode``\s, returns a list of lists, where each list
contains the indices of the nodes belonging to that sentence.
"""
sents = []
tokens = []
for i, node in enumerate(nodes):
if i in token_node_indices:
... | [
"def",
"extract_sentences",
"(",
"nodes",
",",
"token_node_indices",
")",
":",
"sents",
"=",
"[",
"]",
"tokens",
"=",
"[",
"]",
"for",
"i",
",",
"node",
"in",
"enumerate",
"(",
"nodes",
")",
":",
"if",
"i",
"in",
"token_node_indices",
":",
"if",
"node"... | given a list of ``SaltNode``\s, returns a list of lists, where each list
contains the indices of the nodes belonging to that sentence. | [
"given",
"a",
"list",
"of",
"SaltNode",
"\\",
"s",
"returns",
"a",
"list",
"of",
"lists",
"where",
"each",
"list",
"contains",
"the",
"indices",
"of",
"the",
"nodes",
"belonging",
"to",
"that",
"sentence",
"."
] | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/salt/nodes.py#L187-L202 |
49,473 | arne-cl/discoursegraphs | src/discoursegraphs/readwrite/gexf.py | write_gexf | def write_gexf(docgraph, output_file):
"""
takes a document graph, converts it into GEXF format and writes it to
a file.
"""
dg_copy = deepcopy(docgraph)
remove_root_metadata(dg_copy)
layerset2str(dg_copy)
attriblist2str(dg_copy)
nx_write_gexf(dg_copy, output_file) | python | def write_gexf(docgraph, output_file):
"""
takes a document graph, converts it into GEXF format and writes it to
a file.
"""
dg_copy = deepcopy(docgraph)
remove_root_metadata(dg_copy)
layerset2str(dg_copy)
attriblist2str(dg_copy)
nx_write_gexf(dg_copy, output_file) | [
"def",
"write_gexf",
"(",
"docgraph",
",",
"output_file",
")",
":",
"dg_copy",
"=",
"deepcopy",
"(",
"docgraph",
")",
"remove_root_metadata",
"(",
"dg_copy",
")",
"layerset2str",
"(",
"dg_copy",
")",
"attriblist2str",
"(",
"dg_copy",
")",
"nx_write_gexf",
"(",
... | takes a document graph, converts it into GEXF format and writes it to
a file. | [
"takes",
"a",
"document",
"graph",
"converts",
"it",
"into",
"GEXF",
"format",
"and",
"writes",
"it",
"to",
"a",
"file",
"."
] | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/gexf.py#L16-L25 |
49,474 | arne-cl/discoursegraphs | src/discoursegraphs/readwrite/tree.py | get_child_nodes | def get_child_nodes(docgraph, parent_node_id, data=False):
"""Yield all nodes that the given node dominates or spans."""
return select_neighbors_by_edge_attribute(
docgraph=docgraph,
source=parent_node_id,
attribute='edge_type',
value=[EdgeTypes.dominance_relation],
data=... | python | def get_child_nodes(docgraph, parent_node_id, data=False):
"""Yield all nodes that the given node dominates or spans."""
return select_neighbors_by_edge_attribute(
docgraph=docgraph,
source=parent_node_id,
attribute='edge_type',
value=[EdgeTypes.dominance_relation],
data=... | [
"def",
"get_child_nodes",
"(",
"docgraph",
",",
"parent_node_id",
",",
"data",
"=",
"False",
")",
":",
"return",
"select_neighbors_by_edge_attribute",
"(",
"docgraph",
"=",
"docgraph",
",",
"source",
"=",
"parent_node_id",
",",
"attribute",
"=",
"'edge_type'",
","... | Yield all nodes that the given node dominates or spans. | [
"Yield",
"all",
"nodes",
"that",
"the",
"given",
"node",
"dominates",
"or",
"spans",
"."
] | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/tree.py#L102-L109 |
49,475 | arne-cl/discoursegraphs | src/discoursegraphs/readwrite/tree.py | get_parents | def get_parents(docgraph, child_node, strict=True):
"""Return a list of parent nodes that dominate this child.
In a 'syntax tree' a node never has more than one parent node
dominating it. To enforce this, set strict=True.
Parameters
----------
docgraph : DiscourseDocumentGraph
a docume... | python | def get_parents(docgraph, child_node, strict=True):
"""Return a list of parent nodes that dominate this child.
In a 'syntax tree' a node never has more than one parent node
dominating it. To enforce this, set strict=True.
Parameters
----------
docgraph : DiscourseDocumentGraph
a docume... | [
"def",
"get_parents",
"(",
"docgraph",
",",
"child_node",
",",
"strict",
"=",
"True",
")",
":",
"parents",
"=",
"[",
"]",
"for",
"src",
",",
"_",
",",
"edge_attrs",
"in",
"docgraph",
".",
"in_edges",
"(",
"child_node",
",",
"data",
"=",
"True",
")",
... | Return a list of parent nodes that dominate this child.
In a 'syntax tree' a node never has more than one parent node
dominating it. To enforce this, set strict=True.
Parameters
----------
docgraph : DiscourseDocumentGraph
a document graph
strict : bool
If True, raise a ValueEr... | [
"Return",
"a",
"list",
"of",
"parent",
"nodes",
"that",
"dominate",
"this",
"child",
"."
] | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/tree.py#L112-L139 |
49,476 | arne-cl/discoursegraphs | src/discoursegraphs/readwrite/tree.py | sorted_bfs_edges | def sorted_bfs_edges(G, source=None):
"""Produce edges in a breadth-first-search starting at source.
Neighbors appear in the order a linguist would expect in a syntax tree.
The result will only contain edges that express a dominance or spanning
relation, i.e. edges expressing pointing or precedence rel... | python | def sorted_bfs_edges(G, source=None):
"""Produce edges in a breadth-first-search starting at source.
Neighbors appear in the order a linguist would expect in a syntax tree.
The result will only contain edges that express a dominance or spanning
relation, i.e. edges expressing pointing or precedence rel... | [
"def",
"sorted_bfs_edges",
"(",
"G",
",",
"source",
"=",
"None",
")",
":",
"if",
"source",
"is",
"None",
":",
"source",
"=",
"G",
".",
"root",
"xpos",
"=",
"horizontal_positions",
"(",
"G",
",",
"source",
")",
"visited",
"=",
"set",
"(",
"[",
"source... | Produce edges in a breadth-first-search starting at source.
Neighbors appear in the order a linguist would expect in a syntax tree.
The result will only contain edges that express a dominance or spanning
relation, i.e. edges expressing pointing or precedence relations will
be ignored.
Parameters
... | [
"Produce",
"edges",
"in",
"a",
"breadth",
"-",
"first",
"-",
"search",
"starting",
"at",
"source",
"."
] | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/tree.py#L163-L203 |
49,477 | arne-cl/discoursegraphs | src/discoursegraphs/readwrite/tree.py | sorted_bfs_successors | def sorted_bfs_successors(G, source=None):
"""Return dictionary of successors in breadth-first-search from source.
Parameters
----------
G : DiscourseDocumentGraph graph
source : node
Specify starting node for breadth-first search and return edges in
the component reachable from sour... | python | def sorted_bfs_successors(G, source=None):
"""Return dictionary of successors in breadth-first-search from source.
Parameters
----------
G : DiscourseDocumentGraph graph
source : node
Specify starting node for breadth-first search and return edges in
the component reachable from sour... | [
"def",
"sorted_bfs_successors",
"(",
"G",
",",
"source",
"=",
"None",
")",
":",
"if",
"source",
"is",
"None",
":",
"source",
"=",
"G",
".",
"root",
"successors",
"=",
"defaultdict",
"(",
"list",
")",
"for",
"src",
",",
"target",
"in",
"sorted_bfs_edges",... | Return dictionary of successors in breadth-first-search from source.
Parameters
----------
G : DiscourseDocumentGraph graph
source : node
Specify starting node for breadth-first search and return edges in
the component reachable from source.
Returns
-------
successors: dict
... | [
"Return",
"dictionary",
"of",
"successors",
"in",
"breadth",
"-",
"first",
"-",
"search",
"from",
"source",
"."
] | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/tree.py#L206-L228 |
49,478 | arne-cl/discoursegraphs | src/discoursegraphs/readwrite/tree.py | node2bracket | def node2bracket(docgraph, node_id, child_str=''):
"""convert a docgraph node into a PTB-style string."""
node_attrs = docgraph.node[node_id]
if istoken(docgraph, node_id):
pos_str = node_attrs.get(docgraph.ns+':pos', '')
token_str = node_attrs[docgraph.ns+':token']
return u"({pos}{s... | python | def node2bracket(docgraph, node_id, child_str=''):
"""convert a docgraph node into a PTB-style string."""
node_attrs = docgraph.node[node_id]
if istoken(docgraph, node_id):
pos_str = node_attrs.get(docgraph.ns+':pos', '')
token_str = node_attrs[docgraph.ns+':token']
return u"({pos}{s... | [
"def",
"node2bracket",
"(",
"docgraph",
",",
"node_id",
",",
"child_str",
"=",
"''",
")",
":",
"node_attrs",
"=",
"docgraph",
".",
"node",
"[",
"node_id",
"]",
"if",
"istoken",
"(",
"docgraph",
",",
"node_id",
")",
":",
"pos_str",
"=",
"node_attrs",
".",... | convert a docgraph node into a PTB-style string. | [
"convert",
"a",
"docgraph",
"node",
"into",
"a",
"PTB",
"-",
"style",
"string",
"."
] | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/tree.py#L231-L245 |
49,479 | arne-cl/discoursegraphs | src/discoursegraphs/readwrite/tree.py | tree2bracket | def tree2bracket(docgraph, root=None, successors=None):
"""convert a docgraph into a PTB-style string.
If root (a node ID) is given, only convert the subgraph that this
node domintes/spans into a PTB-style string.
"""
if root is None:
root = docgraph.root
if successors is None:
... | python | def tree2bracket(docgraph, root=None, successors=None):
"""convert a docgraph into a PTB-style string.
If root (a node ID) is given, only convert the subgraph that this
node domintes/spans into a PTB-style string.
"""
if root is None:
root = docgraph.root
if successors is None:
... | [
"def",
"tree2bracket",
"(",
"docgraph",
",",
"root",
"=",
"None",
",",
"successors",
"=",
"None",
")",
":",
"if",
"root",
"is",
"None",
":",
"root",
"=",
"docgraph",
".",
"root",
"if",
"successors",
"is",
"None",
":",
"successors",
"=",
"sorted_bfs_succe... | convert a docgraph into a PTB-style string.
If root (a node ID) is given, only convert the subgraph that this
node domintes/spans into a PTB-style string. | [
"convert",
"a",
"docgraph",
"into",
"a",
"PTB",
"-",
"style",
"string",
"."
] | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/tree.py#L248-L263 |
49,480 | arne-cl/discoursegraphs | src/discoursegraphs/readwrite/tree.py | word_wrap_tree | def word_wrap_tree(parented_tree, width=0):
"""line-wrap an NLTK ParentedTree for pretty-printing"""
if width != 0:
for i, leaf_text in enumerate(parented_tree.leaves()):
dedented_text = textwrap.dedent(leaf_text).strip()
parented_tree[parented_tree.leaf_treeposition(i)] = textwr... | python | def word_wrap_tree(parented_tree, width=0):
"""line-wrap an NLTK ParentedTree for pretty-printing"""
if width != 0:
for i, leaf_text in enumerate(parented_tree.leaves()):
dedented_text = textwrap.dedent(leaf_text).strip()
parented_tree[parented_tree.leaf_treeposition(i)] = textwr... | [
"def",
"word_wrap_tree",
"(",
"parented_tree",
",",
"width",
"=",
"0",
")",
":",
"if",
"width",
"!=",
"0",
":",
"for",
"i",
",",
"leaf_text",
"in",
"enumerate",
"(",
"parented_tree",
".",
"leaves",
"(",
")",
")",
":",
"dedented_text",
"=",
"textwrap",
... | line-wrap an NLTK ParentedTree for pretty-printing | [
"line",
"-",
"wrap",
"an",
"NLTK",
"ParentedTree",
"for",
"pretty",
"-",
"printing"
] | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/tree.py#L271-L277 |
49,481 | arne-cl/discoursegraphs | src/discoursegraphs/readwrite/tree.py | DGParentedTree.get_position | def get_position(self, rst_tree, node_id=None):
"""Get the linear position of an element of this DGParentedTree in an RSTTree.
If ``node_id`` is given, this will return the position of the subtree
with that node ID. Otherwise, the position of the root of this
DGParentedTree in the given... | python | def get_position(self, rst_tree, node_id=None):
"""Get the linear position of an element of this DGParentedTree in an RSTTree.
If ``node_id`` is given, this will return the position of the subtree
with that node ID. Otherwise, the position of the root of this
DGParentedTree in the given... | [
"def",
"get_position",
"(",
"self",
",",
"rst_tree",
",",
"node_id",
"=",
"None",
")",
":",
"if",
"node_id",
"is",
"None",
":",
"node_id",
"=",
"self",
".",
"root_id",
"if",
"node_id",
"in",
"rst_tree",
".",
"edu_set",
":",
"return",
"rst_tree",
".",
"... | Get the linear position of an element of this DGParentedTree in an RSTTree.
If ``node_id`` is given, this will return the position of the subtree
with that node ID. Otherwise, the position of the root of this
DGParentedTree in the given RSTTree is returned. | [
"Get",
"the",
"linear",
"position",
"of",
"an",
"element",
"of",
"this",
"DGParentedTree",
"in",
"an",
"RSTTree",
"."
] | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/tree.py#L26-L40 |
49,482 | jrderuiter/pybiomart | src/pybiomart/base.py | ServerBase.get | def get(self, **params):
"""Performs get request to the biomart service.
Args:
**params (dict of str: any): Arbitrary keyword arguments, which
are added as parameters to the get request to biomart.
Returns:
requests.models.Response: Response from biomart... | python | def get(self, **params):
"""Performs get request to the biomart service.
Args:
**params (dict of str: any): Arbitrary keyword arguments, which
are added as parameters to the get request to biomart.
Returns:
requests.models.Response: Response from biomart... | [
"def",
"get",
"(",
"self",
",",
"*",
"*",
"params",
")",
":",
"if",
"self",
".",
"_use_cache",
":",
"r",
"=",
"requests",
".",
"get",
"(",
"self",
".",
"url",
",",
"params",
"=",
"params",
")",
"else",
":",
"with",
"requests_cache",
".",
"disabled"... | Performs get request to the biomart service.
Args:
**params (dict of str: any): Arbitrary keyword arguments, which
are added as parameters to the get request to biomart.
Returns:
requests.models.Response: Response from biomart for the request. | [
"Performs",
"get",
"request",
"to",
"the",
"biomart",
"service",
"."
] | 7802d45fe88549ab0512d6f37f815fc43b172b39 | https://github.com/jrderuiter/pybiomart/blob/7802d45fe88549ab0512d6f37f815fc43b172b39/src/pybiomart/base.py#L95-L112 |
49,483 | arne-cl/discoursegraphs | src/discoursegraphs/readwrite/ptb.py | PTBDocumentGraph.fromstring | def fromstring(cls, ptb_string, namespace='ptb', precedence=False,
ignore_traces=True):
"""create a PTBDocumentGraph from a string containing PTB parses."""
temp = tempfile.NamedTemporaryFile(delete=False)
temp.write(ptb_string)
temp.close()
ptb_docgraph = cls(p... | python | def fromstring(cls, ptb_string, namespace='ptb', precedence=False,
ignore_traces=True):
"""create a PTBDocumentGraph from a string containing PTB parses."""
temp = tempfile.NamedTemporaryFile(delete=False)
temp.write(ptb_string)
temp.close()
ptb_docgraph = cls(p... | [
"def",
"fromstring",
"(",
"cls",
",",
"ptb_string",
",",
"namespace",
"=",
"'ptb'",
",",
"precedence",
"=",
"False",
",",
"ignore_traces",
"=",
"True",
")",
":",
"temp",
"=",
"tempfile",
".",
"NamedTemporaryFile",
"(",
"delete",
"=",
"False",
")",
"temp",
... | create a PTBDocumentGraph from a string containing PTB parses. | [
"create",
"a",
"PTBDocumentGraph",
"from",
"a",
"string",
"containing",
"PTB",
"parses",
"."
] | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/ptb.py#L101-L110 |
49,484 | arne-cl/discoursegraphs | src/discoursegraphs/readwrite/ptb.py | PTBDocumentGraph._add_sentence | def _add_sentence(self, sentence, ignore_traces=True):
"""
add a sentence from the input document to the document graph.
Parameters
----------
sentence : nltk.tree.Tree
a sentence represented by a Tree instance
"""
self.sentences.append(self._node_id)... | python | def _add_sentence(self, sentence, ignore_traces=True):
"""
add a sentence from the input document to the document graph.
Parameters
----------
sentence : nltk.tree.Tree
a sentence represented by a Tree instance
"""
self.sentences.append(self._node_id)... | [
"def",
"_add_sentence",
"(",
"self",
",",
"sentence",
",",
"ignore_traces",
"=",
"True",
")",
":",
"self",
".",
"sentences",
".",
"append",
"(",
"self",
".",
"_node_id",
")",
"# add edge from document root to sentence root",
"self",
".",
"add_edge",
"(",
"self",... | add a sentence from the input document to the document graph.
Parameters
----------
sentence : nltk.tree.Tree
a sentence represented by a Tree instance | [
"add",
"a",
"sentence",
"from",
"the",
"input",
"document",
"to",
"the",
"document",
"graph",
"."
] | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/ptb.py#L112-L125 |
49,485 | arne-cl/discoursegraphs | src/discoursegraphs/readwrite/ptb.py | PTBDocumentGraph._parse_sentencetree | def _parse_sentencetree(self, tree, parent_node_id=None, ignore_traces=True):
"""parse a sentence Tree into this document graph"""
def get_nodelabel(node):
if isinstance(node, nltk.tree.Tree):
return node.label()
elif isinstance(node, unicode):
ret... | python | def _parse_sentencetree(self, tree, parent_node_id=None, ignore_traces=True):
"""parse a sentence Tree into this document graph"""
def get_nodelabel(node):
if isinstance(node, nltk.tree.Tree):
return node.label()
elif isinstance(node, unicode):
ret... | [
"def",
"_parse_sentencetree",
"(",
"self",
",",
"tree",
",",
"parent_node_id",
"=",
"None",
",",
"ignore_traces",
"=",
"True",
")",
":",
"def",
"get_nodelabel",
"(",
"node",
")",
":",
"if",
"isinstance",
"(",
"node",
",",
"nltk",
".",
"tree",
".",
"Tree"... | parse a sentence Tree into this document graph | [
"parse",
"a",
"sentence",
"Tree",
"into",
"this",
"document",
"graph"
] | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/ptb.py#L127-L175 |
49,486 | arne-cl/discoursegraphs | src/discoursegraphs/readwrite/salt/saltxmi.py | create_class_instance | def create_class_instance(element, element_id, doc_id):
"""
given an Salt XML element, returns a corresponding `SaltElement` class
instance, i.e. a SaltXML `SToken` node will be converted into a
`TokenNode`.
Parameters
----------
element : lxml.etree._Element
an `etree._Element` is ... | python | def create_class_instance(element, element_id, doc_id):
"""
given an Salt XML element, returns a corresponding `SaltElement` class
instance, i.e. a SaltXML `SToken` node will be converted into a
`TokenNode`.
Parameters
----------
element : lxml.etree._Element
an `etree._Element` is ... | [
"def",
"create_class_instance",
"(",
"element",
",",
"element_id",
",",
"doc_id",
")",
":",
"xsi_type",
"=",
"get_xsi_type",
"(",
"element",
")",
"element_class",
"=",
"XSI_TYPE_CLASSES",
"[",
"xsi_type",
"]",
"return",
"element_class",
".",
"from_etree",
"(",
"... | given an Salt XML element, returns a corresponding `SaltElement` class
instance, i.e. a SaltXML `SToken` node will be converted into a
`TokenNode`.
Parameters
----------
element : lxml.etree._Element
an `etree._Element` is the XML representation of a Salt element,
e.g. a single 'nod... | [
"given",
"an",
"Salt",
"XML",
"element",
"returns",
"a",
"corresponding",
"SaltElement",
"class",
"instance",
"i",
".",
"e",
".",
"a",
"SaltXML",
"SToken",
"node",
"will",
"be",
"converted",
"into",
"a",
"TokenNode",
"."
] | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/salt/saltxmi.py#L343-L367 |
49,487 | arne-cl/discoursegraphs | src/discoursegraphs/readwrite/salt/saltxmi.py | abslistdir | def abslistdir(directory):
"""
returns a list of absolute filepaths for all files found in the given
directory.
"""
abs_dir = os.path.abspath(directory)
filenames = os.listdir(abs_dir)
return [os.path.join(abs_dir, filename) for filename in filenames] | python | def abslistdir(directory):
"""
returns a list of absolute filepaths for all files found in the given
directory.
"""
abs_dir = os.path.abspath(directory)
filenames = os.listdir(abs_dir)
return [os.path.join(abs_dir, filename) for filename in filenames] | [
"def",
"abslistdir",
"(",
"directory",
")",
":",
"abs_dir",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"directory",
")",
"filenames",
"=",
"os",
".",
"listdir",
"(",
"abs_dir",
")",
"return",
"[",
"os",
".",
"path",
".",
"join",
"(",
"abs_dir",
","... | returns a list of absolute filepaths for all files found in the given
directory. | [
"returns",
"a",
"list",
"of",
"absolute",
"filepaths",
"for",
"all",
"files",
"found",
"in",
"the",
"given",
"directory",
"."
] | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/salt/saltxmi.py#L410-L417 |
49,488 | arne-cl/discoursegraphs | src/discoursegraphs/readwrite/salt/saltxmi.py | SaltDocument._extract_elements | def _extract_elements(self, tree, element_type):
"""
extracts all element of type `element_type from the `_ElementTree`
representation of a SaltXML document and adds them to the corresponding
`SaltDocument` attributes, i.e. `self.nodes`, `self.edges` and
`self.layers`.
P... | python | def _extract_elements(self, tree, element_type):
"""
extracts all element of type `element_type from the `_ElementTree`
representation of a SaltXML document and adds them to the corresponding
`SaltDocument` attributes, i.e. `self.nodes`, `self.edges` and
`self.layers`.
P... | [
"def",
"_extract_elements",
"(",
"self",
",",
"tree",
",",
"element_type",
")",
":",
"# creates a new attribute, e.g. 'self.nodes' and assigns it an",
"# empty list",
"setattr",
"(",
"self",
",",
"element_type",
",",
"[",
"]",
")",
"etree_elements",
"=",
"get_elements",... | extracts all element of type `element_type from the `_ElementTree`
representation of a SaltXML document and adds them to the corresponding
`SaltDocument` attributes, i.e. `self.nodes`, `self.edges` and
`self.layers`.
Parameters
----------
tree : lxml.etree._ElementTree
... | [
"extracts",
"all",
"element",
"of",
"type",
"element_type",
"from",
"the",
"_ElementTree",
"representation",
"of",
"a",
"SaltXML",
"document",
"and",
"adds",
"them",
"to",
"the",
"corresponding",
"SaltDocument",
"attributes",
"i",
".",
"e",
".",
"self",
".",
"... | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/salt/saltxmi.py#L141-L164 |
49,489 | arne-cl/discoursegraphs | src/discoursegraphs/readwrite/salt/saltxmi.py | LinguisticDocument.print_sentence | def print_sentence(self, sent_index):
"""
returns the string representation of a sentence.
:param sent_index: the index of a sentence (from ``self.sentences``)
:type sent_index: int
:return: the sentence string
:rtype: str
"""
tokens = [self.print_token(t... | python | def print_sentence(self, sent_index):
"""
returns the string representation of a sentence.
:param sent_index: the index of a sentence (from ``self.sentences``)
:type sent_index: int
:return: the sentence string
:rtype: str
"""
tokens = [self.print_token(t... | [
"def",
"print_sentence",
"(",
"self",
",",
"sent_index",
")",
":",
"tokens",
"=",
"[",
"self",
".",
"print_token",
"(",
"tok_idx",
")",
"for",
"tok_idx",
"in",
"self",
".",
"sentences",
"[",
"sent_index",
"]",
"]",
"return",
"' '",
".",
"join",
"(",
"t... | returns the string representation of a sentence.
:param sent_index: the index of a sentence (from ``self.sentences``)
:type sent_index: int
:return: the sentence string
:rtype: str | [
"returns",
"the",
"string",
"representation",
"of",
"a",
"sentence",
"."
] | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/salt/saltxmi.py#L251-L262 |
49,490 | arne-cl/discoursegraphs | src/discoursegraphs/readwrite/salt/saltxmi.py | LinguisticDocument.print_token | def print_token(self, token_node_index):
"""returns the string representation of a token."""
err_msg = "The given node is not a token node."
assert isinstance(self.nodes[token_node_index], TokenNode), err_msg
onset = self.nodes[token_node_index].onset
offset = self.nodes[token_no... | python | def print_token(self, token_node_index):
"""returns the string representation of a token."""
err_msg = "The given node is not a token node."
assert isinstance(self.nodes[token_node_index], TokenNode), err_msg
onset = self.nodes[token_node_index].onset
offset = self.nodes[token_no... | [
"def",
"print_token",
"(",
"self",
",",
"token_node_index",
")",
":",
"err_msg",
"=",
"\"The given node is not a token node.\"",
"assert",
"isinstance",
"(",
"self",
".",
"nodes",
"[",
"token_node_index",
"]",
",",
"TokenNode",
")",
",",
"err_msg",
"onset",
"=",
... | returns the string representation of a token. | [
"returns",
"the",
"string",
"representation",
"of",
"a",
"token",
"."
] | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/salt/saltxmi.py#L264-L270 |
49,491 | kata198/python-nonblock | nonblock/common.py | detect_stream_mode | def detect_stream_mode(stream):
'''
detect_stream_mode - Detect the mode on a given stream
@param stream <object> - A stream object
If "mode" is present, that will be used.
@return <type> - "Bytes" type or "str" type
'''
# If "Mode" is present, pull from that
i... | python | def detect_stream_mode(stream):
'''
detect_stream_mode - Detect the mode on a given stream
@param stream <object> - A stream object
If "mode" is present, that will be used.
@return <type> - "Bytes" type or "str" type
'''
# If "Mode" is present, pull from that
i... | [
"def",
"detect_stream_mode",
"(",
"stream",
")",
":",
"# If \"Mode\" is present, pull from that",
"if",
"hasattr",
"(",
"stream",
",",
"'mode'",
")",
":",
"if",
"'b'",
"in",
"stream",
".",
"mode",
":",
"return",
"bytes",
"elif",
"'t'",
"in",
"stream",
".",
"... | detect_stream_mode - Detect the mode on a given stream
@param stream <object> - A stream object
If "mode" is present, that will be used.
@return <type> - "Bytes" type or "str" type | [
"detect_stream_mode",
"-",
"Detect",
"the",
"mode",
"on",
"a",
"given",
"stream"
] | 3f011b3b3b494ccb44d48179e94167fb7382e4a4 | https://github.com/kata198/python-nonblock/blob/3f011b3b3b494ccb44d48179e94167fb7382e4a4/nonblock/common.py#L4-L34 |
49,492 | arne-cl/discoursegraphs | src/discoursegraphs/readwrite/freqt.py | node2freqt | def node2freqt(docgraph, node_id, child_str='', include_pos=False,
escape_func=FREQT_ESCAPE_FUNC):
"""convert a docgraph node into a FREQT string."""
node_attrs = docgraph.node[node_id]
if istoken(docgraph, node_id):
token_str = escape_func(node_attrs[docgraph.ns+':token'])
if... | python | def node2freqt(docgraph, node_id, child_str='', include_pos=False,
escape_func=FREQT_ESCAPE_FUNC):
"""convert a docgraph node into a FREQT string."""
node_attrs = docgraph.node[node_id]
if istoken(docgraph, node_id):
token_str = escape_func(node_attrs[docgraph.ns+':token'])
if... | [
"def",
"node2freqt",
"(",
"docgraph",
",",
"node_id",
",",
"child_str",
"=",
"''",
",",
"include_pos",
"=",
"False",
",",
"escape_func",
"=",
"FREQT_ESCAPE_FUNC",
")",
":",
"node_attrs",
"=",
"docgraph",
".",
"node",
"[",
"node_id",
"]",
"if",
"istoken",
"... | convert a docgraph node into a FREQT string. | [
"convert",
"a",
"docgraph",
"node",
"into",
"a",
"FREQT",
"string",
"."
] | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/freqt.py#L21-L36 |
49,493 | arne-cl/discoursegraphs | src/discoursegraphs/readwrite/freqt.py | sentence2freqt | def sentence2freqt(docgraph, root, successors=None, include_pos=False,
escape_func=FREQT_ESCAPE_FUNC):
"""convert a sentence subgraph into a FREQT string."""
if successors is None:
successors = sorted_bfs_successors(docgraph, root)
if root in successors: # root node has children... | python | def sentence2freqt(docgraph, root, successors=None, include_pos=False,
escape_func=FREQT_ESCAPE_FUNC):
"""convert a sentence subgraph into a FREQT string."""
if successors is None:
successors = sorted_bfs_successors(docgraph, root)
if root in successors: # root node has children... | [
"def",
"sentence2freqt",
"(",
"docgraph",
",",
"root",
",",
"successors",
"=",
"None",
",",
"include_pos",
"=",
"False",
",",
"escape_func",
"=",
"FREQT_ESCAPE_FUNC",
")",
":",
"if",
"successors",
"is",
"None",
":",
"successors",
"=",
"sorted_bfs_successors",
... | convert a sentence subgraph into a FREQT string. | [
"convert",
"a",
"sentence",
"subgraph",
"into",
"a",
"FREQT",
"string",
"."
] | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/freqt.py#L39-L55 |
49,494 | arne-cl/discoursegraphs | src/discoursegraphs/readwrite/freqt.py | docgraph2freqt | def docgraph2freqt(docgraph, root=None, include_pos=False,
escape_func=FREQT_ESCAPE_FUNC):
"""convert a docgraph into a FREQT string."""
if root is None:
return u"\n".join(
sentence2freqt(docgraph, sentence, include_pos=include_pos,
escape_func=e... | python | def docgraph2freqt(docgraph, root=None, include_pos=False,
escape_func=FREQT_ESCAPE_FUNC):
"""convert a docgraph into a FREQT string."""
if root is None:
return u"\n".join(
sentence2freqt(docgraph, sentence, include_pos=include_pos,
escape_func=e... | [
"def",
"docgraph2freqt",
"(",
"docgraph",
",",
"root",
"=",
"None",
",",
"include_pos",
"=",
"False",
",",
"escape_func",
"=",
"FREQT_ESCAPE_FUNC",
")",
":",
"if",
"root",
"is",
"None",
":",
"return",
"u\"\\n\"",
".",
"join",
"(",
"sentence2freqt",
"(",
"d... | convert a docgraph into a FREQT string. | [
"convert",
"a",
"docgraph",
"into",
"a",
"FREQT",
"string",
"."
] | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/freqt.py#L58-L68 |
49,495 | cmheisel/nose-xcover | nosexcover/nosexcover.py | XCoverage.report | def report(self, stream):
"""
Output code coverage report.
"""
if not self.xcoverageToStdout:
# This will create a false stream where output will be ignored
stream = StringIO()
super(XCoverage, self).report(stream)
if not hasattr(self,... | python | def report(self, stream):
"""
Output code coverage report.
"""
if not self.xcoverageToStdout:
# This will create a false stream where output will be ignored
stream = StringIO()
super(XCoverage, self).report(stream)
if not hasattr(self,... | [
"def",
"report",
"(",
"self",
",",
"stream",
")",
":",
"if",
"not",
"self",
".",
"xcoverageToStdout",
":",
"# This will create a false stream where output will be ignored",
"stream",
"=",
"StringIO",
"(",
")",
"super",
"(",
"XCoverage",
",",
"self",
")",
".",
"r... | Output code coverage report. | [
"Output",
"code",
"coverage",
"report",
"."
] | 9f071ed6ea2ca59fe2cae5940f3d4157b4131ff9 | https://github.com/cmheisel/nose-xcover/blob/9f071ed6ea2ca59fe2cae5940f3d4157b4131ff9/nosexcover/nosexcover.py#L61-L80 |
49,496 | arne-cl/discoursegraphs | src/discoursegraphs/readwrite/salt/elements.py | SaltElement.from_etree | def from_etree(cls, etree_element):
"""
creates a `SaltElement` from an `etree._Element` representing
an element in a SaltXMI file.
"""
label_elements = get_subelements(etree_element, 'labels')
labels = [SaltLabel.from_etree(elem) for elem in label_elements]
retur... | python | def from_etree(cls, etree_element):
"""
creates a `SaltElement` from an `etree._Element` representing
an element in a SaltXMI file.
"""
label_elements = get_subelements(etree_element, 'labels')
labels = [SaltLabel.from_etree(elem) for elem in label_elements]
retur... | [
"def",
"from_etree",
"(",
"cls",
",",
"etree_element",
")",
":",
"label_elements",
"=",
"get_subelements",
"(",
"etree_element",
",",
"'labels'",
")",
"labels",
"=",
"[",
"SaltLabel",
".",
"from_etree",
"(",
"elem",
")",
"for",
"elem",
"in",
"label_elements",
... | creates a `SaltElement` from an `etree._Element` representing
an element in a SaltXMI file. | [
"creates",
"a",
"SaltElement",
"from",
"an",
"etree",
".",
"_Element",
"representing",
"an",
"element",
"in",
"a",
"SaltXMI",
"file",
"."
] | 842f0068a3190be2c75905754521b176b25a54fb | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/salt/elements.py#L74-L85 |
49,497 | mattrobenolt/django-sudo | sudo/utils.py | grant_sudo_privileges | def grant_sudo_privileges(request, max_age=COOKIE_AGE):
"""
Assigns a random token to the user's session
that allows them to have elevated permissions
"""
user = getattr(request, 'user', None)
# If there's not a user on the request, just noop
if user is None:
return
if not user... | python | def grant_sudo_privileges(request, max_age=COOKIE_AGE):
"""
Assigns a random token to the user's session
that allows them to have elevated permissions
"""
user = getattr(request, 'user', None)
# If there's not a user on the request, just noop
if user is None:
return
if not user... | [
"def",
"grant_sudo_privileges",
"(",
"request",
",",
"max_age",
"=",
"COOKIE_AGE",
")",
":",
"user",
"=",
"getattr",
"(",
"request",
",",
"'user'",
",",
"None",
")",
"# If there's not a user on the request, just noop",
"if",
"user",
"is",
"None",
":",
"return",
... | Assigns a random token to the user's session
that allows them to have elevated permissions | [
"Assigns",
"a",
"random",
"token",
"to",
"the",
"user",
"s",
"session",
"that",
"allows",
"them",
"to",
"have",
"elevated",
"permissions"
] | 089e21a88bc3ebf9d76ea706f26707d2e4f3f729 | https://github.com/mattrobenolt/django-sudo/blob/089e21a88bc3ebf9d76ea706f26707d2e4f3f729/sudo/utils.py#L19-L40 |
49,498 | mattrobenolt/django-sudo | sudo/utils.py | revoke_sudo_privileges | def revoke_sudo_privileges(request):
"""
Revoke sudo privileges from a request explicitly
"""
request._sudo = False
if COOKIE_NAME in request.session:
del request.session[COOKIE_NAME] | python | def revoke_sudo_privileges(request):
"""
Revoke sudo privileges from a request explicitly
"""
request._sudo = False
if COOKIE_NAME in request.session:
del request.session[COOKIE_NAME] | [
"def",
"revoke_sudo_privileges",
"(",
"request",
")",
":",
"request",
".",
"_sudo",
"=",
"False",
"if",
"COOKIE_NAME",
"in",
"request",
".",
"session",
":",
"del",
"request",
".",
"session",
"[",
"COOKIE_NAME",
"]"
] | Revoke sudo privileges from a request explicitly | [
"Revoke",
"sudo",
"privileges",
"from",
"a",
"request",
"explicitly"
] | 089e21a88bc3ebf9d76ea706f26707d2e4f3f729 | https://github.com/mattrobenolt/django-sudo/blob/089e21a88bc3ebf9d76ea706f26707d2e4f3f729/sudo/utils.py#L43-L49 |
49,499 | mattrobenolt/django-sudo | sudo/utils.py | has_sudo_privileges | def has_sudo_privileges(request):
"""
Check if a request is allowed to perform sudo actions
"""
if getattr(request, '_sudo', None) is None:
try:
request._sudo = (
request.user.is_authenticated() and
constant_time_compare(
request.ge... | python | def has_sudo_privileges(request):
"""
Check if a request is allowed to perform sudo actions
"""
if getattr(request, '_sudo', None) is None:
try:
request._sudo = (
request.user.is_authenticated() and
constant_time_compare(
request.ge... | [
"def",
"has_sudo_privileges",
"(",
"request",
")",
":",
"if",
"getattr",
"(",
"request",
",",
"'_sudo'",
",",
"None",
")",
"is",
"None",
":",
"try",
":",
"request",
".",
"_sudo",
"=",
"(",
"request",
".",
"user",
".",
"is_authenticated",
"(",
")",
"and... | Check if a request is allowed to perform sudo actions | [
"Check",
"if",
"a",
"request",
"is",
"allowed",
"to",
"perform",
"sudo",
"actions"
] | 089e21a88bc3ebf9d76ea706f26707d2e4f3f729 | https://github.com/mattrobenolt/django-sudo/blob/089e21a88bc3ebf9d76ea706f26707d2e4f3f729/sudo/utils.py#L52-L67 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.