Skip to content
This repository was archived by the owner on Nov 22, 2022. It is now read-only.

Commit 0767d82

Browse files
hudevenfacebook-github-bot
authored andcommitted
Make PathManager robust to API changes in fvcore (#1196)
Summary: Pull Request resolved: #1196 As PathManager APIs in fvcore keep involving(adding more args), we want to have this adapter to 1) be robust to the changes 2) be 100% compatible with Python file I/O APIs Reviewed By: chenyangyu1988 Differential Revision: D18803124 fbshipit-source-id: 788012547b690816fc252b6140202a2f2004037e
1 parent 5a7187c commit 0767d82

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

pytext/utils/file_io.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616

1717
class PathManager:
1818
@staticmethod
19-
def open(path: str, mode: str = "r"):
20-
return open(path, mode)
19+
def open(*args, **kwargs):
20+
return open(*args, **kwargs)
2121

2222
@staticmethod
23-
def copy(src_path: str, dst_path: str, overwrite: bool = False) -> bool:
23+
def copy(*args, **kwargs) -> bool:
2424
try:
25-
shutil.copyfile(src_path, dst_path)
25+
shutil.copyfile(*args, **kwargs)
2626
return True
2727
except Exception as e:
2828
print("Error in file copy - {}".format(str(e)))
@@ -49,9 +49,9 @@ def ls(path: str) -> List[str]:
4949
return os.listdir(path)
5050

5151
@staticmethod
52-
def mkdirs(path: str):
53-
os.makedirs(path, exist_ok=True)
52+
def mkdirs(*args, **kwargs):
53+
os.makedirs(*args, exist_ok=True, **kwargs)
5454

5555
@staticmethod
56-
def rm(path: str):
57-
os.remove(path)
56+
def rm(*args, **kwargs):
57+
os.remove(*args, **kwargs)

0 commit comments

Comments
 (0)