Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SymbolTable.read/write to support both Str and Path in Python #218

Merged
merged 1 commit into from
Sep 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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