~ubuntu-branches/ubuntu/vivid/gpodder/vivid

« back to all changes in this revision

Viewing changes to .pc/debian-changes-2.15-1/src/gpodder/__init__.py

  • Committer: Bazaar Package Importer
  • Author(s): tony mancill
  • Date: 2011-05-31 22:05:31 UTC
  • mfrom: (5.2.18 sid)
  • Revision ID: james.westby@ubuntu.com-20110531220531-f3gt49fypbmuair8
Tags: 2.15-2
This time without a patch that reverts the source to 2.14.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*- coding: utf-8 -*-
2
 
#
3
 
# gPodder - A media aggregator and podcast client
4
 
# Copyright (c) 2005-2011 Thomas Perl and the gPodder Team
5
 
#
6
 
# gPodder is free software; you can redistribute it and/or modify
7
 
# it under the terms of the GNU General Public License as published by
8
 
# the Free Software Foundation; either version 3 of the License, or
9
 
# (at your option) any later version.
10
 
#
11
 
# gPodder is distributed in the hope that it will be useful,
12
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
# GNU General Public License for more details.
15
 
#
16
 
# You should have received a copy of the GNU General Public License
17
 
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
 
#
19
 
 
20
 
__author__    = 'Thomas Perl <thp@gpodder.org>'
21
 
__version__   = '2.15'
22
 
__date__      = '2011-05-03'
23
 
__copyright__ = '© 2005-2011 Thomas Perl and the gPodder Team'
24
 
__licence__   = 'GNU General Public License, version 3 or later'
25
 
__url__       = 'http://gpodder.org/'
26
 
 
27
 
import os
28
 
import sys
29
 
import platform
30
 
import gettext
31
 
import locale
32
 
 
33
 
# Check if real hard dependencies are available
34
 
try:
35
 
    import feedparser
36
 
except ImportError:
37
 
    print """
38
 
  Error: Module "feedparser" not found. Please install "python-feedparser".
39
 
         The feedparser module can be downloaded from www.feedparser.org.
40
 
"""
41
 
    sys.exit(1)
42
 
del feedparser
43
 
 
44
 
try:
45
 
    import mygpoclient
46
 
except ImportError:
47
 
    print """
48
 
  Error: Module "mygpoclient" not found. Please install "python-mygpoclient"
49
 
         or download it from http://thp.io/2010/mygpoclient/
50
 
"""
51
 
    sys.exit(1)
52
 
del mygpoclient
53
 
 
54
 
# The User-Agent string for downloads
55
 
user_agent = 'gPodder/%s (+%s)' % (__version__, __url__)
56
 
 
57
 
# Are we running in GUI, Maemo or console mode?
58
 
class UI(object):
59
 
    def __init__(self):
60
 
        self.desktop = False
61
 
        self.diablo = False
62
 
        self.fremantle = False
63
 
 
64
 
    @property
65
 
    def maemo(self):
66
 
        return self.diablo or self.fremantle
67
 
 
68
 
ui = UI()
69
 
 
70
 
# D-Bus specific interface names
71
 
dbus_bus_name = 'org.gpodder'
72
 
dbus_gui_object_path = '/gui'
73
 
dbus_podcasts_object_path = '/podcasts'
74
 
dbus_interface = 'org.gpodder.interface'
75
 
dbus_podcasts = 'org.gpodder.podcasts'
76
 
dbus_session_bus = None
77
 
 
78
 
# Set "win32" to True if we are on Windows
79
 
win32 = (platform.system() == 'Windows')
80
 
 
81
 
# i18n setup (will result in "gettext" to be available)
82
 
# Use   _ = gpodder.gettext   in modules to enable string translations
83
 
textdomain = 'gpodder'
84
 
locale_dir = gettext.bindtextdomain(textdomain)
85
 
t = gettext.translation(textdomain, locale_dir, fallback=True)
86
 
gettext = t.ugettext
87
 
ngettext = t.ungettext
88
 
if win32:
89
 
    # Workaround for bug 650
90
 
    from gtk.glade import bindtextdomain
91
 
    bindtextdomain(textdomain, locale_dir)
92
 
    del bindtextdomain
93
 
del t
94
 
 
95
 
# Set up textdomain for gtk.Builder (this accesses the C library functions)
96
 
if hasattr(locale, 'bindtextdomain'):
97
 
    locale.bindtextdomain(textdomain, locale_dir)
98
 
else:
99
 
    # On Win32, the locale module does not have bindtextdomain. We use a
100
 
    # small module that provides similar functionality here (from doc/dev/).
101
 
    try:
102
 
        import gtkbuilderi18n
103
 
        gtkbuilderi18n.bindtextdomain(textdomain, locale_dir)
104
 
    except ImportError, ioe:
105
 
        pass
106
 
 
107
 
del locale_dir
108
 
 
109
 
# Set up socket timeouts to fix bug 174
110
 
SOCKET_TIMEOUT = 60
111
 
import socket
112
 
socket.setdefaulttimeout(SOCKET_TIMEOUT)
113
 
del socket
114
 
del SOCKET_TIMEOUT
115
 
 
116
 
# Variables reserved for GUI-specific use (will be set accordingly)
117
 
ui_folders = []
118
 
credits_file = None
119
 
icon_file = None
120
 
images_folder = None
121
 
user_hooks = None
122
 
 
123
 
# Episode states used in the database
124
 
STATE_NORMAL, STATE_DOWNLOADED, STATE_DELETED = range(3)
125
 
 
126
 
# Default locations for configuration and data files
127
 
default_home = os.path.expanduser(os.path.join('~', '.config', 'gpodder'))
128
 
home = os.environ.get('GPODDER_HOME', None)
129
 
if home is None:
130
 
    home = default_home
131
 
else:
132
 
    print >>sys.stderr, 'Using', home, 'to store data (GPODDER_HOME is set)'
133
 
subscription_file = os.path.join(home, 'channels.opml')
134
 
config_file = os.path.join(home, 'gpodder.conf')
135
 
database_file = os.path.join(home, 'database.sqlite')
136
 
 
137
 
# Plugins to load by default
138
 
DEFAULT_PLUGINS = ['gpodder.soundcloud', 'gpodder.xspf']
139
 
 
140
 
def load_plugins():
141
 
    """Load (non-essential) plugin modules
142
 
 
143
 
    This loads a default set of plugins, but you can use
144
 
    the environment variable "GPODDER_PLUGINS" to modify
145
 
    the list of plugins."""
146
 
    global DEFAULT_PLUGINS
147
 
    PLUGINS = os.environ.get('GPODDER_PLUGINS', None)
148
 
    if PLUGINS is None:
149
 
        PLUGINS = DEFAULT_PLUGINS
150
 
    else:
151
 
        PLUGINS = PLUGINS.split()
152
 
    for plugin in PLUGINS:
153
 
        try:
154
 
            __import__(plugin)
155
 
        except Exception, e:
156
 
            print >>sys.stderr, 'Cannot load plugin: %s (%s)' % (plugin, e)
157