Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
zodbtools
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
5
Merge Requests
5
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
zodbtools
Commits
adec18bd
Commit
adec18bd
authored
Sep 07, 2022
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
util: Factor readfile function into here
Soon we will need to use it not only from test_restore.py
parent
80559a94
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
10 deletions
+10
-10
zodbtools/test/test_restore.py
zodbtools/test/test_restore.py
+3
-9
zodbtools/util.py
zodbtools/util.py
+7
-1
No files found.
zodbtools/test/test_restore.py
View file @
adec18bd
...
@@ -21,7 +21,7 @@
...
@@ -21,7 +21,7 @@
from
__future__
import
print_function
from
__future__
import
print_function
from
zodbtools.zodbrestore
import
zodbrestore
from
zodbtools.zodbrestore
import
zodbrestore
from
zodbtools.util
import
storageFromURL
from
zodbtools.util
import
storageFromURL
,
readfile
from
os.path
import
dirname
from
os.path
import
dirname
from
tempfile
import
mkdtemp
from
tempfile
import
mkdtemp
...
@@ -49,12 +49,6 @@ def test_zodbrestore(zext):
...
@@ -49,12 +49,6 @@ def test_zodbrestore(zext):
zodbrestore
(
stor
,
zdump
)
zodbrestore
(
stor
,
zdump
)
_
()
_
()
zfs1
=
_
readfile
(
"%s/1%s.fs"
%
(
tdata
,
zkind
))
zfs1
=
readfile
(
"%s/1%s.fs"
%
(
tdata
,
zkind
))
zfs2
=
_
readfile
(
"%s/2.fs"
%
tmpd
)
zfs2
=
readfile
(
"%s/2.fs"
%
tmpd
)
assert
zfs1
==
zfs2
assert
zfs1
==
zfs2
# _readfile reads file at path.
def
_readfile
(
path
):
# -> data(bytes)
with
open
(
path
,
'rb'
)
as
_
:
return
_
.
read
()
zodbtools/util.py
View file @
adec18bd
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
# zodbtools - various utility routines
# zodbtools - various utility routines
# Copyright (C) 2016-20
19
Nexedi SA and Contributors.
# Copyright (C) 2016-20
22
Nexedi SA and Contributors.
# Kirill Smelkov <kirr@nexedi.com>
# Kirill Smelkov <kirr@nexedi.com>
# Jérome Perrin <jerome@nexedi.com>
# Jérome Perrin <jerome@nexedi.com>
#
#
...
@@ -235,3 +235,9 @@ def asbinstream(stream):
...
@@ -235,3 +235,9 @@ def asbinstream(stream):
if
isinstance
(
stream
,
io
.
TextIOBase
):
if
isinstance
(
stream
,
io
.
TextIOBase
):
return
stream
.
buffer
return
stream
.
buffer
return
stream
return
stream
# readfile reads file at path.
def
readfile
(
path
):
# -> data(bytes)
with
open
(
path
,
'rb'
)
as
_
:
return
_
.
read
()
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