Skip to content

Commit

Permalink
Python 3 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
palewire committed Feb 1, 2014
1 parent 5d57750 commit 69eb5b9
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.tox/
MANIFEST
.coverage
build/*
Expand Down
9 changes: 5 additions & 4 deletions bakery/management/commands/build.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import six
import shutil
from django.conf import settings
from optparse import make_option
Expand Down Expand Up @@ -59,7 +60,7 @@ def handle(self, *args, **options):

# Destroy the build directory, if it exists
if self.verbosity > 1:
print "Creating build directory"
six.print_("Creating build directory")
if os.path.exists(self.build_dir):
shutil.rmtree(self.build_dir)

Expand All @@ -69,7 +70,7 @@ def handle(self, *args, **options):
# Build up static files
if not options.get("skip_static"):
if self.verbosity > 1:
print "Creating static directory"
six.print_("Creating static directory")
management.call_command(
"collectstatic",
interactive=False,
Expand All @@ -84,7 +85,7 @@ def handle(self, *args, **options):
# Build the media directory
if not options.get("skip_media"):
if self.verbosity > 1:
print "Building media directory"
six.print_("Building media directory")
if os.path.exists(settings.MEDIA_ROOT) and settings.MEDIA_URL:
shutil.copytree(
settings.MEDIA_ROOT,
Expand All @@ -102,7 +103,7 @@ def handle(self, *args, **options):
# Then loop through and run them all
for view_str in view_list:
if self.verbosity > 1:
print "Building %s" % view_str
six.print_("Building %s" % view_str)
try:
view = get_callable(view_str)
view().build_method()
Expand Down
3 changes: 2 additions & 1 deletion bakery/management/commands/publish.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import six
import subprocess
from django.conf import settings
from optparse import make_option
Expand Down Expand Up @@ -89,7 +90,7 @@ def handle(self, *args, **options):

# Print out the command unless verbosity is above the default
if int(options.get('verbosity')) > 1:
print 'Executing %s' % cmd
six.print_('Executing %s' % cmd)

# Execute the command
subprocess.call(cmd, shell=True)
2 changes: 1 addition & 1 deletion bakery/management/commands/unpublish.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def get_random_string(self, length=6):
"""
return ''.join(
random.choice(string.letters + string.digits)
for i in xrange(length)
for i in range(length)
)

def handle(self, *args, **kwds):
Expand Down
4 changes: 2 additions & 2 deletions bakery/static_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import posixpath
import re
import stat
import urllib
from six.moves.urllib.parse import unquote
from email.Utils import parsedate_tz, mktime_tz
from django.template import loader
from django.http import Http404, HttpResponse, HttpResponseRedirect
Expand Down Expand Up @@ -38,7 +38,7 @@ def serve(request, path, document_root=None, show_indexes=False, default=''):
"""

# Clean up given path to only allow serving files below document_root.
path = posixpath.normpath(urllib.unquote(path))
path = posixpath.normpath(unquote(path))
path = path.lstrip('/')
newpath = ''
for part in path.split('/'):
Expand Down
3 changes: 2 additions & 1 deletion bakery/tests.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import views
from __future__ import absolute_import
from . import views
from django.test import TestCase


Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def fullsplit(path, result=None):
author_email='datadesk@latimes.com',
url='http://www.github.com/datadesk/django-bakery/',
packages=packages,
install_requires=['six==1.5.2'],
cmdclass = cmdclasses,
data_files=data_files,
)
Expand Down
10 changes: 10 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[tox]
envlist=py27,py33

[testenv]
deps=
django
six
commands=
coverage run quicktest.py bakery
coverage report -m

0 comments on commit 69eb5b9

Please sign in to comment.