From: olivier <> Date: Wed, 1 Apr 2009 15:01:37 +0000 (+0000) Subject: move dublincore classes into models module X-Git-Tag: 1.1~717 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=f6474394fd45d0da50c883c73d405385be5c559e;p=telemeta.git move dublincore classes into models module --- diff --git a/telemeta/dublincore.py b/telemeta/dublincore.py deleted file mode 100644 index e3062d34..00000000 --- a/telemeta/dublincore.py +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright (C) 2007 Samalyse SARL -# All rights reserved. -# -# This software is licensed as described in the file COPYING, which -# you should have received as part of this distribution. The terms -# are also available at http://svn.parisson.org/telemeta/TelemetaLicense. -# -# Author: Olivier Guilyardi - -class Resource(object): - "Represent a Dublin Core resource" - - elements = [] - - def __init__(self, *args): - self.elements = args - - def flatten(self): - """Convert the resource to a dictionary with element names as keys. - - Warnings: - - refinements are lost during this conversion, - - if there are several occurences of the same element, only the first is - used, others are lost. - - all values are converted to strings - """ - result = {} - for element in self.elements: - if not result.has_key(element.name): - result[element.name] = unicode(element.value) - return result - -class Element(object): - "Represent a Dublin Core element" - - def __init__(self, name, field=None, value=None, refinement=None): - self.name = name - self.value = value - self.refinement = refinement - self.field = field - diff --git a/telemeta/models/dublincore.py b/telemeta/models/dublincore.py new file mode 100644 index 00000000..e3062d34 --- /dev/null +++ b/telemeta/models/dublincore.py @@ -0,0 +1,41 @@ +# Copyright (C) 2007 Samalyse SARL +# All rights reserved. +# +# This software is licensed as described in the file COPYING, which +# you should have received as part of this distribution. The terms +# are also available at http://svn.parisson.org/telemeta/TelemetaLicense. +# +# Author: Olivier Guilyardi + +class Resource(object): + "Represent a Dublin Core resource" + + elements = [] + + def __init__(self, *args): + self.elements = args + + def flatten(self): + """Convert the resource to a dictionary with element names as keys. + + Warnings: + - refinements are lost during this conversion, + - if there are several occurences of the same element, only the first is + used, others are lost. + - all values are converted to strings + """ + result = {} + for element in self.elements: + if not result.has_key(element.name): + result[element.name] = unicode(element.value) + return result + +class Element(object): + "Represent a Dublin Core element" + + def __init__(self, name, field=None, value=None, refinement=None): + self.name = name + self.value = value + self.refinement = refinement + self.field = field + diff --git a/telemeta/models/media.py b/telemeta/models/media.py index cecf20c2..fd4f7cfa 100644 --- a/telemeta/models/media.py +++ b/telemeta/models/media.py @@ -16,7 +16,7 @@ import re import telemeta from telemeta.core import * -from telemeta import dublincore as dc +from telemeta.models import dublincore as dc from telemeta.models.query import MediaItemManager, MediaItemQuerySet, \ MediaCollectionManager, MediaCollectionQuerySet