From 6f110c11249f7545511839cc9c1ee3891feb2c7e Mon Sep 17 00:00:00 2001 From: mdw Date: Tue, 4 Oct 2005 23:40:35 +0000 Subject: [PATCH] Initial checkin. --- .links | 2 ++ debian/changelog | 5 +++++ debian/control | 27 +++++++++++++++++++++++++ debian/copyright | 16 +++++++++++++++ debian/rules | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ module.c | 29 +++++++++++++++++++++++++++ setup.py | 23 ++++++++++++++++++++++ 7 files changed, 162 insertions(+) create mode 100644 .links create mode 100644 debian/changelog create mode 100644 debian/control create mode 100644 debian/copyright create mode 100755 debian/rules create mode 100644 module.c create mode 100644 setup.py diff --git a/.links b/.links new file mode 100644 index 0000000..70cfb93 --- /dev/null +++ b/.links @@ -0,0 +1,2 @@ +getdate.y +getdate.h diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..42d1a28 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +getdate-python (1.0.0) experimental; urgency=low + + * Written! + + -- Mark Wooding Wed, 5 Oct 2005 00:34:46 +0100 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..f0af776 --- /dev/null +++ b/debian/control @@ -0,0 +1,27 @@ +Source: getdate-python +Section: libraries +Priority: extra +Maintainer: Mark Wooding +Standards-Version: 3.1.1 + +Package: python-getdate +Architecture: all +Depends: python +Description: Python binding for date parser + This is a dummy package for making sure you have the right package for the + default Debian Python installation. + +Package: python2.3-getdate +Architecture: any +Depends: ${shlibs:Depends}, python2.3 +Description: Python binding for date parser + This is a dummy package for making sure you have the right package for the + default Debian Python installation. + +Package: python2.4-getdate +Architecture: any +Depends: ${shlibs:Depends}, python2.4 +Description: Python binding for date parser + This is a dummy package for making sure you have the right package for the + default Debian Python installation. + diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..b8c21f4 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,16 @@ +getdate-python is copyright (c) 2003 Straylight/Edgeware + +getdate-python is free software; you can redistribute it and/or modify it +under the terms of the GNU Library General Public License as published by the +Free Software Foundation; either version 2 of the License, or (at your +option) any later version. + +getdate-python is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for +more details. + +You should have a copy of the GNU Library General Public License in +/usr/share/common-licenses/LGPL-2; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, +USA. diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..596bbe2 --- /dev/null +++ b/debian/rules @@ -0,0 +1,60 @@ +#! /usr/bin/make -f + +export DH_COMPAT = 4 + +DEFVERSION = 2.3 +VERSIONS = $(DEFVERSION) 2.4 + +build: build-stamp + +build-stamp: + for v in $(VERSIONS); do python$$v setup.py build; done + touch build-stamp + +clean: + dh_clean + rm -rf build build-stamp + +install: build + dh_clean + for v in $(VERSIONS); do \ + python$$v setup.py build; \ + python$$v setup.py install --root=debian/python$$v-getdate; \ + done + mkdir -p debian/python-getdate + +binary-indep: install + dh_testdir -i + dh_testroot -i + dh_compress -i + dh_installdocs -i + dh_gencontrol -i + dh_fixperms -i + dh_installdeb -i + dh_md5sums -i + dh_builddeb -i + +binary-arch: install + dh_testdir -a + dh_testroot -a + dh_compress -a + dh_installdocs -a + dh_strip -a + dh_shlibdeps -a + dh_gencontrol -a + dh_fixperms -a + dh_installdeb -a + dh_md5sums -a + dh_builddeb -a + +binary: binary-indep binary-arch + +source: + rm -rf dist/*.tar.gz dist/=deb= + python$(DEFVERSION) setup.py sdist + mkdir dist/=deb= + cd dist/=deb=; tar xvfz ../*.tar.gz + d=`pwd`; cd ..; dpkg-source -i -i'/\.svn/' -b $$d/dist/=deb=/* + rm -rf dist/=deb= + +.PHONY: binary binary-arch binary-indep clean install source build diff --git a/module.c b/module.c new file mode 100644 index 0000000..8683d7d --- /dev/null +++ b/module.c @@ -0,0 +1,29 @@ +#include +#include "getdate.h" + +static PyObject *meth_getdate(PyObject *me, PyObject *arg, PyObject *kw) +{ + time_t now, t; + int tnow = -1; + char *p; + static char *kwlist[] = { "string", "now", 0 }; + + if (!PyArg_ParseTupleAndKeywords(arg, kw, "s|i:getdate", kwlist, + &p, &tnow)) + return (0); + if (tnow != -1) now = tnow; + if ((t = get_date(p, (tnow == -1) ? 0 : &now)) == (time_t)-1) { + PyErr_SetString(PyExc_SyntaxError, "Bad time string"); + return (0); + } + return (PyInt_FromLong(t)); +} + +static PyMethodDef methods[] = { + { "getdate", (PyCFunction)meth_getdate, METH_VARARGS | METH_KEYWORDS, + "getdate(STRING, now = time.time()) -> TIME" }, + { 0 } +}; + +void initgetdate(void) { Py_InitModule("getdate", methods); } + diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..41c302d --- /dev/null +++ b/setup.py @@ -0,0 +1,23 @@ +#! /usr/bin/python + +from distutils.core import setup, Extension +import os as OS + +def needs_update_p(target, deps): + if not OS.path.exists(target): return True + ts = OS.stat(target) + for d in deps: + s = OS.stat(d) + if ts.st_mtime < s.st_mtime: return True + return False + +if needs_update_p('getdate.c', ['getdate.y']): + OS.system('bison -o getdate.c getdate.y') + +setup(name = 'getdate', + version = '1.0.0', + description = 'Date/time parser', + author = 'Mark Wooding', + author_email = 'mdw@distorted.org.uk', + license = 'GNU General Public License', + ext_modules = [Extension('getdate', ['module.c', 'getdate.c'])]) -- 2.11.0