-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
All local files can be now opened. If they appear to be binary and built-in editor is used, info dialog is displayed. If it is remote file, it gets transfered and same decision is made as for local files.
- Loading branch information
1 parent
a5241f7
commit 2c004ea
Showing
2 changed files
with
37 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class FileInfo: | ||
@staticmethod | ||
def is_file_binary(path: str) -> bool: | ||
""" | ||
Tests if file is binary. | ||
:param path: Path to local file. | ||
:return: True if file is binary (can't be decoded with utf-8), false otherwise | ||
""" | ||
with open(path, "rb") as f: | ||
try: | ||
f.read().decode("utf-8") | ||
return False | ||
except UnicodeDecodeError: | ||
return True |