repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
ghukill/pyfc4 | pyfc4/models.py | Repository.start_txn | def start_txn(self, txn_name=None):
'''
Request new transaction from repository, init new Transaction,
store in self.txns
Args:
txn_name (str): human name for transaction
Return:
(Transaction): returns intance of newly created transaction
'''
# if no name provided, create one
if not txn_name:
... | python | def start_txn(self, txn_name=None):
'''
Request new transaction from repository, init new Transaction,
store in self.txns
Args:
txn_name (str): human name for transaction
Return:
(Transaction): returns intance of newly created transaction
'''
# if no name provided, create one
if not txn_name:
... | [
"def",
"start_txn",
"(",
"self",
",",
"txn_name",
"=",
"None",
")",
":",
"if",
"not",
"txn_name",
":",
"txn_name",
"=",
"uuid",
".",
"uuid4",
"(",
")",
".",
"hex",
"txn_response",
"=",
"self",
".",
"api",
".",
"http_request",
"(",
"'POST'",
",",
"'%s... | Request new transaction from repository, init new Transaction,
store in self.txns
Args:
txn_name (str): human name for transaction
Return:
(Transaction): returns intance of newly created transaction | [
"Request",
"new",
"transaction",
"from",
"repository",
"init",
"new",
"Transaction",
"store",
"in",
"self",
".",
"txns"
] | 59011df592f08978c4a901a908862d112a5dcf02 | https://github.com/ghukill/pyfc4/blob/59011df592f08978c4a901a908862d112a5dcf02/pyfc4/models.py#L229-L266 | train |
ghukill/pyfc4 | pyfc4/models.py | Repository.get_txn | def get_txn(self, txn_name, txn_uri):
'''
Retrieves known transaction and adds to self.txns.
TODO:
Perhaps this should send a keep-alive request as well? Obviously still needed, and would reset timer.
Args:
txn_prefix (str, rdflib.term.URIRef): uri of the transaction. e.g. http://localhost:8080/rest/t... | python | def get_txn(self, txn_name, txn_uri):
'''
Retrieves known transaction and adds to self.txns.
TODO:
Perhaps this should send a keep-alive request as well? Obviously still needed, and would reset timer.
Args:
txn_prefix (str, rdflib.term.URIRef): uri of the transaction. e.g. http://localhost:8080/rest/t... | [
"def",
"get_txn",
"(",
"self",
",",
"txn_name",
",",
"txn_uri",
")",
":",
"txn_uri",
"=",
"self",
".",
"parse_uri",
"(",
"txn_uri",
")",
"txn_response",
"=",
"self",
".",
"api",
".",
"http_request",
"(",
"'GET'",
",",
"txn_uri",
",",
"data",
"=",
"None... | Retrieves known transaction and adds to self.txns.
TODO:
Perhaps this should send a keep-alive request as well? Obviously still needed, and would reset timer.
Args:
txn_prefix (str, rdflib.term.URIRef): uri of the transaction. e.g. http://localhost:8080/rest/txn:123456789
txn_name (str): local, human na... | [
"Retrieves",
"known",
"transaction",
"and",
"adds",
"to",
"self",
".",
"txns",
"."
] | 59011df592f08978c4a901a908862d112a5dcf02 | https://github.com/ghukill/pyfc4/blob/59011df592f08978c4a901a908862d112a5dcf02/pyfc4/models.py#L269-L314 | train |
ghukill/pyfc4 | pyfc4/models.py | Transaction.keep_alive | def keep_alive(self):
'''
Keep current transaction alive, updates self.expires
Args:
None
Return:
None: sets new self.expires
'''
# keep transaction alive
txn_response = self.api.http_request('POST','%sfcr:tx' % self.root, data=None, headers=None)
# if 204, transaction kept alive
if txn_res... | python | def keep_alive(self):
'''
Keep current transaction alive, updates self.expires
Args:
None
Return:
None: sets new self.expires
'''
# keep transaction alive
txn_response = self.api.http_request('POST','%sfcr:tx' % self.root, data=None, headers=None)
# if 204, transaction kept alive
if txn_res... | [
"def",
"keep_alive",
"(",
"self",
")",
":",
"txn_response",
"=",
"self",
".",
"api",
".",
"http_request",
"(",
"'POST'",
",",
"'%sfcr:tx'",
"%",
"self",
".",
"root",
",",
"data",
"=",
"None",
",",
"headers",
"=",
"None",
")",
"if",
"txn_response",
".",... | Keep current transaction alive, updates self.expires
Args:
None
Return:
None: sets new self.expires | [
"Keep",
"current",
"transaction",
"alive",
"updates",
"self",
".",
"expires"
] | 59011df592f08978c4a901a908862d112a5dcf02 | https://github.com/ghukill/pyfc4/blob/59011df592f08978c4a901a908862d112a5dcf02/pyfc4/models.py#L357-L387 | train |
ghukill/pyfc4 | pyfc4/models.py | Transaction._close | def _close(self, close_type):
'''
Ends transaction by committing, or rolling back, all changes during transaction.
Args:
close_type (str): expects "commit" or "rollback"
Return:
(bool)
'''
# commit transaction
txn_response = self.api.http_request('POST','%sfcr:tx/fcr:%s' % (self.root, close_type... | python | def _close(self, close_type):
'''
Ends transaction by committing, or rolling back, all changes during transaction.
Args:
close_type (str): expects "commit" or "rollback"
Return:
(bool)
'''
# commit transaction
txn_response = self.api.http_request('POST','%sfcr:tx/fcr:%s' % (self.root, close_type... | [
"def",
"_close",
"(",
"self",
",",
"close_type",
")",
":",
"txn_response",
"=",
"self",
".",
"api",
".",
"http_request",
"(",
"'POST'",
",",
"'%sfcr:tx/fcr:%s'",
"%",
"(",
"self",
".",
"root",
",",
"close_type",
")",
",",
"data",
"=",
"None",
",",
"hea... | Ends transaction by committing, or rolling back, all changes during transaction.
Args:
close_type (str): expects "commit" or "rollback"
Return:
(bool) | [
"Ends",
"transaction",
"by",
"committing",
"or",
"rolling",
"back",
"all",
"changes",
"during",
"transaction",
"."
] | 59011df592f08978c4a901a908862d112a5dcf02 | https://github.com/ghukill/pyfc4/blob/59011df592f08978c4a901a908862d112a5dcf02/pyfc4/models.py#L390-L421 | train |
ghukill/pyfc4 | pyfc4/models.py | API.http_request | def http_request(self,
verb,
uri,
data=None,
headers=None,
files=None,
response_format=None,
is_rdf = True,
stream = False
):
'''
Primary route for all HTTP requests to repository. Ability to set most parameters for requests library,
with some additional convenience parameters as well.... | python | def http_request(self,
verb,
uri,
data=None,
headers=None,
files=None,
response_format=None,
is_rdf = True,
stream = False
):
'''
Primary route for all HTTP requests to repository. Ability to set most parameters for requests library,
with some additional convenience parameters as well.... | [
"def",
"http_request",
"(",
"self",
",",
"verb",
",",
"uri",
",",
"data",
"=",
"None",
",",
"headers",
"=",
"None",
",",
"files",
"=",
"None",
",",
"response_format",
"=",
"None",
",",
"is_rdf",
"=",
"True",
",",
"stream",
"=",
"False",
")",
":",
"... | Primary route for all HTTP requests to repository. Ability to set most parameters for requests library,
with some additional convenience parameters as well.
Args:
verb (str): HTTP verb to use for request, e.g. PUT, POST, GET, HEAD, PATCH, etc.
uri (rdflib.term.URIRef,str): input URI
data (str,file): payl... | [
"Primary",
"route",
"for",
"all",
"HTTP",
"requests",
"to",
"repository",
".",
"Ability",
"to",
"set",
"most",
"parameters",
"for",
"requests",
"library",
"with",
"some",
"additional",
"convenience",
"parameters",
"as",
"well",
"."
] | 59011df592f08978c4a901a908862d112a5dcf02 | https://github.com/ghukill/pyfc4/blob/59011df592f08978c4a901a908862d112a5dcf02/pyfc4/models.py#L471-L537 | train |
ghukill/pyfc4 | pyfc4/models.py | API.parse_rdf_payload | def parse_rdf_payload(self, data, headers):
'''
small function to parse RDF payloads from various repository endpoints
Args:
data (response.data): data from requests response
headers (response.headers): headers from requests response
Returns:
(rdflib.Graph): parsed graph
'''
# handle edge case ... | python | def parse_rdf_payload(self, data, headers):
'''
small function to parse RDF payloads from various repository endpoints
Args:
data (response.data): data from requests response
headers (response.headers): headers from requests response
Returns:
(rdflib.Graph): parsed graph
'''
# handle edge case ... | [
"def",
"parse_rdf_payload",
"(",
"self",
",",
"data",
",",
"headers",
")",
":",
"if",
"headers",
"[",
"'Content-Type'",
"]",
".",
"startswith",
"(",
"'text/plain'",
")",
":",
"logger",
".",
"debug",
"(",
"'text/plain Content-Type detected, using application/n-triple... | small function to parse RDF payloads from various repository endpoints
Args:
data (response.data): data from requests response
headers (response.headers): headers from requests response
Returns:
(rdflib.Graph): parsed graph | [
"small",
"function",
"to",
"parse",
"RDF",
"payloads",
"from",
"various",
"repository",
"endpoints"
] | 59011df592f08978c4a901a908862d112a5dcf02 | https://github.com/ghukill/pyfc4/blob/59011df592f08978c4a901a908862d112a5dcf02/pyfc4/models.py#L585-L615 | train |
ghukill/pyfc4 | pyfc4/models.py | SparqlUpdate._derive_namespaces | def _derive_namespaces(self):
'''
Small method to loop through three graphs in self.diffs, identify unique namespace URIs.
Then, loop through provided dictionary of prefixes and pin one to another.
Args:
None: uses self.prefixes and self.diffs
Returns:
None: sets self.update_namespaces and self.updat... | python | def _derive_namespaces(self):
'''
Small method to loop through three graphs in self.diffs, identify unique namespace URIs.
Then, loop through provided dictionary of prefixes and pin one to another.
Args:
None: uses self.prefixes and self.diffs
Returns:
None: sets self.update_namespaces and self.updat... | [
"def",
"_derive_namespaces",
"(",
"self",
")",
":",
"for",
"graph",
"in",
"[",
"self",
".",
"diffs",
".",
"overlap",
",",
"self",
".",
"diffs",
".",
"removed",
",",
"self",
".",
"diffs",
".",
"added",
"]",
":",
"for",
"s",
",",
"p",
",",
"o",
"in... | Small method to loop through three graphs in self.diffs, identify unique namespace URIs.
Then, loop through provided dictionary of prefixes and pin one to another.
Args:
None: uses self.prefixes and self.diffs
Returns:
None: sets self.update_namespaces and self.update_prefixes | [
"Small",
"method",
"to",
"loop",
"through",
"three",
"graphs",
"in",
"self",
".",
"diffs",
"identify",
"unique",
"namespace",
"URIs",
".",
"Then",
"loop",
"through",
"provided",
"dictionary",
"of",
"prefixes",
"and",
"pin",
"one",
"to",
"another",
"."
] | 59011df592f08978c4a901a908862d112a5dcf02 | https://github.com/ghukill/pyfc4/blob/59011df592f08978c4a901a908862d112a5dcf02/pyfc4/models.py#L641-L675 | train |
ghukill/pyfc4 | pyfc4/models.py | Resource.check_exists | def check_exists(self):
'''
Check if resource exists, update self.exists, returns
Returns:
None: sets self.exists
'''
response = self.repo.api.http_request('HEAD', self.uri)
self.status_code = response.status_code
# resource exists
if self.status_code == 200:
self.exists = True
# resource no ... | python | def check_exists(self):
'''
Check if resource exists, update self.exists, returns
Returns:
None: sets self.exists
'''
response = self.repo.api.http_request('HEAD', self.uri)
self.status_code = response.status_code
# resource exists
if self.status_code == 200:
self.exists = True
# resource no ... | [
"def",
"check_exists",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"repo",
".",
"api",
".",
"http_request",
"(",
"'HEAD'",
",",
"self",
".",
"uri",
")",
"self",
".",
"status_code",
"=",
"response",
".",
"status_code",
"if",
"self",
".",
"statu... | Check if resource exists, update self.exists, returns
Returns:
None: sets self.exists | [
"Check",
"if",
"resource",
"exists",
"update",
"self",
".",
"exists",
"returns"
] | 59011df592f08978c4a901a908862d112a5dcf02 | https://github.com/ghukill/pyfc4/blob/59011df592f08978c4a901a908862d112a5dcf02/pyfc4/models.py#L801-L821 | train |
ghukill/pyfc4 | pyfc4/models.py | Resource.create | def create(self, specify_uri=False, ignore_tombstone=False, serialization_format=None, stream=False, auto_refresh=None):
'''
Primary method to create resources.
Args:
specify_uri (bool): If True, uses PUT verb and sets the URI during creation. If False, uses POST and gets repository minted URI
ignore_tom... | python | def create(self, specify_uri=False, ignore_tombstone=False, serialization_format=None, stream=False, auto_refresh=None):
'''
Primary method to create resources.
Args:
specify_uri (bool): If True, uses PUT verb and sets the URI during creation. If False, uses POST and gets repository minted URI
ignore_tom... | [
"def",
"create",
"(",
"self",
",",
"specify_uri",
"=",
"False",
",",
"ignore_tombstone",
"=",
"False",
",",
"serialization_format",
"=",
"None",
",",
"stream",
"=",
"False",
",",
"auto_refresh",
"=",
"None",
")",
":",
"if",
"self",
".",
"exists",
":",
"r... | Primary method to create resources.
Args:
specify_uri (bool): If True, uses PUT verb and sets the URI during creation. If False, uses POST and gets repository minted URI
ignore_tombstone (bool): If True, will attempt creation, if tombstone exists (409), will delete tombstone and retry
serialization_format(... | [
"Primary",
"method",
"to",
"create",
"resources",
"."
] | 59011df592f08978c4a901a908862d112a5dcf02 | https://github.com/ghukill/pyfc4/blob/59011df592f08978c4a901a908862d112a5dcf02/pyfc4/models.py#L824-L869 | train |
ghukill/pyfc4 | pyfc4/models.py | Resource.options | def options(self):
'''
Small method to return headers of an OPTIONS request to self.uri
Args:
None
Return:
(dict) response headers from OPTIONS request
'''
# http request
response = self.repo.api.http_request('OPTIONS', self.uri)
return response.headers | python | def options(self):
'''
Small method to return headers of an OPTIONS request to self.uri
Args:
None
Return:
(dict) response headers from OPTIONS request
'''
# http request
response = self.repo.api.http_request('OPTIONS', self.uri)
return response.headers | [
"def",
"options",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"repo",
".",
"api",
".",
"http_request",
"(",
"'OPTIONS'",
",",
"self",
".",
"uri",
")",
"return",
"response",
".",
"headers"
] | Small method to return headers of an OPTIONS request to self.uri
Args:
None
Return:
(dict) response headers from OPTIONS request | [
"Small",
"method",
"to",
"return",
"headers",
"of",
"an",
"OPTIONS",
"request",
"to",
"self",
".",
"uri"
] | 59011df592f08978c4a901a908862d112a5dcf02 | https://github.com/ghukill/pyfc4/blob/59011df592f08978c4a901a908862d112a5dcf02/pyfc4/models.py#L928-L942 | train |
ghukill/pyfc4 | pyfc4/models.py | Resource.copy | def copy(self, destination):
'''
Method to copy resource to another location
Args:
destination (rdflib.term.URIRef, str): URI location to move resource
Returns:
(Resource) new, moved instance of resource
'''
# set move headers
destination_uri = self.repo.parse_uri(destination)
# http request
... | python | def copy(self, destination):
'''
Method to copy resource to another location
Args:
destination (rdflib.term.URIRef, str): URI location to move resource
Returns:
(Resource) new, moved instance of resource
'''
# set move headers
destination_uri = self.repo.parse_uri(destination)
# http request
... | [
"def",
"copy",
"(",
"self",
",",
"destination",
")",
":",
"destination_uri",
"=",
"self",
".",
"repo",
".",
"parse_uri",
"(",
"destination",
")",
"response",
"=",
"self",
".",
"repo",
".",
"api",
".",
"http_request",
"(",
"'COPY'",
",",
"self",
".",
"u... | Method to copy resource to another location
Args:
destination (rdflib.term.URIRef, str): URI location to move resource
Returns:
(Resource) new, moved instance of resource | [
"Method",
"to",
"copy",
"resource",
"to",
"another",
"location"
] | 59011df592f08978c4a901a908862d112a5dcf02 | https://github.com/ghukill/pyfc4/blob/59011df592f08978c4a901a908862d112a5dcf02/pyfc4/models.py#L986-L1008 | train |
ghukill/pyfc4 | pyfc4/models.py | Resource.delete | def delete(self, remove_tombstone=True):
'''
Method to delete resources.
Args:
remove_tombstone (bool): If True, will remove tombstone at uri/fcr:tombstone when removing resource.
Returns:
(bool)
'''
response = self.repo.api.http_request('DELETE', self.uri)
# update exists
if response.status_... | python | def delete(self, remove_tombstone=True):
'''
Method to delete resources.
Args:
remove_tombstone (bool): If True, will remove tombstone at uri/fcr:tombstone when removing resource.
Returns:
(bool)
'''
response = self.repo.api.http_request('DELETE', self.uri)
# update exists
if response.status_... | [
"def",
"delete",
"(",
"self",
",",
"remove_tombstone",
"=",
"True",
")",
":",
"response",
"=",
"self",
".",
"repo",
".",
"api",
".",
"http_request",
"(",
"'DELETE'",
",",
"self",
".",
"uri",
")",
"if",
"response",
".",
"status_code",
"==",
"204",
":",
... | Method to delete resources.
Args:
remove_tombstone (bool): If True, will remove tombstone at uri/fcr:tombstone when removing resource.
Returns:
(bool) | [
"Method",
"to",
"delete",
"resources",
"."
] | 59011df592f08978c4a901a908862d112a5dcf02 | https://github.com/ghukill/pyfc4/blob/59011df592f08978c4a901a908862d112a5dcf02/pyfc4/models.py#L1011-L1033 | train |
ghukill/pyfc4 | pyfc4/models.py | Resource.refresh | def refresh(self, refresh_binary=True):
'''
Performs GET request and refreshes RDF information for resource.
Args:
None
Returns:
None
'''
updated_self = self.repo.get_resource(self.uri)
# if resource type of updated_self != self, raise exception
if not isinstance(self, type(updated_self)):
... | python | def refresh(self, refresh_binary=True):
'''
Performs GET request and refreshes RDF information for resource.
Args:
None
Returns:
None
'''
updated_self = self.repo.get_resource(self.uri)
# if resource type of updated_self != self, raise exception
if not isinstance(self, type(updated_self)):
... | [
"def",
"refresh",
"(",
"self",
",",
"refresh_binary",
"=",
"True",
")",
":",
"updated_self",
"=",
"self",
".",
"repo",
".",
"get_resource",
"(",
"self",
".",
"uri",
")",
"if",
"not",
"isinstance",
"(",
"self",
",",
"type",
"(",
"updated_self",
")",
")"... | Performs GET request and refreshes RDF information for resource.
Args:
None
Returns:
None | [
"Performs",
"GET",
"request",
"and",
"refreshes",
"RDF",
"information",
"for",
"resource",
"."
] | 59011df592f08978c4a901a908862d112a5dcf02 | https://github.com/ghukill/pyfc4/blob/59011df592f08978c4a901a908862d112a5dcf02/pyfc4/models.py#L1036-L1082 | train |
ghukill/pyfc4 | pyfc4/models.py | Resource._build_rdf | def _build_rdf(self, data=None):
'''
Parse incoming rdf as self.rdf.orig_graph, create copy at self.rdf.graph
Args:
data (): payload from GET request, expected RDF content in various serialization formats
Returns:
None
'''
# recreate rdf data
self.rdf = SimpleNamespace()
self.rdf.data = data
... | python | def _build_rdf(self, data=None):
'''
Parse incoming rdf as self.rdf.orig_graph, create copy at self.rdf.graph
Args:
data (): payload from GET request, expected RDF content in various serialization formats
Returns:
None
'''
# recreate rdf data
self.rdf = SimpleNamespace()
self.rdf.data = data
... | [
"def",
"_build_rdf",
"(",
"self",
",",
"data",
"=",
"None",
")",
":",
"self",
".",
"rdf",
"=",
"SimpleNamespace",
"(",
")",
"self",
".",
"rdf",
".",
"data",
"=",
"data",
"self",
".",
"rdf",
".",
"prefixes",
"=",
"SimpleNamespace",
"(",
")",
"self",
... | Parse incoming rdf as self.rdf.orig_graph, create copy at self.rdf.graph
Args:
data (): payload from GET request, expected RDF content in various serialization formats
Returns:
None | [
"Parse",
"incoming",
"rdf",
"as",
"self",
".",
"rdf",
".",
"orig_graph",
"create",
"copy",
"at",
"self",
".",
"rdf",
".",
"graph"
] | 59011df592f08978c4a901a908862d112a5dcf02 | https://github.com/ghukill/pyfc4/blob/59011df592f08978c4a901a908862d112a5dcf02/pyfc4/models.py#L1085-L1106 | train |
ghukill/pyfc4 | pyfc4/models.py | Resource._parse_graph | def _parse_graph(self):
'''
use Content-Type from headers to determine parsing method
Args:
None
Return:
None: sets self.rdf by parsing data from GET request, or setting blank graph of resource does not yet exist
'''
# if resource exists, parse self.rdf.data
if self.exists:
self.rdf.graph = s... | python | def _parse_graph(self):
'''
use Content-Type from headers to determine parsing method
Args:
None
Return:
None: sets self.rdf by parsing data from GET request, or setting blank graph of resource does not yet exist
'''
# if resource exists, parse self.rdf.data
if self.exists:
self.rdf.graph = s... | [
"def",
"_parse_graph",
"(",
"self",
")",
":",
"if",
"self",
".",
"exists",
":",
"self",
".",
"rdf",
".",
"graph",
"=",
"self",
".",
"repo",
".",
"api",
".",
"parse_rdf_payload",
"(",
"self",
".",
"rdf",
".",
"data",
",",
"self",
".",
"headers",
")"... | use Content-Type from headers to determine parsing method
Args:
None
Return:
None: sets self.rdf by parsing data from GET request, or setting blank graph of resource does not yet exist | [
"use",
"Content",
"-",
"Type",
"from",
"headers",
"to",
"determine",
"parsing",
"method"
] | 59011df592f08978c4a901a908862d112a5dcf02 | https://github.com/ghukill/pyfc4/blob/59011df592f08978c4a901a908862d112a5dcf02/pyfc4/models.py#L1109-L1143 | train |
ghukill/pyfc4 | pyfc4/models.py | Resource.parse_object_like_triples | def parse_object_like_triples(self):
'''
method to parse triples from self.rdf.graph for object-like
access
Args:
None
Returns:
None: sets self.rdf.triples
'''
# parse triples as object-like attributes in self.rdf.triples
self.rdf.triples = SimpleNamespace() # prepare triples
for s,p,o in se... | python | def parse_object_like_triples(self):
'''
method to parse triples from self.rdf.graph for object-like
access
Args:
None
Returns:
None: sets self.rdf.triples
'''
# parse triples as object-like attributes in self.rdf.triples
self.rdf.triples = SimpleNamespace() # prepare triples
for s,p,o in se... | [
"def",
"parse_object_like_triples",
"(",
"self",
")",
":",
"self",
".",
"rdf",
".",
"triples",
"=",
"SimpleNamespace",
"(",
")",
"for",
"s",
",",
"p",
",",
"o",
"in",
"self",
".",
"rdf",
".",
"graph",
":",
"ns_prefix",
",",
"ns_uri",
",",
"predicate",
... | method to parse triples from self.rdf.graph for object-like
access
Args:
None
Returns:
None: sets self.rdf.triples | [
"method",
"to",
"parse",
"triples",
"from",
"self",
".",
"rdf",
".",
"graph",
"for",
"object",
"-",
"like",
"access"
] | 59011df592f08978c4a901a908862d112a5dcf02 | https://github.com/ghukill/pyfc4/blob/59011df592f08978c4a901a908862d112a5dcf02/pyfc4/models.py#L1146-L1175 | train |
ghukill/pyfc4 | pyfc4/models.py | Resource._empty_resource_attributes | def _empty_resource_attributes(self):
'''
small method to empty values if resource is removed or absent
Args:
None
Return:
None: empties selected resource attributes
'''
self.status_code = 404
self.headers = {}
self.exists = False
# build RDF
self.rdf = self._build_rdf()
# if NonRDF, e... | python | def _empty_resource_attributes(self):
'''
small method to empty values if resource is removed or absent
Args:
None
Return:
None: empties selected resource attributes
'''
self.status_code = 404
self.headers = {}
self.exists = False
# build RDF
self.rdf = self._build_rdf()
# if NonRDF, e... | [
"def",
"_empty_resource_attributes",
"(",
"self",
")",
":",
"self",
".",
"status_code",
"=",
"404",
"self",
".",
"headers",
"=",
"{",
"}",
"self",
".",
"exists",
"=",
"False",
"self",
".",
"rdf",
"=",
"self",
".",
"_build_rdf",
"(",
")",
"if",
"type",
... | small method to empty values if resource is removed or absent
Args:
None
Return:
None: empties selected resource attributes | [
"small",
"method",
"to",
"empty",
"values",
"if",
"resource",
"is",
"removed",
"or",
"absent"
] | 59011df592f08978c4a901a908862d112a5dcf02 | https://github.com/ghukill/pyfc4/blob/59011df592f08978c4a901a908862d112a5dcf02/pyfc4/models.py#L1233-L1254 | train |
ghukill/pyfc4 | pyfc4/models.py | Resource.add_triple | def add_triple(self, p, o, auto_refresh=True):
'''
add triple by providing p,o, assumes s = subject
Args:
p (rdflib.term.URIRef): predicate
o (): object
auto_refresh (bool): whether or not to update object-like self.rdf.triples
Returns:
None: adds triple to self.rdf.graph
'''
self.rdf.graph.... | python | def add_triple(self, p, o, auto_refresh=True):
'''
add triple by providing p,o, assumes s = subject
Args:
p (rdflib.term.URIRef): predicate
o (): object
auto_refresh (bool): whether or not to update object-like self.rdf.triples
Returns:
None: adds triple to self.rdf.graph
'''
self.rdf.graph.... | [
"def",
"add_triple",
"(",
"self",
",",
"p",
",",
"o",
",",
"auto_refresh",
"=",
"True",
")",
":",
"self",
".",
"rdf",
".",
"graph",
".",
"add",
"(",
"(",
"self",
".",
"uri",
",",
"p",
",",
"self",
".",
"_handle_object",
"(",
"o",
")",
")",
")",... | add triple by providing p,o, assumes s = subject
Args:
p (rdflib.term.URIRef): predicate
o (): object
auto_refresh (bool): whether or not to update object-like self.rdf.triples
Returns:
None: adds triple to self.rdf.graph | [
"add",
"triple",
"by",
"providing",
"p",
"o",
"assumes",
"s",
"=",
"subject"
] | 59011df592f08978c4a901a908862d112a5dcf02 | https://github.com/ghukill/pyfc4/blob/59011df592f08978c4a901a908862d112a5dcf02/pyfc4/models.py#L1290-L1307 | train |
ghukill/pyfc4 | pyfc4/models.py | Resource.set_triple | def set_triple(self, p, o, auto_refresh=True):
'''
Assuming the predicate or object matches a single triple, sets the other for that triple.
Args:
p (rdflib.term.URIRef): predicate
o (): object
auto_refresh (bool): whether or not to update object-like self.rdf.triples
Returns:
None: modifies pre-... | python | def set_triple(self, p, o, auto_refresh=True):
'''
Assuming the predicate or object matches a single triple, sets the other for that triple.
Args:
p (rdflib.term.URIRef): predicate
o (): object
auto_refresh (bool): whether or not to update object-like self.rdf.triples
Returns:
None: modifies pre-... | [
"def",
"set_triple",
"(",
"self",
",",
"p",
",",
"o",
",",
"auto_refresh",
"=",
"True",
")",
":",
"self",
".",
"rdf",
".",
"graph",
".",
"set",
"(",
"(",
"self",
".",
"uri",
",",
"p",
",",
"self",
".",
"_handle_object",
"(",
"o",
")",
")",
")",... | Assuming the predicate or object matches a single triple, sets the other for that triple.
Args:
p (rdflib.term.URIRef): predicate
o (): object
auto_refresh (bool): whether or not to update object-like self.rdf.triples
Returns:
None: modifies pre-existing triple in self.rdf.graph | [
"Assuming",
"the",
"predicate",
"or",
"object",
"matches",
"a",
"single",
"triple",
"sets",
"the",
"other",
"for",
"that",
"triple",
"."
] | 59011df592f08978c4a901a908862d112a5dcf02 | https://github.com/ghukill/pyfc4/blob/59011df592f08978c4a901a908862d112a5dcf02/pyfc4/models.py#L1310-L1327 | train |
ghukill/pyfc4 | pyfc4/models.py | Resource.remove_triple | def remove_triple(self, p, o, auto_refresh=True):
'''
remove triple by supplying p,o
Args:
p (rdflib.term.URIRef): predicate
o (): object
auto_refresh (bool): whether or not to update object-like self.rdf.triples
Returns:
None: removes triple from self.rdf.graph
'''
self.rdf.graph.remove((se... | python | def remove_triple(self, p, o, auto_refresh=True):
'''
remove triple by supplying p,o
Args:
p (rdflib.term.URIRef): predicate
o (): object
auto_refresh (bool): whether or not to update object-like self.rdf.triples
Returns:
None: removes triple from self.rdf.graph
'''
self.rdf.graph.remove((se... | [
"def",
"remove_triple",
"(",
"self",
",",
"p",
",",
"o",
",",
"auto_refresh",
"=",
"True",
")",
":",
"self",
".",
"rdf",
".",
"graph",
".",
"remove",
"(",
"(",
"self",
".",
"uri",
",",
"p",
",",
"self",
".",
"_handle_object",
"(",
"o",
")",
")",
... | remove triple by supplying p,o
Args:
p (rdflib.term.URIRef): predicate
o (): object
auto_refresh (bool): whether or not to update object-like self.rdf.triples
Returns:
None: removes triple from self.rdf.graph | [
"remove",
"triple",
"by",
"supplying",
"p",
"o"
] | 59011df592f08978c4a901a908862d112a5dcf02 | https://github.com/ghukill/pyfc4/blob/59011df592f08978c4a901a908862d112a5dcf02/pyfc4/models.py#L1330-L1347 | train |
ghukill/pyfc4 | pyfc4/models.py | Resource._handle_triple_refresh | def _handle_triple_refresh(self, auto_refresh):
'''
method to refresh self.rdf.triples if auto_refresh or defaults set to True
'''
# if auto_refresh set, and True, refresh
if auto_refresh:
self.parse_object_like_triples()
# else, if auto_refresh is not set (None), check repository instance default
e... | python | def _handle_triple_refresh(self, auto_refresh):
'''
method to refresh self.rdf.triples if auto_refresh or defaults set to True
'''
# if auto_refresh set, and True, refresh
if auto_refresh:
self.parse_object_like_triples()
# else, if auto_refresh is not set (None), check repository instance default
e... | [
"def",
"_handle_triple_refresh",
"(",
"self",
",",
"auto_refresh",
")",
":",
"if",
"auto_refresh",
":",
"self",
".",
"parse_object_like_triples",
"(",
")",
"elif",
"auto_refresh",
"==",
"None",
":",
"if",
"self",
".",
"repo",
".",
"default_auto_refresh",
":",
... | method to refresh self.rdf.triples if auto_refresh or defaults set to True | [
"method",
"to",
"refresh",
"self",
".",
"rdf",
".",
"triples",
"if",
"auto_refresh",
"or",
"defaults",
"set",
"to",
"True"
] | 59011df592f08978c4a901a908862d112a5dcf02 | https://github.com/ghukill/pyfc4/blob/59011df592f08978c4a901a908862d112a5dcf02/pyfc4/models.py#L1350-L1363 | train |
ghukill/pyfc4 | pyfc4/models.py | Resource.update | def update(self, sparql_query_only=False, auto_refresh=None, update_binary=True):
'''
Method to update resources in repository. Firing this method computes the difference in the local modified graph and the original one,
creates an instance of SparqlUpdate and builds a sparql query that represents these differe... | python | def update(self, sparql_query_only=False, auto_refresh=None, update_binary=True):
'''
Method to update resources in repository. Firing this method computes the difference in the local modified graph and the original one,
creates an instance of SparqlUpdate and builds a sparql query that represents these differe... | [
"def",
"update",
"(",
"self",
",",
"sparql_query_only",
"=",
"False",
",",
"auto_refresh",
"=",
"None",
",",
"update_binary",
"=",
"True",
")",
":",
"self",
".",
"_diff_graph",
"(",
")",
"sq",
"=",
"SparqlUpdate",
"(",
"self",
".",
"rdf",
".",
"prefixes"... | Method to update resources in repository. Firing this method computes the difference in the local modified graph and the original one,
creates an instance of SparqlUpdate and builds a sparql query that represents these differences, and sends this as a PATCH request.
Note: send PATCH request, regardless of RDF or ... | [
"Method",
"to",
"update",
"resources",
"in",
"repository",
".",
"Firing",
"this",
"method",
"computes",
"the",
"difference",
"in",
"the",
"local",
"modified",
"graph",
"and",
"the",
"original",
"one",
"creates",
"an",
"instance",
"of",
"SparqlUpdate",
"and",
"... | 59011df592f08978c4a901a908862d112a5dcf02 | https://github.com/ghukill/pyfc4/blob/59011df592f08978c4a901a908862d112a5dcf02/pyfc4/models.py#L1366-L1430 | train |
ghukill/pyfc4 | pyfc4/models.py | Resource.children | def children(self, as_resources=False):
'''
method to return hierarchical children of this resource
Args:
as_resources (bool): if True, opens each as appropriate resource type instead of return URI only
Returns:
(list): list of resources
'''
children = [o for s,p,o in self.rdf.graph.triples((None... | python | def children(self, as_resources=False):
'''
method to return hierarchical children of this resource
Args:
as_resources (bool): if True, opens each as appropriate resource type instead of return URI only
Returns:
(list): list of resources
'''
children = [o for s,p,o in self.rdf.graph.triples((None... | [
"def",
"children",
"(",
"self",
",",
"as_resources",
"=",
"False",
")",
":",
"children",
"=",
"[",
"o",
"for",
"s",
",",
"p",
",",
"o",
"in",
"self",
".",
"rdf",
".",
"graph",
".",
"triples",
"(",
"(",
"None",
",",
"self",
".",
"rdf",
".",
"pre... | method to return hierarchical children of this resource
Args:
as_resources (bool): if True, opens each as appropriate resource type instead of return URI only
Returns:
(list): list of resources | [
"method",
"to",
"return",
"hierarchical",
"children",
"of",
"this",
"resource"
] | 59011df592f08978c4a901a908862d112a5dcf02 | https://github.com/ghukill/pyfc4/blob/59011df592f08978c4a901a908862d112a5dcf02/pyfc4/models.py#L1433-L1452 | train |
ghukill/pyfc4 | pyfc4/models.py | Resource.parents | def parents(self, as_resources=False):
'''
method to return hierarchical parents of this resource
Args:
as_resources (bool): if True, opens each as appropriate resource type instead of return URI only
Returns:
(list): list of resources
'''
parents = [o for s,p,o in self.rdf.graph.triples((None, se... | python | def parents(self, as_resources=False):
'''
method to return hierarchical parents of this resource
Args:
as_resources (bool): if True, opens each as appropriate resource type instead of return URI only
Returns:
(list): list of resources
'''
parents = [o for s,p,o in self.rdf.graph.triples((None, se... | [
"def",
"parents",
"(",
"self",
",",
"as_resources",
"=",
"False",
")",
":",
"parents",
"=",
"[",
"o",
"for",
"s",
",",
"p",
",",
"o",
"in",
"self",
".",
"rdf",
".",
"graph",
".",
"triples",
"(",
"(",
"None",
",",
"self",
".",
"rdf",
".",
"prefi... | method to return hierarchical parents of this resource
Args:
as_resources (bool): if True, opens each as appropriate resource type instead of return URI only
Returns:
(list): list of resources | [
"method",
"to",
"return",
"hierarchical",
"parents",
"of",
"this",
"resource"
] | 59011df592f08978c4a901a908862d112a5dcf02 | https://github.com/ghukill/pyfc4/blob/59011df592f08978c4a901a908862d112a5dcf02/pyfc4/models.py#L1455-L1474 | train |
ghukill/pyfc4 | pyfc4/models.py | Resource.siblings | def siblings(self, as_resources=False):
'''
method to return hierarchical siblings of this resource.
Args:
as_resources (bool): if True, opens each as appropriate resource type instead of return URI only
Returns:
(list): list of resources
'''
siblings = set()
# loop through parents and get chil... | python | def siblings(self, as_resources=False):
'''
method to return hierarchical siblings of this resource.
Args:
as_resources (bool): if True, opens each as appropriate resource type instead of return URI only
Returns:
(list): list of resources
'''
siblings = set()
# loop through parents and get chil... | [
"def",
"siblings",
"(",
"self",
",",
"as_resources",
"=",
"False",
")",
":",
"siblings",
"=",
"set",
"(",
")",
"for",
"parent",
"in",
"self",
".",
"parents",
"(",
"as_resources",
"=",
"True",
")",
":",
"for",
"sibling",
"in",
"parent",
".",
"children",... | method to return hierarchical siblings of this resource.
Args:
as_resources (bool): if True, opens each as appropriate resource type instead of return URI only
Returns:
(list): list of resources | [
"method",
"to",
"return",
"hierarchical",
"siblings",
"of",
"this",
"resource",
"."
] | 59011df592f08978c4a901a908862d112a5dcf02 | https://github.com/ghukill/pyfc4/blob/59011df592f08978c4a901a908862d112a5dcf02/pyfc4/models.py#L1477-L1502 | train |
ghukill/pyfc4 | pyfc4/models.py | Resource.create_version | def create_version(self, version_label):
'''
method to create a new version of the resource as it currently stands
- Note: this will create a version based on the current live instance of the resource,
not the local version, which might require self.update() to update.
Args:
version_label (str): label... | python | def create_version(self, version_label):
'''
method to create a new version of the resource as it currently stands
- Note: this will create a version based on the current live instance of the resource,
not the local version, which might require self.update() to update.
Args:
version_label (str): label... | [
"def",
"create_version",
"(",
"self",
",",
"version_label",
")",
":",
"version_response",
"=",
"self",
".",
"repo",
".",
"api",
".",
"http_request",
"(",
"'POST'",
",",
"'%s/fcr:versions'",
"%",
"self",
".",
"uri",
",",
"data",
"=",
"None",
",",
"headers",... | method to create a new version of the resource as it currently stands
- Note: this will create a version based on the current live instance of the resource,
not the local version, which might require self.update() to update.
Args:
version_label (str): label to be used for version
Returns:
(ResourceVe... | [
"method",
"to",
"create",
"a",
"new",
"version",
"of",
"the",
"resource",
"as",
"it",
"currently",
"stands"
] | 59011df592f08978c4a901a908862d112a5dcf02 | https://github.com/ghukill/pyfc4/blob/59011df592f08978c4a901a908862d112a5dcf02/pyfc4/models.py#L1517-L1540 | train |
ghukill/pyfc4 | pyfc4/models.py | Resource.get_versions | def get_versions(self):
'''
retrieves all versions of an object, and stores them at self.versions
Args:
None
Returns:
None: appends instances
'''
# get all versions
versions_response = self.repo.api.http_request('GET', '%s/fcr:versions' % self.uri)
# parse response
versions_graph = self.rep... | python | def get_versions(self):
'''
retrieves all versions of an object, and stores them at self.versions
Args:
None
Returns:
None: appends instances
'''
# get all versions
versions_response = self.repo.api.http_request('GET', '%s/fcr:versions' % self.uri)
# parse response
versions_graph = self.rep... | [
"def",
"get_versions",
"(",
"self",
")",
":",
"versions_response",
"=",
"self",
".",
"repo",
".",
"api",
".",
"http_request",
"(",
"'GET'",
",",
"'%s/fcr:versions'",
"%",
"self",
".",
"uri",
")",
"versions_graph",
"=",
"self",
".",
"repo",
".",
"api",
".... | retrieves all versions of an object, and stores them at self.versions
Args:
None
Returns:
None: appends instances | [
"retrieves",
"all",
"versions",
"of",
"an",
"object",
"and",
"stores",
"them",
"at",
"self",
".",
"versions"
] | 59011df592f08978c4a901a908862d112a5dcf02 | https://github.com/ghukill/pyfc4/blob/59011df592f08978c4a901a908862d112a5dcf02/pyfc4/models.py#L1543-L1568 | train |
ghukill/pyfc4 | pyfc4/models.py | Resource.dump | def dump(self,format='ttl'):
'''
Convenience method to return RDF data for resource,
optionally selecting serialization format.
Inspired by .dump from Samvera.
Args:
format (str): expecting serialization formats accepted by rdflib.serialization(format=)
'''
return self.rdf.graph.serialize(format=for... | python | def dump(self,format='ttl'):
'''
Convenience method to return RDF data for resource,
optionally selecting serialization format.
Inspired by .dump from Samvera.
Args:
format (str): expecting serialization formats accepted by rdflib.serialization(format=)
'''
return self.rdf.graph.serialize(format=for... | [
"def",
"dump",
"(",
"self",
",",
"format",
"=",
"'ttl'",
")",
":",
"return",
"self",
".",
"rdf",
".",
"graph",
".",
"serialize",
"(",
"format",
"=",
"format",
")",
".",
"decode",
"(",
"'utf-8'",
")"
] | Convenience method to return RDF data for resource,
optionally selecting serialization format.
Inspired by .dump from Samvera.
Args:
format (str): expecting serialization formats accepted by rdflib.serialization(format=) | [
"Convenience",
"method",
"to",
"return",
"RDF",
"data",
"for",
"resource",
"optionally",
"selecting",
"serialization",
"format",
".",
"Inspired",
"by",
".",
"dump",
"from",
"Samvera",
"."
] | 59011df592f08978c4a901a908862d112a5dcf02 | https://github.com/ghukill/pyfc4/blob/59011df592f08978c4a901a908862d112a5dcf02/pyfc4/models.py#L1571-L1582 | train |
ghukill/pyfc4 | pyfc4/models.py | ResourceVersion.revert_to | def revert_to(self):
'''
method to revert resource to this version by issuing PATCH
Args:
None
Returns:
None: sends PATCH request, and refreshes parent resource
'''
# send patch
response = self.resource.repo.api.http_request('PATCH', self.uri)
# if response 204
if response.status_code == 20... | python | def revert_to(self):
'''
method to revert resource to this version by issuing PATCH
Args:
None
Returns:
None: sends PATCH request, and refreshes parent resource
'''
# send patch
response = self.resource.repo.api.http_request('PATCH', self.uri)
# if response 204
if response.status_code == 20... | [
"def",
"revert_to",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"resource",
".",
"repo",
".",
"api",
".",
"http_request",
"(",
"'PATCH'",
",",
"self",
".",
"uri",
")",
"if",
"response",
".",
"status_code",
"==",
"204",
":",
"logger",
".",
"d... | method to revert resource to this version by issuing PATCH
Args:
None
Returns:
None: sends PATCH request, and refreshes parent resource | [
"method",
"to",
"revert",
"resource",
"to",
"this",
"version",
"by",
"issuing",
"PATCH"
] | 59011df592f08978c4a901a908862d112a5dcf02 | https://github.com/ghukill/pyfc4/blob/59011df592f08978c4a901a908862d112a5dcf02/pyfc4/models.py#L1609-L1632 | train |
ghukill/pyfc4 | pyfc4/models.py | ResourceVersion.delete | def delete(self):
'''
method to remove version from resource's history
'''
# send patch
response = self.resource.repo.api.http_request('DELETE', self.uri)
# if response 204
if response.status_code == 204:
logger.debug('deleting previous version of resource, %s' % self.uri)
# remove from resource... | python | def delete(self):
'''
method to remove version from resource's history
'''
# send patch
response = self.resource.repo.api.http_request('DELETE', self.uri)
# if response 204
if response.status_code == 204:
logger.debug('deleting previous version of resource, %s' % self.uri)
# remove from resource... | [
"def",
"delete",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"resource",
".",
"repo",
".",
"api",
".",
"http_request",
"(",
"'DELETE'",
",",
"self",
".",
"uri",
")",
"if",
"response",
".",
"status_code",
"==",
"204",
":",
"logger",
".",
"deb... | method to remove version from resource's history | [
"method",
"to",
"remove",
"version",
"from",
"resource",
"s",
"history"
] | 59011df592f08978c4a901a908862d112a5dcf02 | https://github.com/ghukill/pyfc4/blob/59011df592f08978c4a901a908862d112a5dcf02/pyfc4/models.py#L1635-L1656 | train |
ghukill/pyfc4 | pyfc4/models.py | BinaryData.empty | def empty(self):
'''
Method to empty attributes, particularly for use when
object is deleted but remains as variable
'''
self.resource = None
self.delivery = None
self.data = None
self.stream = False
self.mimetype = None
self.location = None | python | def empty(self):
'''
Method to empty attributes, particularly for use when
object is deleted but remains as variable
'''
self.resource = None
self.delivery = None
self.data = None
self.stream = False
self.mimetype = None
self.location = None | [
"def",
"empty",
"(",
"self",
")",
":",
"self",
".",
"resource",
"=",
"None",
"self",
".",
"delivery",
"=",
"None",
"self",
".",
"data",
"=",
"None",
"self",
".",
"stream",
"=",
"False",
"self",
".",
"mimetype",
"=",
"None",
"self",
".",
"location",
... | Method to empty attributes, particularly for use when
object is deleted but remains as variable | [
"Method",
"to",
"empty",
"attributes",
"particularly",
"for",
"use",
"when",
"object",
"is",
"deleted",
"but",
"remains",
"as",
"variable"
] | 59011df592f08978c4a901a908862d112a5dcf02 | https://github.com/ghukill/pyfc4/blob/59011df592f08978c4a901a908862d112a5dcf02/pyfc4/models.py#L1686-L1698 | train |
ghukill/pyfc4 | pyfc4/models.py | BinaryData.refresh | def refresh(self, updated_self):
'''
method to refresh binary attributes and data
Args:
updated_self (Resource): resource this binary data attaches to
Returns:
None: updates attributes
'''
logger.debug('refreshing binary attributes')
self.mimetype = updated_self.binary.mimetype
self.data = upd... | python | def refresh(self, updated_self):
'''
method to refresh binary attributes and data
Args:
updated_self (Resource): resource this binary data attaches to
Returns:
None: updates attributes
'''
logger.debug('refreshing binary attributes')
self.mimetype = updated_self.binary.mimetype
self.data = upd... | [
"def",
"refresh",
"(",
"self",
",",
"updated_self",
")",
":",
"logger",
".",
"debug",
"(",
"'refreshing binary attributes'",
")",
"self",
".",
"mimetype",
"=",
"updated_self",
".",
"binary",
".",
"mimetype",
"self",
".",
"data",
"=",
"updated_self",
".",
"bi... | method to refresh binary attributes and data
Args:
updated_self (Resource): resource this binary data attaches to
Returns:
None: updates attributes | [
"method",
"to",
"refresh",
"binary",
"attributes",
"and",
"data"
] | 59011df592f08978c4a901a908862d112a5dcf02 | https://github.com/ghukill/pyfc4/blob/59011df592f08978c4a901a908862d112a5dcf02/pyfc4/models.py#L1701-L1715 | train |
ghukill/pyfc4 | pyfc4/models.py | BinaryData.parse_binary | def parse_binary(self):
'''
when retrieving a NonRDF resource, parse binary data and make available
via generators
'''
# derive mimetype
self.mimetype = self.resource.rdf.graph.value(
self.resource.uri,
self.resource.rdf.prefixes.ebucore.hasMimeType).toPython()
# get binary content as stremable r... | python | def parse_binary(self):
'''
when retrieving a NonRDF resource, parse binary data and make available
via generators
'''
# derive mimetype
self.mimetype = self.resource.rdf.graph.value(
self.resource.uri,
self.resource.rdf.prefixes.ebucore.hasMimeType).toPython()
# get binary content as stremable r... | [
"def",
"parse_binary",
"(",
"self",
")",
":",
"self",
".",
"mimetype",
"=",
"self",
".",
"resource",
".",
"rdf",
".",
"graph",
".",
"value",
"(",
"self",
".",
"resource",
".",
"uri",
",",
"self",
".",
"resource",
".",
"rdf",
".",
"prefixes",
".",
"... | when retrieving a NonRDF resource, parse binary data and make available
via generators | [
"when",
"retrieving",
"a",
"NonRDF",
"resource",
"parse",
"binary",
"data",
"and",
"make",
"available",
"via",
"generators"
] | 59011df592f08978c4a901a908862d112a5dcf02 | https://github.com/ghukill/pyfc4/blob/59011df592f08978c4a901a908862d112a5dcf02/pyfc4/models.py#L1718-L1737 | train |
ghukill/pyfc4 | pyfc4/models.py | BinaryData._prep_binary_content | def _prep_binary_content(self):
'''
Sets delivery method of either payload or header
Favors Content-Location header if set
Args:
None
Returns:
None: sets attributes in self.binary and headers
'''
# nothing present
if not self.data and not self.location and 'Content-Location' not in self.resour... | python | def _prep_binary_content(self):
'''
Sets delivery method of either payload or header
Favors Content-Location header if set
Args:
None
Returns:
None: sets attributes in self.binary and headers
'''
# nothing present
if not self.data and not self.location and 'Content-Location' not in self.resour... | [
"def",
"_prep_binary_content",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"data",
"and",
"not",
"self",
".",
"location",
"and",
"'Content-Location'",
"not",
"in",
"self",
".",
"resource",
".",
"headers",
".",
"keys",
"(",
")",
":",
"raise",
"Except... | Sets delivery method of either payload or header
Favors Content-Location header if set
Args:
None
Returns:
None: sets attributes in self.binary and headers | [
"Sets",
"delivery",
"method",
"of",
"either",
"payload",
"or",
"header",
"Favors",
"Content",
"-",
"Location",
"header",
"if",
"set"
] | 59011df592f08978c4a901a908862d112a5dcf02 | https://github.com/ghukill/pyfc4/blob/59011df592f08978c4a901a908862d112a5dcf02/pyfc4/models.py#L1785-L1826 | train |
ghukill/pyfc4 | pyfc4/models.py | NonRDFSource.fixity | def fixity(self, response_format=None):
'''
Issues fixity check, return parsed graph
Args:
None
Returns:
(dict): ('verdict':(bool): verdict of fixity check, 'premis_graph':(rdflib.Graph): parsed PREMIS graph from check)
'''
# if no response_format, use default
if not response_format:
response... | python | def fixity(self, response_format=None):
'''
Issues fixity check, return parsed graph
Args:
None
Returns:
(dict): ('verdict':(bool): verdict of fixity check, 'premis_graph':(rdflib.Graph): parsed PREMIS graph from check)
'''
# if no response_format, use default
if not response_format:
response... | [
"def",
"fixity",
"(",
"self",
",",
"response_format",
"=",
"None",
")",
":",
"if",
"not",
"response_format",
":",
"response_format",
"=",
"self",
".",
"repo",
".",
"default_serialization",
"response",
"=",
"self",
".",
"repo",
".",
"api",
".",
"http_request"... | Issues fixity check, return parsed graph
Args:
None
Returns:
(dict): ('verdict':(bool): verdict of fixity check, 'premis_graph':(rdflib.Graph): parsed PREMIS graph from check) | [
"Issues",
"fixity",
"check",
"return",
"parsed",
"graph"
] | 59011df592f08978c4a901a908862d112a5dcf02 | https://github.com/ghukill/pyfc4/blob/59011df592f08978c4a901a908862d112a5dcf02/pyfc4/models.py#L1896-L1928 | train |
sleibman/python-conduit | conduit/core.py | Channel.get_value | def get_value(self, consumer=None):
"""
If consumer is specified, the channel will record that consumer as having consumed the value.
"""
if consumer:
self.consumers[consumer] = True
return self.value | python | def get_value(self, consumer=None):
"""
If consumer is specified, the channel will record that consumer as having consumed the value.
"""
if consumer:
self.consumers[consumer] = True
return self.value | [
"def",
"get_value",
"(",
"self",
",",
"consumer",
"=",
"None",
")",
":",
"if",
"consumer",
":",
"self",
".",
"consumers",
"[",
"consumer",
"]",
"=",
"True",
"return",
"self",
".",
"value"
] | If consumer is specified, the channel will record that consumer as having consumed the value. | [
"If",
"consumer",
"is",
"specified",
"the",
"channel",
"will",
"record",
"that",
"consumer",
"as",
"having",
"consumed",
"the",
"value",
"."
] | f6002d45c4f25e4418591a72fdac9ac6fb422d80 | https://github.com/sleibman/python-conduit/blob/f6002d45c4f25e4418591a72fdac9ac6fb422d80/conduit/core.py#L105-L111 | train |
sleibman/python-conduit | conduit/core.py | DataBlock.set_input_data | def set_input_data(self, key, value):
"""
set_input_data will automatically create an input channel if necessary.
Automatic channel creation is intended for the case where users are trying to set initial values on a block
whose input channels aren't subscribed to anything in the graph.
... | python | def set_input_data(self, key, value):
"""
set_input_data will automatically create an input channel if necessary.
Automatic channel creation is intended for the case where users are trying to set initial values on a block
whose input channels aren't subscribed to anything in the graph.
... | [
"def",
"set_input_data",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"if",
"not",
"key",
"in",
"self",
".",
"input_channels",
".",
"keys",
"(",
")",
":",
"self",
".",
"set_input_channel",
"(",
"key",
",",
"Channel",
"(",
")",
")",
"self",
".",
... | set_input_data will automatically create an input channel if necessary.
Automatic channel creation is intended for the case where users are trying to set initial values on a block
whose input channels aren't subscribed to anything in the graph. | [
"set_input_data",
"will",
"automatically",
"create",
"an",
"input",
"channel",
"if",
"necessary",
".",
"Automatic",
"channel",
"creation",
"is",
"intended",
"for",
"the",
"case",
"where",
"users",
"are",
"trying",
"to",
"set",
"initial",
"values",
"on",
"a",
"... | f6002d45c4f25e4418591a72fdac9ac6fb422d80 | https://github.com/sleibman/python-conduit/blob/f6002d45c4f25e4418591a72fdac9ac6fb422d80/conduit/core.py#L276-L284 | train |
sleibman/python-conduit | conduit/core.py | DataBlock.get_output_channel | def get_output_channel(self, output_channel_name):
"""
get_output_channel will create a new channel object if necessary.
"""
if not output_channel_name in self.output_channels.keys():
self.output_channels[output_channel_name] = Channel()
self.output_channels[output_ch... | python | def get_output_channel(self, output_channel_name):
"""
get_output_channel will create a new channel object if necessary.
"""
if not output_channel_name in self.output_channels.keys():
self.output_channels[output_channel_name] = Channel()
self.output_channels[output_ch... | [
"def",
"get_output_channel",
"(",
"self",
",",
"output_channel_name",
")",
":",
"if",
"not",
"output_channel_name",
"in",
"self",
".",
"output_channels",
".",
"keys",
"(",
")",
":",
"self",
".",
"output_channels",
"[",
"output_channel_name",
"]",
"=",
"Channel",... | get_output_channel will create a new channel object if necessary. | [
"get_output_channel",
"will",
"create",
"a",
"new",
"channel",
"object",
"if",
"necessary",
"."
] | f6002d45c4f25e4418591a72fdac9ac6fb422d80 | https://github.com/sleibman/python-conduit/blob/f6002d45c4f25e4418591a72fdac9ac6fb422d80/conduit/core.py#L336-L343 | train |
adamhadani/python-yelp | yelp/api.py | ReviewSearchApi.by_bounding_box | def by_bounding_box(self, tl_lat, tl_long, br_lat, br_long, term=None, num_biz_requested=None, category=None):
"""
Perform a Yelp Review Search based on a map bounding box.
Args:
tl_lat - bounding box top left latitude
tl_long - bounding box top left longitude
... | python | def by_bounding_box(self, tl_lat, tl_long, br_lat, br_long, term=None, num_biz_requested=None, category=None):
"""
Perform a Yelp Review Search based on a map bounding box.
Args:
tl_lat - bounding box top left latitude
tl_long - bounding box top left longitude
... | [
"def",
"by_bounding_box",
"(",
"self",
",",
"tl_lat",
",",
"tl_long",
",",
"br_lat",
",",
"br_long",
",",
"term",
"=",
"None",
",",
"num_biz_requested",
"=",
"None",
",",
"category",
"=",
"None",
")",
":",
"header",
",",
"content",
"=",
"self",
".",
"_... | Perform a Yelp Review Search based on a map bounding box.
Args:
tl_lat - bounding box top left latitude
tl_long - bounding box top left longitude
br_lat - bounding box bottom right latitude
br_long - bounding box bottom right longitude
term - Searc... | [
"Perform",
"a",
"Yelp",
"Review",
"Search",
"based",
"on",
"a",
"map",
"bounding",
"box",
"."
] | 7694ccb7274cc3c5783250ed0c3396cda2fcfa1a | https://github.com/adamhadani/python-yelp/blob/7694ccb7274cc3c5783250ed0c3396cda2fcfa1a/yelp/api.py#L104-L131 | train |
adamhadani/python-yelp | yelp/api.py | ReviewSearchApi.by_geopoint | def by_geopoint(self, lat, long, radius, term=None, num_biz_requested=None, category=None):
"""
Perform a Yelp Review Search based on a geopoint and radius tuple.
Args:
lat - geopoint latitude
long - geopoint longitude
radius - search radius (in miles... | python | def by_geopoint(self, lat, long, radius, term=None, num_biz_requested=None, category=None):
"""
Perform a Yelp Review Search based on a geopoint and radius tuple.
Args:
lat - geopoint latitude
long - geopoint longitude
radius - search radius (in miles... | [
"def",
"by_geopoint",
"(",
"self",
",",
"lat",
",",
"long",
",",
"radius",
",",
"term",
"=",
"None",
",",
"num_biz_requested",
"=",
"None",
",",
"category",
"=",
"None",
")",
":",
"header",
",",
"content",
"=",
"self",
".",
"_http_request",
"(",
"self"... | Perform a Yelp Review Search based on a geopoint and radius tuple.
Args:
lat - geopoint latitude
long - geopoint longitude
radius - search radius (in miles)
term - Search term to filter by (Optional)
num_biz_requested - Maximum number of match... | [
"Perform",
"a",
"Yelp",
"Review",
"Search",
"based",
"on",
"a",
"geopoint",
"and",
"radius",
"tuple",
"."
] | 7694ccb7274cc3c5783250ed0c3396cda2fcfa1a | https://github.com/adamhadani/python-yelp/blob/7694ccb7274cc3c5783250ed0c3396cda2fcfa1a/yelp/api.py#L134-L158 | train |
adamhadani/python-yelp | yelp/api.py | ReviewSearchApi.by_location | def by_location(self, location, cc=None, radius=None, term=None, num_biz_requested=None, category=None):
"""
Perform a Yelp Review Search based on a location specifier.
Args:
location - textual location specifier of form: "address, neighborhood, city, state or zip, optional country"
... | python | def by_location(self, location, cc=None, radius=None, term=None, num_biz_requested=None, category=None):
"""
Perform a Yelp Review Search based on a location specifier.
Args:
location - textual location specifier of form: "address, neighborhood, city, state or zip, optional country"
... | [
"def",
"by_location",
"(",
"self",
",",
"location",
",",
"cc",
"=",
"None",
",",
"radius",
"=",
"None",
",",
"term",
"=",
"None",
",",
"num_biz_requested",
"=",
"None",
",",
"category",
"=",
"None",
")",
":",
"header",
",",
"content",
"=",
"self",
".... | Perform a Yelp Review Search based on a location specifier.
Args:
location - textual location specifier of form: "address, neighborhood, city, state or zip, optional country"
cc - ISO 3166-1 alpha-2 country code. (Optional)
radius - search radius (in miles) (Optional)
... | [
"Perform",
"a",
"Yelp",
"Review",
"Search",
"based",
"on",
"a",
"location",
"specifier",
"."
] | 7694ccb7274cc3c5783250ed0c3396cda2fcfa1a | https://github.com/adamhadani/python-yelp/blob/7694ccb7274cc3c5783250ed0c3396cda2fcfa1a/yelp/api.py#L161-L184 | train |
adamhadani/python-yelp | yelp/api.py | PhoneApi.by_phone | def by_phone(self, phone, cc=None):
"""
Perform a Yelp Phone API Search based on phone number given.
Args:
phone - Phone number to search by
cc - ISO 3166-1 alpha-2 country code. (Optional)
"""
header, content = self._http_request(self.BASE_URL, ph... | python | def by_phone(self, phone, cc=None):
"""
Perform a Yelp Phone API Search based on phone number given.
Args:
phone - Phone number to search by
cc - ISO 3166-1 alpha-2 country code. (Optional)
"""
header, content = self._http_request(self.BASE_URL, ph... | [
"def",
"by_phone",
"(",
"self",
",",
"phone",
",",
"cc",
"=",
"None",
")",
":",
"header",
",",
"content",
"=",
"self",
".",
"_http_request",
"(",
"self",
".",
"BASE_URL",
",",
"phone",
"=",
"phone",
",",
"cc",
"=",
"cc",
")",
"return",
"json",
".",... | Perform a Yelp Phone API Search based on phone number given.
Args:
phone - Phone number to search by
cc - ISO 3166-1 alpha-2 country code. (Optional) | [
"Perform",
"a",
"Yelp",
"Phone",
"API",
"Search",
"based",
"on",
"phone",
"number",
"given",
"."
] | 7694ccb7274cc3c5783250ed0c3396cda2fcfa1a | https://github.com/adamhadani/python-yelp/blob/7694ccb7274cc3c5783250ed0c3396cda2fcfa1a/yelp/api.py#L203-L214 | train |
adamhadani/python-yelp | yelp/api.py | NeighborhoodApi.by_geopoint | def by_geopoint(self, lat, long):
"""
Perform a Yelp Neighborhood API Search based on a geopoint.
Args:
lat - geopoint latitude
long - geopoint longitude
"""
header, content = self._http_request(self.BASE_URL, lat=lat, long=long)
return... | python | def by_geopoint(self, lat, long):
"""
Perform a Yelp Neighborhood API Search based on a geopoint.
Args:
lat - geopoint latitude
long - geopoint longitude
"""
header, content = self._http_request(self.BASE_URL, lat=lat, long=long)
return... | [
"def",
"by_geopoint",
"(",
"self",
",",
"lat",
",",
"long",
")",
":",
"header",
",",
"content",
"=",
"self",
".",
"_http_request",
"(",
"self",
".",
"BASE_URL",
",",
"lat",
"=",
"lat",
",",
"long",
"=",
"long",
")",
"return",
"json",
".",
"loads",
... | Perform a Yelp Neighborhood API Search based on a geopoint.
Args:
lat - geopoint latitude
long - geopoint longitude | [
"Perform",
"a",
"Yelp",
"Neighborhood",
"API",
"Search",
"based",
"on",
"a",
"geopoint",
"."
] | 7694ccb7274cc3c5783250ed0c3396cda2fcfa1a | https://github.com/adamhadani/python-yelp/blob/7694ccb7274cc3c5783250ed0c3396cda2fcfa1a/yelp/api.py#L233-L243 | train |
adamhadani/python-yelp | yelp/api.py | NeighborhoodApi.by_location | def by_location(self, location, cc=None):
"""
Perform a Yelp Neighborhood API Search based on a location specifier.
Args:
location - textual location specifier of form: "address, city, state or zip, optional country"
cc - ISO 3166-1 alpha-2 country code. (Optional)
... | python | def by_location(self, location, cc=None):
"""
Perform a Yelp Neighborhood API Search based on a location specifier.
Args:
location - textual location specifier of form: "address, city, state or zip, optional country"
cc - ISO 3166-1 alpha-2 country code. (Optional)
... | [
"def",
"by_location",
"(",
"self",
",",
"location",
",",
"cc",
"=",
"None",
")",
":",
"header",
",",
"content",
"=",
"self",
".",
"_http_request",
"(",
"self",
".",
"BASE_URL",
",",
"location",
"=",
"location",
",",
"cc",
"=",
"cc",
")",
"return",
"j... | Perform a Yelp Neighborhood API Search based on a location specifier.
Args:
location - textual location specifier of form: "address, city, state or zip, optional country"
cc - ISO 3166-1 alpha-2 country code. (Optional) | [
"Perform",
"a",
"Yelp",
"Neighborhood",
"API",
"Search",
"based",
"on",
"a",
"location",
"specifier",
"."
] | 7694ccb7274cc3c5783250ed0c3396cda2fcfa1a | https://github.com/adamhadani/python-yelp/blob/7694ccb7274cc3c5783250ed0c3396cda2fcfa1a/yelp/api.py#L246-L256 | train |
eventifyio/eventify | eventify/drivers/zeromq.py | Service.check_transport_host | def check_transport_host(self):
"""
Check if zeromq socket is available
on transport host
"""
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
result = sock.connect_ex(('events-server', 8080))
if result == 0:
logging.info('port 8080 on zmq is o... | python | def check_transport_host(self):
"""
Check if zeromq socket is available
on transport host
"""
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
result = sock.connect_ex(('events-server', 8080))
if result == 0:
logging.info('port 8080 on zmq is o... | [
"def",
"check_transport_host",
"(",
"self",
")",
":",
"sock",
"=",
"socket",
".",
"socket",
"(",
"socket",
".",
"AF_INET",
",",
"socket",
".",
"SOCK_STREAM",
")",
"result",
"=",
"sock",
".",
"connect_ex",
"(",
"(",
"'events-server'",
",",
"8080",
")",
")... | Check if zeromq socket is available
on transport host | [
"Check",
"if",
"zeromq",
"socket",
"is",
"available",
"on",
"transport",
"host"
] | 0e519964a56bd07a879b266f21f177749c63aaed | https://github.com/eventifyio/eventify/blob/0e519964a56bd07a879b266f21f177749c63aaed/eventify/drivers/zeromq.py#L130-L140 | train |
255BITS/hyperchamber | hyperchamber/io/__init__.py | sample | def sample(config, samples):
"""Upload a series of samples. Each sample has keys 'image' and 'label'.
Images are ignored if the rate limit is hit."""
url = get_api_path('sample.json')
multiple_files = []
images = [s['image'] for s in samples]
labels = [s['label'] for s in samples]
for image in images:
... | python | def sample(config, samples):
"""Upload a series of samples. Each sample has keys 'image' and 'label'.
Images are ignored if the rate limit is hit."""
url = get_api_path('sample.json')
multiple_files = []
images = [s['image'] for s in samples]
labels = [s['label'] for s in samples]
for image in images:
... | [
"def",
"sample",
"(",
"config",
",",
"samples",
")",
":",
"url",
"=",
"get_api_path",
"(",
"'sample.json'",
")",
"multiple_files",
"=",
"[",
"]",
"images",
"=",
"[",
"s",
"[",
"'image'",
"]",
"for",
"s",
"in",
"samples",
"]",
"labels",
"=",
"[",
"s",... | Upload a series of samples. Each sample has keys 'image' and 'label'.
Images are ignored if the rate limit is hit. | [
"Upload",
"a",
"series",
"of",
"samples",
".",
"Each",
"sample",
"has",
"keys",
"image",
"and",
"label",
".",
"Images",
"are",
"ignored",
"if",
"the",
"rate",
"limit",
"is",
"hit",
"."
] | 4d5774bde9ea6ce1113f77a069ffc605148482b8 | https://github.com/255BITS/hyperchamber/blob/4d5774bde9ea6ce1113f77a069ffc605148482b8/hyperchamber/io/__init__.py#L43-L63 | train |
255BITS/hyperchamber | hyperchamber/io/__init__.py | measure | def measure(config, result, max_retries=10):
"""Records results on hyperchamber.io. Used when you are done testing a config."""
url = get_api_path('measurement.json')
data = {'config': config, 'result': result}
retries = 0
while(retries < max_retries):
try:
r = requests.post(url, data=json.du... | python | def measure(config, result, max_retries=10):
"""Records results on hyperchamber.io. Used when you are done testing a config."""
url = get_api_path('measurement.json')
data = {'config': config, 'result': result}
retries = 0
while(retries < max_retries):
try:
r = requests.post(url, data=json.du... | [
"def",
"measure",
"(",
"config",
",",
"result",
",",
"max_retries",
"=",
"10",
")",
":",
"url",
"=",
"get_api_path",
"(",
"'measurement.json'",
")",
"data",
"=",
"{",
"'config'",
":",
"config",
",",
"'result'",
":",
"result",
"}",
"retries",
"=",
"0",
... | Records results on hyperchamber.io. Used when you are done testing a config. | [
"Records",
"results",
"on",
"hyperchamber",
".",
"io",
".",
"Used",
"when",
"you",
"are",
"done",
"testing",
"a",
"config",
"."
] | 4d5774bde9ea6ce1113f77a069ffc605148482b8 | https://github.com/255BITS/hyperchamber/blob/4d5774bde9ea6ce1113f77a069ffc605148482b8/hyperchamber/io/__init__.py#L65-L77 | train |
stephenmcd/gunicorn-console | gunicorn_console.py | move_selection | def move_selection(reverse=False):
"""
Goes through the list of gunicorns, setting the selected as the one after
the currently selected.
"""
global selected_pid
if selected_pid not in gunicorns:
selected_pid = None
found = False
pids = sorted(gunicorns.keys(), reverse=reverse)
... | python | def move_selection(reverse=False):
"""
Goes through the list of gunicorns, setting the selected as the one after
the currently selected.
"""
global selected_pid
if selected_pid not in gunicorns:
selected_pid = None
found = False
pids = sorted(gunicorns.keys(), reverse=reverse)
... | [
"def",
"move_selection",
"(",
"reverse",
"=",
"False",
")",
":",
"global",
"selected_pid",
"if",
"selected_pid",
"not",
"in",
"gunicorns",
":",
"selected_pid",
"=",
"None",
"found",
"=",
"False",
"pids",
"=",
"sorted",
"(",
"gunicorns",
".",
"keys",
"(",
"... | Goes through the list of gunicorns, setting the selected as the one after
the currently selected. | [
"Goes",
"through",
"the",
"list",
"of",
"gunicorns",
"setting",
"the",
"selected",
"as",
"the",
"one",
"after",
"the",
"currently",
"selected",
"."
] | f5c9b9a69ea1f2ca00aac3565cb99491684d868a | https://github.com/stephenmcd/gunicorn-console/blob/f5c9b9a69ea1f2ca00aac3565cb99491684d868a/gunicorn_console.py#L87-L102 | train |
stephenmcd/gunicorn-console | gunicorn_console.py | update_gunicorns | def update_gunicorns():
"""
Updates the dict of gunicorn processes. Run the ps command and parse its
output for processes named after gunicorn, building up a dict of gunicorn
processes. When new gunicorns are discovered, run the netstat command to
determine the ports they're serving on.
"""
... | python | def update_gunicorns():
"""
Updates the dict of gunicorn processes. Run the ps command and parse its
output for processes named after gunicorn, building up a dict of gunicorn
processes. When new gunicorns are discovered, run the netstat command to
determine the ports they're serving on.
"""
... | [
"def",
"update_gunicorns",
"(",
")",
":",
"global",
"tick",
"tick",
"+=",
"1",
"if",
"(",
"tick",
"*",
"screen_delay",
")",
"%",
"ps_delay",
"!=",
"0",
":",
"return",
"tick",
"=",
"0",
"for",
"pid",
"in",
"gunicorns",
":",
"gunicorns",
"[",
"pid",
"]... | Updates the dict of gunicorn processes. Run the ps command and parse its
output for processes named after gunicorn, building up a dict of gunicorn
processes. When new gunicorns are discovered, run the netstat command to
determine the ports they're serving on. | [
"Updates",
"the",
"dict",
"of",
"gunicorn",
"processes",
".",
"Run",
"the",
"ps",
"command",
"and",
"parse",
"its",
"output",
"for",
"processes",
"named",
"after",
"gunicorn",
"building",
"up",
"a",
"dict",
"of",
"gunicorn",
"processes",
".",
"When",
"new",
... | f5c9b9a69ea1f2ca00aac3565cb99491684d868a | https://github.com/stephenmcd/gunicorn-console/blob/f5c9b9a69ea1f2ca00aac3565cb99491684d868a/gunicorn_console.py#L105-L150 | train |
stephenmcd/gunicorn-console | gunicorn_console.py | handle_keypress | def handle_keypress(screen):
"""
Check for a key being pressed and handle it if applicable.
"""
global selected_pid
try:
key = screen.getkey().upper()
except:
return
if key in ("KEY_DOWN", "J"):
move_selection()
elif key in ("KEY_UP", "K"):
move_selection(... | python | def handle_keypress(screen):
"""
Check for a key being pressed and handle it if applicable.
"""
global selected_pid
try:
key = screen.getkey().upper()
except:
return
if key in ("KEY_DOWN", "J"):
move_selection()
elif key in ("KEY_UP", "K"):
move_selection(... | [
"def",
"handle_keypress",
"(",
"screen",
")",
":",
"global",
"selected_pid",
"try",
":",
"key",
"=",
"screen",
".",
"getkey",
"(",
")",
".",
"upper",
"(",
")",
"except",
":",
"return",
"if",
"key",
"in",
"(",
"\"KEY_DOWN\"",
",",
"\"J\"",
")",
":",
"... | Check for a key being pressed and handle it if applicable. | [
"Check",
"for",
"a",
"key",
"being",
"pressed",
"and",
"handle",
"it",
"if",
"applicable",
"."
] | f5c9b9a69ea1f2ca00aac3565cb99491684d868a | https://github.com/stephenmcd/gunicorn-console/blob/f5c9b9a69ea1f2ca00aac3565cb99491684d868a/gunicorn_console.py#L153-L192 | train |
stephenmcd/gunicorn-console | gunicorn_console.py | format_row | def format_row(pid="", port="", name="", mem="", workers="", prefix_char=" "):
"""
Applies consistant padding to each of the columns in a row and serves as
the source of the overall screen width.
"""
row = "%s%-5s %-6s %-25s %8s %7s " \
% (prefix_char, pid, port, name, mem, workers)
... | python | def format_row(pid="", port="", name="", mem="", workers="", prefix_char=" "):
"""
Applies consistant padding to each of the columns in a row and serves as
the source of the overall screen width.
"""
row = "%s%-5s %-6s %-25s %8s %7s " \
% (prefix_char, pid, port, name, mem, workers)
... | [
"def",
"format_row",
"(",
"pid",
"=",
"\"\"",
",",
"port",
"=",
"\"\"",
",",
"name",
"=",
"\"\"",
",",
"mem",
"=",
"\"\"",
",",
"workers",
"=",
"\"\"",
",",
"prefix_char",
"=",
"\" \"",
")",
":",
"row",
"=",
"\"%s%-5s %-6s %-25s %8s %7s \"",
"%",
"(",... | Applies consistant padding to each of the columns in a row and serves as
the source of the overall screen width. | [
"Applies",
"consistant",
"padding",
"to",
"each",
"of",
"the",
"columns",
"in",
"a",
"row",
"and",
"serves",
"as",
"the",
"source",
"of",
"the",
"overall",
"screen",
"width",
"."
] | f5c9b9a69ea1f2ca00aac3565cb99491684d868a | https://github.com/stephenmcd/gunicorn-console/blob/f5c9b9a69ea1f2ca00aac3565cb99491684d868a/gunicorn_console.py#L195-L206 | train |
stephenmcd/gunicorn-console | gunicorn_console.py | display_output | def display_output(screen):
"""
Display the menu list of gunicorns.
"""
format_row() # Sets up the screen width.
screen_height = len(gunicorns) + len(instructions.split("\n")) + 9
if not gunicorns:
screen_height += 2 # A couple of blank lines are added when empty.
screen.erase()
... | python | def display_output(screen):
"""
Display the menu list of gunicorns.
"""
format_row() # Sets up the screen width.
screen_height = len(gunicorns) + len(instructions.split("\n")) + 9
if not gunicorns:
screen_height += 2 # A couple of blank lines are added when empty.
screen.erase()
... | [
"def",
"display_output",
"(",
"screen",
")",
":",
"format_row",
"(",
")",
"screen_height",
"=",
"len",
"(",
"gunicorns",
")",
"+",
"len",
"(",
"instructions",
".",
"split",
"(",
"\"\\n\"",
")",
")",
"+",
"9",
"if",
"not",
"gunicorns",
":",
"screen_height... | Display the menu list of gunicorns. | [
"Display",
"the",
"menu",
"list",
"of",
"gunicorns",
"."
] | f5c9b9a69ea1f2ca00aac3565cb99491684d868a | https://github.com/stephenmcd/gunicorn-console/blob/f5c9b9a69ea1f2ca00aac3565cb99491684d868a/gunicorn_console.py#L209-L262 | train |
stephenmcd/gunicorn-console | gunicorn_console.py | main | def main():
"""
Main entry point for gunicorn_console.
"""
# Set up curses.
stdscr = curses.initscr()
curses.start_color()
curses.init_pair(1, foreground_colour, background_colour)
curses.noecho()
stdscr.keypad(True)
stdscr.nodelay(True)
try:
curses.curs_set(False)
... | python | def main():
"""
Main entry point for gunicorn_console.
"""
# Set up curses.
stdscr = curses.initscr()
curses.start_color()
curses.init_pair(1, foreground_colour, background_colour)
curses.noecho()
stdscr.keypad(True)
stdscr.nodelay(True)
try:
curses.curs_set(False)
... | [
"def",
"main",
"(",
")",
":",
"stdscr",
"=",
"curses",
".",
"initscr",
"(",
")",
"curses",
".",
"start_color",
"(",
")",
"curses",
".",
"init_pair",
"(",
"1",
",",
"foreground_colour",
",",
"background_colour",
")",
"curses",
".",
"noecho",
"(",
")",
"... | Main entry point for gunicorn_console. | [
"Main",
"entry",
"point",
"for",
"gunicorn_console",
"."
] | f5c9b9a69ea1f2ca00aac3565cb99491684d868a | https://github.com/stephenmcd/gunicorn-console/blob/f5c9b9a69ea1f2ca00aac3565cb99491684d868a/gunicorn_console.py#L265-L295 | train |
pgxcentre/geneparse | geneparse/extract/extractor.py | _get_variant_silent | def _get_variant_silent(parser, variant):
"""Gets a variant from the parser while disabling logging."""
prev_log = config.LOG_NOT_FOUND
config.LOG_NOT_FOUND = False
results = parser.get_variant_genotypes(variant)
config.LOG_NOT_FOUND = prev_log
return results | python | def _get_variant_silent(parser, variant):
"""Gets a variant from the parser while disabling logging."""
prev_log = config.LOG_NOT_FOUND
config.LOG_NOT_FOUND = False
results = parser.get_variant_genotypes(variant)
config.LOG_NOT_FOUND = prev_log
return results | [
"def",
"_get_variant_silent",
"(",
"parser",
",",
"variant",
")",
":",
"prev_log",
"=",
"config",
".",
"LOG_NOT_FOUND",
"config",
".",
"LOG_NOT_FOUND",
"=",
"False",
"results",
"=",
"parser",
".",
"get_variant_genotypes",
"(",
"variant",
")",
"config",
".",
"L... | Gets a variant from the parser while disabling logging. | [
"Gets",
"a",
"variant",
"from",
"the",
"parser",
"while",
"disabling",
"logging",
"."
] | f698f9708af4c7962d384a70a5a14006b1cb7108 | https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/extract/extractor.py#L93-L99 | train |
KnightConan/sspdatatables | src/sspdatatables/utils/enum.py | ExtendedEnumMeta._attrs_ | def _attrs_(mcs, cls, attr_name: str) -> Tuple[Any, ...]:
"""
Returns a tuple containing just the value of the given attr_name of all
the elements from the cls.
:return: tuple of different types
"""
return tuple(map(lambda x: getattr(x, attr_name), list(cls))) | python | def _attrs_(mcs, cls, attr_name: str) -> Tuple[Any, ...]:
"""
Returns a tuple containing just the value of the given attr_name of all
the elements from the cls.
:return: tuple of different types
"""
return tuple(map(lambda x: getattr(x, attr_name), list(cls))) | [
"def",
"_attrs_",
"(",
"mcs",
",",
"cls",
",",
"attr_name",
":",
"str",
")",
"->",
"Tuple",
"[",
"Any",
",",
"...",
"]",
":",
"return",
"tuple",
"(",
"map",
"(",
"lambda",
"x",
":",
"getattr",
"(",
"x",
",",
"attr_name",
")",
",",
"list",
"(",
... | Returns a tuple containing just the value of the given attr_name of all
the elements from the cls.
:return: tuple of different types | [
"Returns",
"a",
"tuple",
"containing",
"just",
"the",
"value",
"of",
"the",
"given",
"attr_name",
"of",
"all",
"the",
"elements",
"from",
"the",
"cls",
"."
] | 1179a11358734e5e472e5eee703e8d34fa49e9bf | https://github.com/KnightConan/sspdatatables/blob/1179a11358734e5e472e5eee703e8d34fa49e9bf/src/sspdatatables/utils/enum.py#L55-L62 | train |
KnightConan/sspdatatables | src/sspdatatables/utils/enum.py | ExtendedEnumMeta._from_attr_ | def _from_attr_(mcs, cls, attr_name: str, attr_value: Any) -> TypeVar:
"""
Returns the enumeration item regarding to the attribute name and value,
or None if not found for the given cls
:param attr_name: str: attribute's name
:param attr_value: different values: key to search fo... | python | def _from_attr_(mcs, cls, attr_name: str, attr_value: Any) -> TypeVar:
"""
Returns the enumeration item regarding to the attribute name and value,
or None if not found for the given cls
:param attr_name: str: attribute's name
:param attr_value: different values: key to search fo... | [
"def",
"_from_attr_",
"(",
"mcs",
",",
"cls",
",",
"attr_name",
":",
"str",
",",
"attr_value",
":",
"Any",
")",
"->",
"TypeVar",
":",
"return",
"next",
"(",
"iter",
"(",
"filter",
"(",
"lambda",
"x",
":",
"getattr",
"(",
"x",
",",
"attr_name",
")",
... | Returns the enumeration item regarding to the attribute name and value,
or None if not found for the given cls
:param attr_name: str: attribute's name
:param attr_value: different values: key to search for
:return: Enumeration Item | [
"Returns",
"the",
"enumeration",
"item",
"regarding",
"to",
"the",
"attribute",
"name",
"and",
"value",
"or",
"None",
"if",
"not",
"found",
"for",
"the",
"given",
"cls"
] | 1179a11358734e5e472e5eee703e8d34fa49e9bf | https://github.com/KnightConan/sspdatatables/blob/1179a11358734e5e472e5eee703e8d34fa49e9bf/src/sspdatatables/utils/enum.py#L65-L75 | train |
KnightConan/sspdatatables | src/sspdatatables/utils/enum.py | ExtendedEnum.describe | def describe(cls) -> None:
"""
Prints in the console a table showing all the attributes for all the
definitions inside the class
:return: None
"""
max_lengths = []
for attr_name in cls.attr_names():
attr_func = "%ss" % attr_name
attr_list ... | python | def describe(cls) -> None:
"""
Prints in the console a table showing all the attributes for all the
definitions inside the class
:return: None
"""
max_lengths = []
for attr_name in cls.attr_names():
attr_func = "%ss" % attr_name
attr_list ... | [
"def",
"describe",
"(",
"cls",
")",
"->",
"None",
":",
"max_lengths",
"=",
"[",
"]",
"for",
"attr_name",
"in",
"cls",
".",
"attr_names",
"(",
")",
":",
"attr_func",
"=",
"\"%ss\"",
"%",
"attr_name",
"attr_list",
"=",
"list",
"(",
"map",
"(",
"str",
"... | Prints in the console a table showing all the attributes for all the
definitions inside the class
:return: None | [
"Prints",
"in",
"the",
"console",
"a",
"table",
"showing",
"all",
"the",
"attributes",
"for",
"all",
"the",
"definitions",
"inside",
"the",
"class"
] | 1179a11358734e5e472e5eee703e8d34fa49e9bf | https://github.com/KnightConan/sspdatatables/blob/1179a11358734e5e472e5eee703e8d34fa49e9bf/src/sspdatatables/utils/enum.py#L135-L157 | train |
geophysics-ubonn/crtomo_tools | src/td_plot.py | read_iter | def read_iter(use_fpi):
'''Return the path to the final .mag file either for the complex or the fpi
inversion.
'''
filename_rhosuffix = 'exe/inv.lastmod_rho'
filename = 'exe/inv.lastmod'
# filename HAS to exist. Otherwise the inversion was not finished
if(not os.path.isfile(filename)):
... | python | def read_iter(use_fpi):
'''Return the path to the final .mag file either for the complex or the fpi
inversion.
'''
filename_rhosuffix = 'exe/inv.lastmod_rho'
filename = 'exe/inv.lastmod'
# filename HAS to exist. Otherwise the inversion was not finished
if(not os.path.isfile(filename)):
... | [
"def",
"read_iter",
"(",
"use_fpi",
")",
":",
"filename_rhosuffix",
"=",
"'exe/inv.lastmod_rho'",
"filename",
"=",
"'exe/inv.lastmod'",
"if",
"(",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"filename",
")",
")",
":",
"print",
"(",
"'Inversion was not finished... | Return the path to the final .mag file either for the complex or the fpi
inversion. | [
"Return",
"the",
"path",
"to",
"the",
"final",
".",
"mag",
"file",
"either",
"for",
"the",
"complex",
"or",
"the",
"fpi",
"inversion",
"."
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/td_plot.py#L228-L245 | train |
geophysics-ubonn/crtomo_tools | src/td_plot.py | list_datafiles | def list_datafiles():
'''Get the type of the tomodir and the highest iteration to list all files,
which will be plotted.
'''
is_cplx, is_fpi = td_type()
# get the highest iteration
it_rho = read_iter(is_fpi)
it_phase = read_iter(False)
# list the files
files = ['inv/coverage.mag']
... | python | def list_datafiles():
'''Get the type of the tomodir and the highest iteration to list all files,
which will be plotted.
'''
is_cplx, is_fpi = td_type()
# get the highest iteration
it_rho = read_iter(is_fpi)
it_phase = read_iter(False)
# list the files
files = ['inv/coverage.mag']
... | [
"def",
"list_datafiles",
"(",
")",
":",
"is_cplx",
",",
"is_fpi",
"=",
"td_type",
"(",
")",
"it_rho",
"=",
"read_iter",
"(",
"is_fpi",
")",
"it_phase",
"=",
"read_iter",
"(",
"False",
")",
"files",
"=",
"[",
"'inv/coverage.mag'",
"]",
"dtype",
"=",
"[",
... | Get the type of the tomodir and the highest iteration to list all files,
which will be plotted. | [
"Get",
"the",
"type",
"of",
"the",
"tomodir",
"and",
"the",
"highest",
"iteration",
"to",
"list",
"all",
"files",
"which",
"will",
"be",
"plotted",
"."
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/td_plot.py#L265-L285 | train |
geophysics-ubonn/crtomo_tools | src/td_plot.py | read_datafiles | def read_datafiles(files, dtype, column):
'''Load the datafiles and return cov, mag, phase and fpi phase values.
'''
pha = []
pha_fpi = []
for filename, filetype in zip(files, dtype):
if filetype == 'cov':
cov = load_cov(filename)
elif filetype == 'mag':
mag =... | python | def read_datafiles(files, dtype, column):
'''Load the datafiles and return cov, mag, phase and fpi phase values.
'''
pha = []
pha_fpi = []
for filename, filetype in zip(files, dtype):
if filetype == 'cov':
cov = load_cov(filename)
elif filetype == 'mag':
mag =... | [
"def",
"read_datafiles",
"(",
"files",
",",
"dtype",
",",
"column",
")",
":",
"pha",
"=",
"[",
"]",
"pha_fpi",
"=",
"[",
"]",
"for",
"filename",
",",
"filetype",
"in",
"zip",
"(",
"files",
",",
"dtype",
")",
":",
"if",
"filetype",
"==",
"'cov'",
":... | Load the datafiles and return cov, mag, phase and fpi phase values. | [
"Load",
"the",
"datafiles",
"and",
"return",
"cov",
"mag",
"phase",
"and",
"fpi",
"phase",
"values",
"."
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/td_plot.py#L288-L303 | train |
geophysics-ubonn/crtomo_tools | src/td_plot.py | load_cov | def load_cov(name):
'''Load a datafile with coverage file structure.
'''
content = np.genfromtxt(name, skip_header=1, skip_footer=1, usecols=([2]))
return content | python | def load_cov(name):
'''Load a datafile with coverage file structure.
'''
content = np.genfromtxt(name, skip_header=1, skip_footer=1, usecols=([2]))
return content | [
"def",
"load_cov",
"(",
"name",
")",
":",
"content",
"=",
"np",
".",
"genfromtxt",
"(",
"name",
",",
"skip_header",
"=",
"1",
",",
"skip_footer",
"=",
"1",
",",
"usecols",
"=",
"(",
"[",
"2",
"]",
")",
")",
"return",
"content"
] | Load a datafile with coverage file structure. | [
"Load",
"a",
"datafile",
"with",
"coverage",
"file",
"structure",
"."
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/td_plot.py#L306-L311 | train |
geophysics-ubonn/crtomo_tools | src/td_plot.py | load_rho | def load_rho(name, column):
'''Load a datafile with rho structure like mag and phase
'''
try:
content = np.loadtxt(name, skiprows=1, usecols=([column]))
except:
raise ValueError('Given column to open does not exist.')
return content | python | def load_rho(name, column):
'''Load a datafile with rho structure like mag and phase
'''
try:
content = np.loadtxt(name, skiprows=1, usecols=([column]))
except:
raise ValueError('Given column to open does not exist.')
return content | [
"def",
"load_rho",
"(",
"name",
",",
"column",
")",
":",
"try",
":",
"content",
"=",
"np",
".",
"loadtxt",
"(",
"name",
",",
"skiprows",
"=",
"1",
",",
"usecols",
"=",
"(",
"[",
"column",
"]",
")",
")",
"except",
":",
"raise",
"ValueError",
"(",
... | Load a datafile with rho structure like mag and phase | [
"Load",
"a",
"datafile",
"with",
"rho",
"structure",
"like",
"mag",
"and",
"phase"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/td_plot.py#L314-L322 | train |
geophysics-ubonn/crtomo_tools | src/td_plot.py | calc_complex | def calc_complex(mag, pha):
''' Calculate real and imaginary part of the complex conductivity from
magnitude and phase in log10.
'''
complx = [10 ** m * math.e ** (1j * p / 1e3) for m, p in zip(mag, pha)]
real = [math.log10((1 / c).real) for c in complx]
imag = []
for c in complx:
if... | python | def calc_complex(mag, pha):
''' Calculate real and imaginary part of the complex conductivity from
magnitude and phase in log10.
'''
complx = [10 ** m * math.e ** (1j * p / 1e3) for m, p in zip(mag, pha)]
real = [math.log10((1 / c).real) for c in complx]
imag = []
for c in complx:
if... | [
"def",
"calc_complex",
"(",
"mag",
",",
"pha",
")",
":",
"complx",
"=",
"[",
"10",
"**",
"m",
"*",
"math",
".",
"e",
"**",
"(",
"1j",
"*",
"p",
"/",
"1e3",
")",
"for",
"m",
",",
"p",
"in",
"zip",
"(",
"mag",
",",
"pha",
")",
"]",
"real",
... | Calculate real and imaginary part of the complex conductivity from
magnitude and phase in log10. | [
"Calculate",
"real",
"and",
"imaginary",
"part",
"of",
"the",
"complex",
"conductivity",
"from",
"magnitude",
"and",
"phase",
"in",
"log10",
"."
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/td_plot.py#L325-L338 | train |
geophysics-ubonn/crtomo_tools | src/td_plot.py | plot_ratio | def plot_ratio(cid, ax, plotman, title, alpha, vmin, vmax,
xmin, xmax, zmin, zmax, xunit, cbtiks, elecs):
'''Plot ratio of two conductivity directions.
'''
# handle options
cblabel = 'anisotropy ratio'
zlabel = 'z [' + xunit + ']'
xlabel = 'x [' + xunit + ']'
# cm = 'brg'
... | python | def plot_ratio(cid, ax, plotman, title, alpha, vmin, vmax,
xmin, xmax, zmin, zmax, xunit, cbtiks, elecs):
'''Plot ratio of two conductivity directions.
'''
# handle options
cblabel = 'anisotropy ratio'
zlabel = 'z [' + xunit + ']'
xlabel = 'x [' + xunit + ']'
# cm = 'brg'
... | [
"def",
"plot_ratio",
"(",
"cid",
",",
"ax",
",",
"plotman",
",",
"title",
",",
"alpha",
",",
"vmin",
",",
"vmax",
",",
"xmin",
",",
"xmax",
",",
"zmin",
",",
"zmax",
",",
"xunit",
",",
"cbtiks",
",",
"elecs",
")",
":",
"cblabel",
"=",
"'anisotropy ... | Plot ratio of two conductivity directions. | [
"Plot",
"ratio",
"of",
"two",
"conductivity",
"directions",
"."
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/td_plot.py#L534-L570 | train |
geophysics-ubonn/crtomo_tools | src/td_plot.py | check_minmax | def check_minmax(plotman, cid, xmin, xmax, zmin, zmax, vmin, vmax):
'''Get min and max values for axes and colorbar if not given
'''
if xmin is None:
xmin = plotman.grid.grid['x'].min()
if xmax is None:
xmax = plotman.grid.grid['x'].max()
if zmin is None:
zmin = plotman.grid.... | python | def check_minmax(plotman, cid, xmin, xmax, zmin, zmax, vmin, vmax):
'''Get min and max values for axes and colorbar if not given
'''
if xmin is None:
xmin = plotman.grid.grid['x'].min()
if xmax is None:
xmax = plotman.grid.grid['x'].max()
if zmin is None:
zmin = plotman.grid.... | [
"def",
"check_minmax",
"(",
"plotman",
",",
"cid",
",",
"xmin",
",",
"xmax",
",",
"zmin",
",",
"zmax",
",",
"vmin",
",",
"vmax",
")",
":",
"if",
"xmin",
"is",
"None",
":",
"xmin",
"=",
"plotman",
".",
"grid",
".",
"grid",
"[",
"'x'",
"]",
".",
... | Get min and max values for axes and colorbar if not given | [
"Get",
"min",
"and",
"max",
"values",
"for",
"axes",
"and",
"colorbar",
"if",
"not",
"given"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/td_plot.py#L587-L607 | train |
unt-libraries/pyuntl | pyuntl/highwire_structure.py | citation_director | def citation_director(**kwargs):
"""Direct the citation elements based on their qualifier."""
qualifier = kwargs.get('qualifier', '')
content = kwargs.get('content', '')
if qualifier == 'publicationTitle':
return CitationJournalTitle(content=content)
elif qualifier == 'volume':
retur... | python | def citation_director(**kwargs):
"""Direct the citation elements based on their qualifier."""
qualifier = kwargs.get('qualifier', '')
content = kwargs.get('content', '')
if qualifier == 'publicationTitle':
return CitationJournalTitle(content=content)
elif qualifier == 'volume':
retur... | [
"def",
"citation_director",
"(",
"**",
"kwargs",
")",
":",
"qualifier",
"=",
"kwargs",
".",
"get",
"(",
"'qualifier'",
",",
"''",
")",
"content",
"=",
"kwargs",
".",
"get",
"(",
"'content'",
",",
"''",
")",
"if",
"qualifier",
"==",
"'publicationTitle'",
... | Direct the citation elements based on their qualifier. | [
"Direct",
"the",
"citation",
"elements",
"based",
"on",
"their",
"qualifier",
"."
] | f92413302897dab948aac18ee9e482ace0187bd4 | https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/highwire_structure.py#L237-L252 | train |
unt-libraries/pyuntl | pyuntl/highwire_structure.py | identifier_director | def identifier_director(**kwargs):
"""Direct the identifier elements based on their qualifier."""
qualifier = kwargs.get('qualifier', '')
content = kwargs.get('content', '')
if qualifier == 'ISBN':
return CitationISBN(content=content)
elif qualifier == 'ISSN':
return CitationISSN(con... | python | def identifier_director(**kwargs):
"""Direct the identifier elements based on their qualifier."""
qualifier = kwargs.get('qualifier', '')
content = kwargs.get('content', '')
if qualifier == 'ISBN':
return CitationISBN(content=content)
elif qualifier == 'ISSN':
return CitationISSN(con... | [
"def",
"identifier_director",
"(",
"**",
"kwargs",
")",
":",
"qualifier",
"=",
"kwargs",
".",
"get",
"(",
"'qualifier'",
",",
"''",
")",
"content",
"=",
"kwargs",
".",
"get",
"(",
"'content'",
",",
"''",
")",
"if",
"qualifier",
"==",
"'ISBN'",
":",
"re... | Direct the identifier elements based on their qualifier. | [
"Direct",
"the",
"identifier",
"elements",
"based",
"on",
"their",
"qualifier",
"."
] | f92413302897dab948aac18ee9e482ace0187bd4 | https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/highwire_structure.py#L255-L268 | train |
unt-libraries/pyuntl | pyuntl/highwire_structure.py | CitationAuthor.get_author | def get_author(self, **kwargs):
"""Determine the authors from the creator field."""
qualifier = kwargs.get('qualifier', '')
children = kwargs.get('children', [])
creator_type_per = False
author_name = None
# Find the creator type in children.
for child in children... | python | def get_author(self, **kwargs):
"""Determine the authors from the creator field."""
qualifier = kwargs.get('qualifier', '')
children = kwargs.get('children', [])
creator_type_per = False
author_name = None
# Find the creator type in children.
for child in children... | [
"def",
"get_author",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"qualifier",
"=",
"kwargs",
".",
"get",
"(",
"'qualifier'",
",",
"''",
")",
"children",
"=",
"kwargs",
".",
"get",
"(",
"'children'",
",",
"[",
"]",
")",
"creator_type_per",
"=",
"False",... | Determine the authors from the creator field. | [
"Determine",
"the",
"authors",
"from",
"the",
"creator",
"field",
"."
] | f92413302897dab948aac18ee9e482ace0187bd4 | https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/highwire_structure.py#L52-L68 | train |
unt-libraries/pyuntl | pyuntl/highwire_structure.py | CitationPublisher.get_publisher_name | def get_publisher_name(self, **kwargs):
"""Get the publisher name."""
children = kwargs.get('children', [])
# Find the creator type in children.
for child in children:
if child.tag == 'name':
return child.content
return None | python | def get_publisher_name(self, **kwargs):
"""Get the publisher name."""
children = kwargs.get('children', [])
# Find the creator type in children.
for child in children:
if child.tag == 'name':
return child.content
return None | [
"def",
"get_publisher_name",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"children",
"=",
"kwargs",
".",
"get",
"(",
"'children'",
",",
"[",
"]",
")",
"for",
"child",
"in",
"children",
":",
"if",
"child",
".",
"tag",
"==",
"'name'",
":",
"return",
"c... | Get the publisher name. | [
"Get",
"the",
"publisher",
"name",
"."
] | f92413302897dab948aac18ee9e482ace0187bd4 | https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/highwire_structure.py#L77-L84 | train |
unt-libraries/pyuntl | pyuntl/highwire_structure.py | CitationPublicationDate.get_publication_date | def get_publication_date(self, **kwargs):
"""Determine the creation date for the publication date."""
date_string = kwargs.get('content', '')
date_match = CREATION_DATE_REGEX.match(date_string)
month_match = CREATION_MONTH_REGEX.match(date_string)
year_match = CREATION_YEAR_REGEX... | python | def get_publication_date(self, **kwargs):
"""Determine the creation date for the publication date."""
date_string = kwargs.get('content', '')
date_match = CREATION_DATE_REGEX.match(date_string)
month_match = CREATION_MONTH_REGEX.match(date_string)
year_match = CREATION_YEAR_REGEX... | [
"def",
"get_publication_date",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"date_string",
"=",
"kwargs",
".",
"get",
"(",
"'content'",
",",
"''",
")",
"date_match",
"=",
"CREATION_DATE_REGEX",
".",
"match",
"(",
"date_string",
")",
"month_match",
"=",
"CREAT... | Determine the creation date for the publication date. | [
"Determine",
"the",
"creation",
"date",
"for",
"the",
"publication",
"date",
"."
] | f92413302897dab948aac18ee9e482ace0187bd4 | https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/highwire_structure.py#L93-L129 | train |
unt-libraries/pyuntl | pyuntl/highwire_structure.py | CitationOnlineDate.get_online_date | def get_online_date(self, **kwargs):
"""Get the online date from the meta creation date."""
qualifier = kwargs.get('qualifier', '')
content = kwargs.get('content', '')
# Handle meta-creation-date element.
if qualifier == 'metadataCreationDate':
date_match = META_CREAT... | python | def get_online_date(self, **kwargs):
"""Get the online date from the meta creation date."""
qualifier = kwargs.get('qualifier', '')
content = kwargs.get('content', '')
# Handle meta-creation-date element.
if qualifier == 'metadataCreationDate':
date_match = META_CREAT... | [
"def",
"get_online_date",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"qualifier",
"=",
"kwargs",
".",
"get",
"(",
"'qualifier'",
",",
"''",
")",
"content",
"=",
"kwargs",
".",
"get",
"(",
"'content'",
",",
"''",
")",
"if",
"qualifier",
"==",
"'metadat... | Get the online date from the meta creation date. | [
"Get",
"the",
"online",
"date",
"from",
"the",
"meta",
"creation",
"date",
"."
] | f92413302897dab948aac18ee9e482ace0187bd4 | https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/highwire_structure.py#L138-L153 | train |
unt-libraries/pyuntl | pyuntl/highwire_structure.py | CitationDissertationInstitution.get_institution | def get_institution(self, **kwargs):
"""Get the dissertation institution."""
qualifier = kwargs.get('qualifier', '')
content = kwargs.get('content', '')
if qualifier == 'grantor':
return content
return None | python | def get_institution(self, **kwargs):
"""Get the dissertation institution."""
qualifier = kwargs.get('qualifier', '')
content = kwargs.get('content', '')
if qualifier == 'grantor':
return content
return None | [
"def",
"get_institution",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"qualifier",
"=",
"kwargs",
".",
"get",
"(",
"'qualifier'",
",",
"''",
")",
"content",
"=",
"kwargs",
".",
"get",
"(",
"'content'",
",",
"''",
")",
"if",
"qualifier",
"==",
"'grantor... | Get the dissertation institution. | [
"Get",
"the",
"dissertation",
"institution",
"."
] | f92413302897dab948aac18ee9e482ace0187bd4 | https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/highwire_structure.py#L216-L222 | train |
rhayes777/PyAutoFit | autofit/aggregator.py | PhaseOutput.model_results | def model_results(self) -> str:
"""
Reads the model.results file
"""
with open(os.path.join(self.directory, "model.results")) as f:
return f.read() | python | def model_results(self) -> str:
"""
Reads the model.results file
"""
with open(os.path.join(self.directory, "model.results")) as f:
return f.read() | [
"def",
"model_results",
"(",
"self",
")",
"->",
"str",
":",
"with",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"directory",
",",
"\"model.results\"",
")",
")",
"as",
"f",
":",
"return",
"f",
".",
"read",
"(",
")"
] | Reads the model.results file | [
"Reads",
"the",
"model",
".",
"results",
"file"
] | a9e6144abb08edfc6a6906c4030d7119bf8d3e14 | https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/aggregator.py#L44-L49 | train |
rhayes777/PyAutoFit | autofit/aggregator.py | PhaseOutput.header | def header(self) -> str:
"""
A header created by joining the pipeline, phase and data names
"""
return "/".join((self.pipeline, self.phase, self.data)) | python | def header(self) -> str:
"""
A header created by joining the pipeline, phase and data names
"""
return "/".join((self.pipeline, self.phase, self.data)) | [
"def",
"header",
"(",
"self",
")",
"->",
"str",
":",
"return",
"\"/\"",
".",
"join",
"(",
"(",
"self",
".",
"pipeline",
",",
"self",
".",
"phase",
",",
"self",
".",
"data",
")",
")"
] | A header created by joining the pipeline, phase and data names | [
"A",
"header",
"created",
"by",
"joining",
"the",
"pipeline",
"phase",
"and",
"data",
"names"
] | a9e6144abb08edfc6a6906c4030d7119bf8d3e14 | https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/aggregator.py#L52-L56 | train |
rhayes777/PyAutoFit | autofit/aggregator.py | PhaseOutput.optimizer | def optimizer(self) -> non_linear.NonLinearOptimizer:
"""
The optimizer object that was used in this phase
"""
if self.__optimizer is None:
with open(os.path.join(self.directory, ".optimizer.pickle"), "r+b") as f:
self.__optimizer = pickle.loads(f.read())
... | python | def optimizer(self) -> non_linear.NonLinearOptimizer:
"""
The optimizer object that was used in this phase
"""
if self.__optimizer is None:
with open(os.path.join(self.directory, ".optimizer.pickle"), "r+b") as f:
self.__optimizer = pickle.loads(f.read())
... | [
"def",
"optimizer",
"(",
"self",
")",
"->",
"non_linear",
".",
"NonLinearOptimizer",
":",
"if",
"self",
".",
"__optimizer",
"is",
"None",
":",
"with",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"directory",
",",
"\".optimizer.pickle\"",... | The optimizer object that was used in this phase | [
"The",
"optimizer",
"object",
"that",
"was",
"used",
"in",
"this",
"phase"
] | a9e6144abb08edfc6a6906c4030d7119bf8d3e14 | https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/aggregator.py#L59-L66 | train |
rhayes777/PyAutoFit | autofit/aggregator.py | Aggregator.phases_with | def phases_with(self, **kwargs) -> [PhaseOutput]:
"""
Filters phases. If no arguments are passed all phases are returned. Arguments must be key value pairs, with
phase, data or pipeline as the key.
Parameters
----------
kwargs
Filters, e.g. pipeline=pipeline1... | python | def phases_with(self, **kwargs) -> [PhaseOutput]:
"""
Filters phases. If no arguments are passed all phases are returned. Arguments must be key value pairs, with
phase, data or pipeline as the key.
Parameters
----------
kwargs
Filters, e.g. pipeline=pipeline1... | [
"def",
"phases_with",
"(",
"self",
",",
"**",
"kwargs",
")",
"->",
"[",
"PhaseOutput",
"]",
":",
"return",
"[",
"phase",
"for",
"phase",
"in",
"self",
".",
"phases",
"if",
"all",
"(",
"[",
"getattr",
"(",
"phase",
",",
"key",
")",
"==",
"value",
"f... | Filters phases. If no arguments are passed all phases are returned. Arguments must be key value pairs, with
phase, data or pipeline as the key.
Parameters
----------
kwargs
Filters, e.g. pipeline=pipeline1 | [
"Filters",
"phases",
".",
"If",
"no",
"arguments",
"are",
"passed",
"all",
"phases",
"are",
"returned",
".",
"Arguments",
"must",
"be",
"key",
"value",
"pairs",
"with",
"phase",
"data",
"or",
"pipeline",
"as",
"the",
"key",
"."
] | a9e6144abb08edfc6a6906c4030d7119bf8d3e14 | https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/aggregator.py#L94-L105 | train |
rhayes777/PyAutoFit | autofit/aggregator.py | Aggregator.optimizers_with | def optimizers_with(self, **kwargs) -> [non_linear.NonLinearOptimizer]:
"""
Load a list of optimizers for phases in the directory with zero or more filters applied.
Parameters
----------
kwargs
Filters, e.g. pipeline=pipeline1
Returns
-------
... | python | def optimizers_with(self, **kwargs) -> [non_linear.NonLinearOptimizer]:
"""
Load a list of optimizers for phases in the directory with zero or more filters applied.
Parameters
----------
kwargs
Filters, e.g. pipeline=pipeline1
Returns
-------
... | [
"def",
"optimizers_with",
"(",
"self",
",",
"**",
"kwargs",
")",
"->",
"[",
"non_linear",
".",
"NonLinearOptimizer",
"]",
":",
"return",
"[",
"phase",
".",
"optimizer",
"for",
"phase",
"in",
"self",
".",
"phases_with",
"(",
"**",
"kwargs",
")",
"]"
] | Load a list of optimizers for phases in the directory with zero or more filters applied.
Parameters
----------
kwargs
Filters, e.g. pipeline=pipeline1
Returns
-------
optimizers
A list of optimizers, one for each phase in the directory that match... | [
"Load",
"a",
"list",
"of",
"optimizers",
"for",
"phases",
"in",
"the",
"directory",
"with",
"zero",
"or",
"more",
"filters",
"applied",
"."
] | a9e6144abb08edfc6a6906c4030d7119bf8d3e14 | https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/aggregator.py#L107-L121 | train |
rhayes777/PyAutoFit | autofit/aggregator.py | Aggregator.model_results | def model_results(self, **kwargs) -> str:
"""
Collates model results from all phases in the directory or some subset if filters are applied.
Parameters
----------
kwargs
Filters, e.g. pipeline=pipeline1
Returns
-------
model_results
... | python | def model_results(self, **kwargs) -> str:
"""
Collates model results from all phases in the directory or some subset if filters are applied.
Parameters
----------
kwargs
Filters, e.g. pipeline=pipeline1
Returns
-------
model_results
... | [
"def",
"model_results",
"(",
"self",
",",
"**",
"kwargs",
")",
"->",
"str",
":",
"return",
"\"\\n\\n\"",
".",
"join",
"(",
"\"{}\\n\\n{}\"",
".",
"format",
"(",
"phase",
".",
"header",
",",
"phase",
".",
"model_results",
")",
"for",
"phase",
"in",
"self"... | Collates model results from all phases in the directory or some subset if filters are applied.
Parameters
----------
kwargs
Filters, e.g. pipeline=pipeline1
Returns
-------
model_results
A string joining headers and results for all included phase... | [
"Collates",
"model",
"results",
"from",
"all",
"phases",
"in",
"the",
"directory",
"or",
"some",
"subset",
"if",
"filters",
"are",
"applied",
"."
] | a9e6144abb08edfc6a6906c4030d7119bf8d3e14 | https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/aggregator.py#L123-L138 | train |
peterbe/gg | gg/builtins/branches/gg_branches.py | branches | def branches(config, searchstring=""):
"""List all branches. And if exactly 1 found, offer to check it out."""
repo = config.repo
branches_ = list(find(repo, searchstring))
if branches_:
merged = get_merged_branches(repo)
info_out("Found existing branches...")
print_list(branche... | python | def branches(config, searchstring=""):
"""List all branches. And if exactly 1 found, offer to check it out."""
repo = config.repo
branches_ = list(find(repo, searchstring))
if branches_:
merged = get_merged_branches(repo)
info_out("Found existing branches...")
print_list(branche... | [
"def",
"branches",
"(",
"config",
",",
"searchstring",
"=",
"\"\"",
")",
":",
"repo",
"=",
"config",
".",
"repo",
"branches_",
"=",
"list",
"(",
"find",
"(",
"repo",
",",
"searchstring",
")",
")",
"if",
"branches_",
":",
"merged",
"=",
"get_merged_branch... | List all branches. And if exactly 1 found, offer to check it out. | [
"List",
"all",
"branches",
".",
"And",
"if",
"exactly",
"1",
"found",
"offer",
"to",
"check",
"it",
"out",
"."
] | 2aace5bdb4a9b1cb65bea717784edf54c63b7bad | https://github.com/peterbe/gg/blob/2aace5bdb4a9b1cb65bea717784edf54c63b7bad/gg/builtins/branches/gg_branches.py#L13-L39 | train |
Riminder/python-riminder-api | riminder/base64Wrapper.py | decodebytes | def decodebytes(input):
"""Decode base64 string to byte array."""
py_version = sys.version_info[0]
if py_version >= 3:
return _decodebytes_py3(input)
return _decodebytes_py2(input) | python | def decodebytes(input):
"""Decode base64 string to byte array."""
py_version = sys.version_info[0]
if py_version >= 3:
return _decodebytes_py3(input)
return _decodebytes_py2(input) | [
"def",
"decodebytes",
"(",
"input",
")",
":",
"py_version",
"=",
"sys",
".",
"version_info",
"[",
"0",
"]",
"if",
"py_version",
">=",
"3",
":",
"return",
"_decodebytes_py3",
"(",
"input",
")",
"return",
"_decodebytes_py2",
"(",
"input",
")"
] | Decode base64 string to byte array. | [
"Decode",
"base64",
"string",
"to",
"byte",
"array",
"."
] | 01279f0ece08cf3d1dd45f76de6d9edf7fafec90 | https://github.com/Riminder/python-riminder-api/blob/01279f0ece08cf3d1dd45f76de6d9edf7fafec90/riminder/base64Wrapper.py#L14-L19 | train |
gofed/gofedlib | gofedlib/snapshot/capturer.py | ProjectCapturer.capture | def capture(self, commit = ""):
"""Capture the current state of a project based on its provider
Commit is relevant only for upstream providers.
If empty, the latest commit from provider repository is taken.
It is ignored for distribution providers.
:param provider: project provider, e.g. upstream repository... | python | def capture(self, commit = ""):
"""Capture the current state of a project based on its provider
Commit is relevant only for upstream providers.
If empty, the latest commit from provider repository is taken.
It is ignored for distribution providers.
:param provider: project provider, e.g. upstream repository... | [
"def",
"capture",
"(",
"self",
",",
"commit",
"=",
"\"\"",
")",
":",
"self",
".",
"_validateProvider",
"(",
"self",
".",
"_provider",
")",
"client",
"=",
"RepositoryClientBuilder",
"(",
")",
".",
"buildWithRemoteClient",
"(",
"self",
".",
"_provider",
")",
... | Capture the current state of a project based on its provider
Commit is relevant only for upstream providers.
If empty, the latest commit from provider repository is taken.
It is ignored for distribution providers.
:param provider: project provider, e.g. upstream repository, distribution builder
:type provi... | [
"Capture",
"the",
"current",
"state",
"of",
"a",
"project",
"based",
"on",
"its",
"provider"
] | 0674c248fe3d8706f98f912996b65af469f96b10 | https://github.com/gofed/gofedlib/blob/0674c248fe3d8706f98f912996b65af469f96b10/gofedlib/snapshot/capturer.py#L25-L51 | train |
pgxcentre/geneparse | geneparse/logging.py | found_duplicates | def found_duplicates(counts):
"""Log that duplicates were found.
:param counts: A list of duplicate marker names along with their number
of occurences.
:type counts: list
"""
_logger.warning("Duplicated markers found")
for marker, count in counts:
_logger.warning(" -... | python | def found_duplicates(counts):
"""Log that duplicates were found.
:param counts: A list of duplicate marker names along with their number
of occurences.
:type counts: list
"""
_logger.warning("Duplicated markers found")
for marker, count in counts:
_logger.warning(" -... | [
"def",
"found_duplicates",
"(",
"counts",
")",
":",
"_logger",
".",
"warning",
"(",
"\"Duplicated markers found\"",
")",
"for",
"marker",
",",
"count",
"in",
"counts",
":",
"_logger",
".",
"warning",
"(",
"\" - {}: {:,d} times\"",
".",
"format",
"(",
"marker",
... | Log that duplicates were found.
:param counts: A list of duplicate marker names along with their number
of occurences.
:type counts: list | [
"Log",
"that",
"duplicates",
"were",
"found",
"."
] | f698f9708af4c7962d384a70a5a14006b1cb7108 | https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/logging.py#L45-L57 | train |
lalinsky/mbdata | mbdata/utils/__init__.py | patch_model_schemas | def patch_model_schemas(mapping):
"""Update mbdata.models to use different schema names
The function accepts a dictionary with schema name mapping
and updates the schema for all MusicBrainz tables.
If you want to use the default schema:
>>> patch_model_schemas(NO_SCHEMAS)
If you have just on... | python | def patch_model_schemas(mapping):
"""Update mbdata.models to use different schema names
The function accepts a dictionary with schema name mapping
and updates the schema for all MusicBrainz tables.
If you want to use the default schema:
>>> patch_model_schemas(NO_SCHEMAS)
If you have just on... | [
"def",
"patch_model_schemas",
"(",
"mapping",
")",
":",
"from",
"mbdata",
".",
"models",
"import",
"Base",
"for",
"table",
"in",
"Base",
".",
"metadata",
".",
"sorted_tables",
":",
"if",
"table",
".",
"schema",
"is",
"None",
":",
"continue",
"table",
".",
... | Update mbdata.models to use different schema names
The function accepts a dictionary with schema name mapping
and updates the schema for all MusicBrainz tables.
If you want to use the default schema:
>>> patch_model_schemas(NO_SCHEMAS)
If you have just one 'musicbrainz' schema:
>>> patch_mo... | [
"Update",
"mbdata",
".",
"models",
"to",
"use",
"different",
"schema",
"names"
] | 1ec788834047ced8614ad9763e430afe1d1e65e7 | https://github.com/lalinsky/mbdata/blob/1ec788834047ced8614ad9763e430afe1d1e65e7/mbdata/utils/__init__.py#L21-L41 | train |
Nic30/hwtGraph | hwtGraph/elk/fromHwt/statementRenderer.py | detectRamPorts | def detectRamPorts(stm: IfContainer, current_en: RtlSignalBase):
"""
Detect RAM ports in If statement
:param stm: statement to detect the ram ports in
:param current_en: curent en/clk signal
"""
if stm.ifFalse or stm.elIfs:
return
for _stm in stm.ifTrue:
if isinstance(_stm, ... | python | def detectRamPorts(stm: IfContainer, current_en: RtlSignalBase):
"""
Detect RAM ports in If statement
:param stm: statement to detect the ram ports in
:param current_en: curent en/clk signal
"""
if stm.ifFalse or stm.elIfs:
return
for _stm in stm.ifTrue:
if isinstance(_stm, ... | [
"def",
"detectRamPorts",
"(",
"stm",
":",
"IfContainer",
",",
"current_en",
":",
"RtlSignalBase",
")",
":",
"if",
"stm",
".",
"ifFalse",
"or",
"stm",
".",
"elIfs",
":",
"return",
"for",
"_stm",
"in",
"stm",
".",
"ifTrue",
":",
"if",
"isinstance",
"(",
... | Detect RAM ports in If statement
:param stm: statement to detect the ram ports in
:param current_en: curent en/clk signal | [
"Detect",
"RAM",
"ports",
"in",
"If",
"statement"
] | 6b7d4fdd759f263a0fdd2736f02f123e44e4354f | https://github.com/Nic30/hwtGraph/blob/6b7d4fdd759f263a0fdd2736f02f123e44e4354f/hwtGraph/elk/fromHwt/statementRenderer.py#L42-L67 | train |
Nic30/hwtGraph | hwtGraph/elk/fromHwt/statementRenderer.py | StatementRenderer.addInputPort | def addInputPort(self, node, name,
i: Union[Value, RtlSignalBase],
side=PortSide.WEST):
"""
Add and connect input port on subnode
:param node: node where to add input port
:param name: name of newly added port
:param i: input value
... | python | def addInputPort(self, node, name,
i: Union[Value, RtlSignalBase],
side=PortSide.WEST):
"""
Add and connect input port on subnode
:param node: node where to add input port
:param name: name of newly added port
:param i: input value
... | [
"def",
"addInputPort",
"(",
"self",
",",
"node",
",",
"name",
",",
"i",
":",
"Union",
"[",
"Value",
",",
"RtlSignalBase",
"]",
",",
"side",
"=",
"PortSide",
".",
"WEST",
")",
":",
"root",
"=",
"self",
".",
"node",
"port",
"=",
"node",
".",
"addPort... | Add and connect input port on subnode
:param node: node where to add input port
:param name: name of newly added port
:param i: input value
:param side: side where input port should be added | [
"Add",
"and",
"connect",
"input",
"port",
"on",
"subnode"
] | 6b7d4fdd759f263a0fdd2736f02f123e44e4354f | https://github.com/Nic30/hwtGraph/blob/6b7d4fdd759f263a0fdd2736f02f123e44e4354f/hwtGraph/elk/fromHwt/statementRenderer.py#L99-L149 | train |
Nic30/hwtGraph | hwtGraph/elk/fromHwt/statementRenderer.py | StatementRenderer.addOutputPort | def addOutputPort(self, node: LNode, name: str,
out: Optional[Union[RtlSignalBase, LPort]],
side=PortSide.EAST):
"""
Add and connect output port on subnode
"""
oPort = node.addPort(name, PortType.OUTPUT, side)
if out is not None:
... | python | def addOutputPort(self, node: LNode, name: str,
out: Optional[Union[RtlSignalBase, LPort]],
side=PortSide.EAST):
"""
Add and connect output port on subnode
"""
oPort = node.addPort(name, PortType.OUTPUT, side)
if out is not None:
... | [
"def",
"addOutputPort",
"(",
"self",
",",
"node",
":",
"LNode",
",",
"name",
":",
"str",
",",
"out",
":",
"Optional",
"[",
"Union",
"[",
"RtlSignalBase",
",",
"LPort",
"]",
"]",
",",
"side",
"=",
"PortSide",
".",
"EAST",
")",
":",
"oPort",
"=",
"no... | Add and connect output port on subnode | [
"Add",
"and",
"connect",
"output",
"port",
"on",
"subnode"
] | 6b7d4fdd759f263a0fdd2736f02f123e44e4354f | https://github.com/Nic30/hwtGraph/blob/6b7d4fdd759f263a0fdd2736f02f123e44e4354f/hwtGraph/elk/fromHwt/statementRenderer.py#L151-L178 | train |
Nic30/hwtGraph | hwtGraph/elk/fromHwt/statementRenderer.py | StatementRenderer.renderContent | def renderContent(self):
"""
Walk from outputs to inputs
for each public signal register port of wrap node if required
lazy load all operator and statement nodes for signals
"""
stm = self.stm
portCtx = self.portCtx
# for each inputs and outputs render exp... | python | def renderContent(self):
"""
Walk from outputs to inputs
for each public signal register port of wrap node if required
lazy load all operator and statement nodes for signals
"""
stm = self.stm
portCtx = self.portCtx
# for each inputs and outputs render exp... | [
"def",
"renderContent",
"(",
"self",
")",
":",
"stm",
"=",
"self",
".",
"stm",
"portCtx",
"=",
"self",
".",
"portCtx",
"for",
"o",
"in",
"stm",
".",
"_outputs",
":",
"if",
"not",
"self",
".",
"isVirtual",
":",
"portCtx",
".",
"register",
"(",
"o",
... | Walk from outputs to inputs
for each public signal register port of wrap node if required
lazy load all operator and statement nodes for signals | [
"Walk",
"from",
"outputs",
"to",
"inputs",
"for",
"each",
"public",
"signal",
"register",
"port",
"of",
"wrap",
"node",
"if",
"required",
"lazy",
"load",
"all",
"operator",
"and",
"statement",
"nodes",
"for",
"signals"
] | 6b7d4fdd759f263a0fdd2736f02f123e44e4354f | https://github.com/Nic30/hwtGraph/blob/6b7d4fdd759f263a0fdd2736f02f123e44e4354f/hwtGraph/elk/fromHwt/statementRenderer.py#L385-L425 | train |
gofed/gofedlib | gofedlib/distribution/packagenamegenerator.py | PackageNameGenerator.generate | def generate(self, project):
"""
Package name construction is based on provider, not on prefix.
Prefix does not have to equal provider_prefix.
"""
for assignment in self.s2n_mapping:
if assignment["ipprefix"] == project:
self._name = assignment["package"]
return self
#
# github.com -> github
... | python | def generate(self, project):
"""
Package name construction is based on provider, not on prefix.
Prefix does not have to equal provider_prefix.
"""
for assignment in self.s2n_mapping:
if assignment["ipprefix"] == project:
self._name = assignment["package"]
return self
#
# github.com -> github
... | [
"def",
"generate",
"(",
"self",
",",
"project",
")",
":",
"for",
"assignment",
"in",
"self",
".",
"s2n_mapping",
":",
"if",
"assignment",
"[",
"\"ipprefix\"",
"]",
"==",
"project",
":",
"self",
".",
"_name",
"=",
"assignment",
"[",
"\"package\"",
"]",
"r... | Package name construction is based on provider, not on prefix.
Prefix does not have to equal provider_prefix. | [
"Package",
"name",
"construction",
"is",
"based",
"on",
"provider",
"not",
"on",
"prefix",
".",
"Prefix",
"does",
"not",
"have",
"to",
"equal",
"provider_prefix",
"."
] | 0674c248fe3d8706f98f912996b65af469f96b10 | https://github.com/gofed/gofedlib/blob/0674c248fe3d8706f98f912996b65af469f96b10/gofedlib/distribution/packagenamegenerator.py#L9-L59 | train |
NikolayDachev/jadm | lib/paramiko-1.14.1/paramiko/hostkeys.py | HostKeys.hash_host | def hash_host(hostname, salt=None):
"""
Return a "hashed" form of the hostname, as used by OpenSSH when storing
hashed hostnames in the known_hosts file.
:param str hostname: the hostname to hash
:param str salt: optional salt to use when hashing (must be 20 bytes long)
... | python | def hash_host(hostname, salt=None):
"""
Return a "hashed" form of the hostname, as used by OpenSSH when storing
hashed hostnames in the known_hosts file.
:param str hostname: the hostname to hash
:param str salt: optional salt to use when hashing (must be 20 bytes long)
... | [
"def",
"hash_host",
"(",
"hostname",
",",
"salt",
"=",
"None",
")",
":",
"if",
"salt",
"is",
"None",
":",
"salt",
"=",
"os",
".",
"urandom",
"(",
"sha1",
"(",
")",
".",
"digest_size",
")",
"else",
":",
"if",
"salt",
".",
"startswith",
"(",
"'|1|'",... | Return a "hashed" form of the hostname, as used by OpenSSH when storing
hashed hostnames in the known_hosts file.
:param str hostname: the hostname to hash
:param str salt: optional salt to use when hashing (must be 20 bytes long)
:return: the hashed hostname as a `str` | [
"Return",
"a",
"hashed",
"form",
"of",
"the",
"hostname",
"as",
"used",
"by",
"OpenSSH",
"when",
"storing",
"hashed",
"hostnames",
"in",
"the",
"known_hosts",
"file",
"."
] | 12bb550445edfcd87506f7cba7a6a35d413c5511 | https://github.com/NikolayDachev/jadm/blob/12bb550445edfcd87506f7cba7a6a35d413c5511/lib/paramiko-1.14.1/paramiko/hostkeys.py#L258-L276 | train |
geophysics-ubonn/crtomo_tools | lib/crtomo/grid.py | crt_grid._read_elem_nodes | def _read_elem_nodes(self, fid):
""" Read the nodes from an opened elem.dat file. Correct for CutMcK
transformations.
We store three typed of nodes in the dict 'nodes':
* "raw" : as read from the elem.dat file
* "presort" : pre-sorted so we can directly read node number... | python | def _read_elem_nodes(self, fid):
""" Read the nodes from an opened elem.dat file. Correct for CutMcK
transformations.
We store three typed of nodes in the dict 'nodes':
* "raw" : as read from the elem.dat file
* "presort" : pre-sorted so we can directly read node number... | [
"def",
"_read_elem_nodes",
"(",
"self",
",",
"fid",
")",
":",
"nodes",
"=",
"{",
"}",
"nodes_raw",
"=",
"np",
".",
"empty",
"(",
"(",
"self",
".",
"header",
"[",
"'nr_nodes'",
"]",
",",
"3",
")",
",",
"dtype",
"=",
"float",
")",
"for",
"nr",
"in"... | Read the nodes from an opened elem.dat file. Correct for CutMcK
transformations.
We store three typed of nodes in the dict 'nodes':
* "raw" : as read from the elem.dat file
* "presort" : pre-sorted so we can directly read node numbers from
a elec.dat file and use ... | [
"Read",
"the",
"nodes",
"from",
"an",
"opened",
"elem",
".",
"dat",
"file",
".",
"Correct",
"for",
"CutMcK",
"transformations",
"."
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/grid.py#L160-L229 | train |
geophysics-ubonn/crtomo_tools | lib/crtomo/grid.py | crt_grid.calculate_dimensions | def calculate_dimensions(self):
"""For a regular grid, calculate the element and node dimensions
"""
x_coordinates = np.sort(self.grid['x'][:, 0]) # first x node
self.nr_nodes_z = np.where(x_coordinates == x_coordinates[0])[0].size
self.nr_elements_x = self.elements.shape[0] / (... | python | def calculate_dimensions(self):
"""For a regular grid, calculate the element and node dimensions
"""
x_coordinates = np.sort(self.grid['x'][:, 0]) # first x node
self.nr_nodes_z = np.where(x_coordinates == x_coordinates[0])[0].size
self.nr_elements_x = self.elements.shape[0] / (... | [
"def",
"calculate_dimensions",
"(",
"self",
")",
":",
"x_coordinates",
"=",
"np",
".",
"sort",
"(",
"self",
".",
"grid",
"[",
"'x'",
"]",
"[",
":",
",",
"0",
"]",
")",
"self",
".",
"nr_nodes_z",
"=",
"np",
".",
"where",
"(",
"x_coordinates",
"==",
... | For a regular grid, calculate the element and node dimensions | [
"For",
"a",
"regular",
"grid",
"calculate",
"the",
"element",
"and",
"node",
"dimensions"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/grid.py#L306-L313 | train |
geophysics-ubonn/crtomo_tools | lib/crtomo/grid.py | crt_grid._read_elem_neighbors | def _read_elem_neighbors(self, fid):
"""Read the boundary-element-neighbors from the end of the file
"""
# get number of boundary elements
# types 11 and 12 are boundary elements
sizes = sum([len(self.element_data[key]) for key in (11, 12) if
self.element_dat... | python | def _read_elem_neighbors(self, fid):
"""Read the boundary-element-neighbors from the end of the file
"""
# get number of boundary elements
# types 11 and 12 are boundary elements
sizes = sum([len(self.element_data[key]) for key in (11, 12) if
self.element_dat... | [
"def",
"_read_elem_neighbors",
"(",
"self",
",",
"fid",
")",
":",
"sizes",
"=",
"sum",
"(",
"[",
"len",
"(",
"self",
".",
"element_data",
"[",
"key",
"]",
")",
"for",
"key",
"in",
"(",
"11",
",",
"12",
")",
"if",
"self",
".",
"element_data",
".",
... | Read the boundary-element-neighbors from the end of the file | [
"Read",
"the",
"boundary",
"-",
"element",
"-",
"neighbors",
"from",
"the",
"end",
"of",
"the",
"file"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/grid.py#L330-L343 | train |
geophysics-ubonn/crtomo_tools | lib/crtomo/grid.py | crt_grid.load_grid | def load_grid(self, elem_file, elec_file):
"""Load elem.dat and elec.dat
"""
self.load_elem_file(elem_file)
self.load_elec_file(elec_file) | python | def load_grid(self, elem_file, elec_file):
"""Load elem.dat and elec.dat
"""
self.load_elem_file(elem_file)
self.load_elec_file(elec_file) | [
"def",
"load_grid",
"(",
"self",
",",
"elem_file",
",",
"elec_file",
")",
":",
"self",
".",
"load_elem_file",
"(",
"elem_file",
")",
"self",
".",
"load_elec_file",
"(",
"elec_file",
")"
] | Load elem.dat and elec.dat | [
"Load",
"elem",
".",
"dat",
"and",
"elec",
".",
"dat"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/grid.py#L411-L415 | train |
geophysics-ubonn/crtomo_tools | lib/crtomo/grid.py | crt_grid.get_element_centroids | def get_element_centroids(self):
"""return the central points of all elements
Returns
-------
Nx2 array
x/z coordinates for all (N) elements
"""
centroids = np.vstack((
np.mean(self.grid['x'], axis=1), np.mean(self.grid['z'], axis=1)
)).T
... | python | def get_element_centroids(self):
"""return the central points of all elements
Returns
-------
Nx2 array
x/z coordinates for all (N) elements
"""
centroids = np.vstack((
np.mean(self.grid['x'], axis=1), np.mean(self.grid['z'], axis=1)
)).T
... | [
"def",
"get_element_centroids",
"(",
"self",
")",
":",
"centroids",
"=",
"np",
".",
"vstack",
"(",
"(",
"np",
".",
"mean",
"(",
"self",
".",
"grid",
"[",
"'x'",
"]",
",",
"axis",
"=",
"1",
")",
",",
"np",
".",
"mean",
"(",
"self",
".",
"grid",
... | return the central points of all elements
Returns
-------
Nx2 array
x/z coordinates for all (N) elements | [
"return",
"the",
"central",
"points",
"of",
"all",
"elements"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/grid.py#L494-L506 | train |
geophysics-ubonn/crtomo_tools | lib/crtomo/grid.py | crt_grid.get_internal_angles | def get_internal_angles(self):
"""Compute all internal angles of the grid
Returns
-------
numpy.ndarray
NxK array with N the number of elements, and K the number of nodes,
filled with the internal angles in degrees
"""
angles = []
for el... | python | def get_internal_angles(self):
"""Compute all internal angles of the grid
Returns
-------
numpy.ndarray
NxK array with N the number of elements, and K the number of nodes,
filled with the internal angles in degrees
"""
angles = []
for el... | [
"def",
"get_internal_angles",
"(",
"self",
")",
":",
"angles",
"=",
"[",
"]",
"for",
"elx",
",",
"elz",
"in",
"zip",
"(",
"self",
".",
"grid",
"[",
"'x'",
"]",
",",
"self",
".",
"grid",
"[",
"'z'",
"]",
")",
":",
"el_angles",
"=",
"[",
"]",
"xy... | Compute all internal angles of the grid
Returns
-------
numpy.ndarray
NxK array with N the number of elements, and K the number of nodes,
filled with the internal angles in degrees | [
"Compute",
"all",
"internal",
"angles",
"of",
"the",
"grid"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/grid.py#L519-L547 | train |
geophysics-ubonn/crtomo_tools | lib/crtomo/grid.py | crt_grid.Wm | def Wm(self):
"""Return the smoothing regularization matrix Wm of the grid
"""
centroids = self.get_element_centroids()
Wm = scipy.sparse.csr_matrix(
(self.nr_of_elements, self.nr_of_elements))
# Wm = np.zeros((self.nr_of_elements, self.nr_of_elements))
for ... | python | def Wm(self):
"""Return the smoothing regularization matrix Wm of the grid
"""
centroids = self.get_element_centroids()
Wm = scipy.sparse.csr_matrix(
(self.nr_of_elements, self.nr_of_elements))
# Wm = np.zeros((self.nr_of_elements, self.nr_of_elements))
for ... | [
"def",
"Wm",
"(",
"self",
")",
":",
"centroids",
"=",
"self",
".",
"get_element_centroids",
"(",
")",
"Wm",
"=",
"scipy",
".",
"sparse",
".",
"csr_matrix",
"(",
"(",
"self",
".",
"nr_of_elements",
",",
"self",
".",
"nr_of_elements",
")",
")",
"for",
"i... | Return the smoothing regularization matrix Wm of the grid | [
"Return",
"the",
"smoothing",
"regularization",
"matrix",
"Wm",
"of",
"the",
"grid"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/grid.py#L672-L694 | train |
geophysics-ubonn/crtomo_tools | lib/crtomo/tdManager.py | tdMan.create_tomodir | def create_tomodir(self, directory):
"""Create a tomodir subdirectory structure in the given directory
"""
pwd = os.getcwd()
if not os.path.isdir(directory):
os.makedirs(directory)
os.chdir(directory)
directories = (
'config',
'exe',
... | python | def create_tomodir(self, directory):
"""Create a tomodir subdirectory structure in the given directory
"""
pwd = os.getcwd()
if not os.path.isdir(directory):
os.makedirs(directory)
os.chdir(directory)
directories = (
'config',
'exe',
... | [
"def",
"create_tomodir",
"(",
"self",
",",
"directory",
")",
":",
"pwd",
"=",
"os",
".",
"getcwd",
"(",
")",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"directory",
")",
":",
"os",
".",
"makedirs",
"(",
"directory",
")",
"os",
".",
"chdir",... | Create a tomodir subdirectory structure in the given directory | [
"Create",
"a",
"tomodir",
"subdirectory",
"structure",
"in",
"the",
"given",
"directory"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L260-L281 | train |
geophysics-ubonn/crtomo_tools | lib/crtomo/tdManager.py | tdMan.load_rho_file | def load_rho_file(self, filename):
"""Load a forward model from a rho.dat file
Parameters
----------
filename: string
filename to rho.dat file
Returns
-------
pid_mag: int
parameter id for the magnitude model
pid_pha: int
... | python | def load_rho_file(self, filename):
"""Load a forward model from a rho.dat file
Parameters
----------
filename: string
filename to rho.dat file
Returns
-------
pid_mag: int
parameter id for the magnitude model
pid_pha: int
... | [
"def",
"load_rho_file",
"(",
"self",
",",
"filename",
")",
":",
"pids",
"=",
"self",
".",
"parman",
".",
"load_from_rho_file",
"(",
"filename",
")",
"self",
".",
"register_magnitude_model",
"(",
"pids",
"[",
"0",
"]",
")",
"self",
".",
"register_phase_model"... | Load a forward model from a rho.dat file
Parameters
----------
filename: string
filename to rho.dat file
Returns
-------
pid_mag: int
parameter id for the magnitude model
pid_pha: int
parameter id for the phase model | [
"Load",
"a",
"forward",
"model",
"from",
"a",
"rho",
".",
"dat",
"file"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L295-L314 | train |
geophysics-ubonn/crtomo_tools | lib/crtomo/tdManager.py | tdMan.save_to_tomodir | def save_to_tomodir(self, directory):
"""Save the tomodir instance to a directory structure.
Note
----
Test cases:
* modeling only
* inversion only
* modeling and inversion
"""
self.create_tomodir(directory)
self.grid.save_... | python | def save_to_tomodir(self, directory):
"""Save the tomodir instance to a directory structure.
Note
----
Test cases:
* modeling only
* inversion only
* modeling and inversion
"""
self.create_tomodir(directory)
self.grid.save_... | [
"def",
"save_to_tomodir",
"(",
"self",
",",
"directory",
")",
":",
"self",
".",
"create_tomodir",
"(",
"directory",
")",
"self",
".",
"grid",
".",
"save_elem_file",
"(",
"directory",
"+",
"os",
".",
"sep",
"+",
"'grid/elem.dat'",
")",
"self",
".",
"grid",
... | Save the tomodir instance to a directory structure.
Note
----
Test cases:
* modeling only
* inversion only
* modeling and inversion | [
"Save",
"the",
"tomodir",
"instance",
"to",
"a",
"directory",
"structure",
"."
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L316-L383 | train |
geophysics-ubonn/crtomo_tools | lib/crtomo/tdManager.py | tdMan._save_sensitivities | def _save_sensitivities(self, directory):
"""save sensitivities to a directory
"""
print('saving sensitivities')
digits = int(np.ceil(np.log10(self.configs.configs.shape[0])))
for i in range(0, self.configs.configs.shape[0]):
sens_data, meta_data = self.get_sensitivit... | python | def _save_sensitivities(self, directory):
"""save sensitivities to a directory
"""
print('saving sensitivities')
digits = int(np.ceil(np.log10(self.configs.configs.shape[0])))
for i in range(0, self.configs.configs.shape[0]):
sens_data, meta_data = self.get_sensitivit... | [
"def",
"_save_sensitivities",
"(",
"self",
",",
"directory",
")",
":",
"print",
"(",
"'saving sensitivities'",
")",
"digits",
"=",
"int",
"(",
"np",
".",
"ceil",
"(",
"np",
".",
"log10",
"(",
"self",
".",
"configs",
".",
"configs",
".",
"shape",
"[",
"... | save sensitivities to a directory | [
"save",
"sensitivities",
"to",
"a",
"directory"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L385-L407 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.