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
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
Jérome Perrin
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
Show 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 @@
from
__future__
import
print_function
from
zodbtools.zodbrestore
import
zodbrestore
from
zodbtools.util
import
storageFromURL
from
zodbtools.util
import
storageFromURL
,
readfile
from
os.path
import
dirname
from
tempfile
import
mkdtemp
...
...
@@ -49,12 +49,6 @@ def test_zodbrestore(zext):
zodbrestore
(
stor
,
zdump
)
_
()
zfs1
=
_
readfile
(
"%s/1%s.fs"
%
(
tdata
,
zkind
))
zfs2
=
_
readfile
(
"%s/2.fs"
%
tmpd
)
zfs1
=
readfile
(
"%s/1%s.fs"
%
(
tdata
,
zkind
))
zfs2
=
readfile
(
"%s/2.fs"
%
tmpd
)
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 -*-
# 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>
# Jérome Perrin <jerome@nexedi.com>
#
...
...
@@ -235,3 +235,9 @@ def asbinstream(stream):
if
isinstance
(
stream
,
io
.
TextIOBase
):
return
stream
.
buffer
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