Skip to content

Commit 4862841

Browse files
authored
Merge pull request #751 from alankarartist/file_unlatcher
file_unlatcher
2 parents b5efd14 + c549251 commit 4862841

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed

file_unlatcher/AlFileUnlatcher.py

Lines changed: 17 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,29 @@ 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))
79+
if bar:
80+
bar.close()
7681
for file in output:
77-
if os.path.basename(file) == inputFile:
82+
filename = os.path.basename(file)
83+
if filename == inputFile and file not in filesList:
7884
filesList.append(file)
7985
if len(filesList) == 0:
8086
text.delete(1.0, END)
8187
text.insert(1.0, 'Invalid input file')
82-
speak('Invalid input file')
8388
else:
8489
for file in filesList:
8590
directory = os.path.dirname(file)
8691
filename = os.path.basename(file)
8792
try:
8893
text.delete(1.0, END)
89-
speak('Opening ' + inputFile)
9094
text.insert(1.0, 'Opening ' + inputFile)
9195
os.startfile(os.path.join(directory, filename))
9296
except Exception as e:
9397
print(str(e))
9498
text.insert(1.0, 'Set a default application to open'
9599
' the input file')
96-
speak('Set a default application to open the input '
97-
'file')
98100

99101
textHighlightFont = font.Font(family='OnePlus Sans Display', size=12)
100102
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)