(Steve Dougherty)
2013-07-03: Support freenet:// prefix to keys; add __repr__. Support freenet:// prefix to keys; add __repr__.
diff --git a/infocalypse/keys.py b/infocalypse/keys.py --- a/infocalypse/keys.py +++ b/infocalypse/keys.py @@ -9,7 +9,16 @@ class USK: self.key = components[0] self.name = components[1] - self.edition = components[2] + self.edition = int(components[2]) + + # TODO: Is stripping "freenet://" appropriate? + if self.key.startswith('freenet:'): + self.key = self.key[len('freenet:'):] + if self.key.startswith('//'): + self.key = self.key[len('//'):] def __str__(self): - return self.key + '/' + self.name + '/' + self.edition \ No newline at end of file + return '%s/%s/%s' % (self.key, self.name, self.edition) + + def __repr__(self): + return "USK(%s)" % str(self) \ No newline at end of file