[docs]deffrom_file(file:str|LocalFile,configuration:SIO3PackConfig=None)->Package:""" Initialize a package object from a file (archive or directory). :param file: The file path or File object. :param configuration: Configration of the package. :return: The package object. """ifisinstance(file,str):file=LocalFile(file)returnPackage.from_file(file,configuration=configuration)
[docs]deffrom_db(problem_id:int,configuration:SIO3PackConfig=None)->Package:""" Initialize a package object from the database. If sio3pack isn't installed with Django support, it should raise an ImproperlyConfigured exception. If there is no package with the given problem_id, it should raise an UnknownPackageType exception. :param problem_id: The problem id. :param configuration: Configuration of the package. :return: The package object. """try:fromdjango.confimportsettingsconfiguration=configurationorSIO3PackConfig()configuration.django_settings=settingsreturnPackage.from_db(problem_id,configuration)exceptImportError:raiseImproperlyConfigured("sio3pack is not installed with Django support.","from_db function was used, but sio3pack isn't installed with Django support. ""Read the documentation to learn more.",)