Skip to content

Commit

Permalink
#814: set binary mode only for compressed files (encoding is not None)
Browse files Browse the repository at this point in the history
  • Loading branch information
spazm committed Aug 21, 2014
1 parent 22720da commit f259a96
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions awscli/paramfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,12 @@ def guess_mode_from_file(file_path, mode='r'):
"""
Guess file mode by mime type of the filepath.
returns mode + 'b' for encoded files and non-text files,
returns mode for text and unknown.
returns mode + 'b' for encoded files, else mode
"""

ctype, encoding = mimetypes.guess_type(file_path)
if encoding is not None:
return mode + 'b'
if ctype is not None:
if ctype.startswith('text'):
return mode
else:
return mode + 'b'
return mode


Expand Down

0 comments on commit f259a96

Please sign in to comment.