Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
1dd29315
Commit
1dd29315
authored
Mar 30, 2005
by
Paul Winkler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merged slinkp_1726_zopeundo: avoid showing undo transactions in
the wrong folder.
parent
08b3a5ec
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
21 deletions
+25
-21
lib/python/ZopeUndo/Prefix.py
lib/python/ZopeUndo/Prefix.py
+16
-8
lib/python/ZopeUndo/tests/testPrefix.py
lib/python/ZopeUndo/tests/testPrefix.py
+9
-13
No files found.
lib/python/ZopeUndo/Prefix.py
View file @
1dd29315
...
@@ -20,20 +20,28 @@ for running a ZEO server that handles Zope undo.
...
@@ -20,20 +20,28 @@ for running a ZEO server that handles Zope undo.
"""
"""
class
Prefix
:
class
Prefix
:
"""A Prefix() is equal to any
string it a
s a prefix of.
"""A Prefix() is equal to any
path it i
s a prefix of.
This class can be compared to a string (or arbitrary sequence).
The comparison will return True if the prefix value is a prefix of
the string being compared.
Two prefixes can not be compared.
This class can be compared to a string.
The comparison will return True if all path elements of the
Prefix are found at the beginning of the string being compared.
Two Prefixes can not be compared.
"""
"""
__no_side_effects__
=
1
__no_side_effects__
=
1
def
__init__
(
self
,
path
):
def
__init__
(
self
,
path
):
self
.
value
=
len
(
path
),
path
path_list
=
path
.
split
(
'/'
)
self
.
length
=
len
(
path_list
)
self
.
path
=
path_list
def
__cmp__
(
self
,
o
):
def
__cmp__
(
self
,
o
):
l
,
v
=
self
.
value
other_path
=
o
.
split
(
'/'
)
return
cmp
(
o
[:
l
],
v
)
return
cmp
(
other_path
[:
self
.
length
],
self
.
path
)
def
__repr__
(
self
):
# makes failing tests easier to read
return
"Prefix('%s')"
%
'/'
.
join
(
self
.
path
)
lib/python/ZopeUndo/tests/testPrefix.py
View file @
1dd29315
...
@@ -18,19 +18,15 @@ import unittest
...
@@ -18,19 +18,15 @@ import unittest
class
PrefixTest
(
unittest
.
TestCase
):
class
PrefixTest
(
unittest
.
TestCase
):
def
test
(
self
):
def
test
(
self
):
p1
=
(
Prefix
(
"/a/b"
),
p1
=
Prefix
(
"/a/b"
)
(
"/a/b"
,
"/a/b/c"
,
"/a/b/c/d"
),
for
equal
in
(
"/a/b"
,
"/a/b/c"
,
"/a/b/c/d"
):
(
""
,
"/a/c"
))
self
.
assertEqual
(
p1
,
equal
)
for
notEqual
in
(
""
,
"/a/c"
,
"/a/bbb"
,
"///"
):
p2
=
(
Prefix
(
""
),
self
.
assertNotEqual
(
p1
,
notEqual
)
(
""
,
"/def"
,
"/a/b"
,
"/a/b/c"
,
"/a/b/c/d"
),
())
for
prefix
,
equal
,
notequal
in
p1
,
p2
:
for
s
in
equal
:
self
.
assertEqual
(
prefix
,
s
)
for
s
in
notequal
:
self
.
assertNotEqual
(
prefix
,
s
)
p2
=
Prefix
(
""
)
for
equal
in
(
""
,
"/"
,
"/def"
,
"/a/b"
,
"/a/b/c"
,
"/a/b/c/d"
):
self
.
assertEqual
(
p2
,
equal
)
def
test_suite
():
def
test_suite
():
return
unittest
.
makeSuite
(
PrefixTest
)
return
unittest
.
makeSuite
(
PrefixTest
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment