<s> import os <EOL> from django . conf import settings <EOL> from django . db import models <EOL> from django . utils . translation import ugettext_lazy as _ <EOL> from django . contrib . auth . models import User <EOL> OS_NAMES = ( <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ) <EOL> ARCHITECTURES = ( <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ) <EOL> UPLOAD_TO = getattr ( settings , <EOL> "<STR_LIT>" , '<STR_LIT>' ) <EOL> class Classifier ( models . Model ) : <EOL> name = models . CharField ( max_length = <NUM_LIT:255> , unique = True ) <EOL> class Meta : <EOL> verbose_name = _ ( u"<STR_LIT>" ) <EOL> verbose_name_plural = _ ( u"<STR_LIT>" ) <EOL> def __unicode__ ( self ) : <EOL> return self . name <EOL> class Project ( models . Model ) : <EOL> name = models . CharField ( max_length = <NUM_LIT:255> , unique = True ) <EOL> license = models . TextField ( blank = True ) <EOL> metadata_version = models . CharField ( max_length = <NUM_LIT:64> , default = <NUM_LIT:1.0> ) <EOL> author = models . CharField ( max_length = <NUM_LIT> , blank = True ) <EOL> home_page = models . URLField ( verify_exists = False , blank = True , null = True ) <EOL> download_url = models . CharField ( max_length = <NUM_LIT:200> , blank = True , null = True ) <EOL> summary = models . TextField ( blank = True ) <EOL> description = models . TextField ( blank = True ) <EOL> author_email = models . CharField ( max_length = <NUM_LIT:255> , blank = True ) <EOL> classifiers = models . ManyToManyField ( Classifier ) <EOL> owner = models . ForeignKey ( User , related_name = "<STR_LIT>" ) <EOL> updated = models . DateTimeField ( auto_now = True ) <EOL> class Meta : <EOL> verbose_name = _ ( u"<STR_LIT>" ) <EOL> verbose_name_plural = _ ( u"<STR_LIT>" ) <EOL> def __unicode__ ( self ) : <EOL> return self . name <EOL> @ models . permalink <EOL> def get_absolute_url ( self ) : <EOL> return ( '<STR_LIT>' , ( ) , { '<STR_LIT>' : self . name } ) <EOL> @ models . permalink <EOL> def get_pypi_absolute_url ( self ) : <EOL> return ( '<STR_LIT>' , ( ) , { '<STR_LIT>' : self . name } ) <EOL> def get_release ( self , version ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> return self . releases . get ( version = version ) <EOL> except Release . DoesNotExist : <EOL> return None <EOL> class Release ( models . Model ) : <EOL> version = models . CharField ( max_length = <NUM_LIT:32> ) <EOL> distribution = models . FileField ( upload_to = UPLOAD_TO ) <EOL> md5_digest = models . CharField ( max_length = <NUM_LIT:255> , blank = True ) <EOL> platform = models . CharField ( max_length = <NUM_LIT> , blank = True ) <EOL> signature = models . CharField ( max_length = <NUM_LIT> , blank = True ) <EOL> filetype = models . CharField ( max_length = <NUM_LIT:255> , blank = True ) <EOL> pyversion = models . CharField ( max_length = <NUM_LIT:32> , blank = True ) <EOL> project = models . ForeignKey ( Project , related_name = "<STR_LIT>" ) <EOL> upload_time = models . DateTimeField ( auto_now = True ) <EOL> class Meta : <EOL> verbose_name = _ ( u"<STR_LIT>" ) <EOL> verbose_name_plural = _ ( u"<STR_LIT>" ) <EOL> unique_together = ( "<STR_LIT>" , "<STR_LIT:version>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> def __unicode__ ( self ) : <EOL> return u"<STR_LIT>" % ( self . release_name , self . platform ) <EOL> @ property <EOL> def type ( self ) : <EOL> dist_file_types = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } <EOL> return dist_file_types . get ( self . filetype , self . filetype ) <EOL> @ property <EOL> def filename ( self ) : <EOL> return os . path . basename ( self . distribution . name ) <EOL> @ property <EOL> def release_name ( self ) : <EOL> return u"<STR_LIT>" % ( self . project . name , self . version ) <EOL> @ property <EOL> def path ( self ) : <EOL> return self . distribution . name <EOL> @ models . permalink <EOL> def get_absolute_url ( self ) : <EOL> return ( '<STR_LIT>' , ( ) , { '<STR_LIT>' : self . project , '<STR_LIT:version>' : self . version } ) <EOL> def get_dl_url ( self ) : <EOL> return "<STR_LIT>" % ( self . distribution . url , self . md5_digest ) </s>
