SF.net SVN: fclient: [530] trunk/fcp2/src/fcp2
Status: Pre-Alpha
Brought to you by:
jurner
From: <jU...@us...> - 2008-07-07 07:14:37
|
Revision: 530 http://fclient.svn.sourceforge.net/fclient/?rev=530&view=rev Author: jUrner Date: 2008-07-07 00:14:44 -0700 (Mon, 07 Jul 2008) Log Message: ----------- still struggling with relative imports. hopefuly fixed now Modified Paths: -------------- trunk/fcp2/src/fcp2/__init__.py trunk/fcp2/src/fcp2/client.py trunk/fcp2/src/fcp2/config.py trunk/fcp2/src/fcp2/consts.py trunk/fcp2/src/fcp2/events.py trunk/fcp2/src/fcp2/iohandler.py trunk/fcp2/src/fcp2/key.py trunk/fcp2/src/fcp2/message.py trunk/fcp2/src/fcp2/types.py Modified: trunk/fcp2/src/fcp2/__init__.py =================================================================== --- trunk/fcp2/src/fcp2/__init__.py 2008-07-06 21:41:05 UTC (rev 529) +++ trunk/fcp2/src/fcp2/__init__.py 2008-07-07 07:14:44 UTC (rev 530) @@ -4,33 +4,46 @@ @requires: python >= 2.5 """ -import os, sys - +from __future__ import absolute_import +if __name__ == '__main__': # see --> http://bugs.python.org/issue1510172 . works only current dir and below + import os; __path__ = [os.path.dirname(__file__)] + __author__ = 'Juergen Urner' __copyright__ = '(c) 2008 - Juergen Urner' __email__ = 'jue...@ar...' __licence__ = 'Mit' __version__ = '0.0.1' - -#--> rel import hack -class _RelImportHack(object): - def __init__(self, n): - fpath = os.path.abspath(__file__) - for i in xrange(n): fpath = os.path.dirname(fpath) - sys.path.insert(0, fpath) - def __del__(self): sys.path.pop(0) -hack = _RelImportHack(2) - -from fcp2.client import * -from fcp2.config import * -from fcp2.consts import * -from fcp2.key import * -from fcp2.message import * -from fcp2.types import * - -del hack, _RelImportHack -#<-- rel import hack +from .client import Client +from .config import (Config, ConfigDataType, ConfigItem, ConfigKeySep, ConfigValueClass) +from .consts import (ConstByteAmountPostfix, ConstConnectReason, ConstDebugVerbosity, ConstDisconnectReason, + ConstFetchError, ConstFilenameCollision, ConstInsertError, ConstKeyType, ConstLogMessages, + ConstLogger, ConstMessage, ConstPeerNodeStatus, ConstPeerNoteType, ConstPersistence, + ConstPriority, ConstProtocolError, ConstPutDirType, ConstRequestModified, ConstRequestStatus, + ConstRequestType, ConstReturnType, ConstTimeDeltaPostfix, ConstUploadFrom, ConstVerbosity, + Error, ErrorIOBroken, ErrorIOClosed, ErrorIOConnectFailed, ErrorIOTimeout, ErrorMessageParse, + FcpFalse, FcpTrue) +from .key import (Key, KeyCHK, KeyKSK, KeySSK, KeyTypesAll, KeyUSK, TypeKey, base64UrlsaveDecode, keyNormkey) +from .message import (MessagesAll, MsgAddPeer, MsgAllData, MsgClientDisconnected, MsgClientGet, MsgClientHello, + MsgClientPut, MsgClientPutComplexDir, MsgClientPutDiskDir, MsgClientSocketDied, + MsgClientSocketTimeout, MsgCloseConnectionDuplicateClientName, MsgConfigData, MsgDataFound, + MsgEndListPeerNotes, MsgEndListPeers, MsgEndListPersistentRequests, MsgFCPPluginMessage, + MsgFCPPluginReply, MsgFinishedCompression, MsgGenerateSSK, MsgGetConfig, MsgGetFailed, + MsgGetNode, MsgGetPluginInfo, MsgGetRequestStatus, MsgIdentifierCollision, MsgListPeer, + MsgListPeerNotes, MsgListPeers, MsgListPersistentRequests, MsgModifyConfig, MsgModifyPeer, + MsgModifyPeerNote, MsgModifyPersistentRequest, MsgNodeData, MsgNodeHello, MsgPeer, MsgPeerNote, + MsgPeerRemoved, MsgPersistentGet, MsgPersistentPut, MsgPersistentPutDir, MsgPersistentRequestModified, + MsgPersistentRequestRemoved, MsgPluginInfo, MsgProtocolError, MsgPutFailed, MsgPutFetchable, + MsgPutSuccessful, MsgRemovePeer, MsgRemoveRequest, MsgSSKKeypair, MsgShutdown, MsgSimpleProgress, + MsgStartedCompression, MsgSubscribeUSK, MsgSubscribedUSK, MsgSubscribedUSKUpdate, + MsgTestDDAComplete, MsgTestDDAReply, MsgTestDDARequest, MsgTestDDAResponse, MsgURIGenerated, + MsgUnknownNodeIdentifier, MsgUnknownPeerNoteType, MsgWatchGlobal, PersistentParamsSep, + newMessageClass) +from .types import (Type, TypeBase64EncodedString, TypeBool, TypeByteAmount, TypeChoiceFProxyCss, TypeChoiceLoggerPriority, + TypeChoiceNodeDownloadAllowedDirs, TypeChoiceNodeUploadAllowedDirs, TypeChoicePriorityPolicy, + TypeChoiceSSLVersion, TypeDirname, TypeFilename, TypeFloat, TypeIP, TypeIPList, TypeIPort, TypeInt, + TypeIntWithBounds, TypeInt_GetFailed_ExpectedDataLenght, TypePercent, TypeString, TypeStringList, TypeTime, + TypeTimeDelta, TypeUri) #**************************************************************************************** # #**************************************************************************************** Modified: trunk/fcp2/src/fcp2/client.py =================================================================== --- trunk/fcp2/src/fcp2/client.py 2008-07-06 21:41:05 UTC (rev 529) +++ trunk/fcp2/src/fcp2/client.py 2008-07-07 07:14:44 UTC (rev 530) @@ -201,41 +201,33 @@ # someday to handle this # #------------------------------------------------------------------------------------------------------------------------------------------------ - +from __future__ import absolute_import +if __name__ == '__main__': # see --> http://bugs.python.org/issue1510172 . works only current dir and below + import os; __path__ = [os.path.dirname(__file__)] + + import os, sys import atexit import copy -import logging +import logging +import random import subprocess import time -import uuid -#--> rel import hack -class _RelImportHack(object): - def __init__(self, n): - fpath = os.path.abspath(__file__) - for i in xrange(n): fpath = os.path.dirname(fpath) - sys.path.insert(0, fpath) - def __del__(self): sys.path.pop(0) -hack = _RelImportHack(2) +from . import consts +from . import config +from . import events +from . import message +from . import iohandler +from . import types +from . import key -from fcp2 import consts -from fcp2 import config -from fcp2 import events -from fcp2 import message -from fcp2 import iohandler -from fcp2 import types -from fcp2 import key -import random +from .lib import namespace +from .lib import tools -from fcp2.lib import namespace -from fcp2.lib import tools -del hack, _RelImportHack -#<-- rel import hack - __all__ = ['Client', ] #************************************************************************************************* # Modified: trunk/fcp2/src/fcp2/config.py =================================================================== --- trunk/fcp2/src/fcp2/config.py 2008-07-06 21:41:05 UTC (rev 529) +++ trunk/fcp2/src/fcp2/config.py 2008-07-07 07:14:44 UTC (rev 530) @@ -45,25 +45,16 @@ as L{types.Type}. """ -import os, sys -import logging +from __future__ import absolute_import +if __name__ == '__main__': # see --> http://bugs.python.org/issue1510172 . works only current dir and below + import os; __path__ = [os.path.dirname(__file__)] -#--> rel import hack -class _RelImportHack(object): - def __init__(self, n): - fpath = os.path.abspath(__file__) - for i in xrange(n): fpath = os.path.dirname(fpath) - sys.path.insert(0, fpath) - def __del__(self): sys.path.pop(0) -hack = _RelImportHack(2) -from fcp2 import consts -from fcp2 import types -from fcp2 import key +import logging - -del hack, _RelImportHack -#<-- rel import hack +from . import consts +from . import types +from . import key #**************************************************************************************** # #**************************************************************************************** @@ -123,6 +114,7 @@ """ # all known config keys (param class stripped) + Params = { 'console.allowedHosts': types.TypeIPList, # host names, single IPs CIDR-maskip IPs likee 192.168.0.0/24 @@ -460,11 +452,19 @@ yield x return walker(self) - -__all__ = [i for i in dir() if i[0].isupper() and not i.startswith('_')] + #**************************************************************************************************** # #**************************************************************************************************** +def _all_(): + '''* imports are disallowed for relative imports. this print out the list of exported names''' + L = [i for i in globals() if i[0].isupper() and not i.startswith('_')] + L.sort() + print '(' + ', '.join(L) + ')' +#_all_() + + + Modified: trunk/fcp2/src/fcp2/consts.py =================================================================== --- trunk/fcp2/src/fcp2/consts.py 2008-07-06 21:41:05 UTC (rev 529) +++ trunk/fcp2/src/fcp2/consts.py 2008-07-07 07:14:44 UTC (rev 530) @@ -523,5 +523,13 @@ ReportProgress = 0x1 ReportCompression = 0x200 - -__all__ = [i for i in dir() if i[0].isupper() and not i.startswith('_')] +#**************************************************************************************************** +# +#**************************************************************************************************** +def _all_(): + '''* imports are disallowed for relative imports. this print out the list of exported names''' + L = [i for i in globals() if i[0].isupper() and not i.startswith('_')] + L.sort() + print '(' + ', '.join(L) + ')' +#_all_() + Modified: trunk/fcp2/src/fcp2/events.py =================================================================== --- trunk/fcp2/src/fcp2/events.py 2008-07-06 21:41:05 UTC (rev 529) +++ trunk/fcp2/src/fcp2/events.py 2008-07-07 07:14:44 UTC (rev 530) @@ -1,25 +1,14 @@ """Fcp events """ +from __future__ import absolute_import + import os, sys -#--> rel import hack -class _RelImportHack(object): - def __init__(self, n): - fpath = os.path.abspath(__file__) - for i in xrange(n): fpath = os.path.dirname(fpath) - sys.path.insert(0, fpath) - def __del__(self): sys.path.pop(0) -hack = _RelImportHack(2) - -from fcp2 import consts -from fcp2 import types -from fcp2.lib import events - - -del hack, _RelImportHack -#<-- rel import hack +from . import consts +from . import types +from .lib import events #******************************************************************************* # #******************************************************************************* Modified: trunk/fcp2/src/fcp2/iohandler.py =================================================================== --- trunk/fcp2/src/fcp2/iohandler.py 2008-07-06 21:41:05 UTC (rev 529) +++ trunk/fcp2/src/fcp2/iohandler.py 2008-07-07 07:14:44 UTC (rev 530) @@ -3,28 +3,17 @@ The module can be used to handle reading and writing of messages io from sockeet, file or whatever """ - +from __future__ import absolute_import +if __name__ == '__main__': # see --> http://bugs.python.org/issue1510172 . works only current dir and below + import os; __path__ = [os.path.dirname(__file__)] + + import os, sys -import logging import socket import time - -#--> rel import hack, so we don't have to put the package on sys.path -class _RelImportHack(object): - def __init__(self, n): - fpath = os.path.abspath(__file__) - for i in xrange(n): fpath = os.path.dirname(fpath) - sys.path.insert(0, fpath) - def __del__(self): sys.path.pop(0) -hack = _RelImportHack(2) - -from fcp2 import consts -from fcp2 import message -from fcp2 import types - -del hack, _RelImportHack -#<-- rel import hack +from . import consts +from . import message #***************************************************************************** # #***************************************************************************** @@ -359,10 +348,4 @@ raise ValueError('IOObject.BufferSize must be > 0') self._ioPrototype = ioObject - -#*********************************************************************************************** -# -#*********************************************************************************************** -if __name__ == '__main__': - pass \ No newline at end of file Modified: trunk/fcp2/src/fcp2/key.py =================================================================== --- trunk/fcp2/src/fcp2/key.py 2008-07-06 21:41:05 UTC (rev 529) +++ trunk/fcp2/src/fcp2/key.py 2008-07-07 07:14:44 UTC (rev 530) @@ -1,4 +1,7 @@ -"""Fcp keys""" +"""Fcp keys""" +from __future__ import absolute_import +if __name__ == '__main__': # see --> http://bugs.python.org/issue1510172 . works only current dir and below + import os; __path__ = [os.path.dirname(__file__)] import os, sys import base64 @@ -7,19 +10,7 @@ import urllib import urlparse -#--> rel import hack -class _RelImportHack(object): - def __init__(self, n): - fpath = os.path.abspath(__file__) - for i in xrange(n): fpath = os.path.dirname(fpath) - sys.path.insert(0, fpath) - def __del__(self): sys.path.pop(0) -hack = _RelImportHack(2) - -from fcp2 import consts - -del hack, _RelImportHack -#<-- rel import hack +from . import consts #************************************************************************************** # consts #************************************************************************************** @@ -357,7 +348,14 @@ return clss(d['keyData'], docName=d['docName'], edition=edition, tail=d['tail'], pManifest=bool(d['pManifest'])) - -__all__ = [i for i in dir() if i[0].isupper() and not i.startswith('_')] -__all__.append('base64UrlsaveDecode') -__all__.append('keyNormkey') +#**************************************************************************************************** +# +#**************************************************************************************************** +def _all_(): + '''* imports are disallowed for relative imports. this print out the list of exported names''' + L = [i for i in globals() if i[0].isupper() and not i.startswith('_')] + L.append('base64UrlsaveDecode') + L.append('keyNormkey') + L.sort() + print '(' + ', '.join(L) + ')' +#_all_() Modified: trunk/fcp2/src/fcp2/message.py =================================================================== --- trunk/fcp2/src/fcp2/message.py 2008-07-06 21:41:05 UTC (rev 529) +++ trunk/fcp2/src/fcp2/message.py 2008-07-07 07:14:44 UTC (rev 530) @@ -1,28 +1,19 @@ """Freennet Client Protocol messages """ +from __future__ import absolute_import +if __name__ == '__main__': # see --> http://bugs.python.org/issue1510172 . works only current dir and below + import os; __path__ = [os.path.dirname(__file__)] + import os, sys import base64 import socket -#--> rel import hack -class _RelImportHack(object): - def __init__(self, n): - fpath = os.path.abspath(__file__) - for i in xrange(n): fpath = os.path.dirname(fpath) - sys.path.insert(0, fpath) - def __del__(self): sys.path.pop(0) -hack = _RelImportHack(2) - -from fcp2 import consts -from fcp2 import config -from fcp2 import types -from fcp2 import key -from fcp2.lib import node - - -del hack, _RelImportHack -#<-- rel import hack +from . import consts +from . import config +from . import types +from . import key +from .lib import node #******************************************************************************** # consts #******************************************************************************** @@ -1159,5 +1150,13 @@ } -__all__ = [i for i in dir() if i[0].isupper() and not i.startswith('_')] -__all__.append('newMessageClass') \ No newline at end of file +#**************************************************************************************************** +# +#**************************************************************************************************** +def _all_(): + '''* imports are disallowed for relative imports. this print out the list of exported names''' + L = [i for i in globals() if i[0].isupper() and not i.startswith('_')] + L.append('newMessageClass') + L.sort() + print '(' + ', '.join(L) + ')' +#_all_() Modified: trunk/fcp2/src/fcp2/types.py =================================================================== --- trunk/fcp2/src/fcp2/types.py 2008-07-06 21:41:05 UTC (rev 529) +++ trunk/fcp2/src/fcp2/types.py 2008-07-07 07:14:44 UTC (rev 530) @@ -2,25 +2,15 @@ This module handles type conversions from Fcp to Python and vice versa """ +from __future__ import absolute_import +if __name__ == '__main__': # see --> http://bugs.python.org/issue1510172 . works only current dir and below + import os; __path__ = [os.path.dirname(__file__)] import os, sys import base64 import re -#--> rel import hack -class _RelImportHack(object): - def __init__(self, n): - fpath = os.path.abspath(__file__) - for i in xrange(n): fpath = os.path.dirname(fpath) - sys.path.insert(0, fpath) - def __del__(self): sys.path.pop(0) -hack =_RelImportHack(2) - -from fcp2 import consts - - -del hack -#<-- rel import hack +from . import consts #************************************************************************************* # #************************************************************************************* @@ -263,11 +253,14 @@ ChoicesAllowMultiple = False -__all__ = [i for i in dir() if i[0].isupper() and not i.startswith('_')] -#******************************************************************************************** +#**************************************************************************************************** # -#******************************************************************************************** -if __name__ == '__main__': - import doctest - doctest.testmod() +#**************************************************************************************************** +def _all_(): + '''* imports are disallowed for relative imports. this print out the list of exported names''' + L = [i for i in globals() if i[0].isupper() and not i.startswith('_')] + L.sort() + print '(' + ', '.join(L) + ')' +#_all_() + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |