1
# Copyright (c) 2010-2011 OpenStack, LLC.
3
# Licensed under the Apache License, Version 2.0 (the "License");
4
# you may not use this file except in compliance with the License.
5
# You may obtain a copy of the License at
7
# http://www.apache.org/licenses/LICENSE-2.0
9
# Unless required by applicable law or agreed to in writing, software
10
# distributed under the License is distributed on an "AS IS" BASIS,
11
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13
# See the License for the specific language governing permissions and
14
# limitations under the License.
15
from lxml import etree
21
def __init__(self, rel, href, link_type=None, hreflang=None, title=None):
24
self.link_type = link_type
25
self.hreflang = hreflang
31
links["link_type"] = self.link_type
33
links["hreflang"] = self.hreflang
35
links["title"] = self.title
37
links["rel"] = self.rel
38
links["href"] = self.href
39
return {'links': links}
42
ATOM_NAMESPACE = "http://www.w3.org/2005/Atom"
43
ATOM = "{%s}" % ATOM_NAMESPACE
44
NSMAP = {'atom': ATOM_NAMESPACE}
45
dom = etree.Element(ATOM + "link", nsmap=NSMAP)
47
dom.set("link_type", self.link_type)
49
dom.set("hreflang", self.hreflang)
51
dom.set("title", self.title)
52
dom.set("rel", self.rel)
53
dom.set("href", self.href)