Bladeren bron

remove python 2/3 compability code to only support python 3 from now on

Helmut Pozimski 9 jaren geleden
bovenliggende
commit
a35aa28809
8 gewijzigde bestanden met toevoegingen van 17 en 36 verwijderingen
  1. 2 8
      lib_stov/configuration.py
  2. 1 1
      lib_stov/database.py
  3. 10 15
      lib_stov/noapi.py
  4. 1 3
      lib_stov/stov_exceptions.py
  5. 0 2
      lib_stov/subscription.py
  6. 0 2
      lib_stov/youtube.py
  7. 1 1
      setup.py
  8. 2 4
      stov

+ 2 - 8
lib_stov/configuration.py

@@ -15,12 +15,8 @@
 
 # -*- coding: utf8 -*-
 
-from __future__ import unicode_literals
-from __future__ import print_function
-
 import os
 import subprocess
-import sys
 import json
 
 from lib_stov import stov_exceptions
@@ -234,10 +230,8 @@ class conf(object):
             print(self.__explanations[value] + " [" + self.values[value] +
                   "]:" +
                   " ")
-            if sys.version_info >= (3, 0):
-                user_input = input()
-            else:
-                user_input = raw_input()
+            user_input = input()
+
             if user_input != "":
                 self.values[value] = user_input
         self.dbpath = str(os.environ['HOME']) + "/.stov/" + \

+ 1 - 1
lib_stov/database.py

@@ -1,4 +1,4 @@
-#       This file is part of stov, written by Helmut Pozimski in 2014.
+#       This file is part of stov, written by Helmut Pozimski 2012-2015.
 #
 #       stov is free software: you can redistribute it and/or modify
 #       it under the terms of the GNU General Public License as published by

+ 10 - 15
lib_stov/noapi.py

@@ -16,16 +16,11 @@
 
 # -*- coding: utf8 -*-
 
-from __future__ import unicode_literals
-
 import subprocess
 import sys
 import lxml.html
-
-if sys.version_info >= (3,):
-    import urllib.request as urllib2
-else:
-    import urllib2
+import urllib.parse
+import urllib.request
 
 from lib_stov import stov_exceptions
 
@@ -60,18 +55,18 @@ class Connector(object):
     def _construct_url(self):
         if self._type == "channel":
             self._url = "https://www.youtube.com/user/%s" \
-                        % urllib2.quote(self._name)
+                        % urllib.parse.quote(self._name)
         elif self._type == "search":
             self._url = "https://www.youtube.com/results?search_query=%s"\
-                        % urllib2.quote(self._search)
+                        % urllib.parse.quote(self._search)
         elif self._type == "playlist":
             self._url = "https://www.youtube.com/playlist?list=%s" \
-                        % urllib2.quote(self._name)
+                        % urllib.parse.quote(self._name)
 
     def _fetch_title(self):
         """Retrieves the title of the HTML page to use as a title for the
         subscription."""
-        data = urllib2.urlopen(self._url)
+        data = urllib.request.urlopen(self._url)
         parsed_html = lxml.html.parse(data)
         data.close()
         i = 0
@@ -131,9 +126,9 @@ class Connector(object):
                         raise stov_exceptions.YoutubeDlCallFailed()
                     else:
                         videos_list.append(YtVideo(
-                            unicode(video_title, "utf-8"),
-                            unicode(video_description, "utf-8"),
-                            unicode(video_id)))
+                            video_title,
+                            video_description,
+                            video_id))
         return videos_list
 
     def ParseAPIData(self, existing_videos):
@@ -145,6 +140,6 @@ class Connector(object):
         self._fetch_title()
         videos = self._fetch_videos(existing_videos)
         channel = YtChannel()
-        channel.title = unicode(self._title)
+        channel.title = self._title
         channel.videos = videos
         return channel

+ 1 - 3
lib_stov/stov_exceptions.py

@@ -1,4 +1,4 @@
-#       This file is part of stov, written by Helmut Pozimski in 2014.
+#       This file is part of stov, written by Helmut Pozimski 2012-2015.
 #
 #       stov is free software: you can redistribute it and/or modify
 #       it under the terms of the GNU General Public License as published by
@@ -15,8 +15,6 @@
 
 # -*- coding: utf8 -*-
 
-from __future__ import unicode_literals
-
 
 class DBConnectionFailedException(Exception):
     """ This exception will be raised when the initial connetion attempt

+ 0 - 2
lib_stov/subscription.py

@@ -16,8 +16,6 @@
 
 # -*- coding: utf8 -*-
 
-from __future__ import unicode_literals
-
 from lib_stov import stov_exceptions
 from lib_stov import noapi
 

+ 0 - 2
lib_stov/youtube.py

@@ -16,8 +16,6 @@
 
 # -*- coding: utf8 -*-
 
-from __future__ import unicode_literals
-
 import os
 import sys
 import subprocess

+ 1 - 1
setup.py

@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
 
 #
 #        This file is part of stov, written by Helmut Pozimski 2012-2015.

+ 2 - 4
stov

@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
 # -*- coding: utf8 -*-
 
 #   stov - a program to subscribe to channels and users from youtube
@@ -21,8 +21,6 @@
 #   Foundation, Inc., 51 Franklin Street, Fifth Floor,
 #   Boston, MA 02110-1301, USA.
 
-from __future__ import unicode_literals
-from __future__ import print_function
 import sys
 import gettext
 import os
@@ -264,7 +262,7 @@ if os.access(os.environ['HOME'] + "/.stov", os.F_OK & os.W_OK) is not True:
         temp_input = input()
     else:
         # noinspection PyCompatibility
-        temp_input = raw_input()
+        temp_input = input()
     if temp_input == "yes":
         conf.assist()
         try: