GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Python/new_script.py at master · rajendar19/Python Expand file tree/ Copy pathnew_script.pyMore file actions 64 lines (56 loc) · 1.83 KB / Copy pathnew_script.pyFile metadata and controls64 lines (56 loc) · 1.83 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 # Script Name : new_script.py # Author : Craig Richards # Created : 20th November 2012 # Last Modified : # Version : 1.0 # Modifications : # Description : This will create a new basic template for a new script import os # Load the library module import sys # Load the library module import datetime # Load the library module text = '''You need to pass an argument for the new script you want to create, followed by the script name. You can use -python : Python Script -bash : Bash Script -ksh : Korn Shell Script -sql : SQL Script''' if len(sys.argv) < 3: print text sys.exit() if '-h' in sys.argv or '--h' in sys.argv or '-help' in sys.argv or '--help' in sys.argv: print text sys.exit() else: if '-python' in sys.argv[1]: config_file="python.cfg" extension=".py" elif '-bash' in sys.argv[1]: config_file="bash.cfg" extension=".bash" elif '-ksh' in sys.argv[1]: config_file="ksh.cfg" extension=".ksh" elif '-sql' in sys.argv[1]: config_file="sql.cfg" extension=".sql" else: print 'Unknown option - ' + text sys.exit() confdir=os.getenv("my_config") scripts=os.getenv("scripts") dev_dir="Development" newfile=sys.argv[2] output_file=(newfile+extension) outputdir=os.path.join(scripts,dev_dir) script=os.path.join(outputdir, output_file) input_file=os.path.join(confdir,config_file) old_text=" Script Name : " new_text=(" Script Name : "+output_file) newscript = open(script, 'w') input=open(input_file,'r') today=datetime.date.today() old_date= " Created :" new_date= (" Created : "+today.strftime("%d %B %Y")) for line in input: line = line.replace(old_text, new_text) line = line.replace(old_date, new_date) newscript.write(line) |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |