fix
This commit is contained in:
parent
2c9ea743a3
commit
d517e48e8c
@ -35,6 +35,9 @@ class PostNotFound(Exception):
|
|||||||
class NoPostsLeft(Exception):
|
class NoPostsLeft(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
class PostTypeMismatch(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class PostType(Enum):
|
class PostType(Enum):
|
||||||
ARTICLE = 'article'
|
ARTICLE = 'article'
|
||||||
@ -290,9 +293,9 @@ async def do_send(type: Optional[PostType] = None,
|
|||||||
if db.is_already_published(filename):
|
if db.is_already_published(filename):
|
||||||
continue
|
continue
|
||||||
post = Post(filename)
|
post = Post(filename)
|
||||||
if post.type == type:
|
if post.type != type:
|
||||||
break
|
raise PostTypeMismatch()
|
||||||
post = None
|
break
|
||||||
|
|
||||||
if not post:
|
if not post:
|
||||||
raise NoPostsLeft()
|
raise NoPostsLeft()
|
||||||
@ -404,7 +407,7 @@ if __name__ == '__main__':
|
|||||||
asyncio.run(do_send(type=PostType(args.type) if args.type else None,
|
asyncio.run(do_send(type=PostType(args.type) if args.type else None,
|
||||||
mark_as_published=args.prod or args.mark,
|
mark_as_published=args.prod or args.mark,
|
||||||
post_name=args.name))
|
post_name=args.name))
|
||||||
except NoPostsLeft:
|
except (NoPostsLeft, PostTypeMismatch):
|
||||||
logger.warning('no unpublished posts matching the current mode criteria')
|
logger.warning('no unpublished posts matching the current mode criteria')
|
||||||
break
|
break
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user