Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/storage.py
Show First 20 Lines • Show All 1,122 Lines • ▼ Show 20 Lines | def origin_get(self, origin, db=None, cur=None): | ||||
raise ValueError('Origin must have either id or (type and url).') | raise ValueError('Origin must have either id or (type and url).') | ||||
if ori: | if ori: | ||||
return dict(zip(self.origin_keys, ori)) | return dict(zip(self.origin_keys, ori)) | ||||
return None | return None | ||||
@db_transaction_generator() | @db_transaction_generator() | ||||
def origin_search(self, url_pattern, offset=0, limit=50, | def origin_search(self, url_pattern, offset=0, limit=50, | ||||
regexp=False, db=None, cur=None): | regexp=False, with_visit=False, db=None, cur=None): | ||||
"""Search for origins whose urls contain a provided string pattern | """Search for origins whose urls contain a provided string pattern | ||||
or match a provided regular expression. | or match a provided regular expression. | ||||
The search is performed in a case insensitive way. | The search is performed in a case insensitive way. | ||||
Args: | Args: | ||||
url_pattern: the string pattern to search for in origin urls | url_pattern (str): the string pattern to search for in origin urls | ||||
offset: number of found origins to skip before returning results | offset (int): number of found origins to skip before returning | ||||
limit: the maximum number of found origins to return | results | ||||
regexp: if True, consider the provided pattern as a regular | limit (int): the maximum number of found origins to return | ||||
regexp (bool): if True, consider the provided pattern as a regular | |||||
expression and return origins whose urls match it | expression and return origins whose urls match it | ||||
with_visit (bool): if True, filter out origins with no visit | |||||
Returns: | Returns: | ||||
An iterable of dict containing origin information as returned | An iterable of dict containing origin information as returned | ||||
by :meth:`swh.storage.storage.Storage.origin_get`. | by :meth:`swh.storage.storage.Storage.origin_get`. | ||||
""" | """ | ||||
for origin in db.origin_search(url_pattern, offset, limit, | for origin in db.origin_search(url_pattern, offset, limit, | ||||
regexp, cur): | regexp, with_visit, cur): | ||||
yield dict(zip(self.origin_keys, origin)) | yield dict(zip(self.origin_keys, origin)) | ||||
@db_transaction() | @db_transaction() | ||||
def _person_add(self, person, db=None, cur=None): | def _person_add(self, person, db=None, cur=None): | ||||
"""Add a person in storage. | """Add a person in storage. | ||||
Note: Internal function for now, do not use outside of this module. | Note: Internal function for now, do not use outside of this module. | ||||
▲ Show 20 Lines • Show All 389 Lines • Show Last 20 Lines |