This commit is contained in:
E. S 2025-03-29 01:30:54 +03:00
parent 2c9ea743a3
commit d517e48e8c

View File

@ -35,6 +35,9 @@ class PostNotFound(Exception):
class NoPostsLeft(Exception):
pass
class PostTypeMismatch(Exception):
pass
class PostType(Enum):
ARTICLE = 'article'
@ -290,9 +293,9 @@ async def do_send(type: Optional[PostType] = None,
if db.is_already_published(filename):
continue
post = Post(filename)
if post.type == type:
break
post = None
if post.type != type:
raise PostTypeMismatch()
break
if not post:
raise NoPostsLeft()
@ -404,7 +407,7 @@ if __name__ == '__main__':
asyncio.run(do_send(type=PostType(args.type) if args.type else None,
mark_as_published=args.prod or args.mark,
post_name=args.name))
except NoPostsLeft:
except (NoPostsLeft, PostTypeMismatch):
logger.warning('no unpublished posts matching the current mode criteria')
break