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_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
mitsei/dlkit | dlkit/json_/assessment/objects.py | AssessmentOfferedForm.clear_start_time | def clear_start_time(self):
"""Clears the start time.
raise: NoAccess - ``Metadata.isRequired()`` or
``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- This method must be implemented.*
"""
# Implemented from template for osid.assessment.Assessment... | python | def clear_start_time(self):
"""Clears the start time.
raise: NoAccess - ``Metadata.isRequired()`` or
``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- This method must be implemented.*
"""
# Implemented from template for osid.assessment.Assessment... | [
"def",
"clear_start_time",
"(",
"self",
")",
":",
"# Implemented from template for osid.assessment.AssessmentOfferedForm.clear_start_time_template",
"if",
"(",
"self",
".",
"get_start_time_metadata",
"(",
")",
".",
"is_read_only",
"(",
")",
"or",
"self",
".",
"get_start_tim... | Clears the start time.
raise: NoAccess - ``Metadata.isRequired()`` or
``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- This method must be implemented.* | [
"Clears",
"the",
"start",
"time",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment/objects.py#L1865-L1877 |
mitsei/dlkit | dlkit/json_/assessment/objects.py | AssessmentOfferedForm.get_deadline_metadata | def get_deadline_metadata(self):
"""Gets the metadata for the assessment deadline.
return: (osid.Metadata) - metadata for the end time
*compliance: mandatory -- This method must be implemented.*
"""
# Implemented from template for osid.resource.ResourceForm.get_group_metadata_t... | python | def get_deadline_metadata(self):
"""Gets the metadata for the assessment deadline.
return: (osid.Metadata) - metadata for the end time
*compliance: mandatory -- This method must be implemented.*
"""
# Implemented from template for osid.resource.ResourceForm.get_group_metadata_t... | [
"def",
"get_deadline_metadata",
"(",
"self",
")",
":",
"# Implemented from template for osid.resource.ResourceForm.get_group_metadata_template",
"metadata",
"=",
"dict",
"(",
"self",
".",
"_mdata",
"[",
"'deadline'",
"]",
")",
"metadata",
".",
"update",
"(",
"{",
"'exis... | Gets the metadata for the assessment deadline.
return: (osid.Metadata) - metadata for the end time
*compliance: mandatory -- This method must be implemented.* | [
"Gets",
"the",
"metadata",
"for",
"the",
"assessment",
"deadline",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment/objects.py#L1881-L1891 |
mitsei/dlkit | dlkit/json_/assessment/objects.py | AssessmentOfferedForm.set_deadline | def set_deadline(self, end):
"""Sets the assessment end time.
arg: end (timestamp): assessment end time
raise: InvalidArgument - ``end`` is invalid
raise: NoAccess - ``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- This method must be implemented.*
"... | python | def set_deadline(self, end):
"""Sets the assessment end time.
arg: end (timestamp): assessment end time
raise: InvalidArgument - ``end`` is invalid
raise: NoAccess - ``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- This method must be implemented.*
"... | [
"def",
"set_deadline",
"(",
"self",
",",
"end",
")",
":",
"# Implemented from template for osid.assessment.AssessmentOfferedForm.set_start_time_template",
"if",
"self",
".",
"get_deadline_metadata",
"(",
")",
".",
"is_read_only",
"(",
")",
":",
"raise",
"errors",
".",
"... | Sets the assessment end time.
arg: end (timestamp): assessment end time
raise: InvalidArgument - ``end`` is invalid
raise: NoAccess - ``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- This method must be implemented.* | [
"Sets",
"the",
"assessment",
"end",
"time",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment/objects.py#L1896-L1912 |
mitsei/dlkit | dlkit/json_/assessment/objects.py | AssessmentOfferedForm.clear_deadline | def clear_deadline(self):
"""Clears the deadline.
raise: NoAccess - ``Metadata.isRequired()`` or
``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- This method must be implemented.*
"""
# Implemented from template for osid.assessment.AssessmentOffe... | python | def clear_deadline(self):
"""Clears the deadline.
raise: NoAccess - ``Metadata.isRequired()`` or
``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- This method must be implemented.*
"""
# Implemented from template for osid.assessment.AssessmentOffe... | [
"def",
"clear_deadline",
"(",
"self",
")",
":",
"# Implemented from template for osid.assessment.AssessmentOfferedForm.clear_start_time_template",
"if",
"(",
"self",
".",
"get_deadline_metadata",
"(",
")",
".",
"is_read_only",
"(",
")",
"or",
"self",
".",
"get_deadline_meta... | Clears the deadline.
raise: NoAccess - ``Metadata.isRequired()`` or
``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- This method must be implemented.* | [
"Clears",
"the",
"deadline",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment/objects.py#L1914-L1926 |
mitsei/dlkit | dlkit/json_/assessment/objects.py | AssessmentOfferedForm.get_duration_metadata | def get_duration_metadata(self):
"""Gets the metadata for the assessment duration.
return: (osid.Metadata) - metadata for the duration
*compliance: mandatory -- This method must be implemented.*
"""
# Implemented from template for osid.resource.ResourceForm.get_group_metadata_t... | python | def get_duration_metadata(self):
"""Gets the metadata for the assessment duration.
return: (osid.Metadata) - metadata for the duration
*compliance: mandatory -- This method must be implemented.*
"""
# Implemented from template for osid.resource.ResourceForm.get_group_metadata_t... | [
"def",
"get_duration_metadata",
"(",
"self",
")",
":",
"# Implemented from template for osid.resource.ResourceForm.get_group_metadata_template",
"metadata",
"=",
"dict",
"(",
"self",
".",
"_mdata",
"[",
"'duration'",
"]",
")",
"metadata",
".",
"update",
"(",
"{",
"'exis... | Gets the metadata for the assessment duration.
return: (osid.Metadata) - metadata for the duration
*compliance: mandatory -- This method must be implemented.* | [
"Gets",
"the",
"metadata",
"for",
"the",
"assessment",
"duration",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment/objects.py#L1930-L1940 |
mitsei/dlkit | dlkit/json_/assessment/objects.py | AssessmentOfferedForm.set_duration | def set_duration(self, duration):
"""Sets the assessment duration.
arg: duration (osid.calendaring.Duration): assessment
duration
raise: InvalidArgument - ``duration`` is invalid
raise: NoAccess - ``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory ... | python | def set_duration(self, duration):
"""Sets the assessment duration.
arg: duration (osid.calendaring.Duration): assessment
duration
raise: InvalidArgument - ``duration`` is invalid
raise: NoAccess - ``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory ... | [
"def",
"set_duration",
"(",
"self",
",",
"duration",
")",
":",
"# Implemented from template for osid.assessment.AssessmentOfferedForm.set_duration_template",
"if",
"self",
".",
"get_duration_metadata",
"(",
")",
".",
"is_read_only",
"(",
")",
":",
"raise",
"errors",
".",
... | Sets the assessment duration.
arg: duration (osid.calendaring.Duration): assessment
duration
raise: InvalidArgument - ``duration`` is invalid
raise: NoAccess - ``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- This method must be implemented.* | [
"Sets",
"the",
"assessment",
"duration",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment/objects.py#L1945-L1966 |
mitsei/dlkit | dlkit/json_/assessment/objects.py | AssessmentOfferedForm.clear_duration | def clear_duration(self):
"""Clears the duration.
raise: NoAccess - ``Metadata.isRequired()`` or
``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- This method must be implemented.*
"""
# Implemented from template for osid.assessment.AssessmentOffe... | python | def clear_duration(self):
"""Clears the duration.
raise: NoAccess - ``Metadata.isRequired()`` or
``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- This method must be implemented.*
"""
# Implemented from template for osid.assessment.AssessmentOffe... | [
"def",
"clear_duration",
"(",
"self",
")",
":",
"# Implemented from template for osid.assessment.AssessmentOfferedForm.clear_duration_template",
"if",
"(",
"self",
".",
"get_duration_metadata",
"(",
")",
".",
"is_read_only",
"(",
")",
"or",
"self",
".",
"get_duration_metada... | Clears the duration.
raise: NoAccess - ``Metadata.isRequired()`` or
``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- This method must be implemented.* | [
"Clears",
"the",
"duration",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment/objects.py#L1968-L1980 |
mitsei/dlkit | dlkit/json_/assessment/objects.py | AssessmentOfferedForm.get_score_system_metadata | def get_score_system_metadata(self):
"""Gets the metadata for a score system.
return: (osid.Metadata) - metadata for the grade system
*compliance: mandatory -- This method must be implemented.*
"""
# Implemented from template for osid.resource.ResourceForm.get_group_metadata_te... | python | def get_score_system_metadata(self):
"""Gets the metadata for a score system.
return: (osid.Metadata) - metadata for the grade system
*compliance: mandatory -- This method must be implemented.*
"""
# Implemented from template for osid.resource.ResourceForm.get_group_metadata_te... | [
"def",
"get_score_system_metadata",
"(",
"self",
")",
":",
"# Implemented from template for osid.resource.ResourceForm.get_group_metadata_template",
"metadata",
"=",
"dict",
"(",
"self",
".",
"_mdata",
"[",
"'score_system'",
"]",
")",
"metadata",
".",
"update",
"(",
"{",
... | Gets the metadata for a score system.
return: (osid.Metadata) - metadata for the grade system
*compliance: mandatory -- This method must be implemented.* | [
"Gets",
"the",
"metadata",
"for",
"a",
"score",
"system",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment/objects.py#L1984-L1994 |
mitsei/dlkit | dlkit/json_/assessment/objects.py | AssessmentOfferedForm.set_score_system | def set_score_system(self, grade_system_id):
"""Sets the scoring system.
arg: grade_system_id (osid.id.Id): the grade system
raise: InvalidArgument - ``grade_system_id`` is invalid
raise: NoAccess - ``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- This method... | python | def set_score_system(self, grade_system_id):
"""Sets the scoring system.
arg: grade_system_id (osid.id.Id): the grade system
raise: InvalidArgument - ``grade_system_id`` is invalid
raise: NoAccess - ``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- This method... | [
"def",
"set_score_system",
"(",
"self",
",",
"grade_system_id",
")",
":",
"# Implemented from template for osid.resource.ResourceForm.set_avatar_template",
"if",
"self",
".",
"get_score_system_metadata",
"(",
")",
".",
"is_read_only",
"(",
")",
":",
"raise",
"errors",
"."... | Sets the scoring system.
arg: grade_system_id (osid.id.Id): the grade system
raise: InvalidArgument - ``grade_system_id`` is invalid
raise: NoAccess - ``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- This method must be implemented.* | [
"Sets",
"the",
"scoring",
"system",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment/objects.py#L1999-L2013 |
mitsei/dlkit | dlkit/json_/assessment/objects.py | AssessmentOfferedForm.clear_score_system | def clear_score_system(self):
"""Clears the score system.
raise: NoAccess - ``Metadata.isRequired()`` or
``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- This method must be implemented.*
"""
# Implemented from template for osid.resource.Resource... | python | def clear_score_system(self):
"""Clears the score system.
raise: NoAccess - ``Metadata.isRequired()`` or
``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- This method must be implemented.*
"""
# Implemented from template for osid.resource.Resource... | [
"def",
"clear_score_system",
"(",
"self",
")",
":",
"# Implemented from template for osid.resource.ResourceForm.clear_avatar_template",
"if",
"(",
"self",
".",
"get_score_system_metadata",
"(",
")",
".",
"is_read_only",
"(",
")",
"or",
"self",
".",
"get_score_system_metadat... | Clears the score system.
raise: NoAccess - ``Metadata.isRequired()`` or
``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- This method must be implemented.* | [
"Clears",
"the",
"score",
"system",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment/objects.py#L2015-L2027 |
mitsei/dlkit | dlkit/json_/assessment/objects.py | AssessmentOfferedForm.get_grade_system_metadata | def get_grade_system_metadata(self):
"""Gets the metadata for a grading system.
return: (osid.Metadata) - metadata for the grade system
*compliance: mandatory -- This method must be implemented.*
"""
# Implemented from template for osid.resource.ResourceForm.get_group_metadata_... | python | def get_grade_system_metadata(self):
"""Gets the metadata for a grading system.
return: (osid.Metadata) - metadata for the grade system
*compliance: mandatory -- This method must be implemented.*
"""
# Implemented from template for osid.resource.ResourceForm.get_group_metadata_... | [
"def",
"get_grade_system_metadata",
"(",
"self",
")",
":",
"# Implemented from template for osid.resource.ResourceForm.get_group_metadata_template",
"metadata",
"=",
"dict",
"(",
"self",
".",
"_mdata",
"[",
"'grade_system'",
"]",
")",
"metadata",
".",
"update",
"(",
"{",
... | Gets the metadata for a grading system.
return: (osid.Metadata) - metadata for the grade system
*compliance: mandatory -- This method must be implemented.* | [
"Gets",
"the",
"metadata",
"for",
"a",
"grading",
"system",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment/objects.py#L2031-L2041 |
mitsei/dlkit | dlkit/json_/assessment/objects.py | AssessmentOfferedForm.set_grade_system | def set_grade_system(self, grade_system_id):
"""Sets the grading system.
arg: grade_system_id (osid.id.Id): the grade system
raise: InvalidArgument - ``grade_system_id`` is invalid
raise: NoAccess - ``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- This method... | python | def set_grade_system(self, grade_system_id):
"""Sets the grading system.
arg: grade_system_id (osid.id.Id): the grade system
raise: InvalidArgument - ``grade_system_id`` is invalid
raise: NoAccess - ``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- This method... | [
"def",
"set_grade_system",
"(",
"self",
",",
"grade_system_id",
")",
":",
"# Implemented from template for osid.resource.ResourceForm.set_avatar_template",
"if",
"self",
".",
"get_grade_system_metadata",
"(",
")",
".",
"is_read_only",
"(",
")",
":",
"raise",
"errors",
"."... | Sets the grading system.
arg: grade_system_id (osid.id.Id): the grade system
raise: InvalidArgument - ``grade_system_id`` is invalid
raise: NoAccess - ``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- This method must be implemented.* | [
"Sets",
"the",
"grading",
"system",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment/objects.py#L2046-L2060 |
mitsei/dlkit | dlkit/json_/assessment/objects.py | AssessmentOfferedForm.clear_grade_system | def clear_grade_system(self):
"""Clears the grading system.
raise: NoAccess - ``Metadata.isRequired()`` or
``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- This method must be implemented.*
"""
# Implemented from template for osid.resource.Resour... | python | def clear_grade_system(self):
"""Clears the grading system.
raise: NoAccess - ``Metadata.isRequired()`` or
``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- This method must be implemented.*
"""
# Implemented from template for osid.resource.Resour... | [
"def",
"clear_grade_system",
"(",
"self",
")",
":",
"# Implemented from template for osid.resource.ResourceForm.clear_avatar_template",
"if",
"(",
"self",
".",
"get_grade_system_metadata",
"(",
")",
".",
"is_read_only",
"(",
")",
"or",
"self",
".",
"get_grade_system_metadat... | Clears the grading system.
raise: NoAccess - ``Metadata.isRequired()`` or
``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- This method must be implemented.* | [
"Clears",
"the",
"grading",
"system",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment/objects.py#L2062-L2074 |
mitsei/dlkit | dlkit/json_/assessment/objects.py | AssessmentTaken.get_assessment_offered_id | def get_assessment_offered_id(self):
"""Gets the ``Id`` of the ``AssessmentOffered``.
return: (osid.id.Id) - the assessment offered ``Id``
*compliance: mandatory -- This method must be implemented.*
"""
# Implemented from template for osid.learning.Activity.get_objective_id
... | python | def get_assessment_offered_id(self):
"""Gets the ``Id`` of the ``AssessmentOffered``.
return: (osid.id.Id) - the assessment offered ``Id``
*compliance: mandatory -- This method must be implemented.*
"""
# Implemented from template for osid.learning.Activity.get_objective_id
... | [
"def",
"get_assessment_offered_id",
"(",
"self",
")",
":",
"# Implemented from template for osid.learning.Activity.get_objective_id",
"if",
"not",
"bool",
"(",
"self",
".",
"_my_map",
"[",
"'assessmentOfferedId'",
"]",
")",
":",
"raise",
"errors",
".",
"IllegalState",
"... | Gets the ``Id`` of the ``AssessmentOffered``.
return: (osid.id.Id) - the assessment offered ``Id``
*compliance: mandatory -- This method must be implemented.* | [
"Gets",
"the",
"Id",
"of",
"the",
"AssessmentOffered",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment/objects.py#L2162-L2172 |
mitsei/dlkit | dlkit/json_/assessment/objects.py | AssessmentTaken.get_assessment_offered | def get_assessment_offered(self):
"""Gets the ``AssessmentOffered``.
return: (osid.assessment.AssessmentOffered) - the assessment
offered
raise: OperationFailed - unable to complete request
*compliance: mandatory -- This method must be implemented.*
"""
... | python | def get_assessment_offered(self):
"""Gets the ``AssessmentOffered``.
return: (osid.assessment.AssessmentOffered) - the assessment
offered
raise: OperationFailed - unable to complete request
*compliance: mandatory -- This method must be implemented.*
"""
... | [
"def",
"get_assessment_offered",
"(",
"self",
")",
":",
"# Implemented from template for osid.learning.Activity.get_objective",
"if",
"not",
"bool",
"(",
"self",
".",
"_my_map",
"[",
"'assessmentOfferedId'",
"]",
")",
":",
"raise",
"errors",
".",
"IllegalState",
"(",
... | Gets the ``AssessmentOffered``.
return: (osid.assessment.AssessmentOffered) - the assessment
offered
raise: OperationFailed - unable to complete request
*compliance: mandatory -- This method must be implemented.* | [
"Gets",
"the",
"AssessmentOffered",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment/objects.py#L2176-L2193 |
mitsei/dlkit | dlkit/json_/assessment/objects.py | AssessmentTaken.get_taker_id | def get_taker_id(self):
"""Gets the ``Id`` of the resource who took or is taking this assessment.
return: (osid.id.Id) - the resource ``Id``
*compliance: mandatory -- This method must be implemented.*
"""
if self._my_map['takerId']:
return Id(self._my_map['takerId']... | python | def get_taker_id(self):
"""Gets the ``Id`` of the resource who took or is taking this assessment.
return: (osid.id.Id) - the resource ``Id``
*compliance: mandatory -- This method must be implemented.*
"""
if self._my_map['takerId']:
return Id(self._my_map['takerId']... | [
"def",
"get_taker_id",
"(",
"self",
")",
":",
"if",
"self",
".",
"_my_map",
"[",
"'takerId'",
"]",
":",
"return",
"Id",
"(",
"self",
".",
"_my_map",
"[",
"'takerId'",
"]",
")",
"else",
":",
"return",
"Id",
"(",
"self",
".",
"_my_map",
"[",
"'takingAg... | Gets the ``Id`` of the resource who took or is taking this assessment.
return: (osid.id.Id) - the resource ``Id``
*compliance: mandatory -- This method must be implemented.* | [
"Gets",
"the",
"Id",
"of",
"the",
"resource",
"who",
"took",
"or",
"is",
"taking",
"this",
"assessment",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment/objects.py#L2197-L2207 |
mitsei/dlkit | dlkit/json_/assessment/objects.py | AssessmentTaken.has_started | def has_started(self):
"""Tests if this assessment has begun.
return: (boolean) - ``true`` if the assessment has begun,
``false`` otherwise
*compliance: mandatory -- This method must be implemented.*
"""
assessment_offered = self.get_assessment_offered()
... | python | def has_started(self):
"""Tests if this assessment has begun.
return: (boolean) - ``true`` if the assessment has begun,
``false`` otherwise
*compliance: mandatory -- This method must be implemented.*
"""
assessment_offered = self.get_assessment_offered()
... | [
"def",
"has_started",
"(",
"self",
")",
":",
"assessment_offered",
"=",
"self",
".",
"get_assessment_offered",
"(",
")",
"if",
"assessment_offered",
".",
"has_start_time",
"(",
")",
":",
"return",
"DateTime",
".",
"utcnow",
"(",
")",
">=",
"assessment_offered",
... | Tests if this assessment has begun.
return: (boolean) - ``true`` if the assessment has begun,
``false`` otherwise
*compliance: mandatory -- This method must be implemented.* | [
"Tests",
"if",
"this",
"assessment",
"has",
"begun",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment/objects.py#L2246-L2258 |
mitsei/dlkit | dlkit/json_/assessment/objects.py | AssessmentTaken.get_actual_start_time | def get_actual_start_time(self):
"""Gets the time this assessment was started.
return: (osid.calendaring.DateTime) - the start time
raise: IllegalState - ``has_started()`` is ``false``
*compliance: mandatory -- This method must be implemented.*
"""
if not self.has_star... | python | def get_actual_start_time(self):
"""Gets the time this assessment was started.
return: (osid.calendaring.DateTime) - the start time
raise: IllegalState - ``has_started()`` is ``false``
*compliance: mandatory -- This method must be implemented.*
"""
if not self.has_star... | [
"def",
"get_actual_start_time",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"has_started",
"(",
")",
":",
"raise",
"errors",
".",
"IllegalState",
"(",
"'this assessment has not yet started'",
")",
"if",
"self",
".",
"_my_map",
"[",
"'actualStartTime'",
"]",... | Gets the time this assessment was started.
return: (osid.calendaring.DateTime) - the start time
raise: IllegalState - ``has_started()`` is ``false``
*compliance: mandatory -- This method must be implemented.* | [
"Gets",
"the",
"time",
"this",
"assessment",
"was",
"started",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment/objects.py#L2260-L2280 |
mitsei/dlkit | dlkit/json_/assessment/objects.py | AssessmentTaken.has_ended | def has_ended(self):
"""Tests if this assessment has ended.
return: (boolean) - ``true`` if the assessment has ended,
``false`` otherwise
*compliance: mandatory -- This method must be implemented.*
"""
assessment_offered = self.get_assessment_offered()
n... | python | def has_ended(self):
"""Tests if this assessment has ended.
return: (boolean) - ``true`` if the assessment has ended,
``false`` otherwise
*compliance: mandatory -- This method must be implemented.*
"""
assessment_offered = self.get_assessment_offered()
n... | [
"def",
"has_ended",
"(",
"self",
")",
":",
"assessment_offered",
"=",
"self",
".",
"get_assessment_offered",
"(",
")",
"now",
"=",
"DateTime",
".",
"utcnow",
"(",
")",
"# There's got to be a better way to do this:",
"if",
"self",
".",
"_my_map",
"[",
"'completionT... | Tests if this assessment has ended.
return: (boolean) - ``true`` if the assessment has ended,
``false`` otherwise
*compliance: mandatory -- This method must be implemented.* | [
"Tests",
"if",
"this",
"assessment",
"has",
"ended",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment/objects.py#L2284-L2308 |
mitsei/dlkit | dlkit/json_/assessment/objects.py | AssessmentTaken.get_completion_time | def get_completion_time(self):
"""Gets the time of this assessment was completed.
return: (osid.calendaring.DateTime) - the end time
raise: IllegalState - ``has_ended()`` is ``false``
*compliance: mandatory -- This method must be implemented.*
"""
if not self.has_ended... | python | def get_completion_time(self):
"""Gets the time of this assessment was completed.
return: (osid.calendaring.DateTime) - the end time
raise: IllegalState - ``has_ended()`` is ``false``
*compliance: mandatory -- This method must be implemented.*
"""
if not self.has_ended... | [
"def",
"get_completion_time",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"has_ended",
"(",
")",
":",
"raise",
"errors",
".",
"IllegalState",
"(",
"'this assessment has not yet ended'",
")",
"if",
"not",
"self",
".",
"_my_map",
"[",
"'completionTime'",
"]... | Gets the time of this assessment was completed.
return: (osid.calendaring.DateTime) - the end time
raise: IllegalState - ``has_ended()`` is ``false``
*compliance: mandatory -- This method must be implemented.* | [
"Gets",
"the",
"time",
"of",
"this",
"assessment",
"was",
"completed",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment/objects.py#L2310-L2329 |
mitsei/dlkit | dlkit/json_/assessment/objects.py | AssessmentTaken.get_time_spent | def get_time_spent(self):
"""Gets the total time spent taking this assessment.
return: (osid.calendaring.Duration) - the total time spent
*compliance: mandatory -- This method must be implemented.*
"""
# Take another look at this. Not sure it's correct:
if not self.has_... | python | def get_time_spent(self):
"""Gets the total time spent taking this assessment.
return: (osid.calendaring.Duration) - the total time spent
*compliance: mandatory -- This method must be implemented.*
"""
# Take another look at this. Not sure it's correct:
if not self.has_... | [
"def",
"get_time_spent",
"(",
"self",
")",
":",
"# Take another look at this. Not sure it's correct:",
"if",
"not",
"self",
".",
"has_started",
"or",
"not",
"self",
".",
"has_ended",
"(",
")",
":",
"raise",
"errors",
".",
"IllegalState",
"(",
")",
"if",
"self",
... | Gets the total time spent taking this assessment.
return: (osid.calendaring.Duration) - the total time spent
*compliance: mandatory -- This method must be implemented.* | [
"Gets",
"the",
"total",
"time",
"spent",
"taking",
"this",
"assessment",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment/objects.py#L2333-L2346 |
mitsei/dlkit | dlkit/json_/assessment/objects.py | AssessmentTaken.get_score_system_id | def get_score_system_id(self):
"""Gets a score system ``Id`` for the assessment.
return: (osid.id.Id) - the grade system
raise: IllegalState - ``is_score()`` is ``false``
*compliance: mandatory -- This method must be implemented.*
"""
# Implemented from template for os... | python | def get_score_system_id(self):
"""Gets a score system ``Id`` for the assessment.
return: (osid.id.Id) - the grade system
raise: IllegalState - ``is_score()`` is ``false``
*compliance: mandatory -- This method must be implemented.*
"""
# Implemented from template for os... | [
"def",
"get_score_system_id",
"(",
"self",
")",
":",
"# Implemented from template for osid.resource.Resource.get_avatar_template",
"if",
"not",
"bool",
"(",
"self",
".",
"_my_map",
"[",
"'scoreSystemId'",
"]",
")",
":",
"raise",
"errors",
".",
"IllegalState",
"(",
"'t... | Gets a score system ``Id`` for the assessment.
return: (osid.id.Id) - the grade system
raise: IllegalState - ``is_score()`` is ``false``
*compliance: mandatory -- This method must be implemented.* | [
"Gets",
"a",
"score",
"system",
"Id",
"for",
"the",
"assessment",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment/objects.py#L2373-L2390 |
mitsei/dlkit | dlkit/json_/assessment/objects.py | AssessmentTaken.get_score_system | def get_score_system(self):
"""Gets a grade system for the score.
return: (osid.grading.GradeSystem) - the grade system
raise: IllegalState - ``is_scored()`` is ``false``
raise: OperationFailed - unable to complete request
*compliance: mandatory -- This method must be implemen... | python | def get_score_system(self):
"""Gets a grade system for the score.
return: (osid.grading.GradeSystem) - the grade system
raise: IllegalState - ``is_scored()`` is ``false``
raise: OperationFailed - unable to complete request
*compliance: mandatory -- This method must be implemen... | [
"def",
"get_score_system",
"(",
"self",
")",
":",
"# Implemented from template for osid.resource.Resource.get_avatar_template",
"if",
"not",
"bool",
"(",
"self",
".",
"_my_map",
"[",
"'scoreSystemId'",
"]",
")",
":",
"raise",
"errors",
".",
"IllegalState",
"(",
"'this... | Gets a grade system for the score.
return: (osid.grading.GradeSystem) - the grade system
raise: IllegalState - ``is_scored()`` is ``false``
raise: OperationFailed - unable to complete request
*compliance: mandatory -- This method must be implemented.* | [
"Gets",
"a",
"grade",
"system",
"for",
"the",
"score",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment/objects.py#L2394-L2412 |
mitsei/dlkit | dlkit/json_/assessment/objects.py | AssessmentTaken.get_rubric_id | def get_rubric_id(self):
"""Gets the ``Id`` of the rubric.
return: (osid.id.Id) - an assessment taken ``Id``
raise: IllegalState - ``has_rubric()`` is ``false``
*compliance: mandatory -- This method must be implemented.*
"""
# Implemented from template for osid.resourc... | python | def get_rubric_id(self):
"""Gets the ``Id`` of the rubric.
return: (osid.id.Id) - an assessment taken ``Id``
raise: IllegalState - ``has_rubric()`` is ``false``
*compliance: mandatory -- This method must be implemented.*
"""
# Implemented from template for osid.resourc... | [
"def",
"get_rubric_id",
"(",
"self",
")",
":",
"# Implemented from template for osid.resource.Resource.get_avatar_id_template",
"if",
"not",
"bool",
"(",
"self",
".",
"_my_map",
"[",
"'rubricId'",
"]",
")",
":",
"raise",
"errors",
".",
"IllegalState",
"(",
"'this Asse... | Gets the ``Id`` of the rubric.
return: (osid.id.Id) - an assessment taken ``Id``
raise: IllegalState - ``has_rubric()`` is ``false``
*compliance: mandatory -- This method must be implemented.* | [
"Gets",
"the",
"Id",
"of",
"the",
"rubric",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment/objects.py#L2501-L2513 |
mitsei/dlkit | dlkit/json_/assessment/objects.py | AssessmentTaken.get_rubric | def get_rubric(self):
"""Gets the rubric.
return: (osid.assessment.AssessmentTaken) - the assessment taken
raise: IllegalState - ``has_rubric()`` is ``false``
raise: OperationFailed - unable to complete request
*compliance: mandatory -- This method must be implemented.*
... | python | def get_rubric(self):
"""Gets the rubric.
return: (osid.assessment.AssessmentTaken) - the assessment taken
raise: IllegalState - ``has_rubric()`` is ``false``
raise: OperationFailed - unable to complete request
*compliance: mandatory -- This method must be implemented.*
... | [
"def",
"get_rubric",
"(",
"self",
")",
":",
"# Implemented from template for osid.resource.Resource.get_avatar_template",
"if",
"not",
"bool",
"(",
"self",
".",
"_my_map",
"[",
"'rubricId'",
"]",
")",
":",
"raise",
"errors",
".",
"IllegalState",
"(",
"'this Assessment... | Gets the rubric.
return: (osid.assessment.AssessmentTaken) - the assessment taken
raise: IllegalState - ``has_rubric()`` is ``false``
raise: OperationFailed - unable to complete request
*compliance: mandatory -- This method must be implemented.* | [
"Gets",
"the",
"rubric",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment/objects.py#L2517-L2535 |
mitsei/dlkit | dlkit/json_/assessment/objects.py | AssessmentTaken._get_first_assessment_section | def _get_first_assessment_section(self):
"""Gets the first section for this Taken's Assessment."""
if ('sections' not in self._my_map or not self._my_map['sections']):
# This is the first time for this Taken, so start assessment
# SHOULD THIS USE self._update_available_sections??... | python | def _get_first_assessment_section(self):
"""Gets the first section for this Taken's Assessment."""
if ('sections' not in self._my_map or not self._my_map['sections']):
# This is the first time for this Taken, so start assessment
# SHOULD THIS USE self._update_available_sections??... | [
"def",
"_get_first_assessment_section",
"(",
"self",
")",
":",
"if",
"(",
"'sections'",
"not",
"in",
"self",
".",
"_my_map",
"or",
"not",
"self",
".",
"_my_map",
"[",
"'sections'",
"]",
")",
":",
"# This is the first time for this Taken, so start assessment",
"# SHO... | Gets the first section for this Taken's Assessment. | [
"Gets",
"the",
"first",
"section",
"for",
"this",
"Taken",
"s",
"Assessment",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment/objects.py#L2602-L2615 |
mitsei/dlkit | dlkit/json_/assessment/objects.py | AssessmentTaken._get_next_assessment_section | def _get_next_assessment_section(self, assessment_section_id):
"""Gets the next section following section_id.
Assumes that section list exists in taken and section_id is in section list.
Assumes that Section parts only exist as children of Assessments
"""
if self._my_map['secti... | python | def _get_next_assessment_section(self, assessment_section_id):
"""Gets the next section following section_id.
Assumes that section list exists in taken and section_id is in section list.
Assumes that Section parts only exist as children of Assessments
"""
if self._my_map['secti... | [
"def",
"_get_next_assessment_section",
"(",
"self",
",",
"assessment_section_id",
")",
":",
"if",
"self",
".",
"_my_map",
"[",
"'sections'",
"]",
"[",
"-",
"1",
"]",
"==",
"str",
"(",
"assessment_section_id",
")",
":",
"# section_id represents the last seen section"... | Gets the next section following section_id.
Assumes that section list exists in taken and section_id is in section list.
Assumes that Section parts only exist as children of Assessments | [
"Gets",
"the",
"next",
"section",
"following",
"section_id",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment/objects.py#L2617-L2637 |
mitsei/dlkit | dlkit/json_/assessment/objects.py | AssessmentTaken._get_previous_assessment_section | def _get_previous_assessment_section(self, assessment_section_id):
"""Gets the previous section before section_id.
Assumes that section list exists in taken and section_id is in section list.
Assumes that Section parts only exist as children of Assessments
"""
if self._my_map['... | python | def _get_previous_assessment_section(self, assessment_section_id):
"""Gets the previous section before section_id.
Assumes that section list exists in taken and section_id is in section list.
Assumes that Section parts only exist as children of Assessments
"""
if self._my_map['... | [
"def",
"_get_previous_assessment_section",
"(",
"self",
",",
"assessment_section_id",
")",
":",
"if",
"self",
".",
"_my_map",
"[",
"'sections'",
"]",
"[",
"0",
"]",
"==",
"str",
"(",
"assessment_section_id",
")",
":",
"raise",
"errors",
".",
"IllegalState",
"(... | Gets the previous section before section_id.
Assumes that section list exists in taken and section_id is in section list.
Assumes that Section parts only exist as children of Assessments | [
"Gets",
"the",
"previous",
"section",
"before",
"section_id",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment/objects.py#L2639-L2650 |
mitsei/dlkit | dlkit/json_/assessment/objects.py | AssessmentTaken._get_assessment_sections | def _get_assessment_sections(self):
"""Gets a SectionList of all Sections currently known to this AssessmentTaken"""
section_list = []
for section_idstr in self._my_map['sections']:
section_list.append(self._get_assessment_section(Id(section_idstr)))
return AssessmentSectionL... | python | def _get_assessment_sections(self):
"""Gets a SectionList of all Sections currently known to this AssessmentTaken"""
section_list = []
for section_idstr in self._my_map['sections']:
section_list.append(self._get_assessment_section(Id(section_idstr)))
return AssessmentSectionL... | [
"def",
"_get_assessment_sections",
"(",
"self",
")",
":",
"section_list",
"=",
"[",
"]",
"for",
"section_idstr",
"in",
"self",
".",
"_my_map",
"[",
"'sections'",
"]",
":",
"section_list",
".",
"append",
"(",
"self",
".",
"_get_assessment_section",
"(",
"Id",
... | Gets a SectionList of all Sections currently known to this AssessmentTaken | [
"Gets",
"a",
"SectionList",
"of",
"all",
"Sections",
"currently",
"known",
"to",
"this",
"AssessmentTaken"
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment/objects.py#L2660-L2665 |
mitsei/dlkit | dlkit/json_/assessment/objects.py | AssessmentTaken._save | def _save(self):
"""Saves the current state of this AssessmentTaken.
Should be called every time the sections map changes.
"""
collection = JSONClientValidated('assessment',
collection='AssessmentTaken',
... | python | def _save(self):
"""Saves the current state of this AssessmentTaken.
Should be called every time the sections map changes.
"""
collection = JSONClientValidated('assessment',
collection='AssessmentTaken',
... | [
"def",
"_save",
"(",
"self",
")",
":",
"collection",
"=",
"JSONClientValidated",
"(",
"'assessment'",
",",
"collection",
"=",
"'AssessmentTaken'",
",",
"runtime",
"=",
"self",
".",
"_runtime",
")",
"collection",
".",
"save",
"(",
"self",
".",
"_my_map",
")"
... | Saves the current state of this AssessmentTaken.
Should be called every time the sections map changes. | [
"Saves",
"the",
"current",
"state",
"of",
"this",
"AssessmentTaken",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment/objects.py#L2667-L2676 |
mitsei/dlkit | dlkit/json_/assessment/objects.py | AssessmentTakenForm._init_metadata | def _init_metadata(self, **kwargs):
"""Initialize form metadata"""
osid_objects.OsidObjectForm._init_metadata(self, **kwargs)
self._taker_default = self._mdata['taker']['default_id_values'][0] | python | def _init_metadata(self, **kwargs):
"""Initialize form metadata"""
osid_objects.OsidObjectForm._init_metadata(self, **kwargs)
self._taker_default = self._mdata['taker']['default_id_values'][0] | [
"def",
"_init_metadata",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"osid_objects",
".",
"OsidObjectForm",
".",
"_init_metadata",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
"self",
".",
"_taker_default",
"=",
"self",
".",
"_mdata",
"[",
"'taker'",
"... | Initialize form metadata | [
"Initialize",
"form",
"metadata"
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment/objects.py#L2737-L2740 |
mitsei/dlkit | dlkit/json_/assessment/objects.py | AssessmentTakenForm._init_map | def _init_map(self, record_types=None, **kwargs):
"""Initialize form map"""
osid_objects.OsidObjectForm._init_map(self, record_types=record_types)
self._my_map['assessmentOfferedId'] = str(kwargs['assessment_offered_id'])
self._my_map['takerId'] = self._taker_default
self._my_map... | python | def _init_map(self, record_types=None, **kwargs):
"""Initialize form map"""
osid_objects.OsidObjectForm._init_map(self, record_types=record_types)
self._my_map['assessmentOfferedId'] = str(kwargs['assessment_offered_id'])
self._my_map['takerId'] = self._taker_default
self._my_map... | [
"def",
"_init_map",
"(",
"self",
",",
"record_types",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"osid_objects",
".",
"OsidObjectForm",
".",
"_init_map",
"(",
"self",
",",
"record_types",
"=",
"record_types",
")",
"self",
".",
"_my_map",
"[",
"'assess... | Initialize form map | [
"Initialize",
"form",
"map"
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment/objects.py#L2742-L2751 |
mitsei/dlkit | dlkit/json_/assessment/objects.py | AssessmentTakenForm.get_taker_metadata | def get_taker_metadata(self):
"""Gets the metadata for a resource to manually set which resource will be taking the assessment.
return: (osid.Metadata) - metadata for the resource
*compliance: mandatory -- This method must be implemented.*
"""
# Implemented from template for os... | python | def get_taker_metadata(self):
"""Gets the metadata for a resource to manually set which resource will be taking the assessment.
return: (osid.Metadata) - metadata for the resource
*compliance: mandatory -- This method must be implemented.*
"""
# Implemented from template for os... | [
"def",
"get_taker_metadata",
"(",
"self",
")",
":",
"# Implemented from template for osid.resource.ResourceForm.get_group_metadata_template",
"metadata",
"=",
"dict",
"(",
"self",
".",
"_mdata",
"[",
"'taker'",
"]",
")",
"metadata",
".",
"update",
"(",
"{",
"'existing_i... | Gets the metadata for a resource to manually set which resource will be taking the assessment.
return: (osid.Metadata) - metadata for the resource
*compliance: mandatory -- This method must be implemented.* | [
"Gets",
"the",
"metadata",
"for",
"a",
"resource",
"to",
"manually",
"set",
"which",
"resource",
"will",
"be",
"taking",
"the",
"assessment",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment/objects.py#L2753-L2763 |
mitsei/dlkit | dlkit/json_/assessment/objects.py | AssessmentTakenForm.set_taker | def set_taker(self, resource_id):
"""Sets the resource who will be taking this assessment.
arg: resource_id (osid.id.Id): the resource Id
raise: InvalidArgument - ``resource_id`` is invalid
raise: NoAccess - ``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- Th... | python | def set_taker(self, resource_id):
"""Sets the resource who will be taking this assessment.
arg: resource_id (osid.id.Id): the resource Id
raise: InvalidArgument - ``resource_id`` is invalid
raise: NoAccess - ``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- Th... | [
"def",
"set_taker",
"(",
"self",
",",
"resource_id",
")",
":",
"# Implemented from template for osid.resource.ResourceForm.set_avatar_template",
"if",
"self",
".",
"get_taker_metadata",
"(",
")",
".",
"is_read_only",
"(",
")",
":",
"raise",
"errors",
".",
"NoAccess",
... | Sets the resource who will be taking this assessment.
arg: resource_id (osid.id.Id): the resource Id
raise: InvalidArgument - ``resource_id`` is invalid
raise: NoAccess - ``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- This method must be implemented.* | [
"Sets",
"the",
"resource",
"who",
"will",
"be",
"taking",
"this",
"assessment",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment/objects.py#L2768-L2782 |
mitsei/dlkit | dlkit/json_/assessment/objects.py | AssessmentTakenForm.clear_taker | def clear_taker(self):
"""Clears the resource.
raise: NoAccess - ``Metadata.isRequired()`` or
``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- This method must be implemented.*
"""
# Implemented from template for osid.resource.ResourceForm.clear_... | python | def clear_taker(self):
"""Clears the resource.
raise: NoAccess - ``Metadata.isRequired()`` or
``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- This method must be implemented.*
"""
# Implemented from template for osid.resource.ResourceForm.clear_... | [
"def",
"clear_taker",
"(",
"self",
")",
":",
"# Implemented from template for osid.resource.ResourceForm.clear_avatar_template",
"if",
"(",
"self",
".",
"get_taker_metadata",
"(",
")",
".",
"is_read_only",
"(",
")",
"or",
"self",
".",
"get_taker_metadata",
"(",
")",
"... | Clears the resource.
raise: NoAccess - ``Metadata.isRequired()`` or
``Metadata.isReadOnly()`` is ``true``
*compliance: mandatory -- This method must be implemented.* | [
"Clears",
"the",
"resource",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment/objects.py#L2784-L2796 |
mitsei/dlkit | dlkit/json_/assessment/objects.py | AssessmentSection.get_assessment_taken_id | def get_assessment_taken_id(self):
"""Gets the ``Id`` of the ``AssessmentTaken``.
return: (osid.id.Id) - the assessment taken ``Id``
*compliance: mandatory -- This method must be implemented.*
"""
# Implemented from template for osid.learning.Activity.get_objective_id
i... | python | def get_assessment_taken_id(self):
"""Gets the ``Id`` of the ``AssessmentTaken``.
return: (osid.id.Id) - the assessment taken ``Id``
*compliance: mandatory -- This method must be implemented.*
"""
# Implemented from template for osid.learning.Activity.get_objective_id
i... | [
"def",
"get_assessment_taken_id",
"(",
"self",
")",
":",
"# Implemented from template for osid.learning.Activity.get_objective_id",
"if",
"not",
"bool",
"(",
"self",
".",
"_my_map",
"[",
"'assessmentTakenId'",
"]",
")",
":",
"raise",
"errors",
".",
"IllegalState",
"(",
... | Gets the ``Id`` of the ``AssessmentTaken``.
return: (osid.id.Id) - the assessment taken ``Id``
*compliance: mandatory -- This method must be implemented.* | [
"Gets",
"the",
"Id",
"of",
"the",
"AssessmentTaken",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment/objects.py#L3028-L3038 |
mitsei/dlkit | dlkit/json_/assessment/objects.py | AssessmentSection.get_assessment_taken | def get_assessment_taken(self):
"""Gets the ``AssessmentTakeb``.
return: (osid.assessment.AssessmentTaken) - the assessment taken
raise: OperationFailed - unable to complete request
*compliance: mandatory -- This method must be implemented.*
"""
# Implemented from temp... | python | def get_assessment_taken(self):
"""Gets the ``AssessmentTakeb``.
return: (osid.assessment.AssessmentTaken) - the assessment taken
raise: OperationFailed - unable to complete request
*compliance: mandatory -- This method must be implemented.*
"""
# Implemented from temp... | [
"def",
"get_assessment_taken",
"(",
"self",
")",
":",
"# Implemented from template for osid.learning.Activity.get_objective",
"if",
"not",
"bool",
"(",
"self",
".",
"_my_map",
"[",
"'assessmentTakenId'",
"]",
")",
":",
"raise",
"errors",
".",
"IllegalState",
"(",
"'as... | Gets the ``AssessmentTakeb``.
return: (osid.assessment.AssessmentTaken) - the assessment taken
raise: OperationFailed - unable to complete request
*compliance: mandatory -- This method must be implemented.* | [
"Gets",
"the",
"AssessmentTakeb",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment/objects.py#L3042-L3058 |
mitsei/dlkit | dlkit/json_/assessment/objects.py | BankNode.get_bank | def get_bank(self):
"""Gets the ``Bank`` at this node.
return: (osid.assessment.Bank) - the bank represented by this
node
*compliance: mandatory -- This method must be implemented.*
"""
if self._lookup_session is None:
mgr = get_provider_manager('ASS... | python | def get_bank(self):
"""Gets the ``Bank`` at this node.
return: (osid.assessment.Bank) - the bank represented by this
node
*compliance: mandatory -- This method must be implemented.*
"""
if self._lookup_session is None:
mgr = get_provider_manager('ASS... | [
"def",
"get_bank",
"(",
"self",
")",
":",
"if",
"self",
".",
"_lookup_session",
"is",
"None",
":",
"mgr",
"=",
"get_provider_manager",
"(",
"'ASSESSMENT'",
",",
"runtime",
"=",
"self",
".",
"_runtime",
",",
"proxy",
"=",
"self",
".",
"_proxy",
")",
"self... | Gets the ``Bank`` at this node.
return: (osid.assessment.Bank) - the bank represented by this
node
*compliance: mandatory -- This method must be implemented.* | [
"Gets",
"the",
"Bank",
"at",
"this",
"node",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment/objects.py#L3338-L3349 |
mitsei/dlkit | dlkit/json_/assessment/objects.py | BankNode.get_parent_bank_nodes | def get_parent_bank_nodes(self):
"""Gets the parents of this bank.
return: (osid.assessment.BankNodeList) - the parents of this
node
*compliance: mandatory -- This method must be implemented.*
"""
parent_bank_nodes = []
for node in self._my_map['parentNo... | python | def get_parent_bank_nodes(self):
"""Gets the parents of this bank.
return: (osid.assessment.BankNodeList) - the parents of this
node
*compliance: mandatory -- This method must be implemented.*
"""
parent_bank_nodes = []
for node in self._my_map['parentNo... | [
"def",
"get_parent_bank_nodes",
"(",
"self",
")",
":",
"parent_bank_nodes",
"=",
"[",
"]",
"for",
"node",
"in",
"self",
".",
"_my_map",
"[",
"'parentNodes'",
"]",
":",
"parent_bank_nodes",
".",
"append",
"(",
"BankNode",
"(",
"node",
".",
"_my_map",
",",
"... | Gets the parents of this bank.
return: (osid.assessment.BankNodeList) - the parents of this
node
*compliance: mandatory -- This method must be implemented.* | [
"Gets",
"the",
"parents",
"of",
"this",
"bank",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment/objects.py#L3353-L3368 |
peopledoc/django-agnocomplete | demo/views_proxy.py | errors | def errors(request, *args, **kwargs):
"""
A dummy view that will throw errors.
It'll throw any HTTP error that is contained in the search query.
"""
search_term = request.GET.get('q', None)
if '400' in search_term:
return HttpResponseBadRequest(MESSAGE_400)
elif '403' in search_term... | python | def errors(request, *args, **kwargs):
"""
A dummy view that will throw errors.
It'll throw any HTTP error that is contained in the search query.
"""
search_term = request.GET.get('q', None)
if '400' in search_term:
return HttpResponseBadRequest(MESSAGE_400)
elif '403' in search_term... | [
"def",
"errors",
"(",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"search_term",
"=",
"request",
".",
"GET",
".",
"get",
"(",
"'q'",
",",
"None",
")",
"if",
"'400'",
"in",
"search_term",
":",
"return",
"HttpResponseBadRequest",
"(",... | A dummy view that will throw errors.
It'll throw any HTTP error that is contained in the search query. | [
"A",
"dummy",
"view",
"that",
"will",
"throw",
"errors",
"."
] | train | https://github.com/peopledoc/django-agnocomplete/blob/9bf21db2f2036ba5059b843acd32902a09192053/demo/views_proxy.py#L153-L168 |
ayust/kitnirc | kitnirc/client.py | on_connect | def on_connect(client):
"""Default on-connect actions."""
client.nick(client.user.nick)
client.userinfo(client.user.username, client.user.realname) | python | def on_connect(client):
"""Default on-connect actions."""
client.nick(client.user.nick)
client.userinfo(client.user.username, client.user.realname) | [
"def",
"on_connect",
"(",
"client",
")",
":",
"client",
".",
"nick",
"(",
"client",
".",
"user",
".",
"nick",
")",
"client",
".",
"userinfo",
"(",
"client",
".",
"user",
".",
"username",
",",
"client",
".",
"user",
".",
"realname",
")"
] | Default on-connect actions. | [
"Default",
"on",
"-",
"connect",
"actions",
"."
] | train | https://github.com/ayust/kitnirc/blob/cf19fe39219da75f053e1a3976bf21331b6fefea/kitnirc/client.py#L579-L582 |
ayust/kitnirc | kitnirc/client.py | on_line | def on_line(client, line):
"""Default handling for incoming lines.
This handler will automatically manage the following IRC messages:
PING:
Responds with a PONG.
PRIVMSG:
Dispatches the PRIVMSG event.
NOTICE:
Dispatches the NOTICE event.
MOTDSTART:
Initi... | python | def on_line(client, line):
"""Default handling for incoming lines.
This handler will automatically manage the following IRC messages:
PING:
Responds with a PONG.
PRIVMSG:
Dispatches the PRIVMSG event.
NOTICE:
Dispatches the NOTICE event.
MOTDSTART:
Initi... | [
"def",
"on_line",
"(",
"client",
",",
"line",
")",
":",
"if",
"line",
".",
"startswith",
"(",
"\"PING\"",
")",
":",
"client",
".",
"send",
"(",
"\"PONG\"",
"+",
"line",
"[",
"4",
":",
"]",
")",
"return",
"True",
"if",
"line",
".",
"startswith",
"("... | Default handling for incoming lines.
This handler will automatically manage the following IRC messages:
PING:
Responds with a PONG.
PRIVMSG:
Dispatches the PRIVMSG event.
NOTICE:
Dispatches the NOTICE event.
MOTDSTART:
Initializes MOTD receive buffer.
... | [
"Default",
"handling",
"for",
"incoming",
"lines",
"."
] | train | https://github.com/ayust/kitnirc/blob/cf19fe39219da75f053e1a3976bf21331b6fefea/kitnirc/client.py#L585-L621 |
ayust/kitnirc | kitnirc/client.py | parser | def parser(*events):
"""Decorator for convenience - adds a function as a parser for event(s)."""
def dec(func):
for event in events:
PARSERS[event] = func
return func
return dec | python | def parser(*events):
"""Decorator for convenience - adds a function as a parser for event(s)."""
def dec(func):
for event in events:
PARSERS[event] = func
return func
return dec | [
"def",
"parser",
"(",
"*",
"events",
")",
":",
"def",
"dec",
"(",
"func",
")",
":",
"for",
"event",
"in",
"events",
":",
"PARSERS",
"[",
"event",
"]",
"=",
"func",
"return",
"func",
"return",
"dec"
] | Decorator for convenience - adds a function as a parser for event(s). | [
"Decorator",
"for",
"convenience",
"-",
"adds",
"a",
"function",
"as",
"a",
"parser",
"for",
"event",
"(",
"s",
")",
"."
] | train | https://github.com/ayust/kitnirc/blob/cf19fe39219da75f053e1a3976bf21331b6fefea/kitnirc/client.py#L635-L641 |
ayust/kitnirc | kitnirc/client.py | _parse_msg | def _parse_msg(client, command, actor, args):
"""Parse a PRIVMSG or NOTICE and dispatch the corresponding event."""
recipient, _, message = args.partition(' :')
chantypes = client.server.features.get("CHANTYPES", "#")
if recipient[0] in chantypes:
recipient = client.server.get_channel(recipient)... | python | def _parse_msg(client, command, actor, args):
"""Parse a PRIVMSG or NOTICE and dispatch the corresponding event."""
recipient, _, message = args.partition(' :')
chantypes = client.server.features.get("CHANTYPES", "#")
if recipient[0] in chantypes:
recipient = client.server.get_channel(recipient)... | [
"def",
"_parse_msg",
"(",
"client",
",",
"command",
",",
"actor",
",",
"args",
")",
":",
"recipient",
",",
"_",
",",
"message",
"=",
"args",
".",
"partition",
"(",
"' :'",
")",
"chantypes",
"=",
"client",
".",
"server",
".",
"features",
".",
"get",
"... | Parse a PRIVMSG or NOTICE and dispatch the corresponding event. | [
"Parse",
"a",
"PRIVMSG",
"or",
"NOTICE",
"and",
"dispatch",
"the",
"corresponding",
"event",
"."
] | train | https://github.com/ayust/kitnirc/blob/cf19fe39219da75f053e1a3976bf21331b6fefea/kitnirc/client.py#L645-L653 |
ayust/kitnirc | kitnirc/client.py | _parse_join | def _parse_join(client, command, actor, args):
"""Parse a JOIN and update channel states, then dispatch events.
Note that two events are dispatched here:
- JOIN, because a user joined the channel
- MEMBERS, because the channel's members changed
"""
actor = User(actor)
channel = args... | python | def _parse_join(client, command, actor, args):
"""Parse a JOIN and update channel states, then dispatch events.
Note that two events are dispatched here:
- JOIN, because a user joined the channel
- MEMBERS, because the channel's members changed
"""
actor = User(actor)
channel = args... | [
"def",
"_parse_join",
"(",
"client",
",",
"command",
",",
"actor",
",",
"args",
")",
":",
"actor",
"=",
"User",
"(",
"actor",
")",
"channel",
"=",
"args",
".",
"lstrip",
"(",
"' :'",
")",
".",
"lower",
"(",
")",
"if",
"actor",
".",
"nick",
"==",
... | Parse a JOIN and update channel states, then dispatch events.
Note that two events are dispatched here:
- JOIN, because a user joined the channel
- MEMBERS, because the channel's members changed | [
"Parse",
"a",
"JOIN",
"and",
"update",
"channel",
"states",
"then",
"dispatch",
"events",
"."
] | train | https://github.com/ayust/kitnirc/blob/cf19fe39219da75f053e1a3976bf21331b6fefea/kitnirc/client.py#L668-L685 |
ayust/kitnirc | kitnirc/client.py | _parse_part | def _parse_part(client, command, actor, args):
"""Parse a PART and update channel states, then dispatch events.
Note that two events are dispatched here:
- PART, because a user parted the channel
- MEMBERS, because the channel's members changed
"""
actor = User(actor)
channel, _, me... | python | def _parse_part(client, command, actor, args):
"""Parse a PART and update channel states, then dispatch events.
Note that two events are dispatched here:
- PART, because a user parted the channel
- MEMBERS, because the channel's members changed
"""
actor = User(actor)
channel, _, me... | [
"def",
"_parse_part",
"(",
"client",
",",
"command",
",",
"actor",
",",
"args",
")",
":",
"actor",
"=",
"User",
"(",
"actor",
")",
"channel",
",",
"_",
",",
"message",
"=",
"args",
".",
"partition",
"(",
"' :'",
")",
"channel",
"=",
"client",
".",
... | Parse a PART and update channel states, then dispatch events.
Note that two events are dispatched here:
- PART, because a user parted the channel
- MEMBERS, because the channel's members changed | [
"Parse",
"a",
"PART",
"and",
"update",
"channel",
"states",
"then",
"dispatch",
"events",
"."
] | train | https://github.com/ayust/kitnirc/blob/cf19fe39219da75f053e1a3976bf21331b6fefea/kitnirc/client.py#L689-L704 |
ayust/kitnirc | kitnirc/client.py | _parse_quit | def _parse_quit(client, command, actor, args):
"""Parse a QUIT and update channel states, then dispatch events.
Note that two events are dispatched here:
- QUIT, because a user quit the server
- MEMBERS, for each channel the user is no longer in
"""
actor = User(actor)
_, _, message... | python | def _parse_quit(client, command, actor, args):
"""Parse a QUIT and update channel states, then dispatch events.
Note that two events are dispatched here:
- QUIT, because a user quit the server
- MEMBERS, for each channel the user is no longer in
"""
actor = User(actor)
_, _, message... | [
"def",
"_parse_quit",
"(",
"client",
",",
"command",
",",
"actor",
",",
"args",
")",
":",
"actor",
"=",
"User",
"(",
"actor",
")",
"_",
",",
"_",
",",
"message",
"=",
"args",
".",
"partition",
"(",
"':'",
")",
"client",
".",
"dispatch_event",
"(",
... | Parse a QUIT and update channel states, then dispatch events.
Note that two events are dispatched here:
- QUIT, because a user quit the server
- MEMBERS, for each channel the user is no longer in | [
"Parse",
"a",
"QUIT",
"and",
"update",
"channel",
"states",
"then",
"dispatch",
"events",
"."
] | train | https://github.com/ayust/kitnirc/blob/cf19fe39219da75f053e1a3976bf21331b6fefea/kitnirc/client.py#L708-L721 |
ayust/kitnirc | kitnirc/client.py | _parse_kick | def _parse_kick(client, command, actor, args):
"""Parse a KICK and update channel states, then dispatch events.
Note that two events are dispatched here:
- KICK, because a user was kicked from the channel
- MEMBERS, because the channel's members changed
"""
actor = User(actor)
args,... | python | def _parse_kick(client, command, actor, args):
"""Parse a KICK and update channel states, then dispatch events.
Note that two events are dispatched here:
- KICK, because a user was kicked from the channel
- MEMBERS, because the channel's members changed
"""
actor = User(actor)
args,... | [
"def",
"_parse_kick",
"(",
"client",
",",
"command",
",",
"actor",
",",
"args",
")",
":",
"actor",
"=",
"User",
"(",
"actor",
")",
"args",
",",
"_",
",",
"message",
"=",
"args",
".",
"partition",
"(",
"' :'",
")",
"channel",
",",
"target",
"=",
"ar... | Parse a KICK and update channel states, then dispatch events.
Note that two events are dispatched here:
- KICK, because a user was kicked from the channel
- MEMBERS, because the channel's members changed | [
"Parse",
"a",
"KICK",
"and",
"update",
"channel",
"states",
"then",
"dispatch",
"events",
"."
] | train | https://github.com/ayust/kitnirc/blob/cf19fe39219da75f053e1a3976bf21331b6fefea/kitnirc/client.py#L725-L741 |
ayust/kitnirc | kitnirc/client.py | _parse_topic | def _parse_topic(client, command, actor, args):
"""Parse a TOPIC and update channel state, then dispatch a TOPIC event."""
channel, _, topic = args.partition(" :")
channel = client.server.get_channel(channel)
channel.topic = topic or None
if actor:
actor = User(actor)
client.dispatch_eve... | python | def _parse_topic(client, command, actor, args):
"""Parse a TOPIC and update channel state, then dispatch a TOPIC event."""
channel, _, topic = args.partition(" :")
channel = client.server.get_channel(channel)
channel.topic = topic or None
if actor:
actor = User(actor)
client.dispatch_eve... | [
"def",
"_parse_topic",
"(",
"client",
",",
"command",
",",
"actor",
",",
"args",
")",
":",
"channel",
",",
"_",
",",
"topic",
"=",
"args",
".",
"partition",
"(",
"\" :\"",
")",
"channel",
"=",
"client",
".",
"server",
".",
"get_channel",
"(",
"channel"... | Parse a TOPIC and update channel state, then dispatch a TOPIC event. | [
"Parse",
"a",
"TOPIC",
"and",
"update",
"channel",
"state",
"then",
"dispatch",
"a",
"TOPIC",
"event",
"."
] | train | https://github.com/ayust/kitnirc/blob/cf19fe39219da75f053e1a3976bf21331b6fefea/kitnirc/client.py#L745-L752 |
ayust/kitnirc | kitnirc/client.py | _parse_welcome | def _parse_welcome(client, command, actor, args):
"""Parse a WELCOME and update user state, then dispatch a WELCOME event."""
_, _, hostmask = args.rpartition(' ')
client.user.update_from_hostmask(hostmask)
client.dispatch_event("WELCOME", hostmask) | python | def _parse_welcome(client, command, actor, args):
"""Parse a WELCOME and update user state, then dispatch a WELCOME event."""
_, _, hostmask = args.rpartition(' ')
client.user.update_from_hostmask(hostmask)
client.dispatch_event("WELCOME", hostmask) | [
"def",
"_parse_welcome",
"(",
"client",
",",
"command",
",",
"actor",
",",
"args",
")",
":",
"_",
",",
"_",
",",
"hostmask",
"=",
"args",
".",
"rpartition",
"(",
"' '",
")",
"client",
".",
"user",
".",
"update_from_hostmask",
"(",
"hostmask",
")",
"cli... | Parse a WELCOME and update user state, then dispatch a WELCOME event. | [
"Parse",
"a",
"WELCOME",
"and",
"update",
"user",
"state",
"then",
"dispatch",
"a",
"WELCOME",
"event",
"."
] | train | https://github.com/ayust/kitnirc/blob/cf19fe39219da75f053e1a3976bf21331b6fefea/kitnirc/client.py#L756-L760 |
ayust/kitnirc | kitnirc/client.py | _parse_created | def _parse_created(client, command, actor, args):
"""Parse CREATED and update the Host object."""
m = re.search("This server was created (.+)$", args)
if m:
client.server.created = m.group(1) | python | def _parse_created(client, command, actor, args):
"""Parse CREATED and update the Host object."""
m = re.search("This server was created (.+)$", args)
if m:
client.server.created = m.group(1) | [
"def",
"_parse_created",
"(",
"client",
",",
"command",
",",
"actor",
",",
"args",
")",
":",
"m",
"=",
"re",
".",
"search",
"(",
"\"This server was created (.+)$\"",
",",
"args",
")",
"if",
"m",
":",
"client",
".",
"server",
".",
"created",
"=",
"m",
"... | Parse CREATED and update the Host object. | [
"Parse",
"CREATED",
"and",
"update",
"the",
"Host",
"object",
"."
] | train | https://github.com/ayust/kitnirc/blob/cf19fe39219da75f053e1a3976bf21331b6fefea/kitnirc/client.py#L764-L768 |
ayust/kitnirc | kitnirc/client.py | _parse_myinfo | def _parse_myinfo(client, command, actor, args):
"""Parse MYINFO and update the Host object."""
_, server, version, usermodes, channelmodes = args.split(None, 5)[:5]
s = client.server
s.host = server
s.version = version
s.user_modes = set(usermodes)
s.channel_modes = set(channelmodes) | python | def _parse_myinfo(client, command, actor, args):
"""Parse MYINFO and update the Host object."""
_, server, version, usermodes, channelmodes = args.split(None, 5)[:5]
s = client.server
s.host = server
s.version = version
s.user_modes = set(usermodes)
s.channel_modes = set(channelmodes) | [
"def",
"_parse_myinfo",
"(",
"client",
",",
"command",
",",
"actor",
",",
"args",
")",
":",
"_",
",",
"server",
",",
"version",
",",
"usermodes",
",",
"channelmodes",
"=",
"args",
".",
"split",
"(",
"None",
",",
"5",
")",
"[",
":",
"5",
"]",
"s",
... | Parse MYINFO and update the Host object. | [
"Parse",
"MYINFO",
"and",
"update",
"the",
"Host",
"object",
"."
] | train | https://github.com/ayust/kitnirc/blob/cf19fe39219da75f053e1a3976bf21331b6fefea/kitnirc/client.py#L772-L779 |
ayust/kitnirc | kitnirc/client.py | _parse_featurelist | def _parse_featurelist(client, command, actor, args):
"""Parse FEATURELIST and update the Host object."""
# Strip off ":are supported by this server"
args = args.rsplit(":", 1)[0]
# Strip off the nick; we know it's addressed to us.
_, _, args = args.partition(' ')
items = args.split()
for i... | python | def _parse_featurelist(client, command, actor, args):
"""Parse FEATURELIST and update the Host object."""
# Strip off ":are supported by this server"
args = args.rsplit(":", 1)[0]
# Strip off the nick; we know it's addressed to us.
_, _, args = args.partition(' ')
items = args.split()
for i... | [
"def",
"_parse_featurelist",
"(",
"client",
",",
"command",
",",
"actor",
",",
"args",
")",
":",
"# Strip off \":are supported by this server\"",
"args",
"=",
"args",
".",
"rsplit",
"(",
"\":\"",
",",
"1",
")",
"[",
"0",
"]",
"# Strip off the nick; we know it's ad... | Parse FEATURELIST and update the Host object. | [
"Parse",
"FEATURELIST",
"and",
"update",
"the",
"Host",
"object",
"."
] | train | https://github.com/ayust/kitnirc/blob/cf19fe39219da75f053e1a3976bf21331b6fefea/kitnirc/client.py#L783-L800 |
ayust/kitnirc | kitnirc/client.py | _parse_namreply | def _parse_namreply(client, command, actor, args):
"""Parse NAMREPLY and update a Channel object."""
prefixes = client._get_prefixes()
channelinfo, _, useritems = args.partition(' :')
_, _, channel = channelinfo.rpartition(' ') # channeltype channelname
c = client.server.get_channel(channel)
... | python | def _parse_namreply(client, command, actor, args):
"""Parse NAMREPLY and update a Channel object."""
prefixes = client._get_prefixes()
channelinfo, _, useritems = args.partition(' :')
_, _, channel = channelinfo.rpartition(' ') # channeltype channelname
c = client.server.get_channel(channel)
... | [
"def",
"_parse_namreply",
"(",
"client",
",",
"command",
",",
"actor",
",",
"args",
")",
":",
"prefixes",
"=",
"client",
".",
"_get_prefixes",
"(",
")",
"channelinfo",
",",
"_",
",",
"useritems",
"=",
"args",
".",
"partition",
"(",
"' :'",
")",
"_",
",... | Parse NAMREPLY and update a Channel object. | [
"Parse",
"NAMREPLY",
"and",
"update",
"a",
"Channel",
"object",
"."
] | train | https://github.com/ayust/kitnirc/blob/cf19fe39219da75f053e1a3976bf21331b6fefea/kitnirc/client.py#L804-L829 |
ayust/kitnirc | kitnirc/client.py | _parse_endofnames | def _parse_endofnames(client, command, actor, args):
"""Parse an ENDOFNAMES and dispatch a NAMES event for the channel."""
args = args.split(" :", 1)[0] # Strip off human-readable message
_, _, channel = args.rpartition(' ')
channel = client.server.get_channel(channel) or channel.lower()
client.disp... | python | def _parse_endofnames(client, command, actor, args):
"""Parse an ENDOFNAMES and dispatch a NAMES event for the channel."""
args = args.split(" :", 1)[0] # Strip off human-readable message
_, _, channel = args.rpartition(' ')
channel = client.server.get_channel(channel) or channel.lower()
client.disp... | [
"def",
"_parse_endofnames",
"(",
"client",
",",
"command",
",",
"actor",
",",
"args",
")",
":",
"args",
"=",
"args",
".",
"split",
"(",
"\" :\"",
",",
"1",
")",
"[",
"0",
"]",
"# Strip off human-readable message",
"_",
",",
"_",
",",
"channel",
"=",
"a... | Parse an ENDOFNAMES and dispatch a NAMES event for the channel. | [
"Parse",
"an",
"ENDOFNAMES",
"and",
"dispatch",
"a",
"NAMES",
"event",
"for",
"the",
"channel",
"."
] | train | https://github.com/ayust/kitnirc/blob/cf19fe39219da75f053e1a3976bf21331b6fefea/kitnirc/client.py#L833-L838 |
ayust/kitnirc | kitnirc/client.py | _parse_mode | def _parse_mode(client, command, actor, args):
"""Parse a mode changes, update states, and dispatch MODE events."""
chantypes = client.server.features.get("CHANTYPES", "#")
channel, _, args = args.partition(" ")
args = args.lstrip(":")
if channel[0] not in chantypes:
# Personal modes
... | python | def _parse_mode(client, command, actor, args):
"""Parse a mode changes, update states, and dispatch MODE events."""
chantypes = client.server.features.get("CHANTYPES", "#")
channel, _, args = args.partition(" ")
args = args.lstrip(":")
if channel[0] not in chantypes:
# Personal modes
... | [
"def",
"_parse_mode",
"(",
"client",
",",
"command",
",",
"actor",
",",
"args",
")",
":",
"chantypes",
"=",
"client",
".",
"server",
".",
"features",
".",
"get",
"(",
"\"CHANTYPES\"",
",",
"\"#\"",
")",
"channel",
",",
"_",
",",
"args",
"=",
"args",
... | Parse a mode changes, update states, and dispatch MODE events. | [
"Parse",
"a",
"mode",
"changes",
"update",
"states",
"and",
"dispatch",
"MODE",
"events",
"."
] | train | https://github.com/ayust/kitnirc/blob/cf19fe39219da75f053e1a3976bf21331b6fefea/kitnirc/client.py#L842-L898 |
ayust/kitnirc | kitnirc/client.py | _parse_whois | def _parse_whois(client, command, actor, args):
"""Parse the content responses from a WHOIS query.
Individual response lines are parsed and used to fill in data in a buffer,
the full contents of which are then sent as the argument to the WHOIS
event dispatched when an ENDOFWHOIS line is received from t... | python | def _parse_whois(client, command, actor, args):
"""Parse the content responses from a WHOIS query.
Individual response lines are parsed and used to fill in data in a buffer,
the full contents of which are then sent as the argument to the WHOIS
event dispatched when an ENDOFWHOIS line is received from t... | [
"def",
"_parse_whois",
"(",
"client",
",",
"command",
",",
"actor",
",",
"args",
")",
":",
"_",
",",
"_",
",",
"args",
"=",
"args",
".",
"partition",
"(",
"\" \"",
")",
"# Strip off recipient, we know it\"s us",
"nick",
",",
"_",
",",
"args",
"=",
"args"... | Parse the content responses from a WHOIS query.
Individual response lines are parsed and used to fill in data in a buffer,
the full contents of which are then sent as the argument to the WHOIS
event dispatched when an ENDOFWHOIS line is received from the server. | [
"Parse",
"the",
"content",
"responses",
"from",
"a",
"WHOIS",
"query",
"."
] | train | https://github.com/ayust/kitnirc/blob/cf19fe39219da75f053e1a3976bf21331b6fefea/kitnirc/client.py#L904-L957 |
ayust/kitnirc | kitnirc/client.py | _parse_nick | def _parse_nick(client, command, actor, args):
"""Parse a NICK response, update state, and dispatch events.
Note: this function dispatches both a NICK event and also one or more
MEMBERS events for each channel the user that changed nick was in.
"""
old_nick, _, _ = actor.partition('!')
new_nick... | python | def _parse_nick(client, command, actor, args):
"""Parse a NICK response, update state, and dispatch events.
Note: this function dispatches both a NICK event and also one or more
MEMBERS events for each channel the user that changed nick was in.
"""
old_nick, _, _ = actor.partition('!')
new_nick... | [
"def",
"_parse_nick",
"(",
"client",
",",
"command",
",",
"actor",
",",
"args",
")",
":",
"old_nick",
",",
"_",
",",
"_",
"=",
"actor",
".",
"partition",
"(",
"'!'",
")",
"new_nick",
"=",
"args",
"if",
"old_nick",
"==",
"client",
".",
"user",
".",
... | Parse a NICK response, update state, and dispatch events.
Note: this function dispatches both a NICK event and also one or more
MEMBERS events for each channel the user that changed nick was in. | [
"Parse",
"a",
"NICK",
"response",
"update",
"state",
"and",
"dispatch",
"events",
"."
] | train | https://github.com/ayust/kitnirc/blob/cf19fe39219da75f053e1a3976bf21331b6fefea/kitnirc/client.py#L961-L984 |
ayust/kitnirc | kitnirc/client.py | _parse_invite | def _parse_invite(client, command, actor, args):
"""Parse an INVITE and dispatch an event."""
target, _, channel = args.rpartition(" ")
client.dispatch_event("INVITE", actor, target, channel.lower()) | python | def _parse_invite(client, command, actor, args):
"""Parse an INVITE and dispatch an event."""
target, _, channel = args.rpartition(" ")
client.dispatch_event("INVITE", actor, target, channel.lower()) | [
"def",
"_parse_invite",
"(",
"client",
",",
"command",
",",
"actor",
",",
"args",
")",
":",
"target",
",",
"_",
",",
"channel",
"=",
"args",
".",
"rpartition",
"(",
"\" \"",
")",
"client",
".",
"dispatch_event",
"(",
"\"INVITE\"",
",",
"actor",
",",
"t... | Parse an INVITE and dispatch an event. | [
"Parse",
"an",
"INVITE",
"and",
"dispatch",
"an",
"event",
"."
] | train | https://github.com/ayust/kitnirc/blob/cf19fe39219da75f053e1a3976bf21331b6fefea/kitnirc/client.py#L988-L991 |
ayust/kitnirc | kitnirc/client.py | _parse_nicknameinuse | def _parse_nicknameinuse(client, command, actor, args):
"""Parse a NICKNAMEINUSE message and dispatch an event.
The parameter passed along with the event is the nickname
which is already in use.
"""
nick, _, _ = args.rpartition(" ")
client.dispatch_event("NICKNAMEINUSE", nick) | python | def _parse_nicknameinuse(client, command, actor, args):
"""Parse a NICKNAMEINUSE message and dispatch an event.
The parameter passed along with the event is the nickname
which is already in use.
"""
nick, _, _ = args.rpartition(" ")
client.dispatch_event("NICKNAMEINUSE", nick) | [
"def",
"_parse_nicknameinuse",
"(",
"client",
",",
"command",
",",
"actor",
",",
"args",
")",
":",
"nick",
",",
"_",
",",
"_",
"=",
"args",
".",
"rpartition",
"(",
"\" \"",
")",
"client",
".",
"dispatch_event",
"(",
"\"NICKNAMEINUSE\"",
",",
"nick",
")"
... | Parse a NICKNAMEINUSE message and dispatch an event.
The parameter passed along with the event is the nickname
which is already in use. | [
"Parse",
"a",
"NICKNAMEINUSE",
"message",
"and",
"dispatch",
"an",
"event",
"."
] | train | https://github.com/ayust/kitnirc/blob/cf19fe39219da75f053e1a3976bf21331b6fefea/kitnirc/client.py#L995-L1002 |
ayust/kitnirc | kitnirc/client.py | Channel.add_user | def add_user(self, user):
"""Adds a user to the channel."""
if not isinstance(user, User):
user = User(user)
if user.nick in self.members:
_log.warning("Ignoring request to add user '%s' to channel '%s' "
"because that user is already in the membe... | python | def add_user(self, user):
"""Adds a user to the channel."""
if not isinstance(user, User):
user = User(user)
if user.nick in self.members:
_log.warning("Ignoring request to add user '%s' to channel '%s' "
"because that user is already in the membe... | [
"def",
"add_user",
"(",
"self",
",",
"user",
")",
":",
"if",
"not",
"isinstance",
"(",
"user",
",",
"User",
")",
":",
"user",
"=",
"User",
"(",
"user",
")",
"if",
"user",
".",
"nick",
"in",
"self",
".",
"members",
":",
"_log",
".",
"warning",
"("... | Adds a user to the channel. | [
"Adds",
"a",
"user",
"to",
"the",
"channel",
"."
] | train | https://github.com/ayust/kitnirc/blob/cf19fe39219da75f053e1a3976bf21331b6fefea/kitnirc/client.py#L37-L47 |
ayust/kitnirc | kitnirc/client.py | Client.add_handler | def add_handler(self, event, handler):
"""Adds a handler for a particular event.
Handlers are appended to the list, so a handler added earlier
will be called before a handler added later. If you wish to
insert a handler at another position, you should modify the
event_handlers p... | python | def add_handler(self, event, handler):
"""Adds a handler for a particular event.
Handlers are appended to the list, so a handler added earlier
will be called before a handler added later. If you wish to
insert a handler at another position, you should modify the
event_handlers p... | [
"def",
"add_handler",
"(",
"self",
",",
"event",
",",
"handler",
")",
":",
"if",
"event",
"not",
"in",
"self",
".",
"event_handlers",
":",
"_log",
".",
"info",
"(",
"\"Adding event handler for new event %s.\"",
",",
"event",
")",
"self",
".",
"event_handlers",... | Adds a handler for a particular event.
Handlers are appended to the list, so a handler added earlier
will be called before a handler added later. If you wish to
insert a handler at another position, you should modify the
event_handlers property directly:
my_client.event_han... | [
"Adds",
"a",
"handler",
"for",
"a",
"particular",
"event",
"."
] | train | https://github.com/ayust/kitnirc/blob/cf19fe39219da75f053e1a3976bf21331b6fefea/kitnirc/client.py#L203-L217 |
ayust/kitnirc | kitnirc/client.py | Client.dispatch_event | def dispatch_event(self, event, *args):
"""Dispatches an event.
Returns a boolean indicating whether or not a handler
suppressed further handling of the event (even the last).
"""
if event not in self.event_handlers:
_log.error("Dispatch requested for unknown event '... | python | def dispatch_event(self, event, *args):
"""Dispatches an event.
Returns a boolean indicating whether or not a handler
suppressed further handling of the event (even the last).
"""
if event not in self.event_handlers:
_log.error("Dispatch requested for unknown event '... | [
"def",
"dispatch_event",
"(",
"self",
",",
"event",
",",
"*",
"args",
")",
":",
"if",
"event",
"not",
"in",
"self",
".",
"event_handlers",
":",
"_log",
".",
"error",
"(",
"\"Dispatch requested for unknown event '%s'\"",
",",
"event",
")",
"return",
"False",
... | Dispatches an event.
Returns a boolean indicating whether or not a handler
suppressed further handling of the event (even the last). | [
"Dispatches",
"an",
"event",
"."
] | train | https://github.com/ayust/kitnirc/blob/cf19fe39219da75f053e1a3976bf21331b6fefea/kitnirc/client.py#L219-L245 |
ayust/kitnirc | kitnirc/client.py | Client.connect | def connect(self, nick, username=None, realname=None, password=None,
host=None, port=6667, ssl=None):
"""Connect to the server using the specified credentials.
Note: if host is specified here, both the host and port arguments
passed to Client.__init__ will be ignored.
I... | python | def connect(self, nick, username=None, realname=None, password=None,
host=None, port=6667, ssl=None):
"""Connect to the server using the specified credentials.
Note: if host is specified here, both the host and port arguments
passed to Client.__init__ will be ignored.
I... | [
"def",
"connect",
"(",
"self",
",",
"nick",
",",
"username",
"=",
"None",
",",
"realname",
"=",
"None",
",",
"password",
"=",
"None",
",",
"host",
"=",
"None",
",",
"port",
"=",
"6667",
",",
"ssl",
"=",
"None",
")",
":",
"if",
"host",
":",
"self"... | Connect to the server using the specified credentials.
Note: if host is specified here, both the host and port arguments
passed to Client.__init__ will be ignored.
If the 'ssl' argument is boolean true, will use SSL. If it is a
dictionary, will both use SSL and pass the contents as kwa... | [
"Connect",
"to",
"the",
"server",
"using",
"the",
"specified",
"credentials",
"."
] | train | https://github.com/ayust/kitnirc/blob/cf19fe39219da75f053e1a3976bf21331b6fefea/kitnirc/client.py#L247-L291 |
ayust/kitnirc | kitnirc/client.py | Client.run | def run(self):
"""Process events such as incoming data.
This method blocks indefinitely. It will only return after the
connection to the server is closed.
"""
self._stop = False # Allow re-starting the event loop
while not self._stop:
try:
sel... | python | def run(self):
"""Process events such as incoming data.
This method blocks indefinitely. It will only return after the
connection to the server is closed.
"""
self._stop = False # Allow re-starting the event loop
while not self._stop:
try:
sel... | [
"def",
"run",
"(",
"self",
")",
":",
"self",
".",
"_stop",
"=",
"False",
"# Allow re-starting the event loop",
"while",
"not",
"self",
".",
"_stop",
":",
"try",
":",
"self",
".",
"_buffer",
"+=",
"self",
".",
"socket",
".",
"recv",
"(",
"4096",
")",
"e... | Process events such as incoming data.
This method blocks indefinitely. It will only return after the
connection to the server is closed. | [
"Process",
"events",
"such",
"as",
"incoming",
"data",
"."
] | train | https://github.com/ayust/kitnirc/blob/cf19fe39219da75f053e1a3976bf21331b6fefea/kitnirc/client.py#L307-L326 |
ayust/kitnirc | kitnirc/client.py | Client.send | def send(self, *args):
"""Sends a single raw message to the IRC server.
Arguments are automatically joined by spaces. No newlines are allowed.
"""
msg = " ".join(a.nick if isinstance(a, User) else str(a) for a in args)
if "\n" in msg:
raise ValueError("Cannot send() ... | python | def send(self, *args):
"""Sends a single raw message to the IRC server.
Arguments are automatically joined by spaces. No newlines are allowed.
"""
msg = " ".join(a.nick if isinstance(a, User) else str(a) for a in args)
if "\n" in msg:
raise ValueError("Cannot send() ... | [
"def",
"send",
"(",
"self",
",",
"*",
"args",
")",
":",
"msg",
"=",
"\" \"",
".",
"join",
"(",
"a",
".",
"nick",
"if",
"isinstance",
"(",
"a",
",",
"User",
")",
"else",
"str",
"(",
"a",
")",
"for",
"a",
"in",
"args",
")",
"if",
"\"\\n\"",
"in... | Sends a single raw message to the IRC server.
Arguments are automatically joined by spaces. No newlines are allowed. | [
"Sends",
"a",
"single",
"raw",
"message",
"to",
"the",
"IRC",
"server",
"."
] | train | https://github.com/ayust/kitnirc/blob/cf19fe39219da75f053e1a3976bf21331b6fefea/kitnirc/client.py#L332-L341 |
ayust/kitnirc | kitnirc/client.py | Client.userinfo | def userinfo(self, username, realname=None):
"""Set the username and realname for this connection.
Note: this should only be called once, on connect. (The default
on-connect routine calls this automatically.)
"""
realname = realname or username
_log.info("Requesting use... | python | def userinfo(self, username, realname=None):
"""Set the username and realname for this connection.
Note: this should only be called once, on connect. (The default
on-connect routine calls this automatically.)
"""
realname = realname or username
_log.info("Requesting use... | [
"def",
"userinfo",
"(",
"self",
",",
"username",
",",
"realname",
"=",
"None",
")",
":",
"realname",
"=",
"realname",
"or",
"username",
"_log",
".",
"info",
"(",
"\"Requesting user info update: username=%s realname=%s\"",
",",
"username",
",",
"realname",
")",
"... | Set the username and realname for this connection.
Note: this should only be called once, on connect. (The default
on-connect routine calls this automatically.) | [
"Set",
"the",
"username",
"and",
"realname",
"for",
"this",
"connection",
"."
] | train | https://github.com/ayust/kitnirc/blob/cf19fe39219da75f053e1a3976bf21331b6fefea/kitnirc/client.py#L348-L362 |
ayust/kitnirc | kitnirc/client.py | Client.reply | def reply(self, incoming, user, message, prefix=None):
"""Replies to a user in a given channel or PM.
If the specified incoming is a user, simply sends a PM to user.
If the specified incoming is a channel, prefixes the message with the
user's nick and sends it to the channel.
T... | python | def reply(self, incoming, user, message, prefix=None):
"""Replies to a user in a given channel or PM.
If the specified incoming is a user, simply sends a PM to user.
If the specified incoming is a channel, prefixes the message with the
user's nick and sends it to the channel.
T... | [
"def",
"reply",
"(",
"self",
",",
"incoming",
",",
"user",
",",
"message",
",",
"prefix",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"user",
",",
"User",
")",
":",
"user",
"=",
"User",
"(",
"user",
")",
"if",
"isinstance",
"(",
"incomin... | Replies to a user in a given channel or PM.
If the specified incoming is a user, simply sends a PM to user.
If the specified incoming is a channel, prefixes the message with the
user's nick and sends it to the channel.
This is specifically useful in creating responses to commands that ... | [
"Replies",
"to",
"a",
"user",
"in",
"a",
"given",
"channel",
"or",
"PM",
"."
] | train | https://github.com/ayust/kitnirc/blob/cf19fe39219da75f053e1a3976bf21331b6fefea/kitnirc/client.py#L368-L391 |
ayust/kitnirc | kitnirc/client.py | Client.join | def join(self, target, key=None):
"""Attempt to join a channel.
The optional second argument is the channel key, if needed.
"""
chantypes = self.server.features.get("CHANTYPES", "#")
if not target or target[0] not in chantypes:
# Among other things, this prevents acc... | python | def join(self, target, key=None):
"""Attempt to join a channel.
The optional second argument is the channel key, if needed.
"""
chantypes = self.server.features.get("CHANTYPES", "#")
if not target or target[0] not in chantypes:
# Among other things, this prevents acc... | [
"def",
"join",
"(",
"self",
",",
"target",
",",
"key",
"=",
"None",
")",
":",
"chantypes",
"=",
"self",
".",
"server",
".",
"features",
".",
"get",
"(",
"\"CHANTYPES\"",
",",
"\"#\"",
")",
"if",
"not",
"target",
"or",
"target",
"[",
"0",
"]",
"not"... | Attempt to join a channel.
The optional second argument is the channel key, if needed. | [
"Attempt",
"to",
"join",
"a",
"channel",
"."
] | train | https://github.com/ayust/kitnirc/blob/cf19fe39219da75f053e1a3976bf21331b6fefea/kitnirc/client.py#L409-L429 |
ayust/kitnirc | kitnirc/client.py | Client.part | def part(self, target, message=None):
"""Part a channel."""
if not self.server.in_channel(target):
_log.warning("Ignoring request to part channel '%s' because we "
"are not in that channel.", target)
return
return False
self.send("PART... | python | def part(self, target, message=None):
"""Part a channel."""
if not self.server.in_channel(target):
_log.warning("Ignoring request to part channel '%s' because we "
"are not in that channel.", target)
return
return False
self.send("PART... | [
"def",
"part",
"(",
"self",
",",
"target",
",",
"message",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"server",
".",
"in_channel",
"(",
"target",
")",
":",
"_log",
".",
"warning",
"(",
"\"Ignoring request to part channel '%s' because we \"",
"\"are not i... | Part a channel. | [
"Part",
"a",
"channel",
"."
] | train | https://github.com/ayust/kitnirc/blob/cf19fe39219da75f053e1a3976bf21331b6fefea/kitnirc/client.py#L435-L443 |
ayust/kitnirc | kitnirc/client.py | Client.kick | def kick(self, channel, nick, message=None):
"""Attempt to kick a user from a channel.
If a message is not provided, defaults to own nick.
"""
self.send("KICK", channel, nick, ":%s" % (message or self.user.nick)) | python | def kick(self, channel, nick, message=None):
"""Attempt to kick a user from a channel.
If a message is not provided, defaults to own nick.
"""
self.send("KICK", channel, nick, ":%s" % (message or self.user.nick)) | [
"def",
"kick",
"(",
"self",
",",
"channel",
",",
"nick",
",",
"message",
"=",
"None",
")",
":",
"self",
".",
"send",
"(",
"\"KICK\"",
",",
"channel",
",",
"nick",
",",
"\":%s\"",
"%",
"(",
"message",
"or",
"self",
".",
"user",
".",
"nick",
")",
"... | Attempt to kick a user from a channel.
If a message is not provided, defaults to own nick. | [
"Attempt",
"to",
"kick",
"a",
"user",
"from",
"a",
"channel",
"."
] | train | https://github.com/ayust/kitnirc/blob/cf19fe39219da75f053e1a3976bf21331b6fefea/kitnirc/client.py#L451-L456 |
ayust/kitnirc | kitnirc/client.py | Client.mode | def mode(self, channel, add='', remove=''):
"""Add and/or remove modes for a given channel.
The 'add' and 'remove' arguments may, if specified, be either
sequences or dictionaries. If a dictionary is specified, the
corresponding values will be passed as arguments (with expansion
... | python | def mode(self, channel, add='', remove=''):
"""Add and/or remove modes for a given channel.
The 'add' and 'remove' arguments may, if specified, be either
sequences or dictionaries. If a dictionary is specified, the
corresponding values will be passed as arguments (with expansion
... | [
"def",
"mode",
"(",
"self",
",",
"channel",
",",
"add",
"=",
"''",
",",
"remove",
"=",
"''",
")",
":",
"if",
"not",
"self",
".",
"server",
".",
"in_channel",
"(",
"channel",
")",
":",
"_log",
".",
"warning",
"(",
"\"Ignoring request to set modes in chann... | Add and/or remove modes for a given channel.
The 'add' and 'remove' arguments may, if specified, be either
sequences or dictionaries. If a dictionary is specified, the
corresponding values will be passed as arguments (with expansion
if necessary - {'b': ['foo','bar']} will result in two... | [
"Add",
"and",
"/",
"or",
"remove",
"modes",
"for",
"a",
"given",
"channel",
"."
] | train | https://github.com/ayust/kitnirc/blob/cf19fe39219da75f053e1a3976bf21331b6fefea/kitnirc/client.py#L462-L526 |
ayust/kitnirc | kitnirc/client.py | Client.handle | def handle(self, event):
"""Decorator for adding a handler function for a particular event.
Usage:
my_client = Client()
@my_client.handle("WELCOME")
def welcome_handler(client, *params):
# Do something with the event.
pass
""... | python | def handle(self, event):
"""Decorator for adding a handler function for a particular event.
Usage:
my_client = Client()
@my_client.handle("WELCOME")
def welcome_handler(client, *params):
# Do something with the event.
pass
""... | [
"def",
"handle",
"(",
"self",
",",
"event",
")",
":",
"def",
"dec",
"(",
"func",
")",
":",
"self",
".",
"add_handler",
"(",
"event",
",",
"func",
")",
"return",
"func",
"return",
"dec"
] | Decorator for adding a handler function for a particular event.
Usage:
my_client = Client()
@my_client.handle("WELCOME")
def welcome_handler(client, *params):
# Do something with the event.
pass | [
"Decorator",
"for",
"adding",
"a",
"handler",
"function",
"for",
"a",
"particular",
"event",
"."
] | train | https://github.com/ayust/kitnirc/blob/cf19fe39219da75f053e1a3976bf21331b6fefea/kitnirc/client.py#L529-L544 |
ayust/kitnirc | kitnirc/client.py | Client._get_prefixes | def _get_prefixes(self):
"""Get the possible nick prefixes and associated modes for a client."""
prefixes = {
"@": "o",
"+": "v",
}
feature_prefixes = self.server.features.get('PREFIX')
if feature_prefixes:
modes = feature_prefixes[1:len(featur... | python | def _get_prefixes(self):
"""Get the possible nick prefixes and associated modes for a client."""
prefixes = {
"@": "o",
"+": "v",
}
feature_prefixes = self.server.features.get('PREFIX')
if feature_prefixes:
modes = feature_prefixes[1:len(featur... | [
"def",
"_get_prefixes",
"(",
"self",
")",
":",
"prefixes",
"=",
"{",
"\"@\"",
":",
"\"o\"",
",",
"\"+\"",
":",
"\"v\"",
",",
"}",
"feature_prefixes",
"=",
"self",
".",
"server",
".",
"features",
".",
"get",
"(",
"'PREFIX'",
")",
"if",
"feature_prefixes",... | Get the possible nick prefixes and associated modes for a client. | [
"Get",
"the",
"possible",
"nick",
"prefixes",
"and",
"associated",
"modes",
"for",
"a",
"client",
"."
] | train | https://github.com/ayust/kitnirc/blob/cf19fe39219da75f053e1a3976bf21331b6fefea/kitnirc/client.py#L546-L557 |
mitsei/dlkit | dlkit/json_/repository/default_mdata.py | get_asset_mdata | def get_asset_mdata():
"""Return default mdata map for Asset"""
return {
'copyright_registration': {
'element_label': {
'text': 'copyright registration',
'languageTypeId': str(DEFAULT_LANGUAGE_TYPE),
'scriptTypeId': str(DEFAULT_SCRIPT_TYPE),
... | python | def get_asset_mdata():
"""Return default mdata map for Asset"""
return {
'copyright_registration': {
'element_label': {
'text': 'copyright registration',
'languageTypeId': str(DEFAULT_LANGUAGE_TYPE),
'scriptTypeId': str(DEFAULT_SCRIPT_TYPE),
... | [
"def",
"get_asset_mdata",
"(",
")",
":",
"return",
"{",
"'copyright_registration'",
":",
"{",
"'element_label'",
":",
"{",
"'text'",
":",
"'copyright registration'",
",",
"'languageTypeId'",
":",
"str",
"(",
"DEFAULT_LANGUAGE_TYPE",
")",
",",
"'scriptTypeId'",
":",
... | Return default mdata map for Asset | [
"Return",
"default",
"mdata",
"map",
"for",
"Asset"
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/repository/default_mdata.py#L11-L326 |
mitsei/dlkit | dlkit/json_/repository/default_mdata.py | get_asset_content_mdata | def get_asset_content_mdata():
"""Return default mdata map for AssetContent"""
return {
'url': {
'element_label': {
'text': 'url',
'languageTypeId': str(DEFAULT_LANGUAGE_TYPE),
'scriptTypeId': str(DEFAULT_SCRIPT_TYPE),
'formatTy... | python | def get_asset_content_mdata():
"""Return default mdata map for AssetContent"""
return {
'url': {
'element_label': {
'text': 'url',
'languageTypeId': str(DEFAULT_LANGUAGE_TYPE),
'scriptTypeId': str(DEFAULT_SCRIPT_TYPE),
'formatTy... | [
"def",
"get_asset_content_mdata",
"(",
")",
":",
"return",
"{",
"'url'",
":",
"{",
"'element_label'",
":",
"{",
"'text'",
":",
"'url'",
",",
"'languageTypeId'",
":",
"str",
"(",
"DEFAULT_LANGUAGE_TYPE",
")",
",",
"'scriptTypeId'",
":",
"str",
"(",
"DEFAULT_SCR... | Return default mdata map for AssetContent | [
"Return",
"default",
"mdata",
"map",
"for",
"AssetContent"
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/repository/default_mdata.py#L329-L419 |
mitsei/dlkit | dlkit/json_/repository/default_mdata.py | get_composition_mdata | def get_composition_mdata():
"""Return default mdata map for Composition"""
return {
'children': {
'element_label': {
'text': 'children',
'languageTypeId': str(DEFAULT_LANGUAGE_TYPE),
'scriptTypeId': str(DEFAULT_SCRIPT_TYPE),
'f... | python | def get_composition_mdata():
"""Return default mdata map for Composition"""
return {
'children': {
'element_label': {
'text': 'children',
'languageTypeId': str(DEFAULT_LANGUAGE_TYPE),
'scriptTypeId': str(DEFAULT_SCRIPT_TYPE),
'f... | [
"def",
"get_composition_mdata",
"(",
")",
":",
"return",
"{",
"'children'",
":",
"{",
"'element_label'",
":",
"{",
"'text'",
":",
"'children'",
",",
"'languageTypeId'",
":",
"str",
"(",
"DEFAULT_LANGUAGE_TYPE",
")",
",",
"'scriptTypeId'",
":",
"str",
"(",
"DEF... | Return default mdata map for Composition | [
"Return",
"default",
"mdata",
"map",
"for",
"Composition"
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/repository/default_mdata.py#L422-L446 |
theosysbio/means | src/means/approximation/mea/closure_log_normal.py | LogNormalClosure._compute_raw_moments | def _compute_raw_moments(self, n_counter, k_counter):
# The symbols for expectations are simply the first order raw moments.
"""
:param n_counter: a list of :class:`~means.core.descriptors.Moment`\s representing central moments
:type n_counter: list[:class:`~means.core.descriptors.Momen... | python | def _compute_raw_moments(self, n_counter, k_counter):
# The symbols for expectations are simply the first order raw moments.
"""
:param n_counter: a list of :class:`~means.core.descriptors.Moment`\s representing central moments
:type n_counter: list[:class:`~means.core.descriptors.Momen... | [
"def",
"_compute_raw_moments",
"(",
"self",
",",
"n_counter",
",",
"k_counter",
")",
":",
"# The symbols for expectations are simply the first order raw moments.",
"expectation_symbols",
"=",
"[",
"pm",
".",
"symbol",
"for",
"pm",
"in",
"k_counter",
"if",
"pm",
".",
"... | :param n_counter: a list of :class:`~means.core.descriptors.Moment`\s representing central moments
:type n_counter: list[:class:`~means.core.descriptors.Moment`]
:param k_counter: a list of :class:`~means.core.descriptors.Moment`\s representing raw moments
:type k_counter: list[:class:`~means.co... | [
":",
"param",
"n_counter",
":",
"a",
"list",
"of",
":",
"class",
":",
"~means",
".",
"core",
".",
"descriptors",
".",
"Moment",
"\\",
"s",
"representing",
"central",
"moments",
":",
"type",
"n_counter",
":",
"list",
"[",
":",
"class",
":",
"~means",
".... | train | https://github.com/theosysbio/means/blob/fe164916a1d84ab2a4fa039871d38ccdf638b1db/src/means/approximation/mea/closure_log_normal.py#L32-L75 |
theosysbio/means | src/means/approximation/mea/closure_log_normal.py | LogNormalClosure._get_log_covariance | def _get_log_covariance(self, log_variance_mat, log_expectation_symbols, covariance_matrix, x, y):
r"""
Compute log covariances according to:\\
:math:`\log{(Cov(x_i,x_j))} = \frac { 1 + Cov(x_i,x_j)}{\exp[\log \mathbb{E}(x_i) + \log \mathbb{E}(x_j)+\frac{1}{2} (\log Var(x_i) + \log Var(x_j)]}`
... | python | def _get_log_covariance(self, log_variance_mat, log_expectation_symbols, covariance_matrix, x, y):
r"""
Compute log covariances according to:\\
:math:`\log{(Cov(x_i,x_j))} = \frac { 1 + Cov(x_i,x_j)}{\exp[\log \mathbb{E}(x_i) + \log \mathbb{E}(x_j)+\frac{1}{2} (\log Var(x_i) + \log Var(x_j)]}`
... | [
"def",
"_get_log_covariance",
"(",
"self",
",",
"log_variance_mat",
",",
"log_expectation_symbols",
",",
"covariance_matrix",
",",
"x",
",",
"y",
")",
":",
"# The diagonal of the return matrix includes all the log variances",
"if",
"x",
"==",
"y",
":",
"return",
"log_va... | r"""
Compute log covariances according to:\\
:math:`\log{(Cov(x_i,x_j))} = \frac { 1 + Cov(x_i,x_j)}{\exp[\log \mathbb{E}(x_i) + \log \mathbb{E}(x_j)+\frac{1}{2} (\log Var(x_i) + \log Var(x_j)]}`
:param log_variance_mat: a column matrix of log variance
:param log_expectation_symbols: a... | [
"r",
"Compute",
"log",
"covariances",
"according",
"to",
":",
"\\\\"
] | train | https://github.com/theosysbio/means/blob/fe164916a1d84ab2a4fa039871d38ccdf638b1db/src/means/approximation/mea/closure_log_normal.py#L93-L117 |
mitsei/dlkit | dlkit/authz_adapter/assessment_authoring/sessions.py | AssessmentPartSearchSession.get_assessment_parts_by_search | def get_assessment_parts_by_search(self, assessment_part_query, assessment_part_search):
"""Pass through to provider AssessmentPartSearchSession.get_assessment_parts_by_search"""
# Implemented from azosid template for -
# osid.resource.ResourceSearchSession.get_resources_by_search_template
... | python | def get_assessment_parts_by_search(self, assessment_part_query, assessment_part_search):
"""Pass through to provider AssessmentPartSearchSession.get_assessment_parts_by_search"""
# Implemented from azosid template for -
# osid.resource.ResourceSearchSession.get_resources_by_search_template
... | [
"def",
"get_assessment_parts_by_search",
"(",
"self",
",",
"assessment_part_query",
",",
"assessment_part_search",
")",
":",
"# Implemented from azosid template for -",
"# osid.resource.ResourceSearchSession.get_resources_by_search_template",
"if",
"not",
"self",
".",
"_can",
"(",
... | Pass through to provider AssessmentPartSearchSession.get_assessment_parts_by_search | [
"Pass",
"through",
"to",
"provider",
"AssessmentPartSearchSession",
".",
"get_assessment_parts_by_search"
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/authz_adapter/assessment_authoring/sessions.py#L378-L384 |
mitsei/dlkit | dlkit/authz_adapter/assessment_authoring/sessions.py | SequenceRuleSearchSession.get_sequence_rules_by_search | def get_sequence_rules_by_search(self, sequence_rule_query, sequence_rule_search):
"""Pass through to provider SequenceRuleSearchSession.get_sequence_rules_by_search"""
# Implemented from azosid template for -
# osid.resource.ResourceSearchSession.get_resources_by_search_template
if not ... | python | def get_sequence_rules_by_search(self, sequence_rule_query, sequence_rule_search):
"""Pass through to provider SequenceRuleSearchSession.get_sequence_rules_by_search"""
# Implemented from azosid template for -
# osid.resource.ResourceSearchSession.get_resources_by_search_template
if not ... | [
"def",
"get_sequence_rules_by_search",
"(",
"self",
",",
"sequence_rule_query",
",",
"sequence_rule_search",
")",
":",
"# Implemented from azosid template for -",
"# osid.resource.ResourceSearchSession.get_resources_by_search_template",
"if",
"not",
"self",
".",
"_can",
"(",
"'se... | Pass through to provider SequenceRuleSearchSession.get_sequence_rules_by_search | [
"Pass",
"through",
"to",
"provider",
"SequenceRuleSearchSession",
".",
"get_sequence_rules_by_search"
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/authz_adapter/assessment_authoring/sessions.py#L1313-L1319 |
mitsei/dlkit | dlkit/authz_adapter/assessment_authoring/sessions.py | SequenceRuleEnablerSearchSession.get_sequence_rule_enablers_by_search | def get_sequence_rule_enablers_by_search(self, sequence_rule_enabler_query, sequence_rule_enabler_search):
"""Pass through to provider SequenceRuleEnablerSearchSession.get_sequence_rule_enablers_by_search"""
# Implemented from azosid template for -
# osid.resource.ResourceSearchSession.get_resou... | python | def get_sequence_rule_enablers_by_search(self, sequence_rule_enabler_query, sequence_rule_enabler_search):
"""Pass through to provider SequenceRuleEnablerSearchSession.get_sequence_rule_enablers_by_search"""
# Implemented from azosid template for -
# osid.resource.ResourceSearchSession.get_resou... | [
"def",
"get_sequence_rule_enablers_by_search",
"(",
"self",
",",
"sequence_rule_enabler_query",
",",
"sequence_rule_enabler_search",
")",
":",
"# Implemented from azosid template for -",
"# osid.resource.ResourceSearchSession.get_resources_by_search_template",
"if",
"not",
"self",
".",... | Pass through to provider SequenceRuleEnablerSearchSession.get_sequence_rule_enablers_by_search | [
"Pass",
"through",
"to",
"provider",
"SequenceRuleEnablerSearchSession",
".",
"get_sequence_rule_enablers_by_search"
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/authz_adapter/assessment_authoring/sessions.py#L2039-L2045 |
delfick/harpoon | harpoon/option_spec/image_objs.py | Image.image_name | def image_name(self):
"""
The image_name of a container is the concatenation of the ``image_index``,
``image_name_prefix``, and ``name`` of the image.
Also, if $EXTRA_IMAGE_NAME is defined, that is appended
"""
if getattr(self, "_image_name", NotSpecified) is NotSpecifie... | python | def image_name(self):
"""
The image_name of a container is the concatenation of the ``image_index``,
``image_name_prefix``, and ``name`` of the image.
Also, if $EXTRA_IMAGE_NAME is defined, that is appended
"""
if getattr(self, "_image_name", NotSpecified) is NotSpecifie... | [
"def",
"image_name",
"(",
"self",
")",
":",
"if",
"getattr",
"(",
"self",
",",
"\"_image_name\"",
",",
"NotSpecified",
")",
"is",
"NotSpecified",
":",
"self",
".",
"_image_name",
"=",
"self",
".",
"prefixed_image_name",
"if",
"self",
".",
"image_index",
":",... | The image_name of a container is the concatenation of the ``image_index``,
``image_name_prefix``, and ``name`` of the image.
Also, if $EXTRA_IMAGE_NAME is defined, that is appended | [
"The",
"image_name",
"of",
"a",
"container",
"is",
"the",
"concatenation",
"of",
"the",
"image_index",
"image_name_prefix",
"and",
"name",
"of",
"the",
"image",
"."
] | train | https://github.com/delfick/harpoon/blob/a2d39311d6127b7da2e15f40468bf320d598e461/harpoon/option_spec/image_objs.py#L103-L118 |
delfick/harpoon | harpoon/option_spec/image_objs.py | Image.container_name | def container_name(self):
"""
The container_name is the concatenation of ``image_name`` and a uuid1 string
We also remove the url portion of the ``image_name`` before using it.
"""
if getattr(self, "_container_name", NotSpecified) is NotSpecified:
self.container_name... | python | def container_name(self):
"""
The container_name is the concatenation of ``image_name`` and a uuid1 string
We also remove the url portion of the ``image_name`` before using it.
"""
if getattr(self, "_container_name", NotSpecified) is NotSpecified:
self.container_name... | [
"def",
"container_name",
"(",
"self",
")",
":",
"if",
"getattr",
"(",
"self",
",",
"\"_container_name\"",
",",
"NotSpecified",
")",
"is",
"NotSpecified",
":",
"self",
".",
"container_name",
"=",
"\"{0}-{1}\"",
".",
"format",
"(",
"self",
".",
"image_name",
"... | The container_name is the concatenation of ``image_name`` and a uuid1 string
We also remove the url portion of the ``image_name`` before using it. | [
"The",
"container_name",
"is",
"the",
"concatenation",
"of",
"image_name",
"and",
"a",
"uuid1",
"string"
] | train | https://github.com/delfick/harpoon/blob/a2d39311d6127b7da2e15f40468bf320d598e461/harpoon/option_spec/image_objs.py#L144-L152 |
delfick/harpoon | harpoon/option_spec/image_objs.py | Image.container_id | def container_id(self):
"""
Find a container id
If one isn't already set, we ask docker for the container whose name is
the same as the recorded container_name
"""
if getattr(self, "_container_id", None):
return self._container_id
try:
co... | python | def container_id(self):
"""
Find a container id
If one isn't already set, we ask docker for the container whose name is
the same as the recorded container_name
"""
if getattr(self, "_container_id", None):
return self._container_id
try:
co... | [
"def",
"container_id",
"(",
"self",
")",
":",
"if",
"getattr",
"(",
"self",
",",
"\"_container_id\"",
",",
"None",
")",
":",
"return",
"self",
".",
"_container_id",
"try",
":",
"containers",
"=",
"self",
".",
"harpoon",
".",
"docker_api",
".",
"containers"... | Find a container id
If one isn't already set, we ask docker for the container whose name is
the same as the recorded container_name | [
"Find",
"a",
"container",
"id"
] | train | https://github.com/delfick/harpoon/blob/a2d39311d6127b7da2e15f40468bf320d598e461/harpoon/option_spec/image_objs.py#L155-L177 |
delfick/harpoon | harpoon/option_spec/image_objs.py | Image.formatted_command | def formatted_command(self):
"""
If we have ``bash``, then the command is ``/bin/bash -c <bash>``, whereas
if the ``command`` is set, then we just return that.
"""
bash = self.bash
if bash not in (None, "", NotSpecified) and callable(bash):
bash = bash()
... | python | def formatted_command(self):
"""
If we have ``bash``, then the command is ``/bin/bash -c <bash>``, whereas
if the ``command`` is set, then we just return that.
"""
bash = self.bash
if bash not in (None, "", NotSpecified) and callable(bash):
bash = bash()
... | [
"def",
"formatted_command",
"(",
"self",
")",
":",
"bash",
"=",
"self",
".",
"bash",
"if",
"bash",
"not",
"in",
"(",
"None",
",",
"\"\"",
",",
"NotSpecified",
")",
"and",
"callable",
"(",
"bash",
")",
":",
"bash",
"=",
"bash",
"(",
")",
"if",
"bash... | If we have ``bash``, then the command is ``/bin/bash -c <bash>``, whereas
if the ``command`` is set, then we just return that. | [
"If",
"we",
"have",
"bash",
"then",
"the",
"command",
"is",
"/",
"bin",
"/",
"bash",
"-",
"c",
"<bash",
">",
"whereas",
"if",
"the",
"command",
"is",
"set",
"then",
"we",
"just",
"return",
"that",
"."
] | train | https://github.com/delfick/harpoon/blob/a2d39311d6127b7da2e15f40468bf320d598e461/harpoon/option_spec/image_objs.py#L184-L201 |
delfick/harpoon | harpoon/option_spec/image_objs.py | Image.dependencies | def dependencies(self, images):
"""Yield just the dependency images"""
for dep in self.commands.dependent_images:
if not isinstance(dep, six.string_types):
yield dep.name
for image, _ in self.dependency_images():
yield image | python | def dependencies(self, images):
"""Yield just the dependency images"""
for dep in self.commands.dependent_images:
if not isinstance(dep, six.string_types):
yield dep.name
for image, _ in self.dependency_images():
yield image | [
"def",
"dependencies",
"(",
"self",
",",
"images",
")",
":",
"for",
"dep",
"in",
"self",
".",
"commands",
".",
"dependent_images",
":",
"if",
"not",
"isinstance",
"(",
"dep",
",",
"six",
".",
"string_types",
")",
":",
"yield",
"dep",
".",
"name",
"for"... | Yield just the dependency images | [
"Yield",
"just",
"the",
"dependency",
"images"
] | train | https://github.com/delfick/harpoon/blob/a2d39311d6127b7da2e15f40468bf320d598e461/harpoon/option_spec/image_objs.py#L207-L214 |
delfick/harpoon | harpoon/option_spec/image_objs.py | Image.cache_from_names | def cache_from_names(self):
"""Yield the image names to do --cache-from from"""
cache_from = self.cache_from()
if not cache_from or cache_from is NotSpecified:
return
if cache_from is True:
yield self.image_name
return
for thing in cache_fro... | python | def cache_from_names(self):
"""Yield the image names to do --cache-from from"""
cache_from = self.cache_from()
if not cache_from or cache_from is NotSpecified:
return
if cache_from is True:
yield self.image_name
return
for thing in cache_fro... | [
"def",
"cache_from_names",
"(",
"self",
")",
":",
"cache_from",
"=",
"self",
".",
"cache_from",
"(",
")",
"if",
"not",
"cache_from",
"or",
"cache_from",
"is",
"NotSpecified",
":",
"return",
"if",
"cache_from",
"is",
"True",
":",
"yield",
"self",
".",
"imag... | Yield the image names to do --cache-from from | [
"Yield",
"the",
"image",
"names",
"to",
"do",
"--",
"cache",
"-",
"from",
"from"
] | train | https://github.com/delfick/harpoon/blob/a2d39311d6127b7da2e15f40468bf320d598e461/harpoon/option_spec/image_objs.py#L217-L232 |
delfick/harpoon | harpoon/option_spec/image_objs.py | Image.dependency_images | def dependency_images(self, for_running=False):
"""
What images does this one require
Taking into account parent image, and those in link and volumes.share_with options
"""
candidates = []
detach = dict((candidate, not options.attached) for candidate, options in self.dep... | python | def dependency_images(self, for_running=False):
"""
What images does this one require
Taking into account parent image, and those in link and volumes.share_with options
"""
candidates = []
detach = dict((candidate, not options.attached) for candidate, options in self.dep... | [
"def",
"dependency_images",
"(",
"self",
",",
"for_running",
"=",
"False",
")",
":",
"candidates",
"=",
"[",
"]",
"detach",
"=",
"dict",
"(",
"(",
"candidate",
",",
"not",
"options",
".",
"attached",
")",
"for",
"candidate",
",",
"options",
"in",
"self",... | What images does this one require
Taking into account parent image, and those in link and volumes.share_with options | [
"What",
"images",
"does",
"this",
"one",
"require"
] | train | https://github.com/delfick/harpoon/blob/a2d39311d6127b7da2e15f40468bf320d598e461/harpoon/option_spec/image_objs.py#L234-L259 |
delfick/harpoon | harpoon/option_spec/image_objs.py | Image.shared_volume_containers | def shared_volume_containers(self):
"""All the harpoon containers in volumes.share_with for this container"""
for container in self.volumes.share_with:
if not isinstance(container, six.string_types):
yield container.name | python | def shared_volume_containers(self):
"""All the harpoon containers in volumes.share_with for this container"""
for container in self.volumes.share_with:
if not isinstance(container, six.string_types):
yield container.name | [
"def",
"shared_volume_containers",
"(",
"self",
")",
":",
"for",
"container",
"in",
"self",
".",
"volumes",
".",
"share_with",
":",
"if",
"not",
"isinstance",
"(",
"container",
",",
"six",
".",
"string_types",
")",
":",
"yield",
"container",
".",
"name"
] | All the harpoon containers in volumes.share_with for this container | [
"All",
"the",
"harpoon",
"containers",
"in",
"volumes",
".",
"share_with",
"for",
"this",
"container"
] | train | https://github.com/delfick/harpoon/blob/a2d39311d6127b7da2e15f40468bf320d598e461/harpoon/option_spec/image_objs.py#L261-L265 |
delfick/harpoon | harpoon/option_spec/image_objs.py | Image.find_missing_env | def find_missing_env(self):
"""Find any missing environment variables"""
missing = []
for e in self.env:
if e.default_val is None and e.set_val is None:
if e.env_name not in os.environ:
missing.append(e.env_name)
if missing:
ra... | python | def find_missing_env(self):
"""Find any missing environment variables"""
missing = []
for e in self.env:
if e.default_val is None and e.set_val is None:
if e.env_name not in os.environ:
missing.append(e.env_name)
if missing:
ra... | [
"def",
"find_missing_env",
"(",
"self",
")",
":",
"missing",
"=",
"[",
"]",
"for",
"e",
"in",
"self",
".",
"env",
":",
"if",
"e",
".",
"default_val",
"is",
"None",
"and",
"e",
".",
"set_val",
"is",
"None",
":",
"if",
"e",
".",
"env_name",
"not",
... | Find any missing environment variables | [
"Find",
"any",
"missing",
"environment",
"variables"
] | train | https://github.com/delfick/harpoon/blob/a2d39311d6127b7da2e15f40468bf320d598e461/harpoon/option_spec/image_objs.py#L267-L276 |
delfick/harpoon | harpoon/option_spec/image_objs.py | Image.display_line | def display_line(self):
"""A single line describing this image"""
msg = ["Image {0}".format(self.name)]
if self.image_index:
msg.append("Pushes to {0}".format(self.image_name))
return ' : '.join(msg) | python | def display_line(self):
"""A single line describing this image"""
msg = ["Image {0}".format(self.name)]
if self.image_index:
msg.append("Pushes to {0}".format(self.image_name))
return ' : '.join(msg) | [
"def",
"display_line",
"(",
"self",
")",
":",
"msg",
"=",
"[",
"\"Image {0}\"",
".",
"format",
"(",
"self",
".",
"name",
")",
"]",
"if",
"self",
".",
"image_index",
":",
"msg",
".",
"append",
"(",
"\"Pushes to {0}\"",
".",
"format",
"(",
"self",
".",
... | A single line describing this image | [
"A",
"single",
"line",
"describing",
"this",
"image"
] | train | https://github.com/delfick/harpoon/blob/a2d39311d6127b7da2e15f40468bf320d598e461/harpoon/option_spec/image_objs.py#L278-L283 |
delfick/harpoon | harpoon/option_spec/image_objs.py | Image.build_and_run | def build_and_run(self, images):
"""Make this image and run it"""
from harpoon.ship.builder import Builder
Builder().make_image(self, images)
try:
Runner().run_container(self, images)
except DockerAPIError as error:
raise BadImage("Failed to start the con... | python | def build_and_run(self, images):
"""Make this image and run it"""
from harpoon.ship.builder import Builder
Builder().make_image(self, images)
try:
Runner().run_container(self, images)
except DockerAPIError as error:
raise BadImage("Failed to start the con... | [
"def",
"build_and_run",
"(",
"self",
",",
"images",
")",
":",
"from",
"harpoon",
".",
"ship",
".",
"builder",
"import",
"Builder",
"Builder",
"(",
")",
".",
"make_image",
"(",
"self",
",",
"images",
")",
"try",
":",
"Runner",
"(",
")",
".",
"run_contai... | Make this image and run it | [
"Make",
"this",
"image",
"and",
"run",
"it"
] | train | https://github.com/delfick/harpoon/blob/a2d39311d6127b7da2e15f40468bf320d598e461/harpoon/option_spec/image_objs.py#L285-L293 |
delfick/harpoon | harpoon/option_spec/image_objs.py | Image.add_docker_file_to_tarfile | def add_docker_file_to_tarfile(self, docker_file, tar):
"""Add a Dockerfile to a tarfile"""
with hp.a_temp_file() as dockerfile:
log.debug("Context: ./Dockerfile")
dockerfile.write("\n".join(docker_file.docker_lines).encode('utf-8'))
dockerfile.seek(0)
tar... | python | def add_docker_file_to_tarfile(self, docker_file, tar):
"""Add a Dockerfile to a tarfile"""
with hp.a_temp_file() as dockerfile:
log.debug("Context: ./Dockerfile")
dockerfile.write("\n".join(docker_file.docker_lines).encode('utf-8'))
dockerfile.seek(0)
tar... | [
"def",
"add_docker_file_to_tarfile",
"(",
"self",
",",
"docker_file",
",",
"tar",
")",
":",
"with",
"hp",
".",
"a_temp_file",
"(",
")",
"as",
"dockerfile",
":",
"log",
".",
"debug",
"(",
"\"Context: ./Dockerfile\"",
")",
"dockerfile",
".",
"write",
"(",
"\"\... | Add a Dockerfile to a tarfile | [
"Add",
"a",
"Dockerfile",
"to",
"a",
"tarfile"
] | train | https://github.com/delfick/harpoon/blob/a2d39311d6127b7da2e15f40468bf320d598e461/harpoon/option_spec/image_objs.py#L305-L311 |
delfick/harpoon | harpoon/option_spec/image_objs.py | Image.make_context | def make_context(self, docker_file=None):
"""Determine the docker lines for this image"""
kwargs = {"silent_build": self.harpoon.silent_build, "extra_context": self.commands.extra_context}
if docker_file is None:
docker_file = self.docker_file
with ContextBuilder().make_conte... | python | def make_context(self, docker_file=None):
"""Determine the docker lines for this image"""
kwargs = {"silent_build": self.harpoon.silent_build, "extra_context": self.commands.extra_context}
if docker_file is None:
docker_file = self.docker_file
with ContextBuilder().make_conte... | [
"def",
"make_context",
"(",
"self",
",",
"docker_file",
"=",
"None",
")",
":",
"kwargs",
"=",
"{",
"\"silent_build\"",
":",
"self",
".",
"harpoon",
".",
"silent_build",
",",
"\"extra_context\"",
":",
"self",
".",
"commands",
".",
"extra_context",
"}",
"if",
... | Determine the docker lines for this image | [
"Determine",
"the",
"docker",
"lines",
"for",
"this",
"image"
] | train | https://github.com/delfick/harpoon/blob/a2d39311d6127b7da2e15f40468bf320d598e461/harpoon/option_spec/image_objs.py#L314-L321 |
delfick/harpoon | harpoon/option_spec/image_objs.py | WaitCondition.conditions | def conditions(self, start, last_attempt):
"""
Yield lines to execute in a docker context
All conditions must evaluate for the container to be considered ready
"""
if time.time() - start > self.timeout:
yield WaitCondition.Timedout
return
if last... | python | def conditions(self, start, last_attempt):
"""
Yield lines to execute in a docker context
All conditions must evaluate for the container to be considered ready
"""
if time.time() - start > self.timeout:
yield WaitCondition.Timedout
return
if last... | [
"def",
"conditions",
"(",
"self",
",",
"start",
",",
"last_attempt",
")",
":",
"if",
"time",
".",
"time",
"(",
")",
"-",
"start",
">",
"self",
".",
"timeout",
":",
"yield",
"WaitCondition",
".",
"Timedout",
"return",
"if",
"last_attempt",
"is",
"not",
... | Yield lines to execute in a docker context
All conditions must evaluate for the container to be considered ready | [
"Yield",
"lines",
"to",
"execute",
"in",
"a",
"docker",
"context"
] | train | https://github.com/delfick/harpoon/blob/a2d39311d6127b7da2e15f40468bf320d598e461/harpoon/option_spec/image_objs.py#L357-L396 |
delfick/harpoon | harpoon/option_spec/image_objs.py | Context.git_root | def git_root(self):
"""
Find the root git folder
"""
if not getattr(self, "_git_folder", None):
root_folder = os.path.abspath(self.parent_dir)
while not os.path.exists(os.path.join(root_folder, '.git')):
if root_folder == '/':
r... | python | def git_root(self):
"""
Find the root git folder
"""
if not getattr(self, "_git_folder", None):
root_folder = os.path.abspath(self.parent_dir)
while not os.path.exists(os.path.join(root_folder, '.git')):
if root_folder == '/':
r... | [
"def",
"git_root",
"(",
"self",
")",
":",
"if",
"not",
"getattr",
"(",
"self",
",",
"\"_git_folder\"",
",",
"None",
")",
":",
"root_folder",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"self",
".",
"parent_dir",
")",
"while",
"not",
"os",
".",
"path... | Find the root git folder | [
"Find",
"the",
"root",
"git",
"folder"
] | train | https://github.com/delfick/harpoon/blob/a2d39311d6127b7da2e15f40468bf320d598e461/harpoon/option_spec/image_objs.py#L427-L438 |
delfick/harpoon | harpoon/option_spec/image_objs.py | Volumes.share_with_names | def share_with_names(self):
"""The names of the containers that we share with the running container"""
for container in self.share_with:
if isinstance(container, six.string_types):
yield container
else:
yield container.container_name | python | def share_with_names(self):
"""The names of the containers that we share with the running container"""
for container in self.share_with:
if isinstance(container, six.string_types):
yield container
else:
yield container.container_name | [
"def",
"share_with_names",
"(",
"self",
")",
":",
"for",
"container",
"in",
"self",
".",
"share_with",
":",
"if",
"isinstance",
"(",
"container",
",",
"six",
".",
"string_types",
")",
":",
"yield",
"container",
"else",
":",
"yield",
"container",
".",
"cont... | The names of the containers that we share with the running container | [
"The",
"names",
"of",
"the",
"containers",
"that",
"we",
"share",
"with",
"the",
"running",
"container"
] | train | https://github.com/delfick/harpoon/blob/a2d39311d6127b7da2e15f40468bf320d598e461/harpoon/option_spec/image_objs.py#L456-L462 |
delfick/harpoon | harpoon/option_spec/image_objs.py | Environment.pair | def pair(self):
"""Get the name and value for this environment variable"""
if self.set_val is not None:
return self.env_name, self.set_val
elif self.default_val is not None:
return self.env_name, os.environ.get(self.env_name, self.default_val)
else:
re... | python | def pair(self):
"""Get the name and value for this environment variable"""
if self.set_val is not None:
return self.env_name, self.set_val
elif self.default_val is not None:
return self.env_name, os.environ.get(self.env_name, self.default_val)
else:
re... | [
"def",
"pair",
"(",
"self",
")",
":",
"if",
"self",
".",
"set_val",
"is",
"not",
"None",
":",
"return",
"self",
".",
"env_name",
",",
"self",
".",
"set_val",
"elif",
"self",
".",
"default_val",
"is",
"not",
"None",
":",
"return",
"self",
".",
"env_na... | Get the name and value for this environment variable | [
"Get",
"the",
"name",
"and",
"value",
"for",
"this",
"environment",
"variable"
] | train | https://github.com/delfick/harpoon/blob/a2d39311d6127b7da2e15f40468bf320d598e461/harpoon/option_spec/image_objs.py#L494-L501 |
delfick/harpoon | harpoon/option_spec/image_objs.py | Port.pair | def pair(self):
"""return (container_port, (ip, host_port)) or (container_port, host_port)"""
if self.ip is NotSpecified:
if self.ip is NotSpecified:
second = self.host_port
else:
second = (self.ip, )
else:
second = (self.ip, se... | python | def pair(self):
"""return (container_port, (ip, host_port)) or (container_port, host_port)"""
if self.ip is NotSpecified:
if self.ip is NotSpecified:
second = self.host_port
else:
second = (self.ip, )
else:
second = (self.ip, se... | [
"def",
"pair",
"(",
"self",
")",
":",
"if",
"self",
".",
"ip",
"is",
"NotSpecified",
":",
"if",
"self",
".",
"ip",
"is",
"NotSpecified",
":",
"second",
"=",
"self",
".",
"host_port",
"else",
":",
"second",
"=",
"(",
"self",
".",
"ip",
",",
")",
"... | return (container_port, (ip, host_port)) or (container_port, host_port) | [
"return",
"(",
"container_port",
"(",
"ip",
"host_port",
"))",
"or",
"(",
"container_port",
"host_port",
")"
] | train | https://github.com/delfick/harpoon/blob/a2d39311d6127b7da2e15f40468bf320d598e461/harpoon/option_spec/image_objs.py#L508-L517 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.