Code Libary


Ok, i said i had made a code libary, and i have.. so here it is..
The program will make all the directories when loaded..
you need to do, is add your codes!! so whenever a nice snippet comes up on here, just copy it in!!
The program allows, search, remove, add, and also a DocToPy.. converts all txt's, doc's and 'dats, that have been added to the directory, C:\Code Libary < then given 'keyword' folder..
Enjoi.
(Toggle Plain Text) import os def DocToPy(): for dir in os.listdir("C:\Code Libary"): for file in os.listdir(os.path.join("C:\Code Libary", dir)): if file.endswith(".dat") or file.endswith(".txt") or file.endswith(".doc"): if file.endswith(".txt"): oldfile = file.strip("txt") newfile = oldfile + 'py' elif file.endswith(".doc"): oldfile = file.strip("doc") newfile = oldfile + 'py' elif file.endswith(".dat"): oldfile = file.stip("dat") newfile = oldfile + 'py' print newfile os.rename(os.path.join("C:\Code Libary", dir, file), os.path.join("C:\Code Libary", dir, newfile)) Main() def Remove(): num = 1 code = [] for dir in os.listdir("C:\Code Libary"): for file in os.listdir(os.path.join("C:\Code Libary", dir)): print num, file, 'from keyword' ,dir num += 1 code.append(os.path.join("C:\Code Libary", dir, file)) if len(code) >= 1: a = input("Enter Number Of Code To Delete: ") a -= 1 print code[a] b = raw_input("Are you sure you wish to delete (Y/N): ") if b.lower() == "y": os.remove(code[a]) else: print "Not Removed" Main() if len(code) > """) if s == 1: keyword = raw_input("""" Enter A Key Word To Search example 'web' 'gaming' generators' >> """) Search(keyword) if s == 2: Add() if s == 3: Remove() if s == 4: DocToPy() #Used For When First Run #Makes 'keyword' folders for searching #Will NOT replace delete folders if "C:\Code Libary" not in os.listdir("C:\\"): try: os.mkdir("C:\Code Libary") os.mkdir("C:\Code Libary\\web") os.mkdir("C:\Code Libary\\applications") os.mkdir("C:\Code Libary\\gaming") os.mkdir("C:\Code Libary\\snippets") os.mkdir("C:\Code Libary\\networking") except: IOError Main()
Posted On: Friday 28th of December 2012 05:26:30 AM Total Views:  241
View Complete with Replies