Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

utils is a common name #4

Merged
merged 2 commits into from

2 participants

@ifduyue

it is better to use a relative import

@peterbe peterbe merged commit 6c2206b into peterbe:master
@peterbe
Owner

Thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 23, 2012
  1. @ifduyue
  2. @ifduyue

    fix mkdir

    ifduyue authored
    remove duplicate code
    fix a type in utils.mkdir
This page is out of date. Refresh to see the latest.
View
2  tornado_utils/__init__.py
@@ -1 +1 @@
-from utils import *
+from .utils import *
View
18 tornado_utils/thumbnailer.py
@@ -4,23 +4,7 @@
Image = None
import os
-def _mkdir(newdir):
- """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)
+from .utils import mkdir
def get_thumbnail(save_path, image_data, (max_width, max_height), quality=85):
if not Image:
View
20 tornado_utils/tornado_static.py
@@ -26,24 +26,8 @@
import cssmin
except ImportError:
cssmin = None
-
-def mkdir(newdir):
- """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)
+
+from .utils import mkdir
################################################################################
# Global variable where we store the conversions so we don't have to do them
View
2  tornado_utils/utils.py
@@ -76,7 +76,7 @@ def mkdir(newdir):
else:
head, tail = os.path.split(newdir)
if head and not os.path.isdir(head):
- _mkdir(head)
+ mkdir(head)
if tail:
os.mkdir(newdir)
Something went wrong with that request. Please try again.