Opt: Improve assignment log appearance

This commit is contained in:
LmeSzinc 2023-09-16 01:52:33 +08:00
parent 01cf806385
commit cb5aa5c949
2 changed files with 11 additions and 3 deletions

View File

@ -88,11 +88,13 @@ class Assignment(AssignmentClaim, SynthesizeUI):
"""
if not assignments:
return
logger.hr('Assignment check inlist', level=2)
logger.hr('Assignment check inlist', level=1)
logger.info(
f'User specified assignments: {", ".join([x.name for x in assignments])}')
_, remain, _ = self._limit_status
for assignment in assignments:
logger.hr('Assignment inlist', level=2)
logger.info(f'Check assignment inlist: {assignment}')
self.goto_entry(assignment)
if self.appear(CLAIM):
self.claim(assignment, duration, should_redispatch=True)
@ -115,7 +117,7 @@ class Assignment(AssignmentClaim, SynthesizeUI):
3. Dispatchable
Break when a dispatchable assignment is encountered
"""
logger.hr('Assignment check all', level=2)
logger.hr('Assignment check all', level=1)
_, remain, total = self._limit_status
if total == len(self.dispatched):
return remain
@ -126,6 +128,8 @@ class Assignment(AssignmentClaim, SynthesizeUI):
assignment = next(entries)
if assignment in self.dispatched:
continue
logger.hr('Assignment all', level=2)
logger.info(f'Check assignment all: {assignment}')
self.goto_entry(assignment)
if self.appear(CLAIM):
self.claim(assignment, None, should_redispatch=False)

View File

@ -62,11 +62,15 @@ class AssignmentOcr(Ocr):
def after_process(self, result: str):
result = super().after_process(result)
# Drop duration
result = Duration.timedelta_regex(self.lang).sub('', result)
result = result.strip()
if self.lang == 'cn':
# Hourglass icon may be detected as "豆"
result = result.replace('', '')
result = re.sub(r'\d$', '', result)
if self.ocr_regex is None:
return result
matched = self.ocr_regex.fullmatch(result)