Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit e08fe61

Browse files
committed
added a bash script for myself
1 parent c146961 commit e08fe61

File tree

3 files changed

+22
-23
lines changed

3 files changed

+22
-23
lines changed

lc.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
VENV_ACTIVATE="/d/prog/leetcode.py/venv/Scripts/activate"
3+
source "$VENV_ACTIVATE"
4+
python "/d/prog/leetcode.py/main.py" "$@"
5+

main.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def print_question_data(question):
3838
elif difficulty == "Hard":
3939
difficulty_color = Colors.RED
4040
title_width = 50
41-
difficulty_width = 10
41+
difficulty_width = 1
4242
title_formatted = title.ljust(title_width)[:title_width]
4343
difficulty_formatted = (
4444
f"{difficulty_color}{difficulty.ljust(difficulty_width)}{Colors.RESET}"
@@ -455,7 +455,7 @@ def get_available_languages_and_code_snippets(question_detail_data):
455455
return available_languages
456456

457457

458-
def display_question_detail(api_instance, title_slug): #did changes here
458+
def display_question_detail(api_instance, title_slug): # did changes here
459459
question_detail_data = get_question_detail(api_instance, title_slug)
460460
if question_detail_data:
461461
question_url = f"https://leetcode.com/problems/{title_slug}/"
@@ -465,12 +465,17 @@ def display_question_detail(api_instance, title_slug): #did changes here
465465
content_text = BeautifulSoup(content_html, "html.parser").get_text()
466466
print("Question Content:\n", content_text)
467467

468-
user_lang,editor_cli = load_user_data_from_config() # Load the USER_LANG from config
468+
(
469+
user_lang,
470+
editor_cli,
471+
) = load_user_data_from_config() # Load the USER_LANG from config
469472
if user_lang:
470-
file_path = write_code_snippet_to_file(question_detail_data, user_lang, title_slug)
473+
file_path = write_code_snippet_to_file(
474+
question_detail_data, user_lang, title_slug
475+
)
471476
# write_code_snippet_to_file(question_detail_data, user_lang, title_slug)
472477
input("Press any key to continue...")
473-
os.system(f"{editor_cli} {file_path}")
478+
os.system(f"{editor_cli} {file_path}")
474479
else:
475480
available_languages = get_available_languages_and_code_snippets(
476481
question_detail_data
@@ -499,8 +504,6 @@ def display_question_detail(api_instance, title_slug): #did changes here
499504
except ValueError:
500505
print("Invalid input. Please enter a valid index.")
501506

502-
503-
504507

505508
def write_code_snippet_to_file(question_detail_data, lang, title_slug): # tags:path
506509
code_snippets = question_detail_data.get("codeSnippets", [])
@@ -517,7 +520,7 @@ def write_code_snippet_to_file(question_detail_data, lang, title_slug): # tags:
517520
leetcode_folder = os.path.join(home_directory, ".leetcode")
518521
else:
519522
leetcode_folder = leetcode_path
520-
523+
521524
if not os.path.exists(leetcode_folder):
522525
os.makedirs(leetcode_folder)
523526
file_path = os.path.join(
@@ -534,7 +537,6 @@ def write_code_snippet_to_file(question_detail_data, lang, title_slug): # tags:
534537
print(f"Code snippet for {lang} is not available for this question.")
535538

536539

537-
538540
def get_title_slug_from_filename(filepath):
539541
base_name = os.path.basename(filepath)
540542
title_slug, _ = os.path.splitext(base_name)
@@ -649,9 +651,11 @@ def replace_files():
649651
help="Specify the filename containing the code to be submitted",
650652
)
651653
@click.option(
652-
"--help","-h" ,is_flag=True, default=False, help="Show usage information"
654+
"--help", "-h", is_flag=True, default=False, help="Show usage information"
653655
)
654-
def main(config, user_lang, user_path ,question, solve, test, submit, lib,help): # remove help_cmd
656+
def main(
657+
config, user_lang, user_path, question, solve, test, submit, lib, help
658+
): # remove help_cmd
655659
if lib:
656660
replace_files()
657661
exit()
@@ -661,7 +665,7 @@ def main(config, user_lang, user_path ,question, solve, test, submit, lib,help):
661665
if user_lang:
662666
save_user_data_to_config(user_lang)
663667
exit()
664-
#allow user to enter their preferred path
668+
# allow user to enter their preferred path
665669
elif user_path:
666670
save_user_path_to_config(user_path)
667671
exit()

requirements.txt

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,12 @@
11
beautifulsoup4==4.12.2
2-
black==23.7.0
32
certifi==2023.7.22
43
charset-normalizer==3.2.0
5-
click==8.1.6
4+
click==8.1.7
65
colorama==0.4.6
76
idna==3.4
8-
markdown-it-py==3.0.0
9-
mdurl==0.1.2
10-
mypy-extensions==1.0.0
11-
packaging==23.1
12-
pathspec==0.11.1
13-
platformdirs==3.9.1
14-
Pygments==2.15.1
157
python-dateutil==2.8.2
16-
python-dotenv==1.0.0
178
python-leetcode==1.2.1
189
requests==2.31.0
19-
rich==13.4.2
2010
six==1.16.0
2111
soupsieve==2.4.1
2212
toml==0.10.2

0 commit comments

Comments
 (0)