Yaron de Leeuw | 02f3b7d | 2017-08-18 14:41:13 -0400 | [diff] [blame] | 1 | /*[clinic input] |
| 2 | preserve |
| 3 | [clinic start generated code]*/ |
| 4 | |
| 5 | PyDoc_STRVAR(zipimport_zipimporter___init____doc__, |
| 6 | "zipimporter(archivepath, /)\n" |
| 7 | "--\n" |
| 8 | "\n" |
| 9 | "Create a new zipimporter instance.\n" |
| 10 | "\n" |
| 11 | " archivepath\n" |
| 12 | " A path-like object to a zipfile, or to a specific path inside\n" |
| 13 | " a zipfile.\n" |
| 14 | "\n" |
| 15 | "\'archivepath\' must be a path-like object to a zipfile, or to a specific path\n" |
| 16 | "inside a zipfile. For example, it can be \'/tmp/myimport.zip\', or\n" |
| 17 | "\'/tmp/myimport.zip/mydirectory\', if mydirectory is a valid directory inside\n" |
| 18 | "the archive.\n" |
| 19 | "\n" |
| 20 | "\'ZipImportError\' is raised if \'archivepath\' doesn\'t point to a valid Zip\n" |
| 21 | "archive.\n" |
| 22 | "\n" |
| 23 | "The \'archive\' attribute of the zipimporter object contains the name of the\n" |
| 24 | "zipfile targeted."); |
| 25 | |
| 26 | static int |
| 27 | zipimport_zipimporter___init___impl(ZipImporter *self, PyObject *path); |
| 28 | |
| 29 | static int |
| 30 | zipimport_zipimporter___init__(PyObject *self, PyObject *args, PyObject *kwargs) |
| 31 | { |
| 32 | int return_value = -1; |
| 33 | PyObject *path; |
| 34 | |
| 35 | if ((Py_TYPE(self) == &ZipImporter_Type) && |
| 36 | !_PyArg_NoKeywords("zipimporter", kwargs)) { |
| 37 | goto exit; |
| 38 | } |
| 39 | if (!PyArg_ParseTuple(args, "O&:zipimporter", |
| 40 | PyUnicode_FSDecoder, &path)) { |
| 41 | goto exit; |
| 42 | } |
| 43 | return_value = zipimport_zipimporter___init___impl((ZipImporter *)self, path); |
| 44 | |
| 45 | exit: |
| 46 | return return_value; |
| 47 | } |
| 48 | |
| 49 | PyDoc_STRVAR(zipimport_zipimporter_find_module__doc__, |
| 50 | "find_module($self, fullname, path=None, /)\n" |
| 51 | "--\n" |
| 52 | "\n" |
| 53 | "Search for a module specified by \'fullname\'.\n" |
| 54 | "\n" |
| 55 | "\'fullname\' must be the fully qualified (dotted) module name. It returns the\n" |
| 56 | "zipimporter instance itself if the module was found, or None if it wasn\'t.\n" |
| 57 | "The optional \'path\' argument is ignored -- it\'s there for compatibility\n" |
| 58 | "with the importer protocol."); |
| 59 | |
| 60 | #define ZIPIMPORT_ZIPIMPORTER_FIND_MODULE_METHODDEF \ |
| 61 | {"find_module", (PyCFunction)zipimport_zipimporter_find_module, METH_FASTCALL, zipimport_zipimporter_find_module__doc__}, |
| 62 | |
| 63 | static PyObject * |
| 64 | zipimport_zipimporter_find_module_impl(ZipImporter *self, PyObject *fullname, |
| 65 | PyObject *path); |
| 66 | |
| 67 | static PyObject * |
Serhiy Storchaka | a5552f0 | 2017-12-15 13:11:11 +0200 | [diff] [blame^] | 68 | zipimport_zipimporter_find_module(ZipImporter *self, PyObject *const *args, Py_ssize_t nargs) |
Yaron de Leeuw | 02f3b7d | 2017-08-18 14:41:13 -0400 | [diff] [blame] | 69 | { |
| 70 | PyObject *return_value = NULL; |
| 71 | PyObject *fullname; |
| 72 | PyObject *path = Py_None; |
| 73 | |
| 74 | if (!_PyArg_ParseStack(args, nargs, "U|O:find_module", |
| 75 | &fullname, &path)) { |
| 76 | goto exit; |
| 77 | } |
| 78 | return_value = zipimport_zipimporter_find_module_impl(self, fullname, path); |
| 79 | |
| 80 | exit: |
| 81 | return return_value; |
| 82 | } |
| 83 | |
| 84 | PyDoc_STRVAR(zipimport_zipimporter_find_loader__doc__, |
| 85 | "find_loader($self, fullname, path=None, /)\n" |
| 86 | "--\n" |
| 87 | "\n" |
| 88 | "Search for a module specified by \'fullname\'.\n" |
| 89 | "\n" |
| 90 | "\'fullname\' must be the fully qualified (dotted) module name. It returns the\n" |
| 91 | "zipimporter instance itself if the module was found, a string containing the\n" |
| 92 | "full path name if it\'s possibly a portion of a namespace package,\n" |
| 93 | "or None otherwise. The optional \'path\' argument is ignored -- it\'s\n" |
| 94 | "there for compatibility with the importer protocol."); |
| 95 | |
| 96 | #define ZIPIMPORT_ZIPIMPORTER_FIND_LOADER_METHODDEF \ |
| 97 | {"find_loader", (PyCFunction)zipimport_zipimporter_find_loader, METH_FASTCALL, zipimport_zipimporter_find_loader__doc__}, |
| 98 | |
| 99 | static PyObject * |
| 100 | zipimport_zipimporter_find_loader_impl(ZipImporter *self, PyObject *fullname, |
| 101 | PyObject *path); |
| 102 | |
| 103 | static PyObject * |
Serhiy Storchaka | a5552f0 | 2017-12-15 13:11:11 +0200 | [diff] [blame^] | 104 | zipimport_zipimporter_find_loader(ZipImporter *self, PyObject *const *args, Py_ssize_t nargs) |
Yaron de Leeuw | 02f3b7d | 2017-08-18 14:41:13 -0400 | [diff] [blame] | 105 | { |
| 106 | PyObject *return_value = NULL; |
| 107 | PyObject *fullname; |
| 108 | PyObject *path = Py_None; |
| 109 | |
| 110 | if (!_PyArg_ParseStack(args, nargs, "U|O:find_loader", |
| 111 | &fullname, &path)) { |
| 112 | goto exit; |
| 113 | } |
| 114 | return_value = zipimport_zipimporter_find_loader_impl(self, fullname, path); |
| 115 | |
| 116 | exit: |
| 117 | return return_value; |
| 118 | } |
| 119 | |
| 120 | PyDoc_STRVAR(zipimport_zipimporter_load_module__doc__, |
| 121 | "load_module($self, fullname, /)\n" |
| 122 | "--\n" |
| 123 | "\n" |
| 124 | "Load the module specified by \'fullname\'.\n" |
| 125 | "\n" |
| 126 | "\'fullname\' must be the fully qualified (dotted) module name. It returns the\n" |
| 127 | "imported module, or raises ZipImportError if it wasn\'t found."); |
| 128 | |
| 129 | #define ZIPIMPORT_ZIPIMPORTER_LOAD_MODULE_METHODDEF \ |
| 130 | {"load_module", (PyCFunction)zipimport_zipimporter_load_module, METH_O, zipimport_zipimporter_load_module__doc__}, |
| 131 | |
| 132 | static PyObject * |
| 133 | zipimport_zipimporter_load_module_impl(ZipImporter *self, PyObject *fullname); |
| 134 | |
| 135 | static PyObject * |
| 136 | zipimport_zipimporter_load_module(ZipImporter *self, PyObject *arg) |
| 137 | { |
| 138 | PyObject *return_value = NULL; |
| 139 | PyObject *fullname; |
| 140 | |
| 141 | if (!PyArg_Parse(arg, "U:load_module", &fullname)) { |
| 142 | goto exit; |
| 143 | } |
| 144 | return_value = zipimport_zipimporter_load_module_impl(self, fullname); |
| 145 | |
| 146 | exit: |
| 147 | return return_value; |
| 148 | } |
| 149 | |
| 150 | PyDoc_STRVAR(zipimport_zipimporter_get_filename__doc__, |
| 151 | "get_filename($self, fullname, /)\n" |
| 152 | "--\n" |
| 153 | "\n" |
| 154 | "Return the filename for the specified module."); |
| 155 | |
| 156 | #define ZIPIMPORT_ZIPIMPORTER_GET_FILENAME_METHODDEF \ |
| 157 | {"get_filename", (PyCFunction)zipimport_zipimporter_get_filename, METH_O, zipimport_zipimporter_get_filename__doc__}, |
| 158 | |
| 159 | static PyObject * |
| 160 | zipimport_zipimporter_get_filename_impl(ZipImporter *self, |
| 161 | PyObject *fullname); |
| 162 | |
| 163 | static PyObject * |
| 164 | zipimport_zipimporter_get_filename(ZipImporter *self, PyObject *arg) |
| 165 | { |
| 166 | PyObject *return_value = NULL; |
| 167 | PyObject *fullname; |
| 168 | |
| 169 | if (!PyArg_Parse(arg, "U:get_filename", &fullname)) { |
| 170 | goto exit; |
| 171 | } |
| 172 | return_value = zipimport_zipimporter_get_filename_impl(self, fullname); |
| 173 | |
| 174 | exit: |
| 175 | return return_value; |
| 176 | } |
| 177 | |
| 178 | PyDoc_STRVAR(zipimport_zipimporter_is_package__doc__, |
| 179 | "is_package($self, fullname, /)\n" |
| 180 | "--\n" |
| 181 | "\n" |
| 182 | "Return True if the module specified by fullname is a package.\n" |
| 183 | "\n" |
| 184 | "Raise ZipImportError if the module couldn\'t be found."); |
| 185 | |
| 186 | #define ZIPIMPORT_ZIPIMPORTER_IS_PACKAGE_METHODDEF \ |
| 187 | {"is_package", (PyCFunction)zipimport_zipimporter_is_package, METH_O, zipimport_zipimporter_is_package__doc__}, |
| 188 | |
| 189 | static PyObject * |
| 190 | zipimport_zipimporter_is_package_impl(ZipImporter *self, PyObject *fullname); |
| 191 | |
| 192 | static PyObject * |
| 193 | zipimport_zipimporter_is_package(ZipImporter *self, PyObject *arg) |
| 194 | { |
| 195 | PyObject *return_value = NULL; |
| 196 | PyObject *fullname; |
| 197 | |
| 198 | if (!PyArg_Parse(arg, "U:is_package", &fullname)) { |
| 199 | goto exit; |
| 200 | } |
| 201 | return_value = zipimport_zipimporter_is_package_impl(self, fullname); |
| 202 | |
| 203 | exit: |
| 204 | return return_value; |
| 205 | } |
| 206 | |
| 207 | PyDoc_STRVAR(zipimport_zipimporter_get_data__doc__, |
| 208 | "get_data($self, pathname, /)\n" |
| 209 | "--\n" |
| 210 | "\n" |
| 211 | "Return the data associated with \'pathname\'.\n" |
| 212 | "\n" |
| 213 | "Raise OSError if the file was not found."); |
| 214 | |
| 215 | #define ZIPIMPORT_ZIPIMPORTER_GET_DATA_METHODDEF \ |
| 216 | {"get_data", (PyCFunction)zipimport_zipimporter_get_data, METH_O, zipimport_zipimporter_get_data__doc__}, |
| 217 | |
| 218 | static PyObject * |
| 219 | zipimport_zipimporter_get_data_impl(ZipImporter *self, PyObject *path); |
| 220 | |
| 221 | static PyObject * |
| 222 | zipimport_zipimporter_get_data(ZipImporter *self, PyObject *arg) |
| 223 | { |
| 224 | PyObject *return_value = NULL; |
| 225 | PyObject *path; |
| 226 | |
| 227 | if (!PyArg_Parse(arg, "U:get_data", &path)) { |
| 228 | goto exit; |
| 229 | } |
| 230 | return_value = zipimport_zipimporter_get_data_impl(self, path); |
| 231 | |
| 232 | exit: |
| 233 | return return_value; |
| 234 | } |
| 235 | |
| 236 | PyDoc_STRVAR(zipimport_zipimporter_get_code__doc__, |
| 237 | "get_code($self, fullname, /)\n" |
| 238 | "--\n" |
| 239 | "\n" |
| 240 | "Return the code object for the specified module.\n" |
| 241 | "\n" |
| 242 | "Raise ZipImportError if the module couldn\'t be found."); |
| 243 | |
| 244 | #define ZIPIMPORT_ZIPIMPORTER_GET_CODE_METHODDEF \ |
| 245 | {"get_code", (PyCFunction)zipimport_zipimporter_get_code, METH_O, zipimport_zipimporter_get_code__doc__}, |
| 246 | |
| 247 | static PyObject * |
| 248 | zipimport_zipimporter_get_code_impl(ZipImporter *self, PyObject *fullname); |
| 249 | |
| 250 | static PyObject * |
| 251 | zipimport_zipimporter_get_code(ZipImporter *self, PyObject *arg) |
| 252 | { |
| 253 | PyObject *return_value = NULL; |
| 254 | PyObject *fullname; |
| 255 | |
| 256 | if (!PyArg_Parse(arg, "U:get_code", &fullname)) { |
| 257 | goto exit; |
| 258 | } |
| 259 | return_value = zipimport_zipimporter_get_code_impl(self, fullname); |
| 260 | |
| 261 | exit: |
| 262 | return return_value; |
| 263 | } |
| 264 | |
| 265 | PyDoc_STRVAR(zipimport_zipimporter_get_source__doc__, |
| 266 | "get_source($self, fullname, /)\n" |
| 267 | "--\n" |
| 268 | "\n" |
| 269 | "Return the source code for the specified module.\n" |
| 270 | "\n" |
| 271 | "Raise ZipImportError if the module couldn\'t be found, return None if the\n" |
| 272 | "archive does contain the module, but has no source for it."); |
| 273 | |
| 274 | #define ZIPIMPORT_ZIPIMPORTER_GET_SOURCE_METHODDEF \ |
| 275 | {"get_source", (PyCFunction)zipimport_zipimporter_get_source, METH_O, zipimport_zipimporter_get_source__doc__}, |
| 276 | |
| 277 | static PyObject * |
| 278 | zipimport_zipimporter_get_source_impl(ZipImporter *self, PyObject *fullname); |
| 279 | |
| 280 | static PyObject * |
| 281 | zipimport_zipimporter_get_source(ZipImporter *self, PyObject *arg) |
| 282 | { |
| 283 | PyObject *return_value = NULL; |
| 284 | PyObject *fullname; |
| 285 | |
| 286 | if (!PyArg_Parse(arg, "U:get_source", &fullname)) { |
| 287 | goto exit; |
| 288 | } |
| 289 | return_value = zipimport_zipimporter_get_source_impl(self, fullname); |
| 290 | |
| 291 | exit: |
| 292 | return return_value; |
| 293 | } |
Serhiy Storchaka | a5552f0 | 2017-12-15 13:11:11 +0200 | [diff] [blame^] | 294 | /*[clinic end generated code: output=93cb62a3a9752b9f input=a9049054013a1b77]*/ |