/usr/lib/python2.7/dist-packages/flufl/password/_registry.py is in python-flufl.password 1.3-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | # Copyright (C) 2011-2014 by Barry A. Warsaw
#
# This file is part of flufl.password
#
# flufl.password is free software: you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by the
# Free Software Foundation, version 3 of the License.
#
# flufl.password is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
# License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with flufl.password. If not, see <http://www.gnu.org/licenses/>.
"""Scheme registry."""
from __future__ import absolute_import, print_function, unicode_literals
__metaclass__ = type
__all__ = [
'BadPasswordSchemeError',
'lookup',
'register',
]
_registry = {}
class BadPasswordSchemeError(Exception):
"""An unknown password scheme tag was given."""
def register(scheme_class):
"""Register a scheme by its tag.
This is intended to be used as a class descriptor.
:param scheme_class: A password scheme.
:type scheme_class: A class which has a `TAG` attribute. The tag may
contain space-separated words with additional information, but the
scheme will be registered using the first word as the key.
:return: scheme_class
"""
key = scheme_class.TAG.split()[0]
_registry[key] = scheme_class
return scheme_class
def lookup(tag):
"""Return a scheme class by its tag.
:param tag: The tag to search for. The tag may contain space-separated
words with additional information, but the scheme will be looked up
using the first word as the key.
:type tag: string
:return: The matching scheme class.
:rtype: class
:raises BadPasswordSchemeError: when the named scheme can't be found.
"""
key = tag.split()[0]
try:
return _registry[key]
except KeyError:
raise BadPasswordSchemeError(tag)
|