Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Levin Zimmermann
neoppod
Commits
e5354e76
Commit
e5354e76
authored
Dec 13, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
go/neo/t/{tcpu,tzodb}.py: Move hashing utilities & hashRegistry to -> zodbtools
Moved here:
nexedi/zodbtools@e973d519
parent
fe751a15
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
51 deletions
+3
-51
go/neo/t/tcpu.py
go/neo/t/tcpu.py
+1
-27
go/neo/t/tzodb.py
go/neo/t/tzodb.py
+2
-24
No files found.
go/neo/t/tcpu.py
View file @
e5354e76
...
@@ -25,37 +25,11 @@ from __future__ import print_function
...
@@ -25,37 +25,11 @@ from __future__ import print_function
import
sys
import
sys
import
hashlib
import
hashlib
import
zlib
import
zlib
from
zlib
import
crc32
,
adler32
from
os.path
import
dirname
from
os.path
import
dirname
from
zodbtools.util
import
Adler32Hasher
,
CRC32Hasher
from
golang
import
testing
from
golang
import
testing
# adler32 in hashlib interface
class
Adler32Hasher
:
name
=
"adler32"
def
__init__
(
self
):
self
.
h
=
adler32
(
''
)
def
update
(
self
,
data
):
self
.
h
=
adler32
(
data
,
self
.
h
)
def
hexdigest
(
self
):
return
'%08x'
%
(
self
.
h
&
0xffffffff
)
# crc32 in hashlib interface
class
CRC32Hasher
:
name
=
"crc32"
def
__init__
(
self
):
self
.
h
=
crc32
(
''
)
def
update
(
self
,
data
):
self
.
h
=
crc32
(
data
,
self
.
h
)
def
hexdigest
(
self
):
return
'%08x'
%
(
self
.
h
&
0xffffffff
)
# fmtsize formats size in human readable form
# fmtsize formats size in human readable form
_unitv
=
"BKMGT"
# (2^10)^i represents by corresponding char suffix
_unitv
=
"BKMGT"
# (2^10)^i represents by corresponding char suffix
def
fmtsize
(
size
):
def
fmtsize
(
size
):
...
...
go/neo/t/tzodb.py
View file @
e5354e76
...
@@ -22,37 +22,15 @@
...
@@ -22,37 +22,15 @@
from
__future__
import
print_function
from
__future__
import
print_function
import
zodbtools.util
from
zodbtools.util
import
storageFromURL
,
hashRegistry
from
ZODB.POSException
import
POSKeyError
from
ZODB.POSException
import
POSKeyError
from
ZODB.utils
import
p64
,
u64
from
ZODB.utils
import
p64
,
u64
import
hashlib
from
tcpu
import
Adler32Hasher
,
CRC32Hasher
import
sys
import
sys
import
logging
import
logging
from
time
import
time
from
time
import
time
from
getopt
import
getopt
,
GetoptError
from
getopt
import
getopt
,
GetoptError
# hasher that discards data
class
NullHasher
:
name
=
"null"
def
update
(
self
,
data
):
pass
def
hexdigest
(
self
):
return
"00"
# {} name -> hasher
hashRegistry
=
{
"null"
:
NullHasher
,
"adler32"
:
Adler32Hasher
,
"crc32"
:
CRC32Hasher
,
"sha1"
:
hashlib
.
sha1
,
"sha256"
:
hashlib
.
sha256
,
"sha512"
:
hashlib
.
sha512
,
}
def
usage
(
w
):
def
usage
(
w
):
print
(
\
print
(
\
"""Usage: tzodb zhash [options] url
"""Usage: tzodb zhash [options] url
...
@@ -115,7 +93,7 @@ def zhash():
...
@@ -115,7 +93,7 @@ def zhash():
l
=
logging
.
getLogger
()
l
=
logging
.
getLogger
()
l
.
addHandler
(
logging
.
StreamHandler
())
l
.
addHandler
(
logging
.
StreamHandler
())
stor
=
zodbtools
.
util
.
storageFromURL
(
url
,
read_only
=
True
)
stor
=
storageFromURL
(
url
,
read_only
=
True
)
last_tid
=
stor
.
lastTransaction
()
last_tid
=
stor
.
lastTransaction
()
before
=
p64
(
u64
(
last_tid
)
+
1
)
before
=
p64
(
u64
(
last_tid
)
+
1
)
...
...
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