Skip to content

Commit

Permalink
fix some py3 compat issues, closes #6
Browse files Browse the repository at this point in the history
  • Loading branch information
lxyu committed Aug 30, 2016
1 parent 4467f6e commit d15df1f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions kindle.py
Expand Up @@ -12,7 +12,7 @@


def get_sections(filename):
with open(filename, 'r') as f:
with open(filename, 'rb') as f:
content = f.read().decode('utf-8')
content = content.replace(u'\ufeff', u'')
return content.split(BOUNDARY)
Expand Down Expand Up @@ -47,7 +47,7 @@ def export_txt(clips):
lines.append(clips[book][pos].encode('utf-8'))

filename = os.path.join(OUTPUT_DIR, u"%s.md" % book)
with open(filename, 'w') as f:
with open(filename, 'wb') as f:
f.write("\n\n---\n\n".join(lines))


Expand All @@ -56,7 +56,7 @@ def load_clips():
Load previous clips from DATA_FILE
"""
try:
with open(DATA_FILE, 'r') as f:
with open(DATA_FILE, 'rb') as f:
return json.load(f)
except (IOError, ValueError):
return {}
Expand All @@ -83,7 +83,7 @@ def main():
clips[clip['book']][str(clip['position'])] = clip['content']

# remove key with empty value
clips = {k: v for k, v in clips.iteritems() if v}
clips = {k: v for k, v in clips.items() if v}

# save/export clips
save_clips(clips)
Expand Down

0 comments on commit d15df1f

Please sign in to comment.