Skip to content

Commit

Permalink
[utils] Use if/else instead of match/case statement for py39 support
Browse files Browse the repository at this point in the history
  • Loading branch information
anjos committed Nov 3, 2024
1 parent 01e887c commit d0e73a3
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/pelican/plugins/pybtex/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,17 +157,16 @@ def generate_context(
import pybtex.backends.html
import pybtex.database

match style_name:
case "plain" | "alpha" | "unsrt" | "unsrtalpha":
formatter = importlib.import_module(f"pybtex.style.formatting.{style_name}")
style = formatter.Style()
case _:
logger.error(
f"Unsupported formatting style `{style_name}`, defaulting to `plain`"
)
import pybtex.style.formatting.plain

style = pybtex.style.formatting.plain.Style()
if style_name in ("plain", "alpha", "unsrt", "unsrtalpha"):
formatter = importlib.import_module(f"pybtex.style.formatting.{style_name}")
style = formatter.Style()
else:
logger.error(
f"Unsupported formatting style `{style_name}`, defaulting to `plain`"
)
import pybtex.style.formatting.plain

style = pybtex.style.formatting.plain.Style()

# format all entries in a single shot for speed and meaningful labels
all_entries = [e for k in bibdata for e in k.entries.values()]
Expand Down

0 comments on commit d0e73a3

Please sign in to comment.