#NEWLINE# def rebuild( filename , tag = None , format = 'gz' , zonegroups = [ ] , metadata = None ) : #NEWLINE# #INDENT# 'Rebuild the internal timezone info in dateutil/zoneinfo/zoneinfo*tar*\n\n    filename is the timezone tarball from ftp.iana.org/tz.\n\n    ' #NEWLINE# tmpdir = tempfile . mkdtemp ( ) #NEWLINE# zonedir = os . path . join ( tmpdir , 'zoneinfo' ) #NEWLINE# moduledir = os . path . dirname ( __file__ ) #NEWLINE# try : #NEWLINE# #INDENT# with tar_open ( filename ) as tf : #NEWLINE# #INDENT# for name in zonegroups : #NEWLINE# #INDENT# tf . extract ( name , tmpdir ) #NEWLINE# #UNINDENT# filepaths = [ os . path . join ( tmpdir , n ) for n in zonegroups ] #NEWLINE# try : #NEWLINE# #INDENT# check_call ( ( [ 'zic' , '-d' , zonedir ] + filepaths ) ) #NEWLINE# #UNINDENT# except OSError as e : #NEWLINE# #INDENT# _print_on_nosuchfile ( e ) #NEWLINE# raise #NEWLINE# #UNINDENT# #UNINDENT# with open ( os . path . join ( zonedir , METADATA_FN ) , 'w' ) as f : #NEWLINE# #INDENT# json . dump ( metadata , f , indent = 4 , sort_keys = True ) #NEWLINE# #UNINDENT# target = os . path . join ( moduledir , ZONEFILENAME ) #NEWLINE# with tar_open ( target , ( 'w:%s' % format ) ) as tf : #NEWLINE# #INDENT# for entry in os . listdir ( zonedir ) : #NEWLINE# #INDENT# entrypath = os . path . join ( zonedir , entry ) #NEWLINE# tf . add ( entrypath , entry ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# finally : #NEWLINE# #INDENT# shutil . rmtree ( tmpdir )