diff options
author | Philip Sargent <philip.sargent@klebos.com> | 2021-05-04 02:46:56 +0100 |
---|---|---|
committer | Philip Sargent <philip.sargent@klebos.com> | 2021-05-04 02:46:56 +0100 |
commit | 90bb0759a082755c55083f83bf029a44d225e013 (patch) | |
tree | 2b8f51f094c2e2bf12fdb21d3208533c8c357376 /parsers/drawings.py | |
parent | 9ae2e18fe6a25b9dfb0de3bd01916327c5c8a71a (diff) | |
download | troggle-90bb0759a082755c55083f83bf029a44d225e013.tar.gz troggle-90bb0759a082755c55083f83bf029a44d225e013.tar.bz2 troggle-90bb0759a082755c55083f83bf029a44d225e013.zip |
Drawing files upload form
Diffstat (limited to 'parsers/drawings.py')
-rw-r--r-- | parsers/drawings.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/parsers/drawings.py b/parsers/drawings.py index 5b7bc1e..a313a83 100644 --- a/parsers/drawings.py +++ b/parsers/drawings.py @@ -5,6 +5,7 @@ import stat import csv import re import datetime +from pathlib import Path from PIL import Image from functools import reduce @@ -261,6 +262,11 @@ def setdwgfileinfo(dwgfile): def load_drawings_files(): '''Breadth first search of drawings directory looking for sub-directories and *.xml filesize + + Why do we have all this detection of file types/! Why not use get_mime_types ? + What is it all for ?? + + ALL THIS NEEDS TO DETCT UPPER CASE suffices ''' all_xml = [] drawdatadir = settings.DRAWINGS_DATA @@ -294,6 +300,26 @@ def load_drawings_files(): dwgfile = DrawingFile(dwgpath=lf, dwgname=os.path.split(f[:-4])[1]) dwgfile.save() all_xml.append(('th2',dwgfile)) + elif f[-4:] == ".pdf": + # Always creates new + dwgfile = DrawingFile(dwgpath=lf, dwgname=os.path.split(f[:-4])[1]) + dwgfile.save() + all_xml.append(('pdf',dwgfile)) + elif f[-4:] == ".svg": + # Always creates new + dwgfile = DrawingFile(dwgpath=lf, dwgname=os.path.split(f[:-4])[1]) + dwgfile.save() + all_xml.append(('svg',dwgfile)) + elif f[-4:] == ".jpg": + # Always creates new + dwgfile = DrawingFile(dwgpath=lf, dwgname=os.path.split(f[:-4])[1]) + dwgfile.save() + all_xml.append(('jpg',dwgfile)) + elif Path(f).suffix == '': + # therion file + dwgfile = DrawingFile(dwgpath=lf, dwgname=os.path.split(f)[1]) + dwgfile.save() + all_xml.append(('',dwgfile)) print(f' - {len(all_xml)} Drawings files found') |