repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
Aluriak/tergraw | tergraw/view.py | build | def build(matrix):
"""Yield lines generated from given matrix"""
max_x = max(matrix, key=lambda t: t[0])[0]
min_x = min(matrix, key=lambda t: t[0])[0]
max_y = max(matrix, key=lambda t: t[1])[1]
min_y = min(matrix, key=lambda t: t[1])[1]
yield from (
# '{}:'.format(j).ljust(4) + ''.join(m... | python | def build(matrix):
"""Yield lines generated from given matrix"""
max_x = max(matrix, key=lambda t: t[0])[0]
min_x = min(matrix, key=lambda t: t[0])[0]
max_y = max(matrix, key=lambda t: t[1])[1]
min_y = min(matrix, key=lambda t: t[1])[1]
yield from (
# '{}:'.format(j).ljust(4) + ''.join(m... | [
"def",
"build",
"(",
"matrix",
")",
":",
"max_x",
"=",
"max",
"(",
"matrix",
",",
"key",
"=",
"lambda",
"t",
":",
"t",
"[",
"0",
"]",
")",
"[",
"0",
"]",
"min_x",
"=",
"min",
"(",
"matrix",
",",
"key",
"=",
"lambda",
"t",
":",
"t",
"[",
"0"... | Yield lines generated from given matrix | [
"Yield",
"lines",
"generated",
"from",
"given",
"matrix"
] | train | https://github.com/Aluriak/tergraw/blob/7f73cd286a77611e9c73f50b1e43be4f6643ac9f/tergraw/view.py#L19-L29 |
Aluriak/tergraw | tergraw/view.py | next_unwrittable_on_row | def next_unwrittable_on_row(view, coords):
"""Return position of the next (in row) letter that is unwrittable"""
x, y = coords
maxx = max(view.keys(), key=itemgetter(0))[0]
for offset in range(x + 1, maxx):
letter = view[offset, y]
if letter not in REWRITABLE_LETTERS:
return ... | python | def next_unwrittable_on_row(view, coords):
"""Return position of the next (in row) letter that is unwrittable"""
x, y = coords
maxx = max(view.keys(), key=itemgetter(0))[0]
for offset in range(x + 1, maxx):
letter = view[offset, y]
if letter not in REWRITABLE_LETTERS:
return ... | [
"def",
"next_unwrittable_on_row",
"(",
"view",
",",
"coords",
")",
":",
"x",
",",
"y",
"=",
"coords",
"maxx",
"=",
"max",
"(",
"view",
".",
"keys",
"(",
")",
",",
"key",
"=",
"itemgetter",
"(",
"0",
")",
")",
"[",
"0",
"]",
"for",
"offset",
"in",... | Return position of the next (in row) letter that is unwrittable | [
"Return",
"position",
"of",
"the",
"next",
"(",
"in",
"row",
")",
"letter",
"that",
"is",
"unwrittable"
] | train | https://github.com/Aluriak/tergraw/blob/7f73cd286a77611e9c73f50b1e43be4f6643ac9f/tergraw/view.py#L32-L40 |
Aluriak/tergraw | tergraw/view.py | next_unwrittable_on_col | def next_unwrittable_on_col(view, coords):
"""Return position of the next letter (in column) that is unwrittable"""
x, y = coords
maxy = max(view.keys(), key=itemgetter(1))[1]
for offset in range(y + 1, maxy):
letter = view[x, offset]
if letter not in REWRITABLE_LETTERS:
retu... | python | def next_unwrittable_on_col(view, coords):
"""Return position of the next letter (in column) that is unwrittable"""
x, y = coords
maxy = max(view.keys(), key=itemgetter(1))[1]
for offset in range(y + 1, maxy):
letter = view[x, offset]
if letter not in REWRITABLE_LETTERS:
retu... | [
"def",
"next_unwrittable_on_col",
"(",
"view",
",",
"coords",
")",
":",
"x",
",",
"y",
"=",
"coords",
"maxy",
"=",
"max",
"(",
"view",
".",
"keys",
"(",
")",
",",
"key",
"=",
"itemgetter",
"(",
"1",
")",
")",
"[",
"1",
"]",
"for",
"offset",
"in",... | Return position of the next letter (in column) that is unwrittable | [
"Return",
"position",
"of",
"the",
"next",
"letter",
"(",
"in",
"column",
")",
"that",
"is",
"unwrittable"
] | train | https://github.com/Aluriak/tergraw/blob/7f73cd286a77611e9c73f50b1e43be4f6643ac9f/tergraw/view.py#L43-L51 |
Aluriak/tergraw | tergraw/view.py | previous_unwrittable_on_row | def previous_unwrittable_on_row(view, coords):
"""Return position of the previous (in row) letter that is unwrittable"""
x, y = coords
minx = -1
for offset in range(x - 1, minx, -1):
letter = view[offset, y]
if letter not in REWRITABLE_LETTERS:
return offset
return None | python | def previous_unwrittable_on_row(view, coords):
"""Return position of the previous (in row) letter that is unwrittable"""
x, y = coords
minx = -1
for offset in range(x - 1, minx, -1):
letter = view[offset, y]
if letter not in REWRITABLE_LETTERS:
return offset
return None | [
"def",
"previous_unwrittable_on_row",
"(",
"view",
",",
"coords",
")",
":",
"x",
",",
"y",
"=",
"coords",
"minx",
"=",
"-",
"1",
"for",
"offset",
"in",
"range",
"(",
"x",
"-",
"1",
",",
"minx",
",",
"-",
"1",
")",
":",
"letter",
"=",
"view",
"[",... | Return position of the previous (in row) letter that is unwrittable | [
"Return",
"position",
"of",
"the",
"previous",
"(",
"in",
"row",
")",
"letter",
"that",
"is",
"unwrittable"
] | train | https://github.com/Aluriak/tergraw/blob/7f73cd286a77611e9c73f50b1e43be4f6643ac9f/tergraw/view.py#L54-L62 |
Aluriak/tergraw | tergraw/view.py | previous_unwrittable_on_col | def previous_unwrittable_on_col(view, coords):
"""Return position of the previous (in column) letter that is unwrittable"""
x, y = coords
miny = -1
for offset in range(y - 1, miny, -1):
letter = view[x, offset]
if letter not in REWRITABLE_LETTERS:
return offset
return Non... | python | def previous_unwrittable_on_col(view, coords):
"""Return position of the previous (in column) letter that is unwrittable"""
x, y = coords
miny = -1
for offset in range(y - 1, miny, -1):
letter = view[x, offset]
if letter not in REWRITABLE_LETTERS:
return offset
return Non... | [
"def",
"previous_unwrittable_on_col",
"(",
"view",
",",
"coords",
")",
":",
"x",
",",
"y",
"=",
"coords",
"miny",
"=",
"-",
"1",
"for",
"offset",
"in",
"range",
"(",
"y",
"-",
"1",
",",
"miny",
",",
"-",
"1",
")",
":",
"letter",
"=",
"view",
"[",... | Return position of the previous (in column) letter that is unwrittable | [
"Return",
"position",
"of",
"the",
"previous",
"(",
"in",
"column",
")",
"letter",
"that",
"is",
"unwrittable"
] | train | https://github.com/Aluriak/tergraw/blob/7f73cd286a77611e9c73f50b1e43be4f6643ac9f/tergraw/view.py#L65-L73 |
artefactual-labs/agentarchives | agentarchives/archivesspace/client.py | ArchivesSpaceClient._build_base_url | def _build_base_url(self, host, port):
"""Return the API base URL string based on ``host`` and ``port``.
It returns a valid URL when ``host`` isn't. The endling slash is always
removed so it always need to be added by the consumer.
"""
parsed = urlparse(host)
if not pars... | python | def _build_base_url(self, host, port):
"""Return the API base URL string based on ``host`` and ``port``.
It returns a valid URL when ``host`` isn't. The endling slash is always
removed so it always need to be added by the consumer.
"""
parsed = urlparse(host)
if not pars... | [
"def",
"_build_base_url",
"(",
"self",
",",
"host",
",",
"port",
")",
":",
"parsed",
"=",
"urlparse",
"(",
"host",
")",
"if",
"not",
"parsed",
".",
"scheme",
":",
"parsed",
"=",
"parsed",
".",
"_replace",
"(",
"scheme",
"=",
"\"http\"",
")",
"parsed",
... | Return the API base URL string based on ``host`` and ``port``.
It returns a valid URL when ``host`` isn't. The endling slash is always
removed so it always need to be added by the consumer. | [
"Return",
"the",
"API",
"base",
"URL",
"string",
"based",
"on",
"host",
"and",
"port",
"."
] | train | https://github.com/artefactual-labs/agentarchives/blob/af19ade56a90c64069cf46b50972fe72b6f10a45/agentarchives/archivesspace/client.py#L86-L101 |
artefactual-labs/agentarchives | agentarchives/archivesspace/client.py | ArchivesSpaceClient._format_notes | def _format_notes(self, record):
"""
Extracts notes from a record and reformats them in a simplified format.
"""
notes = []
for note in record["notes"]:
if note.get("type"):
n = {}
n["type"] = note["type"]
try:
... | python | def _format_notes(self, record):
"""
Extracts notes from a record and reformats them in a simplified format.
"""
notes = []
for note in record["notes"]:
if note.get("type"):
n = {}
n["type"] = note["type"]
try:
... | [
"def",
"_format_notes",
"(",
"self",
",",
"record",
")",
":",
"notes",
"=",
"[",
"]",
"for",
"note",
"in",
"record",
"[",
"\"notes\"",
"]",
":",
"if",
"note",
".",
"get",
"(",
"\"type\"",
")",
":",
"n",
"=",
"{",
"}",
"n",
"[",
"\"type\"",
"]",
... | Extracts notes from a record and reformats them in a simplified format. | [
"Extracts",
"notes",
"from",
"a",
"record",
"and",
"reformats",
"them",
"in",
"a",
"simplified",
"format",
"."
] | train | https://github.com/artefactual-labs/agentarchives/blob/af19ade56a90c64069cf46b50972fe72b6f10a45/agentarchives/archivesspace/client.py#L188-L207 |
artefactual-labs/agentarchives | agentarchives/archivesspace/client.py | ArchivesSpaceClient._process_notes | def _process_notes(record, new_record):
"""
Populate the notes property using the provided new_record.
If the new_record field was populated, assume that we want to replace
the notes. If there are valid changes to be made, they will be added to
the new_notes list. An empty list ... | python | def _process_notes(record, new_record):
"""
Populate the notes property using the provided new_record.
If the new_record field was populated, assume that we want to replace
the notes. If there are valid changes to be made, they will be added to
the new_notes list. An empty list ... | [
"def",
"_process_notes",
"(",
"record",
",",
"new_record",
")",
":",
"if",
"\"notes\"",
"not",
"in",
"new_record",
"or",
"not",
"new_record",
"[",
"\"notes\"",
"]",
":",
"return",
"False",
"# This assumes any notes passed into the edit record are intended to",
"# replac... | Populate the notes property using the provided new_record.
If the new_record field was populated, assume that we want to replace
the notes. If there are valid changes to be made, they will be added to
the new_notes list. An empty list is counted as a request to delete all
notes.
... | [
"Populate",
"the",
"notes",
"property",
"using",
"the",
"provided",
"new_record",
"."
] | train | https://github.com/artefactual-labs/agentarchives/blob/af19ade56a90c64069cf46b50972fe72b6f10a45/agentarchives/archivesspace/client.py#L210-L249 |
artefactual-labs/agentarchives | agentarchives/archivesspace/client.py | ArchivesSpaceClient._escape_solr_query | def _escape_solr_query(query, field="title"):
"""
Escapes special characters in Solr queries.
Note that this omits * - this is intentionally permitted in user queries.
The list of special characters is located at http://lucene.apache.org/core/4_0_0/queryparser/org/apache/lucene/querypars... | python | def _escape_solr_query(query, field="title"):
"""
Escapes special characters in Solr queries.
Note that this omits * - this is intentionally permitted in user queries.
The list of special characters is located at http://lucene.apache.org/core/4_0_0/queryparser/org/apache/lucene/querypars... | [
"def",
"_escape_solr_query",
"(",
"query",
",",
"field",
"=",
"\"title\"",
")",
":",
"# Different rules for \"title\" and \"identifier\" fields :/",
"if",
"field",
"==",
"\"title\"",
":",
"replacement",
"=",
"r\"\\\\\\\\\\1\"",
"else",
":",
"replacement",
"=",
"r\"\\\\\... | Escapes special characters in Solr queries.
Note that this omits * - this is intentionally permitted in user queries.
The list of special characters is located at http://lucene.apache.org/core/4_0_0/queryparser/org/apache/lucene/queryparser/classic/package-summary.html#Escaping_Special_Characters | [
"Escapes",
"special",
"characters",
"in",
"Solr",
"queries",
".",
"Note",
"that",
"this",
"omits",
"*",
"-",
"this",
"is",
"intentionally",
"permitted",
"in",
"user",
"queries",
".",
"The",
"list",
"of",
"special",
"characters",
"is",
"located",
"at",
"http"... | train | https://github.com/artefactual-labs/agentarchives/blob/af19ade56a90c64069cf46b50972fe72b6f10a45/agentarchives/archivesspace/client.py#L252-L264 |
artefactual-labs/agentarchives | agentarchives/archivesspace/client.py | ArchivesSpaceClient.resource_type | def resource_type(self, resource_id):
"""
Given an ID, determines whether a given resource is a resource or a resource_component.
:param resource_id string: The URI of the resource whose type to determine.
:raises ArchivesSpaceError: if the resource_id does not appear to be either type.... | python | def resource_type(self, resource_id):
"""
Given an ID, determines whether a given resource is a resource or a resource_component.
:param resource_id string: The URI of the resource whose type to determine.
:raises ArchivesSpaceError: if the resource_id does not appear to be either type.... | [
"def",
"resource_type",
"(",
"self",
",",
"resource_id",
")",
":",
"match",
"=",
"re",
".",
"search",
"(",
"r\"repositories/\\d+/(resources|archival_objects)/\\d+\"",
",",
"resource_id",
")",
"if",
"match",
"and",
"match",
".",
"groups",
"(",
")",
":",
"type_",
... | Given an ID, determines whether a given resource is a resource or a resource_component.
:param resource_id string: The URI of the resource whose type to determine.
:raises ArchivesSpaceError: if the resource_id does not appear to be either type. | [
"Given",
"an",
"ID",
"determines",
"whether",
"a",
"given",
"resource",
"is",
"a",
"resource",
"or",
"a",
"resource_component",
"."
] | train | https://github.com/artefactual-labs/agentarchives/blob/af19ade56a90c64069cf46b50972fe72b6f10a45/agentarchives/archivesspace/client.py#L266-L282 |
artefactual-labs/agentarchives | agentarchives/archivesspace/client.py | ArchivesSpaceClient.edit_record | def edit_record(self, new_record):
"""
Update a record in ArchivesSpace using the provided new_record.
The format of new_record is identical to the format returned by get_resource_component_and_children and related methods; consult the documentation for that method in ArchivistsToolkitClient to... | python | def edit_record(self, new_record):
"""
Update a record in ArchivesSpace using the provided new_record.
The format of new_record is identical to the format returned by get_resource_component_and_children and related methods; consult the documentation for that method in ArchivistsToolkitClient to... | [
"def",
"edit_record",
"(",
"self",
",",
"new_record",
")",
":",
"try",
":",
"record_id",
"=",
"new_record",
"[",
"\"id\"",
"]",
"except",
"KeyError",
":",
"raise",
"ValueError",
"(",
"\"No record ID provided!\"",
")",
"record",
"=",
"self",
".",
"get_record",
... | Update a record in ArchivesSpace using the provided new_record.
The format of new_record is identical to the format returned by get_resource_component_and_children and related methods; consult the documentation for that method in ArchivistsToolkitClient to see the format.
This means it's possible, for ... | [
"Update",
"a",
"record",
"in",
"ArchivesSpace",
"using",
"the",
"provided",
"new_record",
"."
] | train | https://github.com/artefactual-labs/agentarchives/blob/af19ade56a90c64069cf46b50972fe72b6f10a45/agentarchives/archivesspace/client.py#L287-L352 |
artefactual-labs/agentarchives | agentarchives/archivesspace/client.py | ArchivesSpaceClient.get_levels_of_description | def get_levels_of_description(self):
"""Returns an array of all levels of description defined in this
ArchivesSpace instance."""
if not hasattr(self, "levels_of_description"):
# TODO: * fetch human-formatted strings
# * is hardcoding this ID okay?
self.l... | python | def get_levels_of_description(self):
"""Returns an array of all levels of description defined in this
ArchivesSpace instance."""
if not hasattr(self, "levels_of_description"):
# TODO: * fetch human-formatted strings
# * is hardcoding this ID okay?
self.l... | [
"def",
"get_levels_of_description",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"\"levels_of_description\"",
")",
":",
"# TODO: * fetch human-formatted strings",
"# * is hardcoding this ID okay?",
"self",
".",
"levels_of_description",
"=",
"self",... | Returns an array of all levels of description defined in this
ArchivesSpace instance. | [
"Returns",
"an",
"array",
"of",
"all",
"levels",
"of",
"description",
"defined",
"in",
"this",
"ArchivesSpace",
"instance",
"."
] | train | https://github.com/artefactual-labs/agentarchives/blob/af19ade56a90c64069cf46b50972fe72b6f10a45/agentarchives/archivesspace/client.py#L354-L364 |
artefactual-labs/agentarchives | agentarchives/archivesspace/client.py | ArchivesSpaceClient.get_resource_component_children | def get_resource_component_children(self, resource_component_id):
"""
Given a resource component, fetches detailed metadata for it and all of its children.
This is implemented using ArchivesSpaceClient.get_resource_component_children and uses its default options when fetching children.
... | python | def get_resource_component_children(self, resource_component_id):
"""
Given a resource component, fetches detailed metadata for it and all of its children.
This is implemented using ArchivesSpaceClient.get_resource_component_children and uses its default options when fetching children.
... | [
"def",
"get_resource_component_children",
"(",
"self",
",",
"resource_component_id",
")",
":",
"resource_type",
"=",
"self",
".",
"resource_type",
"(",
"resource_component_id",
")",
"return",
"self",
".",
"get_resource_component_and_children",
"(",
"resource_component_id",
... | Given a resource component, fetches detailed metadata for it and all of its children.
This is implemented using ArchivesSpaceClient.get_resource_component_children and uses its default options when fetching children.
:param string resource_component_id: The URL of the resource component from which to ... | [
"Given",
"a",
"resource",
"component",
"fetches",
"detailed",
"metadata",
"for",
"it",
"and",
"all",
"of",
"its",
"children",
"."
] | train | https://github.com/artefactual-labs/agentarchives/blob/af19ade56a90c64069cf46b50972fe72b6f10a45/agentarchives/archivesspace/client.py#L392-L403 |
artefactual-labs/agentarchives | agentarchives/archivesspace/client.py | ArchivesSpaceClient.get_resource_component_and_children | def get_resource_component_and_children(
self,
resource_id,
resource_type="collection",
level=1,
sort_data={},
recurse_max_level=False,
sort_by=None,
**kwargs
):
"""
Fetch detailed metadata for the specified resource_id and all of its c... | python | def get_resource_component_and_children(
self,
resource_id,
resource_type="collection",
level=1,
sort_data={},
recurse_max_level=False,
sort_by=None,
**kwargs
):
"""
Fetch detailed metadata for the specified resource_id and all of its c... | [
"def",
"get_resource_component_and_children",
"(",
"self",
",",
"resource_id",
",",
"resource_type",
"=",
"\"collection\"",
",",
"level",
"=",
"1",
",",
"sort_data",
"=",
"{",
"}",
",",
"recurse_max_level",
"=",
"False",
",",
"sort_by",
"=",
"None",
",",
"*",
... | Fetch detailed metadata for the specified resource_id and all of its children.
:param long resource_id: The resource for which to fetch metadata.
:param str resource_type: no-op; not required or used in this implementation.
:param int recurse_max_level: The maximum depth level to fetch when fet... | [
"Fetch",
"detailed",
"metadata",
"for",
"the",
"specified",
"resource_id",
"and",
"all",
"of",
"its",
"children",
"."
] | train | https://github.com/artefactual-labs/agentarchives/blob/af19ade56a90c64069cf46b50972fe72b6f10a45/agentarchives/archivesspace/client.py#L529-L562 |
artefactual-labs/agentarchives | agentarchives/archivesspace/client.py | ArchivesSpaceClient.find_parent_id_for_component | def find_parent_id_for_component(self, component_id):
"""
Given the URL to a component, returns the parent component's URL.
:param string component_id: The URL of the component.
:return: A tuple containing:
* The type of the parent record; valid values are ArchivesSpaceClien... | python | def find_parent_id_for_component(self, component_id):
"""
Given the URL to a component, returns the parent component's URL.
:param string component_id: The URL of the component.
:return: A tuple containing:
* The type of the parent record; valid values are ArchivesSpaceClien... | [
"def",
"find_parent_id_for_component",
"(",
"self",
",",
"component_id",
")",
":",
"response",
"=",
"self",
".",
"get_record",
"(",
"component_id",
")",
"if",
"\"parent\"",
"in",
"response",
":",
"return",
"(",
"ArchivesSpaceClient",
".",
"RESOURCE_COMPONENT",
","... | Given the URL to a component, returns the parent component's URL.
:param string component_id: The URL of the component.
:return: A tuple containing:
* The type of the parent record; valid values are ArchivesSpaceClient.RESOURCE and ArchivesSpaceClient.RESOURCE_COMPONENT.
* The U... | [
"Given",
"the",
"URL",
"to",
"a",
"component",
"returns",
"the",
"parent",
"component",
"s",
"URL",
"."
] | train | https://github.com/artefactual-labs/agentarchives/blob/af19ade56a90c64069cf46b50972fe72b6f10a45/agentarchives/archivesspace/client.py#L575-L595 |
artefactual-labs/agentarchives | agentarchives/archivesspace/client.py | ArchivesSpaceClient.find_collection_ids | def find_collection_ids(self, search_pattern="", identifier="", fetched=0, page=1):
"""
Fetches a list of resource URLs for every resource in the database.
:param string search_pattern: A search pattern to use in looking up resources by title or resourceid.
The search will match any... | python | def find_collection_ids(self, search_pattern="", identifier="", fetched=0, page=1):
"""
Fetches a list of resource URLs for every resource in the database.
:param string search_pattern: A search pattern to use in looking up resources by title or resourceid.
The search will match any... | [
"def",
"find_collection_ids",
"(",
"self",
",",
"search_pattern",
"=",
"\"\"",
",",
"identifier",
"=",
"\"\"",
",",
"fetched",
"=",
"0",
",",
"page",
"=",
"1",
")",
":",
"params",
"=",
"{",
"\"page\"",
":",
"page",
",",
"\"q\"",
":",
"\"primary_type:reso... | Fetches a list of resource URLs for every resource in the database.
:param string search_pattern: A search pattern to use in looking up resources by title or resourceid.
The search will match any title containing this string;
for example, "text" will match "this title has this text in i... | [
"Fetches",
"a",
"list",
"of",
"resource",
"URLs",
"for",
"every",
"resource",
"in",
"the",
"database",
"."
] | train | https://github.com/artefactual-labs/agentarchives/blob/af19ade56a90c64069cf46b50972fe72b6f10a45/agentarchives/archivesspace/client.py#L597-L632 |
artefactual-labs/agentarchives | agentarchives/archivesspace/client.py | ArchivesSpaceClient.find_collections | def find_collections(
self,
search_pattern="",
identifier="",
fetched=0,
page=1,
page_size=30,
sort_by=None,
):
"""
Fetches a list of all resource IDs for every resource in the database.
:param string search_pattern: A search pattern t... | python | def find_collections(
self,
search_pattern="",
identifier="",
fetched=0,
page=1,
page_size=30,
sort_by=None,
):
"""
Fetches a list of all resource IDs for every resource in the database.
:param string search_pattern: A search pattern t... | [
"def",
"find_collections",
"(",
"self",
",",
"search_pattern",
"=",
"\"\"",
",",
"identifier",
"=",
"\"\"",
",",
"fetched",
"=",
"0",
",",
"page",
"=",
"1",
",",
"page_size",
"=",
"30",
",",
"sort_by",
"=",
"None",
",",
")",
":",
"def",
"format_record"... | Fetches a list of all resource IDs for every resource in the database.
:param string search_pattern: A search pattern to use in looking up resources by title or resourceid.
The search will match any title or resourceid containing this string;
for example, "text" will match "this title h... | [
"Fetches",
"a",
"list",
"of",
"all",
"resource",
"IDs",
"for",
"every",
"resource",
"in",
"the",
"database",
"."
] | train | https://github.com/artefactual-labs/agentarchives/blob/af19ade56a90c64069cf46b50972fe72b6f10a45/agentarchives/archivesspace/client.py#L647-L716 |
artefactual-labs/agentarchives | agentarchives/archivesspace/client.py | ArchivesSpaceClient.find_by_id | def find_by_id(self, object_type, field, value):
"""
Find resource by a specific ID.
Results are a dict in the format:
{
'id': <resource URI fragment>,
'identifier': <resource identifier>,
'title': <title of the resource>,
'levelOfDescript... | python | def find_by_id(self, object_type, field, value):
"""
Find resource by a specific ID.
Results are a dict in the format:
{
'id': <resource URI fragment>,
'identifier': <resource identifier>,
'title': <title of the resource>,
'levelOfDescript... | [
"def",
"find_by_id",
"(",
"self",
",",
"object_type",
",",
"field",
",",
"value",
")",
":",
"def",
"format_record",
"(",
"record",
")",
":",
"resolved",
"=",
"record",
"[",
"\"_resolved\"",
"]",
"identifier",
"=",
"(",
"resolved",
"[",
"\"ref_id\"",
"]",
... | Find resource by a specific ID.
Results are a dict in the format:
{
'id': <resource URI fragment>,
'identifier': <resource identifier>,
'title': <title of the resource>,
'levelOfDescription': <level of description>,
}
:param str object_ty... | [
"Find",
"resource",
"by",
"a",
"specific",
"ID",
"."
] | train | https://github.com/artefactual-labs/agentarchives/blob/af19ade56a90c64069cf46b50972fe72b6f10a45/agentarchives/archivesspace/client.py#L718-L764 |
artefactual-labs/agentarchives | agentarchives/archivesspace/client.py | ArchivesSpaceClient.add_digital_object | def add_digital_object(
self,
parent_archival_object,
identifier,
title=None,
uri=None,
location_of_originals=None,
object_type="text",
xlink_show="embed",
xlink_actuate="onLoad",
restricted=False,
use_statement="",
use_cond... | python | def add_digital_object(
self,
parent_archival_object,
identifier,
title=None,
uri=None,
location_of_originals=None,
object_type="text",
xlink_show="embed",
xlink_actuate="onLoad",
restricted=False,
use_statement="",
use_cond... | [
"def",
"add_digital_object",
"(",
"self",
",",
"parent_archival_object",
",",
"identifier",
",",
"title",
"=",
"None",
",",
"uri",
"=",
"None",
",",
"location_of_originals",
"=",
"None",
",",
"object_type",
"=",
"\"text\"",
",",
"xlink_show",
"=",
"\"embed\"",
... | Creates a new digital object.
:param string parent_archival_object: The archival object to which the newly-created digital object will be parented.
:param string identifier: A unique identifier for the digital object, in any format.
:param string title: The title of the digital object.
... | [
"Creates",
"a",
"new",
"digital",
"object",
"."
] | train | https://github.com/artefactual-labs/agentarchives/blob/af19ade56a90c64069cf46b50972fe72b6f10a45/agentarchives/archivesspace/client.py#L785-L965 |
artefactual-labs/agentarchives | agentarchives/archivesspace/client.py | ArchivesSpaceClient.add_child | def add_child(
self,
parent,
title="",
level="",
start_date="",
end_date="",
date_expression="",
notes=[],
):
"""
Adds a new resource component parented within `parent`.
:param str parent: The ID to a resource or a resource com... | python | def add_child(
self,
parent,
title="",
level="",
start_date="",
end_date="",
date_expression="",
notes=[],
):
"""
Adds a new resource component parented within `parent`.
:param str parent: The ID to a resource or a resource com... | [
"def",
"add_child",
"(",
"self",
",",
"parent",
",",
"title",
"=",
"\"\"",
",",
"level",
"=",
"\"\"",
",",
"start_date",
"=",
"\"\"",
",",
"end_date",
"=",
"\"\"",
",",
"date_expression",
"=",
"\"\"",
",",
"notes",
"=",
"[",
"]",
",",
")",
":",
"pa... | Adds a new resource component parented within `parent`.
:param str parent: The ID to a resource or a resource component.
:param str title: A title for the record.
:param str level: The level of description.
:return: The ID of the newly-created record. | [
"Adds",
"a",
"new",
"resource",
"component",
"parented",
"within",
"parent",
"."
] | train | https://github.com/artefactual-labs/agentarchives/blob/af19ade56a90c64069cf46b50972fe72b6f10a45/agentarchives/archivesspace/client.py#L995-L1071 |
kevinconway/iface | iface/decorators.py | attribute | def attribute(func):
"""Wrap a function as an attribute."""
attr = abc.abstractmethod(func)
attr.__iattribute__ = True
attr = _property(attr)
return attr | python | def attribute(func):
"""Wrap a function as an attribute."""
attr = abc.abstractmethod(func)
attr.__iattribute__ = True
attr = _property(attr)
return attr | [
"def",
"attribute",
"(",
"func",
")",
":",
"attr",
"=",
"abc",
".",
"abstractmethod",
"(",
"func",
")",
"attr",
".",
"__iattribute__",
"=",
"True",
"attr",
"=",
"_property",
"(",
"attr",
")",
"return",
"attr"
] | Wrap a function as an attribute. | [
"Wrap",
"a",
"function",
"as",
"an",
"attribute",
"."
] | train | https://github.com/kevinconway/iface/blob/2687f7965eed155b9594a298ffa260a2f9f821f9/iface/decorators.py#L18-L23 |
kevinconway/iface | iface/decorators.py | property | def property(func):
"""Wrap a function as a property.
This differs from attribute by identifying properties explicitly listed
in the class definition rather than named attributes defined on instances
of a class at init time.
"""
attr = abc.abstractmethod(func)
attr.__iproperty__ = True
... | python | def property(func):
"""Wrap a function as a property.
This differs from attribute by identifying properties explicitly listed
in the class definition rather than named attributes defined on instances
of a class at init time.
"""
attr = abc.abstractmethod(func)
attr.__iproperty__ = True
... | [
"def",
"property",
"(",
"func",
")",
":",
"attr",
"=",
"abc",
".",
"abstractmethod",
"(",
"func",
")",
"attr",
".",
"__iproperty__",
"=",
"True",
"attr",
"=",
"Property",
"(",
"attr",
")",
"return",
"attr"
] | Wrap a function as a property.
This differs from attribute by identifying properties explicitly listed
in the class definition rather than named attributes defined on instances
of a class at init time. | [
"Wrap",
"a",
"function",
"as",
"a",
"property",
"."
] | train | https://github.com/kevinconway/iface/blob/2687f7965eed155b9594a298ffa260a2f9f821f9/iface/decorators.py#L26-L36 |
kevinconway/iface | iface/decorators.py | classattribute | def classattribute(func):
"""Wrap a function as a class attribute.
This differs from attribute by identifying attributes explicitly listed
in a class definition rather than those only defined on instances of
a class.
"""
attr = abc.abstractmethod(func)
attr.__iclassattribute__ = True
at... | python | def classattribute(func):
"""Wrap a function as a class attribute.
This differs from attribute by identifying attributes explicitly listed
in a class definition rather than those only defined on instances of
a class.
"""
attr = abc.abstractmethod(func)
attr.__iclassattribute__ = True
at... | [
"def",
"classattribute",
"(",
"func",
")",
":",
"attr",
"=",
"abc",
".",
"abstractmethod",
"(",
"func",
")",
"attr",
".",
"__iclassattribute__",
"=",
"True",
"attr",
"=",
"_property",
"(",
"attr",
")",
"return",
"attr"
] | Wrap a function as a class attribute.
This differs from attribute by identifying attributes explicitly listed
in a class definition rather than those only defined on instances of
a class. | [
"Wrap",
"a",
"function",
"as",
"a",
"class",
"attribute",
"."
] | train | https://github.com/kevinconway/iface/blob/2687f7965eed155b9594a298ffa260a2f9f821f9/iface/decorators.py#L39-L49 |
kevinconway/iface | iface/decorators.py | method | def method(func):
"""Wrap a function as a method."""
attr = abc.abstractmethod(func)
attr.__imethod__ = True
return attr | python | def method(func):
"""Wrap a function as a method."""
attr = abc.abstractmethod(func)
attr.__imethod__ = True
return attr | [
"def",
"method",
"(",
"func",
")",
":",
"attr",
"=",
"abc",
".",
"abstractmethod",
"(",
"func",
")",
"attr",
".",
"__imethod__",
"=",
"True",
"return",
"attr"
] | Wrap a function as a method. | [
"Wrap",
"a",
"function",
"as",
"a",
"method",
"."
] | train | https://github.com/kevinconway/iface/blob/2687f7965eed155b9594a298ffa260a2f9f821f9/iface/decorators.py#L52-L56 |
kevinconway/iface | iface/decorators.py | classmethod | def classmethod(func):
"""Wrap a function as a classmethod.
This applies the classmethod decorator.
"""
attr = abc.abstractmethod(func)
attr.__iclassmethod__ = True
attr = _classmethod(attr)
return attr | python | def classmethod(func):
"""Wrap a function as a classmethod.
This applies the classmethod decorator.
"""
attr = abc.abstractmethod(func)
attr.__iclassmethod__ = True
attr = _classmethod(attr)
return attr | [
"def",
"classmethod",
"(",
"func",
")",
":",
"attr",
"=",
"abc",
".",
"abstractmethod",
"(",
"func",
")",
"attr",
".",
"__iclassmethod__",
"=",
"True",
"attr",
"=",
"_classmethod",
"(",
"attr",
")",
"return",
"attr"
] | Wrap a function as a classmethod.
This applies the classmethod decorator. | [
"Wrap",
"a",
"function",
"as",
"a",
"classmethod",
"."
] | train | https://github.com/kevinconway/iface/blob/2687f7965eed155b9594a298ffa260a2f9f821f9/iface/decorators.py#L59-L67 |
guillermo-carrasco/bcbio-nextgen-monitor | bcbio_monitor/config/__init__.py | parse_config | def parse_config(config_file):
"""Parse a YAML configuration file"""
try:
with open(config_file, 'r') as f:
return yaml.load(f)
except IOError:
print "Configuration file {} not found or not readable.".format(config_file)
raise | python | def parse_config(config_file):
"""Parse a YAML configuration file"""
try:
with open(config_file, 'r') as f:
return yaml.load(f)
except IOError:
print "Configuration file {} not found or not readable.".format(config_file)
raise | [
"def",
"parse_config",
"(",
"config_file",
")",
":",
"try",
":",
"with",
"open",
"(",
"config_file",
",",
"'r'",
")",
"as",
"f",
":",
"return",
"yaml",
".",
"load",
"(",
"f",
")",
"except",
"IOError",
":",
"print",
"\"Configuration file {} not found or not r... | Parse a YAML configuration file | [
"Parse",
"a",
"YAML",
"configuration",
"file"
] | train | https://github.com/guillermo-carrasco/bcbio-nextgen-monitor/blob/6d059154d774140e1fd03a0e3625f607cef06f5a/bcbio_monitor/config/__init__.py#L4-L11 |
kevinconway/iface | iface/checks.py | _ensure_ifaces_tuple | def _ensure_ifaces_tuple(ifaces):
"""Convert to a tuple of interfaces and raise if not interfaces."""
try:
ifaces = tuple(ifaces)
except TypeError:
ifaces = (ifaces,)
for iface in ifaces:
if not _issubclass(iface, ibc.Iface):
raise TypeError('Can only compare ag... | python | def _ensure_ifaces_tuple(ifaces):
"""Convert to a tuple of interfaces and raise if not interfaces."""
try:
ifaces = tuple(ifaces)
except TypeError:
ifaces = (ifaces,)
for iface in ifaces:
if not _issubclass(iface, ibc.Iface):
raise TypeError('Can only compare ag... | [
"def",
"_ensure_ifaces_tuple",
"(",
"ifaces",
")",
":",
"try",
":",
"ifaces",
"=",
"tuple",
"(",
"ifaces",
")",
"except",
"TypeError",
":",
"ifaces",
"=",
"(",
"ifaces",
",",
")",
"for",
"iface",
"in",
"ifaces",
":",
"if",
"not",
"_issubclass",
"(",
"i... | Convert to a tuple of interfaces and raise if not interfaces. | [
"Convert",
"to",
"a",
"tuple",
"of",
"interfaces",
"and",
"raise",
"if",
"not",
"interfaces",
"."
] | train | https://github.com/kevinconway/iface/blob/2687f7965eed155b9594a298ffa260a2f9f821f9/iface/checks.py#L9-L25 |
kevinconway/iface | iface/checks.py | _check_for_definition | def _check_for_definition(iface, cls, tag, defines):
"""Check for a valid definition of a value.
Args:
iface (Iface): An Iface specification.
cls (type): Some type to check for a definition.
tag (str): The name of the tag attribute used to mark the abstract
methods.
... | python | def _check_for_definition(iface, cls, tag, defines):
"""Check for a valid definition of a value.
Args:
iface (Iface): An Iface specification.
cls (type): Some type to check for a definition.
tag (str): The name of the tag attribute used to mark the abstract
methods.
... | [
"def",
"_check_for_definition",
"(",
"iface",
",",
"cls",
",",
"tag",
",",
"defines",
")",
":",
"attributes",
"=",
"(",
"attr",
"for",
"attr",
"in",
"iface",
".",
"__abstractmethods__",
"if",
"hasattr",
"(",
"getattr",
"(",
"iface",
",",
"attr",
")",
","... | Check for a valid definition of a value.
Args:
iface (Iface): An Iface specification.
cls (type): Some type to check for a definition.
tag (str): The name of the tag attribute used to mark the abstract
methods.
defines (callable): A callable that accepts an attribute and... | [
"Check",
"for",
"a",
"valid",
"definition",
"of",
"a",
"value",
"."
] | train | https://github.com/kevinconway/iface/blob/2687f7965eed155b9594a298ffa260a2f9f821f9/iface/checks.py#L28-L64 |
kevinconway/iface | iface/checks.py | issubclass | def issubclass(cls, ifaces):
"""Check if the given class is an implementation of the given iface."""
ifaces = _ensure_ifaces_tuple(ifaces)
for iface in ifaces:
return all((
_check_for_definition(
iface,
cls,
'__iclassattribute__',
... | python | def issubclass(cls, ifaces):
"""Check if the given class is an implementation of the given iface."""
ifaces = _ensure_ifaces_tuple(ifaces)
for iface in ifaces:
return all((
_check_for_definition(
iface,
cls,
'__iclassattribute__',
... | [
"def",
"issubclass",
"(",
"cls",
",",
"ifaces",
")",
":",
"ifaces",
"=",
"_ensure_ifaces_tuple",
"(",
"ifaces",
")",
"for",
"iface",
"in",
"ifaces",
":",
"return",
"all",
"(",
"(",
"_check_for_definition",
"(",
"iface",
",",
"cls",
",",
"'__iclassattribute__... | Check if the given class is an implementation of the given iface. | [
"Check",
"if",
"the",
"given",
"class",
"is",
"an",
"implementation",
"of",
"the",
"given",
"iface",
"."
] | train | https://github.com/kevinconway/iface/blob/2687f7965eed155b9594a298ffa260a2f9f821f9/iface/checks.py#L91-L121 |
kevinconway/iface | iface/checks.py | isinstance | def isinstance(instance, ifaces):
"""Check if a given instance is an implementation of the interface."""
ifaces = _ensure_ifaces_tuple(ifaces)
for iface in ifaces:
attributes = (
attr
for attr in iface.__abstractmethods__
if hasattr(getattr(iface, attr), '__iattr... | python | def isinstance(instance, ifaces):
"""Check if a given instance is an implementation of the interface."""
ifaces = _ensure_ifaces_tuple(ifaces)
for iface in ifaces:
attributes = (
attr
for attr in iface.__abstractmethods__
if hasattr(getattr(iface, attr), '__iattr... | [
"def",
"isinstance",
"(",
"instance",
",",
"ifaces",
")",
":",
"ifaces",
"=",
"_ensure_ifaces_tuple",
"(",
"ifaces",
")",
"for",
"iface",
"in",
"ifaces",
":",
"attributes",
"=",
"(",
"attr",
"for",
"attr",
"in",
"iface",
".",
"__abstractmethods__",
"if",
"... | Check if a given instance is an implementation of the interface. | [
"Check",
"if",
"a",
"given",
"instance",
"is",
"an",
"implementation",
"of",
"the",
"interface",
"."
] | train | https://github.com/kevinconway/iface/blob/2687f7965eed155b9594a298ffa260a2f9f821f9/iface/checks.py#L124-L144 |
mirca/vaneska | vaneska/photometry.py | PSFPhotometry.fit | def fit(self, pixel_flux, data_placeholder, var_list, session, feed_dict={}):
"""
Parameters
----------
pixel_flux : ndarray
The TPF-like pixel flux time series. The first dimension
must represent time, and the remaining two dimensions
must represent t... | python | def fit(self, pixel_flux, data_placeholder, var_list, session, feed_dict={}):
"""
Parameters
----------
pixel_flux : ndarray
The TPF-like pixel flux time series. The first dimension
must represent time, and the remaining two dimensions
must represent t... | [
"def",
"fit",
"(",
"self",
",",
"pixel_flux",
",",
"data_placeholder",
",",
"var_list",
",",
"session",
",",
"feed_dict",
"=",
"{",
"}",
")",
":",
"opt_params",
"=",
"[",
"]",
"cadences",
"=",
"range",
"(",
"pixel_flux",
".",
"shape",
"[",
"0",
"]",
... | Parameters
----------
pixel_flux : ndarray
The TPF-like pixel flux time series. The first dimension
must represent time, and the remaining two dimensions
must represent the spatial dimensions.
data_placeholder : tf.placeholder
A placeholder which w... | [
"Parameters",
"----------",
"pixel_flux",
":",
"ndarray",
"The",
"TPF",
"-",
"like",
"pixel",
"flux",
"time",
"series",
".",
"The",
"first",
"dimension",
"must",
"represent",
"time",
"and",
"the",
"remaining",
"two",
"dimensions",
"must",
"represent",
"the",
"... | train | https://github.com/mirca/vaneska/blob/9bbf0b16957ec765e5f30872c8d22470c66bfd83/vaneska/photometry.py#L21-L46 |
moonso/extract_vcf | extract_vcf/plugin.py | Plugin.get_entry | def get_entry(self, variant_line=None, variant_dict=None, raw_entry=None,
vcf_header=None, csq_format=None, dict_key=None, individual_id=None):
"""Return the splitted entry from variant information
Args:
variant_line (str): A vcf formated variant line
... | python | def get_entry(self, variant_line=None, variant_dict=None, raw_entry=None,
vcf_header=None, csq_format=None, dict_key=None, individual_id=None):
"""Return the splitted entry from variant information
Args:
variant_line (str): A vcf formated variant line
... | [
"def",
"get_entry",
"(",
"self",
",",
"variant_line",
"=",
"None",
",",
"variant_dict",
"=",
"None",
",",
"raw_entry",
"=",
"None",
",",
"vcf_header",
"=",
"None",
",",
"csq_format",
"=",
"None",
",",
"dict_key",
"=",
"None",
",",
"individual_id",
"=",
"... | Return the splitted entry from variant information
Args:
variant_line (str): A vcf formated variant line
vcf_header (list): A list with the vcf header line
csq_format (list): A list with the csq headers
family_id (str): The family ... | [
"Return",
"the",
"splitted",
"entry",
"from",
"variant",
"information",
"Args",
":",
"variant_line",
"(",
"str",
")",
":",
"A",
"vcf",
"formated",
"variant",
"line",
"vcf_header",
"(",
"list",
")",
":",
"A",
"list",
"with",
"the",
"vcf",
"header",
"line",
... | train | https://github.com/moonso/extract_vcf/blob/c8381b362fa6734cd2ee65ef260738868d981aaf/extract_vcf/plugin.py#L82-L154 |
moonso/extract_vcf | extract_vcf/plugin.py | Plugin.get_raw_entry | def get_raw_entry(self, variant_line=None, variant_dict=None,
vcf_header=None, individual_id=None, dict_key=None):
"""Return the raw entry from the vcf field
If no entry was found return None
Args:
variant_line (str): A vcf formated variant ... | python | def get_raw_entry(self, variant_line=None, variant_dict=None,
vcf_header=None, individual_id=None, dict_key=None):
"""Return the raw entry from the vcf field
If no entry was found return None
Args:
variant_line (str): A vcf formated variant ... | [
"def",
"get_raw_entry",
"(",
"self",
",",
"variant_line",
"=",
"None",
",",
"variant_dict",
"=",
"None",
",",
"vcf_header",
"=",
"None",
",",
"individual_id",
"=",
"None",
",",
"dict_key",
"=",
"None",
")",
":",
"if",
"variant_line",
":",
"variant_line",
"... | Return the raw entry from the vcf field
If no entry was found return None
Args:
variant_line (str): A vcf formated variant line
vcf_header (list): A list with the vcf header line
individual_id (str): The individual id to g... | [
"Return",
"the",
"raw",
"entry",
"from",
"the",
"vcf",
"field",
"If",
"no",
"entry",
"was",
"found",
"return",
"None",
"Args",
":",
"variant_line",
"(",
"str",
")",
":",
"A",
"vcf",
"formated",
"variant",
"line",
"vcf_header",
"(",
"list",
")",
":",
"A... | train | https://github.com/moonso/extract_vcf/blob/c8381b362fa6734cd2ee65ef260738868d981aaf/extract_vcf/plugin.py#L156-L274 |
moonso/extract_vcf | extract_vcf/plugin.py | Plugin.get_value | def get_value(self, variant_line=None, variant_dict=None, entry=None,
raw_entry=None, vcf_header=None, csq_format=None, dict_key=None,
individual_id=None):
"""
Return the value as specified by plugin
Get value will return one value or None if no correct value is found.... | python | def get_value(self, variant_line=None, variant_dict=None, entry=None,
raw_entry=None, vcf_header=None, csq_format=None, dict_key=None,
individual_id=None):
"""
Return the value as specified by plugin
Get value will return one value or None if no correct value is found.... | [
"def",
"get_value",
"(",
"self",
",",
"variant_line",
"=",
"None",
",",
"variant_dict",
"=",
"None",
",",
"entry",
"=",
"None",
",",
"raw_entry",
"=",
"None",
",",
"vcf_header",
"=",
"None",
",",
"csq_format",
"=",
"None",
",",
"dict_key",
"=",
"None",
... | Return the value as specified by plugin
Get value will return one value or None if no correct value is found.
Arguments:
variant_line (str): A vcf variant line
variant_dict (dict): A variant dictionary
entry (list): A splitted entry
raw_e... | [
"Return",
"the",
"value",
"as",
"specified",
"by",
"plugin",
"Get",
"value",
"will",
"return",
"one",
"value",
"or",
"None",
"if",
"no",
"correct",
"value",
"is",
"found",
".",
"Arguments",
":",
"variant_line",
"(",
"str",
")",
":",
"A",
"vcf",
"variant"... | train | https://github.com/moonso/extract_vcf/blob/c8381b362fa6734cd2ee65ef260738868d981aaf/extract_vcf/plugin.py#L276-L401 |
Aluriak/tergraw | tergraw/tergraw.py | create_layout | def create_layout(graph, graphviz_prog=DEFAULT_GRAPHVIZ_PROG):
"""Return {node: position} for given graph"""
graphviz_layout = graphutils.graphviz_layout(graph, prog=graphviz_prog)
# print('GRAPHIZ LAYOUT:', graphviz_layout)
layout = {k: (int(x // 10), int(y // 10))
for k, (x, y) in graphv... | python | def create_layout(graph, graphviz_prog=DEFAULT_GRAPHVIZ_PROG):
"""Return {node: position} for given graph"""
graphviz_layout = graphutils.graphviz_layout(graph, prog=graphviz_prog)
# print('GRAPHIZ LAYOUT:', graphviz_layout)
layout = {k: (int(x // 10), int(y // 10))
for k, (x, y) in graphv... | [
"def",
"create_layout",
"(",
"graph",
",",
"graphviz_prog",
"=",
"DEFAULT_GRAPHVIZ_PROG",
")",
":",
"graphviz_layout",
"=",
"graphutils",
".",
"graphviz_layout",
"(",
"graph",
",",
"prog",
"=",
"graphviz_prog",
")",
"# print('GRAPHIZ LAYOUT:', graphviz_layout)",
"layout... | Return {node: position} for given graph | [
"Return",
"{",
"node",
":",
"position",
"}",
"for",
"given",
"graph"
] | train | https://github.com/Aluriak/tergraw/blob/7f73cd286a77611e9c73f50b1e43be4f6643ac9f/tergraw/tergraw.py#L33-L49 |
Aluriak/tergraw | tergraw/tergraw.py | pretty_view | def pretty_view(graph, oriented=False, construction=False,
graphviz_prog=DEFAULT_GRAPHVIZ_PROG):
"""Yield strings, printable view of given graph"""
layout = create_layout(graph, graphviz_prog=graphviz_prog)
matrix_view = defaultdict(lambda: ' ')
# Add the edge to the view
# print('... | python | def pretty_view(graph, oriented=False, construction=False,
graphviz_prog=DEFAULT_GRAPHVIZ_PROG):
"""Yield strings, printable view of given graph"""
layout = create_layout(graph, graphviz_prog=graphviz_prog)
matrix_view = defaultdict(lambda: ' ')
# Add the edge to the view
# print('... | [
"def",
"pretty_view",
"(",
"graph",
",",
"oriented",
"=",
"False",
",",
"construction",
"=",
"False",
",",
"graphviz_prog",
"=",
"DEFAULT_GRAPHVIZ_PROG",
")",
":",
"layout",
"=",
"create_layout",
"(",
"graph",
",",
"graphviz_prog",
"=",
"graphviz_prog",
")",
"... | Yield strings, printable view of given graph | [
"Yield",
"strings",
"printable",
"view",
"of",
"given",
"graph"
] | train | https://github.com/Aluriak/tergraw/blob/7f73cd286a77611e9c73f50b1e43be4f6643ac9f/tergraw/tergraw.py#L53-L193 |
jasonkeene/python-ubersmith | ubersmith/calls/__init__.py | _get_call_class | def _get_call_class(method):
"""Find the call class for method if it exists else create one."""
call_base, call_name = method.split('.', 1)
# import the call class's module
mod = __import__('ubersmith.calls.{0}'.format(call_base), fromlist=[''])
# grab all the public members of the module
gen = ... | python | def _get_call_class(method):
"""Find the call class for method if it exists else create one."""
call_base, call_name = method.split('.', 1)
# import the call class's module
mod = __import__('ubersmith.calls.{0}'.format(call_base), fromlist=[''])
# grab all the public members of the module
gen = ... | [
"def",
"_get_call_class",
"(",
"method",
")",
":",
"call_base",
",",
"call_name",
"=",
"method",
".",
"split",
"(",
"'.'",
",",
"1",
")",
"# import the call class's module",
"mod",
"=",
"__import__",
"(",
"'ubersmith.calls.{0}'",
".",
"format",
"(",
"call_base",... | Find the call class for method if it exists else create one. | [
"Find",
"the",
"call",
"class",
"for",
"method",
"if",
"it",
"exists",
"else",
"create",
"one",
"."
] | train | https://github.com/jasonkeene/python-ubersmith/blob/0c594e2eb41066d1fe7860e3a6f04b14c14f6e6a/ubersmith/calls/__init__.py#L85-L101 |
jasonkeene/python-ubersmith | ubersmith/calls/__init__.py | BaseCall.render | def render(self):
"""Validate, process, clean and return the result of the call."""
if not self.validate():
raise ValidationError
self.process_request()
self.clean()
return self.response | python | def render(self):
"""Validate, process, clean and return the result of the call."""
if not self.validate():
raise ValidationError
self.process_request()
self.clean()
return self.response | [
"def",
"render",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"validate",
"(",
")",
":",
"raise",
"ValidationError",
"self",
".",
"process_request",
"(",
")",
"self",
".",
"clean",
"(",
")",
"return",
"self",
".",
"response"
] | Validate, process, clean and return the result of the call. | [
"Validate",
"process",
"clean",
"and",
"return",
"the",
"result",
"of",
"the",
"call",
"."
] | train | https://github.com/jasonkeene/python-ubersmith/blob/0c594e2eb41066d1fe7860e3a6f04b14c14f6e6a/ubersmith/calls/__init__.py#L44-L52 |
jasonkeene/python-ubersmith | ubersmith/calls/__init__.py | BaseCall.validate | def validate(self):
"""Validate request data before sending it out. Return True/False."""
# check if required_fields aren't present
for field in set(self.required_fields) - set(self.request_data):
if not isinstance(field, string_types):
# field was a collection, itera... | python | def validate(self):
"""Validate request data before sending it out. Return True/False."""
# check if required_fields aren't present
for field in set(self.required_fields) - set(self.request_data):
if not isinstance(field, string_types):
# field was a collection, itera... | [
"def",
"validate",
"(",
"self",
")",
":",
"# check if required_fields aren't present",
"for",
"field",
"in",
"set",
"(",
"self",
".",
"required_fields",
")",
"-",
"set",
"(",
"self",
".",
"request_data",
")",
":",
"if",
"not",
"isinstance",
"(",
"field",
","... | Validate request data before sending it out. Return True/False. | [
"Validate",
"request",
"data",
"before",
"sending",
"it",
"out",
".",
"Return",
"True",
"/",
"False",
"."
] | train | https://github.com/jasonkeene/python-ubersmith/blob/0c594e2eb41066d1fe7860e3a6f04b14c14f6e6a/ubersmith/calls/__init__.py#L54-L62 |
jasonkeene/python-ubersmith | ubersmith/calls/__init__.py | BaseCall.process_request | def process_request(self):
"""Processing the call and set response_data."""
self.response = self.request_handler.process_request(
self.method, self.request_data) | python | def process_request(self):
"""Processing the call and set response_data."""
self.response = self.request_handler.process_request(
self.method, self.request_data) | [
"def",
"process_request",
"(",
"self",
")",
":",
"self",
".",
"response",
"=",
"self",
".",
"request_handler",
".",
"process_request",
"(",
"self",
".",
"method",
",",
"self",
".",
"request_data",
")"
] | Processing the call and set response_data. | [
"Processing",
"the",
"call",
"and",
"set",
"response_data",
"."
] | train | https://github.com/jasonkeene/python-ubersmith/blob/0c594e2eb41066d1fe7860e3a6f04b14c14f6e6a/ubersmith/calls/__init__.py#L64-L67 |
jasonkeene/python-ubersmith | ubersmith/calls/__init__.py | BaseCall.clean | def clean(self):
"""Clean response."""
if self.response.type == 'application/json':
cleaned = copy.deepcopy(self.response.data)
if self.cleaner is not None:
cleaned = self.cleaner(cleaned)
typed_response = {
dict: DictResponse,
... | python | def clean(self):
"""Clean response."""
if self.response.type == 'application/json':
cleaned = copy.deepcopy(self.response.data)
if self.cleaner is not None:
cleaned = self.cleaner(cleaned)
typed_response = {
dict: DictResponse,
... | [
"def",
"clean",
"(",
"self",
")",
":",
"if",
"self",
".",
"response",
".",
"type",
"==",
"'application/json'",
":",
"cleaned",
"=",
"copy",
".",
"deepcopy",
"(",
"self",
".",
"response",
".",
"data",
")",
"if",
"self",
".",
"cleaner",
"is",
"not",
"N... | Clean response. | [
"Clean",
"response",
"."
] | train | https://github.com/jasonkeene/python-ubersmith/blob/0c594e2eb41066d1fe7860e3a6f04b14c14f6e6a/ubersmith/calls/__init__.py#L69-L82 |
jasonkeene/python-ubersmith | ubersmith/compat.py | total_ordering | def total_ordering(cls): # pragma: no cover
"""Class decorator that fills in missing ordering methods"""
convert = {
'__lt__': [('__gt__', lambda self, other: not (self < other or self == other)),
('__le__', lambda self, other: self < other or self == other),
('__g... | python | def total_ordering(cls): # pragma: no cover
"""Class decorator that fills in missing ordering methods"""
convert = {
'__lt__': [('__gt__', lambda self, other: not (self < other or self == other)),
('__le__', lambda self, other: self < other or self == other),
('__g... | [
"def",
"total_ordering",
"(",
"cls",
")",
":",
"# pragma: no cover",
"convert",
"=",
"{",
"'__lt__'",
":",
"[",
"(",
"'__gt__'",
",",
"lambda",
"self",
",",
"other",
":",
"not",
"(",
"self",
"<",
"other",
"or",
"self",
"==",
"other",
")",
")",
",",
"... | Class decorator that fills in missing ordering methods | [
"Class",
"decorator",
"that",
"fills",
"in",
"missing",
"ordering",
"methods"
] | train | https://github.com/jasonkeene/python-ubersmith/blob/0c594e2eb41066d1fe7860e3a6f04b14c14f6e6a/ubersmith/compat.py#L6-L31 |
guillermo-carrasco/bcbio-nextgen-monitor | bcbio_monitor/log/__init__.py | init_logger_file | def init_logger_file(log_file, log_level='INFO'):
""" Append a FileHandler to the root logger.
:param str log_file: Path to the log file
:param str log_level: Logging level
"""
log_level = LOG_LEVELS[log_level] if log_level in LOG_LEVELS.keys() else logging.INFO
ROOT_LOG.setLevel(log_level)
... | python | def init_logger_file(log_file, log_level='INFO'):
""" Append a FileHandler to the root logger.
:param str log_file: Path to the log file
:param str log_level: Logging level
"""
log_level = LOG_LEVELS[log_level] if log_level in LOG_LEVELS.keys() else logging.INFO
ROOT_LOG.setLevel(log_level)
... | [
"def",
"init_logger_file",
"(",
"log_file",
",",
"log_level",
"=",
"'INFO'",
")",
":",
"log_level",
"=",
"LOG_LEVELS",
"[",
"log_level",
"]",
"if",
"log_level",
"in",
"LOG_LEVELS",
".",
"keys",
"(",
")",
"else",
"logging",
".",
"INFO",
"ROOT_LOG",
".",
"se... | Append a FileHandler to the root logger.
:param str log_file: Path to the log file
:param str log_level: Logging level | [
"Append",
"a",
"FileHandler",
"to",
"the",
"root",
"logger",
".",
":",
"param",
"str",
"log_file",
":",
"Path",
"to",
"the",
"log",
"file",
":",
"param",
"str",
"log_level",
":",
"Logging",
"level"
] | train | https://github.com/guillermo-carrasco/bcbio-nextgen-monitor/blob/6d059154d774140e1fd03a0e3625f607cef06f5a/bcbio_monitor/log/__init__.py#L24-L36 |
blockstack-packages/blockstack-auth-python | blockchainauth/keys.py | load_signing_key | def load_signing_key(signing_key, crypto_backend=default_backend()):
""" Optional: crypto backend object from the "cryptography" python library
"""
if not isinstance(crypto_backend, (Backend, MultiBackend)):
raise ValueError('backend must be a valid Backend object')
if isinstance(signing_key, E... | python | def load_signing_key(signing_key, crypto_backend=default_backend()):
""" Optional: crypto backend object from the "cryptography" python library
"""
if not isinstance(crypto_backend, (Backend, MultiBackend)):
raise ValueError('backend must be a valid Backend object')
if isinstance(signing_key, E... | [
"def",
"load_signing_key",
"(",
"signing_key",
",",
"crypto_backend",
"=",
"default_backend",
"(",
")",
")",
":",
"if",
"not",
"isinstance",
"(",
"crypto_backend",
",",
"(",
"Backend",
",",
"MultiBackend",
")",
")",
":",
"raise",
"ValueError",
"(",
"'backend m... | Optional: crypto backend object from the "cryptography" python library | [
"Optional",
":",
"crypto",
"backend",
"object",
"from",
"the",
"cryptography",
"python",
"library"
] | train | https://github.com/blockstack-packages/blockstack-auth-python/blob/24f1707fbb31d1dcd8c327d232027b15ffd66135/blockchainauth/keys.py#L21-L50 |
blockstack-packages/blockstack-auth-python | blockchainauth/keys.py | load_verifying_key | def load_verifying_key(verifying_key, crypto_backend=default_backend()):
""" Optional: crypto backend object from the "cryptography" python library
"""
if not isinstance(crypto_backend, (Backend, MultiBackend)):
raise ValueError('backend must be a valid Backend object')
if isinstance(verifying_... | python | def load_verifying_key(verifying_key, crypto_backend=default_backend()):
""" Optional: crypto backend object from the "cryptography" python library
"""
if not isinstance(crypto_backend, (Backend, MultiBackend)):
raise ValueError('backend must be a valid Backend object')
if isinstance(verifying_... | [
"def",
"load_verifying_key",
"(",
"verifying_key",
",",
"crypto_backend",
"=",
"default_backend",
"(",
")",
")",
":",
"if",
"not",
"isinstance",
"(",
"crypto_backend",
",",
"(",
"Backend",
",",
"MultiBackend",
")",
")",
":",
"raise",
"ValueError",
"(",
"'backe... | Optional: crypto backend object from the "cryptography" python library | [
"Optional",
":",
"crypto",
"backend",
"object",
"from",
"the",
"cryptography",
"python",
"library"
] | train | https://github.com/blockstack-packages/blockstack-auth-python/blob/24f1707fbb31d1dcd8c327d232027b15ffd66135/blockchainauth/keys.py#L53-L72 |
artefactual-labs/agentarchives | agentarchives/atom/client.py | AtomClient._format_notes | def _format_notes(self, record):
"""
Extracts notes from a record and reformats them in a simplified format.
"""
notes = []
if "notes" in record:
for note in record["notes"]:
self._append_note_dict_to_list(notes, "general", note)
if "language... | python | def _format_notes(self, record):
"""
Extracts notes from a record and reformats them in a simplified format.
"""
notes = []
if "notes" in record:
for note in record["notes"]:
self._append_note_dict_to_list(notes, "general", note)
if "language... | [
"def",
"_format_notes",
"(",
"self",
",",
"record",
")",
":",
"notes",
"=",
"[",
"]",
"if",
"\"notes\"",
"in",
"record",
":",
"for",
"note",
"in",
"record",
"[",
"\"notes\"",
"]",
":",
"self",
".",
"_append_note_dict_to_list",
"(",
"notes",
",",
"\"gener... | Extracts notes from a record and reformats them in a simplified format. | [
"Extracts",
"notes",
"from",
"a",
"record",
"and",
"reformats",
"them",
"in",
"a",
"simplified",
"format",
"."
] | train | https://github.com/artefactual-labs/agentarchives/blob/af19ade56a90c64069cf46b50972fe72b6f10a45/agentarchives/atom/client.py#L114-L141 |
artefactual-labs/agentarchives | agentarchives/atom/client.py | AtomClient._escape_lucene_query | def _escape_lucene_query(query, field=None):
"""
Escapes special characters in Solr queries.
Note that this omits * - this is intentionally permitted in user queries.
The list of special characters is located at http://lucene.apache.org/core/4_0_0/queryparser/org/apache/lucene/queryparse... | python | def _escape_lucene_query(query, field=None):
"""
Escapes special characters in Solr queries.
Note that this omits * - this is intentionally permitted in user queries.
The list of special characters is located at http://lucene.apache.org/core/4_0_0/queryparser/org/apache/lucene/queryparse... | [
"def",
"_escape_lucene_query",
"(",
"query",
",",
"field",
"=",
"None",
")",
":",
"replacement",
"=",
"r\"\\\\\\1\"",
"return",
"re",
".",
"sub",
"(",
"r'([\\'\" +\\-!\\(\\)\\{\\}\\[\\]^\"~?:\\\\/]|&&|\\|\\|)'",
",",
"replacement",
",",
"query",
")"
] | Escapes special characters in Solr queries.
Note that this omits * - this is intentionally permitted in user queries.
The list of special characters is located at http://lucene.apache.org/core/4_0_0/queryparser/org/apache/lucene/queryparser/classic/package-summary.html#Escaping_Special_Characters | [
"Escapes",
"special",
"characters",
"in",
"Solr",
"queries",
".",
"Note",
"that",
"this",
"omits",
"*",
"-",
"this",
"is",
"intentionally",
"permitted",
"in",
"user",
"queries",
".",
"The",
"list",
"of",
"special",
"characters",
"is",
"located",
"at",
"http"... | train | https://github.com/artefactual-labs/agentarchives/blob/af19ade56a90c64069cf46b50972fe72b6f10a45/agentarchives/atom/client.py#L151-L158 |
artefactual-labs/agentarchives | agentarchives/atom/client.py | AtomClient.edit_record | def edit_record(self, new_record):
"""
Update a record in AtoM using the provided new_record.
The format of new_record is identical to the format returned by get_resource_component_and_children and related methods; consult the documentation for that method in ArchivistsToolkitClient to see the ... | python | def edit_record(self, new_record):
"""
Update a record in AtoM using the provided new_record.
The format of new_record is identical to the format returned by get_resource_component_and_children and related methods; consult the documentation for that method in ArchivistsToolkitClient to see the ... | [
"def",
"edit_record",
"(",
"self",
",",
"new_record",
")",
":",
"try",
":",
"record_id",
"=",
"new_record",
"[",
"\"slug\"",
"]",
"except",
"KeyError",
":",
"raise",
"ValueError",
"(",
"\"No slug provided!\"",
")",
"record",
"=",
"self",
".",
"get_record",
"... | Update a record in AtoM using the provided new_record.
The format of new_record is identical to the format returned by get_resource_component_and_children and related methods; consult the documentation for that method in ArchivistsToolkitClient to see the format.
This means it's possible, for example, ... | [
"Update",
"a",
"record",
"in",
"AtoM",
"using",
"the",
"provided",
"new_record",
"."
] | train | https://github.com/artefactual-labs/agentarchives/blob/af19ade56a90c64069cf46b50972fe72b6f10a45/agentarchives/atom/client.py#L181-L264 |
artefactual-labs/agentarchives | agentarchives/atom/client.py | AtomClient.get_levels_of_description | def get_levels_of_description(self):
"""
Returns an array of all levels of description defined in this AtoM instance.
"""
if not hasattr(self, "levels_of_description"):
self.levels_of_description = [
item["name"]
for item in self._get(urljoin(s... | python | def get_levels_of_description(self):
"""
Returns an array of all levels of description defined in this AtoM instance.
"""
if not hasattr(self, "levels_of_description"):
self.levels_of_description = [
item["name"]
for item in self._get(urljoin(s... | [
"def",
"get_levels_of_description",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"\"levels_of_description\"",
")",
":",
"self",
".",
"levels_of_description",
"=",
"[",
"item",
"[",
"\"name\"",
"]",
"for",
"item",
"in",
"self",
".",
"_get"... | Returns an array of all levels of description defined in this AtoM instance. | [
"Returns",
"an",
"array",
"of",
"all",
"levels",
"of",
"description",
"defined",
"in",
"this",
"AtoM",
"instance",
"."
] | train | https://github.com/artefactual-labs/agentarchives/blob/af19ade56a90c64069cf46b50972fe72b6f10a45/agentarchives/atom/client.py#L266-L276 |
artefactual-labs/agentarchives | agentarchives/atom/client.py | AtomClient.collection_list | def collection_list(self, resource_id, resource_type="collection"):
"""
Fetches a list of slug representing descriptions within the specified parent description.
:param resource_id str: The slug of the description to fetch children from.
:param resource_type str: no-op; not required or ... | python | def collection_list(self, resource_id, resource_type="collection"):
"""
Fetches a list of slug representing descriptions within the specified parent description.
:param resource_id str: The slug of the description to fetch children from.
:param resource_type str: no-op; not required or ... | [
"def",
"collection_list",
"(",
"self",
",",
"resource_id",
",",
"resource_type",
"=",
"\"collection\"",
")",
":",
"def",
"fetch_children",
"(",
"children",
")",
":",
"results",
"=",
"[",
"]",
"for",
"child",
"in",
"children",
":",
"results",
".",
"append",
... | Fetches a list of slug representing descriptions within the specified parent description.
:param resource_id str: The slug of the description to fetch children from.
:param resource_type str: no-op; not required or used in this implementation.
:return: A list of strings representing the slugs ... | [
"Fetches",
"a",
"list",
"of",
"slug",
"representing",
"descriptions",
"within",
"the",
"specified",
"parent",
"description",
"."
] | train | https://github.com/artefactual-labs/agentarchives/blob/af19ade56a90c64069cf46b50972fe72b6f10a45/agentarchives/atom/client.py#L278-L304 |
artefactual-labs/agentarchives | agentarchives/atom/client.py | AtomClient.get_resource_component_and_children | def get_resource_component_and_children(
self,
resource_id,
resource_type="collection",
level=1,
sort_data={},
recurse_max_level=False,
sort_by=None,
**kwargs
):
"""
Fetch detailed metadata for the specified resource_id and all of its c... | python | def get_resource_component_and_children(
self,
resource_id,
resource_type="collection",
level=1,
sort_data={},
recurse_max_level=False,
sort_by=None,
**kwargs
):
"""
Fetch detailed metadata for the specified resource_id and all of its c... | [
"def",
"get_resource_component_and_children",
"(",
"self",
",",
"resource_id",
",",
"resource_type",
"=",
"\"collection\"",
",",
"level",
"=",
"1",
",",
"sort_data",
"=",
"{",
"}",
",",
"recurse_max_level",
"=",
"False",
",",
"sort_by",
"=",
"None",
",",
"*",
... | Fetch detailed metadata for the specified resource_id and all of its children.
:param str resource_id: The slug for which to fetch description metadata.
:param str resource_type: no-op; not required or used in this implementation.
:param int recurse_max_level: The maximum depth level to fetch w... | [
"Fetch",
"detailed",
"metadata",
"for",
"the",
"specified",
"resource_id",
"and",
"all",
"of",
"its",
"children",
"."
] | train | https://github.com/artefactual-labs/agentarchives/blob/af19ade56a90c64069cf46b50972fe72b6f10a45/agentarchives/atom/client.py#L370-L395 |
artefactual-labs/agentarchives | agentarchives/atom/client.py | AtomClient.find_parent_id_for_component | def find_parent_id_for_component(self, slug):
"""
Given the slug of a description, returns the parent description's slug.
:param string slug: The slug of a description.
:return: The URL of the parent record.
:rtype: string
"""
response = self.get_record(slug)
... | python | def find_parent_id_for_component(self, slug):
"""
Given the slug of a description, returns the parent description's slug.
:param string slug: The slug of a description.
:return: The URL of the parent record.
:rtype: string
"""
response = self.get_record(slug)
... | [
"def",
"find_parent_id_for_component",
"(",
"self",
",",
"slug",
")",
":",
"response",
"=",
"self",
".",
"get_record",
"(",
"slug",
")",
"if",
"\"parent\"",
"in",
"response",
":",
"return",
"response",
"[",
"\"parent\"",
"]",
"# resource was passed in, which has n... | Given the slug of a description, returns the parent description's slug.
:param string slug: The slug of a description.
:return: The URL of the parent record.
:rtype: string | [
"Given",
"the",
"slug",
"of",
"a",
"description",
"returns",
"the",
"parent",
"description",
"s",
"slug",
"."
] | train | https://github.com/artefactual-labs/agentarchives/blob/af19ade56a90c64069cf46b50972fe72b6f10a45/agentarchives/atom/client.py#L437-L452 |
artefactual-labs/agentarchives | agentarchives/atom/client.py | AtomClient.find_collection_ids | def find_collection_ids(self, search_pattern="", identifier="", fetched=0, page=1):
"""
Fetches a list of resource URLs for every top-level description in the database.
:param string search_pattern: A search pattern to use in looking up resources by title or resourceid.
The search w... | python | def find_collection_ids(self, search_pattern="", identifier="", fetched=0, page=1):
"""
Fetches a list of resource URLs for every top-level description in the database.
:param string search_pattern: A search pattern to use in looking up resources by title or resourceid.
The search w... | [
"def",
"find_collection_ids",
"(",
"self",
",",
"search_pattern",
"=",
"\"\"",
",",
"identifier",
"=",
"\"\"",
",",
"fetched",
"=",
"0",
",",
"page",
"=",
"1",
")",
":",
"response",
"=",
"self",
".",
"_collections_search_request",
"(",
"search_pattern",
",",... | Fetches a list of resource URLs for every top-level description in the database.
:param string search_pattern: A search pattern to use in looking up resources by title or resourceid.
The search will match any title containing this string;
for example, "text" will match "this title has t... | [
"Fetches",
"a",
"list",
"of",
"resource",
"URLs",
"for",
"every",
"top",
"-",
"level",
"description",
"in",
"the",
"database",
"."
] | train | https://github.com/artefactual-labs/agentarchives/blob/af19ade56a90c64069cf46b50972fe72b6f10a45/agentarchives/atom/client.py#L454-L479 |
artefactual-labs/agentarchives | agentarchives/atom/client.py | AtomClient._collections_search_request | def _collections_search_request(
self, search_pattern="", identifier="", page=1, page_size=50, sort_by=None
):
"""
Fetches a list of resource URLs for every top-level description in the database.
:param string search_pattern: A search pattern to use in looking up resources by title ... | python | def _collections_search_request(
self, search_pattern="", identifier="", page=1, page_size=50, sort_by=None
):
"""
Fetches a list of resource URLs for every top-level description in the database.
:param string search_pattern: A search pattern to use in looking up resources by title ... | [
"def",
"_collections_search_request",
"(",
"self",
",",
"search_pattern",
"=",
"\"\"",
",",
"identifier",
"=",
"\"\"",
",",
"page",
"=",
"1",
",",
"page_size",
"=",
"50",
",",
"sort_by",
"=",
"None",
")",
":",
"skip",
"=",
"(",
"page",
"-",
"1",
")",
... | Fetches a list of resource URLs for every top-level description in the database.
:param string search_pattern: A search pattern to use in looking up resources by title or resourceid.
The search will match any title containing this string;
for example, "text" will match "this title has t... | [
"Fetches",
"a",
"list",
"of",
"resource",
"URLs",
"for",
"every",
"top",
"-",
"level",
"description",
"in",
"the",
"database",
"."
] | train | https://github.com/artefactual-labs/agentarchives/blob/af19ade56a90c64069cf46b50972fe72b6f10a45/agentarchives/atom/client.py#L481-L520 |
artefactual-labs/agentarchives | agentarchives/atom/client.py | AtomClient.find_collections | def find_collections(
self,
search_pattern="",
identifier="",
fetched=0,
page=1,
page_size=30,
sort_by=None,
):
"""
Fetches a list of all resource IDs for every resource in the database.
:param string search_pattern: A search pattern t... | python | def find_collections(
self,
search_pattern="",
identifier="",
fetched=0,
page=1,
page_size=30,
sort_by=None,
):
"""
Fetches a list of all resource IDs for every resource in the database.
:param string search_pattern: A search pattern t... | [
"def",
"find_collections",
"(",
"self",
",",
"search_pattern",
"=",
"\"\"",
",",
"identifier",
"=",
"\"\"",
",",
"fetched",
"=",
"0",
",",
"page",
"=",
"1",
",",
"page_size",
"=",
"30",
",",
"sort_by",
"=",
"None",
",",
")",
":",
"def",
"format_record"... | Fetches a list of all resource IDs for every resource in the database.
:param string search_pattern: A search pattern to use in looking up resources by title or resourceid.
The search will match any title or resourceid containing this string;
for example, "text" will match "this title h... | [
"Fetches",
"a",
"list",
"of",
"all",
"resource",
"IDs",
"for",
"every",
"resource",
"in",
"the",
"database",
"."
] | train | https://github.com/artefactual-labs/agentarchives/blob/af19ade56a90c64069cf46b50972fe72b6f10a45/agentarchives/atom/client.py#L526-L588 |
artefactual-labs/agentarchives | agentarchives/atom/client.py | AtomClient.augment_resource_ids | def augment_resource_ids(self, resource_ids):
"""
Given a list of resource IDs, returns a list of dicts containing detailed information about the specified resources and their children.
This function recurses to a maximum of two levels when fetching children from the specified resources.
... | python | def augment_resource_ids(self, resource_ids):
"""
Given a list of resource IDs, returns a list of dicts containing detailed information about the specified resources and their children.
This function recurses to a maximum of two levels when fetching children from the specified resources.
... | [
"def",
"augment_resource_ids",
"(",
"self",
",",
"resource_ids",
")",
":",
"resources_augmented",
"=",
"[",
"]",
"for",
"id",
"in",
"resource_ids",
":",
"# resource_data = self.get_resource_component_and_children(id, recurse_max_level=2)",
"# resources_augmented.append(resource_d... | Given a list of resource IDs, returns a list of dicts containing detailed information about the specified resources and their children.
This function recurses to a maximum of two levels when fetching children from the specified resources.
Consult the documentation of ArchivistsToolkitClient.get_resourc... | [
"Given",
"a",
"list",
"of",
"resource",
"IDs",
"returns",
"a",
"list",
"of",
"dicts",
"containing",
"detailed",
"information",
"about",
"the",
"specified",
"resources",
"and",
"their",
"children",
"."
] | train | https://github.com/artefactual-labs/agentarchives/blob/af19ade56a90c64069cf46b50972fe72b6f10a45/agentarchives/atom/client.py#L594-L613 |
artefactual-labs/agentarchives | agentarchives/atom/client.py | AtomClient.add_digital_object | def add_digital_object(
self,
information_object_slug,
identifier=None,
title=None,
uri=None,
location_of_originals=None,
object_type=None,
xlink_show="embed",
xlink_actuate="onLoad",
restricted=False,
use_statement="",
use_... | python | def add_digital_object(
self,
information_object_slug,
identifier=None,
title=None,
uri=None,
location_of_originals=None,
object_type=None,
xlink_show="embed",
xlink_actuate="onLoad",
restricted=False,
use_statement="",
use_... | [
"def",
"add_digital_object",
"(",
"self",
",",
"information_object_slug",
",",
"identifier",
"=",
"None",
",",
"title",
"=",
"None",
",",
"uri",
"=",
"None",
",",
"location_of_originals",
"=",
"None",
",",
"object_type",
"=",
"None",
",",
"xlink_show",
"=",
... | Creates a new digital object. | [
"Creates",
"a",
"new",
"digital",
"object",
"."
] | train | https://github.com/artefactual-labs/agentarchives/blob/af19ade56a90c64069cf46b50972fe72b6f10a45/agentarchives/atom/client.py#L615-L678 |
artefactual-labs/agentarchives | agentarchives/atom/client.py | AtomClient.add_child | def add_child(
self,
parent_slug=None,
title="",
level="",
start_date=None,
end_date=None,
date_expression=None,
notes=[],
):
"""
Adds a new resource component parented within `parent`.
:param str parent_slug: The parent's slug... | python | def add_child(
self,
parent_slug=None,
title="",
level="",
start_date=None,
end_date=None,
date_expression=None,
notes=[],
):
"""
Adds a new resource component parented within `parent`.
:param str parent_slug: The parent's slug... | [
"def",
"add_child",
"(",
"self",
",",
"parent_slug",
"=",
"None",
",",
"title",
"=",
"\"\"",
",",
"level",
"=",
"\"\"",
",",
"start_date",
"=",
"None",
",",
"end_date",
"=",
"None",
",",
"date_expression",
"=",
"None",
",",
"notes",
"=",
"[",
"]",
",... | Adds a new resource component parented within `parent`.
:param str parent_slug: The parent's slug.
:param str title: A title for the record.
:param str level: The level of description.
:return: The ID of the newly-created record. | [
"Adds",
"a",
"new",
"resource",
"component",
"parented",
"within",
"parent",
"."
] | train | https://github.com/artefactual-labs/agentarchives/blob/af19ade56a90c64069cf46b50972fe72b6f10a45/agentarchives/atom/client.py#L692-L747 |
artefactual-labs/agentarchives | agentarchives/atom/client.py | AtomClient.delete_record | def delete_record(self, record_id):
"""
Delete a record with record_id.
"""
self._delete(
urljoin(self.base_url, "informationobjects/{}".format(record_id)),
expected_response=204,
)
return {"status": "Deleted"} | python | def delete_record(self, record_id):
"""
Delete a record with record_id.
"""
self._delete(
urljoin(self.base_url, "informationobjects/{}".format(record_id)),
expected_response=204,
)
return {"status": "Deleted"} | [
"def",
"delete_record",
"(",
"self",
",",
"record_id",
")",
":",
"self",
".",
"_delete",
"(",
"urljoin",
"(",
"self",
".",
"base_url",
",",
"\"informationobjects/{}\"",
".",
"format",
"(",
"record_id",
")",
")",
",",
"expected_response",
"=",
"204",
",",
"... | Delete a record with record_id. | [
"Delete",
"a",
"record",
"with",
"record_id",
"."
] | train | https://github.com/artefactual-labs/agentarchives/blob/af19ade56a90c64069cf46b50972fe72b6f10a45/agentarchives/atom/client.py#L749-L757 |
moonso/extract_vcf | extract_vcf/config_parser.py | ConfigParser.get_string_dict | def get_string_dict(self, plugin_info):
"""
Convert a section with information of priorities to a string dict.
To avoid typos we make all letters lower case when comparing
Arguments:
plugin_info (dict): A dictionary with plugin information
R... | python | def get_string_dict(self, plugin_info):
"""
Convert a section with information of priorities to a string dict.
To avoid typos we make all letters lower case when comparing
Arguments:
plugin_info (dict): A dictionary with plugin information
R... | [
"def",
"get_string_dict",
"(",
"self",
",",
"plugin_info",
")",
":",
"string_info",
"=",
"[",
"]",
"string_dict",
"=",
"{",
"}",
"for",
"key",
"in",
"plugin_info",
":",
"try",
":",
"string_info",
".",
"append",
"(",
"dict",
"(",
"plugin_info",
"[",
"key"... | Convert a section with information of priorities to a string dict.
To avoid typos we make all letters lower case when comparing
Arguments:
plugin_info (dict): A dictionary with plugin information
Return:
string_dict (dict): A dictionary with str... | [
"Convert",
"a",
"section",
"with",
"information",
"of",
"priorities",
"to",
"a",
"string",
"dict",
".",
"To",
"avoid",
"typos",
"we",
"make",
"all",
"letters",
"lower",
"case",
"when",
"comparing",
"Arguments",
":",
"plugin_info",
"(",
"dict",
")",
":",
"A... | train | https://github.com/moonso/extract_vcf/blob/c8381b362fa6734cd2ee65ef260738868d981aaf/extract_vcf/config_parser.py#L128-L171 |
moonso/extract_vcf | extract_vcf/config_parser.py | ConfigParser.version_check | def version_check(self):
"""
Check if the version entry is in the proper format
"""
try:
version_info = self['Version']
except KeyError:
raise ValidateError('Config file has to have a Version section')
try:
float(version_info['version']... | python | def version_check(self):
"""
Check if the version entry is in the proper format
"""
try:
version_info = self['Version']
except KeyError:
raise ValidateError('Config file has to have a Version section')
try:
float(version_info['version']... | [
"def",
"version_check",
"(",
"self",
")",
":",
"try",
":",
"version_info",
"=",
"self",
"[",
"'Version'",
"]",
"except",
"KeyError",
":",
"raise",
"ValidateError",
"(",
"'Config file has to have a Version section'",
")",
"try",
":",
"float",
"(",
"version_info",
... | Check if the version entry is in the proper format | [
"Check",
"if",
"the",
"version",
"entry",
"is",
"in",
"the",
"proper",
"format"
] | train | https://github.com/moonso/extract_vcf/blob/c8381b362fa6734cd2ee65ef260738868d981aaf/extract_vcf/config_parser.py#L175-L194 |
moonso/extract_vcf | extract_vcf/config_parser.py | ConfigParser.check_plugin | def check_plugin(self, plugin):
"""
Check if the section is in the proper format vcf format.
Args:
vcf_section (dict): The information from a vcf section
Returns:
True is it is in the proper format
"""
vcf_section = self[plugin]
... | python | def check_plugin(self, plugin):
"""
Check if the section is in the proper format vcf format.
Args:
vcf_section (dict): The information from a vcf section
Returns:
True is it is in the proper format
"""
vcf_section = self[plugin]
... | [
"def",
"check_plugin",
"(",
"self",
",",
"plugin",
")",
":",
"vcf_section",
"=",
"self",
"[",
"plugin",
"]",
"try",
":",
"vcf_field",
"=",
"vcf_section",
"[",
"'field'",
"]",
"if",
"not",
"vcf_field",
"in",
"self",
".",
"vcf_columns",
":",
"raise",
"Vali... | Check if the section is in the proper format vcf format.
Args:
vcf_section (dict): The information from a vcf section
Returns:
True is it is in the proper format | [
"Check",
"if",
"the",
"section",
"is",
"in",
"the",
"proper",
"format",
"vcf",
"format",
"."
] | train | https://github.com/moonso/extract_vcf/blob/c8381b362fa6734cd2ee65ef260738868d981aaf/extract_vcf/config_parser.py#L196-L290 |
Aluriak/tergraw | tergraw/graphutils.py | dict_to_nx | def dict_to_nx(graph, oriented=False):
"""Return an nx.Graph equivalent of given {node: succs}"""
nxg = nx.DiGraph() if oriented else nx.Graph()
for node, succs in graph.items():
for succ in succs:
nxg.add_edge(node, succ)
return nxg | python | def dict_to_nx(graph, oriented=False):
"""Return an nx.Graph equivalent of given {node: succs}"""
nxg = nx.DiGraph() if oriented else nx.Graph()
for node, succs in graph.items():
for succ in succs:
nxg.add_edge(node, succ)
return nxg | [
"def",
"dict_to_nx",
"(",
"graph",
",",
"oriented",
"=",
"False",
")",
":",
"nxg",
"=",
"nx",
".",
"DiGraph",
"(",
")",
"if",
"oriented",
"else",
"nx",
".",
"Graph",
"(",
")",
"for",
"node",
",",
"succs",
"in",
"graph",
".",
"items",
"(",
")",
":... | Return an nx.Graph equivalent of given {node: succs} | [
"Return",
"an",
"nx",
".",
"Graph",
"equivalent",
"of",
"given",
"{",
"node",
":",
"succs",
"}"
] | train | https://github.com/Aluriak/tergraw/blob/7f73cd286a77611e9c73f50b1e43be4f6643ac9f/tergraw/graphutils.py#L12-L18 |
Aluriak/tergraw | tergraw/graphutils.py | process_input_graph | def process_input_graph(func):
"""Decorator, ensuring first argument is a networkx graph object.
If the first arg is a dict {node: succs}, a networkx graph equivalent
to the dict will be send in place of it."""
@wraps(func)
def wrapped_func(*args, **kwargs):
input_graph = args[0]
if ... | python | def process_input_graph(func):
"""Decorator, ensuring first argument is a networkx graph object.
If the first arg is a dict {node: succs}, a networkx graph equivalent
to the dict will be send in place of it."""
@wraps(func)
def wrapped_func(*args, **kwargs):
input_graph = args[0]
if ... | [
"def",
"process_input_graph",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"wrapped_func",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"input_graph",
"=",
"args",
"[",
"0",
"]",
"if",
"isinstance",
"(",
"input_graph",
",",
"... | Decorator, ensuring first argument is a networkx graph object.
If the first arg is a dict {node: succs}, a networkx graph equivalent
to the dict will be send in place of it. | [
"Decorator",
"ensuring",
"first",
"argument",
"is",
"a",
"networkx",
"graph",
"object",
".",
"If",
"the",
"first",
"arg",
"is",
"a",
"dict",
"{",
"node",
":",
"succs",
"}",
"a",
"networkx",
"graph",
"equivalent",
"to",
"the",
"dict",
"will",
"be",
"send"... | train | https://github.com/Aluriak/tergraw/blob/7f73cd286a77611e9c73f50b1e43be4f6643ac9f/tergraw/graphutils.py#L21-L34 |
davidcarboni/Flask-B3 | b3/__init__.py | values | def values():
"""Get the full current set of B3 values.
:return: A dict containing the keys "X-B3-TraceId", "X-B3-ParentSpanId", "X-B3-SpanId", "X-B3-Sampled" and
"X-B3-Flags" for the current span or subspan. NB some of the values are likely be None, but
all keys will be present.
"""
result = {}... | python | def values():
"""Get the full current set of B3 values.
:return: A dict containing the keys "X-B3-TraceId", "X-B3-ParentSpanId", "X-B3-SpanId", "X-B3-Sampled" and
"X-B3-Flags" for the current span or subspan. NB some of the values are likely be None, but
all keys will be present.
"""
result = {}... | [
"def",
"values",
"(",
")",
":",
"result",
"=",
"{",
"}",
"try",
":",
"# Check if there's a sub-span in progress, otherwise use the main span:",
"span",
"=",
"g",
".",
"get",
"(",
"\"subspan\"",
")",
"if",
"\"subspan\"",
"in",
"g",
"else",
"g",
"for",
"header",
... | Get the full current set of B3 values.
:return: A dict containing the keys "X-B3-TraceId", "X-B3-ParentSpanId", "X-B3-SpanId", "X-B3-Sampled" and
"X-B3-Flags" for the current span or subspan. NB some of the values are likely be None, but
all keys will be present. | [
"Get",
"the",
"full",
"current",
"set",
"of",
"B3",
"values",
".",
":",
"return",
":",
"A",
"dict",
"containing",
"the",
"keys",
"X",
"-",
"B3",
"-",
"TraceId",
"X",
"-",
"B3",
"-",
"ParentSpanId",
"X",
"-",
"B3",
"-",
"SpanId",
"X",
"-",
"B3",
"... | train | https://github.com/davidcarboni/Flask-B3/blob/55092cb1070568aeecfd2c07c5ad6122e15ca345/b3/__init__.py#L20-L39 |
davidcarboni/Flask-B3 | b3/__init__.py | start_span | def start_span(request_headers=None):
"""Collects incoming B3 headers and sets up values for this request as needed.
The collected/computed values are stored on the application context g using the defined http header names as keys.
:param request_headers: Incoming request headers can be passed explicitly.
... | python | def start_span(request_headers=None):
"""Collects incoming B3 headers and sets up values for this request as needed.
The collected/computed values are stored on the application context g using the defined http header names as keys.
:param request_headers: Incoming request headers can be passed explicitly.
... | [
"def",
"start_span",
"(",
"request_headers",
"=",
"None",
")",
":",
"global",
"debug",
"try",
":",
"headers",
"=",
"request_headers",
"if",
"request_headers",
"else",
"request",
".",
"headers",
"except",
"RuntimeError",
":",
"# We're probably working outside the Appli... | Collects incoming B3 headers and sets up values for this request as needed.
The collected/computed values are stored on the application context g using the defined http header names as keys.
:param request_headers: Incoming request headers can be passed explicitly.
If not passed, Flask request.headers will ... | [
"Collects",
"incoming",
"B3",
"headers",
"and",
"sets",
"up",
"values",
"for",
"this",
"request",
"as",
"needed",
".",
"The",
"collected",
"/",
"computed",
"values",
"are",
"stored",
"on",
"the",
"application",
"context",
"g",
"using",
"the",
"defined",
"htt... | train | https://github.com/davidcarboni/Flask-B3/blob/55092cb1070568aeecfd2c07c5ad6122e15ca345/b3/__init__.py#L42-L85 |
davidcarboni/Flask-B3 | b3/__init__.py | span | def span(route):
"""Optional decorator for Flask routes.
If you don't want to trace all routes using `Flask.before_request()' and 'Flask.after_request()'
you can use this decorator as an alternative way to handle incoming B3 headers:
@app.route('/instrumented')
@span
def instrument... | python | def span(route):
"""Optional decorator for Flask routes.
If you don't want to trace all routes using `Flask.before_request()' and 'Flask.after_request()'
you can use this decorator as an alternative way to handle incoming B3 headers:
@app.route('/instrumented')
@span
def instrument... | [
"def",
"span",
"(",
"route",
")",
":",
"@",
"wraps",
"(",
"route",
")",
"def",
"route_decorator",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"start_span",
"(",
")",
"try",
":",
"return",
"route",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs... | Optional decorator for Flask routes.
If you don't want to trace all routes using `Flask.before_request()' and 'Flask.after_request()'
you can use this decorator as an alternative way to handle incoming B3 headers:
@app.route('/instrumented')
@span
def instrumented():
...
... | [
"Optional",
"decorator",
"for",
"Flask",
"routes",
"."
] | train | https://github.com/davidcarboni/Flask-B3/blob/55092cb1070568aeecfd2c07c5ad6122e15ca345/b3/__init__.py#L99-L123 |
davidcarboni/Flask-B3 | b3/__init__.py | _start_subspan | def _start_subspan(headers=None):
""" Sets up a new span to contact a downstream service.
This is used when making a downstream service call. It returns a dict containing the required sub-span headers.
Each downstream call you make is handled as a new span, so call this every time you need to contact anothe... | python | def _start_subspan(headers=None):
""" Sets up a new span to contact a downstream service.
This is used when making a downstream service call. It returns a dict containing the required sub-span headers.
Each downstream call you make is handled as a new span, so call this every time you need to contact anothe... | [
"def",
"_start_subspan",
"(",
"headers",
"=",
"None",
")",
":",
"b3",
"=",
"values",
"(",
")",
"g",
".",
"subspan",
"=",
"{",
"# Propagate the trace ID",
"b3_trace_id",
":",
"b3",
"[",
"b3_trace_id",
"]",
",",
"# Start a new span for the outgoing request",
"b3_s... | Sets up a new span to contact a downstream service.
This is used when making a downstream service call. It returns a dict containing the required sub-span headers.
Each downstream call you make is handled as a new span, so call this every time you need to contact another service.
This temporarily updates w... | [
"Sets",
"up",
"a",
"new",
"span",
"to",
"contact",
"a",
"downstream",
"service",
".",
"This",
"is",
"used",
"when",
"making",
"a",
"downstream",
"service",
"call",
".",
"It",
"returns",
"a",
"dict",
"containing",
"the",
"required",
"sub",
"-",
"span",
"h... | train | https://github.com/davidcarboni/Flask-B3/blob/55092cb1070568aeecfd2c07c5ad6122e15ca345/b3/__init__.py#L153-L209 |
davidcarboni/Flask-B3 | b3/__init__.py | _generate_identifier | def _generate_identifier():
"""
Generates a new, random identifier in B3 format.
:return: A 64-bit random identifier, rendered as a hex String.
"""
bit_length = 64
byte_length = int(bit_length / 8)
identifier = os.urandom(byte_length)
return hexlify(identifier).decode('ascii') | python | def _generate_identifier():
"""
Generates a new, random identifier in B3 format.
:return: A 64-bit random identifier, rendered as a hex String.
"""
bit_length = 64
byte_length = int(bit_length / 8)
identifier = os.urandom(byte_length)
return hexlify(identifier).decode('ascii') | [
"def",
"_generate_identifier",
"(",
")",
":",
"bit_length",
"=",
"64",
"byte_length",
"=",
"int",
"(",
"bit_length",
"/",
"8",
")",
"identifier",
"=",
"os",
".",
"urandom",
"(",
"byte_length",
")",
"return",
"hexlify",
"(",
"identifier",
")",
".",
"decode"... | Generates a new, random identifier in B3 format.
:return: A 64-bit random identifier, rendered as a hex String. | [
"Generates",
"a",
"new",
"random",
"identifier",
"in",
"B3",
"format",
".",
":",
"return",
":",
"A",
"64",
"-",
"bit",
"random",
"identifier",
"rendered",
"as",
"a",
"hex",
"String",
"."
] | train | https://github.com/davidcarboni/Flask-B3/blob/55092cb1070568aeecfd2c07c5ad6122e15ca345/b3/__init__.py#L227-L235 |
davidcarboni/Flask-B3 | b3/__init__.py | _info | def _info(message):
"""Convenience function to log current span values.
"""
span = values()
_log.debug(message + ": {span} in trace {trace}. (Parent span: {parent}).".format(
span=span.get(b3_span_id),
trace=span.get(b3_trace_id),
parent=span.get(b3_parent_span_id),
)) | python | def _info(message):
"""Convenience function to log current span values.
"""
span = values()
_log.debug(message + ": {span} in trace {trace}. (Parent span: {parent}).".format(
span=span.get(b3_span_id),
trace=span.get(b3_trace_id),
parent=span.get(b3_parent_span_id),
)) | [
"def",
"_info",
"(",
"message",
")",
":",
"span",
"=",
"values",
"(",
")",
"_log",
".",
"debug",
"(",
"message",
"+",
"\": {span} in trace {trace}. (Parent span: {parent}).\"",
".",
"format",
"(",
"span",
"=",
"span",
".",
"get",
"(",
"b3_span_id",
")",
",",... | Convenience function to log current span values. | [
"Convenience",
"function",
"to",
"log",
"current",
"span",
"values",
"."
] | train | https://github.com/davidcarboni/Flask-B3/blob/55092cb1070568aeecfd2c07c5ad6122e15ca345/b3/__init__.py#L238-L246 |
proycon/flat | flat/modes/editor/views.py | pub_view | def pub_view(request, docid, configuration):
"""The initial view, does not provide the document content yet"""
if 'autodeclare' in settings.CONFIGURATIONS[configuration]:
for annotationtype, set in settings.CONFIGURATIONS['configuration']['autodeclare']:
try:
r = flat.comm.qu... | python | def pub_view(request, docid, configuration):
"""The initial view, does not provide the document content yet"""
if 'autodeclare' in settings.CONFIGURATIONS[configuration]:
for annotationtype, set in settings.CONFIGURATIONS['configuration']['autodeclare']:
try:
r = flat.comm.qu... | [
"def",
"pub_view",
"(",
"request",
",",
"docid",
",",
"configuration",
")",
":",
"if",
"'autodeclare'",
"in",
"settings",
".",
"CONFIGURATIONS",
"[",
"configuration",
"]",
":",
"for",
"annotationtype",
",",
"set",
"in",
"settings",
".",
"CONFIGURATIONS",
"[",
... | The initial view, does not provide the document content yet | [
"The",
"initial",
"view",
"does",
"not",
"provide",
"the",
"document",
"content",
"yet"
] | train | https://github.com/proycon/flat/blob/f14eea61edcae8656dadccd9a43481ff7e710ffb/flat/modes/editor/views.py#L36-L45 |
proycon/flat | flat/comm.py | checkversion | def checkversion(version):
"""Checks foliadocserve version, returns 1 if the document is newer than the library, -1 if it is older, 0 if it is equal"""
try:
for refversion, responseversion in zip([int(x) for x in REQUIREFOLIADOCSERVE.split('.')], [int(x) for x in version.split('.')]):
if res... | python | def checkversion(version):
"""Checks foliadocserve version, returns 1 if the document is newer than the library, -1 if it is older, 0 if it is equal"""
try:
for refversion, responseversion in zip([int(x) for x in REQUIREFOLIADOCSERVE.split('.')], [int(x) for x in version.split('.')]):
if res... | [
"def",
"checkversion",
"(",
"version",
")",
":",
"try",
":",
"for",
"refversion",
",",
"responseversion",
"in",
"zip",
"(",
"[",
"int",
"(",
"x",
")",
"for",
"x",
"in",
"REQUIREFOLIADOCSERVE",
".",
"split",
"(",
"'.'",
")",
"]",
",",
"[",
"int",
"(",... | Checks foliadocserve version, returns 1 if the document is newer than the library, -1 if it is older, 0 if it is equal | [
"Checks",
"foliadocserve",
"version",
"returns",
"1",
"if",
"the",
"document",
"is",
"newer",
"than",
"the",
"library",
"-",
"1",
"if",
"it",
"is",
"older",
"0",
"if",
"it",
"is",
"equal"
] | train | https://github.com/proycon/flat/blob/f14eea61edcae8656dadccd9a43481ff7e710ffb/flat/comm.py#L12-L22 |
proycon/flat | flat/modes/metadata/views.py | view | def view(request, namespace, docid):
"""The initial view, does not provide the document content yet"""
if flat.users.models.hasreadpermission(request.user.username, namespace, request):
if 'autodeclare' in settings.CONFIGURATIONS[request.session['configuration']]:
if flat.users.models.haswri... | python | def view(request, namespace, docid):
"""The initial view, does not provide the document content yet"""
if flat.users.models.hasreadpermission(request.user.username, namespace, request):
if 'autodeclare' in settings.CONFIGURATIONS[request.session['configuration']]:
if flat.users.models.haswri... | [
"def",
"view",
"(",
"request",
",",
"namespace",
",",
"docid",
")",
":",
"if",
"flat",
".",
"users",
".",
"models",
".",
"hasreadpermission",
"(",
"request",
".",
"user",
".",
"username",
",",
"namespace",
",",
"request",
")",
":",
"if",
"'autodeclare'",... | The initial view, does not provide the document content yet | [
"The",
"initial",
"view",
"does",
"not",
"provide",
"the",
"document",
"content",
"yet"
] | train | https://github.com/proycon/flat/blob/f14eea61edcae8656dadccd9a43481ff7e710ffb/flat/modes/metadata/views.py#L17-L30 |
proycon/flat | flat/views.py | initdoc | def initdoc(request, namespace, docid, mode, template, context=None, configuration=None):
"""Initialise a document (not invoked directly)"""
perspective = request.GET.get('perspective','document')
if context is None: context = {}
if 'configuration' in request.session:
configuration = request.ses... | python | def initdoc(request, namespace, docid, mode, template, context=None, configuration=None):
"""Initialise a document (not invoked directly)"""
perspective = request.GET.get('perspective','document')
if context is None: context = {}
if 'configuration' in request.session:
configuration = request.ses... | [
"def",
"initdoc",
"(",
"request",
",",
"namespace",
",",
"docid",
",",
"mode",
",",
"template",
",",
"context",
"=",
"None",
",",
"configuration",
"=",
"None",
")",
":",
"perspective",
"=",
"request",
".",
"GET",
".",
"get",
"(",
"'perspective'",
",",
... | Initialise a document (not invoked directly) | [
"Initialise",
"a",
"document",
"(",
"not",
"invoked",
"directly",
")"
] | train | https://github.com/proycon/flat/blob/f14eea61edcae8656dadccd9a43481ff7e710ffb/flat/views.py#L123-L177 |
proycon/flat | flat/views.py | query_helper | def query_helper(request,namespace, docid, configuration=None):
"""Does the actual query, called by query() or pub_query(), not directly"""
flatargs = {
'customslicesize': request.POST.get('customslicesize',settings.CONFIGURATIONS[configuration].get('customslicesize','50')), #for pagination of search re... | python | def query_helper(request,namespace, docid, configuration=None):
"""Does the actual query, called by query() or pub_query(), not directly"""
flatargs = {
'customslicesize': request.POST.get('customslicesize',settings.CONFIGURATIONS[configuration].get('customslicesize','50')), #for pagination of search re... | [
"def",
"query_helper",
"(",
"request",
",",
"namespace",
",",
"docid",
",",
"configuration",
"=",
"None",
")",
":",
"flatargs",
"=",
"{",
"'customslicesize'",
":",
"request",
".",
"POST",
".",
"get",
"(",
"'customslicesize'",
",",
"settings",
".",
"CONFIGURA... | Does the actual query, called by query() or pub_query(), not directly | [
"Does",
"the",
"actual",
"query",
"called",
"by",
"query",
"()",
"or",
"pub_query",
"()",
"not",
"directly"
] | train | https://github.com/proycon/flat/blob/f14eea61edcae8656dadccd9a43481ff7e710ffb/flat/views.py#L179-L233 |
proycon/flat | flat/modes/viewer/views.py | pub_poll | def pub_poll(request, docid):
"""The initial viewer, does not provide the document content yet"""
try:
r = flat.comm.get(request, '/poll/pub/' + docid + '/', False)
except URLError:
return HttpResponseForbidden("Unable to connect to the document server [viewer/poll]")
return HttpResponse... | python | def pub_poll(request, docid):
"""The initial viewer, does not provide the document content yet"""
try:
r = flat.comm.get(request, '/poll/pub/' + docid + '/', False)
except URLError:
return HttpResponseForbidden("Unable to connect to the document server [viewer/poll]")
return HttpResponse... | [
"def",
"pub_poll",
"(",
"request",
",",
"docid",
")",
":",
"try",
":",
"r",
"=",
"flat",
".",
"comm",
".",
"get",
"(",
"request",
",",
"'/poll/pub/'",
"+",
"docid",
"+",
"'/'",
",",
"False",
")",
"except",
"URLError",
":",
"return",
"HttpResponseForbid... | The initial viewer, does not provide the document content yet | [
"The",
"initial",
"viewer",
"does",
"not",
"provide",
"the",
"document",
"content",
"yet"
] | train | https://github.com/proycon/flat/blob/f14eea61edcae8656dadccd9a43481ff7e710ffb/flat/modes/viewer/views.py#L37-L43 |
bluedynamics/cone.ugm | src/cone/ugm/browser/autoincrement.py | AutoIncrementForm.prepare | def prepare(_next, self):
"""Hook after prepare and set 'id' disabled.
"""
_next(self)
if not self.autoincrement_support:
return
id_field = self.form['id']
del id_field.attrs['required']
id_field.attrs['disabled'] = 'disabled'
id_field.getter =... | python | def prepare(_next, self):
"""Hook after prepare and set 'id' disabled.
"""
_next(self)
if not self.autoincrement_support:
return
id_field = self.form['id']
del id_field.attrs['required']
id_field.attrs['disabled'] = 'disabled'
id_field.getter =... | [
"def",
"prepare",
"(",
"_next",
",",
"self",
")",
":",
"_next",
"(",
"self",
")",
"if",
"not",
"self",
".",
"autoincrement_support",
":",
"return",
"id_field",
"=",
"self",
".",
"form",
"[",
"'id'",
"]",
"del",
"id_field",
".",
"attrs",
"[",
"'required... | Hook after prepare and set 'id' disabled. | [
"Hook",
"after",
"prepare",
"and",
"set",
"id",
"disabled",
"."
] | train | https://github.com/bluedynamics/cone.ugm/blob/3c197075f3f6e94781289311c5637bb9c8e5597c/src/cone/ugm/browser/autoincrement.py#L52-L61 |
bluedynamics/cone.ugm | src/cone/ugm/browser/actions.py | delete_user_action | def delete_user_action(model, request):
"""Delete user from database.
"""
try:
users = model.parent.backend
uid = model.model.name
del users[uid]
users()
model.parent.invalidate()
localizer = get_localizer(request)
message = localizer.translate(_(
... | python | def delete_user_action(model, request):
"""Delete user from database.
"""
try:
users = model.parent.backend
uid = model.model.name
del users[uid]
users()
model.parent.invalidate()
localizer = get_localizer(request)
message = localizer.translate(_(
... | [
"def",
"delete_user_action",
"(",
"model",
",",
"request",
")",
":",
"try",
":",
"users",
"=",
"model",
".",
"parent",
".",
"backend",
"uid",
"=",
"model",
".",
"model",
".",
"name",
"del",
"users",
"[",
"uid",
"]",
"users",
"(",
")",
"model",
".",
... | Delete user from database. | [
"Delete",
"user",
"from",
"database",
"."
] | train | https://github.com/bluedynamics/cone.ugm/blob/3c197075f3f6e94781289311c5637bb9c8e5597c/src/cone/ugm/browser/actions.py#L67-L90 |
bluedynamics/cone.ugm | src/cone/ugm/browser/actions.py | user_add_to_group_action | def user_add_to_group_action(model, request):
"""Add user to group.
"""
group_id = request.params.get('id')
if not group_id:
group_ids = request.params.getall('id[]')
else:
group_ids = [group_id]
try:
user = model.model
validate_add_users_to_groups(model, [user.id... | python | def user_add_to_group_action(model, request):
"""Add user to group.
"""
group_id = request.params.get('id')
if not group_id:
group_ids = request.params.getall('id[]')
else:
group_ids = [group_id]
try:
user = model.model
validate_add_users_to_groups(model, [user.id... | [
"def",
"user_add_to_group_action",
"(",
"model",
",",
"request",
")",
":",
"group_id",
"=",
"request",
".",
"params",
".",
"get",
"(",
"'id'",
")",
"if",
"not",
"group_id",
":",
"group_ids",
"=",
"request",
".",
"params",
".",
"getall",
"(",
"'id[]'",
")... | Add user to group. | [
"Add",
"user",
"to",
"group",
"."
] | train | https://github.com/bluedynamics/cone.ugm/blob/3c197075f3f6e94781289311c5637bb9c8e5597c/src/cone/ugm/browser/actions.py#L99-L151 |
bluedynamics/cone.ugm | src/cone/ugm/browser/actions.py | delete_group_action | def delete_group_action(model, request):
"""Delete group from database.
"""
try:
groups = model.parent.backend
uid = model.model.name
del groups[uid]
groups()
model.parent.invalidate()
except Exception as e:
return {
'success': False,
... | python | def delete_group_action(model, request):
"""Delete group from database.
"""
try:
groups = model.parent.backend
uid = model.model.name
del groups[uid]
groups()
model.parent.invalidate()
except Exception as e:
return {
'success': False,
... | [
"def",
"delete_group_action",
"(",
"model",
",",
"request",
")",
":",
"try",
":",
"groups",
"=",
"model",
".",
"parent",
".",
"backend",
"uid",
"=",
"model",
".",
"model",
".",
"name",
"del",
"groups",
"[",
"uid",
"]",
"groups",
"(",
")",
"model",
".... | Delete group from database. | [
"Delete",
"group",
"from",
"database",
"."
] | train | https://github.com/bluedynamics/cone.ugm/blob/3c197075f3f6e94781289311c5637bb9c8e5597c/src/cone/ugm/browser/actions.py#L237-L259 |
bluedynamics/cone.ugm | src/cone/ugm/browser/actions.py | group_add_user_action | def group_add_user_action(model, request):
"""Add user to group.
"""
user_id = request.params.get('id')
if not user_id:
user_ids = request.params.getall('id[]')
else:
user_ids = [user_id]
try:
group = model.model
validate_add_users_to_groups(model, user_ids, [grou... | python | def group_add_user_action(model, request):
"""Add user to group.
"""
user_id = request.params.get('id')
if not user_id:
user_ids = request.params.getall('id[]')
else:
user_ids = [user_id]
try:
group = model.model
validate_add_users_to_groups(model, user_ids, [grou... | [
"def",
"group_add_user_action",
"(",
"model",
",",
"request",
")",
":",
"user_id",
"=",
"request",
".",
"params",
".",
"get",
"(",
"'id'",
")",
"if",
"not",
"user_id",
":",
"user_ids",
"=",
"request",
".",
"params",
".",
"getall",
"(",
"'id[]'",
")",
"... | Add user to group. | [
"Add",
"user",
"to",
"group",
"."
] | train | https://github.com/bluedynamics/cone.ugm/blob/3c197075f3f6e94781289311c5637bb9c8e5597c/src/cone/ugm/browser/actions.py#L268-L319 |
bluedynamics/cone.ugm | src/cone/ugm/browser/roles.py | PrincipalRolesForm.prepare | def prepare(_next, self):
"""Hook after prepare and set 'principal_roles' as selection to
``self.form``.
"""
_next(self)
if not self.roles_support:
return
if not self.request.has_permission('manage', self.model.parent):
# XXX: yafowil selection dis... | python | def prepare(_next, self):
"""Hook after prepare and set 'principal_roles' as selection to
``self.form``.
"""
_next(self)
if not self.roles_support:
return
if not self.request.has_permission('manage', self.model.parent):
# XXX: yafowil selection dis... | [
"def",
"prepare",
"(",
"_next",
",",
"self",
")",
":",
"_next",
"(",
"self",
")",
"if",
"not",
"self",
".",
"roles_support",
":",
"return",
"if",
"not",
"self",
".",
"request",
".",
"has_permission",
"(",
"'manage'",
",",
"self",
".",
"model",
".",
"... | Hook after prepare and set 'principal_roles' as selection to
``self.form``. | [
"Hook",
"after",
"prepare",
"and",
"set",
"principal_roles",
"as",
"selection",
"to",
"self",
".",
"form",
"."
] | train | https://github.com/bluedynamics/cone.ugm/blob/3c197075f3f6e94781289311c5637bb9c8e5597c/src/cone/ugm/browser/roles.py#L26-L52 |
bluedynamics/cone.ugm | src/cone/ugm/__init__.py | initialize_ugm | def initialize_ugm(config, global_config, local_config):
"""Initialize UGM.
"""
# custom UGM styles
cfg.merged.css.protected.append((static_resources, 'styles.css'))
# custom UGM javascript
cfg.merged.js.protected.append((static_resources, 'ugm.js'))
# UGM settings
register_config('ugm... | python | def initialize_ugm(config, global_config, local_config):
"""Initialize UGM.
"""
# custom UGM styles
cfg.merged.css.protected.append((static_resources, 'styles.css'))
# custom UGM javascript
cfg.merged.js.protected.append((static_resources, 'ugm.js'))
# UGM settings
register_config('ugm... | [
"def",
"initialize_ugm",
"(",
"config",
",",
"global_config",
",",
"local_config",
")",
":",
"# custom UGM styles",
"cfg",
".",
"merged",
".",
"css",
".",
"protected",
".",
"append",
"(",
"(",
"static_resources",
",",
"'styles.css'",
")",
")",
"# custom UGM java... | Initialize UGM. | [
"Initialize",
"UGM",
"."
] | train | https://github.com/bluedynamics/cone.ugm/blob/3c197075f3f6e94781289311c5637bb9c8e5597c/src/cone/ugm/__init__.py#L62-L103 |
bluedynamics/cone.ugm | src/cone/ugm/browser/expires.py | expiration_extractor | def expiration_extractor(widget, data):
"""Extract expiration information.
- If active flag not set, Account is disabled (value 0).
- If active flag set and value is UNSET, account never expires.
- If active flag set and datetime choosen, account expires at given
datetime.
- Timestamp in seco... | python | def expiration_extractor(widget, data):
"""Extract expiration information.
- If active flag not set, Account is disabled (value 0).
- If active flag set and value is UNSET, account never expires.
- If active flag set and datetime choosen, account expires at given
datetime.
- Timestamp in seco... | [
"def",
"expiration_extractor",
"(",
"widget",
",",
"data",
")",
":",
"active",
"=",
"int",
"(",
"data",
".",
"request",
".",
"get",
"(",
"'%s.active'",
"%",
"widget",
".",
"name",
",",
"'0'",
")",
")",
"if",
"not",
"active",
":",
"return",
"0",
"expi... | Extract expiration information.
- If active flag not set, Account is disabled (value 0).
- If active flag set and value is UNSET, account never expires.
- If active flag set and datetime choosen, account expires at given
datetime.
- Timestamp in seconds since epoch is returned. | [
"Extract",
"expiration",
"information",
"."
] | train | https://github.com/bluedynamics/cone.ugm/blob/3c197075f3f6e94781289311c5637bb9c8e5597c/src/cone/ugm/browser/expires.py#L23-L38 |
bluedynamics/cone.ugm | src/cone/ugm/browser/expires.py | ExpirationForm.prepare | def prepare(_next, self):
"""Hook after prepare and set expiration widget to
``self.form``.
"""
_next(self)
cfg = ugm_general(self.model)
if cfg.attrs['users_account_expiration'] != 'True':
return
mode = 'edit'
if not self.request.has_permissio... | python | def prepare(_next, self):
"""Hook after prepare and set expiration widget to
``self.form``.
"""
_next(self)
cfg = ugm_general(self.model)
if cfg.attrs['users_account_expiration'] != 'True':
return
mode = 'edit'
if not self.request.has_permissio... | [
"def",
"prepare",
"(",
"_next",
",",
"self",
")",
":",
"_next",
"(",
"self",
")",
"cfg",
"=",
"ugm_general",
"(",
"self",
".",
"model",
")",
"if",
"cfg",
".",
"attrs",
"[",
"'users_account_expiration'",
"]",
"!=",
"'True'",
":",
"return",
"mode",
"=",
... | Hook after prepare and set expiration widget to
``self.form``. | [
"Hook",
"after",
"prepare",
"and",
"set",
"expiration",
"widget",
"to",
"self",
".",
"form",
"."
] | train | https://github.com/bluedynamics/cone.ugm/blob/3c197075f3f6e94781289311c5637bb9c8e5597c/src/cone/ugm/browser/expires.py#L127-L158 |
bluedynamics/cone.ugm | src/cone/ugm/browser/portrait.py | portrait_image | def portrait_image(model, request):
"""XXX: needs polishing. Return configured default portrait if not set
on user.
"""
response = Response()
cfg = ugm_general(model)
response.body = model.attrs[cfg.attrs['users_portrait_attr']]
response.headers['Content-Type'] = 'image/jpeg'
response.he... | python | def portrait_image(model, request):
"""XXX: needs polishing. Return configured default portrait if not set
on user.
"""
response = Response()
cfg = ugm_general(model)
response.body = model.attrs[cfg.attrs['users_portrait_attr']]
response.headers['Content-Type'] = 'image/jpeg'
response.he... | [
"def",
"portrait_image",
"(",
"model",
",",
"request",
")",
":",
"response",
"=",
"Response",
"(",
")",
"cfg",
"=",
"ugm_general",
"(",
"model",
")",
"response",
".",
"body",
"=",
"model",
".",
"attrs",
"[",
"cfg",
".",
"attrs",
"[",
"'users_portrait_att... | XXX: needs polishing. Return configured default portrait if not set
on user. | [
"XXX",
":",
"needs",
"polishing",
".",
"Return",
"configured",
"default",
"portrait",
"if",
"not",
"set",
"on",
"user",
"."
] | train | https://github.com/bluedynamics/cone.ugm/blob/3c197075f3f6e94781289311c5637bb9c8e5597c/src/cone/ugm/browser/portrait.py#L22-L31 |
bluedynamics/cone.ugm | src/cone/ugm/browser/portrait.py | PortraitForm.prepare | def prepare(_next, self):
"""Hook after prepare and set 'portrait' as image widget to
``self.form``.
"""
_next(self)
if not self.portrait_support:
return
model = self.model
request = self.request
if request.has_permission('edit_user', model.par... | python | def prepare(_next, self):
"""Hook after prepare and set 'portrait' as image widget to
``self.form``.
"""
_next(self)
if not self.portrait_support:
return
model = self.model
request = self.request
if request.has_permission('edit_user', model.par... | [
"def",
"prepare",
"(",
"_next",
",",
"self",
")",
":",
"_next",
"(",
"self",
")",
"if",
"not",
"self",
".",
"portrait_support",
":",
"return",
"model",
"=",
"self",
".",
"model",
"request",
"=",
"self",
".",
"request",
"if",
"request",
".",
"has_permis... | Hook after prepare and set 'portrait' as image widget to
``self.form``. | [
"Hook",
"after",
"prepare",
"and",
"set",
"portrait",
"as",
"image",
"widget",
"to",
"self",
".",
"form",
"."
] | train | https://github.com/bluedynamics/cone.ugm/blob/3c197075f3f6e94781289311c5637bb9c8e5597c/src/cone/ugm/browser/portrait.py#L45-L92 |
bluedynamics/cone.ugm | src/cone/ugm/model/localmanager.py | LocalManager.local_manager_consider_for_user | def local_manager_consider_for_user(self):
"""Flag whether local manager ACL should be considered for current
authenticated user.
"""
if not self.local_management_enabled:
return False
request = get_current_request()
if authenticated_userid(request) == securit... | python | def local_manager_consider_for_user(self):
"""Flag whether local manager ACL should be considered for current
authenticated user.
"""
if not self.local_management_enabled:
return False
request = get_current_request()
if authenticated_userid(request) == securit... | [
"def",
"local_manager_consider_for_user",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"local_management_enabled",
":",
"return",
"False",
"request",
"=",
"get_current_request",
"(",
")",
"if",
"authenticated_userid",
"(",
"request",
")",
"==",
"security",
"."... | Flag whether local manager ACL should be considered for current
authenticated user. | [
"Flag",
"whether",
"local",
"manager",
"ACL",
"should",
"be",
"considered",
"for",
"current",
"authenticated",
"user",
"."
] | train | https://github.com/bluedynamics/cone.ugm/blob/3c197075f3f6e94781289311c5637bb9c8e5597c/src/cone/ugm/model/localmanager.py#L73-L85 |
bluedynamics/cone.ugm | src/cone/ugm/model/localmanager.py | LocalManager.local_manager_gid | def local_manager_gid(self):
"""Group id of local manager group of current authenticated member.
Currently a user can be assigned only to one local manager group. If
more than one local manager group is configured, an error is raised.
"""
config = self.root['settings']['ugm_loca... | python | def local_manager_gid(self):
"""Group id of local manager group of current authenticated member.
Currently a user can be assigned only to one local manager group. If
more than one local manager group is configured, an error is raised.
"""
config = self.root['settings']['ugm_loca... | [
"def",
"local_manager_gid",
"(",
"self",
")",
":",
"config",
"=",
"self",
".",
"root",
"[",
"'settings'",
"]",
"[",
"'ugm_localmanager'",
"]",
".",
"attrs",
"user",
"=",
"security",
".",
"authenticated_user",
"(",
"get_current_request",
"(",
")",
")",
"if",
... | Group id of local manager group of current authenticated member.
Currently a user can be assigned only to one local manager group. If
more than one local manager group is configured, an error is raised. | [
"Group",
"id",
"of",
"local",
"manager",
"group",
"of",
"current",
"authenticated",
"member",
"."
] | train | https://github.com/bluedynamics/cone.ugm/blob/3c197075f3f6e94781289311c5637bb9c8e5597c/src/cone/ugm/model/localmanager.py#L89-L114 |
bluedynamics/cone.ugm | src/cone/ugm/model/localmanager.py | LocalManager.local_manager_rule | def local_manager_rule(self):
"""Return rule for local manager.
"""
adm_gid = self.local_manager_gid
if not adm_gid:
return None
config = self.root['settings']['ugm_localmanager'].attrs
return config[adm_gid] | python | def local_manager_rule(self):
"""Return rule for local manager.
"""
adm_gid = self.local_manager_gid
if not adm_gid:
return None
config = self.root['settings']['ugm_localmanager'].attrs
return config[adm_gid] | [
"def",
"local_manager_rule",
"(",
"self",
")",
":",
"adm_gid",
"=",
"self",
".",
"local_manager_gid",
"if",
"not",
"adm_gid",
":",
"return",
"None",
"config",
"=",
"self",
".",
"root",
"[",
"'settings'",
"]",
"[",
"'ugm_localmanager'",
"]",
".",
"attrs",
"... | Return rule for local manager. | [
"Return",
"rule",
"for",
"local",
"manager",
"."
] | train | https://github.com/bluedynamics/cone.ugm/blob/3c197075f3f6e94781289311c5637bb9c8e5597c/src/cone/ugm/model/localmanager.py#L118-L125 |
bluedynamics/cone.ugm | src/cone/ugm/model/localmanager.py | LocalManager.local_manager_target_uids | def local_manager_target_uids(self):
"""Target uid's for local manager.
"""
groups = self.root['groups'].backend
managed_uids = set()
for gid in self.local_manager_target_gids:
group = groups.get(gid)
if group:
managed_uids.update(group.mem... | python | def local_manager_target_uids(self):
"""Target uid's for local manager.
"""
groups = self.root['groups'].backend
managed_uids = set()
for gid in self.local_manager_target_gids:
group = groups.get(gid)
if group:
managed_uids.update(group.mem... | [
"def",
"local_manager_target_uids",
"(",
"self",
")",
":",
"groups",
"=",
"self",
".",
"root",
"[",
"'groups'",
"]",
".",
"backend",
"managed_uids",
"=",
"set",
"(",
")",
"for",
"gid",
"in",
"self",
".",
"local_manager_target_gids",
":",
"group",
"=",
"gro... | Target uid's for local manager. | [
"Target",
"uid",
"s",
"for",
"local",
"manager",
"."
] | train | https://github.com/bluedynamics/cone.ugm/blob/3c197075f3f6e94781289311c5637bb9c8e5597c/src/cone/ugm/model/localmanager.py#L149-L158 |
bluedynamics/cone.ugm | src/cone/ugm/model/localmanager.py | LocalManager.local_manager_is_default | def local_manager_is_default(self, adm_gid, gid):
"""Check whether gid is default group for local manager group.
"""
config = self.root['settings']['ugm_localmanager'].attrs
rule = config[adm_gid]
if gid not in rule['target']:
raise Exception(u"group '%s' not managed ... | python | def local_manager_is_default(self, adm_gid, gid):
"""Check whether gid is default group for local manager group.
"""
config = self.root['settings']['ugm_localmanager'].attrs
rule = config[adm_gid]
if gid not in rule['target']:
raise Exception(u"group '%s' not managed ... | [
"def",
"local_manager_is_default",
"(",
"self",
",",
"adm_gid",
",",
"gid",
")",
":",
"config",
"=",
"self",
".",
"root",
"[",
"'settings'",
"]",
"[",
"'ugm_localmanager'",
"]",
".",
"attrs",
"rule",
"=",
"config",
"[",
"adm_gid",
"]",
"if",
"gid",
"not"... | Check whether gid is default group for local manager group. | [
"Check",
"whether",
"gid",
"is",
"default",
"group",
"for",
"local",
"manager",
"group",
"."
] | train | https://github.com/bluedynamics/cone.ugm/blob/3c197075f3f6e94781289311c5637bb9c8e5597c/src/cone/ugm/model/localmanager.py#L161-L168 |
bluedynamics/cone.ugm | src/cone/ugm/browser/user.py | UserForm.form_field_definitions | def form_field_definitions(self):
"""Hook optional_login extractor if necessary for form defaults.
"""
schema = copy.deepcopy(form_field_definitions.user)
uid, login = self._get_auth_attrs()
if uid != login:
field = schema.get(login, schema['default'])
if ... | python | def form_field_definitions(self):
"""Hook optional_login extractor if necessary for form defaults.
"""
schema = copy.deepcopy(form_field_definitions.user)
uid, login = self._get_auth_attrs()
if uid != login:
field = schema.get(login, schema['default'])
if ... | [
"def",
"form_field_definitions",
"(",
"self",
")",
":",
"schema",
"=",
"copy",
".",
"deepcopy",
"(",
"form_field_definitions",
".",
"user",
")",
"uid",
",",
"login",
"=",
"self",
".",
"_get_auth_attrs",
"(",
")",
"if",
"uid",
"!=",
"login",
":",
"field",
... | Hook optional_login extractor if necessary for form defaults. | [
"Hook",
"optional_login",
"extractor",
"if",
"necessary",
"for",
"form",
"defaults",
"."
] | train | https://github.com/bluedynamics/cone.ugm/blob/3c197075f3f6e94781289311c5637bb9c8e5597c/src/cone/ugm/browser/user.py#L183-L198 |
bluedynamics/cone.ugm | src/cone/ugm/browser/remote.py | remote_add_user | def remote_add_user(model, request):
"""Add user via remote service.
Returns a JSON response containing success state and a message indicating
what happened::
{
success: true, // respective false
message: 'message'
}
Expected request parameters:
id
New user id.
... | python | def remote_add_user(model, request):
"""Add user via remote service.
Returns a JSON response containing success state and a message indicating
what happened::
{
success: true, // respective false
message: 'message'
}
Expected request parameters:
id
New user id.
... | [
"def",
"remote_add_user",
"(",
"model",
",",
"request",
")",
":",
"params",
"=",
"request",
".",
"params",
"uid",
"=",
"params",
".",
"get",
"(",
"'id'",
")",
"if",
"not",
"uid",
":",
"return",
"{",
"'success'",
":",
"False",
",",
"'message'",
":",
"... | Add user via remote service.
Returns a JSON response containing success state and a message indicating
what happened::
{
success: true, // respective false
message: 'message'
}
Expected request parameters:
id
New user id.
password
User password to be set ... | [
"Add",
"user",
"via",
"remote",
"service",
"."
] | train | https://github.com/bluedynamics/cone.ugm/blob/3c197075f3f6e94781289311c5637bb9c8e5597c/src/cone/ugm/browser/remote.py#L12-L124 |
bluedynamics/cone.ugm | src/cone/ugm/browser/remote.py | remote_delete_user | def remote_delete_user(model, request):
"""Remove user via remote service.
Returns a JSON response containing success state and a message indicating
what happened::
{
success: true, // respective false
message: 'message'
}
Expected request parameters:
id
Id of use... | python | def remote_delete_user(model, request):
"""Remove user via remote service.
Returns a JSON response containing success state and a message indicating
what happened::
{
success: true, // respective false
message: 'message'
}
Expected request parameters:
id
Id of use... | [
"def",
"remote_delete_user",
"(",
"model",
",",
"request",
")",
":",
"params",
"=",
"request",
".",
"params",
"uid",
"=",
"params",
".",
"get",
"(",
"'id'",
")",
"if",
"not",
"uid",
":",
"return",
"{",
"'success'",
":",
"False",
",",
"'message'",
":",
... | Remove user via remote service.
Returns a JSON response containing success state and a message indicating
what happened::
{
success: true, // respective false
message: 'message'
}
Expected request parameters:
id
Id of user to delete. | [
"Remove",
"user",
"via",
"remote",
"service",
"."
] | train | https://github.com/bluedynamics/cone.ugm/blob/3c197075f3f6e94781289311c5637bb9c8e5597c/src/cone/ugm/browser/remote.py#L133-L180 |
ninuxorg/nodeshot | nodeshot/interop/sync/admin.py | LayerExternalInline.get_formset | def get_formset(self, request, obj=None, **kwargs):
"""
Load Synchronizer schema to display specific fields in admin
"""
if obj is not None:
try:
# this is enough to load the new schema
obj.external
except LayerExternal.DoesNotExist... | python | def get_formset(self, request, obj=None, **kwargs):
"""
Load Synchronizer schema to display specific fields in admin
"""
if obj is not None:
try:
# this is enough to load the new schema
obj.external
except LayerExternal.DoesNotExist... | [
"def",
"get_formset",
"(",
"self",
",",
"request",
",",
"obj",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"obj",
"is",
"not",
"None",
":",
"try",
":",
"# this is enough to load the new schema",
"obj",
".",
"external",
"except",
"LayerExternal",
... | Load Synchronizer schema to display specific fields in admin | [
"Load",
"Synchronizer",
"schema",
"to",
"display",
"specific",
"fields",
"in",
"admin"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/interop/sync/admin.py#L19-L29 |
ninuxorg/nodeshot | nodeshot/core/websockets/server.py | public_broadcaster | def public_broadcaster():
"""
Thread which runs in parallel and constantly checks for new messages
in the public pipe and broadcasts them publicly to all connected clients.
"""
while __websocket_server_running__:
pipein = open(PUBLIC_PIPE, 'r')
line = pipein.readline().replace('\n', ... | python | def public_broadcaster():
"""
Thread which runs in parallel and constantly checks for new messages
in the public pipe and broadcasts them publicly to all connected clients.
"""
while __websocket_server_running__:
pipein = open(PUBLIC_PIPE, 'r')
line = pipein.readline().replace('\n', ... | [
"def",
"public_broadcaster",
"(",
")",
":",
"while",
"__websocket_server_running__",
":",
"pipein",
"=",
"open",
"(",
"PUBLIC_PIPE",
",",
"'r'",
")",
"line",
"=",
"pipein",
".",
"readline",
"(",
")",
".",
"replace",
"(",
"'\\n'",
",",
"''",
")",
".",
"re... | Thread which runs in parallel and constantly checks for new messages
in the public pipe and broadcasts them publicly to all connected clients. | [
"Thread",
"which",
"runs",
"in",
"parallel",
"and",
"constantly",
"checks",
"for",
"new",
"messages",
"in",
"the",
"public",
"pipe",
"and",
"broadcasts",
"them",
"publicly",
"to",
"all",
"connected",
"clients",
"."
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/core/websockets/server.py#L17-L37 |
ninuxorg/nodeshot | nodeshot/core/websockets/server.py | private_messenger | def private_messenger():
"""
Thread which runs in parallel and constantly checks for new messages
in the private pipe and sends them to the specific client.
If client is not connected the message is discarded.
"""
while __websocket_server_running__:
pipein = open(PRIVATE_PIPE, 'r')
... | python | def private_messenger():
"""
Thread which runs in parallel and constantly checks for new messages
in the private pipe and sends them to the specific client.
If client is not connected the message is discarded.
"""
while __websocket_server_running__:
pipein = open(PRIVATE_PIPE, 'r')
... | [
"def",
"private_messenger",
"(",
")",
":",
"while",
"__websocket_server_running__",
":",
"pipein",
"=",
"open",
"(",
"PRIVATE_PIPE",
",",
"'r'",
")",
"line",
"=",
"pipein",
".",
"readline",
"(",
")",
".",
"replace",
"(",
"'\\n'",
",",
"''",
")",
".",
"re... | Thread which runs in parallel and constantly checks for new messages
in the private pipe and sends them to the specific client.
If client is not connected the message is discarded. | [
"Thread",
"which",
"runs",
"in",
"parallel",
"and",
"constantly",
"checks",
"for",
"new",
"messages",
"in",
"the",
"private",
"pipe",
"and",
"sends",
"them",
"to",
"the",
"specific",
"client",
".",
"If",
"client",
"is",
"not",
"connected",
"the",
"message",
... | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/core/websockets/server.py#L43-L66 |
ninuxorg/nodeshot | nodeshot/core/metrics/models.py | Metric.write | def write(self, values, timestamp=None, database=None, async=True):
""" write metric point """
func = write_async if async else write
return func(name=self.name,
values=values,
tags=self.tags,
timestamp=timestamp,
da... | python | def write(self, values, timestamp=None, database=None, async=True):
""" write metric point """
func = write_async if async else write
return func(name=self.name,
values=values,
tags=self.tags,
timestamp=timestamp,
da... | [
"def",
"write",
"(",
"self",
",",
"values",
",",
"timestamp",
"=",
"None",
",",
"database",
"=",
"None",
",",
"async",
"=",
"True",
")",
":",
"func",
"=",
"write_async",
"if",
"async",
"else",
"write",
"return",
"func",
"(",
"name",
"=",
"self",
".",... | write metric point | [
"write",
"metric",
"point"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/core/metrics/models.py#L41-L48 |
ninuxorg/nodeshot | nodeshot/networking/hardware/models/antenna.py | Antenna.save | def save(self, *args, **kwargs):
"""
1. set polarization according to AntennaModel (self.model.polarization) when creating a new antenna
2. inherit latitude and longitude from node
"""
if not self.pk and self.model.polarization:
self.polarization = self.model.polariza... | python | def save(self, *args, **kwargs):
"""
1. set polarization according to AntennaModel (self.model.polarization) when creating a new antenna
2. inherit latitude and longitude from node
"""
if not self.pk and self.model.polarization:
self.polarization = self.model.polariza... | [
"def",
"save",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"self",
".",
"pk",
"and",
"self",
".",
"model",
".",
"polarization",
":",
"self",
".",
"polarization",
"=",
"self",
".",
"model",
".",
"polarization",
"su... | 1. set polarization according to AntennaModel (self.model.polarization) when creating a new antenna
2. inherit latitude and longitude from node | [
"1",
".",
"set",
"polarization",
"according",
"to",
"AntennaModel",
"(",
"self",
".",
"model",
".",
"polarization",
")",
"when",
"creating",
"a",
"new",
"antenna",
"2",
".",
"inherit",
"latitude",
"and",
"longitude",
"from",
"node"
] | train | https://github.com/ninuxorg/nodeshot/blob/2466f0a55f522b2696026f196436ce7ba3f1e5c6/nodeshot/networking/hardware/models/antenna.py#L32-L39 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.