diff options
author | Philip Sargent <philip.sargent@klebos.com> | 2022-03-01 01:30:09 +0000 |
---|---|---|
committer | Philip Sargent <philip.sargent@klebos.com> | 2022-03-01 01:30:09 +0000 |
commit | af50d4912dd088d34ab73030efe7e3cc5505a9c2 (patch) | |
tree | db86f25ac740cd5f4e7e5f07da602b08845b8a14 /parsers/survex.py | |
parent | 8bd20f96006f160066b6ec64800e8b86b0a64190 (diff) | |
download | troggle-af50d4912dd088d34ab73030efe7e3cc5505a9c2.tar.gz troggle-af50d4912dd088d34ab73030efe7e3cc5505a9c2.tar.bz2 troggle-af50d4912dd088d34ab73030efe7e3cc5505a9c2.zip |
Catch error if unfixed merges in survex files
Diffstat (limited to 'parsers/survex.py')
-rw-r--r-- | parsers/survex.py | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/parsers/survex.py b/parsers/survex.py index 87c43d0..29cca3c 100644 --- a/parsers/survex.py +++ b/parsers/survex.py @@ -33,6 +33,9 @@ todo = '''Also walk the entire tree in the :loser: repo looking for unconnected GetPersonExpeditionNameLookup() needs to be fixed. - fix THREEDCACHEDIR and put .3d files in same folder as .svx and fix CaveView + +- LoadSurvexFile() Creates a new current survexfile and valid .survexdirectory + The survexblock passed-in is not necessarily the parent. FIX THIS. ''' survexblockroot = None ROOTBLOCK = "rootblock" @@ -130,7 +133,7 @@ class LoadingSurvex(): rx_star = re.compile(r'(?i)\s*\*[\s,]*(\w+)\s*(.*?)\s*(?:;.*)?$') rx_starref = re.compile(r'(?i)^\s*\*ref[\s.:]*((?:19[6789]\d)|(?:20[0123]\d))\s*#?\s*(X)?\s*(.*?\d+.*?)$') rx_argsref = re.compile(r'(?i)^[\s.:]*((?:19[6789]\d)|(?:20[0123]\d))\s*#?\s*(X)?\s*(.*?\d+.*?)$') - + rx_badmerge= re.compile(r'(?i).*(\>\>\>)|(\<\<\<).*$') rx_ref2 = re.compile(r'(?i)\s*ref[.;]?') rx_ref3 = re.compile(r'(?i)\s*wallet[.;]?') @@ -1037,12 +1040,22 @@ class LoadingSurvex(): if not sline: continue # skip blank lines + # detect a merge failure inserted by version control + mfail = self.rx_badmerge.match(sline) + if mfail: + message = f"\n ! - ERROR version control merge failure\n - '{sline}'\n" + message = message + f" - line {self.lineno} in {blkid} in {survexblock}\n - NERD++ needed to fix it" + print(message) + print(message,file=sys.stderr) + DataIssue.objects.create(parser='survex', message=message) + continue # skip this line + # detect a star command star = self.rx_star.match(sline) if star: # yes we are reading a *command starstatement(star) - else: # not a *cmd so we are reading data OR a ";" rx_comment failed + else: # not a *cmd so we are reading data OR a ";" rx_comment failed. We hope. self.LoadSurvexLeg(survexblock, sline, comment) self.legsnumber = slengthtotal |