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: # User did not select any recent documents os.system('$GODIR/lf.py') else: mimetypes,docs = find_mimetypes(docs) open_files(mimetypes,docs) else: if sys.argv[1] == '-': # read filenames from a pipe junk = [a.strip() for a in sys.stdin.readlines()] # strip of \n chars docs = header.read_cmdline(junk) else: docs = header.read_cmdline(sys.argv[1:]) mimetypes,docs = find_mimetypes(docs)
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 for idx in itemlist: if os.path.exists(data[idx]['fullpath']): newitemlist.append(idx) errcode.append(dostuff(data[idx],choice)) else: