2424import subprocess
2525
2626class MyJavaPy :
27+ """
28+ This class helps clone a Java repository, remove the .gitignore file,
29+ compile specific Java files, and print their locations.
30+ """
31+
2732 def __init__ (self ):
33+ """
34+ Initializes the class with the default Git repository URL.
35+ """
2836 self .repo_url = "https://github.com/MrTG-CodeBot/myJava_py.git"
2937
3038 def check_dirpath (self , dirpath ):
31- try :
39+ """
40+ Checks if the provided directory exists and creates it if not.
41+ Also clones the Git repository to the specified directory and removes the .gitignore file.
42+
43+ Args:
44+ dirpath (str): The full path to the directory for saving Java files.
3245
46+ Returns:
47+ None
48+ """
49+
50+ try :
3351 if not os .path .exists (dirpath ):
3452 os .makedirs (dirpath )
3553 print (f"{ dirpath } created" )
3654
37-
3855 subprocess .run (["git" , "clone" , self .repo_url , dirpath ])
3956
4057 df_path = os .path .join (dirpath , ".gitignore" )
@@ -54,16 +71,23 @@ def check_dirpath(self, dirpath):
5471 for file in file_root :
5572 subprocess .run (["javac" , file ])
5673
57- for slash in file_root :
58- rm_slash = slash .replace (' \\ \\ ' , ' \\ ' )
59- print (f"Files are saved in this dir : { rm_slash } " )
74+ for file in file_root :
75+ cleaned_path = file .replace (" \\ \\ " , " \\ " )
76+ print (f"Files are saved in this directory : { cleaned_path } " )
6077
6178 except Exception as e :
6279 print (f"An error occurred: { e } " )
6380
6481 def run (self ):
82+ """
83+ Prompts the user for the directory path and calls the check_dirpath function.
84+
85+ Returns:
86+ None
87+ """
88+
6589 while True :
66- print ("Please input the full path to the folder for save the Java files and classes (eg: C:\\ abc\\ Downloads\\ java_prgm )." )
90+ print ("Please input the full path to make the new folder for save the Java files and classes (eg: C:\\ abc\\ Downloads\\ new_folder_name )." )
6791 path = input ("Enter path: " )
6892 self .check_dirpath (path )
6993 break
0 commit comments