Commit ed3e616d authored by fred's avatar fred

python3: use print() function

parent 55b3c575
......@@ -38,6 +38,8 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
from __future__ import print_function
import re
import sys
import os
......@@ -875,7 +877,7 @@ class SpipParser:
name, title = name.split('|', 2)
except ValueError:
# XXX
print 'error splitting', repr(name)
print('error splitting', repr(name))
name, title = oTitle, 'XXX'
if not name:
name = oTitle
......@@ -1013,9 +1015,9 @@ class SpipParser:
try:
url = re.findall('href=(.*?)>', self.getVar('group'), re.DOTALL)[0]
except IndexError:
print 'XXX', self.getVar('group')
print('XXX', self.getVar('group'))
except KeyError:
print 'XXX'
print('XXX')
self.pullState()
return self.formatter.link(formattedText, url)
......@@ -1132,6 +1134,6 @@ def makeHtmlFromSpip(text, simple=0, inline=0, documents=None, **keywords):
if __name__ == '__main__':
if os.path.exists(sys.argv[1]):
print makeHtmlFromSpip(unicode(file(sys.argv[1]).read(), 'utf-8'))
print(makeHtmlFromSpip(unicode(file(sys.argv[1]).read(), 'utf-8')))
else:
print makeHtmlFromSpip(unicode(sys.argv[1], 'utf-8'))
print(makeHtmlFromSpip(unicode(sys.argv[1], 'utf-8')))
from __future__ import print_function
import base64
import mutagen
import mutagen.mp3
......@@ -85,8 +87,8 @@ class Command(BaseCommand):
cmd.append(file_path)
if self.verbose:
print 'creating', file_path
print ' ', ' '.join(cmd)
print('creating', file_path)
print(' ', ' '.join(cmd))
else:
cmd[1:1] = ['-loglevel', 'quiet']
......
from __future__ import print_function
from datetime import datetime
from django.core.management.base import BaseCommand, CommandError
......@@ -13,4 +15,4 @@ class Command(BaseCommand):
year, month, day = date.split('-')
date = datetime(int(year), int(month), int(day))
for entry in day_program(date):
print entry.datetime, entry
print(entry.datetime, entry)
# -*- coding: utf-8 -*-
from __future__ import print_function
from datetime import datetime
import time
import gzip
......@@ -166,7 +168,7 @@ class Command(BaseCommand):
with open(filename) as fd:
if self.verbose:
print 'Reading SPIP dump file'
print('Reading SPIP dump file')
content = fd.read()
# the spip_courriers parts of the spip export are not properly
# encoded, we manually remove them here so the XML file can be
......@@ -176,7 +178,7 @@ class Command(BaseCommand):
self.root = ET.fromstring(content)
if self.verbose:
print 'Loading objects from dump'
print('Loading objects from dump')
self.load_keyword_groups()
self.load_keywords()
self.load_rubrics()
......@@ -192,11 +194,11 @@ class Command(BaseCommand):
self.breves = {}
if not self.article_ids:
if self.verbose:
print ' breves...'
print(' breves...')
self.load_breves()
if self.verbose:
print ' articles...'
print(' articles...')
self.load_articles(emission_rubric_ids)
self.set_urls()
......@@ -208,11 +210,11 @@ class Command(BaseCommand):
self.process_episode_keywords()
self.process_newsitem_keywords()
print 'Creating emissions'
print('Creating emissions')
for emission_id in straight_emission_rubric_ids:
rubric = self.rubrics[emission_id]
emission = self.get_or_create_emission(rubric)
print ' ', emission.title
print(' ', emission.title)
if rewritemap_file:
self.add_rewritemap_entries(rubric, emission)
......@@ -225,7 +227,7 @@ class Command(BaseCommand):
self.set_sound_files(article, episode)
print 'Creating newsitems'
print('Creating newsitems')
for breve in self.breves.values():
if breve.titre.startswith('Cette semaine sur Panik'):
continue
......@@ -564,9 +566,9 @@ class Command(BaseCommand):
else:
has_sound = '-'
base_spip_edit_url = 'http://www.radiopanik.org/spip/ecrire/?exec=articles_edit&id_article='
print >> self.stats_skipped_file, unicode('%s\t%s\t%s\t%s%s' % (
self.stats_skipped_file.write(unicode('%s\t%s\t%s\t%s%s' % (
emission.title, article.titre, has_sound,
base_spip_edit_url, article.id_article)).encode('utf-8')
base_spip_edit_url, article.id_article)).encode('utf-8'))
return None
possible_slugs = [article.url.lower()]
......@@ -716,7 +718,7 @@ class Command(BaseCommand):
return
if self.verbose:
print ' set portfolio on', object
print(' set portfolio on', object)
# get filename, eventually to properly sized images
for i, attached_file in enumerate(attached_files):
......@@ -761,5 +763,5 @@ class Command(BaseCommand):
def write_rewritemap(self, rewritemap_file):
fd = file(rewritemap_file, 'w')
for src, dst in self.rewritemap:
print >> fd, src, dst
fd.write('%s %s\n' % (src, dst))
fd.close()
from __future__ import print_function
from optparse import make_option
from django.core.management.base import BaseCommand, CommandError
......@@ -24,6 +26,6 @@ class Command(BaseCommand):
try:
episode = Episode.objects.get(slug=episode_slug)
except Episode.DoesNotExist:
print 'missing episode:', episode
print('missing episode:', episode)
episode.emission = emission
episode.save()
from __future__ import print_function
from datetime import datetime, timedelta
from django.core.management.base import BaseCommand, CommandError
......@@ -17,4 +19,4 @@ class Command(BaseCommand):
week, '%W')
date = datetime(*date.timetuple()[:3])
for entry in period_program(date, date+timedelta(days=7)):
print entry.datetime, entry
print(entry.datetime, entry)
from __future__ import print_function
from django.core.management.base import BaseCommand, CommandError
from ...utils import whatsonair
......@@ -6,6 +8,6 @@ from ...utils import whatsonair
class Command(BaseCommand):
def handle(self, *args, **options):
onair = whatsonair()
print 'found episode:', onair.get('episode')
print 'found emission:', onair.get('emission')
print 'found nonstop:', onair.get('nonstop')
print('found episode:', onair.get('episode'))
print('found emission:', onair.get('emission'))
print('found nonstop:', onair.get('nonstop'))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment