Selfie
Loading...
Searching...
No Matches
selfie_lib.FS.FS Class Reference
Inheritance diagram for selfie_lib.FS.FS:
pytest_selfie.plugin.FSImplementation

Public Member Functions

bool file_exists (self, TypedPath typed_path)
 
T file_walk (self, TypedPath typed_path, Callable[[Iterator[TypedPath]], T] walk)
 
str file_read (self, typed_path)
 
 file_write (self, typed_path, str content)
 
bytes file_read_binary (self, TypedPath typed_path)
 
 file_write_binary (self, TypedPath typed_path, bytes content)
 
Exception assert_failed (self, message, expected=None, actual=None)
 

Detailed Description

Definition at line 11 of file FS.py.

Member Function Documentation

◆ assert_failed()

Exception selfie_lib.FS.FS.assert_failed (   self,
  message,
  expected = None,
  actual = None 
)

Reimplemented in pytest_selfie.plugin.FSImplementation.

Definition at line 38 of file FS.py.

38 def assert_failed(self, message, expected=None, actual=None) -> Exception:
39 pass

◆ file_exists()

bool selfie_lib.FS.FS.file_exists (   self,
TypedPath  typed_path 
)

Definition at line 12 of file FS.py.

12 def file_exists(self, typed_path: TypedPath) -> bool:
13 return Path(typed_path.absolute_path).is_file()
14

◆ file_read()

str selfie_lib.FS.FS.file_read (   self,
  typed_path 
)

Definition at line 25 of file FS.py.

25 def file_read(self, typed_path) -> str:
26 return self.file_read_binary(typed_path).decode()
27

◆ file_read_binary()

bytes selfie_lib.FS.FS.file_read_binary (   self,
TypedPath  typed_path 
)

Definition at line 31 of file FS.py.

31 def file_read_binary(self, typed_path: TypedPath) -> bytes:
32 return Path(typed_path.absolute_path).read_bytes()
33

◆ file_walk()

T selfie_lib.FS.FS.file_walk (   self,
TypedPath  typed_path,
Callable[[Iterator[TypedPath]], T]   walk 
)

Definition at line 15 of file FS.py.

17 ) -> T:
18 def walk_generator(path: TypedPath) -> Iterator[TypedPath]:
19 for file_path in Path(path.absolute_path).rglob("*"):
20 if file_path.is_file():
21 yield TypedPath(file_path.absolute().as_posix())
22
23 return walk(walk_generator(typed_path))
24

◆ file_write()

selfie_lib.FS.FS.file_write (   self,
  typed_path,
str  content 
)

Definition at line 28 of file FS.py.

28 def file_write(self, typed_path, content: str):
29 self.file_write_binary(typed_path, content.encode())
30

◆ file_write_binary()

selfie_lib.FS.FS.file_write_binary (   self,
TypedPath  typed_path,
bytes  content 
)

Definition at line 34 of file FS.py.

34 def file_write_binary(self, typed_path: TypedPath, content: bytes):
35 Path(typed_path.absolute_path).write_bytes(content)
36

The documentation for this class was generated from the following file: