1 |
# Copyright (C) 2004 by Intevation GmbH |
2 |
# Authors: |
3 |
# Jan-Oliver Wagner <[email protected]> |
4 |
# |
5 |
# This program is free software under the GPL (>=v2) |
6 |
# Read the file COPYING coming with Thuban for details. |
7 |
|
8 |
""" |
9 |
Registry for Extensions. |
10 |
|
11 |
This module defines a registry for Extensions. |
12 |
This is basically used for displaying information on |
13 |
the active Extensions in the general About-Dialog. |
14 |
A registration is not mandatory to make a Extension |
15 |
work, but any Extension should register to provide |
16 |
a complete information in the Thuban About Dialog. |
17 |
|
18 |
A Extension should define a ExtensionDesc object |
19 |
and apply ext_registry.add() to register it. |
20 |
""" |
21 |
|
22 |
__version__ = "$Revision$" |
23 |
# $Source$ |
24 |
# $Id$ |
25 |
|
26 |
class ExtensionDesc: |
27 |
|
28 |
""" |
29 |
A description of a Thuban Extension. |
30 |
""" |
31 |
|
32 |
def __init__(self, name, version, authors, copyright, desc): |
33 |
""" |
34 |
Initialize a new Thuban Extension information. |
35 |
|
36 |
name -- The name of the Thuban Extension. |
37 |
Example: 'gns2shp' |
38 |
|
39 |
version -- The version number of the Thuban Extension. |
40 |
Example: '1.0.0' |
41 |
|
42 |
authors -- List of authors. |
43 |
Example: [ 'Jan-Oliver Wagner' ] |
44 |
|
45 |
copyright -- Copyright notice. |
46 |
Example: '2003, 2004 Intevation GmbH' |
47 |
|
48 |
desc -- Short description of the Thuban Extension. |
49 |
Example: _(''' |
50 |
Converts GNS (Geographical Name Service of NIMA) |
51 |
to Shapefile format and displays the data. |
52 |
''') |
53 |
|
54 |
""" |
55 |
self.name = name |
56 |
self.version = version |
57 |
self.authors = authors |
58 |
self.copyright = copyright |
59 |
self.desc = desc |
60 |
|
61 |
class ExtensionRegistry: |
62 |
|
63 |
""" |
64 |
A ExtensionRegistry keeps information on the registered |
65 |
Thuban Extensions. |
66 |
|
67 |
The registry will raise a exception either when the version |
68 |
required for the Extensions exceeds the version of the currently |
69 |
running Thuban or if the name of a registered extension already |
70 |
is used for registering another extension. |
71 |
""" |
72 |
|
73 |
def __init__(self): |
74 |
self.registry = [] |
75 |
|
76 |
def __nonzero__(self): |
77 |
return len(self.registry) <> 0 |
78 |
|
79 |
def __iter__(self): |
80 |
return iter(self.registry) |
81 |
|
82 |
def add(self, ext): |
83 |
self.registry.append(ext) |
84 |
|
85 |
|
86 |
# The central Thuban Extensions registry |
87 |
ext_registry = ExtensionRegistry() |