forked from expo/troggle
Convert codebase for python3 usage
This commit is contained in:
@@ -10,7 +10,7 @@ import csv
|
||||
import re
|
||||
import datetime
|
||||
|
||||
#from PIL import Image
|
||||
from PIL import Image
|
||||
from utils import save_carefully
|
||||
from functools import reduce
|
||||
|
||||
@@ -82,14 +82,14 @@ def get_or_create_placeholder(year):
|
||||
# logging.info("added survey " + survey[header['Year']] + "#" + surveyobj.wallet_number + "\r")
|
||||
|
||||
# dead
|
||||
# def listdir(*directories):
|
||||
# try:
|
||||
# return os.listdir(os.path.join(settings.SURVEYS, *directories))
|
||||
# except:
|
||||
# import urllib.request, urllib.parse, urllib.error
|
||||
# url = settings.SURVEYS + reduce(lambda x, y: x + "/" + y, ["listdir"] + list(directories))
|
||||
# folders = urllib.request.urlopen(url.replace("#", "%23")).readlines()
|
||||
# return [folder.rstrip(r"/") for folder in folders]
|
||||
def listdir(*directories):
|
||||
try:
|
||||
return os.listdir(os.path.join(settings.SURVEYS, *directories))
|
||||
except:
|
||||
import urllib.request, urllib.parse, urllib.error
|
||||
url = settings.SURVEYS + reduce(lambda x, y: x + "/" + y, ["listdir"] + list(directories))
|
||||
folders = urllib.request.urlopen(url.replace("#", "%23")).readlines()
|
||||
return [folder.rstrip(r"/") for folder in folders]
|
||||
|
||||
# add survey scans
|
||||
# def parseSurveyScans(expedition, logfile=None):
|
||||
@@ -252,7 +252,7 @@ def LoadListScans():
|
||||
|
||||
def FindTunnelScan(tunnelfile, path):
|
||||
scansfolder, scansfile = None, None
|
||||
mscansdir = re.search(r"(\d\d\d\d#X?\d+\w?|1995-96kh|92-94Surveybookkh|1991surveybook|smkhs)/(.*?(?:png|jpg|pdf|jpeg))$", path)
|
||||
mscansdir = re.search(rb"(\d\d\d\d#X?\d+\w?|1995-96kh|92-94Surveybookkh|1991surveybook|smkhs)/(.*?(?:png|jpg|pdf|jpeg))$", path)
|
||||
if mscansdir:
|
||||
scansfolderl = SurvexScansFolder.objects.filter(walletname=mscansdir.group(1))
|
||||
if len(scansfolderl):
|
||||
@@ -273,7 +273,7 @@ def FindTunnelScan(tunnelfile, path):
|
||||
if scansfile:
|
||||
tunnelfile.survexscans.add(scansfile)
|
||||
|
||||
elif path and not re.search(r"\.(?:png|jpg|pdf|jpeg)$(?i)", path):
|
||||
elif path and not re.search(rb"\.(?:png|jpg|pdf|jpeg)$(?i)", path):
|
||||
name = os.path.split(path)[1]
|
||||
#print("debug-tunnelfileobjects ", tunnelfile.tunnelpath, path, name)
|
||||
rtunnelfilel = TunnelFile.objects.filter(tunnelname=name)
|
||||
@@ -295,16 +295,16 @@ def SetTunnelfileInfo(tunnelfile):
|
||||
if tunnelfile.filesize <= 0:
|
||||
print("DEBUG - zero length xml file", ff)
|
||||
return
|
||||
mtype = re.search(r"<(fontcolours|sketch)", ttext)
|
||||
mtype = re.search(rb"<(fontcolours|sketch)", ttext)
|
||||
|
||||
assert mtype, ff
|
||||
tunnelfile.bfontcolours = (mtype.group(1)=="fontcolours")
|
||||
tunnelfile.npaths = len(re.findall(r"<skpath", ttext))
|
||||
tunnelfile.npaths = len(re.findall(rb"<skpath", ttext))
|
||||
tunnelfile.save()
|
||||
|
||||
# <tunnelxml tunnelversion="version2009-06-21 Matienzo" tunnelproject="ireby" tunneluser="goatchurch" tunneldate="2009-06-29 23:22:17">
|
||||
# <pcarea area_signal="frame" sfscaledown="12.282584" sfrotatedeg="-90.76982" sfxtrans="11.676667377221136" sfytrans="-15.677173422877454" sfsketch="204description/scans/plan(38).png" sfstyle="" nodeconnzsetrelative="0.0">
|
||||
for path, style in re.findall(r'<pcarea area_signal="frame".*?sfsketch="([^"]*)" sfstyle="([^"]*)"', ttext):
|
||||
for path, style in re.findall(rb'<pcarea area_signal="frame".*?sfsketch="([^"]*)" sfstyle="([^"]*)"', ttext):
|
||||
FindTunnelScan(tunnelfile, path)
|
||||
|
||||
# should also scan and look for survex blocks that might have been included
|
||||
|
||||
Reference in New Issue
Block a user