Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Kirill Smelkov
wendelin.core
Commits
1ac0d8f1
Commit
1ac0d8f1
authored
May 25, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
08a764fe
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
3 deletions
+42
-3
wcfs/testprog/treegen.py
wcfs/testprog/treegen.py
+42
-3
No files found.
wcfs/testprog/treegen.py
View file @
1ac0d8f1
...
...
@@ -100,6 +100,43 @@ from BTrees import LOBTree
LOBTree
.
LOBTree
=
XLOTree
# ZConn represent treegen-level connection to ZODB.
# XXX high-level wrapper around zconn.
class
ZConn
(
object
):
# XXX +.zstor
# .zconn
# .valdict = zconn.root['treegen/values'] = {} v -> ZBlk(v)
# XXX -> free function? (e.g. zopen(zstor)) ?
def
__init__
(
zstor
):
# root['treegen/values'] = {} v -> ZBlk(v)
valdict
=
root
[
'treegen/values'
]
=
PersistentMapping
()
valv
=
b'abcdefghi'
for
v
in
valv
:
zblk
=
ZBlk
()
zblk
.
setblkdata
(
v
)
valdict
[
v
]
=
zblk
commit
(
'treegen/values -> %r'
%
valv
)
def
close
(
self
):
self
.
zconn
.
close
()
# vdecode(vtxt) -> vobj decodes value text into value object, e.g. 'a' -> ZBlk(a)
# vencode(vobj) -> vtxt encodes value object into value text, e.g. ZBlk(a) -> 'a'
def
vdecode
(
self
,
vtxt
):
# -> vobj
return
self
.
valdict
[
vtxt
]
def
vencode
(
self
,
vobj
):
# -> vtxt
for
(
k
,
v
)
in
self
.
valdict
.
items
():
if
v
is
vobj
:
return
k
raise
KeyError
(
"%r not found in value registry"
%
(
vobj
,))
# XXX doc
@
func
def
Trees
(
zstor
,
r
):
for
l
in
r
.
readlines
():
# AllStructs generates subset of all possible tree changes in
# between kv1 and kv2. See top-level documentation for details.
@
func
...
...
@@ -114,14 +151,15 @@ def AllStructs(zstor, kv1txt, kv2txt, n, seed=None):
print
(
"# seed=%d"
%
seed
)
random
.
seed
(
seed
)
# root['treedelta/values'] = {} v -> ZBlk(v)
valdict
=
root
[
'treedelta/values'
]
=
PersistentMapping
()
"""
# root['treegen/values'] = {} v -> ZBlk(v)
valdict = root['treegen/values'] = PersistentMapping()
valv = b'abcdefghi'
for v in valv:
zblk = ZBlk()
zblk.setblkdata(v)
valdict[v] = zblk
commit
(
'tree
delta
/values -> %r'
%
valv
)
commit('tree
gen
/values -> %r' % valv)
# vdecode(vtxt) -> vobj decodes value text into value object, e.g. 'a' -> ZBlk(a)
# vencode(vobj) -> vtxt encodes value object into value text, e.g. ZBlk(a) -> 'a'
...
...
@@ -132,6 +170,7 @@ def AllStructs(zstor, kv1txt, kv2txt, n, seed=None):
if v is vobj:
return k
raise KeyError("%r not found in value registry" % (vobj,))
"""
kv1
=
kvDecode
(
kv1txt
,
vdecode
)
kv2
=
kvDecode
(
kv2txt
,
vdecode
)
...
...
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