summaryrefslogtreecommitdiff
path: root/portato/eix
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.net>2009-07-26 02:54:41 +0200
committerRené 'Necoro' Neumann <necoro@necoro.net>2009-07-26 02:54:41 +0200
commit5a5c7536d307aa12c040f89b4d5048fcd8b1a1f6 (patch)
tree087127de84fe991c3c92942ac03e4ed1549622e6 /portato/eix
parentb8f45f026ace3df864efac5d49a62be4a0fc9eae (diff)
downloadportato-5a5c7536d307aa12c040f89b4d5048fcd8b1a1f6.tar.gz
portato-5a5c7536d307aa12c040f89b4d5048fcd8b1a1f6.tar.bz2
portato-5a5c7536d307aa12c040f89b4d5048fcd8b1a1f6.zip
Get rid of the self-implemented file-stuff. Use the normal python-API instead
Diffstat (limited to 'portato/eix')
-rw-r--r--portato/eix/eix_utils.pxd30
-rw-r--r--portato/eix/eix_utils.pyx57
2 files changed, 0 insertions, 87 deletions
diff --git a/portato/eix/eix_utils.pxd b/portato/eix/eix_utils.pxd
index a85a65e..39f60a9 100644
--- a/portato/eix/eix_utils.pxd
+++ b/portato/eix/eix_utils.pxd
@@ -9,39 +9,9 @@ cdef extern from "string.h":
size_t strlen (char* s)
char* strcpy (char* dest, char* src)
-cdef extern from "stdio.h":
-
- ctypedef struct FILE:
- pass
-
- FILE* c_fopen "fopen" (char* path, char* mode)
- int c_fclose "fclose" (FILE* f)
- int c_feof "feof" (FILE* f)
- int fread (void* buf, size_t size, size_t n, FILE* f)
-
- enum WHENCE:
- SEEK_SET
- SEEK_CUR
- SEEK_END
-
- int fseek (FILE* stream, long offset, WHENCE whence)
-
cdef extern from "Python.h":
- ctypedef struct PyObject:
- pass
-
void* PyMem_Malloc (size_t n)
void PyMem_Free (void* p)
cdef:
- struct File:
- FILE* file
- char* name
-
- File* fopen (char* path, char* mode) except NULL
- void fclose (File* f)
-
- void ffree (void* p)
- char* fget (File* f, size_t n) except NULL
-
char* strdup (char* other) except NULL
diff --git a/portato/eix/eix_utils.pyx b/portato/eix/eix_utils.pyx
index 57fa5d7..0ea9603 100644
--- a/portato/eix/eix_utils.pyx
+++ b/portato/eix/eix_utils.pyx
@@ -1,15 +1,3 @@
-class EndOfFileError (IOError):
-
- def __init__ (self, filename = None):
- self.message = "End of file reached while not expecting it"
- self.filename = filename
-
- def __str__ (self):
- if self.filename is not None:
- return "%s: %s" % (self.message, self.filename)
- else:
- return self.message
-
cdef char* strdup (char * other) except NULL:
cdef size_t len
cdef char* new
@@ -25,48 +13,3 @@ cdef char* strdup (char * other) except NULL:
return NULL
return strcpy(new, other)
-
-
-cdef File* fopen (char* path, char* mode) except NULL:
- cdef File* f
-
- f = <File*> PyMem_Malloc(sizeof(File))
-
- if f is NULL:
- raise MemoryError, "Malloc of File"
- return NULL
-
- f.file = c_fopen(path, mode)
-
- if f.file is NULL:
- raise IOError, (errno, strerror(errno), path)
- return NULL
-
- f.name = strdup(path)
-
- if f.name is NULL:
- return NULL
-
- return f
-
-cdef void fclose (File* f):
- c_fclose(f.file)
- ffree(f.name)
- PyMem_Free(f)
-
-cdef void ffree (void* p):
- PyMem_Free(p)
-
-cdef char* fget (File* f, size_t n) except NULL:
- cdef char* buf
- buf = <char*> PyMem_Malloc(n)
-
- if buf is NULL:
- raise MemoryError, "Malloc"
- return NULL
-
- if (fread(buf, 1, n, f.file) != n):
- PyMem_Free(buf)
- raise EndOfFileError, f.name
-
- return buf