Code cleanup

This commit is contained in:
Roberto Rosario
2011-07-21 11:46:15 -04:00
parent 46aa89d924
commit 90e876ca93
36 changed files with 125 additions and 169 deletions

View File

@@ -20,7 +20,7 @@ except:
import mimetypes
mimetypes.init()
USE_PYTHON_MAGIC = False
def urlquote(link=None, get=None):
u'''
@@ -357,7 +357,7 @@ def get_mimetype(filepath):
"""
file_mimetype = u''
file_mime_encoding = u''
if USE_PYTHON_MAGIC:
if os.path.exists(filepath):
try:
@@ -373,7 +373,7 @@ def get_mimetype(filepath):
else:
path, filename = os.path.split(filepath)
file_mimetype, file_mime_encoding = mimetypes.guess_type(filename)
return file_mimetype, file_mime_encoding
@@ -384,7 +384,7 @@ def validate_path(path):
os.mkdir(path)
except:
return False
# Check if it is writable
try:
fd, test_filepath = tempfile.mkstemp(dir=path)
@@ -392,5 +392,5 @@ def validate_path(path):
os.unlink(test_filepath)
except:
return False
return True