@@ -85,9 +85,9 @@ def __init__(self, fs: Dict[Path, str]):
8585 self .fs = fs
8686
8787 def glob (self , path : Path , glob : str ) -> Generator [Path , None , None ]:
88- path_s = str ( path )
88+ path_s = path . as_posix ( )
8989 for key in self .fs .keys ():
90- key_s = str ( key )
90+ key_s = key . as_posix ( )
9191 if key_s .startswith (path_s ):
9292 if fnmatch (key_s , glob ):
9393 yield key
@@ -100,17 +100,17 @@ def readlines(self, path: Path, encoding: str = "utf-8") -> List[str]:
100100 return content .splitlines (keepends = True )
101101
102102 def write (self , path : Path , content : str ):
103- base = str ( path .parent )
103+ base = path .parent . as_posix ( )
104104 assert any (
105- [str ( key ).startswith (base ) for key in self .fs ]
105+ [key . as_posix ( ).startswith (base ) for key in self .fs ]
106106 ), "No parent folder, this will probably fail without a call to mkdir in a real file system!"
107107 self .fs [path ] = content
108108
109109 def stat (self , path : Path ):
110110 if path in self .fs :
111111 return Stat (path , True , True )
112112 for item in self .fs .keys ():
113- if str ( item ).startswith (str ( path )):
113+ if item . as_posix ( ).startswith (path . as_posix ( )):
114114 return Stat (path , True , False )
115115 return Stat (path , False , False )
116116
@@ -123,11 +123,11 @@ def list(self, path: Path) -> List[Path]:
123123 return []
124124
125125 # Gather all entries that are immediate children of `path`
126- prefix = str ( path ).rstrip ("/" ) + "/"
126+ prefix = path . as_posix ( ).rstrip ("/" ) + "/"
127127 children = set ()
128128
129129 for item in self .fs .keys ():
130- item_s = str ( item )
130+ item_s = item . as_posix ( )
131131 if item_s .startswith (prefix ):
132132 # Determine the remainder path after the prefix
133133 remainder = item_s [len (prefix ) :]
0 commit comments