forked from dforel/autoSplitUploadAliImg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FileList.py
40 lines (31 loc) · 1.04 KB
/
FileList.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import os
class FileList(object):
_instance=None
fileList=[
]
def getList(self):
return self.fileList
def addFile(self,fileObj):
self.fileList.append(fileObj)
def deleteFile(self,id):
for item in self.fileList[:]:
if int(item["id"]) == int(id):
if os.path.exists(item['filePath']):
os.remove(item['filePath'])
self.fileList.remove(item)
return True
else :
return False
return False
def __new__(cls, *args, **kwargs):
if cls._instance is None:
obj = object.__new__(cls)
cls._instance = obj
return cls._instance
@classmethod
def instance(cls, *args, **kwargs):
if not hasattr(FileList, "_instance"):
with FileList._instance_lock:
if not hasattr(FileList, "_instance"):
FileList._instance = FileList(*args, **kwargs)
return FileList._instance