rdf.py 10.5 KB
Newer Older
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
#!/usr/bin/env ${PYTHON}
# -*- mode: python py-indent-offset: 2; -*-
#
# www.gimp.org website administration and tools
#
# Copyright (C) 2002, 2003 Helvetix Victorinox, a pseudonym,
# Mountain View, California
# 
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program 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
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA

import types
import string
import sys
import os
import cgi
30 31
import pprint
import inspect
32

33
sys.path = ['${LIBDIR}'] + sys.path
34

35
import x_xml
36

Helvetix Victorinox's avatar
Helvetix Victorinox committed
37 38 39 40 41 42
def quote(s):
  s = string.replace(s, "&", "&")
  s = string.replace(s, "<", "&lt;")
  s = string.replace(s, ">", "&gt;")
  return (s)
  
43
# Namespaces should appear to be imported into Python as well.
Helvetix Victorinox's avatar
Helvetix Victorinox committed
44
# Otherwise, I have to write all these silly wrappers. XXX
45 46

class RDF(x_xml.Xml):
47
  defaults = {
Helvetix Victorinox's avatar
Helvetix Victorinox committed
48 49 50 51
    "xmlns"       : "http://purl.org/rss/1.0/",
    "xmlns:dc"    : "http://purl.org/dc/elements/1.1/",
    "xmlns:rdf"   : "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
    
52
    "xmlns:admin" : "http://webns.net/mvcb/",
Helvetix Victorinox's avatar
Helvetix Victorinox committed
53 54 55
    "xmlns:syn"   : "http://purl.org/rss/1.0/modules/syndication/",
    "xmlns:taxo"  : "http://purl.org/rss/1.0/modules/taxonomy/",
    "xmlns:gimp"  : "http://www.gimp.org/RDF/v0.1"
56
    }
57 58
  tag = "rdf:RDF"

59
  class init(x_xml.xml_init):
60
    def __init__(self, attrs={}):
61
      return (x_xml.xml_init.__init__(self, RDF, attrs))
62
    pass
63

64
  class fini(x_xml.xml_fini):
65
    def __init__(self):
66
      return (x_xml.xml_fini.__init__(self, RDF))
67
    pass
68
  pass
69

70
class rss(x_xml.Xml):
71
  defaults = { }
72 73 74 75 76 77 78 79 80 81 82 83 84
  tag = "rss"

  class init(x_xml.xml_init):
    def __init__(self, attrs={}):
      return (x_xml.xml_init.__init__(self, rss, attrs))
    pass

  class fini(x_xml.xml_fini):
    def __init__(self):
      return (x_xml.xml_fini.__init__(self, rss))
    pass
  pass

85
class content(x_xml.Xml):
86 87 88
  defaults = { }
  tag = "content"

89
  class init(x_xml.xml_init):
90
    def __init__(self, attrs={}):
91
      return (x_xml.xml_init.__init__(self, content, attrs))
92 93
    pass

94
  class fini(x_xml.xml_fini):
95
    def __init__(self):
96
      return (x_xml.xml_fini.__init__(self, content))
97 98 99 100
    pass
  pass


101
class link(x_xml.Xml):
102 103 104
  defaults = { }
  tag = "link"

105
  class init(x_xml.xml_init):
106
    def __init__(self, attrs={}):
107
      return (x_xml.xml_init.__init__(self, link, attrs))
108 109
    pass

110
  class fini(x_xml.xml_fini):
111
    def __init__(self):
112
      return (x_xml.xml_fini.__init__(self, link))
113
    pass
114 115 116
  
  pass

117

118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
class pubDate(x_xml.Xml):
  defaults = { }
  tag = "pubDate"

  class init(x_xml.xml_init):
    def __init__(self, attrs={}):
      return (x_xml.xml_init.__init__(self, pubDate, attrs))
    pass

  class fini(x_xml.xml_fini):
    def __init__(self):
      return (x_xml.xml_fini.__init__(self, pubDate))
    pass
  
  pass


135
class channel(x_xml.Xml):
136
  tag = "channel"
137
  defaults = { }
138 139 140 141 142 143 144 145 146 147 148 149 150

  class init(x_xml.xml_init):
    def __init__(self, attrs={}):
      return (x_xml.xml_init.__init__(self, channel, attrs))
    pass

  class fini(x_xml.xml_fini):
    def __init__(self):
      return (x_xml.xml_fini.__init__(self, channel))
    pass
  
  pass

151
class title(x_xml.Xml):
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
  defaults = { }
  tag = "title"

  class init(x_xml.xml_init):
    def __init__(self, attrs={}):
      return (x_xml.xml_init.__init__(self, title, attrs))
    pass

  class fini(x_xml.xml_fini):
    def __init__(self):
      return (x_xml.xml_fini.__init__(self, title))
    pass
  
  pass

167
class description(x_xml.Xml):
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
  defaults = { }
  tag = "description"

  class init(x_xml.xml_init):
    def __init__(self, attrs={}):
      return (x_xml.xml_init.__init__(self, description, attrs))
    pass

  class fini(x_xml.xml_fini):
    def __init__(self):
      return (x_xml.xml_fini.__init__(self, description))
    pass
  
  pass

183
class item(x_xml.Xml):
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
  defaults = { }
  tag = "item"

  class init(x_xml.xml_init):
    def __init__(self, attrs={}):
      return (x_xml.xml_init.__init__(self, item, attrs))
    pass

  class fini(x_xml.xml_fini):
    def __init__(self):
      return (x_xml.xml_fini.__init__(self, item))
    pass
  
  pass

Helvetix Victorinox's avatar
Helvetix Victorinox committed
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241
class items(x_xml.Xml):
  defaults = { }
  tag = "items"

  class init(x_xml.xml_init):
    def __init__(self, attrs={}):
      return (x_xml.xml_init.__init__(self, item, attrs))
    pass

  class fini(x_xml.xml_fini):
    def __init__(self):
      return (x_xml.xml_fini.__init__(self, item))
    pass
  
  pass

class li(x_xml.Xml):
  defaults = { }
  tag = "rdf:li"

  class init(x_xml.xml_init):
    def __init__(self, attrs={}):
      return (x_xml.xml_init.__init__(self, item, attrs))
    pass

  pass

class seq(x_xml.Xml):
  defaults = { }
  tag = "rdf:Seq"

  class init(x_xml.xml_init):
    def __init__(self, attrs={}):
      return (x_xml.xml_init.__init__(self, item, attrs))
    pass

  class fini(x_xml.xml_fini):
    def __init__(self):
      return (x_xml.xml_fini.__init__(self, item))
    pass
  
  pass

242 243
# Dublin Core Metadata Element Set
# http://web.resource.org/rss/1.0/modules/dc/
244 245 246
#
# Again, namespaces should be imported (somehow) so they appear
# without all writting all the wrappers by hand.
247

248
class dc_title(x_xml.Xml):
249 250 251 252 253
  defaults = { }
  tag = "dc:title"

  class init(x_xml.xml_init):
    def __init__(self, attrs={}):
254
      return (x_xml.xml_init.__init__(self, dc_title, attrs))
255 256 257 258
    pass

  class fini(x_xml.xml_fini):
    def __init__(self):
259
      return (x_xml.xml_fini.__init__(self, dc_title))
260 261 262 263
    pass
  
  pass

264
class dc_creator(x_xml.Xml):
265 266 267 268 269
  defaults = { }
  tag = "dc:creator"

  class init(x_xml.xml_init):
    def __init__(self, attrs={}):
270
      return (x_xml.xml_init.__init__(self, dc_creator, attrs))
271 272 273 274
    pass

  class fini(x_xml.xml_fini):
    def __init__(self):
275
      return (x_xml.xml_fini.__init__(self, dc_creator))
276 277 278 279
    pass
  
  pass

280
class dc_subject(x_xml.Xml):
281 282 283 284 285
  defaults = { }
  tag = "dc:subject"

  class init(x_xml.xml_init):
    def __init__(self, attrs={}):
286
      return (x_xml.xml_init.__init__(self, dc_subject, attrs))
287 288 289 290
    pass

  class fini(x_xml.xml_fini):
    def __init__(self):
291
      return (x_xml.xml_fini.__init__(self, dc_subject))
292 293 294 295
    pass
  
  pass

296
class dc_description(x_xml.Xml):
297 298 299 300 301
  defaults = { }
  tag = "dc:description"

  class init(x_xml.xml_init):
    def __init__(self, attrs={}):
302
      return (x_xml.xml_init.__init__(self, dc_description, attrs))
303 304 305 306
    pass

  class fini(x_xml.xml_fini):
    def __init__(self):
307
      return (x_xml.xml_fini.__init__(self, dc_description))
308 309 310 311 312
    pass
  
  pass


313
class dc_publisher(x_xml.Xml):
314 315 316 317 318
  defaults = { }
  tag = "dc:publisher"

  class init(x_xml.xml_init):
    def __init__(self, attrs={}):
319
      return (x_xml.xml_init.__init__(self, dc_publisher, attrs))
320 321 322 323
    pass

  class fini(x_xml.xml_fini):
    def __init__(self):
324
      return (x_xml.xml_fini.__init__(self, dc_publisher))
325 326 327 328
    pass
  
  pass

329
class dc_contributor(x_xml.Xml):
330 331 332 333 334
  defaults = { }
  tag = "dc:contributor"

  class init(x_xml.xml_init):
    def __init__(self, attrs={}):
335
      return (x_xml.xml_init.__init__(self, dc_contributor, attrs))
336 337 338 339
    pass

  class fini(x_xml.xml_fini):
    def __init__(self):
340
      return (x_xml.xml_fini.__init__(self, dc_contributor))
341 342 343 344
    pass
  
  pass

345
class dc_date(x_xml.Xml):
346 347 348
  defaults = { }
  tag = "dc:date"

349
  class init(x_xml.xml_init):
350
    def __init__(self, attrs={}):
351
      return (x_xml.xml_init.__init__(self, dc_date, attrs))
352 353
    pass

354
  class fini(x_xml.xml_fini):
355
    def __init__(self):
356
      return (x_xml.xml_fini.__init__(self, dc_date))
357 358
    pass
  
359 360
  pass

361
class dc_type(x_xml.Xml):
362
  defaults = { }
363
  tag = "dc:type"
364

365
  class init(x_xml.xml_init):
366
    def __init__(self, attrs={}):
367
      return (x_xml.xml_init.__init__(self, dc_type, attrs))
368
    pass
369

370
  class fini(x_xml.xml_fini):
371
    def __init__(self):
372
      return (x_xml.xml_fini.__init__(self, dc_type))
373 374 375
    pass
  
  pass
376

377
class dc_format(x_xml.Xml):
378
  defaults = { }
379
  tag = "dc:format"
380

381
  class init(x_xml.xml_init):
382
    def __init__(self, attrs={}):
383
      return (x_xml.xml_init.__init__(self, dc_format, attrs))
384 385
    pass

386
  class fini(x_xml.xml_fini):
387
    def __init__(self):
388
      return (x_xml.xml_fini.__init__(self, dc_format))
389 390 391 392
    pass
  
  pass

393
class dc_identifier(x_xml.Xml):
394
  defaults = { }
395
  tag = "dc:identifier"
396

397
  class init(x_xml.xml_init):
398
    def __init__(self, attrs={}):
399
      return (x_xml.xml_init.__init__(self, dc_identifier, attrs))
400
    pass
401

402
  class fini(x_xml.xml_fini):
403
    def __init__(self):
404
      return (x_xml.xml_fini.__init__(self, dc_identifier))
405 406
    pass
  
407 408
  pass

409
class dc_source(x_xml.Xml):
410
  defaults = { }
411
  tag = "dc:source"
412

413
  class init(x_xml.xml_init):
414
    def __init__(self, attrs={}):
415
      return (x_xml.xml_init.__init__(self, dc_source, attrs))
416 417
    pass

418
  class fini(x_xml.xml_fini):
419
    def __init__(self):
420
      return (x_xml.xml_fini.__init__(self, dc_source))
421 422 423
    pass
  
  pass
424

425
class dc_language(x_xml.Xml):
426 427 428 429 430
  defaults = { }
  tag = "dc:language"

  class init(x_xml.xml_init):
    def __init__(self, attrs={}):
431
      return (x_xml.xml_init.__init__(self, dc_language, attrs))
432 433 434 435
    pass

  class fini(x_xml.xml_fini):
    def __init__(self):
436
      return (x_xml.xml_fini.__init__(self, dc_language))
437 438 439 440
    pass
  
  pass

441
class dc_relation(x_xml.Xml):
442 443 444 445 446
  defaults = { }
  tag = "dc:relation"

  class init(x_xml.xml_init):
    def __init__(self, attrs={}):
447
      return (x_xml.xml_init.__init__(self, dc_relation, attrs))
448 449 450 451
    pass

  class fini(x_xml.xml_fini):
    def __init__(self):
452
      return (x_xml.xml_fini.__init__(self, dc_relation))
453 454 455 456
    pass
  
  pass

457
class dc_coverage(x_xml.Xml):
458 459 460 461 462
  defaults = { }
  tag = "dc:coverage"

  class init(x_xml.xml_init):
    def __init__(self, attrs={}):
463
      return (x_xml.xml_init.__init__(self, dc_coverage, attrs))
464 465 466 467
    pass

  class fini(x_xml.xml_fini):
    def __init__(self):
468
      return (x_xml.xml_fini.__init__(self, dc_coverage))
469 470 471 472
    pass
  
  pass

473
class dc_rights(x_xml.Xml):
474 475 476 477 478
  defaults = { }
  tag = "dc:rights"

  class init(x_xml.xml_init):
    def __init__(self, attrs={}):
479
      return (x_xml.xml_init.__init__(self, dc_rights, attrs))
480 481 482 483
    pass

  class fini(x_xml.xml_fini):
    def __init__(self):
484
      return (x_xml.xml_fini.__init__(self, dc_rights))
485 486 487
    pass
  
  pass