(cls, f, version, build_number)
return self
f should be a file-like object or a path to a zipfile
f should be a file-like object or a path to a zipfile
f should be a file - like object or a path to a zipfile
def create_from_zip(cls, f, version, build_number):
        """f should be a file-like object or a path to a zipfile"""
        self = cls(build_number=build_number, version=version, time=datetime.utcnow())
        self.save()
        # Clear cache to have this new build included immediately
        cls.j2me_enabled_builds.clear(cls)

        with ZipFile(f) as z:
            try:
                for name in z.namelist():
                    path = name.split('/')
                    if path[0] == "dist" and path[-1] != "":
                        path = '/'.join(path[1:])
                        self.put_file(z.read(name), path)
            except:
                self.delete()
                raise
        return self
def create_from_zip ( cls , f , version , build_number ) : self = cls ( build_number = build_number , version = version , time = datetime . utcnow ( ) ) self . save ( ) # Clear cache to have this new build included immediately cls . j2me_enabled_builds . clear ( cls ) with ZipFile ( f ) as z : try : for name in z . namelist ( ) : path = name . split ( '/' ) if path [ 0 ] == "dist" and path [ - 1 ] != "" : path = '/' . join ( path [ 1 : ] ) self . put_file ( z . read ( name ) , path ) except : self . delete ( ) raise return self