Skip to content
Draft
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
20 changes: 10 additions & 10 deletions lib/booki/editor/management/commands/brokenlinks.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# along with Booktype. If not, see <http://www.gnu.org/licenses/>.

import os
import urllib2
from urllib import request as urllib2
from lxml import etree, html

from django.test import Client
Expand All @@ -40,14 +40,14 @@ def checkLink(options, chapter, urlLink):
if urlLink.startswith(hostUrl):
return

print ' >>> ', urlLink,
print(' >>> ', urlLink,)

if cacheLinks.get(urlLink):
returnCode = cacheLinks.get(urlLink)
else:
try:
response = urllib2.urlopen(HeadRequest(urlLink))
except IOError, e:
except IOError as e:
if hasattr(e, 'reason'):
returnCode = e.reason
elif hasattr(e, 'code'):
Expand All @@ -58,18 +58,18 @@ def checkLink(options, chapter, urlLink):
if not options['no_cache']:
cacheLinks[urlLink] = returnCode

print ' [%s]' % returnCode
print(' [%s]' % returnCode)
else:
if options['no_local']: return

c = Client()
newUrl = os.path.normpath('/%s/_v/%s/%s/%s' % (
chapter.version.book.url_title, chapter.version.getVersion(), chapter.url_title, urlLink))

print ' >> ', newUrl,
print(' >> ', newUrl,)
response = c.get(newUrl)

print ' [%s]' % response.status_code
print(' [%s]' % response.status_code)


class Command(BaseCommand):
Expand Down Expand Up @@ -115,17 +115,17 @@ def handle(self, *args, **options):
booksList = models.Book.objects.all().order_by('url_title')

for book in booksList:
print '[%s]' % book.url_title
print('[%s]' % book.url_title)

try:
for chapter in models.Chapter.objects.filter(version__book=book):
print ' [%s]' % chapter.url_title,
print(' [%s]' % chapter.url_title,)

try:
tree = html.document_fromstring(chapter.content)
print ''
print('')
except:
print ' [ERROR PARSING HTML]'
print(' [ERROR PARSING HTML]')
continue

for elem in tree.iter():
Expand Down
2 changes: 1 addition & 1 deletion lib/booki/editor/management/commands/confdel.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def handle(self, *args, **options):
if not options['<key>'][0]:
raise CommandError("You must specify variable name")

if not settings.BOOKTYPE_CONFIG.has_key(options['<key>'][0]):
if options['<key>'][0] not in settings.BOOKTYPE_CONFIG:
raise CommandError("There is no such variable.")

del settings.BOOKTYPE_CONFIG[options['<key>'][0]]
Expand Down
2 changes: 1 addition & 1 deletion lib/booki/editor/management/commands/confget.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def handle(self, *args, **options):
if not options["<key>"][0]:
raise CommandError("You must specify variable name")

if not settings.BOOKTYPE_CONFIG.has_key(options["<key>"][0]):
if options["<key>"][0] not in settings.BOOKTYPE_CONFIG:
raise CommandError("There is no such variable.")

value = settings.BOOKTYPE_CONFIG[options["<key>"][0]]
Expand Down
2 changes: 1 addition & 1 deletion lib/booki/editor/management/commands/conflist.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def handle(self, *args, **options):
self.stderr.write('Does not have BOOKTYPE_CONFIG in settings.py file.')
return False

for name in settings.BOOKTYPE_CONFIG.iterkeys():
for name in settings.BOOKTYPE_CONFIG.keys():
s = name

if options['values']:
Expand Down
4 changes: 2 additions & 2 deletions lib/booki/editor/migrations/0002_load_initial_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ def load_data(apps, schema_editor):
license = License.objects.get(pk=data['pk'])
license.url = data['url']
license.save()
print "Updating url '%s' to license '%s'" % (data['url'], license.name)
print("Updating url '%s' to license '%s'" % (data['url'], license.name))
except License.DoesNotExist:
print "License with pk %s does not exist. Doing nothing" % data['pk']
print("License with pk %s does not exist. Doing nothing" % data['pk'])


class Migration(migrations.Migration):
Expand Down
2 changes: 1 addition & 1 deletion lib/booki/editor/migrations/0004_convert_endnotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def convert_endnotes(apps, schema_editor):
# converting
tree, _ = EpubImporter.convert_endnotes(tree)

content = unicode(etree.tostring(tree, pretty_print=True, encoding='utf-8',
content = str(etree.tostring(tree, pretty_print=True, encoding='utf-8',
xml_declaration=False), 'utf-8')

# remove redundant div wrapper
Expand Down
Loading