]> git.0d.be Git - django-panik-emissions.git/commitdiff
python3: use print() function
authorFrédéric Péters <fpeters@0d.be>
Thu, 10 Oct 2019 12:09:38 +0000 (14:09 +0200)
committerFrédéric Péters <fpeters@0d.be>
Thu, 10 Oct 2019 12:09:38 +0000 (14:09 +0200)
emissions/management/commands/_spip2html.py
emissions/management/commands/create-sound-files.py
emissions/management/commands/day-program.py
emissions/management/commands/load-from-spip.py
emissions/management/commands/update-emission.py
emissions/management/commands/week-program.py
emissions/management/commands/whatsonair.py

index 7d37c92c65b26a924fa2e177589ffebab11fb156..690d8932290ef16af434a4ee66d363c1973592e2 100644 (file)
@@ -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')))
index 1aa475ca545825bc85b81d9f370c8124bf11b2fb..dcf2a7afed518564bfaac540f51701de177c8fd1 100644 (file)
@@ -1,3 +1,5 @@
+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']
 
index 2a9256366e975b2423bc357ef032713649d150f1..5a8a0c062fb504b450df1f3fee889093d67fd690 100644 (file)
@@ -1,3 +1,5 @@
+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)
index 456b04d5848db2f232fcb03ae462be96b6ba9903..18128b7f35605a15fc315844e35ff444da621780 100644 (file)
@@ -1,5 +1,7 @@
 # -*- 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()
index ffce1ec18eea040eb22098c63b2250386ce6b2be..42407e788435e0869f88bcc6ec310f4db7b21b52 100644 (file)
@@ -1,3 +1,5 @@
+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()
index 09a3e5d6b83b68b83a6617b32741f2c31f4e5bee..5fea5064366972a29985eb5aba4dfbd25e369be3 100644 (file)
@@ -1,3 +1,5 @@
+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)
index d016c6fe1e41d8fd8b263686e4a883cf367e3a6f..a87bcd4a0ff44faed423b6b2927e081e427fc6f0 100644 (file)
@@ -1,3 +1,5 @@
+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'))