/*###########################################################################
#
# Copyright (c) 2003 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
############################################################################*/
#include "Python.h"
#include "structmember.h"
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-parameter"
#pragma clang diagnostic ignored "-Wmissing-field-initializers"
#endif
#define TYPE(O) ((PyTypeObject*)(O))
#define OBJECT(O) ((PyObject*)(O))
#define CLASSIC(O) ((PyClassObject*)(O))
#ifndef PyVarObject_HEAD_INIT
#define PyVarObject_HEAD_INIT(a, b) PyObject_HEAD_INIT(a) b,
#endif
#ifndef Py_TYPE
#define Py_TYPE(o) ((o)->ob_type)
#endif
#if PY_MAJOR_VERSION >= 3
#define PY3K
#define PyNative_FromString PyUnicode_FromString
#else
#define PyNative_FromString PyString_FromString
#endif
static PyObject *str__dict__, *str__implemented__, *strextends;
static PyObject *BuiltinImplementationSpecifications, *str__provides__;
static PyObject *str__class__, *str__providedBy__;
static PyObject *empty, *fallback;
static PyObject *str__conform__, *str_call_conform, *adapter_hooks;
static PyObject *str_uncached_lookup, *str_uncached_lookupAll;
static PyObject *str_uncached_subscriptions;
static PyObject *str_registry, *strro, *str_generation, *strchanged;
static PyObject *str__self__;
static PyObject *str__module__;
static PyObject *str__name__;
static PyObject *str__adapt__;
static PyObject *str_CALL_CUSTOM_ADAPT;
static PyTypeObject *Implements;
static int imported_declarations = 0;
static int
import_declarations(void)
{
PyObject *declarations, *i;
declarations = PyImport_ImportModule("zope.interface.declarations");
if (declarations == NULL)
return -1;
BuiltinImplementationSpecifications = PyObject_GetAttrString(
declarations, "BuiltinImplementationSpecifications");
if (BuiltinImplementationSpecifications == NULL)
return -1;
empty = PyObject_GetAttrString(declarations, "_empty");
if (empty == NULL)
return -1;
fallback = PyObject_GetAttrString(declarations, "implementedByFallback");
if (fallback == NULL)
return -1;
i = PyObject_GetAttrString(declarations, "Implements");
if (i == NULL)
return -1;
if (! PyType_Check(i))
{
PyErr_SetString(PyExc_TypeError,
"zope.interface.declarations.Implements is not a type");
return -1;
}
Implements = (PyTypeObject *)i;
Py_DECREF(declarations);
imported_declarations = 1;
return 0;
}
static PyTypeObject SpecificationBaseType; /* Forward */
static PyObject *
implementedByFallback(PyObject *cls)
{
if (imported_declarations == 0 && import_declarations() < 0)
return NULL;
return PyObject_CallFunctionObjArgs(fallback, cls, NULL);
}
static PyObject *
implementedBy(PyObject *ignored, PyObject *cls)
{
/* Fast retrieval of implements spec, if possible, to optimize
common case. Use fallback code if we get stuck.
*/
PyObject *dict = NULL, *spec;
if (PyObject_TypeCheck(cls, &PySuper_Type))
{
// Let merging be handled by Python.
return implementedByFallback(cls);
}
if (PyType_Check(cls))
{
dict = TYPE(cls)->tp_dict;
Py_XINCREF(dict);
}
if (dict == NULL)
dict = PyObject_GetAttr(cls, str__dict__);
if (dict == NULL)
{
/* Probably a security proxied class, use more expensive fallback code */
PyErr_Clear();
return implementedByFallback(cls);
}
spec = PyObject_GetItem(dict, str__implemented__);
Py_DECREF(dict);
if (spec)
{
if (imported_declarations == 0 && import_declarations() < 0)
return NULL;
if (PyObject_TypeCheck(spec, Implements))
return spec;
/* Old-style declaration, use more expensive fallback code */
Py_DECREF(spec);
return implementedByFallback(cls);
}
PyErr_Clear();
/* Maybe we have a builtin */
if (imported_declarations == 0 && import_declarations() < 0)
return NULL;
spec = PyDict_GetItem(BuiltinImplementationSpecifications, cls);
if (spec != NULL)
{
Py_INCREF(spec);
return spec;
}
/* We're stuck, use fallback */
return implementedByFallback(cls);
}
static PyObject *
getObjectSpecification(PyObject *ignored, PyObject *ob)
{
PyObject *cls, *result;
result = PyObject_GetAttr(ob, str__provides__);
if (!result)
{
if (!PyErr_ExceptionMatches(PyExc_AttributeError))
{
/* Propagate non AttributeError exceptions. */
return NULL;
}
PyErr_Clear();
}
else
{
int is_instance = -1;
is_instance = PyObject_IsInstance(result, (PyObject*)&SpecificationBaseType);
if (is_instance < 0)
{
/* Propagate all errors */
return NULL;
}
if (is_instance)
{
return result;
}
}
/* We do a getattr here so as not to be defeated by proxies */
cls = PyObject_GetAttr(ob, str__class__);
if (cls == NULL)
{
if (!PyErr_ExceptionMatches(PyExc_AttributeError))
{
/* Propagate non-AttributeErrors */
return NULL;
}
PyErr_Clear();
if (imported_declarations == 0 && import_declarations() < 0)
return NULL;
Py_INCREF(empty);
return empty;
}
result = implementedBy(NULL, cls);
Py_DECREF(cls);
return result;
}
static PyObject *
providedBy(PyObject *ignored, PyObject *ob)
{
PyObject *result, *cls, *cp;
int is_instance = -1;
result = NULL;
is_instance = PyObject_IsInstance(ob, (PyObject*)&PySuper_Type);
if (is_instance < 0)
{
if (!PyErr_ExceptionMatches(PyExc_AttributeError))
{
/* Propagate non-AttributeErrors */
return NULL;
}
PyErr_Clear();
}
if (is_instance)
{
return implementedBy(NULL, ob);
}
result = PyObject_GetAttr(ob, str__providedBy__);
if (result == NULL)
{
if (!PyErr_ExceptionMatches(PyExc_AttributeError))
{
return NULL;
}
PyErr_Clear();
return getObjectSpecification(NULL, ob);
}
/* We want to make sure we have a spec. We can't do a type check
because we may have a proxy, so we'll just try to get the
only attribute.
*/
if (PyObject_TypeCheck(result, &SpecificationBaseType)
||
PyObject_HasAttr(result, strextends)
)
return result;
/*
The object's class doesn't understand descriptors.
Sigh. We need to get an object descriptor, but we have to be
careful. We want to use the instance's __provides__,l if
there is one, but only if it didn't come from the class.
*/
Py_DECREF(result);
cls = PyObject_GetAttr(ob, str__class__);
if (cls == NULL)
return NULL;
result = PyObject_GetAttr(ob, str__provides__);
if (result == NULL)
{
/* No __provides__, so just fall back to implementedBy */
PyErr_Clear();
result = implementedBy(NULL, cls);
Py_DECREF(cls);
return result;
}
cp = PyObject_GetAttr(cls, str__provides__);
if (cp == NULL)
{
/* The the class has no provides, assume we're done: */
PyErr_Clear();
Py_DECREF(cls);
return result;
}
if (cp == result)
{
/*
Oops, we got the provides from the class. This means
the object doesn't have it's own. We should use implementedBy
*/
Py_DECREF(result);
result = implementedBy(NULL, cls);
}
Py_DECREF(cls);
Py_DECREF(cp);
return result;
}
typedef struct {
PyObject_HEAD
PyObject* weakref
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
本项目是一款基于Python的爱词霸四六级单词爬虫设计源码,包含4383个文件,包括1989个Python字节码文件(pyc)、1972个Python源代码文件(py)、80个HTML文件、47个文本文件(txt)以及其他类型文件。该爬虫旨在抓取并整理爱词霸四六级单词资源,方便用户学习和复习。
资源推荐
资源详情
资源评论
收起资源包目录
基于Python的iciba_crawl爱词霸四六级单词爬虫设计源码 (2000个子文件)
_zope_interface_coptimizations.c 57KB
xsltInternals.h 56KB
parser.h 39KB
tree.h 37KB
xmlerror.h 36KB
schemasInternals.h 26KB
xmlwriter.h 21KB
xpathInternals.h 19KB
lxml.etree_api.h 17KB
etree_api.h 17KB
parserInternals.h 17KB
_embedding.h 17KB
xpath.h 16KB
etree_defs.h 15KB
globals.h 14KB
valid.h 13KB
_cffi_include.h 13KB
xmlreader.h 12KB
xmlIO.h 10KB
xmlunicode.h 10KB
HTMLparser.h 9KB
etree.h 8KB
lxml.etree.h 8KB
encoding.h 8KB
xsltutils.h 8KB
xmlversion.h 8KB
xmlschemas.h 7KB
extensions.h 7KB
hash.h 6KB
transform.h 6KB
relaxng.h 6KB
parse_c_type.h 6KB
xmlmemory.h 6KB
xmlstring.h 5KB
xmlregexp.h 5KB
chvalid.h 5KB
debugXML.h 5KB
xlink.h 5KB
SAX2.h 5KB
catalog.h 5KB
xmlschemastypes.h 5KB
entities.h 5KB
schematron.h 4KB
SAX.h 4KB
xmlautomata.h 4KB
_cffi_errors.h 4KB
xmlexports.h 4KB
nanoftp.h 4KB
xsltconfig.h 4KB
HTMLtree.h 4KB
xsltexports.h 3KB
exsltexports.h 3KB
xpointer.h 3KB
list.h 3KB
variables.h 3KB
DOCBparser.h 3KB
c14n.h 3KB
exslt.h 3KB
xinclude.h 3KB
documents.h 3KB
uri.h 3KB
security.h 3KB
xmlsave.h 2KB
templates.h 2KB
pattern.h 2KB
numbersInternals.h 2KB
nanohttp.h 2KB
functions.h 2KB
xslt.h 2KB
threads.h 2KB
imports.h 2KB
dict.h 2KB
namespaces.h 2KB
extra.h 2KB
xsltlocale.h 2KB
xmlmodule.h 1KB
exsltconfig.h 1KB
keys.h 1KB
attributes.h 930B
preproc.h 892B
lxml-version.h 71B
index.html 3KB
common.html 3KB
summary.html 2KB
metadata.json 1KB
metadata.json 983B
metadata.json 983B
metadata.json 923B
metadata.json 221B
pbr.json 47B
pyparsing.py 266KB
test_imap.py 260KB
pyparsing.py 227KB
pyparsing.py 227KB
imap4.py 206KB
uts46data.py 196KB
uts46data.py 194KB
yacctab.py 166KB
test_dns.py 156KB
test_endpoints.py 145KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
lsx202406
- 粉丝: 2434
- 资源: 5585
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 日志文件:日志概念、LogBack日志技术的概述、使用、logback.xml配置文件详解
- 基于python使用Drl来解决多智能体卸载问题+源码(期末作业&课程设计&项目开发)
- 科学计算领域中的Fortran语言基础知识与应用
- 4.健身房预约课程-微信小程序.zip
- 小乌龟键盘控制源码111111
- 电赛2023年本科组电子电路设计比赛指南与任务解析
- Delphi 12 控件之dspack For Delphi 10.2 - 视频播放组件包e963a-main.zip
- delphi 12 控件之FB4D – The OpenSource Cross-Platform Library for FirebaseFB4D-master.zip
- Rust语言入门与进阶教程
- delphi 12 控件之Delphi开发的微信电脑版登录工具ec617-main.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功