
- the common classes are needed for a more objected oriented style - fixed pep8 Change-Id: I1a5dbb510168002c4c537beece4961741aed1d93
49 lines
1.2 KiB
Python
49 lines
1.2 KiB
Python
import base64
|
|
import binascii
|
|
import ConfigParser
|
|
import io
|
|
|
|
__author__ = "Lisa Zangrando"
|
|
__email__ = "lisa.zangrando[AT]pd.infn.it"
|
|
__copyright__ = """Copyright (c) 2015 INFN - INDIGO-DataCloud
|
|
All Rights Reserved
|
|
|
|
Licensed under the Apache License, Version 2.0;
|
|
you may not use this file except in compliance with the
|
|
License. You may obtain a copy of the License at:
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing,
|
|
software distributed under the License is distributed on an
|
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
|
either express or implied.
|
|
See the License for the specific language governing
|
|
permissions and limitations under the License."""
|
|
|
|
|
|
def encodeBase64(s):
|
|
if not s:
|
|
return None
|
|
|
|
try:
|
|
return base64.encodestring(s)
|
|
except binascii.Error:
|
|
raise binascii.Error
|
|
|
|
|
|
def decodeBase64(s):
|
|
if not s:
|
|
return None
|
|
|
|
try:
|
|
return base64.decodestring(s)
|
|
except binascii.Error:
|
|
raise binascii.Error
|
|
|
|
|
|
def getConfigParameter(data, key, section="DEFAULT"):
|
|
config = ConfigParser.RawConfigParser(allow_no_value=True)
|
|
config.readfp(io.BytesIO(data))
|
|
return config.get(section, key)
|