@@ -89,23 +89,44 @@ class SwisstopoHarvester(OGDCHHarvesterBase):
89
89
]
90
90
91
91
LICENSE = {
92
- u'de' : (
93
- u'Lizenz für kostenlose Geodaten' ,
94
- 'http://www.toposhop.admin.ch/de/shop/terms/use/finished_products'
95
- ),
96
- u'fr' : (
97
- u'Licence pour les géodonnées gratuites' ,
98
- 'http://www.toposhop.admin.ch/fr/shop/terms/use/finished_products'
99
- ),
100
- u'it' : (
101
- u'Licenza per i geodati gratuiti' ,
102
- 'http://www.toposhop.admin.ch/it/shop/terms/use/finished_products'
103
- ),
104
- u'en' : (
105
- u'Licence for free geodata' ,
106
- 'http://www.toposhop.admin.ch/en/shop/terms/use/finished_products'
107
- ),
92
+ 'swisstopo' : {
93
+ u'de' : (
94
+ u'Lizenz für kostenlose Geodaten' ,
95
+ 'http://www.toposhop.admin.ch/de/shop/terms/use/finished_products' # noqa
96
+ ),
97
+ u'fr' : (
98
+ u'Licence pour les géodonnées gratuites' ,
99
+ 'http://www.toposhop.admin.ch/fr/shop/terms/use/finished_products' # noqa
100
+ ),
101
+ u'it' : (
102
+ u'Licenza per i geodati gratuiti' ,
103
+ 'http://www.toposhop.admin.ch/it/shop/terms/use/finished_products' # noqa
104
+ ),
105
+ u'en' : (
106
+ u'Licence for free geodata' ,
107
+ 'http://www.toposhop.admin.ch/en/shop/terms/use/finished_products' # noqa
108
+ ),
109
+ },
110
+ 'bafu' : {
111
+ u'de' : (
112
+ u'Lizenz- und Nutzungsbedingungen BAFU' ,
113
+ 'http://www.geo.admin.ch/internet/geoportal/de/home/geoadmin/contact.parsys.39177.DownloadFile.tmp/lizenznutzungsbedingungend070920.pdf' # noqa
114
+ ),
115
+ u'fr' : (
116
+ u'Conditions d\' utilisation et d\' octroi de licence OFEV' ,
117
+ 'http://www.geo.admin.ch/internet/geoportal/fr/home/geoadmin/contact.parsys.99124.DownloadFile.tmp/lizenznutzungsbedingungenf070920.pdf' # noqa
118
+ ),
119
+ u'it' : (
120
+ u'Condizioni di licenza e di utilizzo UFAM' ,
121
+ 'http://www.geo.admin.ch/internet/geoportal/it/home/geoadmin/contact.parsys.32848.DownloadFile.tmp/lizenzbedingungen070920it.pdf' # noqa
122
+ ),
123
+ u'en' : (
124
+ u'Lizenz- und Nutzungsbedingungen BAFU (german)' ,
125
+ 'http://www.geo.admin.ch/internet/geoportal/de/home/geoadmin/contact.parsys.39177.DownloadFile.tmp/lizenznutzungsbedingungend070920.pdf' # noqa
126
+ ),
127
+ }
108
128
}
129
+
109
130
ORGANIZATION = {
110
131
'swisstopo' : {
111
132
'de' : {
@@ -125,7 +146,8 @@ class SwisstopoHarvester(OGDCHHarvesterBase):
125
146
u'pour les informations géographiques, c\' est-à-dire pour '
126
147
u'la description, la représentation et l’archivage de '
127
148
u'données à référence spatiale.'
128
- )
149
+ ),
150
+ 'website' : u'http://www.swisstopo.admin.ch/'
129
151
},
130
152
'it' : {
131
153
'name' : u'Ufficio federale di topografia swisstopo' ,
@@ -134,7 +156,8 @@ class SwisstopoHarvester(OGDCHHarvesterBase):
134
156
u'per geoinformazione, cioè per la descrizione, '
135
157
u'rappresentazione e archiviazione dei dati '
136
158
u'georeferenziati (geodati).'
137
- )
159
+ ),
160
+ 'website' : u'http://www.swisstopo.admin.ch/'
138
161
},
139
162
'en' : {
140
163
'name' : u'Federal Office of Topography swisstopo' ,
@@ -143,7 +166,8 @@ class SwisstopoHarvester(OGDCHHarvesterBase):
143
166
u'responsible for geographical reference data, for '
144
167
u'instance the description, representation and archiving '
145
168
u'of geographic spatial data.'
146
- )
169
+ ),
170
+ 'website' : u'http://www.swisstopo.admin.ch/'
147
171
}
148
172
},
149
173
'bafu' : {
@@ -166,7 +190,8 @@ class SwisstopoHarvester(OGDCHHarvesterBase):
166
190
u'du développement durable et de protéger l’homme '
167
191
u'contre les dangers naturels et l’environnement '
168
192
u'contre les pollutions.'
169
- )
193
+ ),
194
+ 'website' : u'www.bafu.admin.ch/etat'
170
195
},
171
196
'it' : {
172
197
'name' : u'Ufficio federale dell\' ambiente' ,
@@ -176,7 +201,8 @@ class SwisstopoHarvester(OGDCHHarvesterBase):
176
201
u'sostenibile delle risorse naturali, la protezione delle '
177
202
u'persone dai pericoli naturali e dell\' ambiente da un '
178
203
u'inquinamento eccessivo.'
179
- )
204
+ ),
205
+ 'website' : u'www.bafu.admin.ch/stato'
180
206
},
181
207
'en' : {
182
208
'name' : u'Federal Office for the Environment' ,
@@ -186,7 +212,8 @@ class SwisstopoHarvester(OGDCHHarvesterBase):
186
212
u'sustainably, that the public is protected against '
187
213
u'natural hazards, and that the environment is protected '
188
214
u'from unacceptable adverse impacts.'
189
- )
215
+ ),
216
+ 'website' : u'www.bafu.admin.ch/state'
190
217
}
191
218
}
192
219
}
@@ -252,8 +279,9 @@ def _gen_harvest_obj_for_files(self, harvest_job):
252
279
)
253
280
log .debug (metadata ['resources' ])
254
281
255
- metadata ['license_id' ] = self .LICENSE ['de' ][0 ]
256
- metadata ['license_url' ] = self .LICENSE ['de' ][1 ]
282
+ metadata ['license_id' ], metadata ['license_url' ] = (
283
+ self ._get_org_license (dataset_name )
284
+ )
257
285
258
286
metadata ['layer_name' ] = dataset_name
259
287
@@ -288,8 +316,9 @@ def _gen_harvest_obj_for_apis(self, harvest_job):
288
316
self ._generate_metadata_translations (metadata_dict )
289
317
)
290
318
291
- metadata ['license_id' ] = self .LICENSE ['de' ][0 ]
292
- metadata ['license_url' ] = self .LICENSE ['de' ][1 ]
319
+ metadata ['license_id' ], metadata ['license_url' ] = (
320
+ self ._get_org_license (layer )
321
+ )
293
322
294
323
metadata ['layer_name' ] = layer
295
324
@@ -402,11 +431,12 @@ def _find_or_create_groups(self, context):
402
431
group_ids .append (group ['id' ])
403
432
return group_ids
404
433
434
+ def _get_org_license (self , dataset_name ):
435
+ org = self ._find_owner (dataset_name )
436
+ return self .LICENSE [org ]['de' ][0 ], self .LICENSE [org ]['de' ][1 ]
437
+
405
438
def _find_or_create_organization (self , context , package_dict ):
406
- if re .match ('^ch\.bafu' , package_dict ['layer_name' ]):
407
- org = 'bafu'
408
- else :
409
- org = 'swisstopo'
439
+ org = self ._find_owner (package_dict ['layer_name' ])
410
440
try :
411
441
name = self .ORGANIZATION [org ]['de' ]['name' ]
412
442
data_dict = {
@@ -427,36 +457,50 @@ def _find_or_create_organization(self, context, package_dict):
427
457
org = get_action ('organization_create' )(context , data_dict )
428
458
return org ['id' ]
429
459
460
+ def _find_owner (self , dataset_name ):
461
+ if re .match ('^ch\.bafu' , dataset_name ):
462
+ org = 'bafu'
463
+ else :
464
+ org = 'swisstopo'
465
+ return org
466
+
430
467
def _generate_term_translations (self ):
431
468
'''
432
469
Generate term translatations for groups, organizations and metadata
433
470
'''
434
471
try :
435
472
translations = []
436
473
437
- for lang , lic in self .LICENSE .items ():
438
- if lang != u'de' :
439
- translations .append ({
440
- 'lang_code' : lang ,
441
- 'term' : self .LICENSE [u'de' ][0 ],
442
- 'term_translation' : lic [0 ]
443
- })
444
- translations .append ({
445
- 'lang_code' : lang ,
446
- 'term' : self .LICENSE [u'de' ][1 ],
447
- 'term_translation' : lic [1 ]
448
- })
474
+ for org_name , lic in self .LICENSE .items ():
475
+ for lang , lic_item in lic .items ():
476
+ if lang != u'de' :
477
+ id_value = self .LICENSE [org_name ][u'de' ][0 ]
478
+ url_value = self .LICENSE [org_name ][u'de' ][1 ]
479
+
480
+ if id_value != lic_item [0 ]:
481
+ translations .append ({
482
+ 'lang_code' : lang ,
483
+ 'term' : id_value ,
484
+ 'term_translation' : lic_item [0 ]
485
+ })
486
+ if url_value != lic_item [1 ]:
487
+ translations .append ({
488
+ 'lang_code' : lang ,
489
+ 'term' : url_value ,
490
+ 'term_translation' : lic_item [1 ]
491
+ })
449
492
450
493
for org_name , org in self .ORGANIZATION .items ():
451
494
for lang , org_item in org .items ():
452
495
if lang != 'de' :
453
- for field in ['name' , 'description' ]:
496
+ for field in ['name' , 'description' , 'website' ]:
454
497
value = self .ORGANIZATION [org_name ]['de' ][field ]
455
- translations .append ({
456
- 'lang_code' : lang ,
457
- 'term' : value ,
458
- 'term_translation' : org_item [field ]
459
- })
498
+ if value != org_item [field ]:
499
+ translations .append ({
500
+ 'lang_code' : lang ,
501
+ 'term' : value ,
502
+ 'term_translation' : org_item [field ]
503
+ })
460
504
461
505
for lang , groups in self .GROUPS .iteritems ():
462
506
if lang != u'de' :
0 commit comments