@@ -136,12 +136,12 @@ def __init__(self, namespace_path):
136
136
137
137
@classmethod
138
138
def _resolve (cls , path_str ) -> abc .Traversable :
139
- """
139
+ r """
140
140
Given an item from a namespace path, resolve it to a Traversable.
141
141
142
142
path_str might be a directory on the filesystem or a path to a
143
143
zipfile plus the path within the zipfile, e.g. ``/foo/bar`` or
144
- ``/foo/baz.zip/inner_dir``.
144
+ ``/foo/baz.zip/inner_dir`` or ``foo\baz.zip\inner_dir\sub`` .
145
145
"""
146
146
(dir ,) = (cand for cand in cls ._candidate_paths (path_str ) if cand .is_dir ())
147
147
return dir
@@ -153,10 +153,12 @@ def _candidate_paths(cls, path_str):
153
153
154
154
@staticmethod
155
155
def _resolve_zip_path (path_str ):
156
- for match in reversed (list (re .finditer ('/' , path_str ))):
157
- with contextlib .suppress (FileNotFoundError , IsADirectoryError ):
158
- inner = path_str [match .end () :]
159
- yield ZipPath (path_str [: match .start ()], inner + '/' * len (inner ))
156
+ for match in reversed (list (re .finditer (r'[\\/]' , path_str ))):
157
+ with contextlib .suppress (
158
+ FileNotFoundError , IsADirectoryError , PermissionError
159
+ ):
160
+ inner = path_str [match .end () :].replace ('\\ ' , '/' ) + '/'
161
+ yield ZipPath (path_str [: match .start ()], inner .lstrip ('/' ))
160
162
161
163
def resource_path (self , resource ):
162
164
"""
0 commit comments