Khen Nursimulu | 3869d8d | 2016-11-28 20:44:28 -0500 | [diff] [blame^] | 1 | # -*- coding: utf-8 -*-# |
| 2 | # |
| 3 | # December 23 2014, Christian Hopps <chopps@gmail.com> |
| 4 | # |
| 5 | # Copyright (c) 2015, Deutsche Telekom AG |
| 6 | # |
| 7 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | # you may not use this file except in compliance with the License. |
| 9 | # You may obtain a copy of the License at |
| 10 | # |
| 11 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | # |
| 13 | # Unless required by applicable law or agreed to in writing, software |
| 14 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | # See the License for the specific language governing permissions and |
| 17 | # limitations under the License. |
| 18 | # |
| 19 | from __future__ import absolute_import, division, unicode_literals, print_function, nested_scopes |
| 20 | from lxml.etree import register_namespace |
| 21 | |
| 22 | MAXSSHBUF = 16 * 1024 |
| 23 | NSMAP = { } |
| 24 | |
| 25 | |
| 26 | def nsmap_add (prefix, namespace): |
| 27 | "Add a prefix namespace mapping to the modules mapping dictionary" |
| 28 | NSMAP[prefix] = namespace |
| 29 | register_namespace(prefix, namespace) |
| 30 | |
| 31 | |
| 32 | def nsmap_update (nsdict): |
| 33 | "Add a dicitonary of prefx namespace mappings to the modules mapping dictionary" |
| 34 | NSMAP.update(nsdict) |
| 35 | for key, val in nsdict.items(): |
| 36 | register_namespace(key, val) |
| 37 | |
| 38 | |
| 39 | def qmap (key): |
| 40 | return "{" + NSMAP[key] + "}" |
| 41 | |
| 42 | |
| 43 | # Add base spec namespace |
| 44 | nsmap_add('nc', "urn:ietf:params:xml:ns:netconf:base:1.0") |