Junaidb commited on
Commit
fd32229
·
verified ·
1 Parent(s): 1a36bbe

Create filechecker.py

Browse files
Files changed (1) hide show
  1. components/filechecker.py +20 -0
components/filechecker.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from component.mongoconnection import provideClient
2
+
3
+ mc=provideClient()
4
+
5
+ db=mc["askmydoc_db"]
6
+ coll=db["askmydoc_col"]
7
+
8
+ def checkFile(owner,filetype):
9
+
10
+ document = coll.find_one({"owner": owner})
11
+
12
+ if document is None or "files" not in document or len(document["files"]) == 0:
13
+ return {"status": False, "files": []}
14
+ else:
15
+ cleaned_files=[]
16
+ for file in document["files"]:
17
+ if file["filetype"]==filetype:
18
+ cleaned_files.append({"file_name":file["filename"]})
19
+
20
+ return {"status": True, "files": cleaned_files}