summaryrefslogtreecommitdiffstats
path: root/parsers/drawings.py
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@klebos.com>2022-03-05 22:16:03 +0000
committerPhilip Sargent <philip.sargent@klebos.com>2022-03-05 22:16:03 +0000
commit7a58aac08eb0b19b05f84955d855d8af6bb369de (patch)
tree91a3cfd135dac2d058df0aa78480201ae01f31ce /parsers/drawings.py
parenta3a65524b86abde3bc924d611620f71f87b7bf36 (diff)
downloadtroggle-7a58aac08eb0b19b05f84955d855d8af6bb369de.tar.gz
troggle-7a58aac08eb0b19b05f84955d855d8af6bb369de.tar.bz2
troggle-7a58aac08eb0b19b05f84955d855d8af6bb369de.zip
Drawings uploads git works
Diffstat (limited to 'parsers/drawings.py')
-rw-r--r--parsers/drawings.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/parsers/drawings.py b/parsers/drawings.py
index 024ce43..2f4e4a9 100644
--- a/parsers/drawings.py
+++ b/parsers/drawings.py
@@ -179,7 +179,7 @@ def settnlfileinfo(dwgfile):
def setdrwfileinfo(dwgfile):
'''Read in the drawing file contents and sets values on the dwgfile object,
- but these are PDFs or .txt files, so there is no useful format to search for
+ but these are SVGs, PDFs or .txt files, so there is no useful format to search for
This function is a placeholder in case we thnk of a way to do something
to recognise generic survex filenames.
'''
@@ -190,7 +190,6 @@ def setdrwfileinfo(dwgfile):
print(message)
DataIssue.objects.create(parser='drawings', message=message, url=f'/dwgdataraw/{dwgfile.dwgpath}')
return
-
def load_drawings_files():
'''Breadth first search of drawings directory looking for sub-directories and *.xml filesize
@@ -198,7 +197,8 @@ def load_drawings_files():
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 DETECT UPPER CASE suffices
+ We import JPG, PNG and SVG files; which have already been put on the server,
+ but the upload form intentionally refuses to upload PNG and JPG (though it does allow SVG)
'''
all_xml = []
drawdatadir = settings.DRAWINGS_DATA
@@ -243,6 +243,11 @@ def load_drawings_files():
dwgfile = DrawingFile(dwgpath=lf, dwgname=os.path.split(f[:-4])[1])
dwgfile.save()
all_xml.append(('pdf',dwgfile))
+ elif Path(f).suffix.lower() == ".png":
+ # Always creates new
+ dwgfile = DrawingFile(dwgpath=lf, dwgname=os.path.split(f[:-4])[1])
+ dwgfile.save()
+ all_xml.append(('png',dwgfile))
elif Path(f).suffix.lower() == ".svg":
# Always creates new
dwgfile = DrawingFile(dwgpath=lf, dwgname=os.path.split(f[:-4])[1])
@@ -262,7 +267,7 @@ def load_drawings_files():
print(f' - {len(all_xml)} Drawings files found')
for d in all_xml:
- if d[0] in ['pdf', 'txt', '']:
+ if d[0] in ['pdf', 'txt', 'svg', 'jpg', 'png', '']:
setdrwfileinfo(d[1])
if d[0] == 'xml':
settnlfileinfo(d[1])