当前位置: 首页>>代码示例>>C++>>正文


C++ PyUnicode_FromFormat函数代码示例

本文整理汇总了C++中PyUnicode_FromFormat函数的典型用法代码示例。如果您正苦于以下问题:C++ PyUnicode_FromFormat函数的具体用法?C++ PyUnicode_FromFormat怎么用?C++ PyUnicode_FromFormat使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了PyUnicode_FromFormat函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: BPy_errors_to_report

short BPy_errors_to_report(ReportList *reports)
{
	PyObject *pystring;
	PyObject *pystring_format= NULL; // workaround, see below
	char *cstring;

	const char *filename;
	int lineno;

	if (!PyErr_Occurred())
		return 1;
	
	/* less hassle if we allow NULL */
	if (reports==NULL) {
		PyErr_Print();
		PyErr_Clear();
		return 1;
	}
	
	pystring= PyC_ExceptionBuffer();
	
	if (pystring==NULL) {
		BKE_report(reports, RPT_ERROR, "unknown py-exception, couldn't convert");
		return 0;
	}
	
	PyC_FileAndNum(&filename, &lineno);
	if (filename==NULL)
		filename= "<unknown location>";
	
	cstring= _PyUnicode_AsString(pystring);

#if 0 // ARG!. workaround for a bug in blenders use of vsnprintf
	BKE_reportf(reports, RPT_ERROR, "%s\nlocation:%s:%d\n", cstring, filename, lineno);
#else
	pystring_format= PyUnicode_FromFormat("%s\nlocation:%s:%d\n", cstring, filename, lineno);
	cstring= _PyUnicode_AsString(pystring_format);
	BKE_report(reports, RPT_ERROR, cstring);
#endif
	
	fprintf(stderr, "%s\nlocation:%s:%d\n", cstring, filename, lineno); // not exactly needed. just for testing
	
	Py_DECREF(pystring);
	Py_DECREF(pystring_format); // workaround
	return 1;
}
开发者ID:BHCLL,项目名称:blendocv,代码行数:46,代码来源:bpy_util.c

示例2: PyStructSequence_New

static PyObject *make_oiio_info(void)
{
	PyObject *oiio_info;
	int pos = 0;

#ifdef WITH_OPENIMAGEIO
	int curversion;
#endif

	oiio_info = PyStructSequence_New(&BlenderAppOIIOType);
	if (oiio_info == NULL) {
		return NULL;
	}

#ifndef WITH_OPENIMAGEIO
#define SetStrItem(str) \
	PyStructSequence_SET_ITEM(oiio_info, pos++, PyUnicode_FromString(str))
#endif

#define SetObjItem(obj) \
	PyStructSequence_SET_ITEM(oiio_info, pos++, obj)

#ifdef WITH_OPENIMAGEIO
	curversion = OIIO_getVersionHex();
	SetObjItem(PyBool_FromLong(1));
	SetObjItem(Py_BuildValue("(iii)",
	                         curversion / 10000, (curversion / 100) % 100, curversion % 100));
	SetObjItem(PyUnicode_FromFormat("%2d, %2d, %2d",
	                                curversion / 10000, (curversion / 100) % 100, curversion % 100));
#else
	SetObjItem(PyBool_FromLong(0));
	SetObjItem(Py_BuildValue("(iii)", 0, 0, 0));
	SetStrItem("Unknown");
#endif

	if (PyErr_Occurred()) {
		Py_CLEAR(oiio_info);
		return NULL;
	}

#undef SetStrItem
#undef SetObjItem

	return oiio_info;
}
开发者ID:Andrewson3D,项目名称:blender-for-vray,代码行数:45,代码来源:bpy_app_oiio.c

示例3: _trie_keys_helper

static void
_trie_keys_helper(const char *key, const void *value, void *data)
{
    PyObject *py_list = (PyObject *)data;
    PyObject *py_key;

    if(PyErr_Occurred())
        return;

#ifdef IS_PY3K
    if(!(py_key = PyUnicode_FromFormat(key)))
#else
    if(!(py_key = PyString_FromString(key)))
#endif
        return;
    PyList_Append(py_list, py_key);
    Py_DECREF(py_key);
}
开发者ID:EverestAtWork,项目名称:biopython,代码行数:18,代码来源:triemodule.c

示例4: tb_displayline

static int
tb_displayline(PyObject *f, PyObject *filename, int lineno, PyObject *name)
{
    int err;
    PyObject *line;

    if (filename == NULL || name == NULL)
        return -1;
    line = PyUnicode_FromFormat("  File \"%U\", line %d, in %U\n",
                                filename, lineno, name);
    if (line == NULL)
        return -1;
    err = PyFile_WriteObject(line, f, Py_PRINT_RAW);
    Py_DECREF(line);
    if (err != 0)
        return err;
    return _Py_DisplaySourceLine(f, filename, lineno, 4);
}
开发者ID:henrywoo,项目名称:Python3.1.3-Linux,代码行数:18,代码来源:traceback.c

示例5: capsule_repr

static PyObject *
capsule_repr(PyObject *o)
{
    PyCapsule *capsule = (PyCapsule *)o;
    const char *name;
    const char *quote;

    if (capsule->name) {
        quote = "\"";
        name = capsule->name;
    } else {
        quote = "";
        name = "NULL";
    }

    return PyUnicode_FromFormat("<capsule object %s%s%s at %p>",
        quote, name, quote, capsule);
}
开发者ID:10sr,项目名称:cpython,代码行数:18,代码来源:capsule.c

示例6: setup_module

static int
setup_module(PyObject* m) {
    PyObject *d;
    PyObject *v;

    d = PyModule_GetDict(m);

    /* Ready object types */
    PyType_Ready(&CmsProfile_Type);
    PyType_Ready(&CmsTransform_Type);

    d = PyModule_GetDict(m);

    v = PyUnicode_FromFormat("%d.%d", LCMS_VERSION / 100, LCMS_VERSION % 100);
    PyDict_SetItemString(d, "littlecms_version", v);

    return 0;
}
开发者ID:anex,项目名称:Python,代码行数:18,代码来源:_imagingcms.c

示例7: PyString_FromFormat

// tp_repr slot, decide how a function shall be output
static PyObject *Nuitka_Frame_tp_repr(struct Nuitka_FrameObject *nuitka_frame) {
#if PYTHON_VERSION < 300
    return PyString_FromFormat(
#else
    return PyUnicode_FromFormat(
#endif
#if PYTHON_VERSION >= 370
        "<compiled_frame at %p, file %R, line %d, code %S>", nuitka_frame, nuitka_frame->m_frame.f_code->co_filename,
        nuitka_frame->m_frame.f_lineno, nuitka_frame->m_frame.f_code->co_name
#elif _DEBUG_FRAME || _DEBUG_REFRAME || _DEBUG_EXCEPTIONS
        "<compiled_frame object for %s at %p>", Nuitka_String_AsString(nuitka_frame->m_frame.f_code->co_name),
        nuitka_frame
#else
        "<compiled_frame object at %p>",
        nuitka_frame
#endif
    );
}
开发者ID:kayhayen,项目名称:Nuitka,代码行数:19,代码来源:CompiledFrameType.c

示例8: PyFloat_FromDouble

static PyObject *slot_QVector3D___repr__(PyObject *sipSelf)
{
    QVector3D *sipCpp = reinterpret_cast<QVector3D *>(sipGetCppPtr((sipSimpleWrapper *)sipSelf,sipType_QVector3D));

    if (!sipCpp)
        return 0;


    {
        {
            PyObject * sipRes = 0;

#line 48 "C:\\Users\\marcus\\Downloads\\PyQt-gpl-5.4\\PyQt-gpl-5.4\\sip/QtGui/qvector3d.sip"
        PyObject *x = PyFloat_FromDouble(sipCpp->x());
        PyObject *y = PyFloat_FromDouble(sipCpp->y());
        PyObject *z = PyFloat_FromDouble(sipCpp->z());
        
        if (x && y && z)
        {
        #if PY_MAJOR_VERSION >= 3
            sipRes = PyUnicode_FromFormat("PyQt5.QtGui.QVector3D(%R, %R, %R)", x, y,
                    z);
        #else
            sipRes = PyString_FromString("PyQt5.QtGui.QVector3D(");
            PyString_ConcatAndDel(&sipRes, PyObject_Repr(x));
            PyString_ConcatAndDel(&sipRes, PyString_FromString(", "));
            PyString_ConcatAndDel(&sipRes, PyObject_Repr(y));
            PyString_ConcatAndDel(&sipRes, PyString_FromString(", "));
            PyString_ConcatAndDel(&sipRes, PyObject_Repr(z));
            PyString_ConcatAndDel(&sipRes, PyString_FromString(")"));
        #endif
        }
        
        Py_XDECREF(x);
        Py_XDECREF(y);
        Py_XDECREF(z);
#line 1135 "C:\\Users\\marcus\\Downloads\\PyQt-gpl-5.4\\PyQt-gpl-5.4\\QtGui/sipQtGuiQVector3D.cpp"

            return sipRes;
        }
    }

    return 0;
}
开发者ID:rff255,项目名称:python-qt5,代码行数:44,代码来源:sipQtGuiQVector3D.cpp

示例9: PyInit__imagingcms

PyMODINIT_FUNC
PyInit__imagingcms(void)
{
    PyObject *m;
    PyObject *d;
    PyObject *v;

    /* Patch up object types */
    Py_TYPE(&CmsProfile_Type) = &PyType_Type;
    Py_TYPE(&CmsTransform_Type) = &PyType_Type;

    m = PyModule_Create(&_imagingcms_module);
    d = PyModule_GetDict(m);

    v = PyUnicode_FromFormat("%d.%d", LCMS_VERSION / 100, LCMS_VERSION % 100);
    PyDict_SetItemString(d, "littlecms_version", v);

    return m;
}
开发者ID:znanja,项目名称:pil-py3k,代码行数:19,代码来源:_imagingcms.c

示例10: _asctime

static PyObject *
_asctime(struct tm *timeptr)
{
    /* Inspired by Open Group reference implementation available at
     * http://pubs.opengroup.org/onlinepubs/009695399/functions/asctime.html */
    static char wday_name[7][4] = {
        "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
    };
    static char mon_name[12][4] = {
        "Jan", "Feb", "Mar", "Apr", "May", "Jun",
        "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
    };
    return PyUnicode_FromFormat(
        "%s %s%3d %.2d:%.2d:%.2d %d",
        wday_name[timeptr->tm_wday],
        mon_name[timeptr->tm_mon],
        timeptr->tm_mday, timeptr->tm_hour,
        timeptr->tm_min, timeptr->tm_sec,
        1900 + timeptr->tm_year);
}
开发者ID:dougmassay,项目名称:cpython3.4.4,代码行数:20,代码来源:timemodule.c

示例11: PyString_FromFormat

static PyObject *Nuitka_Generator_tp_repr( struct Nuitka_GeneratorObject *generator )
{
#if PYTHON_VERSION < 300
    return PyString_FromFormat(
        "<compiled_generator object %s at %p>",
        Nuitka_String_AsString( generator->m_name ),
        generator
    );
#else
    return PyUnicode_FromFormat(
        "<compiled_generator object %s at %p>",
#if PYTHON_VERSION < 350
        Nuitka_String_AsString( generator->m_name ),
#else
        Nuitka_String_AsString( generator->m_qualname ),
#endif
        generator
    );
#endif
}
开发者ID:fluxer,项目名称:spm,代码行数:20,代码来源:CompiledGeneratorType.c

示例12: nc_session_get_version

static PyObject *ncSessionGetVersion(ncSessionObject *self, void *closure)
{
	int ver;
	const char* ver_s;

	ver = nc_session_get_version(self->session);
	switch(ver) {
	case 0:
		ver_s = "1.0";
		break;
	case 1:
		ver_s = "1.1";
		break;
	default:
		ver_s = "unknown";
		break;
	}

	return PyUnicode_FromFormat("%s", ver_s);
}
开发者ID:rponczkowski,项目名称:libnetconf,代码行数:20,代码来源:session.c

示例13: get_module_info

/* Return some information about a module. */
static enum zi_module_info
get_module_info(ZipImporter *self, PyObject *fullname)
{
    PyObject *subname;
    PyObject *path, *fullpath, *item;
    struct st_zip_searchorder *zso;

    if (self->prefix == NULL) {
        PyErr_SetString(PyExc_ValueError,
                        "zipimporter.__init__() wasn't called");
        return MI_ERROR;
    }

    subname = get_subname(fullname);
    if (subname == NULL)
        return MI_ERROR;

    path = make_filename(self->prefix, subname);
    Py_DECREF(subname);
    if (path == NULL)
        return MI_ERROR;

    for (zso = zip_searchorder; *zso->suffix; zso++) {
        fullpath = PyUnicode_FromFormat("%U%s", path, zso->suffix);
        if (fullpath == NULL) {
            Py_DECREF(path);
            return MI_ERROR;
        }
        item = PyDict_GetItem(self->files, fullpath);
        Py_DECREF(fullpath);
        if (item != NULL) {
            Py_DECREF(path);
            if (zso->type & IS_PACKAGE)
                return MI_PACKAGE;
            else
                return MI_MODULE;
        }
    }
    Py_DECREF(path);
    return MI_NOT_FOUND;
}
开发者ID:1st1,项目名称:cpython,代码行数:42,代码来源:zipimport.c

示例14: nc_session_get_cpblts

static PyObject *ncSessionGetCapabilities(ncSessionObject *self, void *closure)
{
	struct nc_cpblts* cpblts;
	PyObject *list;
	const char *item;
	ssize_t pos;

	cpblts = nc_session_get_cpblts(self->session);
	if (cpblts == NULL) {
		return (NULL);
	}

	list = PyList_New(nc_cpblts_count(cpblts));
	nc_cpblts_iter_start(cpblts);
	for (pos = 0; pos < nc_cpblts_count(cpblts); pos++) {
		item = nc_cpblts_iter_next(cpblts);
		PyList_SetItem(list, pos, PyUnicode_FromFormat("%s", item));
	}

	return list;
}
开发者ID:rponczkowski,项目名称:libnetconf,代码行数:21,代码来源:session.c

示例15: BMO_opcode_from_opname

static PyObject *bpy_bmesh_op_doc_get(BPy_BMeshOpFunc *self, void *UNUSED(closure))
{
	PyObject *ret;
	char *slot_in;
	char *slot_out;
	int i;

	i = BMO_opcode_from_opname(self->opname);

	slot_in  = bmp_slots_as_args(bmo_opdefines[i]->slot_types_in, false);
	slot_out = bmp_slots_as_args(bmo_opdefines[i]->slot_types_out, true);

	ret = PyUnicode_FromFormat("%.200s bmesh.ops.%.200s(bmesh, %s)\n  -> dict(%s)",
	                           Py_TYPE(self)->tp_name,
	                           self->opname, slot_in, slot_out);

	MEM_freeN(slot_in);
	MEM_freeN(slot_out);

	return ret;
}
开发者ID:Andrewson3D,项目名称:blender-for-vray,代码行数:21,代码来源:bmesh_py_ops.c


注:本文中的PyUnicode_FromFormat函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。