diff options
author | Sebastien Estienne <sebastien.estienne@gmail.com> | 2005-11-19 00:33:52 +0000 |
---|---|---|
committer | Sebastien Estienne <sebastien.estienne@gmail.com> | 2005-11-19 00:33:52 +0000 |
commit | 5ce17adcb1ff31ffdc2618fcf4788beecc1e1ff8 (patch) | |
tree | 0039768e4f21777c78e1f893c51d5253ed72153a /src/modules/pluginutils.py | |
parent | d8bc0dbb720eefc1d7189c99ae8045524952eb46 (diff) |
* added a the begining of a proper plugin architecture
git-svn-id: file:///home/lennart/svn/public/service-discovery-applet/trunk@80 3be567f1-68ff-0310-b24a-ad7cc433fd2f
Diffstat (limited to 'src/modules/pluginutils.py')
-rw-r--r-- | src/modules/pluginutils.py | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/modules/pluginutils.py b/src/modules/pluginutils.py new file mode 100644 index 0000000..61f1a3d --- /dev/null +++ b/src/modules/pluginutils.py @@ -0,0 +1,49 @@ +# -*- coding: UTF-8 -*- +# -*- python -*- +# Copyright (C) 2005 by Sebastien Estienne +# +# This file may be distributed and/or modified under the terms of +# the GNU General Public License version 2 as published by +# the Free Software Foundation. +# This file is distributed without any warranty; without even the implied +# warranty of merchantability or fitness for a particular purpose. +# See "COPYING" in the source distribution for more information. +# +# $id$ +# + +def pair_to_dict(l): + res = dict() + for el in l: + if "=" not in el: + res[el]='' + else: + tmp = el.split('=',1) + if len(tmp[0]) > 0: + res[tmp[0]] = tmp[1] + return res + + +def build_url(uri = "http", hostname="127.0.0.1", port = None, path = None, username = None, password = None): + if path and path != None: + if path[0] == "/": + path = path[1:] + else: + path = "" + + if username: + if password: + username="%s:%s@" % (username,password) + else: + username="%s@" % (username) + else: + username="" + if port and port != None: + hostname="%s:%i" % (hostname,port) + return "%s://%s%s/%s" % (uri,username,hostname,path) + +def get_txt_value(txts, txt): + if txts.has_key(txt): + return txts[txt] + else: + return None |