Skip to content

Commit

Permalink
SymbolTable.read/write to support both Str and Path in Python
Browse files Browse the repository at this point in the history
  • Loading branch information
Garvys committed Sep 15, 2022
1 parent 862546d commit b4651b6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions rustfst-python/rustfst/symbol_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def num_symbols(self) -> int:
return int(num_symbols.value)

@classmethod
def read(cls, filename: Path) -> SymbolTable:
def read(cls, filename: Union[str, Path]) -> SymbolTable:
"""
Reads symbol table from binary file.
This class method creates a new SymbolTable from a symbol table binary file.
Expand All @@ -173,7 +173,7 @@ def read(cls, filename: Path) -> SymbolTable:
return cls(ptr=symt)

@classmethod
def read_text(cls, filename: Path) -> SymbolTable:
def read_text(cls, filename: Union[str, Path]) -> SymbolTable:
"""
Reads symbol table from text file.
This class method creates a new SymbolTable from a symbol table text file.
Expand All @@ -194,7 +194,7 @@ def read_text(cls, filename: Path) -> SymbolTable:

return cls(ptr=symt)

def write(self, filename: Path):
def write(self, filename: Union[str, Path]):
"""
Serializes symbol table to a file.
This methods writes the SymbolTable to a file in binary format.
Expand All @@ -210,7 +210,7 @@ def write(self, filename: Path):
err_msg = f"Write failed for bin file : {filename}"
check_ffi_error(ret_code, err_msg)

def write_text(self, filename: Path):
def write_text(self, filename: Union[str, Path]):
"""
Writes symbol table to text file.
This method writes the SymbolTable to a file in human-readable format.
Expand Down

0 comments on commit b4651b6

Please # to comment.