changeset 102:e606c609f813

reinstate better check to start queuing, check for missed match leading to potential runaway
author Henry S. Thompson <ht@inf.ed.ac.uk>
date Tue, 12 Sep 2023 12:14:04 +0100
parents e2e64c3d763e
children 7d58dc01f329
files bin/merge_date.py
diffstat 1 files changed, 21 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/bin/merge_date.py	Mon Sep 11 22:06:45 2023 +0100
+++ b/bin/merge_date.py	Tue Sep 12 12:14:04 2023 +0100
@@ -133,41 +133,42 @@
       else:
         # still looking, save if >= date else fall through to write
         if DEBUG>1:
-          print("Diso: xkey: %s\n"
+          print("Diso: match: %s\n"
+                "      xkey: %s\n"
                 "      dkey: %s\n"
                 "      xdate: %s\n"
                 "      ddate: %s\n"
                 "      xurl: %s\n"
                 "      durl: %s\n"
-                "xl: %s"%(xkey, dkey, xdate, ddate, xurl, durl, xl),
+                "xl: %s"%(not noMatch,
+                          xkey, dkey, xdate, ddate, xurl, durl, xl),
                 file=sys.stderr)
-        if not noMatch:
+        if (dkey.startswith(xkey1) and
+            (ddate!=xdate or (xkey2 is not None and dkey!=xkey2))):
           xq.append(xl)
           if DEBUG>1:
             sys.stderr.write('xpush\n')
           continue
         # else fall through
-    else:
-      # Not messyD
-      if messyU:
-        raise ValueError("messyU w/o messyD:"
-                        "xkey: %s\n"
-                "dkey: %s\n"
-                "xdate: %s\n"
-                "ddate: %s\n"
-                "xurl: %s\n"
-                "durl: %s\n"
-                "dfq: %s\n"
-                "k1, k2: |%s|%s|\n"
-                "FN: %s XCNT: %s DCNT: %s\n"
-                "xl: %s"%(xkey, dkey, xdate, ddate, xurl, durl,
-                          (b'\n     '.join(dfq)).decode('ascii'),
-                          xkey1, xkey2, FN, XCNT, DCNT, xl))
     if (ddate != xdate or
             not dkey.startswith(xkey1) or
             (xkey2 is not None and dkey!=xkey2) or
         durl!=xurl):
+      if DEBUG and dkey and xkey.decode('ascii')>(dkey.decode('ascii')):
+        
+        raise ValueError("Fail: xkey: %s\n"
+               "      dkey: %s\n"
+               "      xdate: %s\n"
+               "      ddate: %s\n"
+               "dfq: %s\n"
+               "k1, k2: |%s|%s|\n"
+               "FN: %s XCNT: %s DCNT: %s\n"
+               "xl: %s"%(xkey, dkey, xdate, ddate,
+                         (b'\n     '.join(dfq)).decode('ascii'),
+                         xkey1, xkey2, FN, XCNT, DCNT, xl))
       NF.write(xl)
+      if DEBUG>1:
+        sys.stderr.write("out_nl\n")
       continue
     # Got it
     NF.write(xkey)
@@ -177,7 +178,7 @@
     NF.write(xprops[:-2])
     NF.write(b', "lastmod": "%d"}\n'%int(dtime[:-3]))
     if DEBUG>1:
-      sys.stderr.write("out: %s"%(' '.join(xp.decode('ascii')
+      sys.stderr.write("out_t: %s"%(' '.join(xp.decode('ascii')
                                            for xp in (xkey, xdate, xurl))))
       sys.stderr.write(" %d\n"%int(dtime[:-3]))
     dl = df.readline()