[Zope-Checkins] CVS: Zope3/lib/python/Zope/Server/LineReceiver - LineCommandParser.py:1.1.2.2 LineServerChannel.py:1.1.2.2 LineTask.py:1.1.2.2 __init__.py:1.1.2.2
Shane Hathaway
shane@cvs.zope.org
Fri, 5 Apr 2002 10:01:05 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/Server/LineReceiver
In directory cvs.zope.org:/tmp/cvs-serv17395/LineReceiver
Modified Files:
Tag: Zope3-Server-Branch
LineCommandParser.py LineServerChannel.py LineTask.py
__init__.py
Log Message:
Fixed line endings again (I hope no one minds me doing this. I have a tool
that does it automatically :-)
=== Zope3/lib/python/Zope/Server/LineReceiver/LineCommandParser.py 1.1.2.1 => 1.1.2.2 ===
-#
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""
-
-$Id$
-"""
-
-from Zope.Server.IStreamConsumer import IStreamConsumer
-
-
-class LineCommandParser:
- """Line Command parser. Arguments are left alone for now."""
-
- __implements__ = IStreamConsumer
-
- # See Zope.Server.IStreamConsumer.IStreamConsumer
- completed = 0
- inbuf = ''
- cmd = ''
- args = ''
- empty = 0
-
- max_line_length = 1024 # Not a hard limit
-
-
- def __init__(self, adj):
- """
- adj is an Adjustments object.
- """
- self.adj = adj
-
-
- ############################################################
- # Implementation methods for interface
- # Zope.Server.IStreamConsumer
-
- def received(self, data):
- 'See Zope.Server.IStreamConsumer.IStreamConsumer'
- if self.completed:
- return 0 # Can't consume any more.
- pos = data.find('\n')
- datalen = len(data)
- if pos < 0:
- self.inbuf = self.inbuf + data
- if len(self.inbuf) > self.max_line_length:
- # Don't accept any more.
- self.completed = 1
- return datalen
- else:
- # Line finished.
- s = data[:pos + 1]
- self.inbuf = self.inbuf + s
- self.completed = 1
- line = self.inbuf.strip()
- self.parseLine(line)
- return len(s)
-
- #
- ############################################################
-
-
- def parseLine(self, line):
- parts = line.split(' ', 1)
- if len(parts) == 2:
- self.cmd, self.args = parts
- else:
- self.cmd = parts[0]
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+
+$Id$
+"""
+
+from Zope.Server.IStreamConsumer import IStreamConsumer
+
+
+class LineCommandParser:
+ """Line Command parser. Arguments are left alone for now."""
+
+ __implements__ = IStreamConsumer
+
+ # See Zope.Server.IStreamConsumer.IStreamConsumer
+ completed = 0
+ inbuf = ''
+ cmd = ''
+ args = ''
+ empty = 0
+
+ max_line_length = 1024 # Not a hard limit
+
+
+ def __init__(self, adj):
+ """
+ adj is an Adjustments object.
+ """
+ self.adj = adj
+
+
+ ############################################################
+ # Implementation methods for interface
+ # Zope.Server.IStreamConsumer
+
+ def received(self, data):
+ 'See Zope.Server.IStreamConsumer.IStreamConsumer'
+ if self.completed:
+ return 0 # Can't consume any more.
+ pos = data.find('\n')
+ datalen = len(data)
+ if pos < 0:
+ self.inbuf = self.inbuf + data
+ if len(self.inbuf) > self.max_line_length:
+ # Don't accept any more.
+ self.completed = 1
+ return datalen
+ else:
+ # Line finished.
+ s = data[:pos + 1]
+ self.inbuf = self.inbuf + s
+ self.completed = 1
+ line = self.inbuf.strip()
+ self.parseLine(line)
+ return len(s)
+
+ #
+ ############################################################
+
+
+ def parseLine(self, line):
+ parts = line.split(' ', 1)
+ if len(parts) == 2:
+ self.cmd, self.args = parts
+ else:
+ self.cmd = parts[0]
=== Zope3/lib/python/Zope/Server/LineReceiver/LineServerChannel.py 1.1.2.1 => 1.1.2.2 ===
__implements__ = ServerChannelBase.__implements__
- # Wrapper class that is used to execute a command in a different thread
+ # Wrapper class that is used to execute a command in a different thread
task_class = LineTask
# Class that is being initialized to parse the input
parser_class = LineCommandParser
- # List of commands that are always available
+ # List of commands that are always available
special_commands = ('cmd_quit')
# Commands that are run in a separate thread
=== Zope3/lib/python/Zope/Server/LineReceiver/LineTask.py 1.1.2.1 => 1.1.2.2 ===
class LineTask:
"""This is a generic task that can be used with command line
- protocols to handle commands in a separate thread.
+ protocols to handle commands in a separate thread.
"""
__implements__ = ITask
=== Zope3/lib/python/Zope/Server/LineReceiver/__init__.py 1.1.2.1 => 1.1.2.2 ===
-#
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""
-
-$Id$
-"""
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+
+$Id$
+"""