You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
518 B
16 lines
518 B
from .distribution import Distribution
|
|
|
|
class Index(dict):
|
|
|
|
def __setitem__(self, key, value):
|
|
if not isinstance(value, Distribution):
|
|
raise ValueError('Not a distribution: %r.' % value)
|
|
if key != '%s-%s' % (value.name, value.version):
|
|
raise ValueError('Key must match <name>-<version>.')
|
|
super(Index, self).__setitem__(key, value)
|
|
|
|
def add(self, distribution):
|
|
key = '%s-%s' % (distribution.name, distribution.version)
|
|
self[key] = distribution
|
|
|