comparison frontends/src/tools/strings.py @ 719:56aa0e98c92e

frontends tools: moved src/tools/frontends to frontends/src/tools
author souliane <souliane@mailoo.org>
date Thu, 21 Nov 2013 18:57:10 +0100
parents src/tools/frontends/strings.py@d8e7a58eaa00
children 8b6137f7b4e1
comparison
equal deleted inserted replaced
718:074970227bc0 719:56aa0e98c92e
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3
4 # SAT helpers methods for plugins
5 # Copyright (C) 2013 Adrien Cossa (souliane@mailoo.org)
6
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU Affero General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
11
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU Affero General Public License for more details.
16
17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
20
21 def getURLParams(url):
22 """This comes from pyjamas.Location.makeUrlDict with a small change
23 to also parse full URLs, and parameters with no value specified
24 (in that case the default value "" is used).
25 @param url: any URL with or without parameters
26 @return: a dictionary of the parameters, if any was given, or {}
27 """
28 dict_ = {}
29 if "/" in url:
30 # keep the part after the last "/"
31 url = url[url.rindex("/") + 1:]
32 if url.startswith("?"):
33 # remove the first "?"
34 url = url[1:]
35 pairs = url.split("&")
36 for pair in pairs:
37 if len(pair) < 3:
38 continue
39 kv = pair.split("=", 1)
40 dict_[kv[0]] = kv[1] if len(kv) > 1 else ""
41 return dict_
42