@@ -38,7 +38,7 @@ def print_question_data(question):
38
38
elif difficulty == "Hard" :
39
39
difficulty_color = Colors .RED
40
40
title_width = 50
41
- difficulty_width = 10
41
+ difficulty_width = 1
42
42
title_formatted = title .ljust (title_width )[:title_width ]
43
43
difficulty_formatted = (
44
44
f"{ difficulty_color } { difficulty .ljust (difficulty_width )} { Colors .RESET } "
@@ -455,7 +455,7 @@ def get_available_languages_and_code_snippets(question_detail_data):
455
455
return available_languages
456
456
457
457
458
- def display_question_detail (api_instance , title_slug ): # did changes here
458
+ def display_question_detail (api_instance , title_slug ): # did changes here
459
459
question_detail_data = get_question_detail (api_instance , title_slug )
460
460
if question_detail_data :
461
461
question_url = f"https://leetcode.com/problems/{ title_slug } /"
@@ -465,12 +465,17 @@ def display_question_detail(api_instance, title_slug): #did changes here
465
465
content_text = BeautifulSoup (content_html , "html.parser" ).get_text ()
466
466
print ("Question Content:\n " , content_text )
467
467
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
469
472
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
+ )
471
476
# write_code_snippet_to_file(question_detail_data, user_lang, title_slug)
472
477
input ("Press any key to continue..." )
473
- os .system (f"{ editor_cli } { file_path } " )
478
+ os .system (f"{ editor_cli } { file_path } " )
474
479
else :
475
480
available_languages = get_available_languages_and_code_snippets (
476
481
question_detail_data
@@ -499,8 +504,6 @@ def display_question_detail(api_instance, title_slug): #did changes here
499
504
except ValueError :
500
505
print ("Invalid input. Please enter a valid index." )
501
506
502
-
503
-
504
507
505
508
def write_code_snippet_to_file (question_detail_data , lang , title_slug ): # tags:path
506
509
code_snippets = question_detail_data .get ("codeSnippets" , [])
@@ -517,7 +520,7 @@ def write_code_snippet_to_file(question_detail_data, lang, title_slug): # tags:
517
520
leetcode_folder = os .path .join (home_directory , ".leetcode" )
518
521
else :
519
522
leetcode_folder = leetcode_path
520
-
523
+
521
524
if not os .path .exists (leetcode_folder ):
522
525
os .makedirs (leetcode_folder )
523
526
file_path = os .path .join (
@@ -534,7 +537,6 @@ def write_code_snippet_to_file(question_detail_data, lang, title_slug): # tags:
534
537
print (f"Code snippet for { lang } is not available for this question." )
535
538
536
539
537
-
538
540
def get_title_slug_from_filename (filepath ):
539
541
base_name = os .path .basename (filepath )
540
542
title_slug , _ = os .path .splitext (base_name )
@@ -649,9 +651,11 @@ def replace_files():
649
651
help = "Specify the filename containing the code to be submitted" ,
650
652
)
651
653
@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"
653
655
)
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
655
659
if lib :
656
660
replace_files ()
657
661
exit ()
@@ -661,7 +665,7 @@ def main(config, user_lang, user_path ,question, solve, test, submit, lib,help):
661
665
if user_lang :
662
666
save_user_data_to_config (user_lang )
663
667
exit ()
664
- # allow user to enter their preferred path
668
+ # allow user to enter their preferred path
665
669
elif user_path :
666
670
save_user_path_to_config (user_path )
667
671
exit ()
0 commit comments