af1f9fd365
* IMGUR API is no longer used * --skip now accepts file types instead of domain * --skip-domain added * --no-download added * --no-dupe now supports YouTube * Duplicates of older posts will not be dowloaded if --no-dupe and --downloaded-posts options are given together * Invalid characters in MacOS and Linux platforms are removed from filenames * Bug fixes
25 lines
675 B
Python
25 lines
675 B
Python
from os import path
|
|
|
|
class Store:
|
|
def __init__(self,directory=None):
|
|
self.directory = directory
|
|
if self.directory:
|
|
if path.exists(directory):
|
|
with open(directory, 'r') as f:
|
|
self.list = f.read().split("\n")
|
|
else:
|
|
with open(self.directory, 'a'):
|
|
pass
|
|
self.list = []
|
|
else:
|
|
self.list = []
|
|
|
|
def __call__(self):
|
|
return self.list
|
|
|
|
def add(self, data):
|
|
self.list.append(data)
|
|
if self.directory:
|
|
with open(self.directory, 'a') as f:
|
|
f.write("{data}\n".format(data=data))
|