aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2019-12-11 19:04:11 -0800
committerBryan Newbold <bnewbold@robocracy.org>2019-12-12 12:25:38 -0800
commit05ff94448b93d3d2afd045e943fcf18b7dd85b95 (patch)
treea088fb4c79dbbce87822f5398d08b894f63e0b8e /python
parent374ed6ccac6191461616ac3df85daf3a3a9ab2ed (diff)
downloadfatcat-05ff94448b93d3d2afd045e943fcf18b7dd85b95.tar.gz
fatcat-05ff94448b93d3d2afd045e943fcf18b7dd85b95.zip
EntityImporter: submit (not accept) mode
For use with bots that don't have admin privileges, or where human follow-up review is desired.
Diffstat (limited to 'python')
-rw-r--r--python/fatcat_tools/importers/common.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/python/fatcat_tools/importers/common.py b/python/fatcat_tools/importers/common.py
index c0740f94..2971660f 100644
--- a/python/fatcat_tools/importers/common.py
+++ b/python/fatcat_tools/importers/common.py
@@ -271,6 +271,11 @@ class EntityImporter:
if didn't update or insert because of existing)
self.counts['update'] += 1
if updated an entity
+
+ Parameters:
+
+ submit_mode: instead of accepting editgroups, only submits them.
+ implementors must write insert_batch appropriately
"""
def __init__(self, api, **kwargs):
@@ -282,6 +287,7 @@ class EntityImporter:
self.api = api
self.bezerk_mode = kwargs.get('bezerk_mode', False)
+ self.submit_mode = kwargs.get('submit_mode', False)
self.edit_batch_size = kwargs.get('edit_batch_size', 100)
self.editgroup_description = kwargs.get('editgroup_description')
self.editgroup_extra = eg_extra
@@ -325,7 +331,10 @@ class EntityImporter:
def finish(self):
if self._edit_count > 0:
- self.api.accept_editgroup(self._editgroup_id)
+ if self.submit_mode:
+ self.api.submit_editgroup(self._editgroup_id)
+ else:
+ self.api.accept_editgroup(self._editgroup_id)
self._editgroup_id = None
self._edit_count = 0
self._edits_inflight = []
@@ -339,7 +348,10 @@ class EntityImporter:
def get_editgroup_id(self, edits=1):
if self._edit_count >= self.edit_batch_size:
- self.api.accept_editgroup(self._editgroup_id)
+ if self.submit_mode:
+ self.api.submit_editgroup(self._editgroup_id)
+ else:
+ self.api.accept_editgroup(self._editgroup_id)
self._editgroup_id = None
self._edit_count = 0
self._edits_inflight = []