repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 3
values | summary stringlengths 4 350 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
peterbe/gg | gg/main.py | cli | def cli(config, configfile, verbose):
"""A glorious command line tool to make your life with git, GitHub
and Bugzilla much easier."""
config.verbose = verbose
config.configfile = configfile
if not os.path.isfile(configfile):
state.write(configfile, {}) | python | def cli(config, configfile, verbose):
"""A glorious command line tool to make your life with git, GitHub
and Bugzilla much easier."""
config.verbose = verbose
config.configfile = configfile
if not os.path.isfile(configfile):
state.write(configfile, {}) | [
"def",
"cli",
"(",
"config",
",",
"configfile",
",",
"verbose",
")",
":",
"config",
".",
"verbose",
"=",
"verbose",
"config",
".",
"configfile",
"=",
"configfile",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"configfile",
")",
":",
"state",
"."... | A glorious command line tool to make your life with git, GitHub
and Bugzilla much easier. | [
"A",
"glorious",
"command",
"line",
"tool",
"to",
"make",
"your",
"life",
"with",
"git",
"GitHub",
"and",
"Bugzilla",
"much",
"easier",
"."
] | 2aace5bdb4a9b1cb65bea717784edf54c63b7bad | https://github.com/peterbe/gg/blob/2aace5bdb4a9b1cb65bea717784edf54c63b7bad/gg/main.py#L36-L42 | train | A glorious command line tool to make your life with git GitHub
and Bugzilla much easier. |
ghukill/pyfc4 | pyfc4/models.py | Repository.parse_uri | def parse_uri(self, uri=None):
'''
parses and cleans up possible uri inputs, return instance of rdflib.term.URIRef
Args:
uri (rdflib.term.URIRef,str): input URI
Returns:
rdflib.term.URIRef
'''
# no uri provided, assume root
if not uri:
return rdflib.term.URIRef(self.root)
# string uri prov... | python | def parse_uri(self, uri=None):
'''
parses and cleans up possible uri inputs, return instance of rdflib.term.URIRef
Args:
uri (rdflib.term.URIRef,str): input URI
Returns:
rdflib.term.URIRef
'''
# no uri provided, assume root
if not uri:
return rdflib.term.URIRef(self.root)
# string uri prov... | [
"def",
"parse_uri",
"(",
"self",
",",
"uri",
"=",
"None",
")",
":",
"# no uri provided, assume root",
"if",
"not",
"uri",
":",
"return",
"rdflib",
".",
"term",
".",
"URIRef",
"(",
"self",
".",
"root",
")",
"# string uri provided",
"elif",
"type",
"(",
"uri... | parses and cleans up possible uri inputs, return instance of rdflib.term.URIRef
Args:
uri (rdflib.term.URIRef,str): input URI
Returns:
rdflib.term.URIRef | [
"parses",
"and",
"cleans",
"up",
"possible",
"uri",
"inputs",
"return",
"instance",
"of",
"rdflib",
".",
"term",
".",
"URIRef"
] | 59011df592f08978c4a901a908862d112a5dcf02 | https://github.com/ghukill/pyfc4/blob/59011df592f08978c4a901a908862d112a5dcf02/pyfc4/models.py#L105-L138 | train | parse_uri parses and cleans up possible uri inputs |
ghukill/pyfc4 | pyfc4/models.py | Repository.create_resource | def create_resource(self, resource_type=None, uri=None):
'''
Convenience method for creating a new resource
Note: A Resource is instantiated, but is not yet created. Still requires resource.create().
Args:
uri (rdflib.term.URIRef, str): uri of resource to create
resource_type (NonRDFSource (Binary), B... | python | def create_resource(self, resource_type=None, uri=None):
'''
Convenience method for creating a new resource
Note: A Resource is instantiated, but is not yet created. Still requires resource.create().
Args:
uri (rdflib.term.URIRef, str): uri of resource to create
resource_type (NonRDFSource (Binary), B... | [
"def",
"create_resource",
"(",
"self",
",",
"resource_type",
"=",
"None",
",",
"uri",
"=",
"None",
")",
":",
"if",
"resource_type",
"in",
"[",
"NonRDFSource",
",",
"Binary",
",",
"BasicContainer",
",",
"DirectContainer",
",",
"IndirectContainer",
"]",
":",
"... | Convenience method for creating a new resource
Note: A Resource is instantiated, but is not yet created. Still requires resource.create().
Args:
uri (rdflib.term.URIRef, str): uri of resource to create
resource_type (NonRDFSource (Binary), BasicContainer, DirectContainer, IndirectContainer): resource type... | [
"Convenience",
"method",
"for",
"creating",
"a",
"new",
"resource"
] | 59011df592f08978c4a901a908862d112a5dcf02 | https://github.com/ghukill/pyfc4/blob/59011df592f08978c4a901a908862d112a5dcf02/pyfc4/models.py#L141-L159 | train | Create a new resource in the RDF database. |
ghukill/pyfc4 | pyfc4/models.py | Repository.get_resource | def get_resource(self, uri, resource_type=None, response_format=None):
'''
Retrieve resource:
- Issues an initial GET request
- If 200, continues, 404, returns False, otherwise raises Exception
- Parse resource type
- If custom resource type parser provided, this fires
- Else, or if custom parser ... | python | def get_resource(self, uri, resource_type=None, response_format=None):
'''
Retrieve resource:
- Issues an initial GET request
- If 200, continues, 404, returns False, otherwise raises Exception
- Parse resource type
- If custom resource type parser provided, this fires
- Else, or if custom parser ... | [
"def",
"get_resource",
"(",
"self",
",",
"uri",
",",
"resource_type",
"=",
"None",
",",
"response_format",
"=",
"None",
")",
":",
"# handle uri",
"uri",
"=",
"self",
".",
"parse_uri",
"(",
"uri",
")",
"# remove fcr:metadata if included, as handled below",
"if",
... | Retrieve resource:
- Issues an initial GET request
- If 200, continues, 404, returns False, otherwise raises Exception
- Parse resource type
- If custom resource type parser provided, this fires
- Else, or if custom parser misses, fire HEAD request and parse LDP resource type from Link header
- Retu... | [
"Retrieve",
"resource",
":",
"-",
"Issues",
"an",
"initial",
"GET",
"request",
"-",
"If",
"200",
"continues",
"404",
"returns",
"False",
"otherwise",
"raises",
"Exception",
"-",
"Parse",
"resource",
"type",
"-",
"If",
"custom",
"resource",
"type",
"parser",
... | 59011df592f08978c4a901a908862d112a5dcf02 | https://github.com/ghukill/pyfc4/blob/59011df592f08978c4a901a908862d112a5dcf02/pyfc4/models.py#L162-L226 | train | Get a resource from the repository |
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 no name provided, create one",
"if",
"not",
"txn_name",
":",
"txn_name",
"=",
"uuid",
".",
"uuid4",
"(",
")",
".",
"hex",
"# request new transaction",
"txn_response",
"=",
"self",
"... | 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 | start a new transaction from repository |
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",
")",
":",
"# parse uri",
"txn_uri",
"=",
"self",
".",
"parse_uri",
"(",
"txn_uri",
")",
"# request new transaction",
"txn_response",
"=",
"self",
".",
"api",
".",
"http_request",
"(",
"'GET'",
"... | 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 | Retrieves a known transaction and adds it to self. txns. |
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",
")",
":",
"# keep transaction alive",
"txn_response",
"=",
"self",
".",
"api",
".",
"http_request",
"(",
"'POST'",
",",
"'%sfcr:tx'",
"%",
"self",
".",
"root",
",",
"data",
"=",
"None",
",",
"headers",
"=",
"None",
")",
... | 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 | keep alive transaction |
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",
")",
":",
"# commit transaction",
"txn_response",
"=",
"self",
".",
"api",
".",
"http_request",
"(",
"'POST'",
",",
"'%sfcr:tx/fcr:%s'",
"%",
"(",
"self",
".",
"root",
",",
"close_type",
")",
",",
"data",
"=... | 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 | Closes a transaction. |
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 | This function is used to make HTTP requests to the repository. |
ghukill/pyfc4 | pyfc4/models.py | API.parse_resource_type | def parse_resource_type(self, response):
'''
parse resource type from self.http_request()
Note: uses isinstance() as plugins may extend these base LDP resource type.
Args:
response (requests.models.Response): response object
Returns:
[NonRDFSource, BasicContainer, DirectContainer, IndirectContainer]... | python | def parse_resource_type(self, response):
'''
parse resource type from self.http_request()
Note: uses isinstance() as plugins may extend these base LDP resource type.
Args:
response (requests.models.Response): response object
Returns:
[NonRDFSource, BasicContainer, DirectContainer, IndirectContainer]... | [
"def",
"parse_resource_type",
"(",
"self",
",",
"response",
")",
":",
"# parse 'Link' header",
"links",
"=",
"[",
"link",
".",
"split",
"(",
"\";\"",
")",
"[",
"0",
"]",
".",
"lstrip",
"(",
"'<'",
")",
".",
"rstrip",
"(",
"'>'",
")",
"for",
"link",
"... | parse resource type from self.http_request()
Note: uses isinstance() as plugins may extend these base LDP resource type.
Args:
response (requests.models.Response): response object
Returns:
[NonRDFSource, BasicContainer, DirectContainer, IndirectContainer] | [
"parse",
"resource",
"type",
"from",
"self",
".",
"http_request",
"()"
] | 59011df592f08978c4a901a908862d112a5dcf02 | https://github.com/ghukill/pyfc4/blob/59011df592f08978c4a901a908862d112a5dcf02/pyfc4/models.py#L540-L582 | train | parse resource type from response object |
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",
")",
":",
"# handle edge case for content-types not recognized by rdflib parser",
"if",
"headers",
"[",
"'Content-Type'",
"]",
".",
"startswith",
"(",
"'text/plain'",
")",
":",
"logger",
".",
"debug... | 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 | parse RDF payloads from various repository endpoints |
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",
")",
":",
"# iterate through graphs and get unique namespace uris",
"for",
"graph",
"in",
"[",
"self",
".",
"diffs",
".",
"overlap",
",",
"self",
".",
"diffs",
".",
"removed",
",",
"self",
".",
"diffs",
".",
"added",
"... | 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 | Internal method to identify unique namespace URIs in the update_namespaces and update_prefixes dictionary. |
ghukill/pyfc4 | pyfc4/models.py | SparqlUpdate.build_query | def build_query(self):
'''
Using the three graphs derived from self._diff_graph(), build a sparql update query in the format:
PREFIX foo: <http://foo.com>
PREFIX bar: <http://bar.com>
DELETE {...}
INSERT {...}
WHERE {...}
Args:
None: uses variables from self
Returns:
(str) sparql update que... | python | def build_query(self):
'''
Using the three graphs derived from self._diff_graph(), build a sparql update query in the format:
PREFIX foo: <http://foo.com>
PREFIX bar: <http://bar.com>
DELETE {...}
INSERT {...}
WHERE {...}
Args:
None: uses variables from self
Returns:
(str) sparql update que... | [
"def",
"build_query",
"(",
"self",
")",
":",
"# derive namespaces to include prefixes in Sparql update query",
"self",
".",
"_derive_namespaces",
"(",
")",
"sparql_query",
"=",
"''",
"# add prefixes",
"for",
"ns_prefix",
",",
"ns_uri",
"in",
"self",
".",
"update_prefixe... | Using the three graphs derived from self._diff_graph(), build a sparql update query in the format:
PREFIX foo: <http://foo.com>
PREFIX bar: <http://bar.com>
DELETE {...}
INSERT {...}
WHERE {...}
Args:
None: uses variables from self
Returns:
(str) sparql update query as string | [
"Using",
"the",
"three",
"graphs",
"derived",
"from",
"self",
".",
"_diff_graph",
"()",
"build",
"a",
"sparql",
"update",
"query",
"in",
"the",
"format",
":"
] | 59011df592f08978c4a901a908862d112a5dcf02 | https://github.com/ghukill/pyfc4/blob/59011df592f08978c4a901a908862d112a5dcf02/pyfc4/models.py#L678-L722 | train | Build a SPARQL query string from the diff graph |
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",
"# resource exists",
"if",
... | 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 | check if resource exists update self. exists |
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 resource claims existence, raise excepti... | 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 | This method creates a new resource in the repository. |
ghukill/pyfc4 | pyfc4/models.py | Resource._handle_create | def _handle_create(self, response, ignore_tombstone, auto_refresh):
'''
Handles response from self.create()
Args:
response (requests.models.Response): response object from self.create()
ignore_tombstone (bool): If True, will attempt creation, if tombstone exists (409), will delete tombstone and retry
''... | python | def _handle_create(self, response, ignore_tombstone, auto_refresh):
'''
Handles response from self.create()
Args:
response (requests.models.Response): response object from self.create()
ignore_tombstone (bool): If True, will attempt creation, if tombstone exists (409), will delete tombstone and retry
''... | [
"def",
"_handle_create",
"(",
"self",
",",
"response",
",",
"ignore_tombstone",
",",
"auto_refresh",
")",
":",
"# 201, success, refresh",
"if",
"response",
".",
"status_code",
"==",
"201",
":",
"# if not specifying uri, capture from response and append to object",
"self",
... | Handles response from self.create()
Args:
response (requests.models.Response): response object from self.create()
ignore_tombstone (bool): If True, will attempt creation, if tombstone exists (409), will delete tombstone and retry | [
"Handles",
"response",
"from",
"self",
".",
"create",
"()"
] | 59011df592f08978c4a901a908862d112a5dcf02 | https://github.com/ghukill/pyfc4/blob/59011df592f08978c4a901a908862d112a5dcf02/pyfc4/models.py#L872-L925 | train | Handles create requests. |
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",
")",
":",
"# http request",
"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 | get
Small method to return headers of an OPTIONS request to self. uri
None
Return |
ghukill/pyfc4 | pyfc4/models.py | Resource.move | def move(self, destination, remove_tombstone=True):
'''
Method to move resource to another location.
Note: by default, this method removes the tombstone at the resource's original URI.
Can use optional flag remove_tombstone to keep tombstone on successful move.
Note: other resource's triples that are manage... | python | def move(self, destination, remove_tombstone=True):
'''
Method to move resource to another location.
Note: by default, this method removes the tombstone at the resource's original URI.
Can use optional flag remove_tombstone to keep tombstone on successful move.
Note: other resource's triples that are manage... | [
"def",
"move",
"(",
"self",
",",
"destination",
",",
"remove_tombstone",
"=",
"True",
")",
":",
"# set move headers",
"destination_uri",
"=",
"self",
".",
"repo",
".",
"parse_uri",
"(",
"destination",
")",
"# http request",
"response",
"=",
"self",
".",
"repo"... | Method to move resource to another location.
Note: by default, this method removes the tombstone at the resource's original URI.
Can use optional flag remove_tombstone to keep tombstone on successful move.
Note: other resource's triples that are managed by Fedora that point to this resource,
*will* point to th... | [
"Method",
"to",
"move",
"resource",
"to",
"another",
"location",
".",
"Note",
":",
"by",
"default",
"this",
"method",
"removes",
"the",
"tombstone",
"at",
"the",
"resource",
"s",
"original",
"URI",
".",
"Can",
"use",
"optional",
"flag",
"remove_tombstone",
"... | 59011df592f08978c4a901a908862d112a5dcf02 | https://github.com/ghukill/pyfc4/blob/59011df592f08978c4a901a908862d112a5dcf02/pyfc4/models.py#L945-L983 | train | Method to move resource to another location. |
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",
")",
":",
"# set move headers",
"destination_uri",
"=",
"self",
".",
"repo",
".",
"parse_uri",
"(",
"destination",
")",
"# http request",
"response",
"=",
"self",
".",
"repo",
".",
"api",
".",
"http_request",
"... | 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 | Copy resource to another location |
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",
")",
"# update exists",
"if",
"response",
".",
"status_code",
"... | 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 | Delete the resource. |
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 resource type of updated_self != self, raise exception",
"if",
"not",
"isinstance",
"(",... | 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 | Refreshes the RDF information for this resource. |
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",
")",
":",
"# recreate rdf data",
"self",
".",
"rdf",
"=",
"SimpleNamespace",
"(",
")",
"self",
".",
"rdf",
".",
"data",
"=",
"data",
"self",
".",
"rdf",
".",
"prefixes",
"=",
"SimpleNamespace",
... | 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 | Build RDF graph from incoming RDF content. |
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 resource exists, parse self.rdf.data",
"if",
"self",
".",
"exists",
":",
"self",
".",
"rdf",
".",
"graph",
"=",
"self",
".",
"repo",
".",
"api",
".",
"parse_rdf_payload",
"(",
"self",
".",
"rdf",
".",
"da... | 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 | parse the RDF graph of the resource |
ghukill/pyfc4 | pyfc4/models.py | Resource._diff_graph | def _diff_graph(self):
'''
Uses rdflib.compare diff, https://github.com/RDFLib/rdflib/blob/master/rdflib/compare.py
When a resource is retrieved, the graph retrieved and parsed at that time is saved to self.rdf._orig_graph,
and all local modifications are made to self.rdf.graph. This method compares the two g... | python | def _diff_graph(self):
'''
Uses rdflib.compare diff, https://github.com/RDFLib/rdflib/blob/master/rdflib/compare.py
When a resource is retrieved, the graph retrieved and parsed at that time is saved to self.rdf._orig_graph,
and all local modifications are made to self.rdf.graph. This method compares the two g... | [
"def",
"_diff_graph",
"(",
"self",
")",
":",
"overlap",
",",
"removed",
",",
"added",
"=",
"graph_diff",
"(",
"to_isomorphic",
"(",
"self",
".",
"rdf",
".",
"_orig_graph",
")",
",",
"to_isomorphic",
"(",
"self",
".",
"rdf",
".",
"graph",
")",
")",
"dif... | Uses rdflib.compare diff, https://github.com/RDFLib/rdflib/blob/master/rdflib/compare.py
When a resource is retrieved, the graph retrieved and parsed at that time is saved to self.rdf._orig_graph,
and all local modifications are made to self.rdf.graph. This method compares the two graphs and returns the diff
in ... | [
"Uses",
"rdflib",
".",
"compare",
"diff",
"https",
":",
"//",
"github",
".",
"com",
"/",
"RDFLib",
"/",
"rdflib",
"/",
"blob",
"/",
"master",
"/",
"rdflib",
"/",
"compare",
".",
"py",
"When",
"a",
"resource",
"is",
"retrieved",
"the",
"graph",
"retriev... | 59011df592f08978c4a901a908862d112a5dcf02 | https://github.com/ghukill/pyfc4/blob/59011df592f08978c4a901a908862d112a5dcf02/pyfc4/models.py#L1178-L1206 | train | This method compares the graph and returns the diff in a simple format that can be used to build a sparql update query. |
ghukill/pyfc4 | pyfc4/models.py | Resource.add_namespace | def add_namespace(self, ns_prefix, ns_uri):
'''
preferred method is to instantiate with repository under 'context',
but prefixes / namespaces can be added for a Resource instance
adds to self.rdf.prefixes which will endure through create/update/refresh,
and get added back to parsed graph namespaces
Args:... | python | def add_namespace(self, ns_prefix, ns_uri):
'''
preferred method is to instantiate with repository under 'context',
but prefixes / namespaces can be added for a Resource instance
adds to self.rdf.prefixes which will endure through create/update/refresh,
and get added back to parsed graph namespaces
Args:... | [
"def",
"add_namespace",
"(",
"self",
",",
"ns_prefix",
",",
"ns_uri",
")",
":",
"# add to prefixes",
"setattr",
"(",
"self",
".",
"rdf",
".",
"prefixes",
",",
"ns_prefix",
",",
"rdflib",
".",
"Namespace",
"(",
"ns_uri",
")",
")",
"# bind to graph",
"self",
... | preferred method is to instantiate with repository under 'context',
but prefixes / namespaces can be added for a Resource instance
adds to self.rdf.prefixes which will endure through create/update/refresh,
and get added back to parsed graph namespaces
Args:
ns_prefix (str): prefix for namespace, e.g. 'dc',... | [
"preferred",
"method",
"is",
"to",
"instantiate",
"with",
"repository",
"under",
"context",
"but",
"prefixes",
"/",
"namespaces",
"can",
"be",
"added",
"for",
"a",
"Resource",
"instance"
] | 59011df592f08978c4a901a908862d112a5dcf02 | https://github.com/ghukill/pyfc4/blob/59011df592f08978c4a901a908862d112a5dcf02/pyfc4/models.py#L1209-L1230 | train | add a new namespace to the current context |
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",
"# build RDF",
"self",
".",
"rdf",
"=",
"self",
".",
"_build_rdf",
"(",
")",
... | 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 | empty resource attributes |
ghukill/pyfc4 | pyfc4/models.py | Resource._handle_object | def _handle_object(self, object_input):
'''
Method to handle possible values passed for adding, removing, modifying triples.
Detects type of input and sets appropriate http://www.w3.org/2001/XMLSchema# datatype
Args:
object_input (str,int,datetime,): many possible inputs
Returns:
(rdflib.term.Literal... | python | def _handle_object(self, object_input):
'''
Method to handle possible values passed for adding, removing, modifying triples.
Detects type of input and sets appropriate http://www.w3.org/2001/XMLSchema# datatype
Args:
object_input (str,int,datetime,): many possible inputs
Returns:
(rdflib.term.Literal... | [
"def",
"_handle_object",
"(",
"self",
",",
"object_input",
")",
":",
"# if object is string, convert to rdflib.term.Literal with appropriate datatype",
"if",
"type",
"(",
"object_input",
")",
"==",
"str",
":",
"return",
"rdflib",
".",
"term",
".",
"Literal",
"(",
"obj... | Method to handle possible values passed for adding, removing, modifying triples.
Detects type of input and sets appropriate http://www.w3.org/2001/XMLSchema# datatype
Args:
object_input (str,int,datetime,): many possible inputs
Returns:
(rdflib.term.Literal): with appropriate datatype attribute | [
"Method",
"to",
"handle",
"possible",
"values",
"passed",
"for",
"adding",
"removing",
"modifying",
"triples",
".",
"Detects",
"type",
"of",
"input",
"and",
"sets",
"appropriate",
"http",
":",
"//",
"www",
".",
"w3",
".",
"org",
"/",
"2001",
"/",
"XMLSchem... | 59011df592f08978c4a901a908862d112a5dcf02 | https://github.com/ghukill/pyfc4/blob/59011df592f08978c4a901a908862d112a5dcf02/pyfc4/models.py#L1257-L1287 | train | This method handles the object input and returns the object representation. |
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 | Adds a triple to the graph |
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 | Sets the triple p to o in the graph. |
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 | Removes a triple from the graph at the given predicate and object. |
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 set, and True, refresh",
"if",
"auto_refresh",
":",
"self",
".",
"parse_object_like_triples",
"(",
")",
"# else, if auto_refresh is not set (None), check repository instance default",
... | 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 | handle triple refresh |
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",
")",
":",
"# run diff on graphs, send as PATCH request",
"self",
".",
"_diff_graph",
"(",
")",
"sq",
"=",
"SparqlUpdate",
"... | 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 | This method updates the resource in repository. |
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 | method to return hierarchical children of this resource |
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 | method to return hierarchical parents of this resource |
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",
"(",
")",
"# loop through parents and get children",
"for",
"parent",
"in",
"self",
".",
"parents",
"(",
"as_resources",
"=",
"True",
")",
":",
"for",
"sibli... | 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 | get the siblings of this resource |
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",
")",
":",
"# create version",
"version_response",
"=",
"self",
".",
"repo",
".",
"api",
".",
"http_request",
"(",
"'POST'",
",",
"'%s/fcr:versions'",
"%",
"self",
".",
"uri",
",",
"data",
"=",
"None... | 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 | This method creates a new version of the resource. |
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",
")",
":",
"# get all versions",
"versions_response",
"=",
"self",
".",
"repo",
".",
"api",
".",
"http_request",
"(",
"'GET'",
",",
"'%s/fcr:versions'",
"%",
"self",
".",
"uri",
")",
"# parse response",
"versions_graph",
"=",
... | 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 | get all versions of an object and store them at self. versions
|
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 | Dump the current resource to RDF data. |
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",
")",
":",
"# send patch",
"response",
"=",
"self",
".",
"resource",
".",
"repo",
".",
"api",
".",
"http_request",
"(",
"'PATCH'",
",",
"self",
".",
"uri",
")",
"# if response 204",
"if",
"response",
".",
"status_code",
"=="... | 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 | method to revert resource to this version by issuing PATCH request and refreshes parent resource handle
self. _current_resource. refresh |
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",
")",
":",
"# send patch",
"response",
"=",
"self",
".",
"resource",
".",
"repo",
".",
"api",
".",
"http_request",
"(",
"'DELETE'",
",",
"self",
".",
"uri",
")",
"# if response 204",
"if",
"response",
".",
"status_code",
"==",
... | 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 | method to delete resource version from history
|
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 | Empty the object attributes. |
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 | This method is used to refresh the binary attributes and data of the resource. |
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",
")",
":",
"# derive mimetype",
"self",
".",
"mimetype",
"=",
"self",
".",
"resource",
".",
"rdf",
".",
"graph",
".",
"value",
"(",
"self",
".",
"resource",
".",
"uri",
",",
"self",
".",
"resource",
".",
"rdf",
".",
... | 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 | parse binary data and make available
via generators
self |
ghukill/pyfc4 | pyfc4/models.py | BinaryData._prep_binary_mimetype | def _prep_binary_mimetype(self):
'''
Sets Content-Type header based on headers and/or self.binary.mimetype values
Implicitly favors Content-Type header if set
Args:
None
Returns:
None: sets attributes in self.binary and headers
'''
# neither present
if not self.mimetype and 'Content-Type' not ... | python | def _prep_binary_mimetype(self):
'''
Sets Content-Type header based on headers and/or self.binary.mimetype values
Implicitly favors Content-Type header if set
Args:
None
Returns:
None: sets attributes in self.binary and headers
'''
# neither present
if not self.mimetype and 'Content-Type' not ... | [
"def",
"_prep_binary_mimetype",
"(",
"self",
")",
":",
"# neither present",
"if",
"not",
"self",
".",
"mimetype",
"and",
"'Content-Type'",
"not",
"in",
"self",
".",
"resource",
".",
"headers",
".",
"keys",
"(",
")",
":",
"raise",
"Exception",
"(",
"'to creat... | Sets Content-Type header based on headers and/or self.binary.mimetype values
Implicitly favors Content-Type header if set
Args:
None
Returns:
None: sets attributes in self.binary and headers | [
"Sets",
"Content",
"-",
"Type",
"header",
"based",
"on",
"headers",
"and",
"/",
"or",
"self",
".",
"binary",
".",
"mimetype",
"values",
"Implicitly",
"favors",
"Content",
"-",
"Type",
"header",
"if",
"set"
] | 59011df592f08978c4a901a908862d112a5dcf02 | https://github.com/ghukill/pyfc4/blob/59011df592f08978c4a901a908862d112a5dcf02/pyfc4/models.py#L1761-L1782 | train | Sets the Content - Type header based on the mimetype of the binary resource. |
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",
")",
":",
"# nothing present",
"if",
"not",
"self",
".",
"data",
"and",
"not",
"self",
".",
"location",
"and",
"'Content-Location'",
"not",
"in",
"self",
".",
"resource",
".",
"headers",
".",
"keys",
"(",
")",
":... | 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 | Sets delivery method of either payload or header depending on the type of data and location. |
ghukill/pyfc4 | pyfc4/models.py | BinaryData.range | def range(self, byte_start, byte_end, stream=True):
'''
method to return a particular byte range from NonRDF resource's binary data
https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
Args:
byte_start(int): position of range start
byte_end(int): position of range end
Returns:
(requests.Respons... | python | def range(self, byte_start, byte_end, stream=True):
'''
method to return a particular byte range from NonRDF resource's binary data
https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
Args:
byte_start(int): position of range start
byte_end(int): position of range end
Returns:
(requests.Respons... | [
"def",
"range",
"(",
"self",
",",
"byte_start",
",",
"byte_end",
",",
"stream",
"=",
"True",
")",
":",
"response",
"=",
"self",
".",
"resource",
".",
"repo",
".",
"api",
".",
"http_request",
"(",
"'GET'",
",",
"self",
".",
"resource",
".",
"uri",
","... | method to return a particular byte range from NonRDF resource's binary data
https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
Args:
byte_start(int): position of range start
byte_end(int): position of range end
Returns:
(requests.Response): streamable response | [
"method",
"to",
"return",
"a",
"particular",
"byte",
"range",
"from",
"NonRDF",
"resource",
"s",
"binary",
"data",
"https",
":",
"//",
"www",
".",
"w3",
".",
"org",
"/",
"Protocols",
"/",
"rfc2616",
"/",
"rfc2616",
"-",
"sec14",
".",
"html"
] | 59011df592f08978c4a901a908862d112a5dcf02 | https://github.com/ghukill/pyfc4/blob/59011df592f08978c4a901a908862d112a5dcf02/pyfc4/models.py#L1829-L1859 | train | This method returns a particular byte range from the NonRDF resource s binary data. |
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 no response_format, use default",
"if",
"not",
"response_format",
":",
"response_format",
"=",
"self",
".",
"repo",
".",
"default_serialization",
"# issue GET request for fixity check",
"... | 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 | This method returns parsed graph from a fixity check |
sleibman/python-conduit | conduit/core.py | topological_sort | def topological_sort(channels):
"""
Topological sort returns an ordered list of blocks.
Sorting guarantee is that if block A is upstream of block B, block A will come before block B in the sorted list.
Sorting is implemented by first building a shadow copy of the graph and then removing items from the s... | python | def topological_sort(channels):
"""
Topological sort returns an ordered list of blocks.
Sorting guarantee is that if block A is upstream of block B, block A will come before block B in the sorted list.
Sorting is implemented by first building a shadow copy of the graph and then removing items from the s... | [
"def",
"topological_sort",
"(",
"channels",
")",
":",
"sorted_shadow_blocks",
"=",
"[",
"]",
"block_table",
"=",
"{",
"}",
"shadow_table",
"=",
"{",
"}",
"blocks_without_predecessors",
"=",
"set",
"(",
")",
"graph_heads",
"=",
"[",
"]",
"# Create shadow version ... | Topological sort returns an ordered list of blocks.
Sorting guarantee is that if block A is upstream of block B, block A will come before block B in the sorted list.
Sorting is implemented by first building a shadow copy of the graph and then removing items from the shadow graph
one by one as we find items ... | [
"Topological",
"sort",
"returns",
"an",
"ordered",
"list",
"of",
"blocks",
".",
"Sorting",
"guarantee",
"is",
"that",
"if",
"block",
"A",
"is",
"upstream",
"of",
"block",
"B",
"block",
"A",
"will",
"come",
"before",
"block",
"B",
"in",
"the",
"sorted",
"... | f6002d45c4f25e4418591a72fdac9ac6fb422d80 | https://github.com/sleibman/python-conduit/blob/f6002d45c4f25e4418591a72fdac9ac6fb422d80/conduit/core.py#L740-L783 | train | Topological sort returns a list of blocks in the given channels. |
sleibman/python-conduit | conduit/core.py | executed_block_set | def executed_block_set(trace):
"""
Given an execution trace, returns a python set object containing the names of each block for which the user code
was executed. Block names can be set via set_debug_name().
"""
executed_set = set()
for entry in trace:
if entry[0] == 'execute':
... | python | def executed_block_set(trace):
"""
Given an execution trace, returns a python set object containing the names of each block for which the user code
was executed. Block names can be set via set_debug_name().
"""
executed_set = set()
for entry in trace:
if entry[0] == 'execute':
... | [
"def",
"executed_block_set",
"(",
"trace",
")",
":",
"executed_set",
"=",
"set",
"(",
")",
"for",
"entry",
"in",
"trace",
":",
"if",
"entry",
"[",
"0",
"]",
"==",
"'execute'",
":",
"executed_set",
".",
"add",
"(",
"entry",
"[",
"get_trace_index",
"(",
... | Given an execution trace, returns a python set object containing the names of each block for which the user code
was executed. Block names can be set via set_debug_name(). | [
"Given",
"an",
"execution",
"trace",
"returns",
"a",
"python",
"set",
"object",
"containing",
"the",
"names",
"of",
"each",
"block",
"for",
"which",
"the",
"user",
"code",
"was",
"executed",
".",
"Block",
"names",
"can",
"be",
"set",
"via",
"set_debug_name",... | f6002d45c4f25e4418591a72fdac9ac6fb422d80 | https://github.com/sleibman/python-conduit/blob/f6002d45c4f25e4418591a72fdac9ac6fb422d80/conduit/core.py#L794-L803 | train | Given an execution trace returns a python set containing the names of each block for which the user code was executed. |
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 | Returns the value of the attribute. |
sleibman/python-conduit | conduit/core.py | DataBlock._before_valid_time_range | def _before_valid_time_range(self):
"""
In case of uncertainty (times not specified), we assume that we are in a valid range.
"""
if self.start_time is not None:
try:
if self.time < self.start_time:
return True
except TypeError:... | python | def _before_valid_time_range(self):
"""
In case of uncertainty (times not specified), we assume that we are in a valid range.
"""
if self.start_time is not None:
try:
if self.time < self.start_time:
return True
except TypeError:... | [
"def",
"_before_valid_time_range",
"(",
"self",
")",
":",
"if",
"self",
".",
"start_time",
"is",
"not",
"None",
":",
"try",
":",
"if",
"self",
".",
"time",
"<",
"self",
".",
"start_time",
":",
"return",
"True",
"except",
"TypeError",
":",
"return",
"Fals... | In case of uncertainty (times not specified), we assume that we are in a valid range. | [
"In",
"case",
"of",
"uncertainty",
"(",
"times",
"not",
"specified",
")",
"we",
"assume",
"that",
"we",
"are",
"in",
"a",
"valid",
"range",
"."
] | f6002d45c4f25e4418591a72fdac9ac6fb422d80 | https://github.com/sleibman/python-conduit/blob/f6002d45c4f25e4418591a72fdac9ac6fb422d80/conduit/core.py#L240-L250 | train | Returns True if we are in a valid time range False otherwise. |
sleibman/python-conduit | conduit/core.py | DataBlock._after_valid_time_range | def _after_valid_time_range(self):
"""
In case of uncertainty (times not specified), we assume that we are in a valid range.
"""
if self.end_time is not None:
try:
if self.time > self.end_time:
return True
except TypeError:
... | python | def _after_valid_time_range(self):
"""
In case of uncertainty (times not specified), we assume that we are in a valid range.
"""
if self.end_time is not None:
try:
if self.time > self.end_time:
return True
except TypeError:
... | [
"def",
"_after_valid_time_range",
"(",
"self",
")",
":",
"if",
"self",
".",
"end_time",
"is",
"not",
"None",
":",
"try",
":",
"if",
"self",
".",
"time",
">",
"self",
".",
"end_time",
":",
"return",
"True",
"except",
"TypeError",
":",
"return",
"False",
... | In case of uncertainty (times not specified), we assume that we are in a valid range. | [
"In",
"case",
"of",
"uncertainty",
"(",
"times",
"not",
"specified",
")",
"we",
"assume",
"that",
"we",
"are",
"in",
"a",
"valid",
"range",
"."
] | f6002d45c4f25e4418591a72fdac9ac6fb422d80 | https://github.com/sleibman/python-conduit/blob/f6002d45c4f25e4418591a72fdac9ac6fb422d80/conduit/core.py#L252-L262 | train | Returns True if the time is after the end time of the uncertainty. |
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 | Set the input data for the given key. |
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 | Returns the output channel object for the given output channel name. |
sleibman/python-conduit | conduit/core.py | DataBlock.step | def step(self, trace):
"""
Returns a set of DataBlocks whose inputs were updated. This will be used by the Graph run() method to invoke
the step() method of the next blocks in the chain (we don't invoke those call the step() method of those
blocks directly from here, because then the sta... | python | def step(self, trace):
"""
Returns a set of DataBlocks whose inputs were updated. This will be used by the Graph run() method to invoke
the step() method of the next blocks in the chain (we don't invoke those call the step() method of those
blocks directly from here, because then the sta... | [
"def",
"step",
"(",
"self",
",",
"trace",
")",
":",
"downstream_blocks",
"=",
"[",
"]",
"# Restrict the set of input channels we consider to those that are active (a channel is typically deactivated",
"# before it starts producing useful data, and after it has reached the end of useful dat... | Returns a set of DataBlocks whose inputs were updated. This will be used by the Graph run() method to invoke
the step() method of the next blocks in the chain (we don't invoke those call the step() method of those
blocks directly from here, because then the stack could get quite large). | [
"Returns",
"a",
"set",
"of",
"DataBlocks",
"whose",
"inputs",
"were",
"updated",
".",
"This",
"will",
"be",
"used",
"by",
"the",
"Graph",
"run",
"()",
"method",
"to",
"invoke",
"the",
"step",
"()",
"method",
"of",
"the",
"next",
"blocks",
"in",
"the",
... | f6002d45c4f25e4418591a72fdac9ac6fb422d80 | https://github.com/sleibman/python-conduit/blob/f6002d45c4f25e4418591a72fdac9ac6fb422d80/conduit/core.py#L391-L488 | train | This method is called by the Graph class to perform the step of the main graph step. |
sleibman/python-conduit | conduit/core.py | GeneratorBlock.block_code | def block_code(self):
inputs = self._get_all_input_values()
outputs = {}
"""
self.f = self.user_function(**inputs)
try:
outputs = self.f.send(inputs)
except StopIteration:
self.terminate()
"""
if self.first_time:
self.f ... | python | def block_code(self):
inputs = self._get_all_input_values()
outputs = {}
"""
self.f = self.user_function(**inputs)
try:
outputs = self.f.send(inputs)
except StopIteration:
self.terminate()
"""
if self.first_time:
self.f ... | [
"def",
"block_code",
"(",
"self",
")",
":",
"inputs",
"=",
"self",
".",
"_get_all_input_values",
"(",
")",
"outputs",
"=",
"{",
"}",
"if",
"self",
".",
"first_time",
":",
"self",
".",
"f",
"=",
"self",
".",
"user_function",
"(",
"*",
"*",
"inputs",
"... | self.f = self.user_function(**inputs)
try:
outputs = self.f.send(inputs)
except StopIteration:
self.terminate() | [
"self",
".",
"f",
"=",
"self",
".",
"user_function",
"(",
"**",
"inputs",
")",
"try",
":",
"outputs",
"=",
"self",
".",
"f",
".",
"send",
"(",
"inputs",
")",
"except",
"StopIteration",
":",
"self",
".",
"terminate",
"()"
] | f6002d45c4f25e4418591a72fdac9ac6fb422d80 | https://github.com/sleibman/python-conduit/blob/f6002d45c4f25e4418591a72fdac9ac6fb422d80/conduit/core.py#L560-L584 | train | Block code for the user. |
adamhadani/python-yelp | yelp/api.py | HttpApiClient._http_request | def _http_request(self, base_url, **kwargs):
"""
Perform an HTTP Request using base_url and parameters
given by kwargs.
Results are expected to be given in JSON format
and are parsed to python data structures.
"""
# Build our URI
request_params = urlenco... | python | def _http_request(self, base_url, **kwargs):
"""
Perform an HTTP Request using base_url and parameters
given by kwargs.
Results are expected to be given in JSON format
and are parsed to python data structures.
"""
# Build our URI
request_params = urlenco... | [
"def",
"_http_request",
"(",
"self",
",",
"base_url",
",",
"*",
"*",
"kwargs",
")",
":",
"# Build our URI",
"request_params",
"=",
"urlencode",
"(",
"kwargs",
")",
"uri",
"=",
"u'%s?%s&ywsid=%s&output=%s'",
"%",
"(",
"base_url",
",",
"request_params",
",",
"se... | Perform an HTTP Request using base_url and parameters
given by kwargs.
Results are expected to be given in JSON format
and are parsed to python data structures. | [
"Perform",
"an",
"HTTP",
"Request",
"using",
"base_url",
"and",
"parameters",
"given",
"by",
"kwargs",
".",
"Results",
"are",
"expected",
"to",
"be",
"given",
"in",
"JSON",
"format",
"and",
"are",
"parsed",
"to",
"python",
"data",
"structures",
"."
] | 7694ccb7274cc3c5783250ed0c3396cda2fcfa1a | https://github.com/adamhadani/python-yelp/blob/7694ccb7274cc3c5783250ed0c3396cda2fcfa1a/yelp/api.py#L68-L85 | train | Perform an HTTP request using base_url and parameters
|
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 | Perform a Review Search based on a bounding box. |
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 | Perform a Review Search based on a geopoint and radius tuple. |
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 | Perform a Yelp Review Search based on a location specifier. |
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 | Perform a Yelp Phone API Search based on phone number given. |
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 | Perform a Yelp Neighborhood API Search based on a geopoint. |
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 | Perform a Yelp Neighborhood API Search based on a location specifier. |
eventifyio/eventify | eventify/drivers/zeromq.py | Component.run | def run(self):
"""
start component
"""
loop = asyncio.get_event_loop()
if loop.is_closed():
asyncio.set_event_loop(asyncio.new_event_loop())
loop = asyncio.get_event_loop()
txaio.start_logging()
loop.run_until_complete(self.onConnect()) | python | def run(self):
"""
start component
"""
loop = asyncio.get_event_loop()
if loop.is_closed():
asyncio.set_event_loop(asyncio.new_event_loop())
loop = asyncio.get_event_loop()
txaio.start_logging()
loop.run_until_complete(self.onConnect()) | [
"def",
"run",
"(",
"self",
")",
":",
"loop",
"=",
"asyncio",
".",
"get_event_loop",
"(",
")",
"if",
"loop",
".",
"is_closed",
"(",
")",
":",
"asyncio",
".",
"set_event_loop",
"(",
"asyncio",
".",
"new_event_loop",
"(",
")",
")",
"loop",
"=",
"asyncio",... | start component | [
"start",
"component"
] | 0e519964a56bd07a879b266f21f177749c63aaed | https://github.com/eventifyio/eventify/blob/0e519964a56bd07a879b266f21f177749c63aaed/eventify/drivers/zeromq.py#L40-L50 | train | start component
|
eventifyio/eventify | eventify/drivers/zeromq.py | Component.emit_event | async def emit_event(self, event):
"""
Publish an event
:param event: Event object
"""
self.log.info("publishing event on %s", self.publish_topic)
if self.config.extra['config']['pub_options']['retain']:
try:
await persist_event(
... | python | async def emit_event(self, event):
"""
Publish an event
:param event: Event object
"""
self.log.info("publishing event on %s", self.publish_topic)
if self.config.extra['config']['pub_options']['retain']:
try:
await persist_event(
... | [
"async",
"def",
"emit_event",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"\"publishing event on %s\"",
",",
"self",
".",
"publish_topic",
")",
"if",
"self",
".",
"config",
".",
"extra",
"[",
"'config'",
"]",
"[",
"'pub_opt... | Publish an event
:param event: Event object | [
"Publish",
"an",
"event",
":",
"param",
"event",
":",
"Event",
"object"
] | 0e519964a56bd07a879b266f21f177749c63aaed | https://github.com/eventifyio/eventify/blob/0e519964a56bd07a879b266f21f177749c63aaed/eventify/drivers/zeromq.py#L60-L77 | train | Publish an event to the broker. |
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 | Check if zeromq socket is available on transport host |
eventifyio/eventify | eventify/drivers/zeromq.py | Service.start | def start(self):
"""
Start a producer/consumer service
"""
component = Component(self.config, self.handlers)
component.run() | python | def start(self):
"""
Start a producer/consumer service
"""
component = Component(self.config, self.handlers)
component.run() | [
"def",
"start",
"(",
"self",
")",
":",
"component",
"=",
"Component",
"(",
"self",
".",
"config",
",",
"self",
".",
"handlers",
")",
"component",
".",
"run",
"(",
")"
] | Start a producer/consumer service | [
"Start",
"a",
"producer",
"/",
"consumer",
"service"
] | 0e519964a56bd07a879b266f21f177749c63aaed | https://github.com/eventifyio/eventify/blob/0e519964a56bd07a879b266f21f177749c63aaed/eventify/drivers/zeromq.py#L142-L147 | train | Start a producer or consumer service |
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 | Upload a series of samples. |
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 | Records results on hyperchamber. io. Used when you are done testing a config. |
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 | Moves the selection of gunicorns to the next one. |
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 | Update the dictionary of gunicorns. |
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 | Handle a keypress event. |
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 | Formats a single row of text. |
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",
"(",
")",
"# Sets up the screen width.",
"screen_height",
"=",
"len",
"(",
"gunicorns",
")",
"+",
"len",
"(",
"instructions",
".",
"split",
"(",
"\"\\n\"",
")",
")",
"+",
"9",
"if",
"not",
"gu... | 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 | Display the gunicorn menu list. |
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",
"(",
")",
":",
"# Set up curses.",
"stdscr",
"=",
"curses",
".",
"initscr",
"(",
")",
"curses",
".",
"start_color",
"(",
")",
"curses",
".",
"init_pair",
"(",
"1",
",",
"foreground_colour",
",",
"background_colour",
")",
"curses",
".",
"noec... | 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 | Main entry point for gunicorn_console. |
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 | Gets a variant from the parser while disabling logging. |
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 | Returns a tuple containing just the value of the given attr_name of all
the elements from the cls. |
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 | Returns the enumeration item regarding to the attribute name and value attr_value. |
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 | Prints in the console a table showing all the attributes for all the class holding the class. |
geophysics-ubonn/crtomo_tools | src/td_plot.py | handle_options | def handle_options():
'''Handle options.
'''
parser = OptionParser()
parser.set_defaults(cmaglin=False)
parser.set_defaults(single=False)
parser.set_defaults(aniso=False)
parser.set_defaults(hlam=False)
parser.set_defaults(alpha_cov=False)
# general options
parser.add_option("--s... | python | def handle_options():
'''Handle options.
'''
parser = OptionParser()
parser.set_defaults(cmaglin=False)
parser.set_defaults(single=False)
parser.set_defaults(aniso=False)
parser.set_defaults(hlam=False)
parser.set_defaults(alpha_cov=False)
# general options
parser.add_option("--s... | [
"def",
"handle_options",
"(",
")",
":",
"parser",
"=",
"OptionParser",
"(",
")",
"parser",
".",
"set_defaults",
"(",
"cmaglin",
"=",
"False",
")",
"parser",
".",
"set_defaults",
"(",
"single",
"=",
"False",
")",
"parser",
".",
"set_defaults",
"(",
"aniso",... | Handle options. | [
"Handle",
"options",
"."
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/td_plot.py#L39-L225 | train | Handle options. |
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'",
"# filename HAS to exist. Otherwise the inversion was not finished",
"if",
"(",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"filename"... | 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 | Return the path to the final. mag file either for the complex or the fpi
inversion. |
geophysics-ubonn/crtomo_tools | src/td_plot.py | td_type | def td_type():
'''get type of the tomodir (complex or dc and whether fpi)
'''
cfg = np.genfromtxt('exe/crtomo.cfg',
skip_header=15,
dtype='str',
usecols=([0]))
is_complex = False
if cfg[0] == 'F':
is_complex = True
i... | python | def td_type():
'''get type of the tomodir (complex or dc and whether fpi)
'''
cfg = np.genfromtxt('exe/crtomo.cfg',
skip_header=15,
dtype='str',
usecols=([0]))
is_complex = False
if cfg[0] == 'F':
is_complex = True
i... | [
"def",
"td_type",
"(",
")",
":",
"cfg",
"=",
"np",
".",
"genfromtxt",
"(",
"'exe/crtomo.cfg'",
",",
"skip_header",
"=",
"15",
",",
"dtype",
"=",
"'str'",
",",
"usecols",
"=",
"(",
"[",
"0",
"]",
")",
")",
"is_complex",
"=",
"False",
"if",
"cfg",
"[... | get type of the tomodir (complex or dc and whether fpi) | [
"get",
"type",
"of",
"the",
"tomodir",
"(",
"complex",
"or",
"dc",
"and",
"whether",
"fpi",
")"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/td_plot.py#L248-L262 | train | get type of the tomodir |
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",
"(",
")",
"# get the highest iteration",
"it_rho",
"=",
"read_iter",
"(",
"is_fpi",
")",
"it_phase",
"=",
"read_iter",
"(",
"False",
")",
"# list the files",
"files",
"=",
"[",
... | 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 | Get the type of the tomodir and the highest iteration to list all files and the dtype of the tomodir which will be plotted. |
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 | Load the datafiles and return cov mag phase and fpi phase values. |
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 | Load a datafile with coverage file structure. |
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 | Load a datafile with rho structure like mag and phase |
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 | Calculate real and imaginary part of the complex conductivity from magnitude and phase in log10. |
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",
")",
":",
"# handle options",
"cblabel",
... | 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 | Plot ratio of two conductivity directions. |
geophysics-ubonn/crtomo_tools | src/td_plot.py | alpha_from_cov | def alpha_from_cov(plotman, alpha_cov):
'''Calculate alpha values from the coverage/2.5.
'''
abscov = np.abs(load_cov('inv/coverage.mag'))
if alpha_cov:
normcov = np.divide(abscov, 2.5)
normcov[np.where(normcov > 1)] = 1
mask = np.subtract(1, normcov)
alpha = plotman.parm... | python | def alpha_from_cov(plotman, alpha_cov):
'''Calculate alpha values from the coverage/2.5.
'''
abscov = np.abs(load_cov('inv/coverage.mag'))
if alpha_cov:
normcov = np.divide(abscov, 2.5)
normcov[np.where(normcov > 1)] = 1
mask = np.subtract(1, normcov)
alpha = plotman.parm... | [
"def",
"alpha_from_cov",
"(",
"plotman",
",",
"alpha_cov",
")",
":",
"abscov",
"=",
"np",
".",
"abs",
"(",
"load_cov",
"(",
"'inv/coverage.mag'",
")",
")",
"if",
"alpha_cov",
":",
"normcov",
"=",
"np",
".",
"divide",
"(",
"abscov",
",",
"2.5",
")",
"no... | Calculate alpha values from the coverage/2.5. | [
"Calculate",
"alpha",
"values",
"from",
"the",
"coverage",
"/",
"2",
".",
"5",
"."
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/td_plot.py#L573-L584 | train | Calculate alpha values from the coverage. |
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 | Get min and max values for axes and colorbar if not given
|
geophysics-ubonn/crtomo_tools | src/td_plot.py | getfigsize | def getfigsize(plotman):
'''calculate appropriate sizes for the subfigures
'''
xmin = plotman.grid.grid['x'].min()
xmax = plotman.grid.grid['x'].max()
zmin = plotman.grid.grid['z'].min()
zmax = plotman.grid.grid['z'].max()
if np.abs(zmax - zmin) < np.abs(xmax - xmin):
sizex = 10 / 2.... | python | def getfigsize(plotman):
'''calculate appropriate sizes for the subfigures
'''
xmin = plotman.grid.grid['x'].min()
xmax = plotman.grid.grid['x'].max()
zmin = plotman.grid.grid['z'].min()
zmax = plotman.grid.grid['z'].max()
if np.abs(zmax - zmin) < np.abs(xmax - xmin):
sizex = 10 / 2.... | [
"def",
"getfigsize",
"(",
"plotman",
")",
":",
"xmin",
"=",
"plotman",
".",
"grid",
".",
"grid",
"[",
"'x'",
"]",
".",
"min",
"(",
")",
"xmax",
"=",
"plotman",
".",
"grid",
".",
"grid",
"[",
"'x'",
"]",
".",
"max",
"(",
")",
"zmin",
"=",
"plotm... | calculate appropriate sizes for the subfigures | [
"calculate",
"appropriate",
"sizes",
"for",
"the",
"subfigures"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/td_plot.py#L610-L626 | train | calculate appropriate sizes for the subfigures
|
geophysics-ubonn/crtomo_tools | src/td_plot.py | create_tdplot | def create_tdplot(plotman, cov, mag, pha, pha_fpi, alpha, options):
'''Plot the data of the tomodir in one overview plot.
'''
sizex, sizez = getfigsize(plotman)
# create figure
f, ax = plt.subplots(2, 4, figsize=(4 * sizex, 2 * sizez))
if options.title is not None:
plt.suptitle(options.t... | python | def create_tdplot(plotman, cov, mag, pha, pha_fpi, alpha, options):
'''Plot the data of the tomodir in one overview plot.
'''
sizex, sizez = getfigsize(plotman)
# create figure
f, ax = plt.subplots(2, 4, figsize=(4 * sizex, 2 * sizez))
if options.title is not None:
plt.suptitle(options.t... | [
"def",
"create_tdplot",
"(",
"plotman",
",",
"cov",
",",
"mag",
",",
"pha",
",",
"pha_fpi",
",",
"alpha",
",",
"options",
")",
":",
"sizex",
",",
"sizez",
"=",
"getfigsize",
"(",
"plotman",
")",
"# create figure",
"f",
",",
"ax",
"=",
"plt",
".",
"su... | Plot the data of the tomodir in one overview plot. | [
"Plot",
"the",
"data",
"of",
"the",
"tomodir",
"in",
"one",
"overview",
"plot",
"."
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/td_plot.py#L683-L716 | train | Create the data of the tomodir in one overview plot. |
geophysics-ubonn/crtomo_tools | src/td_plot.py | create_singleplots | def create_singleplots(plotman, cov, mag, pha, pha_fpi, alpha, options):
'''Plot the data of the tomodir in individual plots.
'''
magunit = 'log_rho'
if not pha == []:
[real, imag] = calc_complex(mag, pha)
if not pha_fpi == []:
[real_fpi, imag_fpi] = calc_complex(mag, pha_fpi... | python | def create_singleplots(plotman, cov, mag, pha, pha_fpi, alpha, options):
'''Plot the data of the tomodir in individual plots.
'''
magunit = 'log_rho'
if not pha == []:
[real, imag] = calc_complex(mag, pha)
if not pha_fpi == []:
[real_fpi, imag_fpi] = calc_complex(mag, pha_fpi... | [
"def",
"create_singleplots",
"(",
"plotman",
",",
"cov",
",",
"mag",
",",
"pha",
",",
"pha_fpi",
",",
"alpha",
",",
"options",
")",
":",
"magunit",
"=",
"'log_rho'",
"if",
"not",
"pha",
"==",
"[",
"]",
":",
"[",
"real",
",",
"imag",
"]",
"=",
"calc... | Plot the data of the tomodir in individual plots. | [
"Plot",
"the",
"data",
"of",
"the",
"tomodir",
"in",
"individual",
"plots",
"."
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/td_plot.py#L719-L836 | train | Create a single plot for the tomodir. |
geophysics-ubonn/crtomo_tools | src/td_plot.py | create_anisomagplot | def create_anisomagplot(plotman, x, y, z, alpha, options):
'''Plot the data of the tomodir in one overview plot.
'''
sizex, sizez = getfigsize(plotman)
# create figure
f, ax = plt.subplots(2, 3, figsize=(3 * sizex, 2 * sizez))
if options.title is not None:
plt.suptitle(options.title, fon... | python | def create_anisomagplot(plotman, x, y, z, alpha, options):
'''Plot the data of the tomodir in one overview plot.
'''
sizex, sizez = getfigsize(plotman)
# create figure
f, ax = plt.subplots(2, 3, figsize=(3 * sizex, 2 * sizez))
if options.title is not None:
plt.suptitle(options.title, fon... | [
"def",
"create_anisomagplot",
"(",
"plotman",
",",
"x",
",",
"y",
",",
"z",
",",
"alpha",
",",
"options",
")",
":",
"sizex",
",",
"sizez",
"=",
"getfigsize",
"(",
"plotman",
")",
"# create figure",
"f",
",",
"ax",
"=",
"plt",
".",
"subplots",
"(",
"2... | Plot the data of the tomodir in one overview plot. | [
"Plot",
"the",
"data",
"of",
"the",
"tomodir",
"in",
"one",
"overview",
"plot",
"."
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/td_plot.py#L839-L894 | train | Create an overview plot for the tomodir in one overview plot. |
geophysics-ubonn/crtomo_tools | src/td_plot.py | create_anisophaplot | def create_anisophaplot(plotman, x, y, z, alpha, options):
'''Plot the data of the tomodir in one overview plot.
'''
sizex, sizez = getfigsize(plotman)
# create figure
f, ax = plt.subplots(2, 3, figsize=(3 * sizex, 2 * sizez))
if options.title is not None:
plt.suptitle(options.title, fon... | python | def create_anisophaplot(plotman, x, y, z, alpha, options):
'''Plot the data of the tomodir in one overview plot.
'''
sizex, sizez = getfigsize(plotman)
# create figure
f, ax = plt.subplots(2, 3, figsize=(3 * sizex, 2 * sizez))
if options.title is not None:
plt.suptitle(options.title, fon... | [
"def",
"create_anisophaplot",
"(",
"plotman",
",",
"x",
",",
"y",
",",
"z",
",",
"alpha",
",",
"options",
")",
":",
"sizex",
",",
"sizez",
"=",
"getfigsize",
"(",
"plotman",
")",
"# create figure",
"f",
",",
"ax",
"=",
"plt",
".",
"subplots",
"(",
"2... | Plot the data of the tomodir in one overview plot. | [
"Plot",
"the",
"data",
"of",
"the",
"tomodir",
"in",
"one",
"overview",
"plot",
"."
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/td_plot.py#L897-L945 | train | Create an overview plot of the data of the tomodir in one overview plot. |
geophysics-ubonn/crtomo_tools | src/td_plot.py | create_hlammagplot | def create_hlammagplot(plotman, h, ratio, alpha, options):
'''Plot the data of the tomodir in one overview plot.
'''
sizex, sizez = getfigsize(plotman)
# create figure
f, ax = plt.subplots(1, 3, figsize=(3 * sizex, sizez))
if options.title is not None:
plt.suptitle(options.title, fontsiz... | python | def create_hlammagplot(plotman, h, ratio, alpha, options):
'''Plot the data of the tomodir in one overview plot.
'''
sizex, sizez = getfigsize(plotman)
# create figure
f, ax = plt.subplots(1, 3, figsize=(3 * sizex, sizez))
if options.title is not None:
plt.suptitle(options.title, fontsiz... | [
"def",
"create_hlammagplot",
"(",
"plotman",
",",
"h",
",",
"ratio",
",",
"alpha",
",",
"options",
")",
":",
"sizex",
",",
"sizez",
"=",
"getfigsize",
"(",
"plotman",
")",
"# create figure",
"f",
",",
"ax",
"=",
"plt",
".",
"subplots",
"(",
"1",
",",
... | Plot the data of the tomodir in one overview plot. | [
"Plot",
"the",
"data",
"of",
"the",
"tomodir",
"in",
"one",
"overview",
"plot",
"."
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/td_plot.py#L948-L987 | train | Create the hlammag plot. |
geophysics-ubonn/crtomo_tools | src/td_plot.py | create_hlamphaplot | def create_hlamphaplot(plotman, h, v, alpha, options):
'''Plot the data of the tomodir in one overview plot.
'''
sizex, sizez = getfigsize(plotman)
# create figure
f, ax = plt.subplots(1, 3, figsize=(3 * sizex, sizez))
if options.title is not None:
plt.suptitle(options.title, fontsize=18... | python | def create_hlamphaplot(plotman, h, v, alpha, options):
'''Plot the data of the tomodir in one overview plot.
'''
sizex, sizez = getfigsize(plotman)
# create figure
f, ax = plt.subplots(1, 3, figsize=(3 * sizex, sizez))
if options.title is not None:
plt.suptitle(options.title, fontsize=18... | [
"def",
"create_hlamphaplot",
"(",
"plotman",
",",
"h",
",",
"v",
",",
"alpha",
",",
"options",
")",
":",
"sizex",
",",
"sizez",
"=",
"getfigsize",
"(",
"plotman",
")",
"# create figure",
"f",
",",
"ax",
"=",
"plt",
".",
"subplots",
"(",
"1",
",",
"3"... | Plot the data of the tomodir in one overview plot. | [
"Plot",
"the",
"data",
"of",
"the",
"tomodir",
"in",
"one",
"overview",
"plot",
"."
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/td_plot.py#L990-L1020 | train | Create the data of the tomodir in one overview plot. |
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 | Direct the citation elements based on their qualifier. |
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'",
":",... | 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 | Direct the identifier elements based on their qualifier. |
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",
"=",
"F... | 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 | Determine the authors from the creator field. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.