~computer-janitor-hackers/computer-janitor/py3refactor

« back to all changes in this revision

Viewing changes to computerjanitor/__init__.py

  • Committer: Barry Warsaw
  • Date: 2012-06-08 22:52:43 UTC
  • Revision ID: barry@python.org-20120608225243-l9yc1xenjuy6h1zi
Migrate the last of the default crufts and tests.  The computerjanitor package
directory is no longer necessary.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# __init__.py for computerjanitor
2
 
# Copyright (C) 2008  Canonical, Ltd.
3
 
#
4
 
# This program is free software: you can redistribute it and/or modify
5
 
# it under the terms of the GNU General Public License as published by
6
 
# the Free Software Foundation, version 3 of the License.
7
 
#
8
 
# This program is distributed in the hope that it will be useful,
9
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 
# GNU General Public License for more details.
12
 
#
13
 
# You should have received a copy of the GNU General Public License
14
 
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
 
 
16
 
 
17
 
from __future__ import absolute_import
18
 
 
19
 
VERSION = "1.11"
20
 
 
21
 
 
22
 
# Set up gettext. This needs to be before the import statements below
23
 
# so that if any modules call it right after importing, they find
24
 
# setup_gettext.
25
 
 
26
 
def setup_gettext():
27
 
    """Set up gettext for a module.
28
 
 
29
 
    Return a method to be used for looking up translations. Usage:
30
 
 
31
 
      import computerjanitor
32
 
      _ = computerjanitor.setup_gettext()
33
 
 
34
 
    """
35
 
 
36
 
    import gettext
37
 
    import os
38
 
 
39
 
    domain = 'update-manager'
40
 
    localedir = os.environ.get('LOCPATH', None)
41
 
    t = gettext.translation(domain, localedir=localedir, fallback=True)
42
 
    try:
43
 
        return t.ugettext
44
 
    except AttributeError:
45
 
        return t.gettext
46
 
 
47
 
 
48
 
from .cruft import Cruft
49
 
from .file_cruft import FileCruft
50
 
from .package_cruft import PackageCruft
51
 
from .missing_package_cruft import MissingPackageCruft
52
 
from .exc import ComputerJanitorException as Exception, UnimplementedMethod
53
 
from .plugin import Plugin, PluginManager
54
 
 
55
 
# reference it here to make pyflakes happy
56
 
Cruft
57
 
FileCruft
58
 
PackageCruft
59
 
Exception
60
 
UnimplementedMethod
61
 
MissingPackageCruft
62
 
Plugin
63
 
PluginManager
64
 
 
65