From f62a90b2160b5b2900da8b11fe410abce0889318 Mon Sep 17 00:00:00 2001 From: Harald Pfeiffer Date: Tue, 25 Sep 2018 16:32:04 +0200 Subject: Moving to ISO-3166-1 ALPHA-2 for files, i.e. us-OR instead of en-OR --- refresh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/refresh b/refresh index 22b9fd5..44fac16 100755 --- a/refresh +++ b/refresh @@ -74,7 +74,7 @@ def hparse(lines, locode, year): This function parses the JSON string we expect from holidata.net and writes its fragments to the specific region files, if a region is given. So, e.g.: a holiday for all of the US will not have a region definition and thus be written to file.en-US, whereas a holiday that is not - valid for all of the US but is valid for Oregon will be written to file.en-OR. + valid for all of the US but is valid for Oregon will be written to file.us-OR. """ islocdef = {} for line in lines.split('\n'): @@ -82,14 +82,15 @@ def hparse(lines, locode, year): sys.stdout.write(".") jdata = json.loads(line) mylocale = unicode(jdata['locale']) - mycountry = mylocale.split('-')[0] + mycountry = mylocale.split('-')[1] + myscountry = mycountry.lower() myregion = unicode(jdata['region']) if myregion == "": myregion = mylocale.split('-')[1] # holidata.net violates ISO-3166-2:DE here: if myregion == "NRW": myregion = "NW" # or Neustadt/Weinstr., Palz > Pott - myhlocale = unicode(mycountry + "-" + myregion) + myhlocale = unicode(myscountry + "-" + myregion) if jdata['date'] == "": print("%s has no date given for %s!", jdata['description'], jdata['locale']) mydate = unicode('1970_01_01') -- cgit v1.2.3