"Fossies" - the Fresh Open Source Software Archive 
Member "revelation-0.5.4/src/lib/datahandler/__init__.py" (4 Oct 2020, 2428 Bytes) of package /linux/privat/revelation-0.5.4.tar.xz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style:
standard) with prefixed line numbers.
Alternatively you can here
view or
download the uninterpreted source code file.
For more information about "__init__.py" see the
Fossies "Dox" file reference documentation and the latest
Fossies "Diffs" side-by-side code changes report:
0.5.3_vs_0.5.4.
1 #
2 # Revelation - a password manager for GNOME 2
3 # http://oss.codepoet.no/revelation/
4 # $Id$
5 #
6 # Module for data handlers
7 #
8 #
9 # Copyright (c) 2003-2006 Erik Grinaker
10 #
11 # This program is free software; you can redistribute it and/or
12 # modify it under the terms of the GNU General Public License
13 # as published by the Free Software Foundation; either version 2
14 # of the License, or (at your option) any later version.
15 #
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
20 #
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write to the Free Software
23 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 #
25
26 from .base import Error, DataError, FormatError, PasswordError, VersionError
27
28 from .csvfile import CSV, Bitwarden
29 from .fpm import FPM
30 from .gpass import GPass04, GPass05
31 from .keepassxc import KeepassXCCSV
32 from .netrc import NetRC
33 from .pwsafe import PasswordSafe1, PasswordSafe2, MyPasswordSafe, MyPasswordSafeOld, PasswordGorilla
34 from .rvl import RevelationXML, Revelation, Revelation2, RevelationLUKS
35 from .splashid import SplashIDCSV
36 from .text import PlainText
37 from .xhtml import XHTML
38
39 HANDLERS = [
40 CSV,
41 Bitwarden,
42 FPM,
43 GPass04,
44 GPass05,
45 KeepassXCCSV,
46 MyPasswordSafe,
47 MyPasswordSafeOld,
48 NetRC,
49 PasswordGorilla,
50 PasswordSafe1,
51 PasswordSafe2,
52 PlainText,
53 Revelation,
54 Revelation2,
55 RevelationLUKS,
56 SplashIDCSV,
57 XHTML,
58 RevelationXML
59 ]
60
61
62 class DetectError(Error):
63 "Exception for autodetection error"
64 pass
65
66
67 def detect_handler(input):
68 "Detects which handler may process a data stream"
69
70 for handler in get_import_handlers():
71 if handler().detect(input) == True:
72 return handler
73
74 else:
75 raise DetectError
76
77
78 def get_export_handlers():
79 "Returns a list of handlers which can export"
80
81 handlers = []
82
83 for handler in HANDLERS:
84 if handler.exporter:
85 handlers.append(handler)
86
87 return handlers
88
89
90 def get_import_handlers():
91 "Returns a list of handlers which can import"
92
93 handlers = []
94
95 for handler in HANDLERS:
96 if handler.importer:
97 handlers.append(handler)
98
99 return handlers
100