source: cows/trunk/cows/model/iso19115_subset.py @ 3553

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/cows/trunk/cows/model/iso19115_subset.py@4060
Revision 3553, 4.4 KB checked in by spascoe, 12 years ago (diff)

Moved all the model classes into their own sub-module.

Line 
1# Copyright (C) 2007 STFC & NERC (Science and Technology Facilities Council).
2# This software may be distributed under the terms of the
3# Q Public License, version 1.0 or later.
4# http://ndg.nerc.ac.uk/public_docs/QPublic_license.txt
5"""
6Classes modelling the OWS ISO19115 subset package v1.1.0.
7
8@author: Stephen Pascoe
9"""
10
11class LanguageString(str):
12    """
13    If you wish to attach a language identifier to a string use this
14    class.  Otherwise normal strings can be used in place of LanguageString.
15   
16    @ivar lang: language identifier
17    @type lang: str
18
19    """
20
21    def __new__(cls, value='', lang=None):
22        return str.__new__(cls, value)
23   
24    def __init__(self, value='', lang=None):
25        self.lang = lang
26
27class Code(str):
28    """
29    If you wish to attach a codeSpace to a Code element use this class,
30    otherwise it can be substituted with a string
31
32    @ivar code
33    @type code: str
34    @ivar codeSpace: URI qualifying self.code
35    @type codeSpace: None or char
36
37    """
38
39    def __new__(cls, code='', codeSpace=None):
40        return str.__new__(cls, code)
41
42    def __init__(self, code='', codeSpace=None):
43        self.codeSpace = codeSpace
44
45class Keywords(list):
46    """
47    If you wish to attach a type code to a keyword list use this class.
48    Otherwise any iterable can be used in place of Keywords.
49
50    @ivar type
51    @type type: Code
52
53    """
54    __slots__ = ['type']
55
56    def __new__(cls, value=[], type=None):
57        return list.__new__(cls, value)
58
59    def __init__(self, value=[], type=None):
60        self.type = type
61       
62class Xlink(object):
63    """
64    This class exposes all xlink:simpleLink attributes.
65
66    @ivar href: A URL
67    @type href: str
68    @ivar role
69    @type role: None or str
70    @ivar show
71    @type show: None or str
72    @ivar title
73    @type title: None or str
74    @ivar actuate
75    @type actuate: None or str
76    @ivar arcrole
77    @type arcrole: None or str
78
79    """
80    def __init__(self, href, role=None, show=None, title=None, actuate=None,
81                 arcrole=None):
82        self.href = href
83        self.role = role
84        self.show = show
85        self.title = title
86        self.actuate = actuate
87        self.arcrole = arcrole
88
89class OnlineResource(Xlink):
90    pass
91
92
93#ResponsibleParty, Address, Telephone, & Contact classes added by D.Lowe
94class ResponsibleParty(object):
95    """
96    @ivar individualName
97    @type individualName: None or str
98    @ivar positionName
99    @type positionName: None or str
100    @ivar role
101    @type role: None or Code
102    @ivar contactInfo
103    @type contactInfo: None or Contact
104    """
105    def __init__(self, individualName=None, positionName=None, role=None, contactInfo=None):
106        self.individualName=individualName
107        self.positionName=positionName
108        self.role=role   
109        self.contactInfo=contactInfo
110
111class Address(object):
112    """
113    @ivar deliveryPoints
114    @type deliveryPoints: iterable of str objects
115    @ivar city
116    @type city: None or str
117    @ivar administrativeArea
118    @type administrativeArea: None or str
119    @ivar postalCode
120    @type postalCode: None or str
121    @ivar country
122    @type country: None or str
123    @ivar electronicMailAddress
124    @type electronicMailAddress: None or str
125   
126    """
127    def __init__(self, deliveryPoints=[],city=None, administrativeArea=None, postalCode=None, country=None, electronicMailAddress=None):
128        self.deliveryPoints=deliveryPoints
129        self.city=city
130        self.administrativeArea=administrativeArea
131        self.postalCode=postalCode
132        self.country=country
133        self.electronicMailAddress=electronicMailAddress       
134
135class Telephone(object):
136   """
137   @ivar voice
138   @type voice: None or str
139   @ivar facsimile
140   @type facsimile: None or str
141   """
142   def __init__(self, voice=None, facsimile=None):
143       self.voice=voice
144       self.facsimile=facsimile
145
146class Contact(object):
147    """
148    @ivar hoursOfService
149    @type hoursOfService: None or str
150    @ivar contactInstructions
151    @type contactInstructions: None or str
152    @ivar address
153    @type address: None or Address
154    @ivar phone
155    @type phone: None or Telephone
156    @ivar onlineResource
157    @type onlineResource: None or OnlineResource
158    """
159    def __init__(self, hoursOfService=None, contactInstructions=None, address=None, phone=None, onlineResource=None):
160        self.hoursOfService=hoursOfService
161        self.contactInstructions=contactInstructions
162        self.address=address
163        self.phone=phone
164        self.onlineResource=onlineResource
Note: See TracBrowser for help on using the repository browser.