Treat zero or >1 dat files as an error
Based on feedback from
I7efbd6f453fe2b3e71f564121ff0f64a74289d86
Change-Id: Ie131ab8475083350dc183d9f6d5ea7a0b0617c5b
diff --git a/libc/tools/zoneinfo/update-tzdata.py b/libc/tools/zoneinfo/update-tzdata.py
index 68c893d..3dcb210 100755
--- a/libc/tools/zoneinfo/update-tzdata.py
+++ b/libc/tools/zoneinfo/update-tzdata.py
@@ -130,9 +130,14 @@
os.chdir(icu_working_dir)
icu_dat_data_dir = '%s/stubdata' % icu_dir
- for file in glob.glob('data/out/tmp/*.dat'):
- print 'Copying %s to %s ...' % (file, icu_dat_data_dir)
- shutil.copy(file, icu_dat_data_dir)
+ datfiles = glob.glob('data/out/tmp/icudt??l.dat')
+ if len(datfiles) != 1:
+ print 'ERROR: Unexpectedly found %d .dat files (%s). Halting.' % (len(datfiles), datfiles)
+ sys.exit(1)
+
+ datfile = datfiles[0]
+ print 'Copying %s to %s ...' % (datfile, icu_dat_data_dir)
+ shutil.copy(datfile, icu_dat_data_dir)
# Switch back to the original working cwd.
os.chdir(original_working_dir)