#NEWLINE# @ classmethod #NEWLINE# def create_from_zip( cls , f , version , build_number ) : #NEWLINE# #INDENT# 'f should be a file-like object or a path to a zipfile' #NEWLINE# self = cls ( build_number = build_number , version = version , time = datetime . utcnow ( ) ) #NEWLINE# self . save ( ) #NEWLINE# with ZipFile ( f ) as z : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# for name in z . namelist ( ) : #NEWLINE# #INDENT# path = name . split ( '/' ) #NEWLINE# if ( ( path [ 0 ] == 'dist' ) and ( path [ ( - 1 ) ] != '' ) ) : #NEWLINE# #INDENT# path = '/' . join ( path [ 1 : ] ) #NEWLINE# self . put_file ( z . read ( name ) , path ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# except : #NEWLINE# #INDENT# self . delete ( ) #NEWLINE# raise #NEWLINE# #UNINDENT# #UNINDENT# return self