repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_documentation_string stringlengths 1 47.2k | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|
edx/edx-submissions | submissions/api.py | get_submission_and_student | def get_submission_and_student(uuid, read_replica=False):
"""
Retrieve a submission by its unique identifier, including the associated student item.
Args:
uuid (str): the unique identifier of the submission.
Kwargs:
read_replica (bool): If true, attempt to use the read replica database... | python | def get_submission_and_student(uuid, read_replica=False):
"""
Retrieve a submission by its unique identifier, including the associated student item.
Args:
uuid (str): the unique identifier of the submission.
Kwargs:
read_replica (bool): If true, attempt to use the read replica database... | Retrieve a submission by its unique identifier, including the associated student item.
Args:
uuid (str): the unique identifier of the submission.
Kwargs:
read_replica (bool): If true, attempt to use the read replica database.
If no read replica is available, use the default databas... | https://github.com/edx/edx-submissions/blob/8d531ca25f7c2886dfcb1bb8febe0910e1433ca2/submissions/api.py#L307-L357 |
edx/edx-submissions | submissions/api.py | get_submissions | def get_submissions(student_item_dict, limit=None):
"""Retrieves the submissions for the specified student item,
ordered by most recent submitted date.
Returns the submissions relative to the specified student item. Exception
thrown if no submission is found relative to this location.
Args:
... | python | def get_submissions(student_item_dict, limit=None):
"""Retrieves the submissions for the specified student item,
ordered by most recent submitted date.
Returns the submissions relative to the specified student item. Exception
thrown if no submission is found relative to this location.
Args:
... | Retrieves the submissions for the specified student item,
ordered by most recent submitted date.
Returns the submissions relative to the specified student item. Exception
thrown if no submission is found relative to this location.
Args:
student_item_dict (dict): The location of the problem thi... | https://github.com/edx/edx-submissions/blob/8d531ca25f7c2886dfcb1bb8febe0910e1433ca2/submissions/api.py#L360-L421 |
edx/edx-submissions | submissions/api.py | get_all_submissions | def get_all_submissions(course_id, item_id, item_type, read_replica=True):
"""For the given item, get the most recent submission for every student who has submitted.
This may return a very large result set! It is implemented as a generator for efficiency.
Args:
course_id, item_id, item_type (strin... | python | def get_all_submissions(course_id, item_id, item_type, read_replica=True):
"""For the given item, get the most recent submission for every student who has submitted.
This may return a very large result set! It is implemented as a generator for efficiency.
Args:
course_id, item_id, item_type (strin... | For the given item, get the most recent submission for every student who has submitted.
This may return a very large result set! It is implemented as a generator for efficiency.
Args:
course_id, item_id, item_type (string): The values of the respective student_item fields
to filter the sub... | https://github.com/edx/edx-submissions/blob/8d531ca25f7c2886dfcb1bb8febe0910e1433ca2/submissions/api.py#L424-L464 |
edx/edx-submissions | submissions/api.py | get_all_course_submission_information | def get_all_course_submission_information(course_id, item_type, read_replica=True):
""" For the given course, get all student items of the given item type, all the submissions for those itemes,
and the latest scores for each item. If a submission was given a score that is not the latest score for the
releva... | python | def get_all_course_submission_information(course_id, item_type, read_replica=True):
""" For the given course, get all student items of the given item type, all the submissions for those itemes,
and the latest scores for each item. If a submission was given a score that is not the latest score for the
releva... | For the given course, get all student items of the given item type, all the submissions for those itemes,
and the latest scores for each item. If a submission was given a score that is not the latest score for the
relevant student item, it will still be included but without score.
Args:
course_id (... | https://github.com/edx/edx-submissions/blob/8d531ca25f7c2886dfcb1bb8febe0910e1433ca2/submissions/api.py#L467-L523 |
edx/edx-submissions | submissions/api.py | get_top_submissions | def get_top_submissions(course_id, item_id, item_type, number_of_top_scores, use_cache=True, read_replica=True):
"""Get a number of top scores for an assessment based on a particular student item
This function will return top scores for the piece of assessment.
It will consider only the latest and greater ... | python | def get_top_submissions(course_id, item_id, item_type, number_of_top_scores, use_cache=True, read_replica=True):
"""Get a number of top scores for an assessment based on a particular student item
This function will return top scores for the piece of assessment.
It will consider only the latest and greater ... | Get a number of top scores for an assessment based on a particular student item
This function will return top scores for the piece of assessment.
It will consider only the latest and greater than 0 score for a piece of assessment.
A score is only calculated for a student item if it has completed the workfl... | https://github.com/edx/edx-submissions/blob/8d531ca25f7c2886dfcb1bb8febe0910e1433ca2/submissions/api.py#L526-L625 |
edx/edx-submissions | submissions/api.py | get_score | def get_score(student_item):
"""Get the score for a particular student item
Each student item should have a unique score. This function will return the
score if it is available. A score is only calculated for a student item if
it has completed the workflow for a particular assessment module.
Args:... | python | def get_score(student_item):
"""Get the score for a particular student item
Each student item should have a unique score. This function will return the
score if it is available. A score is only calculated for a student item if
it has completed the workflow for a particular assessment module.
Args:... | Get the score for a particular student item
Each student item should have a unique score. This function will return the
score if it is available. A score is only calculated for a student item if
it has completed the workflow for a particular assessment module.
Args:
student_item (dict): The di... | https://github.com/edx/edx-submissions/blob/8d531ca25f7c2886dfcb1bb8febe0910e1433ca2/submissions/api.py#L628-L676 |
edx/edx-submissions | submissions/api.py | get_scores | def get_scores(course_id, student_id):
"""Return a dict mapping item_ids to scores.
Scores are represented by serialized Score objects in JSON-like dict
format.
This method would be used by an LMS to find all the scores for a given
student in a given course.
Scores that are "hidden" (because ... | python | def get_scores(course_id, student_id):
"""Return a dict mapping item_ids to scores.
Scores are represented by serialized Score objects in JSON-like dict
format.
This method would be used by an LMS to find all the scores for a given
student in a given course.
Scores that are "hidden" (because ... | Return a dict mapping item_ids to scores.
Scores are represented by serialized Score objects in JSON-like dict
format.
This method would be used by an LMS to find all the scores for a given
student in a given course.
Scores that are "hidden" (because they have points earned set to zero)
are e... | https://github.com/edx/edx-submissions/blob/8d531ca25f7c2886dfcb1bb8febe0910e1433ca2/submissions/api.py#L679-L722 |
edx/edx-submissions | submissions/api.py | reset_score | def reset_score(student_id, course_id, item_id, clear_state=False, emit_signal=True):
"""
Reset scores for a specific student on a specific problem.
Note: this does *not* delete `Score` models from the database,
since these are immutable. It simply creates a new score with
the "reset" flag set to ... | python | def reset_score(student_id, course_id, item_id, clear_state=False, emit_signal=True):
"""
Reset scores for a specific student on a specific problem.
Note: this does *not* delete `Score` models from the database,
since these are immutable. It simply creates a new score with
the "reset" flag set to ... | Reset scores for a specific student on a specific problem.
Note: this does *not* delete `Score` models from the database,
since these are immutable. It simply creates a new score with
the "reset" flag set to True.
Args:
student_id (unicode): The ID of the student for whom to reset scores.
... | https://github.com/edx/edx-submissions/blob/8d531ca25f7c2886dfcb1bb8febe0910e1433ca2/submissions/api.py#L759-L824 |
edx/edx-submissions | submissions/api.py | set_score | def set_score(submission_uuid, points_earned, points_possible,
annotation_creator=None, annotation_type=None, annotation_reason=None):
"""Set a score for a particular submission.
Sets the score for a particular submission. This score is calculated
externally to the API.
Args:
sub... | python | def set_score(submission_uuid, points_earned, points_possible,
annotation_creator=None, annotation_type=None, annotation_reason=None):
"""Set a score for a particular submission.
Sets the score for a particular submission. This score is calculated
externally to the API.
Args:
sub... | Set a score for a particular submission.
Sets the score for a particular submission. This score is calculated
externally to the API.
Args:
submission_uuid (str): UUID for the submission (must exist).
points_earned (int): The earned points for this submission.
points_possible (int):... | https://github.com/edx/edx-submissions/blob/8d531ca25f7c2886dfcb1bb8febe0910e1433ca2/submissions/api.py#L827-L920 |
edx/edx-submissions | submissions/api.py | _log_submission | def _log_submission(submission, student_item):
"""
Log the creation of a submission.
Args:
submission (dict): The serialized submission model.
student_item (dict): The serialized student item model.
Returns:
None
"""
logger.info(
u"Created submission uuid={submi... | python | def _log_submission(submission, student_item):
"""
Log the creation of a submission.
Args:
submission (dict): The serialized submission model.
student_item (dict): The serialized student item model.
Returns:
None
"""
logger.info(
u"Created submission uuid={submi... | Log the creation of a submission.
Args:
submission (dict): The serialized submission model.
student_item (dict): The serialized student item model.
Returns:
None | https://github.com/edx/edx-submissions/blob/8d531ca25f7c2886dfcb1bb8febe0910e1433ca2/submissions/api.py#L923-L944 |
edx/edx-submissions | submissions/api.py | _log_score | def _log_score(score):
"""
Log the creation of a score.
Args:
score (Score): The score model.
Returns:
None
"""
logger.info(
"Score of ({}/{}) set for submission {}"
.format(score.points_earned, score.points_possible, score.submission.uuid)
) | python | def _log_score(score):
"""
Log the creation of a score.
Args:
score (Score): The score model.
Returns:
None
"""
logger.info(
"Score of ({}/{}) set for submission {}"
.format(score.points_earned, score.points_possible, score.submission.uuid)
) | Log the creation of a score.
Args:
score (Score): The score model.
Returns:
None | https://github.com/edx/edx-submissions/blob/8d531ca25f7c2886dfcb1bb8febe0910e1433ca2/submissions/api.py#L947-L960 |
edx/edx-submissions | submissions/api.py | _get_or_create_student_item | def _get_or_create_student_item(student_item_dict):
"""Gets or creates a Student Item that matches the values specified.
Attempts to get the specified Student Item. If it does not exist, the
specified parameters are validated, and a new Student Item is created.
Args:
student_item_dict (dict): ... | python | def _get_or_create_student_item(student_item_dict):
"""Gets or creates a Student Item that matches the values specified.
Attempts to get the specified Student Item. If it does not exist, the
specified parameters are validated, and a new Student Item is created.
Args:
student_item_dict (dict): ... | Gets or creates a Student Item that matches the values specified.
Attempts to get the specified Student Item. If it does not exist, the
specified parameters are validated, and a new Student Item is created.
Args:
student_item_dict (dict): The dict containing the student_id, item_id,
co... | https://github.com/edx/edx-submissions/blob/8d531ca25f7c2886dfcb1bb8febe0910e1433ca2/submissions/api.py#L963-L1014 |
joyent/python-manta | manta/client.py | RawMantaClient._request | def _request(self,
path,
method="GET",
query=None,
body=None,
headers=None):
"""Make a Manta request
...
@returns (res, content)
"""
assert path.startswith('/'), "bogus path: %r" % path
... | python | def _request(self,
path,
method="GET",
query=None,
body=None,
headers=None):
"""Make a Manta request
...
@returns (res, content)
"""
assert path.startswith('/'), "bogus path: %r" % path
... | Make a Manta request
...
@returns (res, content) | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/client.py#L165-L220 |
joyent/python-manta | manta/client.py | RawMantaClient.put_directory | def put_directory(self, mdir):
"""PutDirectory
https://apidocs.joyent.com/manta/api.html#PutDirectory
@param mdir {str} A manta path, e.g. '/trent/stor/mydir'.
"""
log.debug('PutDirectory %r', mdir)
headers = {"Content-Type": "application/json; type=directory"}
r... | python | def put_directory(self, mdir):
"""PutDirectory
https://apidocs.joyent.com/manta/api.html#PutDirectory
@param mdir {str} A manta path, e.g. '/trent/stor/mydir'.
"""
log.debug('PutDirectory %r', mdir)
headers = {"Content-Type": "application/json; type=directory"}
r... | PutDirectory
https://apidocs.joyent.com/manta/api.html#PutDirectory
@param mdir {str} A manta path, e.g. '/trent/stor/mydir'. | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/client.py#L222-L232 |
joyent/python-manta | manta/client.py | RawMantaClient.list_directory | def list_directory(self, mdir, limit=None, marker=None):
"""ListDirectory
https://apidocs.joyent.com/manta/api.html#ListDirectory
@param mdir {str} A manta path, e.g. '/trent/stor/mydir'.
@param limit {int} Limits the number of records to come back (default
and max is 1000).... | python | def list_directory(self, mdir, limit=None, marker=None):
"""ListDirectory
https://apidocs.joyent.com/manta/api.html#ListDirectory
@param mdir {str} A manta path, e.g. '/trent/stor/mydir'.
@param limit {int} Limits the number of records to come back (default
and max is 1000).... | ListDirectory
https://apidocs.joyent.com/manta/api.html#ListDirectory
@param mdir {str} A manta path, e.g. '/trent/stor/mydir'.
@param limit {int} Limits the number of records to come back (default
and max is 1000).
@param marker {str} Key name at which to start the next lis... | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/client.py#L234-L247 |
joyent/python-manta | manta/client.py | RawMantaClient.list_directory2 | def list_directory2(self, mdir, limit=None, marker=None):
"""A lower-level version of `list_directory` that returns the
response object (which includes the headers).
...
@returns (res, dirents) {2-tuple}
"""
log.debug('ListDirectory %r', mdir)
query = {}
... | python | def list_directory2(self, mdir, limit=None, marker=None):
"""A lower-level version of `list_directory` that returns the
response object (which includes the headers).
...
@returns (res, dirents) {2-tuple}
"""
log.debug('ListDirectory %r', mdir)
query = {}
... | A lower-level version of `list_directory` that returns the
response object (which includes the headers).
...
@returns (res, dirents) {2-tuple} | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/client.py#L249-L276 |
joyent/python-manta | manta/client.py | RawMantaClient.head_directory | def head_directory(self, mdir):
"""HEAD method on ListDirectory
https://apidocs.joyent.com/manta/api.html#ListDirectory
This is not strictly a documented Manta API call. However it is
provided to allow access to the useful 'result-set-size' header.
@param mdir {str} A manta pat... | python | def head_directory(self, mdir):
"""HEAD method on ListDirectory
https://apidocs.joyent.com/manta/api.html#ListDirectory
This is not strictly a documented Manta API call. However it is
provided to allow access to the useful 'result-set-size' header.
@param mdir {str} A manta pat... | HEAD method on ListDirectory
https://apidocs.joyent.com/manta/api.html#ListDirectory
This is not strictly a documented Manta API call. However it is
provided to allow access to the useful 'result-set-size' header.
@param mdir {str} A manta path, e.g. '/trent/stor/mydir'.
@retur... | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/client.py#L278-L292 |
joyent/python-manta | manta/client.py | RawMantaClient.put_object | def put_object(self,
mpath,
content=None,
path=None,
file=None,
content_length=None,
content_type="application/octet-stream",
durability_level=None):
"""PutObject
https://... | python | def put_object(self,
mpath,
content=None,
path=None,
file=None,
content_length=None,
content_type="application/octet-stream",
durability_level=None):
"""PutObject
https://... | PutObject
https://apidocs.joyent.com/manta/api.html#PutObject
Examples:
client.put_object('/trent/stor/foo', 'foo\nbar\nbaz')
client.put_object('/trent/stor/foo', path='path/to/foo.txt')
client.put_object('/trent/stor/foo', file=open('path/to/foo.txt'),
... | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/client.py#L305-L370 |
joyent/python-manta | manta/client.py | RawMantaClient.get_object | def get_object(self, mpath, path=None, accept="*/*"):
"""GetObject
https://apidocs.joyent.com/manta/api.html#GetObject
@param mpath {str} Required. A manta path, e.g. '/trent/stor/myobj'.
@param path {str} Optional. If given, the retrieved object will be
written to the given... | python | def get_object(self, mpath, path=None, accept="*/*"):
"""GetObject
https://apidocs.joyent.com/manta/api.html#GetObject
@param mpath {str} Required. A manta path, e.g. '/trent/stor/myobj'.
@param path {str} Optional. If given, the retrieved object will be
written to the given... | GetObject
https://apidocs.joyent.com/manta/api.html#GetObject
@param mpath {str} Required. A manta path, e.g. '/trent/stor/myobj'.
@param path {str} Optional. If given, the retrieved object will be
written to the given file path instead of the content being
returned.
... | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/client.py#L372-L392 |
joyent/python-manta | manta/client.py | RawMantaClient.get_object2 | def get_object2(self, mpath, path=None, accept="*/*"):
"""A lower-level version of `get_object` that returns the
response object (which includes the headers).
...
@returns (res, content) {2-tuple} `content` is None if `path` was
provided
"""
log.debug('GetObj... | python | def get_object2(self, mpath, path=None, accept="*/*"):
"""A lower-level version of `get_object` that returns the
response object (which includes the headers).
...
@returns (res, content) {2-tuple} `content` is None if `path` was
provided
"""
log.debug('GetObj... | A lower-level version of `get_object` that returns the
response object (which includes the headers).
...
@returns (res, content) {2-tuple} `content` is None if `path` was
provided | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/client.py#L394-L427 |
joyent/python-manta | manta/client.py | RawMantaClient.delete_object | def delete_object(self, mpath):
"""DeleteObject
https://apidocs.joyent.com/manta/api.html#DeleteObject
@param mpath {str} Required. A manta path, e.g. '/trent/stor/myobj'.
"""
log.debug('DeleteObject %r', mpath)
res, content = self._request(mpath, "DELETE")
if re... | python | def delete_object(self, mpath):
"""DeleteObject
https://apidocs.joyent.com/manta/api.html#DeleteObject
@param mpath {str} Required. A manta path, e.g. '/trent/stor/myobj'.
"""
log.debug('DeleteObject %r', mpath)
res, content = self._request(mpath, "DELETE")
if re... | DeleteObject
https://apidocs.joyent.com/manta/api.html#DeleteObject
@param mpath {str} Required. A manta path, e.g. '/trent/stor/myobj'. | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/client.py#L429-L439 |
joyent/python-manta | manta/client.py | RawMantaClient.put_snaplink | def put_snaplink(self, link_path, object_path):
"""PutSnapLink
https://mo.joyent.com/docs/muskie/master/api.html#putsnaplink
@param link_path {str} Required. A manta path, e.g.
'/trent/stor/mylink'.
@param object_path {str} Required. The manta path to an existing target
... | python | def put_snaplink(self, link_path, object_path):
"""PutSnapLink
https://mo.joyent.com/docs/muskie/master/api.html#putsnaplink
@param link_path {str} Required. A manta path, e.g.
'/trent/stor/mylink'.
@param object_path {str} Required. The manta path to an existing target
... | PutSnapLink
https://mo.joyent.com/docs/muskie/master/api.html#putsnaplink
@param link_path {str} Required. A manta path, e.g.
'/trent/stor/mylink'.
@param object_path {str} Required. The manta path to an existing target
manta object. | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/client.py#L441-L458 |
joyent/python-manta | manta/client.py | RawMantaClient.create_job | def create_job(self, phases, name=None, input=None):
"""CreateJob
https://apidocs.joyent.com/manta/api.html#CreateJob
"""
log.debug('CreateJob')
path = '/%s/jobs' % self.account
body = {"phases": phases}
if name:
body["name"] = name
if input:
... | python | def create_job(self, phases, name=None, input=None):
"""CreateJob
https://apidocs.joyent.com/manta/api.html#CreateJob
"""
log.debug('CreateJob')
path = '/%s/jobs' % self.account
body = {"phases": phases}
if name:
body["name"] = name
if input:
... | CreateJob
https://apidocs.joyent.com/manta/api.html#CreateJob | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/client.py#L460-L481 |
joyent/python-manta | manta/client.py | RawMantaClient.add_job_inputs | def add_job_inputs(self, job_id, keys):
"""AddJobInputs
https://apidocs.joyent.com/manta/api.html#AddJobInputs
"""
log.debug("AddJobInputs %r", job_id)
path = "/%s/jobs/%s/live/in" % (self.account, job_id)
body = '\r\n'.join(keys) + '\r\n'
headers = {
... | python | def add_job_inputs(self, job_id, keys):
"""AddJobInputs
https://apidocs.joyent.com/manta/api.html#AddJobInputs
"""
log.debug("AddJobInputs %r", job_id)
path = "/%s/jobs/%s/live/in" % (self.account, job_id)
body = '\r\n'.join(keys) + '\r\n'
headers = {
... | AddJobInputs
https://apidocs.joyent.com/manta/api.html#AddJobInputs | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/client.py#L483-L496 |
joyent/python-manta | manta/client.py | RawMantaClient.end_job_input | def end_job_input(self, job_id):
"""EndJobInput
https://mo.joyent.com/docs/muskie/master/api.html#EndJobInput
"""
log.debug("EndJobInput %r", job_id)
path = "/%s/jobs/%s/live/in/end" % (self.account, job_id)
headers = {
# "Content-Length": "0" #XXX needed?
... | python | def end_job_input(self, job_id):
"""EndJobInput
https://mo.joyent.com/docs/muskie/master/api.html#EndJobInput
"""
log.debug("EndJobInput %r", job_id)
path = "/%s/jobs/%s/live/in/end" % (self.account, job_id)
headers = {
# "Content-Length": "0" #XXX needed?
... | EndJobInput
https://mo.joyent.com/docs/muskie/master/api.html#EndJobInput | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/client.py#L498-L509 |
joyent/python-manta | manta/client.py | RawMantaClient.list_jobs | def list_jobs(self, state=None, limit=None, marker=None):
"""ListJobs
https://apidocs.joyent.com/manta/api.html#ListJobs
Limitation: at this time `list_jobs` doesn't support paging through
more than the default response num results. (TODO)
@param state {str} Only return jobs in... | python | def list_jobs(self, state=None, limit=None, marker=None):
"""ListJobs
https://apidocs.joyent.com/manta/api.html#ListJobs
Limitation: at this time `list_jobs` doesn't support paging through
more than the default response num results. (TODO)
@param state {str} Only return jobs in... | ListJobs
https://apidocs.joyent.com/manta/api.html#ListJobs
Limitation: at this time `list_jobs` doesn't support paging through
more than the default response num results. (TODO)
@param state {str} Only return jobs in the given state, e.g.
"running", "done", etc.
@p... | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/client.py#L522-L558 |
joyent/python-manta | manta/client.py | RawMantaClient.get_job | def get_job(self, job_id):
"""GetJob
https://apidocs.joyent.com/manta/api.html#GetJob
"""
log.debug("GetJob %r", job_id)
path = "/%s/jobs/%s/live/status" % (self.account, job_id)
res, content = self._request(path, "GET")
if res.status != 200:
raise err... | python | def get_job(self, job_id):
"""GetJob
https://apidocs.joyent.com/manta/api.html#GetJob
"""
log.debug("GetJob %r", job_id)
path = "/%s/jobs/%s/live/status" % (self.account, job_id)
res, content = self._request(path, "GET")
if res.status != 200:
raise err... | GetJob
https://apidocs.joyent.com/manta/api.html#GetJob | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/client.py#L560-L572 |
joyent/python-manta | manta/client.py | RawMantaClient.get_job_output | def get_job_output(self, job_id):
"""GetJobOutput
https://apidocs.joyent.com/manta/api.html#GetJobOutput
"""
log.debug("GetJobOutput %r", job_id)
path = "/%s/jobs/%s/live/out" % (self.account, job_id)
res, content = self._request(path, "GET")
if res["status"] != "... | python | def get_job_output(self, job_id):
"""GetJobOutput
https://apidocs.joyent.com/manta/api.html#GetJobOutput
"""
log.debug("GetJobOutput %r", job_id)
path = "/%s/jobs/%s/live/out" % (self.account, job_id)
res, content = self._request(path, "GET")
if res["status"] != "... | GetJobOutput
https://apidocs.joyent.com/manta/api.html#GetJobOutput | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/client.py#L574-L584 |
joyent/python-manta | manta/client.py | RawMantaClient.get_job_errors | def get_job_errors(self, job_id):
"""GetJobErrors
https://apidocs.joyent.com/manta/api.html#GetJobErrors
"""
log.debug("GetJobErrors %r", job_id)
path = "/%s/jobs/%s/live/err" % (self.account, job_id)
res, content = self._request(path, "GET")
if res["status"] != "... | python | def get_job_errors(self, job_id):
"""GetJobErrors
https://apidocs.joyent.com/manta/api.html#GetJobErrors
"""
log.debug("GetJobErrors %r", job_id)
path = "/%s/jobs/%s/live/err" % (self.account, job_id)
res, content = self._request(path, "GET")
if res["status"] != "... | GetJobErrors
https://apidocs.joyent.com/manta/api.html#GetJobErrors | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/client.py#L610-L619 |
joyent/python-manta | manta/client.py | MantaClient.walk | def walk(self, mtop, topdown=True):
"""`os.walk(path)` for a directory in Manta.
A somewhat limited form in that some of the optional args to
`os.walk` are not supported. Also, instead of dir *names* and file
*names*, the dirents for those are returned. E.g.:
>>> for dirpat... | python | def walk(self, mtop, topdown=True):
"""`os.walk(path)` for a directory in Manta.
A somewhat limited form in that some of the optional args to
`os.walk` are not supported. Also, instead of dir *names* and file
*names*, the dirents for those are returned. E.g.:
>>> for dirpat... | `os.walk(path)` for a directory in Manta.
A somewhat limited form in that some of the optional args to
`os.walk` are not supported. Also, instead of dir *names* and file
*names*, the dirents for those are returned. E.g.:
>>> for dirpath, dirents, objents in client.walk('/trent/stor... | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/client.py#L656-L695 |
joyent/python-manta | manta/client.py | MantaClient.ls | def ls(self, mdir, limit=None, marker=None):
"""List a directory.
Dev Notes:
- If `limit` and `marker` are *not* specified. This handles paging
through a directory with more entries than Manta will return in
one request (1000).
- This returns a dict mapping name to d... | python | def ls(self, mdir, limit=None, marker=None):
"""List a directory.
Dev Notes:
- If `limit` and `marker` are *not* specified. This handles paging
through a directory with more entries than Manta will return in
one request (1000).
- This returns a dict mapping name to d... | List a directory.
Dev Notes:
- If `limit` and `marker` are *not* specified. This handles paging
through a directory with more entries than Manta will return in
one request (1000).
- This returns a dict mapping name to dirent as a convenience.
Note that that makes t... | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/client.py#L697-L744 |
joyent/python-manta | manta/client.py | MantaClient.mkdir | def mkdir(self, mdir, parents=False):
"""Make a directory.
Note that this will not error out if the directory already exists
(that is how the PutDirectory Manta API behaves).
@param mdir {str} A manta path, e.g. '/trent/stor/mydir'.
@param parents {bool} Optional. Default false... | python | def mkdir(self, mdir, parents=False):
"""Make a directory.
Note that this will not error out if the directory already exists
(that is how the PutDirectory Manta API behaves).
@param mdir {str} A manta path, e.g. '/trent/stor/mydir'.
@param parents {bool} Optional. Default false... | Make a directory.
Note that this will not error out if the directory already exists
(that is how the PutDirectory Manta API behaves).
@param mdir {str} A manta path, e.g. '/trent/stor/mydir'.
@param parents {bool} Optional. Default false. Like 'mkdir -p', this
will create p... | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/client.py#L746-L801 |
joyent/python-manta | manta/client.py | MantaClient.stat | def stat(self, mpath):
"""Return available dirent info for the given Manta path."""
parts = mpath.split('/')
if len(parts) == 0:
raise errors.MantaError("cannot stat empty manta path: %r" % mpath)
elif len(parts) <= 3:
raise errors.MantaError("cannot stat special ... | python | def stat(self, mpath):
"""Return available dirent info for the given Manta path."""
parts = mpath.split('/')
if len(parts) == 0:
raise errors.MantaError("cannot stat empty manta path: %r" % mpath)
elif len(parts) <= 3:
raise errors.MantaError("cannot stat special ... | Return available dirent info for the given Manta path. | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/client.py#L811-L826 |
joyent/python-manta | manta/client.py | MantaClient.type | def type(self, mpath):
"""Return the manta type for the given manta path.
@param mpath {str} The manta path for which to get the type.
@returns {str|None} The manta type, e.g. "object" or "directory",
or None if the path doesn't exist.
"""
try:
return sel... | python | def type(self, mpath):
"""Return the manta type for the given manta path.
@param mpath {str} The manta path for which to get the type.
@returns {str|None} The manta type, e.g. "object" or "directory",
or None if the path doesn't exist.
"""
try:
return sel... | Return the manta type for the given manta path.
@param mpath {str} The manta path for which to get the type.
@returns {str|None} The manta type, e.g. "object" or "directory",
or None if the path doesn't exist. | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/client.py#L828-L844 |
joyent/python-manta | manta/client.py | MantaClient.get_job | def get_job(self, job_id):
"""GetJob
https://apidocs.joyent.com/manta/api.html#GetJob
with the added sugar that it will retrieve the archived job if it has
been archived, per:
https://apidocs.joyent.com/manta/jobs-reference.html#job-completion-and-archival
"""
... | python | def get_job(self, job_id):
"""GetJob
https://apidocs.joyent.com/manta/api.html#GetJob
with the added sugar that it will retrieve the archived job if it has
been archived, per:
https://apidocs.joyent.com/manta/jobs-reference.html#job-completion-and-archival
"""
... | GetJob
https://apidocs.joyent.com/manta/api.html#GetJob
with the added sugar that it will retrieve the archived job if it has
been archived, per:
https://apidocs.joyent.com/manta/jobs-reference.html#job-completion-and-archival | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/client.py#L846-L864 |
joyent/python-manta | manta/client.py | MantaClient.get_job_input | def get_job_input(self, job_id):
"""GetJobInput
https://apidocs.joyent.com/manta/api.html#GetJobInput
with the added sugar that it will retrieve the archived job if it has
been archived, per:
https://apidocs.joyent.com/manta/jobs-reference.html#job-completion-and-archival... | python | def get_job_input(self, job_id):
"""GetJobInput
https://apidocs.joyent.com/manta/api.html#GetJobInput
with the added sugar that it will retrieve the archived job if it has
been archived, per:
https://apidocs.joyent.com/manta/jobs-reference.html#job-completion-and-archival... | GetJobInput
https://apidocs.joyent.com/manta/api.html#GetJobInput
with the added sugar that it will retrieve the archived job if it has
been archived, per:
https://apidocs.joyent.com/manta/jobs-reference.html#job-completion-and-archival | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/client.py#L866-L882 |
joyent/python-manta | manta/client.py | MantaClient.get_job_errors | def get_job_errors(self, job_id):
"""GetJobErrors
https://apidocs.joyent.com/manta/api.html#GetJobErrors
with the added sugar that it will retrieve the archived job if it has
been archived, per:
https://apidocs.joyent.com/manta/jobs-reference.html#job-completion-and-archi... | python | def get_job_errors(self, job_id):
"""GetJobErrors
https://apidocs.joyent.com/manta/api.html#GetJobErrors
with the added sugar that it will retrieve the archived job if it has
been archived, per:
https://apidocs.joyent.com/manta/jobs-reference.html#job-completion-and-archi... | GetJobErrors
https://apidocs.joyent.com/manta/api.html#GetJobErrors
with the added sugar that it will retrieve the archived job if it has
been archived, per:
https://apidocs.joyent.com/manta/jobs-reference.html#job-completion-and-archival | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/client.py#L920-L935 |
joyent/python-manta | manta/cmdln.py | alias | def alias(*aliases):
"""Decorator to add aliases for Cmdln.do_* command handlers.
Example:
class MyShell(cmdln.Cmdln):
@cmdln.alias("!", "sh")
def do_shell(self, argv):
#...implement 'shell' command
"""
def decorate(f):
if not hasattr(f, "aliases... | python | def alias(*aliases):
"""Decorator to add aliases for Cmdln.do_* command handlers.
Example:
class MyShell(cmdln.Cmdln):
@cmdln.alias("!", "sh")
def do_shell(self, argv):
#...implement 'shell' command
"""
def decorate(f):
if not hasattr(f, "aliases... | Decorator to add aliases for Cmdln.do_* command handlers.
Example:
class MyShell(cmdln.Cmdln):
@cmdln.alias("!", "sh")
def do_shell(self, argv):
#...implement 'shell' command | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/cmdln.py#L83-L99 |
joyent/python-manta | manta/cmdln.py | option | def option(*args, **kwargs):
"""Decorator to add an option to the optparser argument of a Cmdln
subcommand.
Example:
class MyShell(cmdln.Cmdln):
@cmdln.option("-f", "--force", help="force removal")
def do_remove(self, subcmd, opts, *args):
#...
"""
#... | python | def option(*args, **kwargs):
"""Decorator to add an option to the optparser argument of a Cmdln
subcommand.
Example:
class MyShell(cmdln.Cmdln):
@cmdln.option("-f", "--force", help="force removal")
def do_remove(self, subcmd, opts, *args):
#...
"""
#... | Decorator to add an option to the optparser argument of a Cmdln
subcommand.
Example:
class MyShell(cmdln.Cmdln):
@cmdln.option("-f", "--force", help="force removal")
def do_remove(self, subcmd, opts, *args):
#... | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/cmdln.py#L1023-L1042 |
joyent/python-manta | manta/cmdln.py | man_sections_from_cmdln | def man_sections_from_cmdln(inst, summary=None, description=None, author=None):
"""Return man page sections appropriate for the given Cmdln instance.
Join these sections for man page content.
The man page sections generated are:
NAME
SYNOPSIS
DESCRIPTION (if `description` is given)... | python | def man_sections_from_cmdln(inst, summary=None, description=None, author=None):
"""Return man page sections appropriate for the given Cmdln instance.
Join these sections for man page content.
The man page sections generated are:
NAME
SYNOPSIS
DESCRIPTION (if `description` is given)... | Return man page sections appropriate for the given Cmdln instance.
Join these sections for man page content.
The man page sections generated are:
NAME
SYNOPSIS
DESCRIPTION (if `description` is given)
OPTIONS
COMMANDS
HELP TOPICS (if any)
@param inst {Cmdln}... | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/cmdln.py#L1185-L1273 |
joyent/python-manta | manta/cmdln.py | _format_linedata | def _format_linedata(linedata, indent, indent_width):
"""Format specific linedata into a pleasant layout.
"linedata" is a list of 2-tuples of the form:
(<item-display-string>, <item-docstring>)
"indent" is a string to use for one level of indentation
"indent_width" is a number o... | python | def _format_linedata(linedata, indent, indent_width):
"""Format specific linedata into a pleasant layout.
"linedata" is a list of 2-tuples of the form:
(<item-display-string>, <item-docstring>)
"indent" is a string to use for one level of indentation
"indent_width" is a number o... | Format specific linedata into a pleasant layout.
"linedata" is a list of 2-tuples of the form:
(<item-display-string>, <item-docstring>)
"indent" is a string to use for one level of indentation
"indent_width" is a number of columns by which the
formatted data will be ind... | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/cmdln.py#L1278-L1310 |
joyent/python-manta | manta/cmdln.py | _summarize_doc | def _summarize_doc(doc, length=60):
r"""Parse out a short one line summary from the given doclines.
"doc" is the doc string to summarize.
"length" is the max length for the summary
>>> _summarize_doc("this function does this")
'this function does this'
>>> _summarize_doc("this function... | python | def _summarize_doc(doc, length=60):
r"""Parse out a short one line summary from the given doclines.
"doc" is the doc string to summarize.
"length" is the max length for the summary
>>> _summarize_doc("this function does this")
'this function does this'
>>> _summarize_doc("this function... | r"""Parse out a short one line summary from the given doclines.
"doc" is the doc string to summarize.
"length" is the max length for the summary
>>> _summarize_doc("this function does this")
'this function does this'
>>> _summarize_doc("this function does this", 10)
'this fu...'
>>... | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/cmdln.py#L1313-L1348 |
joyent/python-manta | manta/cmdln.py | line2argv | def line2argv(line):
r"""Parse the given line into an argument vector.
"line" is the line of input to parse.
This may get niggly when dealing with quoting and escaping. The
current state of this parsing may not be completely thorough/correct
in this respect.
>>> from cmdln import line2arg... | python | def line2argv(line):
r"""Parse the given line into an argument vector.
"line" is the line of input to parse.
This may get niggly when dealing with quoting and escaping. The
current state of this parsing may not be completely thorough/correct
in this respect.
>>> from cmdln import line2arg... | r"""Parse the given line into an argument vector.
"line" is the line of input to parse.
This may get niggly when dealing with quoting and escaping. The
current state of this parsing may not be completely thorough/correct
in this respect.
>>> from cmdln import line2argv
>>> line2argv("foo"... | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/cmdln.py#L1351-L1469 |
joyent/python-manta | manta/cmdln.py | argv2line | def argv2line(argv):
r"""Put together the given argument vector into a command line.
"argv" is the argument vector to process.
>>> from cmdln import argv2line
>>> argv2line(['foo'])
'foo'
>>> argv2line(['foo', 'bar'])
'foo bar'
>>> argv2line(['foo', 'bar baz'])
'foo "bar baz"'
... | python | def argv2line(argv):
r"""Put together the given argument vector into a command line.
"argv" is the argument vector to process.
>>> from cmdln import argv2line
>>> argv2line(['foo'])
'foo'
>>> argv2line(['foo', 'bar'])
'foo bar'
>>> argv2line(['foo', 'bar baz'])
'foo "bar baz"'
... | r"""Put together the given argument vector into a command line.
"argv" is the argument vector to process.
>>> from cmdln import argv2line
>>> argv2line(['foo'])
'foo'
>>> argv2line(['foo', 'bar'])
'foo bar'
>>> argv2line(['foo', 'bar baz'])
'foo "bar baz"'
>>> argv2line(['foo"b... | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/cmdln.py#L1472-L1503 |
joyent/python-manta | manta/cmdln.py | _get_indent | def _get_indent(marker, s, tab_width=8):
"""_get_indent(marker, s, tab_width=8) ->
(<indentation-of-'marker'>, <indentation-width>)"""
# Figure out how much the marker is indented.
INDENT_CHARS = tuple(' \t')
start = s.index(marker)
i = start
while i > 0:
if s[i - 1] not in INDEN... | python | def _get_indent(marker, s, tab_width=8):
"""_get_indent(marker, s, tab_width=8) ->
(<indentation-of-'marker'>, <indentation-width>)"""
# Figure out how much the marker is indented.
INDENT_CHARS = tuple(' \t')
start = s.index(marker)
i = start
while i > 0:
if s[i - 1] not in INDEN... | _get_indent(marker, s, tab_width=8) ->
(<indentation-of-'marker'>, <indentation-width>) | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/cmdln.py#L1592-L1610 |
joyent/python-manta | manta/cmdln.py | _get_trailing_whitespace | def _get_trailing_whitespace(marker, s):
"""Return the whitespace content trailing the given 'marker' in string 's',
up to and including a newline.
"""
suffix = ''
start = s.index(marker) + len(marker)
i = start
while i < len(s):
if s[i] in ' \t':
suffix += s[i]
e... | python | def _get_trailing_whitespace(marker, s):
"""Return the whitespace content trailing the given 'marker' in string 's',
up to and including a newline.
"""
suffix = ''
start = s.index(marker) + len(marker)
i = start
while i < len(s):
if s[i] in ' \t':
suffix += s[i]
e... | Return the whitespace content trailing the given 'marker' in string 's',
up to and including a newline. | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/cmdln.py#L1613-L1631 |
joyent/python-manta | manta/cmdln.py | RawCmdln.get_optparser | def get_optparser(self):
"""Hook for subclasses to set the option parser for the
top-level command/shell.
This option parser is used retrieved and used by `.main()' to
handle top-level options.
The default implements a single '-h|--help' option. Sub-classes
can return N... | python | def get_optparser(self):
"""Hook for subclasses to set the option parser for the
top-level command/shell.
This option parser is used retrieved and used by `.main()' to
handle top-level options.
The default implements a single '-h|--help' option. Sub-classes
can return N... | Hook for subclasses to set the option parser for the
top-level command/shell.
This option parser is used retrieved and used by `.main()' to
handle top-level options.
The default implements a single '-h|--help' option. Sub-classes
can return None to have no options at the top-le... | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/cmdln.py#L178-L191 |
joyent/python-manta | manta/cmdln.py | RawCmdln.main | def main(self, argv=None, loop=LOOP_NEVER):
"""A possible mainline handler for a script, like so:
import cmdln
class MyCmd(cmdln.Cmdln):
name = "mycmd"
...
if __name__ == "__main__":
MyCmd().main()
By default this wil... | python | def main(self, argv=None, loop=LOOP_NEVER):
"""A possible mainline handler for a script, like so:
import cmdln
class MyCmd(cmdln.Cmdln):
name = "mycmd"
...
if __name__ == "__main__":
MyCmd().main()
By default this wil... | A possible mainline handler for a script, like so:
import cmdln
class MyCmd(cmdln.Cmdln):
name = "mycmd"
...
if __name__ == "__main__":
MyCmd().main()
By default this will use sys.argv to issue a single command to
'My... | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/cmdln.py#L204-L270 |
joyent/python-manta | manta/cmdln.py | RawCmdln.cmd | def cmd(self, argv):
"""Run one command and exit.
"argv" is the arglist for the command to run. argv[0] is the
command to run. If argv is an empty list then the
'emptyline' handler is run.
Returns the return value from the command handler.
"""
... | python | def cmd(self, argv):
"""Run one command and exit.
"argv" is the arglist for the command to run. argv[0] is the
command to run. If argv is an empty list then the
'emptyline' handler is run.
Returns the return value from the command handler.
"""
... | Run one command and exit.
"argv" is the arglist for the command to run. argv[0] is the
command to run. If argv is an empty list then the
'emptyline' handler is run.
Returns the return value from the command handler. | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/cmdln.py#L272-L292 |
joyent/python-manta | manta/cmdln.py | RawCmdln.cmdloop | def cmdloop(self, intro=None):
"""Repeatedly issue a prompt, accept input, parse into an argv, and
dispatch (via .precmd(), .onecmd() and .postcmd()), passing them
the argv. In other words, start a shell.
"intro" (optional) is a introductory message to print when
sta... | python | def cmdloop(self, intro=None):
"""Repeatedly issue a prompt, accept input, parse into an argv, and
dispatch (via .precmd(), .onecmd() and .postcmd()), passing them
the argv. In other words, start a shell.
"intro" (optional) is a introductory message to print when
sta... | Repeatedly issue a prompt, accept input, parse into an argv, and
dispatch (via .precmd(), .onecmd() and .postcmd()), passing them
the argv. In other words, start a shell.
"intro" (optional) is a introductory message to print when
starting the command loop. This overrides the... | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/cmdln.py#L306-L376 |
joyent/python-manta | manta/cmdln.py | RawCmdln.cmdexc | def cmdexc(self, argv):
"""Called if an exception is raised in any of precmd(), onecmd(),
or postcmd(). If True is returned, the exception is deemed to have
been dealt with. Otherwise, the exception is re-raised.
The default implementation handles CmdlnUserError's, which
typical... | python | def cmdexc(self, argv):
"""Called if an exception is raised in any of precmd(), onecmd(),
or postcmd(). If True is returned, the exception is deemed to have
been dealt with. Otherwise, the exception is re-raised.
The default implementation handles CmdlnUserError's, which
typical... | Called if an exception is raised in any of precmd(), onecmd(),
or postcmd(). If True is returned, the exception is deemed to have
been dealt with. Otherwise, the exception is re-raised.
The default implementation handles CmdlnUserError's, which
typically correspond to user error in call... | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/cmdln.py#L396-L413 |
joyent/python-manta | manta/cmdln.py | RawCmdln.default | def default(self, argv):
"""Hook called to handle a command for which there is no handler.
"argv" is the command and arguments to run.
The default implementation writes an error message to stderr
and returns an error exit status.
Returns a numeric command exit status.
... | python | def default(self, argv):
"""Hook called to handle a command for which there is no handler.
"argv" is the command and arguments to run.
The default implementation writes an error message to stderr
and returns an error exit status.
Returns a numeric command exit status.
... | Hook called to handle a command for which there is no handler.
"argv" is the command and arguments to run.
The default implementation writes an error message to stderr
and returns an error exit status.
Returns a numeric command exit status. | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/cmdln.py#L434-L451 |
joyent/python-manta | manta/cmdln.py | RawCmdln.helpdefault | def helpdefault(self, cmd, known):
"""Hook called to handle help on a command for which there is no
help handler.
"cmd" is the command name on which help was requested.
"known" is a boolean indicating if this command is known
(i.e. if there is a handler for it).
... | python | def helpdefault(self, cmd, known):
"""Hook called to handle help on a command for which there is no
help handler.
"cmd" is the command name on which help was requested.
"known" is a boolean indicating if this command is known
(i.e. if there is a handler for it).
... | Hook called to handle help on a command for which there is no
help handler.
"cmd" is the command name on which help was requested.
"known" is a boolean indicating if this command is known
(i.e. if there is a handler for it).
Returns a return code. | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/cmdln.py#L468-L493 |
joyent/python-manta | manta/cmdln.py | RawCmdln.do_help | def do_help(self, argv):
"""${cmd_name}: give detailed help on a specific sub-command
Usage:
${name} help [COMMAND]
"""
if len(argv) > 1: # asking for help on a particular command
doc = None
cmdname = self._get_canonical_cmd_name(argv[1]) or argv[1]
... | python | def do_help(self, argv):
"""${cmd_name}: give detailed help on a specific sub-command
Usage:
${name} help [COMMAND]
"""
if len(argv) > 1: # asking for help on a particular command
doc = None
cmdname = self._get_canonical_cmd_name(argv[1]) or argv[1]
... | ${cmd_name}: give detailed help on a specific sub-command
Usage:
${name} help [COMMAND] | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/cmdln.py#L495-L537 |
joyent/python-manta | manta/cmdln.py | RawCmdln._help_reindent | def _help_reindent(self, help, indent=None):
"""Hook to re-indent help strings before writing to stdout.
"help" is the help content to re-indent
"indent" is a string with which to indent each line of the
help content after normalizing. If unspecified or None
... | python | def _help_reindent(self, help, indent=None):
"""Hook to re-indent help strings before writing to stdout.
"help" is the help content to re-indent
"indent" is a string with which to indent each line of the
help content after normalizing. If unspecified or None
... | Hook to re-indent help strings before writing to stdout.
"help" is the help content to re-indent
"indent" is a string with which to indent each line of the
help content after normalizing. If unspecified or None
then the default is use: the 'self.helpindent' class... | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/cmdln.py#L541-L567 |
joyent/python-manta | manta/cmdln.py | RawCmdln._help_preprocess | def _help_preprocess(self, help, cmdname):
"""Hook to preprocess a help string before writing to stdout.
"help" is the help string to process.
"cmdname" is the canonical sub-command name for which help
is being given, or None if the help is not specific to a
... | python | def _help_preprocess(self, help, cmdname):
"""Hook to preprocess a help string before writing to stdout.
"help" is the help string to process.
"cmdname" is the canonical sub-command name for which help
is being given, or None if the help is not specific to a
... | Hook to preprocess a help string before writing to stdout.
"help" is the help string to process.
"cmdname" is the canonical sub-command name for which help
is being given, or None if the help is not specific to a
command.
By default the following templat... | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/cmdln.py#L569-L617 |
joyent/python-manta | manta/cmdln.py | RawCmdln._get_help_names | def _get_help_names(self):
"""Return a mapping of help topic name to `.help_*()` method."""
# Determine the additional help topics, if any.
help_names = {}
token2cmdname = self._get_canonical_map()
for attrname, attr in self._gen_names_and_attrs():
if not attrname.sta... | python | def _get_help_names(self):
"""Return a mapping of help topic name to `.help_*()` method."""
# Determine the additional help topics, if any.
help_names = {}
token2cmdname = self._get_canonical_map()
for attrname, attr in self._gen_names_and_attrs():
if not attrname.sta... | Return a mapping of help topic name to `.help_*()` method. | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/cmdln.py#L711-L721 |
joyent/python-manta | manta/cmdln.py | RawCmdln._get_canonical_map | def _get_canonical_map(self):
"""Return a mapping of available command names and aliases to
their canonical command name.
"""
cacheattr = "_token2canonical"
if not hasattr(self, cacheattr):
# Get the list of commands and their aliases, if any.
token2canoni... | python | def _get_canonical_map(self):
"""Return a mapping of available command names and aliases to
their canonical command name.
"""
cacheattr = "_token2canonical"
if not hasattr(self, cacheattr):
# Get the list of commands and their aliases, if any.
token2canoni... | Return a mapping of available command names and aliases to
their canonical command name. | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/cmdln.py#L851-L879 |
joyent/python-manta | manta/cmdln.py | SubCmdOptionParser.set_cmdln_info | def set_cmdln_info(self, cmdln, subcmd):
"""Called by Cmdln to pass relevant info about itself needed
for print_help().
"""
self.cmdln = cmdln
self.subcmd = subcmd | python | def set_cmdln_info(self, cmdln, subcmd):
"""Called by Cmdln to pass relevant info about itself needed
for print_help().
"""
self.cmdln = cmdln
self.subcmd = subcmd | Called by Cmdln to pass relevant info about itself needed
for print_help(). | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/cmdln.py#L1009-L1014 |
joyent/python-manta | manta/cmdln.py | Cmdln._dispatch_cmd | def _dispatch_cmd(self, handler, argv):
"""Introspect sub-command handler signature to determine how to
dispatch the command. The raw handler provided by the base
'RawCmdln' class is still supported:
def do_foo(self, argv):
# 'argv' is the vector of command line args... | python | def _dispatch_cmd(self, handler, argv):
"""Introspect sub-command handler signature to determine how to
dispatch the command. The raw handler provided by the base
'RawCmdln' class is still supported:
def do_foo(self, argv):
# 'argv' is the vector of command line args... | Introspect sub-command handler signature to determine how to
dispatch the command. The raw handler provided by the base
'RawCmdln' class is still supported:
def do_foo(self, argv):
# 'argv' is the vector of command line args, argv[0] is
# the command name its... | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/cmdln.py#L1075-L1152 |
joyent/python-manta | tools/which.py | _getRegisteredExecutable | def _getRegisteredExecutable(exeName):
"""Windows allow application paths to be registered in the registry."""
registered = None
if sys.platform.startswith('win'):
if os.path.splitext(exeName)[1].lower() != '.exe':
exeName += '.exe'
import _winreg
try:
key = "... | python | def _getRegisteredExecutable(exeName):
"""Windows allow application paths to be registered in the registry."""
registered = None
if sys.platform.startswith('win'):
if os.path.splitext(exeName)[1].lower() != '.exe':
exeName += '.exe'
import _winreg
try:
key = "... | Windows allow application paths to be registered in the registry. | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/tools/which.py#L90-L106 |
joyent/python-manta | tools/which.py | whichgen | def whichgen(command, path=None, verbose=0, exts=None):
"""Return a generator of full paths to the given command.
"command" is a the name of the executable to search for.
"path" is an optional alternate path list to search. The default it
to use the PATH environment variable.
"verbose", if ... | python | def whichgen(command, path=None, verbose=0, exts=None):
"""Return a generator of full paths to the given command.
"command" is a the name of the executable to search for.
"path" is an optional alternate path list to search. The default it
to use the PATH environment variable.
"verbose", if ... | Return a generator of full paths to the given command.
"command" is a the name of the executable to search for.
"path" is an optional alternate path list to search. The default it
to use the PATH environment variable.
"verbose", if true, will cause a 2-tuple to be returned for each
matc... | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/tools/which.py#L144-L233 |
joyent/python-manta | tools/which.py | whichall | def whichall(command, path=None, verbose=0, exts=None):
"""Return a list of full paths to all matches of the given command
on the path.
"command" is a the name of the executable to search for.
"path" is an optional alternate path list to search. The default it
to use the PATH environment vari... | python | def whichall(command, path=None, verbose=0, exts=None):
"""Return a list of full paths to all matches of the given command
on the path.
"command" is a the name of the executable to search for.
"path" is an optional alternate path list to search. The default it
to use the PATH environment vari... | Return a list of full paths to all matches of the given command
on the path.
"command" is a the name of the executable to search for.
"path" is an optional alternate path list to search. The default it
to use the PATH environment variable.
"verbose", if true, will cause a 2-tuple to be return... | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/tools/which.py#L261-L278 |
joyent/python-manta | setup.py | get_version | def get_version():
"""Get the python-manta version without having to import the manta package,
which requires deps to already be installed.
"""
_globals = {}
_locals = {}
exec(
compile(
open(TOP + "/manta/version.py").read(), TOP + "/manta/version.py",
'exec'), _g... | python | def get_version():
"""Get the python-manta version without having to import the manta package,
which requires deps to already be installed.
"""
_globals = {}
_locals = {}
exec(
compile(
open(TOP + "/manta/version.py").read(), TOP + "/manta/version.py",
'exec'), _g... | Get the python-manta version without having to import the manta package,
which requires deps to already be installed. | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/setup.py#L18-L28 |
joyent/python-manta | manta/auth.py | fingerprint_from_ssh_pub_key | def fingerprint_from_ssh_pub_key(data):
"""Calculate the fingerprint of SSH public key data.
>>> data = "ssh-rsa AAAAB3NzaC1y...4IEAA1Z4wIWCuk8F9Tzw== my key comment"
>>> fingerprint_from_ssh_pub_key(data)
'54:c7:4c:93:cf:ff:e3:32:68:bc:89:6e:5e:22:b5:9c'
Adapted from <http://stackoverflow.com/que... | python | def fingerprint_from_ssh_pub_key(data):
"""Calculate the fingerprint of SSH public key data.
>>> data = "ssh-rsa AAAAB3NzaC1y...4IEAA1Z4wIWCuk8F9Tzw== my key comment"
>>> fingerprint_from_ssh_pub_key(data)
'54:c7:4c:93:cf:ff:e3:32:68:bc:89:6e:5e:22:b5:9c'
Adapted from <http://stackoverflow.com/que... | Calculate the fingerprint of SSH public key data.
>>> data = "ssh-rsa AAAAB3NzaC1y...4IEAA1Z4wIWCuk8F9Tzw== my key comment"
>>> fingerprint_from_ssh_pub_key(data)
'54:c7:4c:93:cf:ff:e3:32:68:bc:89:6e:5e:22:b5:9c'
Adapted from <http://stackoverflow.com/questions/6682815/>
and imgapi.js#fingerprintF... | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/auth.py#L63-L86 |
joyent/python-manta | manta/auth.py | fingerprint_from_raw_ssh_pub_key | def fingerprint_from_raw_ssh_pub_key(key):
"""Encode a raw SSH key (string of bytes, as from
`str(paramiko.AgentKey)`) to a fingerprint in the typical
'54:c7:4c:93:cf:ff:e3:32:68:bc:89:6e:5e:22:b5:9c' form.
"""
fp_plain = hashlib.md5(key).hexdigest()
return ':'.join(a + b for a, b in zip(fp_plai... | python | def fingerprint_from_raw_ssh_pub_key(key):
"""Encode a raw SSH key (string of bytes, as from
`str(paramiko.AgentKey)`) to a fingerprint in the typical
'54:c7:4c:93:cf:ff:e3:32:68:bc:89:6e:5e:22:b5:9c' form.
"""
fp_plain = hashlib.md5(key).hexdigest()
return ':'.join(a + b for a, b in zip(fp_plai... | Encode a raw SSH key (string of bytes, as from
`str(paramiko.AgentKey)`) to a fingerprint in the typical
'54:c7:4c:93:cf:ff:e3:32:68:bc:89:6e:5e:22:b5:9c' form. | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/auth.py#L89-L95 |
joyent/python-manta | manta/auth.py | sha256_fingerprint_from_raw_ssh_pub_key | def sha256_fingerprint_from_raw_ssh_pub_key(raw_key):
"""Encode a raw SSH key (string of bytes, as from
`str(paramiko.AgentKey)`) to a fingerprint in the SHA256 form:
SHA256:j2WoSeOWhFy69BQ39fuafFAySp9qCZTSCEyT2vRKcL+s
"""
digest = hashlib.sha256(raw_key).digest()
h = base64.b64encode(digest... | python | def sha256_fingerprint_from_raw_ssh_pub_key(raw_key):
"""Encode a raw SSH key (string of bytes, as from
`str(paramiko.AgentKey)`) to a fingerprint in the SHA256 form:
SHA256:j2WoSeOWhFy69BQ39fuafFAySp9qCZTSCEyT2vRKcL+s
"""
digest = hashlib.sha256(raw_key).digest()
h = base64.b64encode(digest... | Encode a raw SSH key (string of bytes, as from
`str(paramiko.AgentKey)`) to a fingerprint in the SHA256 form:
SHA256:j2WoSeOWhFy69BQ39fuafFAySp9qCZTSCEyT2vRKcL+s | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/auth.py#L111-L119 |
joyent/python-manta | manta/auth.py | load_ssh_key | def load_ssh_key(key_id, skip_priv_key=False):
"""
Load a local ssh private key (in PEM format). PEM format is the OpenSSH
default format for private keys.
See similar code in imgapi.js#loadSSHKey.
@param key_id {str} An ssh public key fingerprint or ssh private key path.
@param skip_priv_key ... | python | def load_ssh_key(key_id, skip_priv_key=False):
"""
Load a local ssh private key (in PEM format). PEM format is the OpenSSH
default format for private keys.
See similar code in imgapi.js#loadSSHKey.
@param key_id {str} An ssh public key fingerprint or ssh private key path.
@param skip_priv_key ... | Load a local ssh private key (in PEM format). PEM format is the OpenSSH
default format for private keys.
See similar code in imgapi.js#loadSSHKey.
@param key_id {str} An ssh public key fingerprint or ssh private key path.
@param skip_priv_key {boolean} Optional. Default false. If true, then this
... | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/auth.py#L121-L225 |
joyent/python-manta | manta/auth.py | ssh_key_info_from_key_data | def ssh_key_info_from_key_data(key_id, priv_key=None):
"""Get/load SSH key info necessary for signing.
@param key_id {str} Either a private ssh key fingerprint, e.g.
'b3:f0:a1:6c:18:3b:42:63:fd:6e:57:42:74:17:d4:bc', or the path to
an ssh private key file (like ssh's IdentityFile config option)... | python | def ssh_key_info_from_key_data(key_id, priv_key=None):
"""Get/load SSH key info necessary for signing.
@param key_id {str} Either a private ssh key fingerprint, e.g.
'b3:f0:a1:6c:18:3b:42:63:fd:6e:57:42:74:17:d4:bc', or the path to
an ssh private key file (like ssh's IdentityFile config option)... | Get/load SSH key info necessary for signing.
@param key_id {str} Either a private ssh key fingerprint, e.g.
'b3:f0:a1:6c:18:3b:42:63:fd:6e:57:42:74:17:d4:bc', or the path to
an ssh private key file (like ssh's IdentityFile config option).
@param priv_key {str} Optional. SSH private key file dat... | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/auth.py#L246-L310 |
joyent/python-manta | manta/auth.py | agent_key_info_from_key_id | def agent_key_info_from_key_id(key_id):
"""Find a matching key in the ssh-agent.
@param key_id {str} Either a private ssh key fingerprint, e.g.
'b3:f0:a1:6c:18:3b:42:63:fd:6e:57:42:74:17:d4:bc', or the path to
an ssh private key file (like ssh's IdentityFile config option).
@return {dict} w... | python | def agent_key_info_from_key_id(key_id):
"""Find a matching key in the ssh-agent.
@param key_id {str} Either a private ssh key fingerprint, e.g.
'b3:f0:a1:6c:18:3b:42:63:fd:6e:57:42:74:17:d4:bc', or the path to
an ssh private key file (like ssh's IdentityFile config option).
@return {dict} w... | Find a matching key in the ssh-agent.
@param key_id {str} Either a private ssh key fingerprint, e.g.
'b3:f0:a1:6c:18:3b:42:63:fd:6e:57:42:74:17:d4:bc', or the path to
an ssh private key file (like ssh's IdentityFile config option).
@return {dict} with these keys:
- type: "agent"
... | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/auth.py#L312-L362 |
joyent/python-manta | manta/auth.py | PrivateKeySigner._get_key_info | def _get_key_info(self):
"""Get key info appropriate for signing."""
if self._key_info_cache is None:
self._key_info_cache = ssh_key_info_from_key_data(self.key_id,
self.priv_key)
return self._key_info_cache | python | def _get_key_info(self):
"""Get key info appropriate for signing."""
if self._key_info_cache is None:
self._key_info_cache = ssh_key_info_from_key_data(self.key_id,
self.priv_key)
return self._key_info_cache | Get key info appropriate for signing. | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/auth.py#L431-L436 |
joyent/python-manta | manta/auth.py | SSHAgentSigner._get_key_info | def _get_key_info(self):
"""Get key info appropriate for signing."""
if self._key_info_cache is None:
self._key_info_cache = agent_key_info_from_key_id(self.key_id)
return self._key_info_cache | python | def _get_key_info(self):
"""Get key info appropriate for signing."""
if self._key_info_cache is None:
self._key_info_cache = agent_key_info_from_key_id(self.key_id)
return self._key_info_cache | Get key info appropriate for signing. | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/auth.py#L465-L469 |
joyent/python-manta | manta/auth.py | CLISigner._get_key_info | def _get_key_info(self):
"""Get key info appropriate for signing: either from the ssh agent
or from a private key.
"""
if self._key_info_cache is not None:
return self._key_info_cache
errors = []
# First try the agent.
try:
key_info = age... | python | def _get_key_info(self):
"""Get key info appropriate for signing: either from the ssh agent
or from a private key.
"""
if self._key_info_cache is not None:
return self._key_info_cache
errors = []
# First try the agent.
try:
key_info = age... | Get key info appropriate for signing: either from the ssh agent
or from a private key. | https://github.com/joyent/python-manta/blob/f68ef142bdbac058c981e3b28e18d77612f5b7c6/manta/auth.py#L502-L532 |
src-d/lookout-sdk | python/lookout/sdk/grpc/connection.py | create_channel | def create_channel(
target: str,
options: Optional[List[Tuple[str, Any]]] = None,
interceptors: Optional[List[ClientInterceptor]] = None,
) -> grpc.Channel:
"""Creates a gRPC channel
The gRPC channel is created with the provided options and intercepts each
invocation via the provide... | python | def create_channel(
target: str,
options: Optional[List[Tuple[str, Any]]] = None,
interceptors: Optional[List[ClientInterceptor]] = None,
) -> grpc.Channel:
"""Creates a gRPC channel
The gRPC channel is created with the provided options and intercepts each
invocation via the provide... | Creates a gRPC channel
The gRPC channel is created with the provided options and intercepts each
invocation via the provided interceptors.
The created channel is configured with the following default options:
- "grpc.max_send_message_length": 100MB,
- "grpc.max_receive_message_length": 100... | https://github.com/src-d/lookout-sdk/blob/2ca64a77b022864fed3bb31d12997712c7e98e6e/python/lookout/sdk/grpc/connection.py#L20-L48 |
src-d/lookout-sdk | python/lookout/sdk/grpc/connection.py | create_server | def create_server(
max_workers: int,
options: Optional[List[Tuple[str, Any]]] = None,
interceptors: Optional[List[grpc.ServerInterceptor]] = None,
) -> grpc.Server:
"""Creates a gRPC server
The gRPC server is created with the provided options and intercepts each
incoming RPCs via th... | python | def create_server(
max_workers: int,
options: Optional[List[Tuple[str, Any]]] = None,
interceptors: Optional[List[grpc.ServerInterceptor]] = None,
) -> grpc.Server:
"""Creates a gRPC server
The gRPC server is created with the provided options and intercepts each
incoming RPCs via th... | Creates a gRPC server
The gRPC server is created with the provided options and intercepts each
incoming RPCs via the provided interceptors.
The created server is configured with the following default options:
- "grpc.max_send_message_length": 100MB,
- "grpc.max_receive_message_length": 100... | https://github.com/src-d/lookout-sdk/blob/2ca64a77b022864fed3bb31d12997712c7e98e6e/python/lookout/sdk/grpc/connection.py#L51-L87 |
src-d/lookout-sdk | python/lookout/sdk/grpc/connection.py | to_grpc_address | def to_grpc_address(target: str) -> str:
"""Converts a standard gRPC target to one that is supported by grpcio
:param target: the server address.
:returns: the converted address.
"""
u = urlparse(target)
if u.scheme == "dns":
raise ValueError("dns:// not supported")
if u.scheme ==... | python | def to_grpc_address(target: str) -> str:
"""Converts a standard gRPC target to one that is supported by grpcio
:param target: the server address.
:returns: the converted address.
"""
u = urlparse(target)
if u.scheme == "dns":
raise ValueError("dns:// not supported")
if u.scheme ==... | Converts a standard gRPC target to one that is supported by grpcio
:param target: the server address.
:returns: the converted address. | https://github.com/src-d/lookout-sdk/blob/2ca64a77b022864fed3bb31d12997712c7e98e6e/python/lookout/sdk/grpc/connection.py#L90-L104 |
openego/eDisGo | edisgo/flex_opt/storage_positioning.py | one_storage_per_feeder | def one_storage_per_feeder(edisgo, storage_timeseries,
storage_nominal_power=None, **kwargs):
"""
Allocates the given storage capacity to multiple smaller storages.
For each feeder with load or voltage issues it is checked if integrating a
storage will reduce peaks in the fee... | python | def one_storage_per_feeder(edisgo, storage_timeseries,
storage_nominal_power=None, **kwargs):
"""
Allocates the given storage capacity to multiple smaller storages.
For each feeder with load or voltage issues it is checked if integrating a
storage will reduce peaks in the fee... | Allocates the given storage capacity to multiple smaller storages.
For each feeder with load or voltage issues it is checked if integrating a
storage will reduce peaks in the feeder, starting with the feeder with
the highest theoretical grid expansion costs. A heuristic approach is used
to estimate sto... | https://github.com/openego/eDisGo/blob/e6245bdaf236f9c49dbda5a18c1c458290f41e2b/edisgo/flex_opt/storage_positioning.py#L18-L637 |
openego/eDisGo | edisgo/grid/tools.py | position_switch_disconnectors | def position_switch_disconnectors(mv_grid, mode='load', status='open'):
"""
Determine position of switch disconnector in MV grid rings
Determination of the switch disconnector location is motivated by placing
it to minimized load flows in both parts of the ring (half-rings).
The switch disconnecter... | python | def position_switch_disconnectors(mv_grid, mode='load', status='open'):
"""
Determine position of switch disconnector in MV grid rings
Determination of the switch disconnector location is motivated by placing
it to minimized load flows in both parts of the ring (half-rings).
The switch disconnecter... | Determine position of switch disconnector in MV grid rings
Determination of the switch disconnector location is motivated by placing
it to minimized load flows in both parts of the ring (half-rings).
The switch disconnecter will be installed to a LV station, unless none
exists in a ring. In this case, ... | https://github.com/openego/eDisGo/blob/e6245bdaf236f9c49dbda5a18c1c458290f41e2b/edisgo/grid/tools.py#L16-L208 |
openego/eDisGo | edisgo/grid/tools.py | implement_switch_disconnector | def implement_switch_disconnector(mv_grid, node1, node2):
"""
Install switch disconnector in grid topology
The graph that represents the grid's topology is altered in such way that
it explicitly includes a switch disconnector.
The switch disconnector is always located at ``node1``. Technically, it
... | python | def implement_switch_disconnector(mv_grid, node1, node2):
"""
Install switch disconnector in grid topology
The graph that represents the grid's topology is altered in such way that
it explicitly includes a switch disconnector.
The switch disconnector is always located at ``node1``. Technically, it
... | Install switch disconnector in grid topology
The graph that represents the grid's topology is altered in such way that
it explicitly includes a switch disconnector.
The switch disconnector is always located at ``node1``. Technically, it
does not make any difference. This is just an convention ensuring
... | https://github.com/openego/eDisGo/blob/e6245bdaf236f9c49dbda5a18c1c458290f41e2b/edisgo/grid/tools.py#L211-L278 |
openego/eDisGo | edisgo/grid/tools.py | select_cable | def select_cable(network, level, apparent_power):
"""Selects an appropriate cable type and quantity using given apparent
power.
Considers load factor.
Parameters
----------
network : :class:`~.grid.network.Network`
The eDisGo container object
level : :obj:`str`
Grid level (... | python | def select_cable(network, level, apparent_power):
"""Selects an appropriate cable type and quantity using given apparent
power.
Considers load factor.
Parameters
----------
network : :class:`~.grid.network.Network`
The eDisGo container object
level : :obj:`str`
Grid level (... | Selects an appropriate cable type and quantity using given apparent
power.
Considers load factor.
Parameters
----------
network : :class:`~.grid.network.Network`
The eDisGo container object
level : :obj:`str`
Grid level ('mv' or 'lv')
apparent_power : :obj:`float`
A... | https://github.com/openego/eDisGo/blob/e6245bdaf236f9c49dbda5a18c1c458290f41e2b/edisgo/grid/tools.py#L281-L359 |
openego/eDisGo | edisgo/grid/tools.py | get_gen_info | def get_gen_info(network, level='mvlv', fluctuating=False):
"""
Gets all the installed generators with some additional information.
Parameters
----------
network : :class:`~.grid.network.Network`
Network object holding the grid data.
level : :obj:`str`
Defines which generators a... | python | def get_gen_info(network, level='mvlv', fluctuating=False):
"""
Gets all the installed generators with some additional information.
Parameters
----------
network : :class:`~.grid.network.Network`
Network object holding the grid data.
level : :obj:`str`
Defines which generators a... | Gets all the installed generators with some additional information.
Parameters
----------
network : :class:`~.grid.network.Network`
Network object holding the grid data.
level : :obj:`str`
Defines which generators are returned. Possible options are:
* 'mv'
Only genera... | https://github.com/openego/eDisGo/blob/e6245bdaf236f9c49dbda5a18c1c458290f41e2b/edisgo/grid/tools.py#L362-L452 |
openego/eDisGo | edisgo/grid/tools.py | assign_mv_feeder_to_nodes | def assign_mv_feeder_to_nodes(mv_grid):
"""
Assigns an MV feeder to every generator, LV station, load, and branch tee
Parameters
-----------
mv_grid : :class:`~.grid.grids.MVGrid`
"""
mv_station_neighbors = mv_grid.graph.neighbors(mv_grid.station)
# get all nodes in MV grid and remove ... | python | def assign_mv_feeder_to_nodes(mv_grid):
"""
Assigns an MV feeder to every generator, LV station, load, and branch tee
Parameters
-----------
mv_grid : :class:`~.grid.grids.MVGrid`
"""
mv_station_neighbors = mv_grid.graph.neighbors(mv_grid.station)
# get all nodes in MV grid and remove ... | Assigns an MV feeder to every generator, LV station, load, and branch tee
Parameters
-----------
mv_grid : :class:`~.grid.grids.MVGrid` | https://github.com/openego/eDisGo/blob/e6245bdaf236f9c49dbda5a18c1c458290f41e2b/edisgo/grid/tools.py#L455-L483 |
openego/eDisGo | edisgo/grid/tools.py | get_mv_feeder_from_line | def get_mv_feeder_from_line(line):
"""
Determines MV feeder the given line is in.
MV feeders are identified by the first line segment of the half-ring.
Parameters
----------
line : :class:`~.grid.components.Line`
Line to find the MV feeder for.
Returns
-------
:class:`~.gr... | python | def get_mv_feeder_from_line(line):
"""
Determines MV feeder the given line is in.
MV feeders are identified by the first line segment of the half-ring.
Parameters
----------
line : :class:`~.grid.components.Line`
Line to find the MV feeder for.
Returns
-------
:class:`~.gr... | Determines MV feeder the given line is in.
MV feeders are identified by the first line segment of the half-ring.
Parameters
----------
line : :class:`~.grid.components.Line`
Line to find the MV feeder for.
Returns
-------
:class:`~.grid.components.Line`
MV feeder identifie... | https://github.com/openego/eDisGo/blob/e6245bdaf236f9c49dbda5a18c1c458290f41e2b/edisgo/grid/tools.py#L486-L531 |
openego/eDisGo | edisgo/grid/tools.py | disconnect_storage | def disconnect_storage(network, storage):
"""
Removes storage from network graph and pypsa representation.
Parameters
-----------
network : :class:`~.grid.network.Network`
storage : :class:`~.grid.components.Storage`
Storage instance to be removed.
"""
# does only remove from n... | python | def disconnect_storage(network, storage):
"""
Removes storage from network graph and pypsa representation.
Parameters
-----------
network : :class:`~.grid.network.Network`
storage : :class:`~.grid.components.Storage`
Storage instance to be removed.
"""
# does only remove from n... | Removes storage from network graph and pypsa representation.
Parameters
-----------
network : :class:`~.grid.network.Network`
storage : :class:`~.grid.components.Storage`
Storage instance to be removed. | https://github.com/openego/eDisGo/blob/e6245bdaf236f9c49dbda5a18c1c458290f41e2b/edisgo/grid/tools.py#L534-L567 |
openego/eDisGo | edisgo/grid/grids.py | Grid.weather_cells | def weather_cells(self):
"""
Weather cells contained in grid
Returns
-------
list
list of weather cell ids contained in grid
"""
if not self._weather_cells:
# get all the weather cell ids
self._weather_cells = []
f... | python | def weather_cells(self):
"""
Weather cells contained in grid
Returns
-------
list
list of weather cell ids contained in grid
"""
if not self._weather_cells:
# get all the weather cell ids
self._weather_cells = []
f... | Weather cells contained in grid
Returns
-------
list
list of weather cell ids contained in grid | https://github.com/openego/eDisGo/blob/e6245bdaf236f9c49dbda5a18c1c458290f41e2b/edisgo/grid/grids.py#L93-L115 |
openego/eDisGo | edisgo/grid/grids.py | Grid.peak_generation | def peak_generation(self):
"""
Cumulative peak generation capacity of generators of this grid
Returns
-------
float
Ad-hoc calculated or cached peak generation capacity
"""
if self._peak_generation is None:
self._peak_generation = sum(
... | python | def peak_generation(self):
"""
Cumulative peak generation capacity of generators of this grid
Returns
-------
float
Ad-hoc calculated or cached peak generation capacity
"""
if self._peak_generation is None:
self._peak_generation = sum(
... | Cumulative peak generation capacity of generators of this grid
Returns
-------
float
Ad-hoc calculated or cached peak generation capacity | https://github.com/openego/eDisGo/blob/e6245bdaf236f9c49dbda5a18c1c458290f41e2b/edisgo/grid/grids.py#L118-L132 |
openego/eDisGo | edisgo/grid/grids.py | Grid.peak_generation_per_technology | def peak_generation_per_technology(self):
"""
Peak generation of each technology in the grid
Returns
-------
:pandas:`pandas.Series<series>`
Peak generation index by technology
"""
peak_generation = defaultdict(float)
for gen in self.generator... | python | def peak_generation_per_technology(self):
"""
Peak generation of each technology in the grid
Returns
-------
:pandas:`pandas.Series<series>`
Peak generation index by technology
"""
peak_generation = defaultdict(float)
for gen in self.generator... | Peak generation of each technology in the grid
Returns
-------
:pandas:`pandas.Series<series>`
Peak generation index by technology | https://github.com/openego/eDisGo/blob/e6245bdaf236f9c49dbda5a18c1c458290f41e2b/edisgo/grid/grids.py#L135-L148 |
openego/eDisGo | edisgo/grid/grids.py | Grid.peak_generation_per_technology_and_weather_cell | def peak_generation_per_technology_and_weather_cell(self):
"""
Peak generation of each technology and the
corresponding weather cell in the grid
Returns
-------
:pandas:`pandas.Series<series>`
Peak generation index by technology
"""
peak_gen... | python | def peak_generation_per_technology_and_weather_cell(self):
"""
Peak generation of each technology and the
corresponding weather cell in the grid
Returns
-------
:pandas:`pandas.Series<series>`
Peak generation index by technology
"""
peak_gen... | Peak generation of each technology and the
corresponding weather cell in the grid
Returns
-------
:pandas:`pandas.Series<series>`
Peak generation index by technology | https://github.com/openego/eDisGo/blob/e6245bdaf236f9c49dbda5a18c1c458290f41e2b/edisgo/grid/grids.py#L151-L176 |
openego/eDisGo | edisgo/grid/grids.py | Grid.peak_load | def peak_load(self):
"""
Cumulative peak load capacity of generators of this grid
Returns
-------
float
Ad-hoc calculated or cached peak load capacity
"""
if self._peak_load is None:
self._peak_load = sum(
[_.peak_load.sum(... | python | def peak_load(self):
"""
Cumulative peak load capacity of generators of this grid
Returns
-------
float
Ad-hoc calculated or cached peak load capacity
"""
if self._peak_load is None:
self._peak_load = sum(
[_.peak_load.sum(... | Cumulative peak load capacity of generators of this grid
Returns
-------
float
Ad-hoc calculated or cached peak load capacity | https://github.com/openego/eDisGo/blob/e6245bdaf236f9c49dbda5a18c1c458290f41e2b/edisgo/grid/grids.py#L179-L193 |
openego/eDisGo | edisgo/grid/grids.py | Grid.consumption | def consumption(self):
"""
Consumption in kWh per sector for whole grid
Returns
-------
:pandas:`pandas.Series<series>`
Indexed by demand sector
"""
consumption = defaultdict(float)
for load in self.graph.nodes_by_attribute('load'):
... | python | def consumption(self):
"""
Consumption in kWh per sector for whole grid
Returns
-------
:pandas:`pandas.Series<series>`
Indexed by demand sector
"""
consumption = defaultdict(float)
for load in self.graph.nodes_by_attribute('load'):
... | Consumption in kWh per sector for whole grid
Returns
-------
:pandas:`pandas.Series<series>`
Indexed by demand sector | https://github.com/openego/eDisGo/blob/e6245bdaf236f9c49dbda5a18c1c458290f41e2b/edisgo/grid/grids.py#L196-L210 |
openego/eDisGo | edisgo/grid/grids.py | Grid.generators | def generators(self):
"""
Connected Generators within the grid
Returns
-------
list
List of Generator Objects
"""
if not self._generators:
generators = list(self.graph.nodes_by_attribute('generator'))
generators.extend(list(se... | python | def generators(self):
"""
Connected Generators within the grid
Returns
-------
list
List of Generator Objects
"""
if not self._generators:
generators = list(self.graph.nodes_by_attribute('generator'))
generators.extend(list(se... | Connected Generators within the grid
Returns
-------
list
List of Generator Objects | https://github.com/openego/eDisGo/blob/e6245bdaf236f9c49dbda5a18c1c458290f41e2b/edisgo/grid/grids.py#L213-L229 |
openego/eDisGo | edisgo/grid/grids.py | MVGrid.draw | def draw(self):
""" Draw MV grid's graph using the geo data of nodes
Notes
-----
This method uses the coordinates stored in the nodes' geoms which
are usually conformal, not equidistant. Therefore, the plot might
be distorted and does not (fully) reflect the real positio... | python | def draw(self):
""" Draw MV grid's graph using the geo data of nodes
Notes
-----
This method uses the coordinates stored in the nodes' geoms which
are usually conformal, not equidistant. Therefore, the plot might
be distorted and does not (fully) reflect the real positio... | Draw MV grid's graph using the geo data of nodes
Notes
-----
This method uses the coordinates stored in the nodes' geoms which
are usually conformal, not equidistant. Therefore, the plot might
be distorted and does not (fully) reflect the real positions or
distances betw... | https://github.com/openego/eDisGo/blob/e6245bdaf236f9c49dbda5a18c1c458290f41e2b/edisgo/grid/grids.py#L285-L303 |
openego/eDisGo | edisgo/grid/grids.py | Graph.nodes_from_line | def nodes_from_line(self, line):
"""
Get nodes adjacent to line
Here, line refers to the object behind the key 'line' of the attribute
dict attached to each edge.
Parameters
----------
line: edisgo.grid.components.Line
A eDisGo line object
R... | python | def nodes_from_line(self, line):
"""
Get nodes adjacent to line
Here, line refers to the object behind the key 'line' of the attribute
dict attached to each edge.
Parameters
----------
line: edisgo.grid.components.Line
A eDisGo line object
R... | Get nodes adjacent to line
Here, line refers to the object behind the key 'line' of the attribute
dict attached to each edge.
Parameters
----------
line: edisgo.grid.components.Line
A eDisGo line object
Returns
-------
tuple
Node... | https://github.com/openego/eDisGo/blob/e6245bdaf236f9c49dbda5a18c1c458290f41e2b/edisgo/grid/grids.py#L322-L341 |
openego/eDisGo | edisgo/grid/grids.py | Graph.line_from_nodes | def line_from_nodes(self, u, v):
"""
Get line between two nodes ``u`` and ``v``.
Parameters
----------
u : :class:`~.grid.components.Component`
One adjacent node
v : :class:`~.grid.components.Component`
The other adjacent node
Returns
... | python | def line_from_nodes(self, u, v):
"""
Get line between two nodes ``u`` and ``v``.
Parameters
----------
u : :class:`~.grid.components.Component`
One adjacent node
v : :class:`~.grid.components.Component`
The other adjacent node
Returns
... | Get line between two nodes ``u`` and ``v``.
Parameters
----------
u : :class:`~.grid.components.Component`
One adjacent node
v : :class:`~.grid.components.Component`
The other adjacent node
Returns
-------
Line
Line segment co... | https://github.com/openego/eDisGo/blob/e6245bdaf236f9c49dbda5a18c1c458290f41e2b/edisgo/grid/grids.py#L343-L368 |
openego/eDisGo | edisgo/grid/grids.py | Graph.nodes_by_attribute | def nodes_by_attribute(self, attr_val, attr='type'):
"""
Select Graph's nodes by attribute value
Get all nodes that share the same attribute. By default, the attr 'type'
is used to specify the nodes type (generator, load, etc.).
Examples
--------
>>> import edis... | python | def nodes_by_attribute(self, attr_val, attr='type'):
"""
Select Graph's nodes by attribute value
Get all nodes that share the same attribute. By default, the attr 'type'
is used to specify the nodes type (generator, load, etc.).
Examples
--------
>>> import edis... | Select Graph's nodes by attribute value
Get all nodes that share the same attribute. By default, the attr 'type'
is used to specify the nodes type (generator, load, etc.).
Examples
--------
>>> import edisgo
>>> G = edisgo.grids.Graph()
>>> G.add_node(1, type='g... | https://github.com/openego/eDisGo/blob/e6245bdaf236f9c49dbda5a18c1c458290f41e2b/edisgo/grid/grids.py#L370-L405 |
openego/eDisGo | edisgo/grid/grids.py | Graph.lines_by_attribute | def lines_by_attribute(self, attr_val=None, attr='type'):
""" Returns a generator for iterating over Graph's lines by attribute value.
Get all lines that share the same attribute. By default, the attr 'type'
is used to specify the lines' type (line, agg_line, etc.).
The edge of a graph... | python | def lines_by_attribute(self, attr_val=None, attr='type'):
""" Returns a generator for iterating over Graph's lines by attribute value.
Get all lines that share the same attribute. By default, the attr 'type'
is used to specify the lines' type (line, agg_line, etc.).
The edge of a graph... | Returns a generator for iterating over Graph's lines by attribute value.
Get all lines that share the same attribute. By default, the attr 'type'
is used to specify the lines' type (line, agg_line, etc.).
The edge of a graph is described by the two adjacent nodes and the line
object it... | https://github.com/openego/eDisGo/blob/e6245bdaf236f9c49dbda5a18c1c458290f41e2b/edisgo/grid/grids.py#L407-L478 |
src-d/lookout-sdk | python/lookout/sdk/grpc/interceptors/base.py | ServerInterceptorWrapper.intercept_service | def intercept_service(self, continuation, handler_call_details):
"""Intercepts incoming RPCs before handing them over to a handler
See `grpc.ServerInterceptor.intercept_service`.
"""
rpc_method_handler = self._get_rpc_handler(handler_call_details)
if rpc_method_handler.response... | python | def intercept_service(self, continuation, handler_call_details):
"""Intercepts incoming RPCs before handing them over to a handler
See `grpc.ServerInterceptor.intercept_service`.
"""
rpc_method_handler = self._get_rpc_handler(handler_call_details)
if rpc_method_handler.response... | Intercepts incoming RPCs before handing them over to a handler
See `grpc.ServerInterceptor.intercept_service`. | https://github.com/src-d/lookout-sdk/blob/2ca64a77b022864fed3bb31d12997712c7e98e6e/python/lookout/sdk/grpc/interceptors/base.py#L53-L72 |
openego/eDisGo | edisgo/tools/pypsa_io.py | to_pypsa | def to_pypsa(network, mode, timesteps):
"""
Translate graph based grid representation to PyPSA Network
For details from a user perspective see API documentation of
:meth:`~.grid.network.EDisGo.analyze` of the API class
:class:`~.grid.network.EDisGo`.
Translating eDisGo's grid topology to PyPSA... | python | def to_pypsa(network, mode, timesteps):
"""
Translate graph based grid representation to PyPSA Network
For details from a user perspective see API documentation of
:meth:`~.grid.network.EDisGo.analyze` of the API class
:class:`~.grid.network.EDisGo`.
Translating eDisGo's grid topology to PyPSA... | Translate graph based grid representation to PyPSA Network
For details from a user perspective see API documentation of
:meth:`~.grid.network.EDisGo.analyze` of the API class
:class:`~.grid.network.EDisGo`.
Translating eDisGo's grid topology to PyPSA representation is structured
into translating t... | https://github.com/openego/eDisGo/blob/e6245bdaf236f9c49dbda5a18c1c458290f41e2b/edisgo/tools/pypsa_io.py#L20-L192 |
openego/eDisGo | edisgo/tools/pypsa_io.py | mv_to_pypsa | def mv_to_pypsa(network):
"""Translate MV grid topology representation to PyPSA format
MV grid topology translated here includes
* MV station (no transformer, see :meth:`~.grid.network.EDisGo.analyze`)
* Loads, Generators, Lines, Storages, Branch Tees of MV grid level as well
as LV stations. LV ... | python | def mv_to_pypsa(network):
"""Translate MV grid topology representation to PyPSA format
MV grid topology translated here includes
* MV station (no transformer, see :meth:`~.grid.network.EDisGo.analyze`)
* Loads, Generators, Lines, Storages, Branch Tees of MV grid level as well
as LV stations. LV ... | Translate MV grid topology representation to PyPSA format
MV grid topology translated here includes
* MV station (no transformer, see :meth:`~.grid.network.EDisGo.analyze`)
* Loads, Generators, Lines, Storages, Branch Tees of MV grid level as well
as LV stations. LV stations do not have load and gen... | https://github.com/openego/eDisGo/blob/e6245bdaf236f9c49dbda5a18c1c458290f41e2b/edisgo/tools/pypsa_io.py#L195-L437 |
openego/eDisGo | edisgo/tools/pypsa_io.py | combine_mv_and_lv | def combine_mv_and_lv(mv, lv):
"""Combine MV and LV grid topology in PyPSA format
"""
combined = {
c: pd.concat([mv[c], lv[c]], axis=0) for c in list(lv.keys())
}
combined['Transformer'] = mv['Transformer']
return combined | python | def combine_mv_and_lv(mv, lv):
"""Combine MV and LV grid topology in PyPSA format
"""
combined = {
c: pd.concat([mv[c], lv[c]], axis=0) for c in list(lv.keys())
}
combined['Transformer'] = mv['Transformer']
return combined | Combine MV and LV grid topology in PyPSA format | https://github.com/openego/eDisGo/blob/e6245bdaf236f9c49dbda5a18c1c458290f41e2b/edisgo/tools/pypsa_io.py#L592-L602 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.