make package cybertools.tracking Python3-ready
This commit is contained in:
		
							parent
							
								
									43ea46e401
								
							
						
					
					
						commit
						fad566b354
					
				
					 8 changed files with 55 additions and 87 deletions
				
			
		
							
								
								
									
										21
									
								
								LICENSE
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								LICENSE
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,21 @@
 | 
			
		|||
The MIT License (MIT) 
 | 
			
		||||
 | 
			
		||||
Copyright (C) 2023 cyberconcepts.org team
 | 
			
		||||
 | 
			
		||||
Permission is hereby granted, free of charge, to any person obtaining a copy
 | 
			
		||||
of this software and associated documentation files (the "Software"), to deal
 | 
			
		||||
in the Software without restriction, including without limitation the rights
 | 
			
		||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 | 
			
		||||
copies of the Software, and to permit persons to whom the Software is
 | 
			
		||||
furnished to do so, subject to the following conditions:
 | 
			
		||||
 | 
			
		||||
The above copyright notice and this permission notice shall be included in all
 | 
			
		||||
copies or substantial portions of the Software.
 | 
			
		||||
 | 
			
		||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 | 
			
		||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 | 
			
		||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 | 
			
		||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 | 
			
		||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 | 
			
		||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 | 
			
		||||
SOFTWARE.
 | 
			
		||||
| 
						 | 
				
			
			@ -1,27 +1,8 @@
 | 
			
		|||
#
 | 
			
		||||
#  Copyright (c) 2006 Helmut Merz helmutm@cy55.de
 | 
			
		||||
#
 | 
			
		||||
#  This program is free software; you can redistribute it and/or modify
 | 
			
		||||
#  it under the terms of the GNU General Public License as published by
 | 
			
		||||
#  the Free Software Foundation; either version 2 of the License, or
 | 
			
		||||
#  (at your option) any later version.
 | 
			
		||||
#
 | 
			
		||||
#  This program is distributed in the hope that it will be useful,
 | 
			
		||||
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
#  GNU General Public License for more details.
 | 
			
		||||
#
 | 
			
		||||
#  You should have received a copy of the GNU General Public License
 | 
			
		||||
#  along with this program; if not, write to the Free Software
 | 
			
		||||
#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 | 
			
		||||
#
 | 
			
		||||
# cybertools.text.base
 | 
			
		||||
 | 
			
		||||
"""
 | 
			
		||||
Base classes for text transformations.
 | 
			
		||||
"""Base classes for text transformations.
 | 
			
		||||
 | 
			
		||||
Based on code provided by zc.index and TextIndexNG3.
 | 
			
		||||
 | 
			
		||||
$Id$
 | 
			
		||||
"""
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,23 +1,6 @@
 | 
			
		|||
#
 | 
			
		||||
#  Copyright (c) 2016 Helmut Merz helmutm@cy55.de
 | 
			
		||||
#
 | 
			
		||||
#  This program is free software; you can redistribute it and/or modify
 | 
			
		||||
#  it under the terms of the GNU General Public License as published by
 | 
			
		||||
#  the Free Software Foundation; either version 2 of the License, or
 | 
			
		||||
#  (at your option) any later version.
 | 
			
		||||
#
 | 
			
		||||
#  This program is distributed in the hope that it will be useful,
 | 
			
		||||
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
#  GNU General Public License for more details.
 | 
			
		||||
#
 | 
			
		||||
#  You should have received a copy of the GNU General Public License
 | 
			
		||||
#  along with this program; if not, write to the Free Software
 | 
			
		||||
#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 | 
			
		||||
#
 | 
			
		||||
# cybertools.tracking.btree
 | 
			
		||||
 | 
			
		||||
"""
 | 
			
		||||
ZODB-/BTree-based implementation of user interaction tracking.
 | 
			
		||||
"""ZODB-/BTree-based implementation of user interaction tracking.
 | 
			
		||||
"""
 | 
			
		||||
 | 
			
		||||
import time
 | 
			
		||||
| 
						 | 
				
			
			@ -25,7 +8,7 @@ from persistent import Persistent
 | 
			
		|||
from BTrees import OOBTree, IOBTree
 | 
			
		||||
from BTrees.IFBTree import intersection, union
 | 
			
		||||
from zope.component import adapter
 | 
			
		||||
from zope.interface import implements
 | 
			
		||||
from zope.interface import implementer
 | 
			
		||||
from zope.app.container.btree import BTreeContainer
 | 
			
		||||
from zope.app.container.interfaces import IObjectRemovedEvent
 | 
			
		||||
from zope.index.field import FieldIndex
 | 
			
		||||
| 
						 | 
				
			
			@ -36,10 +19,9 @@ from cybertools.tracking.interfaces import IRun, ITrackingStorage, ITrack
 | 
			
		|||
from cybertools.util.date import getTimeStamp, timeStamp2ISO
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@implementer(IRun)
 | 
			
		||||
class Run(object):
 | 
			
		||||
 | 
			
		||||
    implements(IRun)
 | 
			
		||||
 | 
			
		||||
    id = start = end = 0
 | 
			
		||||
    finished = False
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -53,11 +35,9 @@ class Run(object):
 | 
			
		|||
                                       str(self.finished)))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@implementer(ITrack)
 | 
			
		||||
class Track(Persistent):
 | 
			
		||||
 | 
			
		||||
    #implements(ITrack, IPhysicallyLocatable)
 | 
			
		||||
    implements(ITrack)
 | 
			
		||||
 | 
			
		||||
    metadata_attributes = ('taskId', 'runId', 'userName', 'timeStamp')
 | 
			
		||||
    index_attributes = metadata_attributes
 | 
			
		||||
    typeName = 'Track'
 | 
			
		||||
| 
						 | 
				
			
			@ -112,10 +92,9 @@ class Track(Persistent):
 | 
			
		|||
        return self.__name__
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@implementer(ITrackingStorage)
 | 
			
		||||
class TrackingStorage(BTreeContainer):
 | 
			
		||||
 | 
			
		||||
    implements(ITrackingStorage)
 | 
			
		||||
 | 
			
		||||
    trackFactory = Track
 | 
			
		||||
    indexAttributes = trackFactory.index_attributes
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -293,7 +272,7 @@ class TrackingStorage(BTreeContainer):
 | 
			
		|||
                resultx = None
 | 
			
		||||
                for v in value:
 | 
			
		||||
                    v2 = v
 | 
			
		||||
                    if isinstance(v, basestring) and v.endswith('*'):
 | 
			
		||||
                    if isinstance(v, str) and v.endswith('*'):
 | 
			
		||||
                        v = v[:-1]
 | 
			
		||||
                        v2 = v + 'z'
 | 
			
		||||
                    resultx = self.union(resultx, self.indexes[idx].apply((v, v2)))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,8 @@
 | 
			
		|||
 | 
			
		||||
import unittest, doctest
 | 
			
		||||
import warnings
 | 
			
		||||
 | 
			
		||||
#warnings.filterwarnings('ignore', category=DeprecationWarning)
 | 
			
		||||
 | 
			
		||||
class Test(unittest.TestCase):
 | 
			
		||||
    "Basic tests for the cybertools.tracking.comment package."
 | 
			
		||||
| 
						 | 
				
			
			@ -12,7 +14,7 @@ class Test(unittest.TestCase):
 | 
			
		|||
def test_suite():
 | 
			
		||||
    flags = doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS
 | 
			
		||||
    return unittest.TestSuite((
 | 
			
		||||
                unittest.makeSuite(Test),
 | 
			
		||||
        unittest.TestLoader().loadTestsFromTestCase(Test),
 | 
			
		||||
        doctest.DocFileSuite('README.txt', optionflags=flags),
 | 
			
		||||
    ))
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -23,9 +23,9 @@ Storing and Retrieving Notifications
 | 
			
		|||
  >>> ntf01 = list(manager.query(userName='user01'))[0]
 | 
			
		||||
  >>> ntf01
 | 
			
		||||
  <Notification ['obj01', 1, 'user01', '...']:
 | 
			
		||||
  {'media': ['inbox'], 'state': 'new', 'type': 'object_changed'}>
 | 
			
		||||
  {'type': 'object_changed', 'state': 'new', 'media': ['inbox']}>
 | 
			
		||||
 | 
			
		||||
  >>> print ntf01.state
 | 
			
		||||
  >>> print(ntf01.state)
 | 
			
		||||
  new
 | 
			
		||||
  >>> print ntf01.timingType
 | 
			
		||||
  >>> print(ntf01.timingType)
 | 
			
		||||
  None
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,38 +1,19 @@
 | 
			
		|||
#
 | 
			
		||||
#  Copyright (c) 2008 Helmut Merz helmutm@cy55.de
 | 
			
		||||
#
 | 
			
		||||
#  This program is free software; you can redistribute it and/or modify
 | 
			
		||||
#  it under the terms of the GNU General Public License as published by
 | 
			
		||||
#  the Free Software Foundation; either version 2 of the License, or
 | 
			
		||||
#  (at your option) any later version.
 | 
			
		||||
#
 | 
			
		||||
#  This program is distributed in the hope that it will be useful,
 | 
			
		||||
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
#  GNU General Public License for more details.
 | 
			
		||||
#
 | 
			
		||||
#  You should have received a copy of the GNU General Public License
 | 
			
		||||
#  along with this program; if not, write to the Free Software
 | 
			
		||||
#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 | 
			
		||||
#
 | 
			
		||||
# cybertools.tracking.notify.base
 | 
			
		||||
 | 
			
		||||
"""
 | 
			
		||||
Base classes for a notification framework.
 | 
			
		||||
 | 
			
		||||
$Id$
 | 
			
		||||
"""Base classes for a notification framework.
 | 
			
		||||
"""
 | 
			
		||||
 | 
			
		||||
from zope.component import adapts
 | 
			
		||||
from zope.interface import implements
 | 
			
		||||
from zope.interface import implementer
 | 
			
		||||
 | 
			
		||||
from cybertools.tracking.btree import Track
 | 
			
		||||
from cybertools.tracking.interfaces import ITrackingStorage
 | 
			
		||||
from cybertools.tracking.notify.interfaces import INotification, INotificationManager
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@implementer(INotificationManager)
 | 
			
		||||
class NotificationManager(object):
 | 
			
		||||
 | 
			
		||||
    implements(INotificationManager)
 | 
			
		||||
    adapts(ITrackingStorage)
 | 
			
		||||
 | 
			
		||||
    def __init__(self, context):
 | 
			
		||||
| 
						 | 
				
			
			@ -53,10 +34,9 @@ class NotificationManager(object):
 | 
			
		|||
        return self.context.query(**kw)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@implementer(INotification)
 | 
			
		||||
class Notification(Track):
 | 
			
		||||
 | 
			
		||||
    implements(INotification)
 | 
			
		||||
 | 
			
		||||
    typeName = 'Notification'
 | 
			
		||||
 | 
			
		||||
    def __getattr__(self, attr):
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,8 @@
 | 
			
		|||
 | 
			
		||||
import unittest, doctest
 | 
			
		||||
import warnings
 | 
			
		||||
 | 
			
		||||
warnings.filterwarnings('ignore', category=DeprecationWarning)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Test(unittest.TestCase):
 | 
			
		||||
| 
						 | 
				
			
			@ -12,7 +15,7 @@ class Test(unittest.TestCase):
 | 
			
		|||
def test_suite():
 | 
			
		||||
    flags = doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS
 | 
			
		||||
    return unittest.TestSuite((
 | 
			
		||||
                unittest.makeSuite(Test),
 | 
			
		||||
        unittest.TestLoader().loadTestsFromTestCase(Test),
 | 
			
		||||
        doctest.DocFileSuite('README.txt', optionflags=flags),
 | 
			
		||||
    ))
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,10 +1,12 @@
 | 
			
		|||
 | 
			
		||||
import unittest, doctest
 | 
			
		||||
import os
 | 
			
		||||
 | 
			
		||||
import warnings
 | 
			
		||||
 | 
			
		||||
testDir = os.path.join(os.path.dirname(__file__), 'testdata')
 | 
			
		||||
 | 
			
		||||
#warnings.filterwarnings('ignore', category=DeprecationWarning)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Test(unittest.TestCase):
 | 
			
		||||
    "Basic tests for the loops.track package."
 | 
			
		||||
| 
						 | 
				
			
			@ -16,7 +18,7 @@ class Test(unittest.TestCase):
 | 
			
		|||
def test_suite():
 | 
			
		||||
    flags = doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS
 | 
			
		||||
    return unittest.TestSuite((
 | 
			
		||||
                unittest.makeSuite(Test),
 | 
			
		||||
        unittest.TestLoader().loadTestsFromTestCase(Test),
 | 
			
		||||
        doctest.DocFileSuite('README.txt', optionflags=flags),
 | 
			
		||||
    ))
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue