return errcode if __name__ == "__main__": itemlist = [] if '-h' in sys.argv or '-help' in sys.argv or '--help' in sys.argv: print __doc__ sys.exit() if len(sys.argv) > 1: choice = sys.argv[1] else: choice = "" if choice in ['mv','cp','rm','ck','ln','','h']: #i.e. not a file data = header.read_database(SHELFDATA) if len(data) == 0: print "No items on the shelf." sys.exit() if len(sys.argv) > 2: #arguments already given itemlist = header.read_range(sys.argv[2:],len(data)) else: #no arguments given header.print_database(data) if choice not in ["","h"]: #unless we just wanted list, get args line=raw_input("Choose: ") if line!="": itemlist = header.read_range(line.split(),len(data)) if choice in ('cp','mv','ck','ln'): newitemlist = [] # list of items that exist errcode = [] # list of files that failed to move/copy/link
junk = junk + docs # remove old items if list is too long if len(junk) > MAXDOCLENGTH: idx = len(junk) - MINDOCLENGTH junk = junk[idx:] header.write_database(junk,RECENTDATA,mode='w') # Begin Main program if __name__ == '__main__': if '-h' in sys.argv or '-help' in sys.argv or '--help' in sys.argv: print __doc__ raise SystemExit alldata = header.read_database(RECENTDATA) alldata.reverse() # most recent (last entry) is first if len(sys.argv) == 1 or sys.argv[1] == 'h': if len(alldata) == 0: print "No recent files!" sys.exit() header.print_database(alldata) choice=raw_input("Choose: ") docs = [] if choice != "": filelist = header.read_range(choice.split(),len(alldata)) docs = [alldata[i]['fullpath'] for i in filelist] if len(docs) == 0:
"""Prints the stored sync locations and lets the user choose one or more to synchronize. It returns a list of the full file path names""" header.print_database(data,shownum=False) choice=raw_input("Choose: ") if choice != "": choicelist = [header.to_lower(f) for f in choice.split()] docs = grep_data(choicelist,data) return docs if __name__ == "__main__": if '-h' in sys.argv or '-help' in sys.argv or '--help' in sys.argv: print __doc__ sys.exit() data = header.read_database(syncFile) if len(data) == 0: print "No sync locations" sys.exit() if len(sys.argv) == 1: header.print_database(data,shownum=False) sys.exit() flag = sys.argv[1] if flag == 'h': header.print_database(data,shownum=False) sys.exit() elif flag == 'a': # add namelist = [s['name'] for s in data]