Skip to content

Commit 96b814c

Browse files
committed
Some functions moved.
1 parent 6e036f4 commit 96b814c

File tree

6 files changed

+25
-24
lines changed

6 files changed

+25
-24
lines changed

.DS_Store

2 KB
Binary file not shown.

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
/AppStorage/
22
/__pycache__/
3-
/links.txt
3+
/links.txt
4+
/build/
5+
/dist/
6+
/main.spec

Checker.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,17 @@ def isLinksFileEmpty():
77
if (len(fileData) < 1):
88
return True
99
else:
10-
return False
10+
return False
11+
12+
def isFolderExists():
13+
isExists = os.path.exists("AppStorage")
14+
15+
if (not isExists):
16+
os.mkdir("AppStorage")
17+
18+
def isLinksFileExists():
19+
isExists = os.path.exists("links.txt")
20+
21+
if (not isExists):
22+
print("Your links.txt file is not exists. New one created.")
23+
file = open("links.txt", "x")

Remover.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
11
import os
2-
3-
def CheckLinksFile():
4-
isExists = os.path.exists("links.txt")
5-
6-
if (not isExists):
7-
print("Your links.txt file is not exists. New one created.")
8-
file = open("links.txt", "x")
92

103
def RemoveLines():
114
file = open("links.txt", "w")

Saver.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# Input is going to be [url, fileName]
44

55
import os
6+
from Checker import isFolderExists
67

78
def CheckFile(fileName):
89
path = "AppStorage/" + fileName + ".txt"
@@ -11,19 +12,10 @@ def CheckFile(fileName):
1112
if (not isExists):
1213
open((path), "x")
1314

14-
def CheckFolder():
15-
# In this function, I will handle folder existence.
16-
# If folder not exists, function gonna be create new folder.
17-
18-
isExists = os.path.exists("AppStorage")
19-
20-
if (not isExists):
21-
os.mkdir("AppStorage")
22-
2315
def WriteData(Data):
2416
# Data -> [URL, fileName]
2517
path = "AppStorage/" + Data[1] + ".txt"
26-
CheckFolder() # Ensure the folder exists
18+
isFolderExists()
2719
CheckFile(Data[1]) # Ensure the file exists
2820

2921
with open(path, "a") as file:

main.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
from LinkExtractor import Extract
2-
from Saver import CheckFolder, WriteData
3-
from Remover import CheckLinksFile, RemoveLines
4-
from Checker import isLinksFileEmpty
2+
from Saver import WriteData
3+
from Remover import RemoveLines
4+
from Checker import isLinksFileEmpty, isFolderExists, isLinksFileExists
55

66
def main():
7-
CheckLinksFile()
7+
isLinksFileExists()
88

99
if (isLinksFileEmpty):
1010
print("Your links.txt file is empty. Fill it with your desired log lines to proceed.")
1111
else:
1212
fileData = open("links.txt", "r").readlines()
13-
CheckFolder()
13+
isFolderExists()
1414

1515
for x in fileData:
1616
data = Extract(x)

0 commit comments

Comments
 (0)