File tree 1 file changed +8
-10
lines changed
1 file changed +8
-10
lines changed Original file line number Diff line number Diff line change 3
3
import datetime
4
4
import zipfile
5
5
6
- from fsspec import open_files
6
+ import fsspec
7
7
from fsspec .archive import AbstractArchiveFileSystem
8
8
from fsspec .utils import DEFAULT_BLOCK_SIZE
9
9
@@ -46,15 +46,9 @@ def __init__(
46
46
"""
47
47
super ().__init__ (self , ** kwargs )
48
48
if isinstance (fo , str ):
49
- files = open_files (
49
+ fo = fsspec . open (
50
50
fo , mode = mode + "b" , protocol = target_protocol , ** (target_options or {})
51
51
)
52
- if len (files ) != 1 :
53
- raise ValueError (
54
- 'Path "{}" did not resolve to exactly'
55
- 'one file: "{}"' .format (fo , files )
56
- )
57
- fo = files [0 ]
58
52
self .of = fo
59
53
self .fo = fo .__enter__ () # the whole instance is a context
60
54
self .zip = zipfile .ZipFile (self .fo , mode = mode )
@@ -68,7 +62,11 @@ def _strip_protocol(cls, path):
68
62
69
63
def __del__ (self ):
70
64
if hasattr (self , "zip" ):
71
- self .zip .close ()
65
+ self .close ()
66
+
67
+ def close (self ):
68
+ "Commits any write changes to the file. Done on ``del`` too."
69
+ self .zip .close ()
72
70
73
71
def _get_dirs (self ):
74
72
if self .dir_cache is None :
@@ -78,7 +76,7 @@ def _get_dirs(self):
78
76
for dirname in self ._all_dirnames (self .zip .namelist ())
79
77
}
80
78
for z in files :
81
- f = {s : getattr (z , s ) for s in zipfile .ZipInfo .__slots__ }
79
+ f = {s : getattr (z , s , None ) for s in zipfile .ZipInfo .__slots__ }
82
80
f .update (
83
81
{
84
82
"name" : z .filename ,
You can’t perform that action at this time.
0 commit comments