Skip to content

Commit 7b6237f

Browse files
committed
file_unlatcher
1 parent f2a6aa8 commit 7b6237f

File tree

2 files changed

+15
-18
lines changed

2 files changed

+15
-18
lines changed

file_unlatcher/AlFileUnlatcher.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import os
33
from tkinter import Tk, Label, END, Frame, SUNKEN
44
from tkinter import font, Button, X, Entry, Text, BOTH
5-
import pyttsx3
65
from PIL import ImageTk, Image
76

87
cwd = os.path.dirname(os.path.realpath(__file__))
@@ -33,13 +32,6 @@ def hideScreen():
3332
root.overrideredirect(0)
3433
root.iconify()
3534

36-
def speak(audio):
37-
engine = pyttsx3.init('sapi5')
38-
voices = engine.getProperty('voices')
39-
engine.setProperty('voice', voices[0].id)
40-
engine.say(audio)
41-
engine.runAndWait()
42-
4335
def find():
4436
inputFile = fileText.get()
4537
fileName = os.path.join(cwd + '/AlFileUnlatcher',
@@ -51,16 +43,25 @@ def find():
5143
dFile.close()
5244
filesList = []
5345
notFoundList = []
46+
otherList = []
5447
dFile = open(fileName, "r")
55-
for file in dFile:
48+
files = dFile.readlines()
49+
for file in files:
5650
file = file.replace('\n', '')
5751
if os.path.basename(file) == inputFile:
5852
if os.path.isfile(file):
5953
filesList.append(file)
6054
else:
6155
notFoundList.append(file)
62-
del(file)
56+
else:
57+
otherList.append(file)
6358
dFile.close()
59+
lines = filesList + otherList
60+
nFile = open(fileName, "w+")
61+
for line in lines:
62+
line += '\n'
63+
nFile.write(line)
64+
nFile.close()
6465
lfl = len(filesList)
6566
lnfl = len(notFoundList)
6667
if (lfl == 0) or (lnfl != 0 and lfl == 0) or (lnfl != 0):
@@ -73,28 +74,27 @@ def find():
7374
dFile = open(fileName, 'a')
7475
dFile.writelines(allFiles)
7576
dFile.close()
77+
uniqlines = set(open(fileName).readlines())
78+
bar = open(fileName, 'w+').writelines(set(uniqlines))
7679
for file in output:
77-
if os.path.basename(file) == inputFile:
80+
filename = os.path.basename(file)
81+
if filename == inputFile and file not in filesList:
7882
filesList.append(file)
7983
if len(filesList) == 0:
8084
text.delete(1.0, END)
8185
text.insert(1.0, 'Invalid input file')
82-
speak('Invalid input file')
8386
else:
8487
for file in filesList:
8588
directory = os.path.dirname(file)
8689
filename = os.path.basename(file)
8790
try:
8891
text.delete(1.0, END)
89-
speak('Opening ' + inputFile)
9092
text.insert(1.0, 'Opening ' + inputFile)
9193
os.startfile(os.path.join(directory, filename))
9294
except Exception as e:
9395
print(str(e))
9496
text.insert(1.0, 'Set a default application to open'
9597
' the input file')
96-
speak('Set a default application to open the input '
97-
'file')
9898

9999
textHighlightFont = font.Font(family='OnePlus Sans Display', size=12)
100100
appHighlightFont = font.Font(family='OnePlus Sans Display', size=12,

file_unlatcher/README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,8 @@ A python script based GUI interface to search and open all files with same name
77
Use the package manager [pip](https://pip.pypa.io/en/stable/) to install packages.
88

99
```bash
10-
pip install pyttsx3
11-
pip install PyAudio
1210
pip install Pillow
1311
```
14-
1. If there is problem in installing PyAudio, then go to the [link](https://www.lfd.uci.edu/~gohlke/pythonlibs/) and download the package file according to the system requirements and then try to install it.
1512

1613
## Usage
1714

0 commit comments

Comments
 (0)