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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
/* -*- Mode: C; c-basic-offset: 4 -*-
*
* SoupURI.override: overrides for SoupURI
*/
%%
ignore-glob
soup_uri_set_*
%%
override-slot SoupURI.tp_str
static PyObject *
_wrap_soup_uri_tp_str (PyObject *self)
{
char *str;
PyObject *ret;
str = soup_uri_to_string (pyg_boxed_get (self, SoupURI), FALSE);
ret = PyString_FromString (str);
g_free (str);
return ret;
}
%%
override-slot SoupURI.tp_repr
static PyObject *
_wrap_soup_uri_tp_repr (PyObject *self)
{
SoupURI *uri = pyg_boxed_get (self, SoupURI);
char *str, *repr;
PyObject *ret;
str = soup_uri_to_string (uri, FALSE);
repr = g_strdup_printf ("<SoupURI '%s' at %p>", str, uri);
ret = PyString_FromString (repr);
g_free (repr);
g_free (str);
return ret;
}
%%
override-attr SoupURI.scheme
static int
_wrap_soup_uri__set_scheme (PyObject *self, PyObject *value, void *closure)
{
char *scheme = PyString_AsString (value);
if (!scheme)
return -1;
soup_uri_set_scheme (pyg_boxed_get (self, SoupURI), scheme);
return 0;
}
%%
override-attr SoupURI.user
static int
_wrap_soup_uri__set_user (PyObject *self, PyObject *value, void *closure)
{
char *user = PyString_AsString (value);
if (!user)
return -1;
soup_uri_set_user (pyg_boxed_get (self, SoupURI), user);
return 0;
}
%%
override-attr SoupURI.password
static int
_wrap_soup_uri__set_password (PyObject *self, PyObject *value, void *closure)
{
char *password = PyString_AsString (value);
if (!password)
return -1;
soup_uri_set_password (pyg_boxed_get (self, SoupURI), password);
return 0;
}
%%
override-attr SoupURI.host
static int
_wrap_soup_uri__set_host (PyObject *self, PyObject *value, void *closure)
{
char *host = PyString_AsString (value);
if (!host)
return -1;
soup_uri_set_host (pyg_boxed_get (self, SoupURI), host);
return 0;
}
%%
override-attr SoupURI.port
static int
_wrap_soup_uri__set_port (PyObject *self, PyObject *value, void *closure)
{
int port = PyInt_AsLong (value);
if (PyErr_Occurred())
return -1;
soup_uri_set_port (pyg_boxed_get (self, SoupURI), port);
return 0;
}
%%
override-attr SoupURI.path
static int
_wrap_soup_uri__set_path (PyObject *self, PyObject *value, void *closure)
{
char *path = PyString_AsString (value);
if (!path)
return -1;
soup_uri_set_path (pyg_boxed_get (self, SoupURI), path);
return 0;
}
%%
override-attr SoupURI.query
static int
_wrap_soup_uri__set_query (PyObject *self, PyObject *value, void *closure)
{
if (PyString_Check (value)) {
char *string_query = PyString_AsString (value);
soup_uri_set_query (pyg_boxed_get (self, SoupURI), string_query);
} else if (PyDict_Check (value)) {
GHashTable *dict_query = pysoup_pydict_to_ghashtable (value);
if (!dict_query)
return -1;
soup_uri_set_query_from_form (pyg_boxed_get (self, SoupURI), dict_query);
g_hash_table_destroy (dict_query);
} else {
PyErr_SetString (PyExc_TypeError, "query value must be a string or a dict");
return -1;
}
return 0;
}
%%
override-attr SoupURI.fragment
static int
_wrap_soup_uri__set_fragment (PyObject *self, PyObject *value, void *closure)
{
char *fragment = PyString_AsString (value);
if (!fragment)
return -1;
soup_uri_set_fragment (pyg_boxed_get (self, SoupURI), fragment);
return 0;
}
|