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 |
|---|---|---|---|---|---|---|---|---|---|---|
mitodl/PyLmod | pylmod/gradebook.py | GradeBook.get_assignments | def get_assignments(
self,
gradebook_id='',
simple=False,
max_points=True,
avg_stats=False,
grading_stats=False
):
"""Get assignments for a gradebook.
Return list of assignments for a given gradebook,
specified by a py:... | python | def get_assignments(
self,
gradebook_id='',
simple=False,
max_points=True,
avg_stats=False,
grading_stats=False
):
"""Get assignments for a gradebook.
Return list of assignments for a given gradebook,
specified by a py:... | [
"def",
"get_assignments",
"(",
"self",
",",
"gradebook_id",
"=",
"''",
",",
"simple",
"=",
"False",
",",
"max_points",
"=",
"True",
",",
"avg_stats",
"=",
"False",
",",
"grading_stats",
"=",
"False",
")",
":",
"# These are parameters required for the remote API ca... | Get assignments for a gradebook.
Return list of assignments for a given gradebook,
specified by a py:attribute::gradebook_id. You can control
if additional parameters are returned, but the response
time with py:attribute::avg_stats and py:attribute::grading_stats
enabled is sig... | [
"Get",
"assignments",
"for",
"a",
"gradebook",
"."
] | train | https://github.com/mitodl/PyLmod/blob/b798b86c33d1eb615e7cd4f3457b5c15da1d86e0/pylmod/gradebook.py#L183-L280 |
mitodl/PyLmod | pylmod/gradebook.py | GradeBook.get_assignment_by_name | def get_assignment_by_name(self, assignment_name, assignments=None):
"""Get assignment by name.
Get an assignment by name. It works by retrieving all assignments
and returning the first assignment with a matching name. If the
optional parameter ``assignments`` is provided, it uses this
... | python | def get_assignment_by_name(self, assignment_name, assignments=None):
"""Get assignment by name.
Get an assignment by name. It works by retrieving all assignments
and returning the first assignment with a matching name. If the
optional parameter ``assignments`` is provided, it uses this
... | [
"def",
"get_assignment_by_name",
"(",
"self",
",",
"assignment_name",
",",
"assignments",
"=",
"None",
")",
":",
"if",
"assignments",
"is",
"None",
":",
"assignments",
"=",
"self",
".",
"get_assignments",
"(",
")",
"for",
"assignment",
"in",
"assignments",
":"... | Get assignment by name.
Get an assignment by name. It works by retrieving all assignments
and returning the first assignment with a matching name. If the
optional parameter ``assignments`` is provided, it uses this
collection rather than retrieving all assignments from the service.
... | [
"Get",
"assignment",
"by",
"name",
"."
] | train | https://github.com/mitodl/PyLmod/blob/b798b86c33d1eb615e7cd4f3457b5c15da1d86e0/pylmod/gradebook.py#L282-L333 |
mitodl/PyLmod | pylmod/gradebook.py | GradeBook.create_assignment | def create_assignment( # pylint: disable=too-many-arguments
self,
name,
short_name,
weight,
max_points,
due_date_str,
gradebook_id='',
**kwargs
):
"""Create a new assignment.
Create a new assignment. By... | python | def create_assignment( # pylint: disable=too-many-arguments
self,
name,
short_name,
weight,
max_points,
due_date_str,
gradebook_id='',
**kwargs
):
"""Create a new assignment.
Create a new assignment. By... | [
"def",
"create_assignment",
"(",
"# pylint: disable=too-many-arguments",
"self",
",",
"name",
",",
"short_name",
",",
"weight",
",",
"max_points",
",",
"due_date_str",
",",
"gradebook_id",
"=",
"''",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"{",
"'name'... | Create a new assignment.
Create a new assignment. By default, assignments are created
under the `Uncategorized` category.
Args:
name (str): descriptive assignment name,
i.e. ``new NUMERIC SIMPLE ASSIGNMENT``
short_name (str): short name of assignment, on... | [
"Create",
"a",
"new",
"assignment",
"."
] | train | https://github.com/mitodl/PyLmod/blob/b798b86c33d1eb615e7cd4f3457b5c15da1d86e0/pylmod/gradebook.py#L335-L425 |
mitodl/PyLmod | pylmod/gradebook.py | GradeBook.set_grade | def set_grade(
self,
assignment_id,
student_id,
grade_value,
gradebook_id='',
**kwargs
):
"""Set numerical grade for student and assignment.
Set a numerical grade for for a student and assignment. Additional
options
... | python | def set_grade(
self,
assignment_id,
student_id,
grade_value,
gradebook_id='',
**kwargs
):
"""Set numerical grade for student and assignment.
Set a numerical grade for for a student and assignment. Additional
options
... | [
"def",
"set_grade",
"(",
"self",
",",
"assignment_id",
",",
"student_id",
",",
"grade_value",
",",
"gradebook_id",
"=",
"''",
",",
"*",
"*",
"kwargs",
")",
":",
"# pylint: disable=too-many-arguments",
"# numericGradeValue stringified because 'x' is a possible",
"# value f... | Set numerical grade for student and assignment.
Set a numerical grade for for a student and assignment. Additional
options
for grade ``mode`` are: OVERALL_GRADE = ``1``, REGULAR_GRADE = ``2``
To set 'excused' as the grade, enter ``None`` for letter and
numeric grade values,
... | [
"Set",
"numerical",
"grade",
"for",
"student",
"and",
"assignment",
"."
] | train | https://github.com/mitodl/PyLmod/blob/b798b86c33d1eb615e7cd4f3457b5c15da1d86e0/pylmod/gradebook.py#L454-L531 |
mitodl/PyLmod | pylmod/gradebook.py | GradeBook.multi_grade | def multi_grade(self, grade_array, gradebook_id=''):
"""Set multiple grades for students.
Set multiple student grades for a gradebook. The grades are passed
as a list of dictionaries.
Each grade dictionary in ``grade_array`` must contain a
``studentId`` and a ``assignmentId``.... | python | def multi_grade(self, grade_array, gradebook_id=''):
"""Set multiple grades for students.
Set multiple student grades for a gradebook. The grades are passed
as a list of dictionaries.
Each grade dictionary in ``grade_array`` must contain a
``studentId`` and a ``assignmentId``.... | [
"def",
"multi_grade",
"(",
"self",
",",
"grade_array",
",",
"gradebook_id",
"=",
"''",
")",
":",
"log",
".",
"info",
"(",
"'Sending grades: %r'",
",",
"grade_array",
")",
"return",
"self",
".",
"post",
"(",
"'multiGrades/{gradebookId}'",
".",
"format",
"(",
... | Set multiple grades for students.
Set multiple student grades for a gradebook. The grades are passed
as a list of dictionaries.
Each grade dictionary in ``grade_array`` must contain a
``studentId`` and a ``assignmentId``.
Options for grade mode are: OVERALL_GRADE = ``1``,
... | [
"Set",
"multiple",
"grades",
"for",
"students",
"."
] | train | https://github.com/mitodl/PyLmod/blob/b798b86c33d1eb615e7cd4f3457b5c15da1d86e0/pylmod/gradebook.py#L533-L609 |
mitodl/PyLmod | pylmod/gradebook.py | GradeBook.get_sections | def get_sections(self, gradebook_id='', simple=False):
"""Get the sections for a gradebook.
Return a dictionary of types of sections containing a list of that
type for a given gradebook. Specified by a gradebookid.
If simple=True, a list of dictionaries is provided for each
se... | python | def get_sections(self, gradebook_id='', simple=False):
"""Get the sections for a gradebook.
Return a dictionary of types of sections containing a list of that
type for a given gradebook. Specified by a gradebookid.
If simple=True, a list of dictionaries is provided for each
se... | [
"def",
"get_sections",
"(",
"self",
",",
"gradebook_id",
"=",
"''",
",",
"simple",
"=",
"False",
")",
":",
"params",
"=",
"dict",
"(",
"includeMembers",
"=",
"'false'",
")",
"section_data",
"=",
"self",
".",
"get",
"(",
"'sections/{gradebookId}'",
".",
"fo... | Get the sections for a gradebook.
Return a dictionary of types of sections containing a list of that
type for a given gradebook. Specified by a gradebookid.
If simple=True, a list of dictionaries is provided for each
section regardless of type. The dictionary only contains one
... | [
"Get",
"the",
"sections",
"for",
"a",
"gradebook",
"."
] | train | https://github.com/mitodl/PyLmod/blob/b798b86c33d1eb615e7cd4f3457b5c15da1d86e0/pylmod/gradebook.py#L611-L681 |
mitodl/PyLmod | pylmod/gradebook.py | GradeBook.get_section_by_name | def get_section_by_name(self, section_name):
"""Get a section by its name.
Get a list of sections for a given gradebook,
specified by a gradebookid.
Args:
section_name (str): The section's name.
Raises:
requests.RequestException: Exception connection er... | python | def get_section_by_name(self, section_name):
"""Get a section by its name.
Get a list of sections for a given gradebook,
specified by a gradebookid.
Args:
section_name (str): The section's name.
Raises:
requests.RequestException: Exception connection er... | [
"def",
"get_section_by_name",
"(",
"self",
",",
"section_name",
")",
":",
"sections",
"=",
"self",
".",
"unravel_sections",
"(",
"self",
".",
"get_sections",
"(",
")",
")",
"for",
"section",
"in",
"sections",
":",
"if",
"section",
"[",
"'name'",
"]",
"==",... | Get a section by its name.
Get a list of sections for a given gradebook,
specified by a gradebookid.
Args:
section_name (str): The section's name.
Raises:
requests.RequestException: Exception connection error
ValueError: Unable to decode response co... | [
"Get",
"a",
"section",
"by",
"its",
"name",
"."
] | train | https://github.com/mitodl/PyLmod/blob/b798b86c33d1eb615e7cd4f3457b5c15da1d86e0/pylmod/gradebook.py#L683-L721 |
mitodl/PyLmod | pylmod/gradebook.py | GradeBook.get_students | def get_students(
self,
gradebook_id='',
simple=False,
section_name='',
include_photo=False,
include_grade_info=False,
include_grade_history=False,
include_makeup_grades=False
):
"""Get students for a gradebook.
... | python | def get_students(
self,
gradebook_id='',
simple=False,
section_name='',
include_photo=False,
include_grade_info=False,
include_grade_history=False,
include_makeup_grades=False
):
"""Get students for a gradebook.
... | [
"def",
"get_students",
"(",
"self",
",",
"gradebook_id",
"=",
"''",
",",
"simple",
"=",
"False",
",",
"section_name",
"=",
"''",
",",
"include_photo",
"=",
"False",
",",
"include_grade_info",
"=",
"False",
",",
"include_grade_history",
"=",
"False",
",",
"in... | Get students for a gradebook.
Get a list of students for a given gradebook,
specified by a gradebook id. Does not include grade data.
Args:
gradebook_id (str): unique identifier for gradebook, i.e. ``2314``
simple (bool):
if ``True``, just return diction... | [
"Get",
"students",
"for",
"a",
"gradebook",
"."
] | train | https://github.com/mitodl/PyLmod/blob/b798b86c33d1eb615e7cd4f3457b5c15da1d86e0/pylmod/gradebook.py#L723-L838 |
mitodl/PyLmod | pylmod/gradebook.py | GradeBook.get_student_by_email | def get_student_by_email(self, email, students=None):
"""Get a student based on an email address.
Calls ``self.get_students()`` to get list of all students,
if not passed as the ``students`` parameter.
Args:
email (str): student email
students (list): dictionary... | python | def get_student_by_email(self, email, students=None):
"""Get a student based on an email address.
Calls ``self.get_students()`` to get list of all students,
if not passed as the ``students`` parameter.
Args:
email (str): student email
students (list): dictionary... | [
"def",
"get_student_by_email",
"(",
"self",
",",
"email",
",",
"students",
"=",
"None",
")",
":",
"if",
"students",
"is",
"None",
":",
"students",
"=",
"self",
".",
"get_students",
"(",
")",
"email",
"=",
"email",
".",
"lower",
"(",
")",
"for",
"studen... | Get a student based on an email address.
Calls ``self.get_students()`` to get list of all students,
if not passed as the ``students`` parameter.
Args:
email (str): student email
students (list): dictionary of students to search, default: None
When ``stud... | [
"Get",
"a",
"student",
"based",
"on",
"an",
"email",
"address",
"."
] | train | https://github.com/mitodl/PyLmod/blob/b798b86c33d1eb615e7cd4f3457b5c15da1d86e0/pylmod/gradebook.py#L840-L866 |
mitodl/PyLmod | pylmod/gradebook.py | GradeBook._spreadsheet2gradebook_multi | def _spreadsheet2gradebook_multi(
self,
csv_reader,
email_field,
non_assignment_fields,
approve_grades=False,
use_max_points_column=False,
max_points_column=None,
normalize_column=None
):
"""Transfer grades from ... | python | def _spreadsheet2gradebook_multi(
self,
csv_reader,
email_field,
non_assignment_fields,
approve_grades=False,
use_max_points_column=False,
max_points_column=None,
normalize_column=None
):
"""Transfer grades from ... | [
"def",
"_spreadsheet2gradebook_multi",
"(",
"self",
",",
"csv_reader",
",",
"email_field",
",",
"non_assignment_fields",
",",
"approve_grades",
"=",
"False",
",",
"use_max_points_column",
"=",
"False",
",",
"max_points_column",
"=",
"None",
",",
"normalize_column",
"=... | Transfer grades from spreadsheet to array.
Helper function that transfer grades from spreadsheet using
``multi_grade()`` (multiple students at a time). We do this by
creating a large array containing all grades to transfer, then
make one call to the Gradebook API.
Args:
... | [
"Transfer",
"grades",
"from",
"spreadsheet",
"to",
"array",
"."
] | train | https://github.com/mitodl/PyLmod/blob/b798b86c33d1eb615e7cd4f3457b5c15da1d86e0/pylmod/gradebook.py#L868-L1051 |
mitodl/PyLmod | pylmod/gradebook.py | GradeBook.spreadsheet2gradebook | def spreadsheet2gradebook(
self,
csv_file,
email_field=None,
approve_grades=False,
use_max_points_column=False,
max_points_column=None,
normalize_column=None
):
"""Upload grade spreadsheet to gradebook.
Upload grade... | python | def spreadsheet2gradebook(
self,
csv_file,
email_field=None,
approve_grades=False,
use_max_points_column=False,
max_points_column=None,
normalize_column=None
):
"""Upload grade spreadsheet to gradebook.
Upload grade... | [
"def",
"spreadsheet2gradebook",
"(",
"self",
",",
"csv_file",
",",
"email_field",
"=",
"None",
",",
"approve_grades",
"=",
"False",
",",
"use_max_points_column",
"=",
"False",
",",
"max_points_column",
"=",
"None",
",",
"normalize_column",
"=",
"None",
")",
":",... | Upload grade spreadsheet to gradebook.
Upload grades from CSV format spreadsheet file into the
Learning Modules gradebook. The spreadsheet must have a column
named ``External email`` which is used as the student's email
address (for looking up and matching studentId).
These co... | [
"Upload",
"grade",
"spreadsheet",
"to",
"gradebook",
"."
] | train | https://github.com/mitodl/PyLmod/blob/b798b86c33d1eb615e7cd4f3457b5c15da1d86e0/pylmod/gradebook.py#L1053-L1137 |
mitodl/PyLmod | pylmod/gradebook.py | GradeBook.get_staff | def get_staff(self, gradebook_id, simple=False):
"""Get staff list for gradebook.
Get staff list for the gradebook specified. Optionally, return
a less detailed list by specifying ``simple = True``.
If simple=True, return a list of dictionaries, one dictionary
for each member. ... | python | def get_staff(self, gradebook_id, simple=False):
"""Get staff list for gradebook.
Get staff list for the gradebook specified. Optionally, return
a less detailed list by specifying ``simple = True``.
If simple=True, return a list of dictionaries, one dictionary
for each member. ... | [
"def",
"get_staff",
"(",
"self",
",",
"gradebook_id",
",",
"simple",
"=",
"False",
")",
":",
"staff_data",
"=",
"self",
".",
"get",
"(",
"'staff/{gradebookId}'",
".",
"format",
"(",
"gradebookId",
"=",
"gradebook_id",
"or",
"self",
".",
"gradebook_id",
")",
... | Get staff list for gradebook.
Get staff list for the gradebook specified. Optionally, return
a less detailed list by specifying ``simple = True``.
If simple=True, return a list of dictionaries, one dictionary
for each member. The dictionary contains a member's ``email``,
``disp... | [
"Get",
"staff",
"list",
"for",
"gradebook",
"."
] | train | https://github.com/mitodl/PyLmod/blob/b798b86c33d1eb615e7cd4f3457b5c15da1d86e0/pylmod/gradebook.py#L1139-L1232 |
mitodl/PyLmod | pylmod/membership.py | Membership.get_group | def get_group(self, uuid=None):
"""Get group data based on uuid.
Args:
uuid (str): optional uuid. defaults to self.cuuid
Raises:
PyLmodUnexpectedData: No data was returned.
requests.RequestException: Exception connection error
Returns:
d... | python | def get_group(self, uuid=None):
"""Get group data based on uuid.
Args:
uuid (str): optional uuid. defaults to self.cuuid
Raises:
PyLmodUnexpectedData: No data was returned.
requests.RequestException: Exception connection error
Returns:
d... | [
"def",
"get_group",
"(",
"self",
",",
"uuid",
"=",
"None",
")",
":",
"if",
"uuid",
"is",
"None",
":",
"uuid",
"=",
"self",
".",
"uuid",
"group_data",
"=",
"self",
".",
"get",
"(",
"'group'",
",",
"params",
"=",
"{",
"'uuid'",
":",
"uuid",
"}",
")... | Get group data based on uuid.
Args:
uuid (str): optional uuid. defaults to self.cuuid
Raises:
PyLmodUnexpectedData: No data was returned.
requests.RequestException: Exception connection error
Returns:
dict: group json | [
"Get",
"group",
"data",
"based",
"on",
"uuid",
"."
] | train | https://github.com/mitodl/PyLmod/blob/b798b86c33d1eb615e7cd4f3457b5c15da1d86e0/pylmod/membership.py#L32-L49 |
mitodl/PyLmod | pylmod/membership.py | Membership.get_group_id | def get_group_id(self, uuid=None):
"""Get group id based on uuid.
Args:
uuid (str): optional uuid. defaults to self.cuuid
Raises:
PyLmodUnexpectedData: No group data was returned.
requests.RequestException: Exception connection error
Returns:
... | python | def get_group_id(self, uuid=None):
"""Get group id based on uuid.
Args:
uuid (str): optional uuid. defaults to self.cuuid
Raises:
PyLmodUnexpectedData: No group data was returned.
requests.RequestException: Exception connection error
Returns:
... | [
"def",
"get_group_id",
"(",
"self",
",",
"uuid",
"=",
"None",
")",
":",
"group_data",
"=",
"self",
".",
"get_group",
"(",
"uuid",
")",
"try",
":",
"return",
"group_data",
"[",
"'response'",
"]",
"[",
"'docs'",
"]",
"[",
"0",
"]",
"[",
"'id'",
"]",
... | Get group id based on uuid.
Args:
uuid (str): optional uuid. defaults to self.cuuid
Raises:
PyLmodUnexpectedData: No group data was returned.
requests.RequestException: Exception connection error
Returns:
int: numeric group id | [
"Get",
"group",
"id",
"based",
"on",
"uuid",
"."
] | train | https://github.com/mitodl/PyLmod/blob/b798b86c33d1eb615e7cd4f3457b5c15da1d86e0/pylmod/membership.py#L51-L72 |
mitodl/PyLmod | pylmod/membership.py | Membership.get_membership | def get_membership(self, uuid=None):
"""Get membership data based on uuid.
Args:
uuid (str): optional uuid. defaults to self.cuuid
Raises:
PyLmodUnexpectedData: No data was returned.
requests.RequestException: Exception connection error
Returns:
... | python | def get_membership(self, uuid=None):
"""Get membership data based on uuid.
Args:
uuid (str): optional uuid. defaults to self.cuuid
Raises:
PyLmodUnexpectedData: No data was returned.
requests.RequestException: Exception connection error
Returns:
... | [
"def",
"get_membership",
"(",
"self",
",",
"uuid",
"=",
"None",
")",
":",
"group_id",
"=",
"self",
".",
"get_group_id",
"(",
"uuid",
"=",
"uuid",
")",
"uri",
"=",
"'group/{group_id}/member'",
"mbr_data",
"=",
"self",
".",
"get",
"(",
"uri",
".",
"format"... | Get membership data based on uuid.
Args:
uuid (str): optional uuid. defaults to self.cuuid
Raises:
PyLmodUnexpectedData: No data was returned.
requests.RequestException: Exception connection error
Returns:
dict: membership json | [
"Get",
"membership",
"data",
"based",
"on",
"uuid",
"."
] | train | https://github.com/mitodl/PyLmod/blob/b798b86c33d1eb615e7cd4f3457b5c15da1d86e0/pylmod/membership.py#L74-L91 |
mitodl/PyLmod | pylmod/membership.py | Membership.email_has_role | def email_has_role(self, email, role_name, uuid=None):
"""Determine if an email is associated with a role.
Args:
email (str): user email
role_name (str): user role
uuid (str): optional uuid. defaults to self.cuuid
Raises:
PyLmodUnexpectedData: Un... | python | def email_has_role(self, email, role_name, uuid=None):
"""Determine if an email is associated with a role.
Args:
email (str): user email
role_name (str): user role
uuid (str): optional uuid. defaults to self.cuuid
Raises:
PyLmodUnexpectedData: Un... | [
"def",
"email_has_role",
"(",
"self",
",",
"email",
",",
"role_name",
",",
"uuid",
"=",
"None",
")",
":",
"mbr_data",
"=",
"self",
".",
"get_membership",
"(",
"uuid",
"=",
"uuid",
")",
"docs",
"=",
"[",
"]",
"try",
":",
"docs",
"=",
"mbr_data",
"[",
... | Determine if an email is associated with a role.
Args:
email (str): user email
role_name (str): user role
uuid (str): optional uuid. defaults to self.cuuid
Raises:
PyLmodUnexpectedData: Unexpected data was returned.
requests.RequestException:... | [
"Determine",
"if",
"an",
"email",
"is",
"associated",
"with",
"a",
"role",
"."
] | train | https://github.com/mitodl/PyLmod/blob/b798b86c33d1eb615e7cd4f3457b5c15da1d86e0/pylmod/membership.py#L93-L126 |
mitodl/PyLmod | pylmod/membership.py | Membership.get_course_id | def get_course_id(self, course_uuid):
"""Get course id based on uuid.
Args:
uuid (str): course uuid, i.e. /project/mitxdemosite
Raises:
PyLmodUnexpectedData: No course data was returned.
requests.RequestException: Exception connection error
Returns:... | python | def get_course_id(self, course_uuid):
"""Get course id based on uuid.
Args:
uuid (str): course uuid, i.e. /project/mitxdemosite
Raises:
PyLmodUnexpectedData: No course data was returned.
requests.RequestException: Exception connection error
Returns:... | [
"def",
"get_course_id",
"(",
"self",
",",
"course_uuid",
")",
":",
"course_data",
"=",
"self",
".",
"get",
"(",
"'courseguide/course?uuid={uuid}'",
".",
"format",
"(",
"uuid",
"=",
"course_uuid",
"or",
"self",
".",
"course_id",
")",
",",
"params",
"=",
"None... | Get course id based on uuid.
Args:
uuid (str): course uuid, i.e. /project/mitxdemosite
Raises:
PyLmodUnexpectedData: No course data was returned.
requests.RequestException: Exception connection error
Returns:
int: numeric course id | [
"Get",
"course",
"id",
"based",
"on",
"uuid",
"."
] | train | https://github.com/mitodl/PyLmod/blob/b798b86c33d1eb615e7cd4f3457b5c15da1d86e0/pylmod/membership.py#L128-L159 |
mitodl/PyLmod | pylmod/membership.py | Membership.get_course_guide_staff | def get_course_guide_staff(self, course_id=''):
"""Get the staff roster for a course.
Get a list of staff members for a given course,
specified by a course id.
Args:
course_id (int): unique identifier for course, i.e. ``2314``
Raises:
requests.RequestEx... | python | def get_course_guide_staff(self, course_id=''):
"""Get the staff roster for a course.
Get a list of staff members for a given course,
specified by a course id.
Args:
course_id (int): unique identifier for course, i.e. ``2314``
Raises:
requests.RequestEx... | [
"def",
"get_course_guide_staff",
"(",
"self",
",",
"course_id",
"=",
"''",
")",
":",
"staff_data",
"=",
"self",
".",
"get",
"(",
"'courseguide/course/{courseId}/staff'",
".",
"format",
"(",
"courseId",
"=",
"course_id",
"or",
"self",
".",
"course_id",
")",
","... | Get the staff roster for a course.
Get a list of staff members for a given course,
specified by a course id.
Args:
course_id (int): unique identifier for course, i.e. ``2314``
Raises:
requests.RequestException: Exception connection error
ValueError:... | [
"Get",
"the",
"staff",
"roster",
"for",
"a",
"course",
"."
] | train | https://github.com/mitodl/PyLmod/blob/b798b86c33d1eb615e7cd4f3457b5c15da1d86e0/pylmod/membership.py#L161-L210 |
mitodl/PyLmod | pylmod/base.py | Base._data_to_json | def _data_to_json(data):
"""Convert to json if it isn't already a string.
Args:
data (str): data to convert to json
"""
if type(data) not in [str, unicode]:
data = json.dumps(data)
return data | python | def _data_to_json(data):
"""Convert to json if it isn't already a string.
Args:
data (str): data to convert to json
"""
if type(data) not in [str, unicode]:
data = json.dumps(data)
return data | [
"def",
"_data_to_json",
"(",
"data",
")",
":",
"if",
"type",
"(",
"data",
")",
"not",
"in",
"[",
"str",
",",
"unicode",
"]",
":",
"data",
"=",
"json",
".",
"dumps",
"(",
"data",
")",
"return",
"data"
] | Convert to json if it isn't already a string.
Args:
data (str): data to convert to json | [
"Convert",
"to",
"json",
"if",
"it",
"isn",
"t",
"already",
"a",
"string",
"."
] | train | https://github.com/mitodl/PyLmod/blob/b798b86c33d1eb615e7cd4f3457b5c15da1d86e0/pylmod/base.py#L69-L77 |
mitodl/PyLmod | pylmod/base.py | Base._url_format | def _url_format(self, service):
"""Generate URL from urlbase and service.
Args:
service (str): The endpoint service to use, i.e. gradebook
Returns:
str: URL to where the request should be made
"""
base_service_url = '{base}{service}'.format(
b... | python | def _url_format(self, service):
"""Generate URL from urlbase and service.
Args:
service (str): The endpoint service to use, i.e. gradebook
Returns:
str: URL to where the request should be made
"""
base_service_url = '{base}{service}'.format(
b... | [
"def",
"_url_format",
"(",
"self",
",",
"service",
")",
":",
"base_service_url",
"=",
"'{base}{service}'",
".",
"format",
"(",
"base",
"=",
"self",
".",
"urlbase",
",",
"service",
"=",
"service",
")",
"return",
"base_service_url"
] | Generate URL from urlbase and service.
Args:
service (str): The endpoint service to use, i.e. gradebook
Returns:
str: URL to where the request should be made | [
"Generate",
"URL",
"from",
"urlbase",
"and",
"service",
"."
] | train | https://github.com/mitodl/PyLmod/blob/b798b86c33d1eb615e7cd4f3457b5c15da1d86e0/pylmod/base.py#L79-L91 |
mitodl/PyLmod | pylmod/base.py | Base.rest_action | def rest_action(self, func, url, **kwargs):
"""Routine to do low-level REST operation, with retry.
Args:
func (callable): API function to call
url (str): service URL endpoint
kwargs (dict): addition parameters
Raises:
requests.RequestException: E... | python | def rest_action(self, func, url, **kwargs):
"""Routine to do low-level REST operation, with retry.
Args:
func (callable): API function to call
url (str): service URL endpoint
kwargs (dict): addition parameters
Raises:
requests.RequestException: E... | [
"def",
"rest_action",
"(",
"self",
",",
"func",
",",
"url",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"response",
"=",
"func",
"(",
"url",
",",
"timeout",
"=",
"self",
".",
"TIMEOUT",
",",
"*",
"*",
"kwargs",
")",
"except",
"requests",
".",
... | Routine to do low-level REST operation, with retry.
Args:
func (callable): API function to call
url (str): service URL endpoint
kwargs (dict): addition parameters
Raises:
requests.RequestException: Exception connection error
ValueError: Unabl... | [
"Routine",
"to",
"do",
"low",
"-",
"level",
"REST",
"operation",
"with",
"retry",
"."
] | train | https://github.com/mitodl/PyLmod/blob/b798b86c33d1eb615e7cd4f3457b5c15da1d86e0/pylmod/base.py#L93-L120 |
mitodl/PyLmod | pylmod/base.py | Base.get | def get(self, service, params=None):
"""Generic GET operation for retrieving data from Learning Modules API.
.. code-block:: python
gbk.get('students/{gradebookId}', params=params, gradebookId=gbid)
Args:
service (str): The endpoint service to use, i.e. gradebook
... | python | def get(self, service, params=None):
"""Generic GET operation for retrieving data from Learning Modules API.
.. code-block:: python
gbk.get('students/{gradebookId}', params=params, gradebookId=gbid)
Args:
service (str): The endpoint service to use, i.e. gradebook
... | [
"def",
"get",
"(",
"self",
",",
"service",
",",
"params",
"=",
"None",
")",
":",
"url",
"=",
"self",
".",
"_url_format",
"(",
"service",
")",
"if",
"params",
"is",
"None",
":",
"params",
"=",
"{",
"}",
"return",
"self",
".",
"rest_action",
"(",
"se... | Generic GET operation for retrieving data from Learning Modules API.
.. code-block:: python
gbk.get('students/{gradebookId}', params=params, gradebookId=gbid)
Args:
service (str): The endpoint service to use, i.e. gradebook
params (dict): additional parameters to a... | [
"Generic",
"GET",
"operation",
"for",
"retrieving",
"data",
"from",
"Learning",
"Modules",
"API",
"."
] | train | https://github.com/mitodl/PyLmod/blob/b798b86c33d1eb615e7cd4f3457b5c15da1d86e0/pylmod/base.py#L122-L143 |
mitodl/PyLmod | pylmod/base.py | Base.post | def post(self, service, data):
"""Generic POST operation for sending data to Learning Modules API.
Data should be a JSON string or a dict. If it is not a string,
it is turned into a JSON string for the POST body.
Args:
service (str): The endpoint service to use, i.e. grade... | python | def post(self, service, data):
"""Generic POST operation for sending data to Learning Modules API.
Data should be a JSON string or a dict. If it is not a string,
it is turned into a JSON string for the POST body.
Args:
service (str): The endpoint service to use, i.e. grade... | [
"def",
"post",
"(",
"self",
",",
"service",
",",
"data",
")",
":",
"url",
"=",
"self",
".",
"_url_format",
"(",
"service",
")",
"data",
"=",
"Base",
".",
"_data_to_json",
"(",
"data",
")",
"# Add content-type for body in POST.",
"headers",
"=",
"{",
"'cont... | Generic POST operation for sending data to Learning Modules API.
Data should be a JSON string or a dict. If it is not a string,
it is turned into a JSON string for the POST body.
Args:
service (str): The endpoint service to use, i.e. gradebook
data (json or dict): the ... | [
"Generic",
"POST",
"operation",
"for",
"sending",
"data",
"to",
"Learning",
"Modules",
"API",
"."
] | train | https://github.com/mitodl/PyLmod/blob/b798b86c33d1eb615e7cd4f3457b5c15da1d86e0/pylmod/base.py#L145-L167 |
mitodl/PyLmod | pylmod/base.py | Base.delete | def delete(self, service):
"""Generic DELETE operation for Learning Modules API.
Args:
service (str): The endpoint service to use, i.e. gradebook
Raises:
requests.RequestException: Exception connection error
ValueError: Unable to decode response content
... | python | def delete(self, service):
"""Generic DELETE operation for Learning Modules API.
Args:
service (str): The endpoint service to use, i.e. gradebook
Raises:
requests.RequestException: Exception connection error
ValueError: Unable to decode response content
... | [
"def",
"delete",
"(",
"self",
",",
"service",
")",
":",
"url",
"=",
"self",
".",
"_url_format",
"(",
"service",
")",
"return",
"self",
".",
"rest_action",
"(",
"self",
".",
"_session",
".",
"delete",
",",
"url",
")"
] | Generic DELETE operation for Learning Modules API.
Args:
service (str): The endpoint service to use, i.e. gradebook
Raises:
requests.RequestException: Exception connection error
ValueError: Unable to decode response content
Returns:
list: the js... | [
"Generic",
"DELETE",
"operation",
"for",
"Learning",
"Modules",
"API",
"."
] | train | https://github.com/mitodl/PyLmod/blob/b798b86c33d1eb615e7cd4f3457b5c15da1d86e0/pylmod/base.py#L169-L185 |
googlearchive/firebase-token-generator-python | firebase_token_generator.py | create_token | def create_token(secret, data, options=None):
"""
Generates a secure authentication token.
Our token format follows the JSON Web Token (JWT) standard:
header.claims.signature
Where:
1) "header" is a stringified, base64-encoded JSON object containing version and algorithm information.
2)... | python | def create_token(secret, data, options=None):
"""
Generates a secure authentication token.
Our token format follows the JSON Web Token (JWT) standard:
header.claims.signature
Where:
1) "header" is a stringified, base64-encoded JSON object containing version and algorithm information.
2)... | [
"def",
"create_token",
"(",
"secret",
",",
"data",
",",
"options",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"secret",
",",
"basestring",
")",
":",
"raise",
"ValueError",
"(",
"\"firebase_token_generator.create_token: secret must be a string.\"",
")",
... | Generates a secure authentication token.
Our token format follows the JSON Web Token (JWT) standard:
header.claims.signature
Where:
1) "header" is a stringified, base64-encoded JSON object containing version and algorithm information.
2) "claims" is a stringified, base64-encoded JSON object con... | [
"Generates",
"a",
"secure",
"authentication",
"token",
".",
"Our",
"token",
"format",
"follows",
"the",
"JSON",
"Web",
"Token",
"(",
"JWT",
")",
"standard",
":",
"header",
".",
"claims",
".",
"signature",
"Where",
":",
"1",
")",
"header",
"is",
"a",
"str... | train | https://github.com/googlearchive/firebase-token-generator-python/blob/cb8a67d25f4a464cd4f37f076046d17912621c09/firebase_token_generator.py#L31-L90 |
datalib/libextract | libextract/core.py | parse_html | def parse_html(fileobj, encoding):
"""
Given a file object *fileobj*, get an ElementTree instance.
The *encoding* is assumed to be utf8.
"""
parser = HTMLParser(encoding=encoding, remove_blank_text=True)
return parse(fileobj, parser) | python | def parse_html(fileobj, encoding):
"""
Given a file object *fileobj*, get an ElementTree instance.
The *encoding* is assumed to be utf8.
"""
parser = HTMLParser(encoding=encoding, remove_blank_text=True)
return parse(fileobj, parser) | [
"def",
"parse_html",
"(",
"fileobj",
",",
"encoding",
")",
":",
"parser",
"=",
"HTMLParser",
"(",
"encoding",
"=",
"encoding",
",",
"remove_blank_text",
"=",
"True",
")",
"return",
"parse",
"(",
"fileobj",
",",
"parser",
")"
] | Given a file object *fileobj*, get an ElementTree instance.
The *encoding* is assumed to be utf8. | [
"Given",
"a",
"file",
"object",
"*",
"fileobj",
"*",
"get",
"an",
"ElementTree",
"instance",
".",
"The",
"*",
"encoding",
"*",
"is",
"assumed",
"to",
"be",
"utf8",
"."
] | train | https://github.com/datalib/libextract/blob/9cf9d55c7f8cd622eab0a50f009385f0a39b1200/libextract/core.py#L20-L26 |
biocommons/biocommons.seqrepo | biocommons/seqrepo/fastadir/fastadir.py | FastaDir.fetch | def fetch(self, seq_id, start=None, end=None):
"""fetch sequence by seq_id, optionally with start, end bounds
"""
rec = self._db.execute("""select * from seqinfo where seq_id = ? order by added desc""", [seq_id]).fetchone()
if rec is None:
raise KeyError(seq_id)
if... | python | def fetch(self, seq_id, start=None, end=None):
"""fetch sequence by seq_id, optionally with start, end bounds
"""
rec = self._db.execute("""select * from seqinfo where seq_id = ? order by added desc""", [seq_id]).fetchone()
if rec is None:
raise KeyError(seq_id)
if... | [
"def",
"fetch",
"(",
"self",
",",
"seq_id",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
")",
":",
"rec",
"=",
"self",
".",
"_db",
".",
"execute",
"(",
"\"\"\"select * from seqinfo where seq_id = ? order by added desc\"\"\"",
",",
"[",
"seq_id",
"]",
... | fetch sequence by seq_id, optionally with start, end bounds | [
"fetch",
"sequence",
"by",
"seq_id",
"optionally",
"with",
"start",
"end",
"bounds"
] | train | https://github.com/biocommons/biocommons.seqrepo/blob/fb6d88682cb73ee6971cfa47d4dcd90a9c649167/biocommons/seqrepo/fastadir/fastadir.py#L102-L118 |
biocommons/biocommons.seqrepo | biocommons/seqrepo/fastadir/fastadir.py | FastaDir.store | def store(self, seq_id, seq):
"""store a sequence with key seq_id. The sequence itself is stored in
a fasta file and a reference to it in the sqlite3 database.
"""
if not self._writeable:
raise RuntimeError("Cannot write -- opened read-only")
# open a file for wri... | python | def store(self, seq_id, seq):
"""store a sequence with key seq_id. The sequence itself is stored in
a fasta file and a reference to it in the sqlite3 database.
"""
if not self._writeable:
raise RuntimeError("Cannot write -- opened read-only")
# open a file for wri... | [
"def",
"store",
"(",
"self",
",",
"seq_id",
",",
"seq",
")",
":",
"if",
"not",
"self",
".",
"_writeable",
":",
"raise",
"RuntimeError",
"(",
"\"Cannot write -- opened read-only\"",
")",
"# open a file for writing if necessary",
"# path: <root_dir>/<reldir>/<basename>",
... | store a sequence with key seq_id. The sequence itself is stored in
a fasta file and a reference to it in the sqlite3 database. | [
"store",
"a",
"sequence",
"with",
"key",
"seq_id",
".",
"The",
"sequence",
"itself",
"is",
"stored",
"in",
"a",
"fasta",
"file",
"and",
"a",
"reference",
"to",
"it",
"in",
"the",
"sqlite3",
"database",
"."
] | train | https://github.com/biocommons/biocommons.seqrepo/blob/fb6d88682cb73ee6971cfa47d4dcd90a9c649167/biocommons/seqrepo/fastadir/fastadir.py#L135-L165 |
jmcarp/sqlalchemy-postgres-copy | postgres_copy/__init__.py | copy_to | def copy_to(source, dest, engine_or_conn, **flags):
"""Export a query or select to a file. For flags, see the PostgreSQL
documentation at http://www.postgresql.org/docs/9.5/static/sql-copy.html.
Examples: ::
select = MyTable.select()
with open('/path/to/file.tsv', 'w') as fp:
co... | python | def copy_to(source, dest, engine_or_conn, **flags):
"""Export a query or select to a file. For flags, see the PostgreSQL
documentation at http://www.postgresql.org/docs/9.5/static/sql-copy.html.
Examples: ::
select = MyTable.select()
with open('/path/to/file.tsv', 'w') as fp:
co... | [
"def",
"copy_to",
"(",
"source",
",",
"dest",
",",
"engine_or_conn",
",",
"*",
"*",
"flags",
")",
":",
"dialect",
"=",
"postgresql",
".",
"dialect",
"(",
")",
"statement",
"=",
"getattr",
"(",
"source",
",",
"'statement'",
",",
"source",
")",
"compiled",... | Export a query or select to a file. For flags, see the PostgreSQL
documentation at http://www.postgresql.org/docs/9.5/static/sql-copy.html.
Examples: ::
select = MyTable.select()
with open('/path/to/file.tsv', 'w') as fp:
copy_to(select, fp, conn)
query = session.query(MyMo... | [
"Export",
"a",
"query",
"or",
"select",
"to",
"a",
"file",
".",
"For",
"flags",
"see",
"the",
"PostgreSQL",
"documentation",
"at",
"http",
":",
"//",
"www",
".",
"postgresql",
".",
"org",
"/",
"docs",
"/",
"9",
".",
"5",
"/",
"static",
"/",
"sql",
... | train | https://github.com/jmcarp/sqlalchemy-postgres-copy/blob/01ef522e8e46a6961e227069d465b0cb93e42383/postgres_copy/__init__.py#L10-L41 |
jmcarp/sqlalchemy-postgres-copy | postgres_copy/__init__.py | copy_from | def copy_from(source, dest, engine_or_conn, columns=(), **flags):
"""Import a table from a file. For flags, see the PostgreSQL documentation
at http://www.postgresql.org/docs/9.5/static/sql-copy.html.
Examples: ::
with open('/path/to/file.tsv') as fp:
copy_from(fp, MyTable, conn)
... | python | def copy_from(source, dest, engine_or_conn, columns=(), **flags):
"""Import a table from a file. For flags, see the PostgreSQL documentation
at http://www.postgresql.org/docs/9.5/static/sql-copy.html.
Examples: ::
with open('/path/to/file.tsv') as fp:
copy_from(fp, MyTable, conn)
... | [
"def",
"copy_from",
"(",
"source",
",",
"dest",
",",
"engine_or_conn",
",",
"columns",
"=",
"(",
")",
",",
"*",
"*",
"flags",
")",
":",
"tbl",
"=",
"dest",
".",
"__table__",
"if",
"is_model",
"(",
"dest",
")",
"else",
"dest",
"conn",
",",
"autoclose"... | Import a table from a file. For flags, see the PostgreSQL documentation
at http://www.postgresql.org/docs/9.5/static/sql-copy.html.
Examples: ::
with open('/path/to/file.tsv') as fp:
copy_from(fp, MyTable, conn)
with open('/path/to/file.csv') as fp:
copy_from(fp, MyMode... | [
"Import",
"a",
"table",
"from",
"a",
"file",
".",
"For",
"flags",
"see",
"the",
"PostgreSQL",
"documentation",
"at",
"http",
":",
"//",
"www",
".",
"postgresql",
".",
"org",
"/",
"docs",
"/",
"9",
".",
"5",
"/",
"static",
"/",
"sql",
"-",
"copy",
"... | train | https://github.com/jmcarp/sqlalchemy-postgres-copy/blob/01ef522e8e46a6961e227069d465b0cb93e42383/postgres_copy/__init__.py#L43-L81 |
jmcarp/sqlalchemy-postgres-copy | postgres_copy/__init__.py | raw_connection_from | def raw_connection_from(engine_or_conn):
"""Extract a raw_connection and determine if it should be automatically closed.
Only connections opened by this package will be closed automatically.
"""
if hasattr(engine_or_conn, 'cursor'):
return engine_or_conn, False
if hasattr(engine_or_conn, 'c... | python | def raw_connection_from(engine_or_conn):
"""Extract a raw_connection and determine if it should be automatically closed.
Only connections opened by this package will be closed automatically.
"""
if hasattr(engine_or_conn, 'cursor'):
return engine_or_conn, False
if hasattr(engine_or_conn, 'c... | [
"def",
"raw_connection_from",
"(",
"engine_or_conn",
")",
":",
"if",
"hasattr",
"(",
"engine_or_conn",
",",
"'cursor'",
")",
":",
"return",
"engine_or_conn",
",",
"False",
"if",
"hasattr",
"(",
"engine_or_conn",
",",
"'connection'",
")",
":",
"return",
"engine_o... | Extract a raw_connection and determine if it should be automatically closed.
Only connections opened by this package will be closed automatically. | [
"Extract",
"a",
"raw_connection",
"and",
"determine",
"if",
"it",
"should",
"be",
"automatically",
"closed",
"."
] | train | https://github.com/jmcarp/sqlalchemy-postgres-copy/blob/01ef522e8e46a6961e227069d465b0cb93e42383/postgres_copy/__init__.py#L83-L92 |
biocommons/biocommons.seqrepo | biocommons/seqrepo/py2compat/_makedirs.py | makedirs | def makedirs(name, mode=0o777, exist_ok=False):
"""cheapo replacement for py3 makedirs with support for exist_ok
"""
if os.path.exists(name):
if not exist_ok:
raise FileExistsError("File exists: " + name)
else:
os.makedirs(name, mode) | python | def makedirs(name, mode=0o777, exist_ok=False):
"""cheapo replacement for py3 makedirs with support for exist_ok
"""
if os.path.exists(name):
if not exist_ok:
raise FileExistsError("File exists: " + name)
else:
os.makedirs(name, mode) | [
"def",
"makedirs",
"(",
"name",
",",
"mode",
"=",
"0o777",
",",
"exist_ok",
"=",
"False",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"name",
")",
":",
"if",
"not",
"exist_ok",
":",
"raise",
"FileExistsError",
"(",
"\"File exists: \"",
"+",
... | cheapo replacement for py3 makedirs with support for exist_ok | [
"cheapo",
"replacement",
"for",
"py3",
"makedirs",
"with",
"support",
"for",
"exist_ok"
] | train | https://github.com/biocommons/biocommons.seqrepo/blob/fb6d88682cb73ee6971cfa47d4dcd90a9c649167/biocommons/seqrepo/py2compat/_makedirs.py#L10-L19 |
biocommons/biocommons.seqrepo | misc/threading-verification.py | fetch_in_thread | def fetch_in_thread(sr, nsa):
"""fetch a sequence in a thread
"""
def fetch_seq(q, nsa):
pid, ppid = os.getpid(), os.getppid()
q.put((pid, ppid, sr[nsa]))
q = Queue()
p = Process(target=fetch_seq, args=(q, nsa))
p.start()
pid, ppid, seq = q.get()
p.join()
asse... | python | def fetch_in_thread(sr, nsa):
"""fetch a sequence in a thread
"""
def fetch_seq(q, nsa):
pid, ppid = os.getpid(), os.getppid()
q.put((pid, ppid, sr[nsa]))
q = Queue()
p = Process(target=fetch_seq, args=(q, nsa))
p.start()
pid, ppid, seq = q.get()
p.join()
asse... | [
"def",
"fetch_in_thread",
"(",
"sr",
",",
"nsa",
")",
":",
"def",
"fetch_seq",
"(",
"q",
",",
"nsa",
")",
":",
"pid",
",",
"ppid",
"=",
"os",
".",
"getpid",
"(",
")",
",",
"os",
".",
"getppid",
"(",
")",
"q",
".",
"put",
"(",
"(",
"pid",
",",... | fetch a sequence in a thread | [
"fetch",
"a",
"sequence",
"in",
"a",
"thread"
] | train | https://github.com/biocommons/biocommons.seqrepo/blob/fb6d88682cb73ee6971cfa47d4dcd90a9c649167/misc/threading-verification.py#L32-L48 |
junaruga/rpm-py-installer | install.py | Application.run | def run(self):
"""Run install process."""
try:
self.linux.verify_system_status()
except InstallSkipError:
Log.info('Install skipped.')
return
work_dir = tempfile.mkdtemp(suffix='-rpm-py-installer')
Log.info("Created working directory '{0}'".fo... | python | def run(self):
"""Run install process."""
try:
self.linux.verify_system_status()
except InstallSkipError:
Log.info('Install skipped.')
return
work_dir = tempfile.mkdtemp(suffix='-rpm-py-installer')
Log.info("Created working directory '{0}'".fo... | [
"def",
"run",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"linux",
".",
"verify_system_status",
"(",
")",
"except",
"InstallSkipError",
":",
"Log",
".",
"info",
"(",
"'Install skipped.'",
")",
"return",
"work_dir",
"=",
"tempfile",
".",
"mkdtemp",
"(",... | Run install process. | [
"Run",
"install",
"process",
"."
] | train | https://github.com/junaruga/rpm-py-installer/blob/12f45feb0ba533dec8d0d16ef1e9b7fb8cfbd4ed/install.py#L28-L54 |
junaruga/rpm-py-installer | install.py | RpmPy.download_and_install | def download_and_install(self):
"""Download and install RPM Python binding."""
if self.is_installed_from_bin:
try:
self.installer.install_from_rpm_py_package()
return
except RpmPyPackageNotFoundError as e:
Log.warn('RPM Py Package n... | python | def download_and_install(self):
"""Download and install RPM Python binding."""
if self.is_installed_from_bin:
try:
self.installer.install_from_rpm_py_package()
return
except RpmPyPackageNotFoundError as e:
Log.warn('RPM Py Package n... | [
"def",
"download_and_install",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_installed_from_bin",
":",
"try",
":",
"self",
".",
"installer",
".",
"install_from_rpm_py_package",
"(",
")",
"return",
"except",
"RpmPyPackageNotFoundError",
"as",
"e",
":",
"Log",
"."... | Download and install RPM Python binding. | [
"Download",
"and",
"install",
"RPM",
"Python",
"binding",
"."
] | train | https://github.com/junaruga/rpm-py-installer/blob/12f45feb0ba533dec8d0d16ef1e9b7fb8cfbd4ed/install.py#L161-L184 |
junaruga/rpm-py-installer | install.py | RpmPyVersion.git_branch | def git_branch(self):
"""Git branch name."""
info = self.info
return 'rpm-{major}.{minor}.x'.format(
major=info[0], minor=info[1]) | python | def git_branch(self):
"""Git branch name."""
info = self.info
return 'rpm-{major}.{minor}.x'.format(
major=info[0], minor=info[1]) | [
"def",
"git_branch",
"(",
"self",
")",
":",
"info",
"=",
"self",
".",
"info",
"return",
"'rpm-{major}.{minor}.x'",
".",
"format",
"(",
"major",
"=",
"info",
"[",
"0",
"]",
",",
"minor",
"=",
"info",
"[",
"1",
"]",
")"
] | Git branch name. | [
"Git",
"branch",
"name",
"."
] | train | https://github.com/junaruga/rpm-py-installer/blob/12f45feb0ba533dec8d0d16ef1e9b7fb8cfbd4ed/install.py#L215-L219 |
junaruga/rpm-py-installer | install.py | SetupPy.add_patchs_to_build_without_pkg_config | def add_patchs_to_build_without_pkg_config(self, lib_dir, include_dir):
"""Add patches to remove pkg-config command and rpm.pc part.
Replace with given library_path: lib_dir and include_path: include_dir
without rpm.pc file.
"""
additional_patches = [
{
... | python | def add_patchs_to_build_without_pkg_config(self, lib_dir, include_dir):
"""Add patches to remove pkg-config command and rpm.pc part.
Replace with given library_path: lib_dir and include_path: include_dir
without rpm.pc file.
"""
additional_patches = [
{
... | [
"def",
"add_patchs_to_build_without_pkg_config",
"(",
"self",
",",
"lib_dir",
",",
"include_dir",
")",
":",
"additional_patches",
"=",
"[",
"{",
"'src'",
":",
"r\"pkgconfig\\('--libs-only-L'\\)\"",
",",
"'dest'",
":",
"\"['{0}']\"",
".",
"format",
"(",
"lib_dir",
")... | Add patches to remove pkg-config command and rpm.pc part.
Replace with given library_path: lib_dir and include_path: include_dir
without rpm.pc file. | [
"Add",
"patches",
"to",
"remove",
"pkg",
"-",
"config",
"command",
"and",
"rpm",
".",
"pc",
"part",
"."
] | train | https://github.com/junaruga/rpm-py-installer/blob/12f45feb0ba533dec8d0d16ef1e9b7fb8cfbd4ed/install.py#L323-L347 |
junaruga/rpm-py-installer | install.py | SetupPy.apply_and_save | def apply_and_save(self):
"""Apply replaced words and patches, and save setup.py file."""
patches = self.patches
content = None
with open(self.IN_PATH) as f_in:
# As setup.py.in file size is 2.4 KByte.
# it's fine to read entire content.
content = f_i... | python | def apply_and_save(self):
"""Apply replaced words and patches, and save setup.py file."""
patches = self.patches
content = None
with open(self.IN_PATH) as f_in:
# As setup.py.in file size is 2.4 KByte.
# it's fine to read entire content.
content = f_i... | [
"def",
"apply_and_save",
"(",
"self",
")",
":",
"patches",
"=",
"self",
".",
"patches",
"content",
"=",
"None",
"with",
"open",
"(",
"self",
".",
"IN_PATH",
")",
"as",
"f_in",
":",
"# As setup.py.in file size is 2.4 KByte.",
"# it's fine to read entire content.",
... | Apply replaced words and patches, and save setup.py file. | [
"Apply",
"replaced",
"words",
"and",
"patches",
"and",
"save",
"setup",
".",
"py",
"file",
"."
] | train | https://github.com/junaruga/rpm-py-installer/blob/12f45feb0ba533dec8d0d16ef1e9b7fb8cfbd4ed/install.py#L349-L382 |
junaruga/rpm-py-installer | install.py | Downloader.download_and_expand | def download_and_expand(self):
"""Download and expand RPM Python binding."""
top_dir_name = None
if self.git_branch:
# Download a source by git clone.
top_dir_name = self._download_and_expand_by_git()
else:
# Download a source from the arcihve URL.
... | python | def download_and_expand(self):
"""Download and expand RPM Python binding."""
top_dir_name = None
if self.git_branch:
# Download a source by git clone.
top_dir_name = self._download_and_expand_by_git()
else:
# Download a source from the arcihve URL.
... | [
"def",
"download_and_expand",
"(",
"self",
")",
":",
"top_dir_name",
"=",
"None",
"if",
"self",
".",
"git_branch",
":",
"# Download a source by git clone.",
"top_dir_name",
"=",
"self",
".",
"_download_and_expand_by_git",
"(",
")",
"else",
":",
"# Download a source fr... | Download and expand RPM Python binding. | [
"Download",
"and",
"expand",
"RPM",
"Python",
"binding",
"."
] | train | https://github.com/junaruga/rpm-py-installer/blob/12f45feb0ba533dec8d0d16ef1e9b7fb8cfbd4ed/install.py#L412-L428 |
junaruga/rpm-py-installer | install.py | Installer.run | def run(self):
"""Run install main logic."""
self._make_lib_file_symbolic_links()
self._copy_each_include_files_to_include_dir()
self._make_dep_lib_file_sym_links_and_copy_include_files()
self.setup_py.add_patchs_to_build_without_pkg_config(
self.rpm.lib_dir, self.rpm... | python | def run(self):
"""Run install main logic."""
self._make_lib_file_symbolic_links()
self._copy_each_include_files_to_include_dir()
self._make_dep_lib_file_sym_links_and_copy_include_files()
self.setup_py.add_patchs_to_build_without_pkg_config(
self.rpm.lib_dir, self.rpm... | [
"def",
"run",
"(",
"self",
")",
":",
"self",
".",
"_make_lib_file_symbolic_links",
"(",
")",
"self",
".",
"_copy_each_include_files_to_include_dir",
"(",
")",
"self",
".",
"_make_dep_lib_file_sym_links_and_copy_include_files",
"(",
")",
"self",
".",
"setup_py",
".",
... | Run install main logic. | [
"Run",
"install",
"main",
"logic",
"."
] | train | https://github.com/junaruga/rpm-py-installer/blob/12f45feb0ba533dec8d0d16ef1e9b7fb8cfbd4ed/install.py#L610-L619 |
junaruga/rpm-py-installer | install.py | Installer._make_lib_file_symbolic_links | def _make_lib_file_symbolic_links(self):
"""Make symbolic links for lib files.
Make symbolic links from system library files or downloaded lib files
to downloaded source library files.
For example, case: Fedora x86_64
Make symbolic links
from
a. /usr/lib64/l... | python | def _make_lib_file_symbolic_links(self):
"""Make symbolic links for lib files.
Make symbolic links from system library files or downloaded lib files
to downloaded source library files.
For example, case: Fedora x86_64
Make symbolic links
from
a. /usr/lib64/l... | [
"def",
"_make_lib_file_symbolic_links",
"(",
"self",
")",
":",
"so_file_dict",
"=",
"{",
"'rpmio'",
":",
"{",
"'sym_src_dir'",
":",
"self",
".",
"rpm",
".",
"lib_dir",
",",
"'sym_dst_dir'",
":",
"'rpmio/.libs'",
",",
"'require'",
":",
"True",
",",
"}",
",",
... | Make symbolic links for lib files.
Make symbolic links from system library files or downloaded lib files
to downloaded source library files.
For example, case: Fedora x86_64
Make symbolic links
from
a. /usr/lib64/librpmio.so* (one of them)
b. /usr/lib64/... | [
"Make",
"symbolic",
"links",
"for",
"lib",
"files",
"."
] | train | https://github.com/junaruga/rpm-py-installer/blob/12f45feb0ba533dec8d0d16ef1e9b7fb8cfbd4ed/install.py#L629-L706 |
junaruga/rpm-py-installer | install.py | Installer._copy_each_include_files_to_include_dir | def _copy_each_include_files_to_include_dir(self):
"""Copy include header files for each directory to include directory.
Copy include header files
from
rpm/
rpmio/*.h
lib/*.h
build/*.h
sign/*.h
to
rp... | python | def _copy_each_include_files_to_include_dir(self):
"""Copy include header files for each directory to include directory.
Copy include header files
from
rpm/
rpmio/*.h
lib/*.h
build/*.h
sign/*.h
to
rp... | [
"def",
"_copy_each_include_files_to_include_dir",
"(",
"self",
")",
":",
"src_header_dirs",
"=",
"[",
"'rpmio'",
",",
"'lib'",
",",
"'build'",
",",
"'sign'",
",",
"]",
"with",
"Cmd",
".",
"pushd",
"(",
"'..'",
")",
":",
"src_include_dir",
"=",
"os",
".",
"... | Copy include header files for each directory to include directory.
Copy include header files
from
rpm/
rpmio/*.h
lib/*.h
build/*.h
sign/*.h
to
rpm/
include/
rpm/*.h
... | [
"Copy",
"include",
"header",
"files",
"for",
"each",
"directory",
"to",
"include",
"directory",
"."
] | train | https://github.com/junaruga/rpm-py-installer/blob/12f45feb0ba533dec8d0d16ef1e9b7fb8cfbd4ed/install.py#L711-L756 |
junaruga/rpm-py-installer | install.py | Installer._make_dep_lib_file_sym_links_and_copy_include_files | def _make_dep_lib_file_sym_links_and_copy_include_files(self):
"""Make symbolick links for lib files and copy include files.
Do below steps for a dependency packages.
Dependency packages
- popt-devel
Steps
1. Make symbolic links from system library files or downloaded ... | python | def _make_dep_lib_file_sym_links_and_copy_include_files(self):
"""Make symbolick links for lib files and copy include files.
Do below steps for a dependency packages.
Dependency packages
- popt-devel
Steps
1. Make symbolic links from system library files or downloaded ... | [
"def",
"_make_dep_lib_file_sym_links_and_copy_include_files",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_rpm_py_has_popt_devel_dep",
"(",
")",
":",
"message",
"=",
"(",
"'The RPM Python binding does not have popt-devel dependency'",
")",
"Log",
".",
"debug",
"(",
... | Make symbolick links for lib files and copy include files.
Do below steps for a dependency packages.
Dependency packages
- popt-devel
Steps
1. Make symbolic links from system library files or downloaded lib
files to downloaded source library files.
2. Copy i... | [
"Make",
"symbolick",
"links",
"for",
"lib",
"files",
"and",
"copy",
"include",
"files",
"."
] | train | https://github.com/junaruga/rpm-py-installer/blob/12f45feb0ba533dec8d0d16ef1e9b7fb8cfbd4ed/install.py#L758-L824 |
junaruga/rpm-py-installer | install.py | Installer._rpm_py_has_popt_devel_dep | def _rpm_py_has_popt_devel_dep(self):
"""Check if the RPM Python binding has a depndency to popt-devel.
Search include header files in the source code to check it.
"""
found = False
with open('../include/rpm/rpmlib.h') as f_in:
for line in f_in:
if re... | python | def _rpm_py_has_popt_devel_dep(self):
"""Check if the RPM Python binding has a depndency to popt-devel.
Search include header files in the source code to check it.
"""
found = False
with open('../include/rpm/rpmlib.h') as f_in:
for line in f_in:
if re... | [
"def",
"_rpm_py_has_popt_devel_dep",
"(",
"self",
")",
":",
"found",
"=",
"False",
"with",
"open",
"(",
"'../include/rpm/rpmlib.h'",
")",
"as",
"f_in",
":",
"for",
"line",
"in",
"f_in",
":",
"if",
"re",
".",
"match",
"(",
"r'^#include .*popt.h.*$'",
",",
"li... | Check if the RPM Python binding has a depndency to popt-devel.
Search include header files in the source code to check it. | [
"Check",
"if",
"the",
"RPM",
"Python",
"binding",
"has",
"a",
"depndency",
"to",
"popt",
"-",
"devel",
"."
] | train | https://github.com/junaruga/rpm-py-installer/blob/12f45feb0ba533dec8d0d16ef1e9b7fb8cfbd4ed/install.py#L833-L844 |
junaruga/rpm-py-installer | install.py | FedoraInstaller.run | def run(self):
"""Run install main logic."""
try:
if not self._is_rpm_all_lib_include_files_installed():
self._make_lib_file_symbolic_links()
self._copy_each_include_files_to_include_dir()
self._make_dep_lib_file_sym_links_and_copy_include_file... | python | def run(self):
"""Run install main logic."""
try:
if not self._is_rpm_all_lib_include_files_installed():
self._make_lib_file_symbolic_links()
self._copy_each_include_files_to_include_dir()
self._make_dep_lib_file_sym_links_and_copy_include_file... | [
"def",
"run",
"(",
"self",
")",
":",
"try",
":",
"if",
"not",
"self",
".",
"_is_rpm_all_lib_include_files_installed",
"(",
")",
":",
"self",
".",
"_make_lib_file_symbolic_links",
"(",
")",
"self",
".",
"_copy_each_include_files_to_include_dir",
"(",
")",
"self",
... | Run install main logic. | [
"Run",
"install",
"main",
"logic",
"."
] | train | https://github.com/junaruga/rpm-py-installer/blob/12f45feb0ba533dec8d0d16ef1e9b7fb8cfbd4ed/install.py#L874-L896 |
junaruga/rpm-py-installer | install.py | FedoraInstaller.install_from_rpm_py_package | def install_from_rpm_py_package(self):
"""Run install from RPM Python binding RPM package."""
self._download_and_extract_rpm_py_package()
# Find ./usr/lib64/pythonN.N/site-packages/rpm directory.
# A binary built by same version Python with used Python is target
# for the safe i... | python | def install_from_rpm_py_package(self):
"""Run install from RPM Python binding RPM package."""
self._download_and_extract_rpm_py_package()
# Find ./usr/lib64/pythonN.N/site-packages/rpm directory.
# A binary built by same version Python with used Python is target
# for the safe i... | [
"def",
"install_from_rpm_py_package",
"(",
"self",
")",
":",
"self",
".",
"_download_and_extract_rpm_py_package",
"(",
")",
"# Find ./usr/lib64/pythonN.N/site-packages/rpm directory.",
"# A binary built by same version Python with used Python is target",
"# for the safe installation.",
"... | Run install from RPM Python binding RPM package. | [
"Run",
"install",
"from",
"RPM",
"Python",
"binding",
"RPM",
"package",
"."
] | train | https://github.com/junaruga/rpm-py-installer/blob/12f45feb0ba533dec8d0d16ef1e9b7fb8cfbd4ed/install.py#L898-L953 |
junaruga/rpm-py-installer | install.py | Linux.get_instance | def get_instance(cls, python, rpm_path, **kwargs):
"""Get OS object."""
linux = None
if Cmd.which('apt-get'):
linux = DebianLinux(python, rpm_path, **kwargs)
else:
linux = FedoraLinux(python, rpm_path, **kwargs)
return linux | python | def get_instance(cls, python, rpm_path, **kwargs):
"""Get OS object."""
linux = None
if Cmd.which('apt-get'):
linux = DebianLinux(python, rpm_path, **kwargs)
else:
linux = FedoraLinux(python, rpm_path, **kwargs)
return linux | [
"def",
"get_instance",
"(",
"cls",
",",
"python",
",",
"rpm_path",
",",
"*",
"*",
"kwargs",
")",
":",
"linux",
"=",
"None",
"if",
"Cmd",
".",
"which",
"(",
"'apt-get'",
")",
":",
"linux",
"=",
"DebianLinux",
"(",
"python",
",",
"rpm_path",
",",
"*",
... | Get OS object. | [
"Get",
"OS",
"object",
"."
] | train | https://github.com/junaruga/rpm-py-installer/blob/12f45feb0ba533dec8d0d16ef1e9b7fb8cfbd4ed/install.py#L1175-L1182 |
junaruga/rpm-py-installer | install.py | Linux.verify_system_status | def verify_system_status(self):
"""Verify system status."""
if not sys.platform.startswith('linux'):
raise InstallError('Supported platform is Linux only.')
if self.python.is_system_python():
if self.python.is_python_binding_installed():
message = '''
RPM... | python | def verify_system_status(self):
"""Verify system status."""
if not sys.platform.startswith('linux'):
raise InstallError('Supported platform is Linux only.')
if self.python.is_system_python():
if self.python.is_python_binding_installed():
message = '''
RPM... | [
"def",
"verify_system_status",
"(",
"self",
")",
":",
"if",
"not",
"sys",
".",
"platform",
".",
"startswith",
"(",
"'linux'",
")",
":",
"raise",
"InstallError",
"(",
"'Supported platform is Linux only.'",
")",
"if",
"self",
".",
"python",
".",
"is_system_python"... | Verify system status. | [
"Verify",
"system",
"status",
"."
] | train | https://github.com/junaruga/rpm-py-installer/blob/12f45feb0ba533dec8d0d16ef1e9b7fb8cfbd4ed/install.py#L1192-L1216 |
junaruga/rpm-py-installer | install.py | FedoraLinux.verify_package_status | def verify_package_status(self):
"""Verify dependency RPM package status."""
# rpm-libs is required for /usr/lib64/librpm*.so
self.rpm.verify_packages_installed(['rpm-libs'])
# Check RPM so files to build the Python binding.
message_format = '''
RPM: {0} or
RPM download tool (dn... | python | def verify_package_status(self):
"""Verify dependency RPM package status."""
# rpm-libs is required for /usr/lib64/librpm*.so
self.rpm.verify_packages_installed(['rpm-libs'])
# Check RPM so files to build the Python binding.
message_format = '''
RPM: {0} or
RPM download tool (dn... | [
"def",
"verify_package_status",
"(",
"self",
")",
":",
"# rpm-libs is required for /usr/lib64/librpm*.so",
"self",
".",
"rpm",
".",
"verify_packages_installed",
"(",
"[",
"'rpm-libs'",
"]",
")",
"# Check RPM so files to build the Python binding.",
"message_format",
"=",
"'''\... | Verify dependency RPM package status. | [
"Verify",
"dependency",
"RPM",
"package",
"status",
"."
] | train | https://github.com/junaruga/rpm-py-installer/blob/12f45feb0ba533dec8d0d16ef1e9b7fb8cfbd4ed/install.py#L1233-L1250 |
junaruga/rpm-py-installer | install.py | FedoraLinux.create_installer | def create_installer(self, rpm_py_version, **kwargs):
"""Create Installer object."""
return FedoraInstaller(rpm_py_version, self.python, self.rpm, **kwargs) | python | def create_installer(self, rpm_py_version, **kwargs):
"""Create Installer object."""
return FedoraInstaller(rpm_py_version, self.python, self.rpm, **kwargs) | [
"def",
"create_installer",
"(",
"self",
",",
"rpm_py_version",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"FedoraInstaller",
"(",
"rpm_py_version",
",",
"self",
".",
"python",
",",
"self",
".",
"rpm",
",",
"*",
"*",
"kwargs",
")"
] | Create Installer object. | [
"Create",
"Installer",
"object",
"."
] | train | https://github.com/junaruga/rpm-py-installer/blob/12f45feb0ba533dec8d0d16ef1e9b7fb8cfbd4ed/install.py#L1256-L1258 |
junaruga/rpm-py-installer | install.py | DebianLinux.create_installer | def create_installer(self, rpm_py_version, **kwargs):
"""Create Installer object."""
return DebianInstaller(rpm_py_version, self.python, self.rpm, **kwargs) | python | def create_installer(self, rpm_py_version, **kwargs):
"""Create Installer object."""
return DebianInstaller(rpm_py_version, self.python, self.rpm, **kwargs) | [
"def",
"create_installer",
"(",
"self",
",",
"rpm_py_version",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"DebianInstaller",
"(",
"rpm_py_version",
",",
"self",
".",
"python",
",",
"self",
".",
"rpm",
",",
"*",
"*",
"kwargs",
")"
] | Create Installer object. | [
"Create",
"Installer",
"object",
"."
] | train | https://github.com/junaruga/rpm-py-installer/blob/12f45feb0ba533dec8d0d16ef1e9b7fb8cfbd4ed/install.py#L1282-L1284 |
junaruga/rpm-py-installer | install.py | Python.python_lib_rpm_dirs | def python_lib_rpm_dirs(self):
"""Both arch and non-arch site-packages directories."""
libs = [self.python_lib_arch_dir, self.python_lib_non_arch_dir]
def append_rpm(path):
return os.path.join(path, 'rpm')
return map(append_rpm, libs) | python | def python_lib_rpm_dirs(self):
"""Both arch and non-arch site-packages directories."""
libs = [self.python_lib_arch_dir, self.python_lib_non_arch_dir]
def append_rpm(path):
return os.path.join(path, 'rpm')
return map(append_rpm, libs) | [
"def",
"python_lib_rpm_dirs",
"(",
"self",
")",
":",
"libs",
"=",
"[",
"self",
".",
"python_lib_arch_dir",
",",
"self",
".",
"python_lib_non_arch_dir",
"]",
"def",
"append_rpm",
"(",
"path",
")",
":",
"return",
"os",
".",
"path",
".",
"join",
"(",
"path",
... | Both arch and non-arch site-packages directories. | [
"Both",
"arch",
"and",
"non",
"-",
"arch",
"site",
"-",
"packages",
"directories",
"."
] | train | https://github.com/junaruga/rpm-py-installer/blob/12f45feb0ba533dec8d0d16ef1e9b7fb8cfbd4ed/install.py#L1325-L1332 |
junaruga/rpm-py-installer | install.py | Python.is_python_binding_installed | def is_python_binding_installed(self):
"""Check if the Python binding has already installed.
Consider below cases.
- pip command is not installed.
- The installed RPM Python binding does not have information
showed as a result of pip list.
"""
is_installed = Fa... | python | def is_python_binding_installed(self):
"""Check if the Python binding has already installed.
Consider below cases.
- pip command is not installed.
- The installed RPM Python binding does not have information
showed as a result of pip list.
"""
is_installed = Fa... | [
"def",
"is_python_binding_installed",
"(",
"self",
")",
":",
"is_installed",
"=",
"False",
"is_install_error",
"=",
"False",
"try",
":",
"is_installed",
"=",
"self",
".",
"is_python_binding_installed_on_pip",
"(",
")",
"except",
"InstallError",
":",
"# Consider a case... | Check if the Python binding has already installed.
Consider below cases.
- pip command is not installed.
- The installed RPM Python binding does not have information
showed as a result of pip list. | [
"Check",
"if",
"the",
"Python",
"binding",
"has",
"already",
"installed",
"."
] | train | https://github.com/junaruga/rpm-py-installer/blob/12f45feb0ba533dec8d0d16ef1e9b7fb8cfbd4ed/install.py#L1334-L1357 |
junaruga/rpm-py-installer | install.py | Python.is_python_binding_installed_on_pip | def is_python_binding_installed_on_pip(self):
"""Check if the Python binding has already installed."""
pip_version = self._get_pip_version()
Log.debug('Pip version: {0}'.format(pip_version))
pip_major_version = int(pip_version.split('.')[0])
installed = False
# --format ... | python | def is_python_binding_installed_on_pip(self):
"""Check if the Python binding has already installed."""
pip_version = self._get_pip_version()
Log.debug('Pip version: {0}'.format(pip_version))
pip_major_version = int(pip_version.split('.')[0])
installed = False
# --format ... | [
"def",
"is_python_binding_installed_on_pip",
"(",
"self",
")",
":",
"pip_version",
"=",
"self",
".",
"_get_pip_version",
"(",
")",
"Log",
".",
"debug",
"(",
"'Pip version: {0}'",
".",
"format",
"(",
"pip_version",
")",
")",
"pip_major_version",
"=",
"int",
"(",
... | Check if the Python binding has already installed. | [
"Check",
"if",
"the",
"Python",
"binding",
"has",
"already",
"installed",
"."
] | train | https://github.com/junaruga/rpm-py-installer/blob/12f45feb0ba533dec8d0d16ef1e9b7fb8cfbd4ed/install.py#L1359-L1388 |
junaruga/rpm-py-installer | install.py | Rpm.version | def version(self):
"""RPM vesion string."""
stdout = Cmd.sh_e_out('{0} --version'.format(self.rpm_path))
rpm_version = stdout.split()[2]
return rpm_version | python | def version(self):
"""RPM vesion string."""
stdout = Cmd.sh_e_out('{0} --version'.format(self.rpm_path))
rpm_version = stdout.split()[2]
return rpm_version | [
"def",
"version",
"(",
"self",
")",
":",
"stdout",
"=",
"Cmd",
".",
"sh_e_out",
"(",
"'{0} --version'",
".",
"format",
"(",
"self",
".",
"rpm_path",
")",
")",
"rpm_version",
"=",
"stdout",
".",
"split",
"(",
")",
"[",
"2",
"]",
"return",
"rpm_version"
... | RPM vesion string. | [
"RPM",
"vesion",
"string",
"."
] | train | https://github.com/junaruga/rpm-py-installer/blob/12f45feb0ba533dec8d0d16ef1e9b7fb8cfbd4ed/install.py#L1435-L1439 |
junaruga/rpm-py-installer | install.py | Rpm.is_system_rpm | def is_system_rpm(self):
"""Check if the RPM is system RPM."""
sys_rpm_paths = [
'/usr/bin/rpm',
# On CentOS6, system RPM is installed in this directory.
'/bin/rpm',
]
matched = False
for sys_rpm_path in sys_rpm_paths:
if self.rpm_p... | python | def is_system_rpm(self):
"""Check if the RPM is system RPM."""
sys_rpm_paths = [
'/usr/bin/rpm',
# On CentOS6, system RPM is installed in this directory.
'/bin/rpm',
]
matched = False
for sys_rpm_path in sys_rpm_paths:
if self.rpm_p... | [
"def",
"is_system_rpm",
"(",
"self",
")",
":",
"sys_rpm_paths",
"=",
"[",
"'/usr/bin/rpm'",
",",
"# On CentOS6, system RPM is installed in this directory.",
"'/bin/rpm'",
",",
"]",
"matched",
"=",
"False",
"for",
"sys_rpm_path",
"in",
"sys_rpm_paths",
":",
"if",
"self... | Check if the RPM is system RPM. | [
"Check",
"if",
"the",
"RPM",
"is",
"system",
"RPM",
"."
] | train | https://github.com/junaruga/rpm-py-installer/blob/12f45feb0ba533dec8d0d16ef1e9b7fb8cfbd4ed/install.py#L1447-L1459 |
junaruga/rpm-py-installer | install.py | Rpm.is_package_installed | def is_package_installed(self, package_name):
"""Check if the RPM package is installed."""
if not package_name:
raise ValueError('package_name required.')
installed = True
try:
Cmd.sh_e('{0} --query {1} --quiet'.format(self.rpm_path,
... | python | def is_package_installed(self, package_name):
"""Check if the RPM package is installed."""
if not package_name:
raise ValueError('package_name required.')
installed = True
try:
Cmd.sh_e('{0} --query {1} --quiet'.format(self.rpm_path,
... | [
"def",
"is_package_installed",
"(",
"self",
",",
"package_name",
")",
":",
"if",
"not",
"package_name",
":",
"raise",
"ValueError",
"(",
"'package_name required.'",
")",
"installed",
"=",
"True",
"try",
":",
"Cmd",
".",
"sh_e",
"(",
"'{0} --query {1} --quiet'",
... | Check if the RPM package is installed. | [
"Check",
"if",
"the",
"RPM",
"package",
"is",
"installed",
"."
] | train | https://github.com/junaruga/rpm-py-installer/blob/12f45feb0ba533dec8d0d16ef1e9b7fb8cfbd4ed/install.py#L1465-L1476 |
junaruga/rpm-py-installer | install.py | Rpm.verify_packages_installed | def verify_packages_installed(self, package_names):
"""Check if the RPM packages are installed.
Raise InstallError if any of the packages is not installed.
"""
if not package_names:
raise ValueError('package_names required.')
missing_packages = []
for packag... | python | def verify_packages_installed(self, package_names):
"""Check if the RPM packages are installed.
Raise InstallError if any of the packages is not installed.
"""
if not package_names:
raise ValueError('package_names required.')
missing_packages = []
for packag... | [
"def",
"verify_packages_installed",
"(",
"self",
",",
"package_names",
")",
":",
"if",
"not",
"package_names",
":",
"raise",
"ValueError",
"(",
"'package_names required.'",
")",
"missing_packages",
"=",
"[",
"]",
"for",
"package_name",
"in",
"package_names",
":",
... | Check if the RPM packages are installed.
Raise InstallError if any of the packages is not installed. | [
"Check",
"if",
"the",
"RPM",
"packages",
"are",
"installed",
"."
] | train | https://github.com/junaruga/rpm-py-installer/blob/12f45feb0ba533dec8d0d16ef1e9b7fb8cfbd4ed/install.py#L1478-L1497 |
junaruga/rpm-py-installer | install.py | FedoraRpm.lib_dir | def lib_dir(self):
"""Return standard library directory path used by RPM libs.
TODO: Support non-system RPM.
"""
if not self._lib_dir:
rpm_lib_dir = None
cmd = '{0} -ql rpm-libs'.format(self.rpm_path)
out = Cmd.sh_e_out(cmd)
lines = out.sp... | python | def lib_dir(self):
"""Return standard library directory path used by RPM libs.
TODO: Support non-system RPM.
"""
if not self._lib_dir:
rpm_lib_dir = None
cmd = '{0} -ql rpm-libs'.format(self.rpm_path)
out = Cmd.sh_e_out(cmd)
lines = out.sp... | [
"def",
"lib_dir",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_lib_dir",
":",
"rpm_lib_dir",
"=",
"None",
"cmd",
"=",
"'{0} -ql rpm-libs'",
".",
"format",
"(",
"self",
".",
"rpm_path",
")",
"out",
"=",
"Cmd",
".",
"sh_e_out",
"(",
"cmd",
")",
"... | Return standard library directory path used by RPM libs.
TODO: Support non-system RPM. | [
"Return",
"standard",
"library",
"directory",
"path",
"used",
"by",
"RPM",
"libs",
"."
] | train | https://github.com/junaruga/rpm-py-installer/blob/12f45feb0ba533dec8d0d16ef1e9b7fb8cfbd4ed/install.py#L1527-L1542 |
junaruga/rpm-py-installer | install.py | FedoraRpm.is_downloadable | def is_downloadable(self):
"""Return if rpm is downloadable by the package command.
Check if dnf or yum plugin package exists.
"""
is_plugin_avaiable = False
if self.is_dnf:
is_plugin_avaiable = self.is_package_installed(
'dnf-plugins... | python | def is_downloadable(self):
"""Return if rpm is downloadable by the package command.
Check if dnf or yum plugin package exists.
"""
is_plugin_avaiable = False
if self.is_dnf:
is_plugin_avaiable = self.is_package_installed(
'dnf-plugins... | [
"def",
"is_downloadable",
"(",
"self",
")",
":",
"is_plugin_avaiable",
"=",
"False",
"if",
"self",
".",
"is_dnf",
":",
"is_plugin_avaiable",
"=",
"self",
".",
"is_package_installed",
"(",
"'dnf-plugins-core'",
")",
"else",
":",
"\"\"\" yum environment.\n Ma... | Return if rpm is downloadable by the package command.
Check if dnf or yum plugin package exists. | [
"Return",
"if",
"rpm",
"is",
"downloadable",
"by",
"the",
"package",
"command",
"."
] | train | https://github.com/junaruga/rpm-py-installer/blob/12f45feb0ba533dec8d0d16ef1e9b7fb8cfbd4ed/install.py#L1561-L1581 |
junaruga/rpm-py-installer | install.py | FedoraRpm.download | def download(self, package_name):
"""Download given package."""
if not package_name:
ValueError('package_name required.')
if self.is_dnf:
cmd = 'dnf download {0}.{1}'.format(package_name, self.arch)
else:
cmd = 'yumdownloader {0}.{1}'.format(package_na... | python | def download(self, package_name):
"""Download given package."""
if not package_name:
ValueError('package_name required.')
if self.is_dnf:
cmd = 'dnf download {0}.{1}'.format(package_name, self.arch)
else:
cmd = 'yumdownloader {0}.{1}'.format(package_na... | [
"def",
"download",
"(",
"self",
",",
"package_name",
")",
":",
"if",
"not",
"package_name",
":",
"ValueError",
"(",
"'package_name required.'",
")",
"if",
"self",
".",
"is_dnf",
":",
"cmd",
"=",
"'dnf download {0}.{1}'",
".",
"format",
"(",
"package_name",
","... | Download given package. | [
"Download",
"given",
"package",
"."
] | train | https://github.com/junaruga/rpm-py-installer/blob/12f45feb0ba533dec8d0d16ef1e9b7fb8cfbd4ed/install.py#L1588-L1608 |
junaruga/rpm-py-installer | install.py | FedoraRpm.extract | def extract(self, package_name):
"""Extract given package."""
for cmd in ['rpm2cpio', 'cpio']:
if not Cmd.which(cmd):
message = '{0} command not found. Install {0}.'.format(cmd)
raise InstallError(message)
pattern = '{0}*{1}.rpm'.format(package_name, ... | python | def extract(self, package_name):
"""Extract given package."""
for cmd in ['rpm2cpio', 'cpio']:
if not Cmd.which(cmd):
message = '{0} command not found. Install {0}.'.format(cmd)
raise InstallError(message)
pattern = '{0}*{1}.rpm'.format(package_name, ... | [
"def",
"extract",
"(",
"self",
",",
"package_name",
")",
":",
"for",
"cmd",
"in",
"[",
"'rpm2cpio'",
",",
"'cpio'",
"]",
":",
"if",
"not",
"Cmd",
".",
"which",
"(",
"cmd",
")",
":",
"message",
"=",
"'{0} command not found. Install {0}.'",
".",
"format",
... | Extract given package. | [
"Extract",
"given",
"package",
"."
] | train | https://github.com/junaruga/rpm-py-installer/blob/12f45feb0ba533dec8d0d16ef1e9b7fb8cfbd4ed/install.py#L1610-L1622 |
junaruga/rpm-py-installer | install.py | DebianRpm.lib_dir | def lib_dir(self):
"""Return standard library directory path used by RPM libs."""
if not self._lib_dir:
lib_files = glob.glob("/usr/lib/*/librpm.so*")
if not lib_files:
raise InstallError("Can not find lib directory.")
self._lib_dir = os.path.dirname(l... | python | def lib_dir(self):
"""Return standard library directory path used by RPM libs."""
if not self._lib_dir:
lib_files = glob.glob("/usr/lib/*/librpm.so*")
if not lib_files:
raise InstallError("Can not find lib directory.")
self._lib_dir = os.path.dirname(l... | [
"def",
"lib_dir",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_lib_dir",
":",
"lib_files",
"=",
"glob",
".",
"glob",
"(",
"\"/usr/lib/*/librpm.so*\"",
")",
"if",
"not",
"lib_files",
":",
"raise",
"InstallError",
"(",
"\"Can not find lib directory.\"",
")... | Return standard library directory path used by RPM libs. | [
"Return",
"standard",
"library",
"directory",
"path",
"used",
"by",
"RPM",
"libs",
"."
] | train | https://github.com/junaruga/rpm-py-installer/blob/12f45feb0ba533dec8d0d16ef1e9b7fb8cfbd4ed/install.py#L1636-L1643 |
junaruga/rpm-py-installer | install.py | Cmd.sh_e | def sh_e(cls, cmd, **kwargs):
"""Run the command. It behaves like "sh -e".
It raises InstallError if the command failed.
"""
Log.debug('CMD: {0}'.format(cmd))
cmd_kwargs = {
'shell': True,
}
cmd_kwargs.update(kwargs)
env = os.environ.copy()
... | python | def sh_e(cls, cmd, **kwargs):
"""Run the command. It behaves like "sh -e".
It raises InstallError if the command failed.
"""
Log.debug('CMD: {0}'.format(cmd))
cmd_kwargs = {
'shell': True,
}
cmd_kwargs.update(kwargs)
env = os.environ.copy()
... | [
"def",
"sh_e",
"(",
"cls",
",",
"cmd",
",",
"*",
"*",
"kwargs",
")",
":",
"Log",
".",
"debug",
"(",
"'CMD: {0}'",
".",
"format",
"(",
"cmd",
")",
")",
"cmd_kwargs",
"=",
"{",
"'shell'",
":",
"True",
",",
"}",
"cmd_kwargs",
".",
"update",
"(",
"kw... | Run the command. It behaves like "sh -e".
It raises InstallError if the command failed. | [
"Run",
"the",
"command",
".",
"It",
"behaves",
"like",
"sh",
"-",
"e",
"."
] | train | https://github.com/junaruga/rpm-py-installer/blob/12f45feb0ba533dec8d0d16ef1e9b7fb8cfbd4ed/install.py#L1707-L1758 |
junaruga/rpm-py-installer | install.py | Cmd.sh_e_out | def sh_e_out(cls, cmd, **kwargs):
"""Run the command. and returns the stdout."""
cmd_kwargs = {
'stdout': subprocess.PIPE,
}
cmd_kwargs.update(kwargs)
return cls.sh_e(cmd, **cmd_kwargs)[0] | python | def sh_e_out(cls, cmd, **kwargs):
"""Run the command. and returns the stdout."""
cmd_kwargs = {
'stdout': subprocess.PIPE,
}
cmd_kwargs.update(kwargs)
return cls.sh_e(cmd, **cmd_kwargs)[0] | [
"def",
"sh_e_out",
"(",
"cls",
",",
"cmd",
",",
"*",
"*",
"kwargs",
")",
":",
"cmd_kwargs",
"=",
"{",
"'stdout'",
":",
"subprocess",
".",
"PIPE",
",",
"}",
"cmd_kwargs",
".",
"update",
"(",
"kwargs",
")",
"return",
"cls",
".",
"sh_e",
"(",
"cmd",
"... | Run the command. and returns the stdout. | [
"Run",
"the",
"command",
".",
"and",
"returns",
"the",
"stdout",
"."
] | train | https://github.com/junaruga/rpm-py-installer/blob/12f45feb0ba533dec8d0d16ef1e9b7fb8cfbd4ed/install.py#L1761-L1767 |
junaruga/rpm-py-installer | install.py | Cmd.cd | def cd(cls, directory):
"""Change directory. It behaves like "cd directory"."""
Log.debug('CMD: cd {0}'.format(directory))
os.chdir(directory) | python | def cd(cls, directory):
"""Change directory. It behaves like "cd directory"."""
Log.debug('CMD: cd {0}'.format(directory))
os.chdir(directory) | [
"def",
"cd",
"(",
"cls",
",",
"directory",
")",
":",
"Log",
".",
"debug",
"(",
"'CMD: cd {0}'",
".",
"format",
"(",
"directory",
")",
")",
"os",
".",
"chdir",
"(",
"directory",
")"
] | Change directory. It behaves like "cd directory". | [
"Change",
"directory",
".",
"It",
"behaves",
"like",
"cd",
"directory",
"."
] | train | https://github.com/junaruga/rpm-py-installer/blob/12f45feb0ba533dec8d0d16ef1e9b7fb8cfbd4ed/install.py#L1770-L1773 |
junaruga/rpm-py-installer | install.py | Cmd.pushd | def pushd(cls, new_dir):
"""Change directory, and back to previous directory.
It behaves like "pushd directory; something; popd".
"""
previous_dir = os.getcwd()
try:
new_ab_dir = None
if os.path.isabs(new_dir):
new_ab_dir = new_dir
... | python | def pushd(cls, new_dir):
"""Change directory, and back to previous directory.
It behaves like "pushd directory; something; popd".
"""
previous_dir = os.getcwd()
try:
new_ab_dir = None
if os.path.isabs(new_dir):
new_ab_dir = new_dir
... | [
"def",
"pushd",
"(",
"cls",
",",
"new_dir",
")",
":",
"previous_dir",
"=",
"os",
".",
"getcwd",
"(",
")",
"try",
":",
"new_ab_dir",
"=",
"None",
"if",
"os",
".",
"path",
".",
"isabs",
"(",
"new_dir",
")",
":",
"new_ab_dir",
"=",
"new_dir",
"else",
... | Change directory, and back to previous directory.
It behaves like "pushd directory; something; popd". | [
"Change",
"directory",
"and",
"back",
"to",
"previous",
"directory",
"."
] | train | https://github.com/junaruga/rpm-py-installer/blob/12f45feb0ba533dec8d0d16ef1e9b7fb8cfbd4ed/install.py#L1777-L1793 |
junaruga/rpm-py-installer | install.py | Cmd.which | def which(cls, cmd):
"""Return an absolute path of the command.
It behaves like "which command".
"""
abs_path_cmd = None
if sys.version_info >= (3, 3):
abs_path_cmd = shutil.which(cmd)
else:
abs_path_cmd = find_executable(cmd)
return abs_p... | python | def which(cls, cmd):
"""Return an absolute path of the command.
It behaves like "which command".
"""
abs_path_cmd = None
if sys.version_info >= (3, 3):
abs_path_cmd = shutil.which(cmd)
else:
abs_path_cmd = find_executable(cmd)
return abs_p... | [
"def",
"which",
"(",
"cls",
",",
"cmd",
")",
":",
"abs_path_cmd",
"=",
"None",
"if",
"sys",
".",
"version_info",
">=",
"(",
"3",
",",
"3",
")",
":",
"abs_path_cmd",
"=",
"shutil",
".",
"which",
"(",
"cmd",
")",
"else",
":",
"abs_path_cmd",
"=",
"fi... | Return an absolute path of the command.
It behaves like "which command". | [
"Return",
"an",
"absolute",
"path",
"of",
"the",
"command",
"."
] | train | https://github.com/junaruga/rpm-py-installer/blob/12f45feb0ba533dec8d0d16ef1e9b7fb8cfbd4ed/install.py#L1796-L1806 |
junaruga/rpm-py-installer | install.py | Cmd.curl_remote_name | def curl_remote_name(cls, file_url):
"""Download file_url, and save as a file name of the URL.
It behaves like "curl -O or --remote-name".
It raises HTTPError if the file_url not found.
"""
tar_gz_file_name = file_url.split('/')[-1]
if sys.version_info >= (3, 2):
... | python | def curl_remote_name(cls, file_url):
"""Download file_url, and save as a file name of the URL.
It behaves like "curl -O or --remote-name".
It raises HTTPError if the file_url not found.
"""
tar_gz_file_name = file_url.split('/')[-1]
if sys.version_info >= (3, 2):
... | [
"def",
"curl_remote_name",
"(",
"cls",
",",
"file_url",
")",
":",
"tar_gz_file_name",
"=",
"file_url",
".",
"split",
"(",
"'/'",
")",
"[",
"-",
"1",
"]",
"if",
"sys",
".",
"version_info",
">=",
"(",
"3",
",",
"2",
")",
":",
"from",
"urllib",
".",
"... | Download file_url, and save as a file name of the URL.
It behaves like "curl -O or --remote-name".
It raises HTTPError if the file_url not found. | [
"Download",
"file_url",
"and",
"save",
"as",
"a",
"file",
"name",
"of",
"the",
"URL",
"."
] | train | https://github.com/junaruga/rpm-py-installer/blob/12f45feb0ba533dec8d0d16ef1e9b7fb8cfbd4ed/install.py#L1809-L1838 |
junaruga/rpm-py-installer | install.py | Cmd.tar_extract | def tar_extract(cls, tar_comp_file_path):
"""Extract tar.gz or tar bz2 file.
It behaves like
- tar xzf tar_gz_file_path
- tar xjf tar_bz2_file_path
It raises tarfile.ReadError if the file is broken.
"""
try:
with contextlib.closing(tarfile.open(ta... | python | def tar_extract(cls, tar_comp_file_path):
"""Extract tar.gz or tar bz2 file.
It behaves like
- tar xzf tar_gz_file_path
- tar xjf tar_bz2_file_path
It raises tarfile.ReadError if the file is broken.
"""
try:
with contextlib.closing(tarfile.open(ta... | [
"def",
"tar_extract",
"(",
"cls",
",",
"tar_comp_file_path",
")",
":",
"try",
":",
"with",
"contextlib",
".",
"closing",
"(",
"tarfile",
".",
"open",
"(",
"tar_comp_file_path",
")",
")",
"as",
"tar",
":",
"tar",
".",
"extractall",
"(",
")",
"except",
"ta... | Extract tar.gz or tar bz2 file.
It behaves like
- tar xzf tar_gz_file_path
- tar xjf tar_bz2_file_path
It raises tarfile.ReadError if the file is broken. | [
"Extract",
"tar",
".",
"gz",
"or",
"tar",
"bz2",
"file",
"."
] | train | https://github.com/junaruga/rpm-py-installer/blob/12f45feb0ba533dec8d0d16ef1e9b7fb8cfbd4ed/install.py#L1841-L1857 |
junaruga/rpm-py-installer | install.py | Cmd.find | def find(cls, searched_dir, pattern):
"""Find matched files.
It does not include symbolic file in the result.
"""
Log.debug('find {0} with pattern: {1}'.format(searched_dir, pattern))
matched_files = []
for root_dir, dir_names, file_names in os.walk(searched_dir,
... | python | def find(cls, searched_dir, pattern):
"""Find matched files.
It does not include symbolic file in the result.
"""
Log.debug('find {0} with pattern: {1}'.format(searched_dir, pattern))
matched_files = []
for root_dir, dir_names, file_names in os.walk(searched_dir,
... | [
"def",
"find",
"(",
"cls",
",",
"searched_dir",
",",
"pattern",
")",
":",
"Log",
".",
"debug",
"(",
"'find {0} with pattern: {1}'",
".",
"format",
"(",
"searched_dir",
",",
"pattern",
")",
")",
"matched_files",
"=",
"[",
"]",
"for",
"root_dir",
",",
"dir_n... | Find matched files.
It does not include symbolic file in the result. | [
"Find",
"matched",
"files",
"."
] | train | https://github.com/junaruga/rpm-py-installer/blob/12f45feb0ba533dec8d0d16ef1e9b7fb8cfbd4ed/install.py#L1860-L1875 |
junaruga/rpm-py-installer | install.py | Utils.version_str2tuple | def version_str2tuple(cls, version_str):
"""Version info.
tuple object. ex. ('4', '14', '0', 'rc1')
"""
if not isinstance(version_str, str):
ValueError('version_str invalid instance.')
version_info_list = re.findall(r'[0-9a-zA-Z]+', version_str)
def convert_... | python | def version_str2tuple(cls, version_str):
"""Version info.
tuple object. ex. ('4', '14', '0', 'rc1')
"""
if not isinstance(version_str, str):
ValueError('version_str invalid instance.')
version_info_list = re.findall(r'[0-9a-zA-Z]+', version_str)
def convert_... | [
"def",
"version_str2tuple",
"(",
"cls",
",",
"version_str",
")",
":",
"if",
"not",
"isinstance",
"(",
"version_str",
",",
"str",
")",
":",
"ValueError",
"(",
"'version_str invalid instance.'",
")",
"version_info_list",
"=",
"re",
".",
"findall",
"(",
"r'[0-9a-zA... | Version info.
tuple object. ex. ('4', '14', '0', 'rc1') | [
"Version",
"info",
"."
] | train | https://github.com/junaruga/rpm-py-installer/blob/12f45feb0ba533dec8d0d16ef1e9b7fb8cfbd4ed/install.py#L1890-L1909 |
biocommons/biocommons.seqrepo | biocommons/seqrepo/fastaiter/fastaiter.py | FastaIter | def FastaIter(handle):
"""generator that returns (header, sequence) tuples from an open FASTA file handle
Lines before the start of the first record are ignored.
"""
header = None
for line in handle:
if line.startswith(">"):
if header is not None: # not the first record
... | python | def FastaIter(handle):
"""generator that returns (header, sequence) tuples from an open FASTA file handle
Lines before the start of the first record are ignored.
"""
header = None
for line in handle:
if line.startswith(">"):
if header is not None: # not the first record
... | [
"def",
"FastaIter",
"(",
"handle",
")",
":",
"header",
"=",
"None",
"for",
"line",
"in",
"handle",
":",
"if",
"line",
".",
"startswith",
"(",
"\">\"",
")",
":",
"if",
"header",
"is",
"not",
"None",
":",
"# not the first record",
"yield",
"header",
",",
... | generator that returns (header, sequence) tuples from an open FASTA file handle
Lines before the start of the first record are ignored. | [
"generator",
"that",
"returns",
"(",
"header",
"sequence",
")",
"tuples",
"from",
"an",
"open",
"FASTA",
"file",
"handle"
] | train | https://github.com/biocommons/biocommons.seqrepo/blob/fb6d88682cb73ee6971cfa47d4dcd90a9c649167/biocommons/seqrepo/fastaiter/fastaiter.py#L1-L21 |
biocommons/biocommons.seqrepo | biocommons/seqrepo/py2compat/_which.py | which | def which(file):
"""
>>> which("sh") is not None
True
>>> which("bogus-executable-that-doesn't-exist") is None
True
"""
for path in os.environ["PATH"].split(os.pathsep):
if os.path.exists(os.path.join(path, file)):
return os.path.join(path, file)
return None | python | def which(file):
"""
>>> which("sh") is not None
True
>>> which("bogus-executable-that-doesn't-exist") is None
True
"""
for path in os.environ["PATH"].split(os.pathsep):
if os.path.exists(os.path.join(path, file)):
return os.path.join(path, file)
return None | [
"def",
"which",
"(",
"file",
")",
":",
"for",
"path",
"in",
"os",
".",
"environ",
"[",
"\"PATH\"",
"]",
".",
"split",
"(",
"os",
".",
"pathsep",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"os",
".",
"path",
".",
"join",
"(",
"path",... | >>> which("sh") is not None
True
>>> which("bogus-executable-that-doesn't-exist") is None
True | [
">>>",
"which",
"(",
"sh",
")",
"is",
"not",
"None",
"True"
] | train | https://github.com/biocommons/biocommons.seqrepo/blob/fb6d88682cb73ee6971cfa47d4dcd90a9c649167/biocommons/seqrepo/py2compat/_which.py#L3-L15 |
junaruga/rpm-py-installer | setup.py | install_rpm_py | def install_rpm_py():
"""Install RPM Python binding."""
python_path = sys.executable
cmd = '{0} install.py'.format(python_path)
exit_status = os.system(cmd)
if exit_status != 0:
raise Exception('Command failed: {0}'.format(cmd)) | python | def install_rpm_py():
"""Install RPM Python binding."""
python_path = sys.executable
cmd = '{0} install.py'.format(python_path)
exit_status = os.system(cmd)
if exit_status != 0:
raise Exception('Command failed: {0}'.format(cmd)) | [
"def",
"install_rpm_py",
"(",
")",
":",
"python_path",
"=",
"sys",
".",
"executable",
"cmd",
"=",
"'{0} install.py'",
".",
"format",
"(",
"python_path",
")",
"exit_status",
"=",
"os",
".",
"system",
"(",
"cmd",
")",
"if",
"exit_status",
"!=",
"0",
":",
"... | Install RPM Python binding. | [
"Install",
"RPM",
"Python",
"binding",
"."
] | train | https://github.com/junaruga/rpm-py-installer/blob/12f45feb0ba533dec8d0d16ef1e9b7fb8cfbd4ed/setup.py#L14-L20 |
biocommons/biocommons.seqrepo | biocommons/seqrepo/fastadir/fabgz.py | _get_bgzip_version | def _get_bgzip_version(exe):
"""return bgzip version as string"""
p = subprocess.Popen([exe, "-h"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True)
output = p.communicate()
version_line = output[0].splitlines()[1]
version = re.match(r"(?:Version:|bgzip \(htslib\))\s+(\d+\.... | python | def _get_bgzip_version(exe):
"""return bgzip version as string"""
p = subprocess.Popen([exe, "-h"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True)
output = p.communicate()
version_line = output[0].splitlines()[1]
version = re.match(r"(?:Version:|bgzip \(htslib\))\s+(\d+\.... | [
"def",
"_get_bgzip_version",
"(",
"exe",
")",
":",
"p",
"=",
"subprocess",
".",
"Popen",
"(",
"[",
"exe",
",",
"\"-h\"",
"]",
",",
"stdout",
"=",
"subprocess",
".",
"PIPE",
",",
"stderr",
"=",
"subprocess",
".",
"STDOUT",
",",
"universal_newlines",
"=",
... | return bgzip version as string | [
"return",
"bgzip",
"version",
"as",
"string"
] | train | https://github.com/biocommons/biocommons.seqrepo/blob/fb6d88682cb73ee6971cfa47d4dcd90a9c649167/biocommons/seqrepo/fastadir/fabgz.py#L32-L38 |
biocommons/biocommons.seqrepo | biocommons/seqrepo/fastadir/fabgz.py | _find_bgzip | def _find_bgzip():
"""return path to bgzip if found and meets version requirements, else exception"""
missing_file_exception = OSError if six.PY2 else FileNotFoundError
min_bgzip_version = ".".join(map(str, min_bgzip_version_info))
exe = os.environ.get("SEQREPO_BGZIP_PATH", which("bgzip") or "/usr/bin/b... | python | def _find_bgzip():
"""return path to bgzip if found and meets version requirements, else exception"""
missing_file_exception = OSError if six.PY2 else FileNotFoundError
min_bgzip_version = ".".join(map(str, min_bgzip_version_info))
exe = os.environ.get("SEQREPO_BGZIP_PATH", which("bgzip") or "/usr/bin/b... | [
"def",
"_find_bgzip",
"(",
")",
":",
"missing_file_exception",
"=",
"OSError",
"if",
"six",
".",
"PY2",
"else",
"FileNotFoundError",
"min_bgzip_version",
"=",
"\".\"",
".",
"join",
"(",
"map",
"(",
"str",
",",
"min_bgzip_version_info",
")",
")",
"exe",
"=",
... | return path to bgzip if found and meets version requirements, else exception | [
"return",
"path",
"to",
"bgzip",
"if",
"found",
"and",
"meets",
"version",
"requirements",
"else",
"exception"
] | train | https://github.com/biocommons/biocommons.seqrepo/blob/fb6d88682cb73ee6971cfa47d4dcd90a9c649167/biocommons/seqrepo/fastadir/fabgz.py#L41-L60 |
biocommons/biocommons.seqrepo | biocommons/seqrepo/seqrepo.py | SeqRepo.fetch_uri | def fetch_uri(self, uri, start=None, end=None):
"""fetch sequence for URI/CURIE of the form namespace:alias, such as
NCBI:NM_000059.3.
"""
namespace, alias = uri_re.match(uri).groups()
return self.fetch(alias=alias, namespace=namespace, start=start, end=end) | python | def fetch_uri(self, uri, start=None, end=None):
"""fetch sequence for URI/CURIE of the form namespace:alias, such as
NCBI:NM_000059.3.
"""
namespace, alias = uri_re.match(uri).groups()
return self.fetch(alias=alias, namespace=namespace, start=start, end=end) | [
"def",
"fetch_uri",
"(",
"self",
",",
"uri",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
")",
":",
"namespace",
",",
"alias",
"=",
"uri_re",
".",
"match",
"(",
"uri",
")",
".",
"groups",
"(",
")",
"return",
"self",
".",
"fetch",
"(",
"ali... | fetch sequence for URI/CURIE of the form namespace:alias, such as
NCBI:NM_000059.3. | [
"fetch",
"sequence",
"for",
"URI",
"/",
"CURIE",
"of",
"the",
"form",
"namespace",
":",
"alias",
"such",
"as",
"NCBI",
":",
"NM_000059",
".",
"3",
"."
] | train | https://github.com/biocommons/biocommons.seqrepo/blob/fb6d88682cb73ee6971cfa47d4dcd90a9c649167/biocommons/seqrepo/seqrepo.py#L102-L109 |
biocommons/biocommons.seqrepo | biocommons/seqrepo/seqrepo.py | SeqRepo.store | def store(self, seq, nsaliases):
"""nsaliases is a list of dicts, like:
[{"namespace": "en", "alias": "rose"},
{"namespace": "fr", "alias": "rose"},
{"namespace": "es", "alias": "rosa"}]
"""
if not self._writeable:
raise RuntimeError("Cannot write --... | python | def store(self, seq, nsaliases):
"""nsaliases is a list of dicts, like:
[{"namespace": "en", "alias": "rose"},
{"namespace": "fr", "alias": "rose"},
{"namespace": "es", "alias": "rosa"}]
"""
if not self._writeable:
raise RuntimeError("Cannot write --... | [
"def",
"store",
"(",
"self",
",",
"seq",
",",
"nsaliases",
")",
":",
"if",
"not",
"self",
".",
"_writeable",
":",
"raise",
"RuntimeError",
"(",
"\"Cannot write -- opened read-only\"",
")",
"if",
"self",
".",
"_upcase",
":",
"seq",
"=",
"seq",
".",
"upper",... | nsaliases is a list of dicts, like:
[{"namespace": "en", "alias": "rose"},
{"namespace": "fr", "alias": "rose"},
{"namespace": "es", "alias": "rosa"}] | [
"nsaliases",
"is",
"a",
"list",
"of",
"dicts",
"like",
":"
] | train | https://github.com/biocommons/biocommons.seqrepo/blob/fb6d88682cb73ee6971cfa47d4dcd90a9c649167/biocommons/seqrepo/seqrepo.py#L112-L172 |
biocommons/biocommons.seqrepo | biocommons/seqrepo/seqrepo.py | SeqRepo.translate_alias | def translate_alias(self, alias, namespace=None, target_namespaces=None, translate_ncbi_namespace=None):
"""given an alias and optional namespace, return a list of all other
aliases for same sequence
"""
if translate_ncbi_namespace is None:
translate_ncbi_namespace = self.t... | python | def translate_alias(self, alias, namespace=None, target_namespaces=None, translate_ncbi_namespace=None):
"""given an alias and optional namespace, return a list of all other
aliases for same sequence
"""
if translate_ncbi_namespace is None:
translate_ncbi_namespace = self.t... | [
"def",
"translate_alias",
"(",
"self",
",",
"alias",
",",
"namespace",
"=",
"None",
",",
"target_namespaces",
"=",
"None",
",",
"translate_ncbi_namespace",
"=",
"None",
")",
":",
"if",
"translate_ncbi_namespace",
"is",
"None",
":",
"translate_ncbi_namespace",
"=",... | given an alias and optional namespace, return a list of all other
aliases for same sequence | [
"given",
"an",
"alias",
"and",
"optional",
"namespace",
"return",
"a",
"list",
"of",
"all",
"other",
"aliases",
"for",
"same",
"sequence"
] | train | https://github.com/biocommons/biocommons.seqrepo/blob/fb6d88682cb73ee6971cfa47d4dcd90a9c649167/biocommons/seqrepo/seqrepo.py#L175-L188 |
biocommons/biocommons.seqrepo | biocommons/seqrepo/seqrepo.py | SeqRepo.translate_identifier | def translate_identifier(self, identifier, target_namespaces=None, translate_ncbi_namespace=None):
"""Given a string identifier, return a list of aliases (as
identifiers) that refer to the same sequence.
"""
namespace, alias = identifier.split(nsa_sep) if nsa_sep in identifier else (Non... | python | def translate_identifier(self, identifier, target_namespaces=None, translate_ncbi_namespace=None):
"""Given a string identifier, return a list of aliases (as
identifiers) that refer to the same sequence.
"""
namespace, alias = identifier.split(nsa_sep) if nsa_sep in identifier else (Non... | [
"def",
"translate_identifier",
"(",
"self",
",",
"identifier",
",",
"target_namespaces",
"=",
"None",
",",
"translate_ncbi_namespace",
"=",
"None",
")",
":",
"namespace",
",",
"alias",
"=",
"identifier",
".",
"split",
"(",
"nsa_sep",
")",
"if",
"nsa_sep",
"in"... | Given a string identifier, return a list of aliases (as
identifiers) that refer to the same sequence. | [
"Given",
"a",
"string",
"identifier",
"return",
"a",
"list",
"of",
"aliases",
"(",
"as",
"identifiers",
")",
"that",
"refer",
"to",
"the",
"same",
"sequence",
"."
] | train | https://github.com/biocommons/biocommons.seqrepo/blob/fb6d88682cb73ee6971cfa47d4dcd90a9c649167/biocommons/seqrepo/seqrepo.py#L191-L201 |
biocommons/biocommons.seqrepo | biocommons/seqrepo/seqrepo.py | SeqRepo._get_unique_seqid | def _get_unique_seqid(self, alias, namespace):
"""given alias and namespace, return seq_id if exactly one distinct
sequence id is found, raise KeyError if there's no match, or
raise ValueError if there's more than one match.
"""
recs = self.aliases.find_aliases(alias=alias, nam... | python | def _get_unique_seqid(self, alias, namespace):
"""given alias and namespace, return seq_id if exactly one distinct
sequence id is found, raise KeyError if there's no match, or
raise ValueError if there's more than one match.
"""
recs = self.aliases.find_aliases(alias=alias, nam... | [
"def",
"_get_unique_seqid",
"(",
"self",
",",
"alias",
",",
"namespace",
")",
":",
"recs",
"=",
"self",
".",
"aliases",
".",
"find_aliases",
"(",
"alias",
"=",
"alias",
",",
"namespace",
"=",
"namespace",
")",
"seq_ids",
"=",
"set",
"(",
"r",
"[",
"\"s... | given alias and namespace, return seq_id if exactly one distinct
sequence id is found, raise KeyError if there's no match, or
raise ValueError if there's more than one match. | [
"given",
"alias",
"and",
"namespace",
"return",
"seq_id",
"if",
"exactly",
"one",
"distinct",
"sequence",
"id",
"is",
"found",
"raise",
"KeyError",
"if",
"there",
"s",
"no",
"match",
"or",
"raise",
"ValueError",
"if",
"there",
"s",
"more",
"than",
"one",
"... | train | https://github.com/biocommons/biocommons.seqrepo/blob/fb6d88682cb73ee6971cfa47d4dcd90a9c649167/biocommons/seqrepo/seqrepo.py#L207-L221 |
biocommons/biocommons.seqrepo | biocommons/seqrepo/seqrepo.py | SeqRepo._update_digest_aliases | def _update_digest_aliases(self, seq_id, seq):
"""compute digest aliases for seq and update; returns number of digest
aliases (some of which may have already existed)
For the moment, sha512 is computed for seq_id separately from
the sha512 here. We should fix that.
"""
... | python | def _update_digest_aliases(self, seq_id, seq):
"""compute digest aliases for seq and update; returns number of digest
aliases (some of which may have already existed)
For the moment, sha512 is computed for seq_id separately from
the sha512 here. We should fix that.
"""
... | [
"def",
"_update_digest_aliases",
"(",
"self",
",",
"seq_id",
",",
"seq",
")",
":",
"ir",
"=",
"bioutils",
".",
"digests",
".",
"seq_vmc_identifier",
"(",
"seq",
")",
"seq_aliases",
"=",
"[",
"{",
"\"namespace\"",
":",
"ir",
"[",
"\"namespace\"",
"]",
",",
... | compute digest aliases for seq and update; returns number of digest
aliases (some of which may have already existed)
For the moment, sha512 is computed for seq_id separately from
the sha512 here. We should fix that. | [
"compute",
"digest",
"aliases",
"for",
"seq",
"and",
"update",
";",
"returns",
"number",
"of",
"digest",
"aliases",
"(",
"some",
"of",
"which",
"may",
"have",
"already",
"existed",
")"
] | train | https://github.com/biocommons/biocommons.seqrepo/blob/fb6d88682cb73ee6971cfa47d4dcd90a9c649167/biocommons/seqrepo/seqrepo.py#L224-L255 |
biocommons/biocommons.seqrepo | biocommons/seqrepo/seqaliasdb/seqaliasdb.py | SeqAliasDB.fetch_aliases | def fetch_aliases(self, seq_id, current_only=True, translate_ncbi_namespace=None):
"""return list of alias annotation records (dicts) for a given seq_id"""
return [dict(r) for r in self.find_aliases(seq_id=seq_id,
current_only=current_only,
... | python | def fetch_aliases(self, seq_id, current_only=True, translate_ncbi_namespace=None):
"""return list of alias annotation records (dicts) for a given seq_id"""
return [dict(r) for r in self.find_aliases(seq_id=seq_id,
current_only=current_only,
... | [
"def",
"fetch_aliases",
"(",
"self",
",",
"seq_id",
",",
"current_only",
"=",
"True",
",",
"translate_ncbi_namespace",
"=",
"None",
")",
":",
"return",
"[",
"dict",
"(",
"r",
")",
"for",
"r",
"in",
"self",
".",
"find_aliases",
"(",
"seq_id",
"=",
"seq_id... | return list of alias annotation records (dicts) for a given seq_id | [
"return",
"list",
"of",
"alias",
"annotation",
"records",
"(",
"dicts",
")",
"for",
"a",
"given",
"seq_id"
] | train | https://github.com/biocommons/biocommons.seqrepo/blob/fb6d88682cb73ee6971cfa47d4dcd90a9c649167/biocommons/seqrepo/seqaliasdb/seqaliasdb.py#L58-L62 |
biocommons/biocommons.seqrepo | biocommons/seqrepo/seqaliasdb/seqaliasdb.py | SeqAliasDB.find_aliases | def find_aliases(self, seq_id=None, namespace=None, alias=None, current_only=True, translate_ncbi_namespace=None):
"""returns iterator over alias annotation records that match criteria
The arguments, all optional, restrict the records that are
returned. Without arguments, all aliases a... | python | def find_aliases(self, seq_id=None, namespace=None, alias=None, current_only=True, translate_ncbi_namespace=None):
"""returns iterator over alias annotation records that match criteria
The arguments, all optional, restrict the records that are
returned. Without arguments, all aliases a... | [
"def",
"find_aliases",
"(",
"self",
",",
"seq_id",
"=",
"None",
",",
"namespace",
"=",
"None",
",",
"alias",
"=",
"None",
",",
"current_only",
"=",
"True",
",",
"translate_ncbi_namespace",
"=",
"None",
")",
":",
"clauses",
"=",
"[",
"]",
"params",
"=",
... | returns iterator over alias annotation records that match criteria
The arguments, all optional, restrict the records that are
returned. Without arguments, all aliases are returned.
If arguments contain %, the `like` comparison operator is
used. Otherwise arguments must match ... | [
"returns",
"iterator",
"over",
"alias",
"annotation",
"records",
"that",
"match",
"criteria",
"The",
"arguments",
"all",
"optional",
"restrict",
"the",
"records",
"that",
"are",
"returned",
".",
"Without",
"arguments",
"all",
"aliases",
"are",
"returned",
"."
] | train | https://github.com/biocommons/biocommons.seqrepo/blob/fb6d88682cb73ee6971cfa47d4dcd90a9c649167/biocommons/seqrepo/seqaliasdb/seqaliasdb.py#L64-L110 |
biocommons/biocommons.seqrepo | biocommons/seqrepo/seqaliasdb/seqaliasdb.py | SeqAliasDB.store_alias | def store_alias(self, seq_id, namespace, alias):
"""associate a namespaced alias with a sequence
Alias association with sequences is idempotent: duplicate
associations are discarded silently.
"""
if not self._writeable:
raise RuntimeError("Cannot write -- opened re... | python | def store_alias(self, seq_id, namespace, alias):
"""associate a namespaced alias with a sequence
Alias association with sequences is idempotent: duplicate
associations are discarded silently.
"""
if not self._writeable:
raise RuntimeError("Cannot write -- opened re... | [
"def",
"store_alias",
"(",
"self",
",",
"seq_id",
",",
"namespace",
",",
"alias",
")",
":",
"if",
"not",
"self",
".",
"_writeable",
":",
"raise",
"RuntimeError",
"(",
"\"Cannot write -- opened read-only\"",
")",
"log_pfx",
"=",
"\"store({q},{n},{a})\"",
".",
"fo... | associate a namespaced alias with a sequence
Alias association with sequences is idempotent: duplicate
associations are discarded silently. | [
"associate",
"a",
"namespaced",
"alias",
"with",
"a",
"sequence"
] | train | https://github.com/biocommons/biocommons.seqrepo/blob/fb6d88682cb73ee6971cfa47d4dcd90a9c649167/biocommons/seqrepo/seqaliasdb/seqaliasdb.py#L123-L157 |
biocommons/biocommons.seqrepo | biocommons/seqrepo/seqaliasdb/seqaliasdb.py | SeqAliasDB._upgrade_db | def _upgrade_db(self):
"""upgrade db using scripts for specified (current) schema version"""
migration_path = "_data/migrations"
sqlite3.connect(self._db_path).close() # ensure that it exists
db_url = "sqlite:///" + self._db_path
backend = yoyo.get_backend(db_url)
migr... | python | def _upgrade_db(self):
"""upgrade db using scripts for specified (current) schema version"""
migration_path = "_data/migrations"
sqlite3.connect(self._db_path).close() # ensure that it exists
db_url = "sqlite:///" + self._db_path
backend = yoyo.get_backend(db_url)
migr... | [
"def",
"_upgrade_db",
"(",
"self",
")",
":",
"migration_path",
"=",
"\"_data/migrations\"",
"sqlite3",
".",
"connect",
"(",
"self",
".",
"_db_path",
")",
".",
"close",
"(",
")",
"# ensure that it exists",
"db_url",
"=",
"\"sqlite:///\"",
"+",
"self",
".",
"_db... | upgrade db using scripts for specified (current) schema version | [
"upgrade",
"db",
"using",
"scripts",
"for",
"specified",
"(",
"current",
")",
"schema",
"version"
] | train | https://github.com/biocommons/biocommons.seqrepo/blob/fb6d88682cb73ee6971cfa47d4dcd90a9c649167/biocommons/seqrepo/seqaliasdb/seqaliasdb.py#L173-L183 |
biocommons/biocommons.seqrepo | biocommons/seqrepo/py2compat/_commonpath.py | commonpath | def commonpath(paths):
"""py2 compatible version of py3's os.path.commonpath
>>> commonpath([""])
''
>>> commonpath(["/"])
'/'
>>> commonpath(["/a"])
'/a'
>>> commonpath(["/a//"])
'/a'
>>> commonpath(["/a", "/a"])
'/a'
>>> commonpath(["/a/b", "/a"])
'/a'
>>> comm... | python | def commonpath(paths):
"""py2 compatible version of py3's os.path.commonpath
>>> commonpath([""])
''
>>> commonpath(["/"])
'/'
>>> commonpath(["/a"])
'/a'
>>> commonpath(["/a//"])
'/a'
>>> commonpath(["/a", "/a"])
'/a'
>>> commonpath(["/a/b", "/a"])
'/a'
>>> comm... | [
"def",
"commonpath",
"(",
"paths",
")",
":",
"assert",
"os",
".",
"sep",
"==",
"\"/\"",
",",
"\"tested only on slash-delimited paths\"",
"split_re",
"=",
"re",
".",
"compile",
"(",
"os",
".",
"sep",
"+",
"\"+\"",
")",
"if",
"len",
"(",
"paths",
")",
"=="... | py2 compatible version of py3's os.path.commonpath
>>> commonpath([""])
''
>>> commonpath(["/"])
'/'
>>> commonpath(["/a"])
'/a'
>>> commonpath(["/a//"])
'/a'
>>> commonpath(["/a", "/a"])
'/a'
>>> commonpath(["/a/b", "/a"])
'/a'
>>> commonpath(["/a/b", "/a/b"])
'... | [
"py2",
"compatible",
"version",
"of",
"py3",
"s",
"os",
".",
"path",
".",
"commonpath"
] | train | https://github.com/biocommons/biocommons.seqrepo/blob/fb6d88682cb73ee6971cfa47d4dcd90a9c649167/biocommons/seqrepo/py2compat/_commonpath.py#L5-L58 |
biocommons/biocommons.seqrepo | biocommons/seqrepo/cli.py | add_assembly_names | def add_assembly_names(opts):
"""add assembly names as aliases to existing sequences
Specifically, associate aliases like GRCh37.p9:1 with existing
refseq accessions
```
[{'aliases': ['chr19'],
'assembly_unit': 'Primary Assembly',
'genbank_ac': 'CM000681.2',
'length': 58617616,
... | python | def add_assembly_names(opts):
"""add assembly names as aliases to existing sequences
Specifically, associate aliases like GRCh37.p9:1 with existing
refseq accessions
```
[{'aliases': ['chr19'],
'assembly_unit': 'Primary Assembly',
'genbank_ac': 'CM000681.2',
'length': 58617616,
... | [
"def",
"add_assembly_names",
"(",
"opts",
")",
":",
"seqrepo_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"opts",
".",
"root_directory",
",",
"opts",
".",
"instance_name",
")",
"sr",
"=",
"SeqRepo",
"(",
"seqrepo_dir",
",",
"writeable",
"=",
"True",
"... | add assembly names as aliases to existing sequences
Specifically, associate aliases like GRCh37.p9:1 with existing
refseq accessions
```
[{'aliases': ['chr19'],
'assembly_unit': 'Primary Assembly',
'genbank_ac': 'CM000681.2',
'length': 58617616,
'name': '19',
'refseq_ac':... | [
"add",
"assembly",
"names",
"as",
"aliases",
"to",
"existing",
"sequences"
] | train | https://github.com/biocommons/biocommons.seqrepo/blob/fb6d88682cb73ee6971cfa47d4dcd90a9c649167/biocommons/seqrepo/cli.py#L200-L265 |
biocommons/biocommons.seqrepo | biocommons/seqrepo/cli.py | snapshot | def snapshot(opts):
"""snapshot a seqrepo data directory by hardlinking sequence files,
copying sqlite databases, and remove write permissions from directories
"""
seqrepo_dir = os.path.join(opts.root_directory, opts.instance_name)
dst_dir = opts.destination_name
if not dst_dir.startswith("/")... | python | def snapshot(opts):
"""snapshot a seqrepo data directory by hardlinking sequence files,
copying sqlite databases, and remove write permissions from directories
"""
seqrepo_dir = os.path.join(opts.root_directory, opts.instance_name)
dst_dir = opts.destination_name
if not dst_dir.startswith("/")... | [
"def",
"snapshot",
"(",
"opts",
")",
":",
"seqrepo_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"opts",
".",
"root_directory",
",",
"opts",
".",
"instance_name",
")",
"dst_dir",
"=",
"opts",
".",
"destination_name",
"if",
"not",
"dst_dir",
".",
"start... | snapshot a seqrepo data directory by hardlinking sequence files,
copying sqlite databases, and remove write permissions from directories | [
"snapshot",
"a",
"seqrepo",
"data",
"directory",
"by",
"hardlinking",
"sequence",
"files",
"copying",
"sqlite",
"databases",
"and",
"remove",
"write",
"permissions",
"from",
"directories"
] | train | https://github.com/biocommons/biocommons.seqrepo/blob/fb6d88682cb73ee6971cfa47d4dcd90a9c649167/biocommons/seqrepo/cli.py#L423-L486 |
learningequality/iceqube | src/iceqube/storage/backends/default.py | BaseBackend.wait_for_job_update | def wait_for_job_update(self, job_id, timeout=None):
"""
Blocks until a job given by job_id has updated its state (canceled, completed, progress updated, etc.)
if timeout is not None, then this function raises iceqube.exceptions.TimeoutError.
:param job_id: the job's job_id to monitor f... | python | def wait_for_job_update(self, job_id, timeout=None):
"""
Blocks until a job given by job_id has updated its state (canceled, completed, progress updated, etc.)
if timeout is not None, then this function raises iceqube.exceptions.TimeoutError.
:param job_id: the job's job_id to monitor f... | [
"def",
"wait_for_job_update",
"(",
"self",
",",
"job_id",
",",
"timeout",
"=",
"None",
")",
":",
"# internally, we register an Event object for each entry in this function.",
"# when self.notify_of_job_update() is called, we call Event.set() on all events",
"# registered for that job, th... | Blocks until a job given by job_id has updated its state (canceled, completed, progress updated, etc.)
if timeout is not None, then this function raises iceqube.exceptions.TimeoutError.
:param job_id: the job's job_id to monitor for changes.
:param timeout: if None, wait forever for a job updat... | [
"Blocks",
"until",
"a",
"job",
"given",
"by",
"job_id",
"has",
"updated",
"its",
"state",
"(",
"canceled",
"completed",
"progress",
"updated",
"etc",
".",
")",
"if",
"timeout",
"is",
"not",
"None",
"then",
"this",
"function",
"raises",
"iceqube",
".",
"exc... | train | https://github.com/learningequality/iceqube/blob/97ac9e0f65bfedb0efa9f94638bcb57c7926dea2/src/iceqube/storage/backends/default.py#L45-L67 |
learningequality/iceqube | src/iceqube/common/utils.py | import_stringified_func | def import_stringified_func(funcstring):
"""
Import a string that represents a module and function, e.g. {module}.{funcname}.
Given a function f, import_stringified_func(stringify_func(f)) will return the same function.
:param funcstring: String to try to import
:return: callable
"""
assert... | python | def import_stringified_func(funcstring):
"""
Import a string that represents a module and function, e.g. {module}.{funcname}.
Given a function f, import_stringified_func(stringify_func(f)) will return the same function.
:param funcstring: String to try to import
:return: callable
"""
assert... | [
"def",
"import_stringified_func",
"(",
"funcstring",
")",
":",
"assert",
"isinstance",
"(",
"funcstring",
",",
"str",
")",
"modulestring",
",",
"funcname",
"=",
"funcstring",
".",
"rsplit",
"(",
"'.'",
",",
"1",
")",
"mod",
"=",
"importlib",
".",
"import_mod... | Import a string that represents a module and function, e.g. {module}.{funcname}.
Given a function f, import_stringified_func(stringify_func(f)) will return the same function.
:param funcstring: String to try to import
:return: callable | [
"Import",
"a",
"string",
"that",
"represents",
"a",
"module",
"and",
"function",
"e",
".",
"g",
".",
"{",
"module",
"}",
".",
"{",
"funcname",
"}",
"."
] | train | https://github.com/learningequality/iceqube/blob/97ac9e0f65bfedb0efa9f94638bcb57c7926dea2/src/iceqube/common/utils.py#L18-L33 |
learningequality/iceqube | src/iceqube/common/utils.py | EventWaitingThread.main_loop | def main_loop(self, timeout=None):
"""
Check if self.trigger_event is set. If it is, then run our function. If not, return early.
:param timeout: How long to wait for a trigger event. Defaults to 0.
:return:
"""
if self.trigger_event.wait(timeout):
try:
... | python | def main_loop(self, timeout=None):
"""
Check if self.trigger_event is set. If it is, then run our function. If not, return early.
:param timeout: How long to wait for a trigger event. Defaults to 0.
:return:
"""
if self.trigger_event.wait(timeout):
try:
... | [
"def",
"main_loop",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"if",
"self",
".",
"trigger_event",
".",
"wait",
"(",
"timeout",
")",
":",
"try",
":",
"self",
".",
"func",
"(",
")",
"except",
"Exception",
"as",
"e",
":",
"self",
".",
"logge... | Check if self.trigger_event is set. If it is, then run our function. If not, return early.
:param timeout: How long to wait for a trigger event. Defaults to 0.
:return: | [
"Check",
"if",
"self",
".",
"trigger_event",
"is",
"set",
".",
"If",
"it",
"is",
"then",
"run",
"our",
"function",
".",
"If",
"not",
"return",
"early",
".",
":",
"param",
"timeout",
":",
"How",
"long",
"to",
"wait",
"for",
"a",
"trigger",
"event",
".... | train | https://github.com/learningequality/iceqube/blob/97ac9e0f65bfedb0efa9f94638bcb57c7926dea2/src/iceqube/common/utils.py#L134-L146 |
learningequality/iceqube | src/iceqube/storage/backends/inmem.py | StorageBackend.set_sqlite_pragmas | def set_sqlite_pragmas(self):
"""
Sets the connection PRAGMAs for the sqlalchemy engine stored in self.engine.
It currently sets:
- journal_mode to WAL
:return: None
"""
def _pragmas_on_connect(dbapi_con, con_record):
dbapi_con.execute("PRAGMA journ... | python | def set_sqlite_pragmas(self):
"""
Sets the connection PRAGMAs for the sqlalchemy engine stored in self.engine.
It currently sets:
- journal_mode to WAL
:return: None
"""
def _pragmas_on_connect(dbapi_con, con_record):
dbapi_con.execute("PRAGMA journ... | [
"def",
"set_sqlite_pragmas",
"(",
"self",
")",
":",
"def",
"_pragmas_on_connect",
"(",
"dbapi_con",
",",
"con_record",
")",
":",
"dbapi_con",
".",
"execute",
"(",
"\"PRAGMA journal_mode = WAL;\"",
")",
"event",
".",
"listen",
"(",
"self",
".",
"engine",
",",
"... | Sets the connection PRAGMAs for the sqlalchemy engine stored in self.engine.
It currently sets:
- journal_mode to WAL
:return: None | [
"Sets",
"the",
"connection",
"PRAGMAs",
"for",
"the",
"sqlalchemy",
"engine",
"stored",
"in",
"self",
".",
"engine",
"."
] | train | https://github.com/learningequality/iceqube/blob/97ac9e0f65bfedb0efa9f94638bcb57c7926dea2/src/iceqube/storage/backends/inmem.py#L78-L91 |
learningequality/iceqube | src/iceqube/storage/backends/inmem.py | StorageBackend.schedule_job | def schedule_job(self, j):
"""
Add the job given by j to the job queue.
Note: Does not actually run the job.
"""
job_id = uuid.uuid4().hex
j.job_id = job_id
session = self.sessionmaker()
orm_job = ORMJob(
id=job_id,
state=j.state,... | python | def schedule_job(self, j):
"""
Add the job given by j to the job queue.
Note: Does not actually run the job.
"""
job_id = uuid.uuid4().hex
j.job_id = job_id
session = self.sessionmaker()
orm_job = ORMJob(
id=job_id,
state=j.state,... | [
"def",
"schedule_job",
"(",
"self",
",",
"j",
")",
":",
"job_id",
"=",
"uuid",
".",
"uuid4",
"(",
")",
".",
"hex",
"j",
".",
"job_id",
"=",
"job_id",
"session",
"=",
"self",
".",
"sessionmaker",
"(",
")",
"orm_job",
"=",
"ORMJob",
"(",
"id",
"=",
... | Add the job given by j to the job queue.
Note: Does not actually run the job. | [
"Add",
"the",
"job",
"given",
"by",
"j",
"to",
"the",
"job",
"queue",
"."
] | train | https://github.com/learningequality/iceqube/blob/97ac9e0f65bfedb0efa9f94638bcb57c7926dea2/src/iceqube/storage/backends/inmem.py#L93-L116 |
learningequality/iceqube | src/iceqube/storage/backends/inmem.py | StorageBackend.mark_job_as_canceling | def mark_job_as_canceling(self, job_id):
"""
Mark the job as requested for canceling. Does not actually try to cancel a running job.
:param job_id: the job to be marked as canceling.
:return: the job object
"""
job, _ = self._update_job_state(job_id, State.CANCELING)
... | python | def mark_job_as_canceling(self, job_id):
"""
Mark the job as requested for canceling. Does not actually try to cancel a running job.
:param job_id: the job to be marked as canceling.
:return: the job object
"""
job, _ = self._update_job_state(job_id, State.CANCELING)
... | [
"def",
"mark_job_as_canceling",
"(",
"self",
",",
"job_id",
")",
":",
"job",
",",
"_",
"=",
"self",
".",
"_update_job_state",
"(",
"job_id",
",",
"State",
".",
"CANCELING",
")",
"return",
"job"
] | Mark the job as requested for canceling. Does not actually try to cancel a running job.
:param job_id: the job to be marked as canceling.
:return: the job object | [
"Mark",
"the",
"job",
"as",
"requested",
"for",
"canceling",
".",
"Does",
"not",
"actually",
"try",
"to",
"cancel",
"a",
"running",
"job",
"."
] | train | https://github.com/learningequality/iceqube/blob/97ac9e0f65bfedb0efa9f94638bcb57c7926dea2/src/iceqube/storage/backends/inmem.py#L127-L136 |
learningequality/iceqube | src/iceqube/storage/backends/inmem.py | StorageBackend.clear | def clear(self, job_id=None, force=False):
"""
Clear the queue and the job data. If job_id is not given, clear out all
jobs marked COMPLETED. If job_id is given, clear out the given job's
data. This function won't do anything if the job's state is not COMPLETED or FAILED.
:type j... | python | def clear(self, job_id=None, force=False):
"""
Clear the queue and the job data. If job_id is not given, clear out all
jobs marked COMPLETED. If job_id is given, clear out the given job's
data. This function won't do anything if the job's state is not COMPLETED or FAILED.
:type j... | [
"def",
"clear",
"(",
"self",
",",
"job_id",
"=",
"None",
",",
"force",
"=",
"False",
")",
":",
"s",
"=",
"self",
".",
"sessionmaker",
"(",
")",
"q",
"=",
"self",
".",
"_ns_query",
"(",
"s",
")",
"if",
"job_id",
":",
"q",
"=",
"q",
".",
"filter_... | Clear the queue and the job data. If job_id is not given, clear out all
jobs marked COMPLETED. If job_id is given, clear out the given job's
data. This function won't do anything if the job's state is not COMPLETED or FAILED.
:type job_id: NoneType or str
:param job_id: the job_id to cle... | [
"Clear",
"the",
"queue",
"and",
"the",
"job",
"data",
".",
"If",
"job_id",
"is",
"not",
"given",
"clear",
"out",
"all",
"jobs",
"marked",
"COMPLETED",
".",
"If",
"job_id",
"is",
"given",
"clear",
"out",
"the",
"given",
"job",
"s",
"data",
".",
"This",
... | train | https://github.com/learningequality/iceqube/blob/97ac9e0f65bfedb0efa9f94638bcb57c7926dea2/src/iceqube/storage/backends/inmem.py#L166-L188 |
learningequality/iceqube | src/iceqube/storage/backends/inmem.py | StorageBackend.update_job_progress | def update_job_progress(self, job_id, progress, total_progress):
"""
Update the job given by job_id's progress info.
:type total_progress: int
:type progress: int
:type job_id: str
:param job_id: The id of the job to update
:param progress: The current progress ac... | python | def update_job_progress(self, job_id, progress, total_progress):
"""
Update the job given by job_id's progress info.
:type total_progress: int
:type progress: int
:type job_id: str
:param job_id: The id of the job to update
:param progress: The current progress ac... | [
"def",
"update_job_progress",
"(",
"self",
",",
"job_id",
",",
"progress",
",",
"total_progress",
")",
":",
"session",
"=",
"self",
".",
"sessionmaker",
"(",
")",
"job",
",",
"orm_job",
"=",
"self",
".",
"_update_job_state",
"(",
"job_id",
",",
"state",
"=... | Update the job given by job_id's progress info.
:type total_progress: int
:type progress: int
:type job_id: str
:param job_id: The id of the job to update
:param progress: The current progress achieved by the job
:param total_progress: The total progress achievable by the... | [
"Update",
"the",
"job",
"given",
"by",
"job_id",
"s",
"progress",
"info",
".",
":",
"type",
"total_progress",
":",
"int",
":",
"type",
"progress",
":",
"int",
":",
"type",
"job_id",
":",
"str",
":",
"param",
"job_id",
":",
"The",
"id",
"of",
"the",
"... | train | https://github.com/learningequality/iceqube/blob/97ac9e0f65bfedb0efa9f94638bcb57c7926dea2/src/iceqube/storage/backends/inmem.py#L190-L224 |
learningequality/iceqube | src/iceqube/storage/backends/inmem.py | StorageBackend.mark_job_as_failed | def mark_job_as_failed(self, job_id, exception, traceback):
"""
Mark the job as failed, and record the traceback and exception.
Args:
job_id: The job_id of the job that failed.
exception: The exception object thrown by the job.
traceback: The traceback, if any... | python | def mark_job_as_failed(self, job_id, exception, traceback):
"""
Mark the job as failed, and record the traceback and exception.
Args:
job_id: The job_id of the job that failed.
exception: The exception object thrown by the job.
traceback: The traceback, if any... | [
"def",
"mark_job_as_failed",
"(",
"self",
",",
"job_id",
",",
"exception",
",",
"traceback",
")",
":",
"session",
"=",
"self",
".",
"sessionmaker",
"(",
")",
"job",
",",
"orm_job",
"=",
"self",
".",
"_update_job_state",
"(",
"job_id",
",",
"State",
".",
... | Mark the job as failed, and record the traceback and exception.
Args:
job_id: The job_id of the job that failed.
exception: The exception object thrown by the job.
traceback: The traceback, if any. Note (aron): Not implemented yet. We need to find a way
for the co... | [
"Mark",
"the",
"job",
"as",
"failed",
"and",
"record",
"the",
"traceback",
"and",
"exception",
".",
"Args",
":",
"job_id",
":",
"The",
"job_id",
"of",
"the",
"job",
"that",
"failed",
".",
"exception",
":",
"The",
"exception",
"object",
"thrown",
"by",
"t... | train | https://github.com/learningequality/iceqube/blob/97ac9e0f65bfedb0efa9f94638bcb57c7926dea2/src/iceqube/storage/backends/inmem.py#L235-L267 |
learningequality/iceqube | src/iceqube/storage/backends/inmem.py | StorageBackend._ns_query | def _ns_query(self, session):
"""
Return a SQLAlchemy query that is already namespaced by the app and namespace given to this backend
during initialization.
Returns: a SQLAlchemy query object
"""
return session.query(ORMJob).filter(ORMJob.app == self.app,
... | python | def _ns_query(self, session):
"""
Return a SQLAlchemy query that is already namespaced by the app and namespace given to this backend
during initialization.
Returns: a SQLAlchemy query object
"""
return session.query(ORMJob).filter(ORMJob.app == self.app,
... | [
"def",
"_ns_query",
"(",
"self",
",",
"session",
")",
":",
"return",
"session",
".",
"query",
"(",
"ORMJob",
")",
".",
"filter",
"(",
"ORMJob",
".",
"app",
"==",
"self",
".",
"app",
",",
"ORMJob",
".",
"namespace",
"==",
"self",
".",
"namespace",
")"... | Return a SQLAlchemy query that is already namespaced by the app and namespace given to this backend
during initialization.
Returns: a SQLAlchemy query object | [
"Return",
"a",
"SQLAlchemy",
"query",
"that",
"is",
"already",
"namespaced",
"by",
"the",
"app",
"and",
"namespace",
"given",
"to",
"this",
"backend",
"during",
"initialization",
".",
"Returns",
":",
"a",
"SQLAlchemy",
"query",
"object"
] | train | https://github.com/learningequality/iceqube/blob/97ac9e0f65bfedb0efa9f94638bcb57c7926dea2/src/iceqube/storage/backends/inmem.py#L304-L312 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.