SF.net SVN: fclient: [460] trunk/fcp2/src/fcp2/key.py
Status: Pre-Alpha
Brought to you by:
jurner
|
From: <jU...@us...> - 2008-07-01 11:27:25
|
Revision: 460
http://fclient.svn.sourceforge.net/fclient/?rev=460&view=rev
Author: jUrner
Date: 2008-07-01 04:27:35 -0700 (Tue, 01 Jul 2008)
Log Message:
-----------
for ease of use, all necessary symbols are now imported to main
Modified Paths:
--------------
trunk/fcp2/src/fcp2/key.py
Modified: trunk/fcp2/src/fcp2/key.py
===================================================================
--- trunk/fcp2/src/fcp2/key.py 2008-07-01 11:27:28 UTC (rev 459)
+++ trunk/fcp2/src/fcp2/key.py 2008-07-01 11:27:35 UTC (rev 460)
@@ -16,17 +16,14 @@
from fcp2 import consts
-del hack
+del hack, _RelImportHack
#<-- rel import hack
#**************************************************************************************
# consts
#**************************************************************************************
-ReMatchExact = '\A%s\Z'
+_ReMatchExact = '\A%s\Z'
KeyTypesAll = {}
-# for testing, arbitrary but valid key data
-DummyKeyData = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,AAAAAAA'
-
#**************************************************************************************
# freenet base64 for keys
#**************************************************************************************
@@ -73,7 +70,7 @@
# see: [freenet/src/support/base64.java]
#
#***************************************************************************************
-class KeyMeta(type):
+class _KeyMeta(type):
"""Metaclass for freenet keys"""
def __new__(klass, name, bases, kws):
@@ -90,7 +87,7 @@
#
#**************************************************************************************
#TODO: too bad, can not move this to types.py ...cross import
-class FcpTypeKey(object):
+class TypeKey(object):
"""key type for type conversions
>>> key = FcpTypeKey.fcpToPython('CHK@aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,AAAAAAA/foo')
@@ -146,20 +143,20 @@
return key.toString()
-def key(string):
+def Key(string):
"""creates a key object from a string
@return: L{KeyBase}
"""
- return FcpTypeKey.fcpToPython(string)
+ return TypeKey.fcpToPython(string)
#**************************************************************************************
#
#**************************************************************************************
-class KeyBase(object):
+class _KeyBase(object):
"""Base class for freenet keys
"""
- __metaclass__ = KeyMeta
+ __metaclass__ = _KeyMeta
KeyType = None
def __eq__(self, other):
@@ -179,7 +176,7 @@
raise NotImplementedError()
-class CHK(KeyBase):
+class KeyCHK(_KeyBase):
""""""
_key_pattern_ = '''
(?P<keyType>CHK@)
@@ -190,9 +187,9 @@
)
(?: / (?P<filename>[^/]+?)? (?: /)?)?
'''
- KeyType = consts.KeyType.CHK
+ KeyType = consts.ConstKeyType.CHK
KeyPattern = re.compile(_key_pattern_, re.I | re.X)
- ExactKeyPattern = re.compile(ReMatchExact % _key_pattern_, re.I | re.X)
+ ExactKeyPattern = re.compile(_ReMatchExact % _key_pattern_, re.I | re.X)
def __init__(self, keyData=None, filename=None):
"""Creates a CHK key
@@ -218,9 +215,10 @@
d = result.groupdict()
key = clss(d['keyData'], filename=d['filename'])
return key
-
+
+
-class SSK(KeyBase):
+class KeySSK(_KeyBase):
_key_pattern_ = '''
(?P<keyType>SSK@)
(?P<keyData>
@@ -233,9 +231,9 @@
(?: /)?
)?
'''
- KeyType = consts.KeyType.SSK
+ KeyType = consts.ConstKeyType.SSK
KeyPattern = re.compile(_key_pattern_, re.I | re.X)
- ExactKeyPattern = re.compile(ReMatchExact % _key_pattern_, re.I | re.X)
+ ExactKeyPattern = re.compile(_ReMatchExact % _key_pattern_, re.I | re.X)
def __init__(self, keyData, filename=None):
self.filename = filename
@@ -255,17 +253,18 @@
if result is not None:
d = result.groupdict()
return clss(d['keyData'], d['filename'])
-
-class KSK(KeyBase):
+
+
+class KeyKSK(_KeyBase):
_key_pattern_ = '''
(?P<keyType>KSK@)
(?P<filename>[^/]+?)
(?: /)?
'''
- KeyType = consts.KeyType.KSK
+ KeyType = consts.ConstKeyType.KSK
KeyPattern = re.compile(_key_pattern_, re.I | re.X)
- ExactKeyPattern = re.compile(ReMatchExact % _key_pattern_, re.I | re.X)
+ ExactKeyPattern = re.compile(_ReMatchExact % _key_pattern_, re.I | re.X)
def __init__(self, filename):
@@ -283,9 +282,10 @@
if result is not None:
d = result.groupdict()
return clss(filename=d['filename'])
-
+
-class USK(KeyBase):
+
+class KeyUSK(_KeyBase):
_key_pattern_ = '''
(?P<keyType>USK@)
(?P<keyData>
@@ -298,9 +298,9 @@
(?: /)?
'''
- KeyType = consts.KeyType.USK
+ KeyType = consts.ConstKeyType.USK
KeyPattern = re.compile(_key_pattern_, re.I | re.X)
- ExactKeyPattern = re.compile(ReMatchExact % _key_pattern_, re.I | re.X)
+ ExactKeyPattern = re.compile(_ReMatchExact % _key_pattern_, re.I | re.X)
def __init__(self, keyData, filename=None, edition=0):
"""Creates a USK key
@@ -330,6 +330,8 @@
d = result.groupdict()
return clss(d['keyData'], d['filename'], edition=d['edition'])
+
+__all__ = [i for i in dir() if i[0].isupper() and not i.startswith('_')]
#*****************************************************************************
#
#*****************************************************************************
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|