aboutsummaryrefslogtreecommitdiff
path: root/utils.py
diff options
context:
space:
mode:
authorneodarz <neodarz@neodarz.net>2020-08-15 14:07:15 +0200
committerneodarz <neodarz@neodarz.net>2020-08-15 14:07:15 +0200
commitc4fb7fda5b1b6bb22db1f517f71cf393f68c6a9b (patch)
tree746b1c9e7d5b2f49e338706fec9f9c0d74f9f7c3 /utils.py
downloadmusic_downloader-c4fb7fda5b1b6bb22db1f517f71cf393f68c6a9b.tar.xz
music_downloader-c4fb7fda5b1b6bb22db1f517f71cf393f68c6a9b.zip
Initial commit
Diffstat (limited to 'utils.py')
-rw-r--r--utils.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/utils.py b/utils.py
new file mode 100644
index 0000000..2736206
--- /dev/null
+++ b/utils.py
@@ -0,0 +1,21 @@
+import sys
+import logging
+
+
+def read_file(filename):
+ lines = []
+
+ if filename.is_dir():
+ logging.fatal(f'{filename} is a folder instead of a file!')
+ sys.exit(1)
+ elif not filename.is_file():
+ filename.touch()
+ with open(filename) as filehandler:
+ for line in filehandler.readlines():
+ lines.append(line.strip())
+
+ return lines
+
+def write_file(filename, data):
+ with open(filename, 'a') as filehandler:
+ filehandler.write(data+'\n')