summaryrefslogtreecommitdiffstats
path: root/src/python-missingos
diff options
context:
space:
mode:
authorJason Stubbs <jstubbs@gentoo.org>2005-08-28 08:37:44 +0000
committerJason Stubbs <jstubbs@gentoo.org>2005-08-28 08:37:44 +0000
commitd9fc4acc572c6647a4f27b838d35d27d805d190e (patch)
tree262a8de35d8c7567312757da5f1f66efdc8cece5 /src/python-missingos
downloadportage-d9fc4acc572c6647a4f27b838d35d27d805d190e.tar.gz
portage-d9fc4acc572c6647a4f27b838d35d27d805d190e.tar.bz2
portage-d9fc4acc572c6647a4f27b838d35d27d805d190e.zip
Migration (without history) of the current stable line to subversion.
svn path=/main/branches/2.0/; revision=1941
Diffstat (limited to 'src/python-missingos')
-rw-r--r--src/python-missingos/ChangeLog16
-rw-r--r--src/python-missingos/PKG-INFO10
-rw-r--r--src/python-missingos/README15
-rw-r--r--src/python-missingos/missingos.c120
-rw-r--r--src/python-missingos/setup.cfg8
-rwxr-xr-xsrc/python-missingos/setup.py24
6 files changed, 193 insertions, 0 deletions
diff --git a/src/python-missingos/ChangeLog b/src/python-missingos/ChangeLog
new file mode 100644
index 000000000..1c80b2e63
--- /dev/null
+++ b/src/python-missingos/ChangeLog
@@ -0,0 +1,16 @@
+# $Header: /var/cvsroot/gentoo-src/portage/src/python-missingos/ChangeLog,v 1.4 2003/03/22 14:24:38 carpaski Exp $
+
+python-missingos ChangeLog
+Jonathon D Nelson <jnelson@gentoo.org>
+2 April 2002
+
+ 2 April 2002 14:15 jnelson
+ * Add optional 'mode' parameter to mknod
+ * Change from missingosmodule to missingos.
+ * Add some __doc__ entries
+ * Remove stupid hack for Python 1.5.2 support,
+ 1.5.2 doesn't have Py_FileSystemDefaultEncoding anyway.
+ * Return description of error when mode not p,b,c,u in mknod
+
+ 2 April 2002 12:10 jnelson
+ * Populate files
diff --git a/src/python-missingos/PKG-INFO b/src/python-missingos/PKG-INFO
new file mode 100644
index 000000000..cb8087f4c
--- /dev/null
+++ b/src/python-missingos/PKG-INFO
@@ -0,0 +1,10 @@
+Metadata-Version: 1.0
+Name: python-missingos
+Version: 0.2
+Summary: UNKNOWN
+Home-page: UNKNOWN
+Author: Jonathon D Nelson
+Author-email: jnelson@gentoo.org
+License: UNKNOWN
+Description: UNKNOWN
+Platform: UNKNOWN
diff --git a/src/python-missingos/README b/src/python-missingos/README
new file mode 100644
index 000000000..de3467d52
--- /dev/null
+++ b/src/python-missingos/README
@@ -0,0 +1,15 @@
+# $Header: /var/cvsroot/gentoo-src/portage/src/python-missingos/README,v 1.5.2.1 2004/10/22 16:53:30 carpaski Exp $
+
+python-missingos
+Jonathon D Nelson <jnelson@gentoo.org>
+2 April 2002
+
+INTRO
+=====
+This module provides some missing file operations that don't
+seem to be provided by the standard os and posix modules.
+This list currently includes lchown and mknod.
+
+COPYRIGHT
+=========
+GPL
diff --git a/src/python-missingos/missingos.c b/src/python-missingos/missingos.c
new file mode 100644
index 000000000..cbcde5bf1
--- /dev/null
+++ b/src/python-missingos/missingos.c
@@ -0,0 +1,120 @@
+/* $Header: /var/cvsroot/gentoo-src/portage/src/python-missingos/missingos.c,v 1.5.2.1 2004/10/22 16:53:30 carpaski Exp $ */
+
+#include "Python.h"
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+static char missingos_lchown__doc__[];
+static PyObject * missingos_lchown(PyObject *self, PyObject *args);
+static char missingos_mknod__doc__[];
+static PyObject * missingos_mknod(PyObject *self, PyObject *args);
+
+static char missingos__doc__[] = "Provide some operations that\
+ are missing from the standard os / posix modules.";
+
+static PyMethodDef missingos_methods[] = {
+ {"lchown", missingos_lchown, METH_VARARGS, missingos_lchown__doc__},
+ {"mknod", missingos_mknod, METH_VARARGS, missingos_mknod__doc__},
+ {NULL, NULL} /* sentinel */
+};
+
+static PyObject *
+posix_error_with_allocated_filename(char* name)
+{
+ PyObject *rc = PyErr_SetFromErrnoWithFilename(PyExc_OSError, name);
+ PyMem_Free(name);
+ return rc;
+}
+
+static char missingos_lchown__doc__[] =
+"lchown(path, uid, gid) -> None\n\
+Change the owner and group id of path to the numeric uid and gid.";
+
+static PyObject *
+missingos_lchown(PyObject *self, PyObject *args) {
+ char *path = NULL;
+ int uid, gid;
+ int res;
+ if (!PyArg_ParseTuple(args, "etii:lchown",
+ Py_FileSystemDefaultEncoding, &path,
+ &uid, &gid))
+ return NULL;
+ res = lchown(path, (uid_t) uid, (gid_t) gid);
+ if (res < 0)
+ return posix_error_with_allocated_filename(path);
+ PyMem_Free(path);
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static char missingos_mknod__doc__[] =
+"mknod(path, type, major, minor [, mode=0600 ]) -> None\n\
+Create a special file. Mode fixed at 0600.\
+Note that for type 'p' major and minor are ignored.\
+";
+
+static PyObject *
+missingos_mknod(PyObject *self, PyObject *args) {
+ char *path = NULL;
+ char *type = NULL;
+ int major = 0;
+ int minor = 0;
+ mode_t real_mode;
+ dev_t real_dev;
+ int mode = 0600;
+
+ int res;
+ if (!PyArg_ParseTuple(args, "etsii|i:mknod",
+ Py_FileSystemDefaultEncoding, &path,
+ &type, &major, &minor, &mode))
+ return NULL;
+ /* type can be *one* of b, c, u, p */
+ /* major/minor are forbidden for p, reqd otherwise */
+ if (!strcmp(type, "p")) {
+ /* pipe */
+ if (major != 0 || minor != 0) {
+ return NULL;
+ }
+ real_mode = S_IFIFO;
+ major = 0;
+ minor = 0;
+ } else if (!strcmp(type, "b")) {
+ /* block */
+ real_mode = S_IFBLK;
+ } else if (!strcmp(type, "c")) {
+ real_mode = S_IFCHR;
+ /* char */
+ } else if (!strcmp(type, "u")) {
+ real_mode = S_IFCHR;
+ /* unbuffered char */
+ } else {
+ /* error */
+ PyErr_SetString(PyExc_ValueError, "type must be one of p,b,c,u");
+ return NULL;
+ }
+
+ real_mode |= mode;
+ real_dev = (major << 8) | minor;
+
+ /* use mode to modify real_mode */
+
+ res = mknod(path, real_mode, real_dev);
+ if (res < 0)
+ return posix_error_with_allocated_filename(path);
+ PyMem_Free(path);
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+
+DL_EXPORT(void)
+initmissingos(void) {
+ PyObject *m;
+
+ m = Py_InitModule4("missingos", missingos_methods,
+ missingos__doc__, (PyObject *)NULL,
+ PYTHON_API_VERSION);
+}
diff --git a/src/python-missingos/setup.cfg b/src/python-missingos/setup.cfg
new file mode 100644
index 000000000..8677f66f3
--- /dev/null
+++ b/src/python-missingos/setup.cfg
@@ -0,0 +1,8 @@
+# python-missingos
+# $Header: /var/cvsroot/gentoo-src/portage/src/python-missingos/setup.cfg,v 1.4.2.1 2004/10/22 16:53:30 carpaski Exp $
+
+[bdist_rpm]
+release = 1
+doc_files = ChangeLog
+ README
+python=python2
diff --git a/src/python-missingos/setup.py b/src/python-missingos/setup.py
new file mode 100755
index 000000000..b82e3e517
--- /dev/null
+++ b/src/python-missingos/setup.py
@@ -0,0 +1,24 @@
+#! /usr/bin/env python2.2
+# $Header: /var/cvsroot/gentoo-src/portage/src/python-missingos/setup.py,v 1.5.2.1 2004/10/22 16:53:30 carpaski Exp $
+
+from os import chdir, stat
+from distutils.core import setup, Extension
+
+setup (# Distribution meta-data
+ name = "python-missingos",
+ version = "0.2",
+ description = "",
+ author = "Jonathon D Nelson",
+ author_email = "jnelson@gentoo.org",
+ license = "",
+ long_description = \
+ '''''',
+ ext_modules = [ Extension(
+ "missingos",
+ ["missingos.c"],
+ libraries=[],
+ )
+ ],
+ url = "",
+ )
+