Show More
@@ -121,6 +121,27 b' static void listdir_stat_dealloc(PyObjec' | |||||
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*/ | |
@@ -134,7 +155,7 b' static PyTypeObject listdir_stat_type = ' | |||||
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*/ | |
@@ -1352,7 +1373,7 b' static PyMethodDef methods[] = {' | |||||
1352 | {NULL, NULL} |
|
1373 | {NULL, NULL} | |
1353 | }; |
|
1374 | }; | |
1354 |
|
1375 | |||
1355 |
static const int version = |
|
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 = { |
@@ -69,7 +69,7 b' def _importfrom(pkgname, modname):' | |||||
69 | (r'cext', r'bdiff'): 3, |
|
69 | (r'cext', r'bdiff'): 3, | |
70 | (r'cext', r'diffhelpers'): 1, |
|
70 | (r'cext', r'diffhelpers'): 1, | |
71 | (r'cext', r'mpatch'): 1, |
|
71 | (r'cext', r'mpatch'): 1, | |
72 |
(r'cext', r'osutil'): |
|
72 | (r'cext', r'osutil'): 4, | |
73 | (r'cext', r'parsers'): 4, |
|
73 | (r'cext', r'parsers'): 4, | |
74 | } |
|
74 | } | |
75 |
|
75 |
General Comments 0
You need to be logged in to leave comments.
Login now