fix: task slicing range

This commit is contained in:
2026-08-27 15:55:28 +08:00
parent 157dd985a8
commit c8975875b1
2 changed files with 19 additions and 17 deletions
+11 -9
View File
@@ -65,11 +65,13 @@ def main(driver: Chrome, logger = logging.getLogger('main')):
wb: Workbook = None
filename: str = None
column: ColumnMapping = None
limit = 0
start, end, limit = 2, 0, 0
def begin(opts: dict, args: dict):
nonlocal status
def begin(opts: dict, args: dict, i, j):
nonlocal status, start, end
if status != Status.READY: raise ValueError(status)
if i: start += i
if j: end = j
options.update(opts)
status = Status.RUNNING
parameters.update(args)
@@ -91,7 +93,7 @@ def main(driver: Chrome, logger = logging.getLogger('main')):
result = dict()
col = headers.index(header) + 1
for row in range(options.get('start'), limit + 1):
for row in range(start, limit + 1):
key = str(wb.active.cell(row, col).value)
result[key] = result.get(key, 0) + 1
@@ -315,7 +317,7 @@ def main(driver: Chrome, logger = logging.getLogger('main')):
source = load_workbook(buffer)
source.active.cell(1, col).value = column.sent
for row in range(options.get('start'), limit + 1):
for row in range(start, limit + 1):
c1 = source.active.cell(row, col)
c2 = wb.active.cell(row, col)
if not (c1.value and str(c1.value).strip()):
@@ -403,13 +405,13 @@ def main(driver: Chrome, logger = logging.getLogger('main')):
logger.warning("[%d/%d] Exhausted all allowed attempts; skipping", index-1, limit-1)
raise Skip()
if options.get('slice') and (start := options.get('start')) and (end := options.get('limit')):
if index < start or index >= start + end:
logger.info("[%d/%d] Not planned; skipping '%s'", index-1, limit-1, email)
raise Next()
if options.get('slice'):
if (items := options.get('subcategories')) and (item := str(cell(index, column.region).value)) not in items:
logger.info("[%d/%d] Value '%s' not enlisted; skipping '%s'", index-1, limit-1, item, email)
raise Next()
if index < start or index >= start + end:
logger.info("[%d/%d] Not planned; skipping '%s'", index-1, limit-1, email)
raise Next()
if (sent := cell(index, column.sent).value) is not None and str(sent).strip():
logger.info("[%d/%d] Already visited; skipping '%s'", index-1, limit-1, email)