Skip to content

Commit

Permalink
Renamed determinetype to determine_type for uniform naming
Browse files Browse the repository at this point in the history
  • Loading branch information
samastur committed Nov 15, 2015
1 parent d147d5c commit 6fd61ac
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions pyimagediet/diet.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def read_yaml_configuration(filename):
return config


def determinetype(filename):
def determine_type(filename):
'''Determine the file type and return it.'''
ftype = magic.from_file(filename, mime=True).decode('utf8')
if ftype == 'text/plain':
Expand Down Expand Up @@ -122,7 +122,7 @@ def diet(filename, configuration):
raise NotFileDietException('Passed filename does not point to a file')
conf = parse_configuration(configuration)

filetype = determinetype(filename)
filetype = determine_type(filename)
squeeze_cmd = conf['pipelines'].get(filetype)
if squeeze_cmd:
tmpbackup_ext = 'diet_internal'
Expand All @@ -132,7 +132,7 @@ def diet(filename, configuration):
size = os.stat(filename).st_size
new_size = squeeze(squeeze_cmd, filename, backup)

if not conf.get('keep_processed', False) and new_size >= size:
if not conf.get('keep_processed', False) and new_size > size:
copy_if_different(backup, filename)

# Delete backup, if it was internal
Expand Down
22 changes: 11 additions & 11 deletions tests/test_diet.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,35 +42,35 @@ def test_read_yaml_configuration():


#
# determinetype
# determine_type
#
def test_determinetype_returns_text_on_yaml():
def test_determine_type_returns_text_on_yaml():
f = join(TEST_FILES_DIR, 'config.yaml')
ftype = diet.determinetype(f)
ftype = diet.determine_type(f)
assert ftype == 'text'


def test_determinetype_returns_png_on_png_images():
def test_determine_type_returns_png_on_png_images():
f = join(TEST_FILES_DIR, 'nature.png')
ftype = diet.determinetype(f)
ftype = diet.determine_type(f)
assert ftype == 'png'


def test_determinetype_returns_gif_on_gif_images():
def test_determine_type_returns_gif_on_gif_images():
f = join(TEST_FILES_DIR, 'nature.gif')
ftype = diet.determinetype(f)
ftype = diet.determine_type(f)
assert ftype == 'gif'


def test_determinetype_returns_jpeg_on_jpeg_images():
def test_determine_type_returns_jpeg_on_jpeg_images():
f = join(TEST_FILES_DIR, 'vienna.jpg')
ftype = diet.determinetype(f)
ftype = diet.determine_type(f)
assert ftype == 'jpeg'


def test_determinetype_returns_svg_on_svg_images():
def test_determine_type_returns_svg_on_svg_images():
f = join(TEST_FILES_DIR, 'nature.svg')
ftype = diet.determinetype(f)
ftype = diet.determine_type(f)
assert ftype == 'svg'


Expand Down

0 comments on commit 6fd61ac

Please sign in to comment.