Skip to content
This repository has been archived by the owner on Mar 10, 2020. It is now read-only.

utils is a common name #4

Merged
merged 2 commits into from
Mar 23, 2012
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion tornado_utils/__init__.py
Original file line number Original file line Diff line number Diff line change
@@ -1 +1 @@
from utils import * from .utils import *
18 changes: 1 addition & 17 deletions tornado_utils/thumbnailer.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -4,23 +4,7 @@
Image = None Image = None
import os import os


def _mkdir(newdir): from .utils import mkdir
"""works the way a good mkdir should :)
- already exists, silently complete
- regular file in the way, raise an exception
- parent directory(ies) does not exist, make them as well
"""
if os.path.isdir(newdir):
pass
elif os.path.isfile(newdir):
raise OSError("a file with the same name as the desired " \
"dir, '%s', already exists." % newdir)
else:
head, tail = os.path.split(newdir)
if head and not os.path.isdir(head):
_mkdir(head)
if tail:
os.mkdir(newdir)


def get_thumbnail(save_path, image_data, (max_width, max_height), quality=85): def get_thumbnail(save_path, image_data, (max_width, max_height), quality=85):
if not Image: if not Image:
Expand Down
20 changes: 2 additions & 18 deletions tornado_utils/tornado_static.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -26,24 +26,8 @@
import cssmin import cssmin
except ImportError: except ImportError:
cssmin = None cssmin = None


def mkdir(newdir): from .utils import mkdir
"""works the way a good mkdir should :)
- already exists, silently complete
- regular file in the way, raise an exception
- parent directory(ies) does not exist, make them as well
"""
if os.path.isdir(newdir):
pass
elif os.path.isfile(newdir):
raise OSError("a file with the same name as the desired " \
"dir, '%s', already exists." % newdir)
else:
head, tail = os.path.split(newdir)
if head and not os.path.isdir(head):
_mkdir(head)
if tail:
os.mkdir(newdir)


################################################################################ ################################################################################
# Global variable where we store the conversions so we don't have to do them # Global variable where we store the conversions so we don't have to do them
Expand Down
2 changes: 1 addition & 1 deletion tornado_utils/utils.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def mkdir(newdir):
else: else:
head, tail = os.path.split(newdir) head, tail = os.path.split(newdir)
if head and not os.path.isdir(head): if head and not os.path.isdir(head):
_mkdir(head) mkdir(head)
if tail: if tail:
os.mkdir(newdir) os.mkdir(newdir)


Expand Down