Skip to content

Commit

Permalink
Some functions moved.
Browse files Browse the repository at this point in the history
  • Loading branch information
OyuNet committed Feb 5, 2024
1 parent 6e036f4 commit 96b814c
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 24 deletions.
Binary file modified .DS_Store
Binary file not shown.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/AppStorage/
/__pycache__/
/links.txt
/links.txt
/build/
/dist/
/main.spec
15 changes: 14 additions & 1 deletion Checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,17 @@ def isLinksFileEmpty():
if (len(fileData) < 1):
return True
else:
return False
return False

def isFolderExists():
isExists = os.path.exists("AppStorage")

if (not isExists):
os.mkdir("AppStorage")

def isLinksFileExists():
isExists = os.path.exists("links.txt")

if (not isExists):
print("Your links.txt file is not exists. New one created.")
file = open("links.txt", "x")
7 changes: 0 additions & 7 deletions Remover.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
import os

def CheckLinksFile():
isExists = os.path.exists("links.txt")

if (not isExists):
print("Your links.txt file is not exists. New one created.")
file = open("links.txt", "x")

def RemoveLines():
file = open("links.txt", "w")
Expand Down
12 changes: 2 additions & 10 deletions Saver.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Input is going to be [url, fileName]

import os
from Checker import isFolderExists

def CheckFile(fileName):
path = "AppStorage/" + fileName + ".txt"
Expand All @@ -11,19 +12,10 @@ def CheckFile(fileName):
if (not isExists):
open((path), "x")

def CheckFolder():
# In this function, I will handle folder existence.
# If folder not exists, function gonna be create new folder.

isExists = os.path.exists("AppStorage")

if (not isExists):
os.mkdir("AppStorage")

def WriteData(Data):
# Data -> [URL, fileName]
path = "AppStorage/" + Data[1] + ".txt"
CheckFolder() # Ensure the folder exists
isFolderExists()
CheckFile(Data[1]) # Ensure the file exists

with open(path, "a") as file:
Expand Down
10 changes: 5 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
from LinkExtractor import Extract
from Saver import CheckFolder, WriteData
from Remover import CheckLinksFile, RemoveLines
from Checker import isLinksFileEmpty
from Saver import WriteData
from Remover import RemoveLines
from Checker import isLinksFileEmpty, isFolderExists, isLinksFileExists

def main():
CheckLinksFile()
isLinksFileExists()

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

for x in fileData:
data = Extract(x)
Expand Down

0 comments on commit 96b814c

Please sign in to comment.