This commit is contained in:
11
file_list.py
11
file_list.py
@@ -35,7 +35,7 @@ def setup_options():
|
||||
parser.add_argument("-s",type=str,dest="search",default=False,
|
||||
help="Search list based on path pattern")
|
||||
parser.add_argument("--match",type=str,dest="match",default=False,
|
||||
help="Search for closest match from basenames")
|
||||
help="Search for closest match from basenames, can be helped with adding -s")
|
||||
parser.add_argument('startpath', action="store",default='.', nargs='?')
|
||||
|
||||
options=parser.parse_args()
|
||||
@@ -177,11 +177,14 @@ def searchdb(sqlfile,needle):
|
||||
for row in db:
|
||||
print(row[0])
|
||||
|
||||
def matchdb(sqlfile,needle):
|
||||
def matchdb(sqlfile,needle,helper):
|
||||
import difflib as dl
|
||||
conn=sqlite3.connect(sqlfile)
|
||||
conn.text_factory=str
|
||||
db=conn.cursor()
|
||||
if helper:
|
||||
db.execute("SELECT file FROM list WHERE file LIKE ?",('%'+needle+'%',))
|
||||
else:
|
||||
db.execute("SELECT file FROM list")
|
||||
ratio=0
|
||||
best_match=""
|
||||
@@ -207,11 +210,11 @@ def main():
|
||||
|
||||
if not os.path.exists(options.sqlfile):
|
||||
createdb(options.sqlfile);
|
||||
if options.search:
|
||||
if options.search and not options.match:
|
||||
searchdb(options.sqlfile,options.search)
|
||||
sys.exit(0)
|
||||
if options.match:
|
||||
matchdb(options.sqlfile,options.match)
|
||||
matchdb(options.sqlfile,options.match,options.search)
|
||||
sys.exit(0)
|
||||
if options.delete:
|
||||
print('Deleting entries...')
|
||||
|
||||
Reference in New Issue
Block a user