Skip to content

Commit 1f98bb9

Browse files
committed
Provide extended API for Frontier
1 parent f611720 commit 1f98bb9

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

pytest.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[pytest]
2-
addopts = --doctest-modules --doctest-glob='scrapinghub/*.py'
2+
addopts = --doctest-glob='scrapinghub/*.py'

scrapinghub/client.py

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
from .hubstorage.resourcetype import ItemsResourceType
1212

1313
# scrapinghub.hubstorage classes to use as-is
14-
from .hubstorage.frontier import Frontier
1514
from .hubstorage.job import JobMeta
1615
from .hubstorage.project import Settings
1716

1817
# scrapinghub.hubstorage proxied classes
1918
from .hubstorage.activity import Activity as _Activity
2019
from .hubstorage.collectionsrt import Collections as _Collections
2120
from .hubstorage.collectionsrt import Collection as _Collection
21+
from .hubstorage.frontier import Frontier as _Frontier
2222
from .hubstorage.job import Items as _Items
2323
from .hubstorage.job import Logs as _Logs
2424
from .hubstorage.job import Samples as _Samples
@@ -227,7 +227,7 @@ def __init__(self, client, projectid):
227227
# proxied sub-resources
228228
self.activity = Activity(_Activity, client, projectid)
229229
self.collections = Collections(_Collections, client, projectid)
230-
self.frontier = Frontier(client._hsclient, projectid)
230+
self.frontier = Frontier(_Frontier, client, projectid)
231231
self.settings = Settings(client._hsclient, projectid)
232232

233233

@@ -1084,6 +1084,31 @@ def list(self):
10841084
return list(self.iter())
10851085

10861086

1087+
class Frontier(_Proxy):
1088+
"""Frontiers collection for a project."""
1089+
1090+
def __init__(self, *args, **kwargs):
1091+
super(Frontier, self).__init__(*args, **kwargs)
1092+
self._proxy_methods(['close', 'flush', 'add', 'read', 'delete',
1093+
'delete_slot'])
1094+
1095+
@property
1096+
def newcount(self):
1097+
return self._origin.newcount
1098+
1099+
def iter(self):
1100+
return iter(self.list())
1101+
1102+
def list(self):
1103+
return next(self._origin.apiget('list'))
1104+
1105+
def iter_slots(self, name):
1106+
return iter(self.list_slots(name))
1107+
1108+
def list_slots(self, name):
1109+
return next(self._origin.apiget((name, 'list')))
1110+
1111+
10871112
class Collection(object):
10881113
"""Representation of a project collection object.
10891114

0 commit comments

Comments
 (0)