SF.net SVN: fclient: [98] trunk/sandbox/fcp/fcp2_0_uri.py
Status: Pre-Alpha
Brought to you by:
jurner
From: <ju...@us...> - 2008-02-01 14:43:04
|
Revision: 98 http://fclient.svn.sourceforge.net/fclient/?rev=98&view=rev Author: jurner Date: 2008-02-01 06:43:03 -0800 (Fri, 01 Feb 2008) Log Message: ----------- some fixes Modified Paths: -------------- trunk/sandbox/fcp/fcp2_0_uri.py Modified: trunk/sandbox/fcp/fcp2_0_uri.py =================================================================== --- trunk/sandbox/fcp/fcp2_0_uri.py 2008-02-01 14:42:18 UTC (rev 97) +++ trunk/sandbox/fcp/fcp2_0_uri.py 2008-02-01 14:43:03 UTC (rev 98) @@ -3,6 +3,8 @@ import base64 import re import urlparse + +import fcp2_0_consts as consts #************************************************************************************** # freenet base64 for keys #************************************************************************************** @@ -38,7 +40,7 @@ #*************************************************************************************** KeyPat = re.compile( r''' -^(CHK | SSK | SVK | USK) @ +^(CHK | SSK | SVK | USK @) ( [a-z0-9\-~]{43}, [a-z0-9\-~]{43}, @@ -49,8 +51,8 @@ def keyType(uri): """Returns the ky type of a freenet key or None if the type could not be determined""" - if uri.startswith('KSK@'): - return 'KSK' + if uri.startswith(consts.KeyType.KSK): + return consts.KeyType.KSK result = KeyPat.match(uri) if result is None: return None @@ -67,32 +69,26 @@ class Uri(object): + + KeyType = consts.KeyType + - KeyTypeSSK = 'SSK' - KeyTypeKSK = 'KSK' - KeyTypeCHK = 'CHK' - KeyTypeUSK = 'USK' - KeyTypeSVK = 'SVK' - KeyTypeInvalid = '' - KeysTypesAll = (KeyTypeSSK, KeyTypeKSK, KeyTypeCHK, KeyTypeUSK, KeyTypeSVK) - - def __init__(self, uri): self.uri = stripUri(uri) result = keyType(self.uri) - self.keyType = self.KeyTypeInvalid if result is None else result + self.keyType = self.KeyType.Invalid if result is None else result def __nonzero__(self): - return self.keyType != self.KeyTypeInvalid + return self.keyType != self.KeyType.Invalid def split(self): """Splits the uri @return: tuple(freenet-key, file-name) """ - if self.keyType() != self.KeyUnknown: + if self.keyType() != self.KeyType.Invalid: head, sep, tail = self.uri.partition('/') return head, tail return self.uri, '' This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |