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 @@
|
||||||
#
|
# cybertools.text.base
|
||||||
# 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
|
|
||||||
#
|
|
||||||
|
|
||||||
"""
|
"""Base classes for text transformations.
|
||||||
Base classes for text transformations.
|
|
||||||
|
|
||||||
Based on code provided by zc.index and TextIndexNG3.
|
Based on code provided by zc.index and TextIndexNG3.
|
||||||
|
|
||||||
$Id$
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,23 +1,6 @@
|
||||||
#
|
# cybertools.tracking.btree
|
||||||
# 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
|
|
||||||
#
|
|
||||||
|
|
||||||
"""
|
"""ZODB-/BTree-based implementation of user interaction tracking.
|
||||||
ZODB-/BTree-based implementation of user interaction tracking.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
@ -25,7 +8,7 @@ from persistent import Persistent
|
||||||
from BTrees import OOBTree, IOBTree
|
from BTrees import OOBTree, IOBTree
|
||||||
from BTrees.IFBTree import intersection, union
|
from BTrees.IFBTree import intersection, union
|
||||||
from zope.component import adapter
|
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.btree import BTreeContainer
|
||||||
from zope.app.container.interfaces import IObjectRemovedEvent
|
from zope.app.container.interfaces import IObjectRemovedEvent
|
||||||
from zope.index.field import FieldIndex
|
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
|
from cybertools.util.date import getTimeStamp, timeStamp2ISO
|
||||||
|
|
||||||
|
|
||||||
|
@implementer(IRun)
|
||||||
class Run(object):
|
class Run(object):
|
||||||
|
|
||||||
implements(IRun)
|
|
||||||
|
|
||||||
id = start = end = 0
|
id = start = end = 0
|
||||||
finished = False
|
finished = False
|
||||||
|
|
||||||
|
@ -53,11 +35,9 @@ class Run(object):
|
||||||
str(self.finished)))
|
str(self.finished)))
|
||||||
|
|
||||||
|
|
||||||
|
@implementer(ITrack)
|
||||||
class Track(Persistent):
|
class Track(Persistent):
|
||||||
|
|
||||||
#implements(ITrack, IPhysicallyLocatable)
|
|
||||||
implements(ITrack)
|
|
||||||
|
|
||||||
metadata_attributes = ('taskId', 'runId', 'userName', 'timeStamp')
|
metadata_attributes = ('taskId', 'runId', 'userName', 'timeStamp')
|
||||||
index_attributes = metadata_attributes
|
index_attributes = metadata_attributes
|
||||||
typeName = 'Track'
|
typeName = 'Track'
|
||||||
|
@ -112,10 +92,9 @@ class Track(Persistent):
|
||||||
return self.__name__
|
return self.__name__
|
||||||
|
|
||||||
|
|
||||||
|
@implementer(ITrackingStorage)
|
||||||
class TrackingStorage(BTreeContainer):
|
class TrackingStorage(BTreeContainer):
|
||||||
|
|
||||||
implements(ITrackingStorage)
|
|
||||||
|
|
||||||
trackFactory = Track
|
trackFactory = Track
|
||||||
indexAttributes = trackFactory.index_attributes
|
indexAttributes = trackFactory.index_attributes
|
||||||
|
|
||||||
|
@ -293,7 +272,7 @@ class TrackingStorage(BTreeContainer):
|
||||||
resultx = None
|
resultx = None
|
||||||
for v in value:
|
for v in value:
|
||||||
v2 = v
|
v2 = v
|
||||||
if isinstance(v, basestring) and v.endswith('*'):
|
if isinstance(v, str) and v.endswith('*'):
|
||||||
v = v[:-1]
|
v = v[:-1]
|
||||||
v2 = v + 'z'
|
v2 = v + 'z'
|
||||||
resultx = self.union(resultx, self.indexes[idx].apply((v, v2)))
|
resultx = self.union(resultx, self.indexes[idx].apply((v, v2)))
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
|
|
||||||
import unittest, doctest
|
import unittest, doctest
|
||||||
|
import warnings
|
||||||
|
|
||||||
|
#warnings.filterwarnings('ignore', category=DeprecationWarning)
|
||||||
|
|
||||||
class Test(unittest.TestCase):
|
class Test(unittest.TestCase):
|
||||||
"Basic tests for the cybertools.tracking.comment package."
|
"Basic tests for the cybertools.tracking.comment package."
|
||||||
|
@ -12,9 +14,9 @@ class Test(unittest.TestCase):
|
||||||
def test_suite():
|
def test_suite():
|
||||||
flags = doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS
|
flags = doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS
|
||||||
return unittest.TestSuite((
|
return unittest.TestSuite((
|
||||||
unittest.makeSuite(Test),
|
unittest.TestLoader().loadTestsFromTestCase(Test),
|
||||||
doctest.DocFileSuite('README.txt', optionflags=flags),
|
doctest.DocFileSuite('README.txt', optionflags=flags),
|
||||||
))
|
))
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main(defaultTest='test_suite')
|
unittest.main(defaultTest='test_suite')
|
||||||
|
|
|
@ -23,9 +23,9 @@ Storing and Retrieving Notifications
|
||||||
>>> ntf01 = list(manager.query(userName='user01'))[0]
|
>>> ntf01 = list(manager.query(userName='user01'))[0]
|
||||||
>>> ntf01
|
>>> ntf01
|
||||||
<Notification ['obj01', 1, 'user01', '...']:
|
<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
|
new
|
||||||
>>> print ntf01.timingType
|
>>> print(ntf01.timingType)
|
||||||
None
|
None
|
||||||
|
|
|
@ -1,38 +1,19 @@
|
||||||
#
|
# cybertools.tracking.notify.base
|
||||||
# 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
|
|
||||||
#
|
|
||||||
|
|
||||||
"""
|
"""Base classes for a notification framework.
|
||||||
Base classes for a notification framework.
|
|
||||||
|
|
||||||
$Id$
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from zope.component import adapts
|
from zope.component import adapts
|
||||||
from zope.interface import implements
|
from zope.interface import implementer
|
||||||
|
|
||||||
from cybertools.tracking.btree import Track
|
from cybertools.tracking.btree import Track
|
||||||
from cybertools.tracking.interfaces import ITrackingStorage
|
from cybertools.tracking.interfaces import ITrackingStorage
|
||||||
from cybertools.tracking.notify.interfaces import INotification, INotificationManager
|
from cybertools.tracking.notify.interfaces import INotification, INotificationManager
|
||||||
|
|
||||||
|
|
||||||
|
@implementer(INotificationManager)
|
||||||
class NotificationManager(object):
|
class NotificationManager(object):
|
||||||
|
|
||||||
implements(INotificationManager)
|
|
||||||
adapts(ITrackingStorage)
|
adapts(ITrackingStorage)
|
||||||
|
|
||||||
def __init__(self, context):
|
def __init__(self, context):
|
||||||
|
@ -53,10 +34,9 @@ class NotificationManager(object):
|
||||||
return self.context.query(**kw)
|
return self.context.query(**kw)
|
||||||
|
|
||||||
|
|
||||||
|
@implementer(INotification)
|
||||||
class Notification(Track):
|
class Notification(Track):
|
||||||
|
|
||||||
implements(INotification)
|
|
||||||
|
|
||||||
typeName = 'Notification'
|
typeName = 'Notification'
|
||||||
|
|
||||||
def __getattr__(self, attr):
|
def __getattr__(self, attr):
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
|
|
||||||
import unittest, doctest
|
import unittest, doctest
|
||||||
|
import warnings
|
||||||
|
|
||||||
|
warnings.filterwarnings('ignore', category=DeprecationWarning)
|
||||||
|
|
||||||
|
|
||||||
class Test(unittest.TestCase):
|
class Test(unittest.TestCase):
|
||||||
|
@ -12,9 +15,9 @@ class Test(unittest.TestCase):
|
||||||
def test_suite():
|
def test_suite():
|
||||||
flags = doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS
|
flags = doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS
|
||||||
return unittest.TestSuite((
|
return unittest.TestSuite((
|
||||||
unittest.makeSuite(Test),
|
unittest.TestLoader().loadTestsFromTestCase(Test),
|
||||||
doctest.DocFileSuite('README.txt', optionflags=flags),
|
doctest.DocFileSuite('README.txt', optionflags=flags),
|
||||||
))
|
))
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main(defaultTest='test_suite')
|
unittest.main(defaultTest='test_suite')
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
|
|
||||||
import unittest, doctest
|
import unittest, doctest
|
||||||
import os
|
import os
|
||||||
|
import warnings
|
||||||
|
|
||||||
testDir = os.path.join(os.path.dirname(__file__), 'testdata')
|
testDir = os.path.join(os.path.dirname(__file__), 'testdata')
|
||||||
|
|
||||||
|
#warnings.filterwarnings('ignore', category=DeprecationWarning)
|
||||||
|
|
||||||
|
|
||||||
class Test(unittest.TestCase):
|
class Test(unittest.TestCase):
|
||||||
"Basic tests for the loops.track package."
|
"Basic tests for the loops.track package."
|
||||||
|
@ -16,9 +18,9 @@ class Test(unittest.TestCase):
|
||||||
def test_suite():
|
def test_suite():
|
||||||
flags = doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS
|
flags = doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS
|
||||||
return unittest.TestSuite((
|
return unittest.TestSuite((
|
||||||
unittest.makeSuite(Test),
|
unittest.TestLoader().loadTestsFromTestCase(Test),
|
||||||
doctest.DocFileSuite('README.txt', optionflags=flags),
|
doctest.DocFileSuite('README.txt', optionflags=flags),
|
||||||
))
|
))
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main(defaultTest='test_suite')
|
unittest.main(defaultTest='test_suite')
|
||||||
|
|
Loading…
Add table
Reference in a new issue