File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3131
3232COMMENT_CONFIG_REGEX = re .compile (r"<COMMENT>" )
3333
34+ EXISTING_LANGUAGE_REGEX = re .compile (r"^lang = \"(\w+)\"$" , re .MULTILINE )
3435
35- def main (language : str = "rust" ) -> None :
36+
37+ def main (language : str ) -> None :
3638 cj = browser_cookie3 .chrome (domain_name = LEETCODE_DOMAIN_NAME )
3739 cookies = {c .name : c .value for c in cj }
3840
3941 csrftoken = cookies [CSRFTOKEN_KEY ]
4042 leetcode_session = cookies [LEETCODE_SESSION_KEY ]
4143
44+ with open (INITIAL_CONFIG_LOCATION , "r" ) as f :
45+ content = f .read ()
46+
47+ # If the language isn't provided, take the language from the current config
48+ if language is None and os .path .exists (TARGET_CONFIG_LOCATION ):
49+ with open (TARGET_CONFIG_LOCATION ) as f :
50+ if match := re .search (EXISTING_LANGUAGE_REGEX , f .read ()):
51+ language = match .groups ()[0 ]
52+
4253 language_stubs = []
4354 if os .path .exists (f"{ STUBS_LOCATION } /{ language } .txt" ):
4455 language_stubs = [
You can’t perform that action at this time.
0 commit comments