repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_documentation_string stringlengths 1 47.2k | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|
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:... | 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... | 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
... | 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.
... | 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... | 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... | 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
... | 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,
... | 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``.... | 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``,
... | 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... | 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
... | 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... | 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... | 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.
... | 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... | 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... | 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... | 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 ... | 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:
... | 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... | 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... | 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. ... | 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... | 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... | 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 | 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:
... | 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 | 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:
... | 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 | 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... | 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:... | 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:... | 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 | 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... | 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:... | 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 | Convert to json if it isn't already a string.
Args:
data (str): data to convert to json | 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... | 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 | 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... | 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... | 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
... | 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... | 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... | 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 ... | 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
... | 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... | 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)... | 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... | 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) | Given a file object *fileobj*, get an ElementTree instance.
The *encoding* is assumed to be utf8. | 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... | fetch sequence by seq_id, optionally with start, end bounds | 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... | 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. | 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... | 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... | 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)
... | 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... | 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... | Extract a raw_connection and determine if it should be automatically closed.
Only connections opened by this package will be closed automatically. | 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) | cheapo replacement for py3 makedirs with support for exist_ok | 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... | fetch a sequence in a thread | 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... | Run install process. | 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... | Download and install RPM Python binding. | 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]) | Git branch name. | 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 = [
{
... | 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. | 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... | Apply replaced words and patches, and save setup.py file. | 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.
... | Download and expand RPM Python binding. | 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... | Run install main logic. | 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... | 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/... | 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... | 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
... | 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 ... | 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... | 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... | Check if the RPM Python binding has a depndency to popt-devel.
Search include header files in the source code to check it. | 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... | Run install main logic. | 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... | Run install from RPM Python binding RPM package. | 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 | Get OS object. | 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... | Verify system status. | 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... | Verify dependency RPM package status. | 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) | Create Installer object. | 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) | Create Installer object. | 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) | Both arch and non-arch site-packages directories. | 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... | 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. | 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 ... | Check if the Python binding has already installed. | 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 | RPM vesion string. | 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... | Check if the RPM is system RPM. | 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,
... | Check if the RPM package is installed. | 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... | Check if the RPM packages are installed.
Raise InstallError if any of the packages is not installed. | 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... | Return standard library directory path used by RPM libs.
TODO: Support non-system RPM. | 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... | Return if rpm is downloadable by the package command.
Check if dnf or yum plugin package exists. | 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... | Download given package. | 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, ... | Extract given package. | 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... | Return standard library directory path used by RPM libs. | 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()
... | Run the command. It behaves like "sh -e".
It raises InstallError if the command failed. | 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] | Run the command. and returns the stdout. | 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) | Change directory. It behaves like "cd directory". | 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
... | Change directory, and back to previous directory.
It behaves like "pushd directory; something; popd". | 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... | Return an absolute path of the command.
It behaves like "which command". | 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):
... | 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. | 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... | 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. | 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,
... | Find matched files.
It does not include symbolic file in the result. | 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_... | Version info.
tuple object. ex. ('4', '14', '0', 'rc1') | 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
... | generator that returns (header, sequence) tuples from an open FASTA file handle
Lines before the start of the first record are ignored. | 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 | >>> which("sh") is not None
True
>>> which("bogus-executable-that-doesn't-exist") is None
True | 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)) | Install RPM Python binding. | 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+\.... | return bgzip version as string | 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... | return path to bgzip if found and meets version requirements, else exception | 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) | fetch sequence for URI/CURIE of the form namespace:alias, such as
NCBI:NM_000059.3. | 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 --... | nsaliases is a list of dicts, like:
[{"namespace": "en", "alias": "rose"},
{"namespace": "fr", "alias": "rose"},
{"namespace": "es", "alias": "rosa"}] | 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... | given an alias and optional namespace, return a list of all other
aliases for same sequence | 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... | Given a string identifier, return a list of aliases (as
identifiers) that refer to the same sequence. | 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... | 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. | 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.
"""
... | 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. | 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,
... | return list of alias annotation records (dicts) for a given seq_id | 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... | 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 ... | 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... | associate a namespaced alias with a sequence
Alias association with sequences is idempotent: duplicate
associations are discarded silently. | 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... | upgrade db using scripts for specified (current) schema version | 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... | 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"])
'... | 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,
... | 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':... | 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("/")... | snapshot a seqrepo data directory by hardlinking sequence files,
copying sqlite databases, and remove write permissions from directories | 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... | 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... | 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... | 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 | 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:
... | 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: | 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... | Sets the connection PRAGMAs for the sqlalchemy engine stored in self.engine.
It currently sets:
- journal_mode to WAL
:return: None | 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,... | Add the job given by j to the job queue.
Note: Does not actually run the job. | 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)
... | 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 | 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... | 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... | 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... | 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... | 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... | 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... | 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,
... | Return a SQLAlchemy query that is already namespaced by the app and namespace given to this backend
during initialization.
Returns: a SQLAlchemy query object | 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.