changeset 36780 | f3c314020beb |
parent 36620 | 186c6df3a373 |
child 39610 | 11ed2eadf937 |
36779:bf9a04d78084 | 36780:f3c314020beb |
---|---|
119 static void listdir_stat_dealloc(PyObject *o) |
119 static void listdir_stat_dealloc(PyObject *o) |
120 { |
120 { |
121 o->ob_type->tp_free(o); |
121 o->ob_type->tp_free(o); |
122 } |
122 } |
123 |
123 |
124 static PyObject *listdir_stat_getitem(PyObject *self, PyObject *key) |
|
125 { |
|
126 long index = PyLong_AsLong(key); |
|
127 if (index == -1 && PyErr_Occurred()) { |
|
128 return NULL; |
|
129 } |
|
130 if (index != 8) { |
|
131 PyErr_Format(PyExc_IndexError, "osutil.stat objects only " |
|
132 "support stat.ST_MTIME in " |
|
133 "__getitem__"); |
|
134 return NULL; |
|
135 } |
|
136 return listdir_stat_st_mtime(self, NULL); |
|
137 } |
|
138 |
|
139 static PyMappingMethods listdir_stat_type_mapping_methods = { |
|
140 (lenfunc)NULL, /* mp_length */ |
|
141 (binaryfunc)listdir_stat_getitem, /* mp_subscript */ |
|
142 (objobjargproc)NULL, /* mp_ass_subscript */ |
|
143 }; |
|
144 |
|
124 static PyTypeObject listdir_stat_type = { |
145 static PyTypeObject listdir_stat_type = { |
125 PyVarObject_HEAD_INIT(NULL, 0) /* header */ |
146 PyVarObject_HEAD_INIT(NULL, 0) /* header */ |
126 "osutil.stat", /*tp_name*/ |
147 "osutil.stat", /*tp_name*/ |
127 sizeof(struct listdir_stat), /*tp_basicsize*/ |
148 sizeof(struct listdir_stat), /*tp_basicsize*/ |
128 0, /*tp_itemsize*/ |
149 0, /*tp_itemsize*/ |
132 0, /*tp_setattr*/ |
153 0, /*tp_setattr*/ |
133 0, /*tp_compare*/ |
154 0, /*tp_compare*/ |
134 0, /*tp_repr*/ |
155 0, /*tp_repr*/ |
135 0, /*tp_as_number*/ |
156 0, /*tp_as_number*/ |
136 0, /*tp_as_sequence*/ |
157 0, /*tp_as_sequence*/ |
137 0, /*tp_as_mapping*/ |
158 &listdir_stat_type_mapping_methods, /*tp_as_mapping*/ |
138 0, /*tp_hash */ |
159 0, /*tp_hash */ |
139 0, /*tp_call*/ |
160 0, /*tp_call*/ |
140 0, /*tp_str*/ |
161 0, /*tp_str*/ |
141 0, /*tp_getattro*/ |
162 0, /*tp_getattro*/ |
142 0, /*tp_setattro*/ |
163 0, /*tp_setattro*/ |
1350 }, |
1371 }, |
1351 #endif |
1372 #endif |
1352 {NULL, NULL} |
1373 {NULL, NULL} |
1353 }; |
1374 }; |
1354 |
1375 |
1355 static const int version = 3; |
1376 static const int version = 4; |
1356 |
1377 |
1357 #ifdef IS_PY3K |
1378 #ifdef IS_PY3K |
1358 static struct PyModuleDef osutil_module = { |
1379 static struct PyModuleDef osutil_module = { |
1359 PyModuleDef_HEAD_INIT, |
1380 PyModuleDef_HEAD_INIT, |
1360 "osutil", |
1381 "osutil", |