55from subprocess import run , CalledProcessError
66from shutil import which
77from typing import Set
8+ from logger import log_message
89
910
10- # LOGGING MESSAGE ---
1111def check_pip_installed () -> bool :
1212 """Check if pip3 is installed and available in PATH."""
1313 pip_path = which ("pip3" )
@@ -17,11 +17,6 @@ def check_pip_installed() -> bool:
1717 return True
1818
1919
20- def log_message (message : str , level : str = "info" ) -> None :
21- prefixes = {"info" : "📍" , "success" : "📦" , "error" : "❌" }
22- print (f"{ prefixes .get (level , '📍' )} { message } " )
23-
24-
2520# --- VALIDATE LIB NAME
2621def validate_library_name (lib_name : str ) -> bool :
2722 """Check if the library name is valid."""
@@ -74,7 +69,7 @@ def install_lib(
7469 file .write (f"{ lib_name } \n " )
7570 libs_list .add (lib_name .lower ())
7671
77- # Read existing libs (case-insensitive )
72+ # Read existing libs (case-sensetive )
7873 libs_set : Set [str ] = set ()
7974 try :
8075 with open (req_path , "r" , encoding = "utf-8" ) as file :
@@ -100,8 +95,6 @@ def install_lib(
10095 if flag == "-quiet" :
10196 pip_args .append ("-q" )
10297 try :
103- # Safely calling pip from argument list, without shell=True (as it was
104- # in previous commit)
10598 result = run (
10699 pip_args ,
107100 check = True ,
@@ -113,11 +106,13 @@ def install_lib(
113106
114107 if "requirement already satisfied" in stdout_lower :
115108 log_message (f"{ lib_name } already installed" , "success" )
109+
116110 elif "successfully installed" in stdout_lower :
117111 # Find the line with "Successfully installed {lib_name}
118112 for line in stdout .splitlines ():
119113 if "Successfully installed" in line :
120114 log_message (line .strip (), "success" )
115+
121116 # If somewhat went wrong
122117 else :
123118 log_message (f"{ lib_name } installation output:" , "info" )
0 commit comments