Skip to content

feat(puid): add custom lookup table in config#32

Merged
vEnhance merged 4 commits intovEnhance:mainfrom
extouchtriangle:main
Mar 17, 2025
Merged

feat(puid): add custom lookup table in config#32
vEnhance merged 4 commits intovEnhance:mainfrom
extouchtriangle:main

Conversation

@extouchtriangle
Copy link
Copy Markdown
Contributor

@extouchtriangle extouchtriangle commented Mar 16, 2025

This is in response to a conversation on the OTIS discord about adding a custom lookup table in rc.py.

@extouchtriangle
Copy link
Copy Markdown
Contributor Author

yay it looks like pyright and ruff diagnostics in nvim have worked

Comment thread von/rc.py Outdated
@vEnhance
Copy link
Copy Markdown
Owner

made some changes:

  • I think lookup doesn't feel right for the name on a config file, so I changed it to abbreviations which is more intuitive. lookup is the internal variable name, imo
  • used config.get('lookup', {}) which is shorter (one line rather than four)
  • I think in the example we shouldn't use python dictionary format, imo the point of YAML is to be human readable. the following is arguably easier to read:
abbreviations:
  Inter Galaxy Math Olympiad: IGMO
  Inter Universe Math Olympiad: IUMO

Overall diff:

diff --git a/von/rc.py b/von/rc.py
index c6708c5..4c3560b 100644
--- a/von/rc.py
+++ b/von/rc.py
@@ -51,12 +51,12 @@ tags: ["trivial", "easy", "medium", "hard", "brutal"]
 # By default, it detects from $EDITOR automatically
 # editor: vim
 
-# If you would like to define a custom contest name
-# (to be used in the PUID script), then you should
-# define it here. This will also override any "standard"
-# lookups in `puid.py`. (This should be in python dictionary
-# format)
-# lookup: {"contest-1": "abbreviation-1", "contest-2": "abbreviation-2"}
+# If you would like to define a custom contest name (to be used in the PUID script),
+# then you should define it here.
+# This will also override any "standard" lookups in `puid.py`.
+# abbreviations:
+#   Inter Galaxy Math Olympiad: IGMO
+#   Inter Universe Math Olympiad: IUMO
 """
 
 if not CONFIG_DIR.exists():
@@ -120,10 +120,7 @@ elif sys.platform.startswith("darwin"):
 else:
     USER_OS = "linux"  # including cygwin
 
-if (custom_lookup := config.get("lookup")) is not None:
-    VON_CUSTOM_LOOKUP = custom_lookup
-else:
-    VON_CUSTOM_LOOKUP = {}
+VON_CUSTOM_LOOKUP = config.get("abbreviations", {})
 
 # These used to be editable but I don't think it's worth it
 VON_INDEX_NAME = "index"

let me know if that looks OK then we can merge this

@extouchtriangle
Copy link
Copy Markdown
Contributor Author

Yeah, this looks good.

@vEnhance vEnhance merged commit dded9a8 into vEnhance:main Mar 17, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants