| 36 | extern PyTypeObject SignatureType; |
| 37 | |
| 38 | int |
| 39 | Signature_init(Signature *self, PyObject *args, PyObject *kwds) |
| 40 | { |
| 41 | char *keywords[] = {"name", "email", "time", "offset", "encoding", NULL}; |
| 42 | PyObject *py_name; |
| 43 | char *email, *encoding = NULL; |
| 44 | long long time = -1; |
| 45 | int offset = 0; |
| 46 | |
| 47 | if (!PyArg_ParseTupleAndKeywords( |
| 48 | args, kwds, "Os|Liz", keywords, |
| 49 | &py_name, &email, &time, &offset, &encoding)) |
| 50 | return -1; |
| 51 | |
| 52 | PyObject *tname; |
| 53 | const char *name = pgit_borrow_encoding( |
| 54 | py_name, value_or_default(encoding, "utf-8"), NULL, &tname); |
| 55 | if (name == NULL) |
| 56 | return -1; |
| 57 | |
| 58 | git_signature *signature; |
| 59 | int err = (time == -1) ? git_signature_now(&signature, name, email) |
| 60 | : git_signature_new(&signature, name, email, time, offset); |
| 61 | Py_DECREF(tname); |
| 62 | if (err < 0) { |
| 63 | Error_set(err); |
| 64 | return -1; |
| 65 | } |
| 66 | |
| 67 | self->obj = NULL; |
| 68 | self->signature = signature; |
| 69 | |
| 70 | if (encoding) { |
| 71 | self->encoding = strdup(encoding); |
| 72 | if (self->encoding == NULL) { |
| 73 | PyErr_NoMemory(); |
| 74 | return -1; |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | return 0; |
| 79 | } |
| 80 | |
| 81 | void |
| 82 | Signature_dealloc(Signature *self) |
nothing calls this directly
no test coverage detected
searching dependent graphs…