This repository has been archived by the owner on Apr 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
extension.py
1305 lines (944 loc) · 35 KB
/
extension.py
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"""$Id$"""
__author__ = "Sam Ruby <http://intertwingly.net>, Mark Pilgrim <http://diveintomark.org/> and Phil Ringnalda <http://philringnalda.com>"
__version__ = "$Revision$"
__copyright__ = "Copyright (c) 2002 Sam Ruby, Mark Pilgrim and Phil Ringnalda"
from validators import *
from logging import *
########################################################################
# Extensions that are valid everywhere #
########################################################################
class extension_everywhere:
def do_dc_title(self):
return text(), noduplicates()
def do_dc_description(self):
return text(), noduplicates()
def do_dc_publisher(self):
if "webMaster" in self.children:
self.log(DuplicateSemantics({"core":"webMaster", "ext":"dc:publisher"}))
return text() # duplicates allowed
def do_dc_contributor(self):
return text() # duplicates allowed
def do_dc_type(self):
return text(), noduplicates()
def do_dc_format(self):
return text(), noduplicates()
def do_dc_identifier(self):
return text()
def do_dc_source(self):
if "source" in self.children:
self.log(DuplicateItemSemantics({"core":"source", "ext":"dc:source"}))
return text(), noduplicates()
def do_dc_language(self):
if "language" in self.children:
self.log(DuplicateSemantics({"core":"language", "ext":"dc:language"}))
return iso639(), noduplicates()
def do_dc_relation(self):
return text(), # duplicates allowed
def do_dc_coverage(self):
return text(), # duplicates allowed
def do_dc_rights(self):
if "copyright" in self.children:
self.log(DuplicateSemantics({"core":"copyright", "ext":"dc:rights"}))
return nonhtml(), noduplicates()
def do_dcterms_alternative(self):
return text() #duplicates allowed
def do_dcterms_abstract(self):
return text(), noduplicates()
def do_dcterms_tableOfContents(self):
return rdfResourceURI(), noduplicates()
def do_dcterms_created(self):
return w3cdtf(), noduplicates()
def do_dcterms_valid(self):
return eater()
def do_dcterms_available(self):
return eater()
def do_dcterms_issued(self):
return w3cdtf(), noduplicates()
def do_dcterms_modified(self):
if "lastBuildDate" in self.children:
self.log(DuplicateSemantics({"core":"lastBuildDate", "ext":"dcterms:modified"}))
return w3cdtf(), noduplicates()
def do_dcterms_dateAccepted(self):
return text(), noduplicates()
def do_dcterms_dateCopyrighted(self):
return text(), noduplicates()
def do_dcterms_dateSubmitted(self):
return text(), noduplicates()
def do_dcterms_extent(self):
return positiveInteger(), nonblank(), noduplicates()
# def do_dcterms_medium(self):
# spec defines it as something that should never be used
# undefined element'll do for now
def do_dcterms_isVersionOf(self):
return rdfResourceURI() # duplicates allowed
def do_dcterms_hasVersion(self):
return rdfResourceURI() # duplicates allowed
def do_dcterms_isReplacedBy(self):
return rdfResourceURI() # duplicates allowed
def do_dcterms_replaces(self):
return rdfResourceURI() # duplicates allowed
def do_dcterms_isRequiredBy(self):
return rdfResourceURI() # duplicates allowed
def do_dcterms_requires(self):
return rdfResourceURI() # duplicates allowed
def do_dcterms_isPartOf(self):
return rdfResourceURI() # duplicates allowed
def do_dcterms_hasPart(self):
return rdfResourceURI() # duplicates allowed
def do_dcterms_isReferencedBy(self):
return rdfResourceURI() # duplicates allowed
def do_dcterms_references(self):
return rdfResourceURI() # duplicates allowed
def do_dcterms_isFormatOf(self):
return rdfResourceURI() # duplicates allowed
def do_dcterms_hasFormat(self):
return rdfResourceURI() # duplicates allowed
def do_dcterms_conformsTo(self):
return rdfResourceURI() # duplicates allowed
def do_dcterms_spatial(self):
return eater()
def do_dcterms_temporal(self):
return eater()
def do_dcterms_audience(self):
return text()
def do_dcterms_mediator(self):
return text(), noduplicates()
# added to DMCI, but no XML mapping has been defined
def do_dcterms_accessRights(self):
return eater()
def do_dcterms_accrualMethod(self):
return eater()
def do_dcterms_accrualPeriodicity(self):
return eater()
def do_dcterms_accrualPolicy(self):
return eater()
def do_dcterms_bibliographicCitation(self):
return eater()
def do_dcterms_educationLevel(self):
return eater()
def do_dcterms_instructionalMethod(self):
return eater()
def do_dcterms_license(self):
return eater()
def do_dcterms_provenance(self):
return eater()
def do_dcterms_rightsHolder(self):
return eater()
def do_rdf_RDF(self):
return eater()
def do_rdf_type(self):
return eater()
def do_rdf_Description(self):
return eater()
def do_rdfs_seeAlso(self):
return rdfResourceURI() # duplicates allowed
def do_geo_Point(self):
return geo_point()
def do_geo_lat(self):
return latitude()
def do_geo_long(self):
return longitude()
def do_geo_alt(self):
return decimal()
def do_geourl_latitude(self):
return latitude()
def do_geourl_longitude(self):
return longitude()
def do_georss_where(self):
return georss_where()
def do_georss_point(self):
return gml_pos()
def do_georss_line(self):
return gml_posList()
def do_georss_polygon(self):
return gml_posList()
def do_georss_featureTypeTag(self):
return text()
def do_georss_relationshipTag(self):
return text()
def do_georss_featureName(self):
return text()
def do_georss_elev(self):
return decimal()
def do_georss_floor(self):
return Integer()
def do_georss_radius(self):
return Float()
def do_icbm_latitude(self):
return latitude()
def do_icbm_longitude(self):
return longitude()
def do_opml_dateCreated(self):
return rfc822(), noduplicates()
def do_opml_dateModified(self):
return rfc822(), noduplicates()
def do_opml_ownerName(self):
return safeHtml(), noduplicates()
def do_opml_ownerEmail(self):
return email(), noduplicates()
def do_opml_ownerId(self):
return httpURL(), noduplicates()
########################################################################
# Extensions that are valid at either the channel or item levels #
########################################################################
from media import media_elements, media_content, media_group
class extension_channel_item(extension_everywhere, media_elements):
def do_taxo_topics(self):
return eater()
def do_l_link(self):
return l_link()
########################################################################
# Extensions that are valid at only at the item level #
########################################################################
class extension_item(extension_channel_item):
def do_annotate_reference(self):
return rdfResourceURI(), noduplicates()
def do_ag_source(self):
return text(), noduplicates()
def do_ag_sourceURL(self):
return rfc2396_full(), noduplicates()
def do_ag_timestamp(self):
return iso8601(), noduplicates()
def do_ev_startdate(self):
return unbounded_iso8601(), noduplicates()
def do_ev_enddate(self):
return unbounded_iso8601(), noduplicates()
def do_ev_location(self):
return eater()
def do_ev_organizer(self):
return eater()
def do_ev_type(self):
return text(), noduplicates()
def do_feedburner_awareness(self):
return rfc2396_full(), noduplicates()
def do_feedburner_origEnclosureLink(self):
return rfc2396_full(), noduplicates()
def do_feedburner_origLink(self):
return rfc2396_full(), noduplicates()
def do_foaf_maker(self):
return eater()
def do_foaf_primaryTopic(self):
return eater()
def do_slash_comments(self):
return nonNegativeInteger(), noduplicates()
def do_slash_section(self):
return text()
def do_slash_department(self):
return text()
def do_slash_hit_parade(self):
return commaSeparatedIntegers(), noduplicates()
def do_thr_children(self):
if self.getFeedType() != TYPE_RSS1:
self.log(UndefinedElement({'parent':self.name,"element":"thr:children"}))
return eater()
def do_thr_total(self):
return nonNegativeInteger(), noduplicates()
def do_thr_in_reply_to(self):
return in_reply_to()
def do_wfw_comment(self):
return rfc2396_full(), noduplicates()
def do_wfw_commentRss(self):
return rfc2396_full(), noduplicates()
def do_wfw_commentRSS(self):
self.log(CommentRSS({"parent":self.parent.name, "element":self.name}))
return rfc2396_full(), noduplicates()
def do_wiki_diff(self):
return text()
def do_wiki_history(self):
return text()
def do_wiki_importance(self):
return text()
def do_wiki_status(self):
return text()
def do_wiki_version(self):
return text()
def do_g_actor(self):
return nonhtml(), noduplicates()
def do_g_age(self):
return nonNegativeInteger(), noduplicates()
def do_g_agent(self):
return nonhtml(), noduplicates()
def do_g_area(self):
return nonhtml(), noduplicates() # intUnit
def do_g_apparel_type(self):
return nonhtml(), noduplicates()
def do_g_artist(self):
return nonhtml(), noduplicates()
def do_g_author(self):
return nonhtml(), noduplicates()
def do_g_bathrooms(self):
return nonNegativeInteger(), noduplicates()
def do_g_bedrooms(self):
return nonNegativeInteger(), noduplicates()
def do_g_brand(self):
return nonhtml(), noduplicates()
def do_g_calories(self):
return g_float(), noduplicates()
def do_g_cholesterol(self):
return g_float(), noduplicates()
def do_g_color(self):
return nonhtml(), noduplicates()
def do_g_cooking_time(self):
return g_float(), noduplicates()
def do_g_condition(self):
return nonhtml(), noduplicates()
def do_g_course(self):
return nonhtml(), noduplicates()
def do_g_course_date_range(self):
return g_dateTimeRange(), noduplicates()
def do_g_course_number(self):
return nonhtml(), noduplicates()
def do_g_course_times(self):
return nonhtml(), noduplicates()
def do_g_cuisine(self):
return nonhtml(), noduplicates()
def do_g_currency(self):
return iso4217(), noduplicates()
def do_g_delivery_notes(self):
return nonhtml(), noduplicates()
def do_g_delivery_radius(self):
return floatUnit(), noduplicates()
def do_g_education(self):
return nonhtml(), noduplicates()
def do_g_employer(self):
return nonhtml(), noduplicates()
def do_g_ethnicity(self):
return nonhtml(), noduplicates()
def do_g_event_date_range(self):
return g_dateTimeRange(), noduplicates()
def do_g_expiration_date(self):
return iso8601_date(), noduplicates()
def do_g_expiration_date_time(self):
return iso8601(), noduplicates()
def do_g_fiber(self):
return g_float(), noduplicates()
def do_g_from_location(self):
return g_locationType(), noduplicates()
def do_g_gender(self):
return g_genderEnumeration(), noduplicates()
def do_g_hoa_dues(self):
return g_float(), noduplicates()
def do_g_format(self):
return nonhtml(), noduplicates()
def do_g_id(self):
return nonhtml(), noduplicates()
def do_g_image_link(self):
return rfc2396_full(), maxten()
def do_g_immigration_status(self):
return nonhtml(), noduplicates()
def do_g_interested_in(self):
return nonhtml(), noduplicates()
def do_g_isbn(self):
return nonhtml(), noduplicates()
def do_g_job_function(self):
return nonhtml(), noduplicates()
def do_g_job_industry(self):
return nonhtml(), noduplicates()
def do_g_job_type(self):
return nonhtml(), noduplicates()
def do_g_label(self):
return g_labelType(), maxten()
def do_g_listing_type(self):
return truefalse(), noduplicates()
def do_g_location(self):
return g_full_locationType(), noduplicates()
def do_g_main_ingredient(self):
return nonhtml(), noduplicates()
def do_g_make(self):
return nonhtml(), noduplicates()
def do_g_manufacturer(self):
return nonhtml(), noduplicates()
def do_g_manufacturer_id(self):
return nonhtml(), noduplicates()
def do_g_marital_status(self):
return g_maritalStatusEnumeration(), noduplicates()
def do_g_meal_type(self):
return nonhtml(), noduplicates()
def do_g_megapixels(self):
return floatUnit(), noduplicates()
def do_g_memory(self):
return floatUnit(), noduplicates()
def do_g_mileage(self):
return g_intUnit(), noduplicates()
def do_g_model(self):
return nonhtml(), noduplicates()
def do_g_model_number(self):
return nonhtml(), noduplicates()
def do_g_name_of_item_being_reviewed(self):
return nonhtml(), noduplicates()
def do_g_news_source(self):
return nonhtml(), noduplicates()
def do_g_occupation(self):
return nonhtml(), noduplicates()
def do_g_payment_notes(self):
return nonhtml(), noduplicates()
def do_g_pages(self):
return positiveInteger(), nonblank(), noduplicates()
def do_g_payment_accepted(self):
return g_paymentMethodEnumeration()
def do_g_pickup(self):
return truefalse(), noduplicates()
def do_g_preparation_time(self):
return floatUnit(), noduplicates()
def do_g_price(self):
return floatUnit(), noduplicates()
def do_g_price_type(self):
return g_priceTypeEnumeration(), noduplicates()
def do_g_processor_speed(self):
return floatUnit(), noduplicates()
def do_g_product_type(self):
return nonhtml(), noduplicates()
def do_g_property_type(self):
return nonhtml(), noduplicates()
def do_g_protein(self):
return floatUnit(), noduplicates()
def do_g_publication_name(self):
return nonhtml(), noduplicates()
def do_g_publication_volume(self):
return nonhtml(), noduplicates()
def do_g_publish_date(self):
return iso8601_date(), noduplicates()
def do_g_quantity(self):
return nonNegativeInteger(), nonblank(), noduplicates()
def do_g_rating(self):
return g_ratingTypeEnumeration(), noduplicates()
def do_g_review_type(self):
return nonhtml(), noduplicates()
def do_g_reviewer_type(self):
return g_reviewerTypeEnumeration(), noduplicates()
def do_g_salary(self):
return g_float(), noduplicates()
def do_g_salary_type(self):
return g_salaryTypeEnumeration(), noduplicates()
def do_g_saturated_fat(self):
return g_float(), noduplicates()
def do_g_school_district(self):
return nonhtml(), noduplicates()
def do_g_service_type(self):
return nonhtml(), noduplicates()
def do_g_servings(self):
return g_float(), noduplicates()
def do_g_sexual_orientation(self):
return nonhtml(), noduplicates()
def do_g_size(self):
return nonhtml(), noduplicates() # TODO: expressed in either two or three dimensions.
def do_g_shipping(self):
return g_shipping(), noduplicates()
def do_g_sodium(self):
return g_float(), noduplicates()
def do_g_subject(self):
return nonhtml(), noduplicates()
def do_g_subject_area(self):
return nonhtml(), noduplicates()
def do_g_tax_percent(self):
return percentType(), noduplicates()
def do_g_tax_region(self):
return nonhtml(), noduplicates()
def do_g_to_location(self):
return g_locationType(), noduplicates()
def do_g_total_carbs(self):
return g_float(), noduplicates()
def do_g_total_fat(self):
return g_float(), noduplicates()
def do_g_travel_date_range(self):
return g_dateTimeRange(), noduplicates()
def do_g_university(self):
return nonhtml(), noduplicates()
def do_g_upc(self):
return nonhtml(), noduplicates()
def do_g_url_of_item_being_reviewed(self):
return rfc2396_full(), noduplicates()
def do_g_vehicle_type(self):
return nonhtml(), noduplicates()
def do_g_vin(self):
return nonhtml(), noduplicates()
def do_g_weight(self):
return floatUnit(), noduplicates()
def do_g_year(self):
return g_year(), noduplicates()
def do_media_group(self):
return media_group()
def do_media_content(self):
return media_content()
def do_sx_sync(self):
import sse
return sse.Sync()
def do_conversationsNetwork_introMilliseconds(self):
return nonNegativeInteger(), noduplicates()
def do_conversationsNetwork_image(self):
return httpURL(), noduplicates()
def do_conversationsNetwork_ratingAverage(self):
return Float(), noduplicates()
def do_conversationsNetwork_ratingCount(self):
return nonNegativeInteger(), noduplicates()
def do_conversationsNetwork_ratingIndividual(self):
return positiveInteger(), noduplicates()
def do_conversationsNetwork_ratingTimestamp(self):
return iso8601(), noduplicates()
class heisen_uri(rfc3987, rfc2396_full):
def validate(self):
if self.getFeedType() == TYPE_ATOM:
rfc3987.validate(self)
elif not rfc2396_full.rfc2396_re.match(self.value):
self.log(ContainsRelRef({'parent':self.parent.name}))
class feedFlare(nonhtml):
def getExpectedAttrNames(self):
return [(None,u'href'),(None,u'src')]
def prevalidate(self):
self.validate_required_attribute((None,'href'), heisen_uri)
self.validate_required_attribute((None,'src'), heisen_uri)
return text.prevalidate(self)
class feedInfo(validatorBase):
def getExpectedAttrNames(self):
return [(None,u'uri')]
def prevalidate(self):
self.validate_required_attribute((None,'uri'), rfc3987)
class xmlView(validatorBase):
def getExpectedAttrNames(self):
return [(None,u'href')]
def prevalidate(self):
self.validate_required_attribute((None,'href'), rfc2396_full)
class georss_where(validatorBase):
def do_gml_Point(self):
return gml_point()
def do_gml_LineString(self):
return gml_line()
def do_gml_Polygon(self):
return gml_polygon()
def do_gml_Envelope(self):
return gml_envelope()
class geo_srsName(validatorBase):
def getExpectedAttrNames(self):
return [(None, u'srsName')]
class gml_point(geo_srsName):
def do_gml_pos(self):
return gml_pos()
class geo_point(validatorBase):
def do_geo_lat(self):
return latitude()
def do_geo_long(self):
return longitude()
def validate(self):
if "geo_lat" not in self.children:
self.log(MissingElement({"parent":self.name.replace('_',':'), "element":"geo:lat"}))
if "geo_long" not in self.children:
self.log(MissingElement({"parent":self.name.replace('_',':'), "element":"geo:long"}))
class gml_pos(text):
def validate(self):
if not re.match('^[-+]?\d+\.?\d*[ ,][-+]?\d+\.?\d*$', self.value):
return self.log(InvalidCoord({'value':self.value}))
if self.value.find(',')>=0:
self.log(CoordComma({'value':self.value}))
class gml_line(geo_srsName):
def do_gml_posList(self):
return gml_posList()
class gml_posList(text):
def validate(self):
if self.value.find(',')>=0:
# ensure that commas are only used to separate lat and long
if not re.match('^[-+.0-9]+[, ][-+.0-9]( [-+.0-9]+[, ][-+.0-9])+$',
value.strip()):
return self.log(InvalidCoordList({'value':self.value}))
self.log(CoordComma({'value':self.value}))
self.value=self.value.replace(',',' ')
values = self.value.strip().split()
if len(values)<3 or len(values)%2 == 1:
return self.log(InvalidCoordList({'value':self.value}))
for value in values:
if not re.match('^[-+]?\d+\.?\d*$', value):
return self.log(InvalidCoordList({'value':value}))
class gml_polygon(geo_srsName):
def do_gml_exterior(self):
return gml_exterior()
class gml_exterior(validatorBase):
def do_gml_LinearRing(self):
return gml_linearRing()
class gml_linearRing(geo_srsName):
def do_gml_posList(self):
return gml_posList()
class gml_envelope(geo_srsName):
def do_gml_lowerCorner(self):
return gml_pos()
def do_gml_upperCorner(self):
return gml_pos()
class access_restriction(enumeration):
error = InvalidAccessRestrictionRel
valuelist = ["allow", "deny"]
def getExpectedAttrNames(self):
return [(None, u'relationship')]
def prevalidate(self):
self.children.append(True) # force warnings about "mixed" content
if not self.attrs.has_key((None,"relationship")):
self.log(MissingAttribute({"parent":self.parent.name, "element":self.name, "attr":"relationship"}))
else:
self.value=self.attrs.getValue((None,"relationship"))
########################################################################
# Extensions that are valid at only at the RSS 2.0 item level #
########################################################################
class extension_rss20_item(extension_item):
def do_trackback_ping(self):
return rfc2396_full(), noduplicates()
def do_trackback_about(self):
return rfc2396_full()
def do_dcterms_accessRights(self):
return eater()
def do_dcterms_accrualMethod(self):
return eater()
def do_dcterms_accrualPeriodicity(self):
return eater()
def do_dcterms_accrualPolicy(self):
return eater()
def do_dcterms_bibliographicCitation(self):
return eater()
def do_dcterms_educationLevel(self):
return eater()
def do_dcterms_instructionalMethod(self):
return eater()
def do_dcterms_license(self):
return eater()
def do_dcterms_provenance(self):
return eater()
def do_dcterms_rightsHolder(self):
return eater()
########################################################################
# Extensions that are valid at only at the RSS 1.0 item level #
########################################################################
class extension_rss10_item(extension_item):
def do_trackback_ping(self):
return rdfResourceURI(), noduplicates()
def do_trackback_about(self):
return rdfResourceURI()
def do_l_permalink(self):
return l_permalink()
class l_permalink(rdfResourceURI, MimeType):
lNS = u'http://purl.org/rss/1.0/modules/link/'
def getExpectedAttrNames(self):
return rdfResourceURI.getExpectedAttrNames(self) + [(self.lNS, u'type')]
def validate(self):
if (self.lNS, 'type') in self.attrs.getNames():
self.value=self.attrs.getValue((self.lNS, 'type'))
MimeType.validate(self)
return rdfResourceURI.validate(self)
class l_link(rdfResourceURI, MimeType):
lNS = u'http://purl.org/rss/1.0/modules/link/'
def getExpectedAttrNames(self):
return rdfResourceURI.getExpectedAttrNames(self) + [
(self.lNS, u'lang'), (self.lNS, u'rel'),
(self.lNS, u'type'), (self.lNS, u'title')
]
def prevalidate(self):
self.validate_optional_attribute((self.lNS,'lang'), iso639)
self.validate_required_attribute((self.lNS,'rel'), rfc2396_full)
self.validate_optional_attribute((self.lNS,'title'), nonhtml)
if self.attrs.has_key((self.lNS, "type")):
if self.attrs.getValue((self.lNS, "type")).find(':') < 0:
self.validate_optional_attribute((self.lNS,'type'), MimeType)
else:
self.validate_optional_attribute((self.lNS,'type'), rfc2396_full)
########################################################################
# Extensions that are valid at only at the Atom entry level #
########################################################################
class extension_entry(extension_item):
def do_dc_creator(self): # atom:creator
return text() # duplicates allowed
def do_dc_subject(self): # atom:category
return text() # duplicates allowed
def do_dc_date(self): # atom:published
return w3cdtf(), noduplicates()
def do_creativeCommons_license(self):
return rfc2396_full()
def do_trackback_ping(self):
return rfc2396_full(), noduplicates()
# XXX This should have duplicate semantics with link[@rel='related']
def do_trackback_about(self):
return rfc2396_full()
########################################################################
# Extensions that are valid at only at the channel level #
########################################################################
class extension_channel(extension_channel_item):
def do_admin_generatorAgent(self):
if "generator" in self.children:
self.log(DuplicateSemantics({"core":"generator", "ext":"admin:generatorAgent"}))
return admin_generatorAgent(), noduplicates()
def do_admin_errorReportsTo(self):
return admin_errorReportsTo(), noduplicates()
def do_blogChannel_blogRoll(self):
return rfc2396_full(), noduplicates()
def do_blogChannel_mySubscriptions(self):
return rfc2396_full(), noduplicates()
def do_blogChannel_blink(self):
return rfc2396_full(), noduplicates()
def do_blogChannel_changes(self):
return rfc2396_full(), noduplicates()
def do_sy_updatePeriod(self):
return sy_updatePeriod(), noduplicates()
def do_sy_updateFrequency(self):
return positiveInteger(), nonblank(), noduplicates()
def do_sy_updateBase(self):
return w3cdtf(), noduplicates()
def do_foaf_maker(self):
return eater()
def do_cp_server(self):
return rdfResourceURI()
def do_wiki_interwiki(self):
return text()
def do_thr_in_reply_to(self):
return in_reply_to()
def do_cf_listinfo(self):
from cf import listinfo
return listinfo()
def do_cf_treatAs(self):
from cf import treatAs
return treatAs()
def do_feedburner_awareness(self):
return rfc2396_full(), noduplicates()
def do_feedburner_browserFriendly(self):
return nonhtml(), noduplicates()
def do_feedburner_emailServiceId(self):
return noduplicates()
def do_feedburner_feedFlare(self):
return feedFlare()
def do_feedburner_info(self):
return feedInfo()