if rc: raise SignatureFailedError('Failed with return code: {rc}'.format(rc)) class SignatureFailedError(OSError): pass if __name__ == "__main__": (tzdata_loc, iana_sig_loc, du_sig_loc) = load_config( ('tzdata_loc', 'iana_sig_loc', 'du_sig_loc') ) from tzdata_files import get_tzdata_files, get_sig_files from tzdata_files import load_directory, data_key, sig_key d_flist = load_directory(tzdata_loc) s_flist = load_directory(iana_sig_loc) data_files = get_tzdata_files(d_flist) data_files = get_sig_files(s_flist, c_dict=data_files) invalid_sigs = [] for version, subdict in iteritems(data_files): try: dfname = subdict[data_key] except KeyError: continue try: sfname = subdict[sig_key]
if rc: raise SignatureFailedError('Failed with return code: {rc}'.format(rc)) class SignatureFailedError(OSError): pass if __name__ == "__main__": (tzdata_loc, iana_sig_loc, du_sig_loc) = load_config( ('tzdata_loc', 'iana_sig_loc', 'du_sig_loc')) from tzdata_files import get_tzdata_files, get_sig_files from tzdata_files import load_directory, data_key, sig_key d_flist = load_directory(tzdata_loc) s_flist = load_directory(iana_sig_loc) data_files = get_tzdata_files(d_flist) data_files = get_sig_files(s_flist, c_dict=data_files) invalid_sigs = [] for version, subdict in data_files.items(): try: dfname = subdict[data_key] except KeyError: continue try: sfname = subdict[sig_key]
json.dump(obj, jf, **pretty_print) if __name__ == "__main__": from os import listdir, path from six import iteritems from tzdata_files import get_tzdata_files, data_key, load_directory # Get all the valid tzdata files we have in the tzdata location (data_loc, zi_format, zi_meta_loc) = load_config(('tzdata_loc', 'zoneinfo_format_str', 'zoneinfo_metadata_loc')) flist = load_directory(data_loc) data_files = get_tzdata_files(flist) for version, subdict in iteritems(data_files): fname = subdict[data_key] fpath = path.join(data_loc, fname) zi_fname = zi_format.format(version=version) zi_fpath = path.join(zi_meta_loc, zi_fname) if not (path.exists(zi_fpath) and valid_metadata(zi_fpath, fpath)): md = generate_metadata(version, fname, fpath) save_json(zi_fpath, md)
def save_json(fpath, obj): pretty_print = dict(indent=4, sort_keys=True, separators=(',', ': ')) with open(fpath, 'w') as jf: json.dump(obj, jf, **pretty_print) if __name__ == "__main__": from os import listdir, path from tzdata_files import get_tzdata_files, data_key, load_directory # Get all the valid tzdata files we have in the tzdata location (data_loc, zi_format, zi_meta_loc) = load_config( ('tzdata_loc', 'zoneinfo_format_str', 'zoneinfo_metadata_loc')) flist = load_directory(data_loc) data_files = get_tzdata_files(flist) for version, subdict in data_files.items(): fname = subdict[data_key] fpath = path.join(data_loc, fname) zi_fname = zi_format.format(version=version) zi_fpath = path.join(zi_meta_loc, zi_fname) if not (path.exists(zi_fpath) and valid_metadata(zi_fpath, fpath)): md = generate_metadata(version, fname, fpath) save_json(zi_fpath, md)