77from time import gmtime , strftime
88# webbrowser for openLink command, and datetime for date and time
99
10+ __cache__ = 0 # Set cache to 0
11+ prompt = '' # Setup prompt variable
12+ __os__ = platform .system () # Get operating system name and store it in a variable
13+ null = None # Create new variable with value of None
14+
1015# Print version and title as function
1116def title ():
1217 print ('@------------------------------------------------------------------------------------@' )
1318 print ('| |' )
14- print ('| |PyTerm v0.4.3 | |' )
19+ print ('| |PyTerm v0.4.4 | |' )
1520 print ('| |' )
1621 print ('@------------------------------------------------------------------------------------@' )
1722
1823def clear (): # Clear screen
19- if __os__ == 'nt ' : # Windows
24+ if __os__ == 'Windows ' : # Windows
2025 os .system ('cls' )
2126 else : # Linux and Mac OS X
2227 os .system ('clear' )
@@ -39,9 +44,6 @@ def setupColor():
3944 except :
4045 os .system ('color 0A' )
4146
42- __cache__ = 0 # Set cache to 0
43- prompt = '' # Setup prompt variable
44- __os__ = os .name # Get operating system name and store it in a variable
4547
4648def cache ():
4749 try :
@@ -104,6 +106,7 @@ def init():
104106 print (prompt + ' ' , end = '' ) # Input prompt without line break ( \n )
105107 cmd = input ('' ) # Collect input
106108 if cmd == 'help' :
109+ print ('changelog Shows PyTerm\' s change log (../change.log)' )
107110 print ('color Changes the text and the background color' )
108111 print ('copy Copies a file' )
109112 print ('curDir Displays the current directory' )
@@ -121,13 +124,15 @@ def init():
121124 print ('info -c Clear stored info' )
122125 print ('info -g Get stored info' )
123126 print ('ip Displays your computer\' s IP address' )
127+ print ('licenes Shows PyTerm\' s license (../LICENSE.txt)' )
124128 print ('md Creates a directory' )
125129 print ('math -a Adds two numbers together' )
126130 print ('math -s Subtracts two numbers' )
127131 print ('math -m Multiplies two numbers' )
128132 print ('math -d Divides two numbers' )
129133 print ('mkdir Creates a directory' )
130134 print ('mkfil Creates a file' )
135+ print ('notepad Opens Windows Notepad' )
131136 print ('openBinFil Opens a binary file' )
132137 print ('openFil Opens a file' )
133138 print ('openLink Opens a link in your browser' )
@@ -145,6 +150,7 @@ def init():
145150 print ('terminate Exits the program' )
146151 print ('time Also shows date and time\n ' )
147152 elif cmd == 'help -a' or cmd == 'help --alt' : # Help
153+ print ('changelog Shows PyTerm\' s change log (../change.log)' )
148154 print ('color Changes the text and the background color' )
149155 print ('copy Copies a file' )
150156 print ('curDir Displays the current directory' )
@@ -159,13 +165,15 @@ def init():
159165 print ('find Finds a specific text in a file' )
160166 print ('help Displays this help message' )
161167 print ('ip Displays your computer\' s IP address' )
168+ print ('licenes Shows PyTerm\' s license (../LICENSE.txt)' )
162169 print ('math -a Adds two numbers together' )
163170 print ('math -s Subtracts two numbers' )
164171 print ('math -m Multiplies two numbers' )
165172 print ('math -d Divides two numbers' )
166173 print ('md Creates a directory' )
167174 print ('mkdir Creates a directory' )
168175 print ('mkfil Creates a file' )
176+ print ('notepad Opens Windows Notepad' )
169177 print ('openBinFil Opens a binary file' )
170178 print ('openFil Opens a file' )
171179 print ('openLink Opens a link in your browser' )
@@ -226,8 +234,11 @@ def init():
226234 toDel = input ('' ) # Collect directory or file name
227235 try : # Try if to delete the file
228236 if fileExists (toDel ): # See if file exsits
229- os .remove (toDel )
230- print ('Successfully deleted ' + toDel )
237+ try :
238+ os .remove (toDel )
239+ print ('Successfully deleted ' + toDel )
240+ except :
241+ print ('Error! Please make sure that the file in not in us by another program!' )
231242 else :
232243 print ('The file does not exist!' )
233244 except : # The user might have typed a folder name or the access is deined
@@ -290,8 +301,7 @@ def init():
290301 print (' -o or --overwrite Overwrites all the stored info with the new info' )
291302 print (' -c or --clear Clears stored info\n \n ' )
292303 elif cmd == 'time' or cmd == 'date' : # Display date and time
293- time = dt .datetime .now () # Get date and time
294- print (time ) # Print date and time
304+ print (dt .datetime .now ()) # Print date and time
295305 elif cmd == 'openLink' : # Open link in browser
296306 print ('Link?' )
297307 fopenLink (input ('' )) # Get input and open it in browser
@@ -360,14 +370,17 @@ def init():
360370 elif cmd == 'find' : # Find text in a file
361371 print ('Full file or directory path to find text?' )
362372 toFind = input ('' ) # Get file
363- print ('Text to find?' )
364- toFindTxt = input ('' ) # Get text to find
365- try :
366- f = open (toFind , 'r' ) # Open file
367- toFindStr = f .read () # Read from file
368- print ('First appearance of the word ' + toFindTxt + ' is found at character ' + str (toFindStr .find (toFindTxt ))) # Print results
369- except :
370- print ('Error! Please try again' ) # Error
373+ if fileExists (toFind ):
374+ print ('Text to find?' )
375+ toFindTxt = input ('' ) # Get text to find
376+ try :
377+ f = open (toFind , 'r' ) # Open file
378+ toFindStr = f .read () # Read from file
379+ print ('First appearance of the word ' + toFindTxt + ' is found at character ' + str (toFindStr .find (toFindTxt ))) # Print results
380+ except :
381+ print ('Error! Please try again' ) # Error
382+ else :
383+ print ('File does not exist!' )
371384 elif cmd == 'color' : # Switch color
372385 print ('Color?' ) # Ask color
373386 print ('0 = Black 8 = Gray' ) # Show colors
@@ -404,7 +417,10 @@ def init():
404417 print ('Directory of the folder to delete? Example: C:\\ Users\\ exampleUser\\ Documents\\ New_Folder' )
405418 toDelDir = input ('' ) # Get directory
406419 if fileExists (toDelDir ): # Check if directory exists
407- os .rmdir (toDelDir ) # Remove directory
420+ try :
421+ os .rmdir (toDelDir ) # Remove directory
422+ except :
423+ print ('Error! Please make sure that directory/folder is not being used by another program!' )
408424 else :
409425 print ('Not a valid directory of a folder!' ) # Error
410426 elif cmd == 'rename' : # Rename file
@@ -537,8 +553,18 @@ def init():
537553 print (' -m or --multiply Multiplies two numbers' )
538554 print (' -d or --divide Divides two numbers\n \n ' )
539555 elif cmd == 'ver' or cmd == 'version' :
540- print ('PyTerm v0.4.3' )
541- elif cmd == '' : # Empty input
556+ print ('PyTerm v0.4.4' )
557+ elif cmd == 'notepad' :
558+ if __os__ == 'Windows' :
559+ subprocess .Popen ('notepad.exe' )
560+ else :
561+ print ('Sorry, notepad is only for Windows!' )
562+ elif cmd == 'license' :
563+ if fileExists ('../LICENSE.txt' ):
564+ print (open ('../LICENSE.txt' , 'r' ).read ())
565+ else :
566+ print ('Could not find license!' )
567+ elif cmd == '' or cmd == null : # Empty input
542568 continue # Continue
543569 else : # Is not a command
544570 print ('Python ' + platform .python_version ()+ ' -> PyTerm -> "' + cmd + '" is not a command!' ) # Error
0 commit comments