Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9337386
D1286.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Subscribers
None
D1286.diff
View Options
diff --git a/swh-team/swh-weekly-report b/swh-team/swh-weekly-report
--- a/swh-team/swh-weekly-report
+++ b/swh-team/swh-weekly-report
@@ -6,53 +6,9 @@
from datetime import datetime
from dateutil.relativedelta import relativedelta
-from functools import lru_cache
from phabricator import Phabricator
-
-def paginate(query, args, stop):
- """perform a query paginating through results until stop condition is met
-
- """
- def do_query():
- after = '0'
- keep_going = True
- while keep_going:
- r = query(**args, after=after)
- if not(r['data']):
- break
- for item in r['data']:
- if stop(item):
- keep_going = False
- break
- yield item
-
- after = r['cursor']['after']
-
- return list(do_query())
-
-
-@lru_cache()
-def lookup_repo(phab, repo_phid):
- """lookup Phabricator repository by PHID
-
- """
- return phab.phid.query(phids=[repo_phid])[repo_phid]
-
-
-def pp_repo(repo):
- """pretty print a short name for a given repository
-
- """
- return repo['uri'].split('/')[-2]
-
-
-@lru_cache()
-def whoami(phab):
- """return current user's PHID
-
- """
- return phab.user.whoami()['phid']
+from swhphab import paginate, lookup_repo, pp_repo, whoami
def list_tasks(phab, newer_than):
diff --git a/swh-team/swhphab.py b/swh-team/swhphab.py
new file mode 100644
--- /dev/null
+++ b/swh-team/swhphab.py
@@ -0,0 +1,47 @@
+
+from functools import lru_cache
+
+
+def paginate(query, args, stop):
+ """perform a query paginating through results until stop condition is met
+
+ """
+ def do_query():
+ after = '0'
+ keep_going = True
+ while keep_going:
+ r = query(**args, after=after)
+ if not(r['data']):
+ break
+ for item in r['data']:
+ if stop(item):
+ keep_going = False
+ break
+ yield item
+
+ after = r['cursor']['after']
+
+ return list(do_query())
+
+
+@lru_cache()
+def lookup_repo(phab, repo_phid):
+ """lookup Phabricator repository by PHID
+
+ """
+ return phab.phid.query(phids=[repo_phid])[repo_phid]
+
+
+def pp_repo(repo):
+ """pretty print a short name for a given repository
+
+ """
+ return repo['uri'].split('/')[-2]
+
+
+@lru_cache()
+def whoami(phab):
+ """return current user's PHID
+
+ """
+ return phab.user.whoami()['phid']
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Jul 3 2025, 8:03 AM (10 w, 2 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3216841
Attached To
D1286: swh-monthly-report: helper script to draft monthly activity team reports
Event Timeline
Log In to Comment