~arky/ubuntu/lucid/aptdaemon/fix-523759

« back to all changes in this revision

Viewing changes to aptdaemon/utils.py

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt
  • Date: 2009-10-06 09:01:10 UTC
  • mfrom: (1.1.11 upstream)
  • Revision ID: james.westby@ubuntu.com-20091006090110-ffj1b4g9ahe2lom7
Tags: 0.10+bzr258-0ubuntu1
* New upstream snapshot:
  - fix hang in authentication dialog (LP: #426720)
  - don't ask for authentication twice (LP: #437094)
  - better handling for broken dependencies
* remove mvo-branch.patch, disallow-unauthenticated-branch.diff
  both got merged upstream
* debian/patches/fix_syslog_crash.patch:
  - fix crash if no syslogd is installed
* aptdaemon/worker.py:
  - test lock of the apt download dir as well 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
"""Module with little helper functions and classes:
 
2
 
 
3
deprecated - decorator to emit a warning if a depreacted function is used
 
4
"""
 
5
#Copyright (C) 2008-2009 Sebastian Heinlein <sevel@glatzor.de>
 
6
#
 
7
#Licensed under the GNU General Public License Version 2
 
8
#
 
9
#This program is free software; you can redistribute it and/or modify
 
10
#it under the terms of the GNU General Public License as published by
 
11
#the Free Software Foundation; either version 2 of the License, or
 
12
#(at your option) any later version.
 
13
#
 
14
#This program is distributed in the hope that it will be useful,
 
15
#but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
17
#GNU General Public License for more details.
 
18
#
 
19
#You should have received a copy of the GNU General Public License
 
20
#along with this program; if not, write to the Free Software
 
21
#Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
22
 
 
23
__author__ = "Sebastian Heinlein <devel@glatzor.de>"
 
24
 
 
25
import functools
 
26
import warnings
 
27
 
 
28
def deprecated(func):
 
29
    """This is a decorator which can be used to mark functions
 
30
    as deprecated. It will result in a warning being emitted
 
31
    when the function is used.
 
32
 
 
33
    Taken from http://wiki.python.org/moin/PythonDecoratorLibrary
 
34
    #GeneratingDeprecationWarnings
 
35
    """
 
36
    @functools.wraps(func)
 
37
    def new_func(*args, **kwargs):
 
38
        warnings.warn_explicit(
 
39
            "Call to deprecated function %(funcname)s." % {
 
40
                'funcname': func.__name__,
 
41
            },
 
42
            category=DeprecationWarning,
 
43
            filename=func.func_code.co_filename,
 
44
            lineno=func.func_code.co_firstlineno + 1
 
45
        )
 
46
        return func(*args, **kwargs)
 
47
    return new_func
 
48
 
 
49
# vim:ts=4:sw=4:et