MCPcopy Create free account
hub / github.com/cruppstahl/upscaledb / parse_parameters

Function parse_parameters

python/src/python.cc:107–160  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

105}
106
107static bool
108parse_parameters(PyObject *extargs, std::vector<ups_parameter_t> &params)
109{
110 int name;
111 int i, extsize = PyTuple_Size(extargs);
112
113 /* sanity check */
114 if (extsize > 64)
115 return (false);
116
117 for (i = 0; i < extsize; i++) {
118 ups_parameter_t param = {0, 0};
119
120 PyObject *n, *v, *o = PyTuple_GetItem(extargs, i);
121 if (!o)
122 return (false);
123 if (o->ob_type != &PyTuple_Type) {
124 PyErr_SetString(PyExc_TypeError,
125 "Last argument must be a tuple of tuples");
126 return (false);
127 }
128 if (PyTuple_Size(o) != 2) {
129 PyErr_SetString(PyExc_TypeError,
130 "Last argument must be a tuple of tuples");
131 return (false);
132 }
133 n = PyTuple_GetItem(o, 0);
134 v = PyTuple_GetItem(o, 1);
135 name = PyInt_AsLong(n);
136 if (PyErr_Occurred())
137 return (false);
138
139 // a few parameters are passed as a string
140 param.name = name;
141 if (name == UPS_PARAM_LOG_DIRECTORY
142 || name == UPS_PARAM_ENCRYPTION_KEY
143 || name == UPS_PARAM_CUSTOM_COMPARE_NAME) {
144 param.value = (uint64_t)PyBytes_AsString(v);
145 }
146 else {
147 param.value = PyInt_AsLong(v);
148 }
149 if (PyErr_Occurred())
150 return (false);
151
152 params.push_back(param);
153 }
154
155 // terminating element
156 ups_parameter_t last = {0, 0};
157 params.push_back(last);
158
159 return (true);
160}
161
162static PyObject *
163env_create(UpsEnvironment *self, PyObject *args)

Callers 4

env_createFunction · 0.85
env_openFunction · 0.85
env_create_dbFunction · 0.85
env_open_dbFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected