Commit 5bc41c9b authored by Marius Gedminas's avatar Marius Gedminas

Use with open() in more places

parent 08a93058
...@@ -76,8 +76,7 @@ def U64(v): ...@@ -76,8 +76,7 @@ def U64(v):
return l return l
def check(path): def check(path):
file = open(path, 'rb') with open(path, 'rb') as file:
file.seek(0, 2) file.seek(0, 2)
file_size = file.tell() file_size = file.tell()
if file_size == 0: if file_size == 0:
......
...@@ -141,7 +141,7 @@ it will leave a marker with the choosen layout if no marker exists yet: ...@@ -141,7 +141,7 @@ it will leave a marker with the choosen layout if no marker exists yet:
>>> fsh.layout_name >>> fsh.layout_name
'bushy' 'bushy'
>>> fsh.create() >>> fsh.create()
>>> open(os.path.join(blobs, LAYOUT_MARKER), 'rb').read() >>> with open(os.path.join(blobs, LAYOUT_MARKER), 'rb') as fp: fp.read()
'bushy' 'bushy'
If the FSH finds a marker, then it verifies whether its content matches the If the FSH finds a marker, then it verifies whether its content matches the
...@@ -171,7 +171,7 @@ the marker will be used in the future: ...@@ -171,7 +171,7 @@ the marker will be used in the future:
>>> blob_storage = BlobStorage(blobs, base_storage) >>> blob_storage = BlobStorage(blobs, base_storage)
>>> blob_storage.fshelper.layout_name >>> blob_storage.fshelper.layout_name
'lawn' 'lawn'
>>> open(os.path.join(blobs, LAYOUT_MARKER), 'rb').read() >>> with open(os.path.join(blobs, LAYOUT_MARKER), 'rb') as fp: fp.read()
'lawn' 'lawn'
>>> blob_storage = BlobStorage('blobs', base_storage, layout='bushy') >>> blob_storage = BlobStorage('blobs', base_storage, layout='bushy')
... # doctest: +ELLIPSIS ... # doctest: +ELLIPSIS
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment