FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
querystring-parser/querystring_parser/builder.py at master · Affirm/querystring-parser · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
Affirm
/
querystring-parser
Public
forked from
bernii/querystring-parser
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
querystring-parser
/
querystring_parser
/
builder.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
45 lines (41 loc) · 1.09 KB
Breadcrumbs
querystring-parser
/
querystring_parser
/
builder.py
Copy path
File metadata and controls
45 lines (41 loc) · 1.09 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# coding: utf-8
'''
Created on 2012-03-28
@author: Tomasz 'Doppler' Najdek
Updated 2012-04-01 Bernard 'berni' Kobos
'''
import
urllib
import
types
def
build
(
item
,
encoding
=
None
):
def
recursion
(
item
,
base
=
None
):
pairs
=
list
()
if
(
hasattr
(
item
,
'values'
)):
for
key
,
value
in
item
.
items
():
if
encoding
:
quoted_key
=
urllib
.
quote
(
unicode
(
key
).
encode
(
encoding
))
else
:
quoted_key
=
urllib
.
quote
(
unicode
(
key
))
if
(
base
):
new_base
=
"%s[%s]"
%
(
base
,
quoted_key
)
pairs
+=
recursion
(
value
,
new_base
)
else
:
new_base
=
quoted_key
pairs
+=
recursion
(
value
,
new_base
)
elif
(
isinstance
(
item
,
types
.
ListType
)):
for
(
index
,
value
)
in
enumerate
(
item
):
if
(
base
):
new_base
=
"%s"
%
(
base
)
pairs
+=
recursion
(
value
,
new_base
)
else
:
pairs
+=
recursion
(
value
)
else
:
if
encoding
:
quoted_item
=
urllib
.
quote
(
unicode
(
item
).
encode
(
encoding
))
else
:
quoted_item
=
urllib
.
quote
(
unicode
(
item
))
if
(
base
):
pairs
.
append
(
"%s=%s"
%
(
base
,
quoted_item
))
else
:
pairs
.
append
(
quoted_item
)
return
pairs
return
'&'
.
join
(
recursion
(
item
))
Back
|
FazBrowse Home
|
New Git URL