BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
etsy-python
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
etsy-python
Commits
6afd47d2
Commit
6afd47d2
authored
May 31, 2010
by
Dan McKinley
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
replacing loop of string replaces for url creation with string format
parent
b5735e31
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
8 deletions
+11
-8
_core.py
etsy/_core.py
+11
-8
No files found.
etsy/_core.py
View file @
6afd47d2
...
...
@@ -85,7 +85,13 @@ class APIMethod(object):
def
compile
(
self
):
self
.
positionals
=
re
.
findall
(
'{(.*)}'
,
self
.
spec
[
'uri'
])
uri
=
self
.
spec
[
'uri'
]
self
.
positionals
=
re
.
findall
(
'{(.*)}'
,
uri
)
for
p
in
self
.
positionals
:
uri
=
uri
.
replace
(
'{
%
s}'
%
p
,
'
%%
(
%
s)s'
%
p
)
self
.
uri_format
=
uri
self
.
compiled
=
True
...
...
@@ -104,12 +110,15 @@ class APIMethod(object):
'Positional argument duplicated in kwargs:
%
s'
%
k
)
kwargs
[
k
]
=
v
ps
=
{}
for
p
in
self
.
positionals
:
if
p
not
in
kwargs
:
raise
ValueError
(
"Required argument '
%
s' not provided."
%
p
)
ps
[
p
]
=
kwargs
[
p
]
del
kwargs
[
p
]
self
.
type_checker
(
self
.
spec
,
**
kwargs
)
return
self
.
api
.
_get
(
self
.
spec
[
'uri'
]
,
**
kwargs
)
return
self
.
api
.
_get
(
self
.
uri_format
%
ps
,
**
kwargs
)
...
...
@@ -164,12 +173,6 @@ class API(object):
def
_get
(
self
,
url
,
**
kwargs
):
for
k
,
v
in
kwargs
.
items
():
arg
=
'{
%
s}'
%
k
if
arg
in
url
:
url
=
url
.
replace
(
arg
,
str
(
v
))
del
kwargs
[
k
]
kwargs
.
update
(
dict
(
api_key
=
self
.
api_key
))
qs
=
urlencode
(
kwargs
)
url
=
'
%
s
%
s?
%
s'
%
(
self
.
api_url
,
url
,
qs
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment