~earboxer/zachwalk

42a9c82d7a4f2548b61d286b152387333693ba12 — Zach DeCook 5 months ago 17d4fa5 master
date: Check all link lines

(rather than just the first one with a date)
2 files changed, 7 insertions(+), 4 deletions(-)

M test_zachwalk.py
M zachwalk.py
M test_zachwalk.py => test_zachwalk.py +1 -1
@@ 14,7 14,7 @@ def main():
    assert zachwalk.gnd(['=> geminitoepub.gmi     2021-02-27 Gemini to Epub']) == parse('2021-02-27').date()
    assert zachwalk.gnd(['=> m5paper.gmi	2021-01-31 M5Paper']) == parse('2021-01-31').date()
    assert zachwalk.gnd(['=> gemini://fossphones.com/03-29-22.gmi 2022-03-29 Linux Phone News - March 29, 2022']) == parse('2022-03-29').date()

    assert zachwalk.gnd(['=> pizza.gmi 1999-01-01 yum', '=> crepes.gmi 2099-01-01 cool']) == parse('2099-01-01').date()

    assert zachwalk.getdesc('=> m5paper.gmi	2021-01-31 M5Paper') == '2021-01-31 M5Paper'


M zachwalk.py => zachwalk.py +6 -3
@@ 33,6 33,7 @@ def getnewestdate(url):
    # TODO: something special if status is not 2x
    return gnd(fp)
def gnd(fp):
    nd = DEFAULT
    for line in fp:
     if type(line) != str:
       line=line.decode('UTF-8')


@@ 40,15 41,17 @@ def gnd(fp):
      desc =getdesc(line)
      try:
        date = parse(desc[0:10],fuzzy=True).date()
        return date
        if date > nd:
          nd = date
      except:
        try:
          date = parse(desc,fuzzy=True).date()
          return date
          if date > nd:
            nd = date
        except:
          pass
        pass
    return DEFAULT
    return nd

def replaceDateIfNewer(desc, newestdate):
    try: