cremcrem2devdiademsformagenericinstru_searchlamnlivemultiproductionrelease/1.4.4securitysocialstoragetestvideo
|
Last change
on this file since a406471 was
a406471,
checked in by olivier <>, 6 years ago
|
|
convert DC elements values to strings
|
-
Property mode set to
100644
|
|
File size:
1.2 KB
|
| Line | |
|---|
| 1 | # Copyright (C) 2007 Samalyse SARL |
|---|
| 2 | # All rights reserved. |
|---|
| 3 | # |
|---|
| 4 | # This software is licensed as described in the file COPYING, which |
|---|
| 5 | # you should have received as part of this distribution. The terms |
|---|
| 6 | # are also available at http://svn.parisson.org/telemeta/TelemetaLicense. |
|---|
| 7 | # |
|---|
| 8 | # Author: Olivier Guilyardi <olivier@samalyse.com> |
|---|
| 9 | |
|---|
| 10 | class Resource(object): |
|---|
| 11 | "Represent a Dublin Core resource" |
|---|
| 12 | |
|---|
| 13 | elements = [] |
|---|
| 14 | |
|---|
| 15 | def __init__(self, *args): |
|---|
| 16 | self.elements = args |
|---|
| 17 | |
|---|
| 18 | def flatten(self): |
|---|
| 19 | """Convert the resource to a dictionary with element names as keys. |
|---|
| 20 | |
|---|
| 21 | Warnings: |
|---|
| 22 | - refinements are lost during this conversion, |
|---|
| 23 | - if there are several occurences of the same element, only the first is |
|---|
| 24 | used, others are lost. |
|---|
| 25 | - all values are converted to strings |
|---|
| 26 | """ |
|---|
| 27 | result = {} |
|---|
| 28 | for element in self.elements: |
|---|
| 29 | if not result.has_key(element.name): |
|---|
| 30 | result[element.name] = str(element.value) |
|---|
| 31 | return result |
|---|
| 32 | |
|---|
| 33 | class Element(object): |
|---|
| 34 | "Represent a Dublin Core element" |
|---|
| 35 | |
|---|
| 36 | def __init__(self, name, field=None, value=None, refinement=None): |
|---|
| 37 | self.name = name |
|---|
| 38 | self.value = value |
|---|
| 39 | self.refinement = refinement |
|---|
| 40 | self.field = field |
|---|
| 41 | |
|---|
Note: See
TracBrowser
for help on using the repository browser.