Skip to content

Commit

Permalink
Merge pull request #21 from haiwen/change-char
Browse files Browse the repository at this point in the history
new diff method. can return unicode only
  • Loading branch information
freeplant authored Jul 18, 2018
2 parents df0d7db + 83d3377 commit 70555b6
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions seafobj/commit_differ.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#coding: UTF-8
# coding: UTF-8

from seafobj import fs_mgr
import os
import logging

ZERO_OBJ_ID = '0000000000000000000000000000000000000000'


class DiffEntry(object):
def __init__(self, path, obj_id, size=-1, new_path=None):
self.path = path
Expand All @@ -22,6 +22,19 @@ def __init__(self, repo_id, version, root1, root2, handle_rename=False, fold_dir
self.handle_rename = handle_rename
self.fold_dirs = fold_dirs

def diff_to_unicode(self):
# you can also do this by overwriting key points
res = []
diff_res = self.diff()
for dirents in diff_res:
for dirent in dirents:
for key in dirent.__dict__.keys():
v = dirent.__dict__[key]
if isinstance(v, str):
dirent.__dict__[key] = v.decode('utf8')
res.append(dirents)
return tuple(res)

def diff(self):
added_files = []
deleted_files = []
Expand Down

0 comments on commit 70555b6

Please sign in to comment.