Skip to content
Open
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
11 changes: 11 additions & 0 deletions EmmetNPP/emmet/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,19 @@ def read_file(path, size=-1, mode='rb'):
with open(path, mode, **kwargs) as fp:
return fp.read(size)

def unicode_str_isneed(str, encoding='utf-8'):
if not isinstance(str, unicode):
str = unicode(str, encoding)

return str


class File():
def __init__(self):
pass

def _read(self, path, size, mode='rb'):
path = unicode_str_isneed(path)
reader = is_url(path) and read_http or read_file
return reader(path, size, mode)

Expand Down Expand Up @@ -93,6 +101,9 @@ def locate_file(self, editor_file, file_name):

result = None

editor_file = unicode_str_isneed(editor_file)
file_name = unicode_str_isneed(file_name)

previous_parent = ''
parent = os.path.dirname(editor_file)
while parent and os.path.exists(parent) and parent != previous_parent:
Expand Down