Additions to make code more compatible for py2 and py3

This commit is contained in:
Manuel Cortez 2018-03-04 12:29:25 -06:00
parent 20942dedd9
commit b47d6efe45
10 changed files with 35 additions and 6 deletions

View File

@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
""" main controller for MusicDL"""
from __future__ import unicode_literals # at top of module
import webbrowser
import wx
import logging

View File

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals # at top of module
import os
import random
import vlc

View File

@ -1,5 +1,6 @@
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
from __future__ import unicode_literals # at top of module
class song(object):
""" Represents a song in all services. Data will be filled by the service itself"""

View File

@ -1,6 +1,10 @@
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import urllib.parse
from __future__ import unicode_literals # at top of module
try:
import urllib.parse as urlparse
except ImportError:
import urllib as urlparse
import requests
import youtube_dl
from bs4 import BeautifulSoup
@ -25,7 +29,7 @@ class interface(object):
s.title = data[0].text.replace("\n", "").replace("\t", "")
# s.artist = data[1].text.replace("\n", "").replace("\t", "")
# print(data)
s.url = u"https://my.mail.ru"+urllib.parse.quote(data[0].__dict__["attrs"]["href"])
s.url = u"https://my.mail.ru"+urlparse.quote(data[0].__dict__["attrs"]["href"])
self.results.append(s)
def get_download_url(self, url):

View File

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals # at top of module
import requests
from .import baseFile
from update.utils import seconds_to_string

View File

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals # at top of module
import isodate
import youtube_dl
from googleapiclient.discovery import build

View File

@ -1,5 +1,6 @@
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
from __future__ import unicode_literals # at top of module
import re
import json
import requests

View File

@ -1,4 +1,9 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals # at top of module
import sys
if sys.version[0] == "2":
import fixes
fixes.setup()
import i18n
i18n.setup()
import widgetUtils

View File

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals # at top of module
import wx
import application
from .import utils

View File

@ -1,6 +1,10 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals # at top of module
import wx
import wx.adv
try:
import wx.adv
except ImportError:
pass
import application
import widgetUtils
@ -77,7 +81,10 @@ class mainWindow(wx.Frame):
self.sb.SetStatusText(status)
def about_dialog(self, *args, **kwargs):
try:
info = wx.adv.AboutDialogInfo()
except:
info = wx.AboutDialogInfo()
info.SetName(application.name)
info.SetVersion(application.version)
info.SetDescription(application.description)
@ -86,7 +93,10 @@ class mainWindow(wx.Frame):
info.SetTranslators(application.translators)
# info.SetLicence(application.licence)
info.AddDeveloper(application.author)
try:
wx.adv.AboutBox(info)
except:
wx.AboutBox(info)
def get_text(self):
t = self.text.GetValue()
@ -103,5 +113,8 @@ class mainWindow(wx.Frame):
saveFileDialog.Destroy()
def notify(self, title, text):
try:
self.notification = wx.adv.NotificationMessage(title, text, parent=self)
except AttributeError:
self.notification = wx.NotificationMessage(title, text, parent=self)
self.notification.Show()