mirror of
https://codeberg.org/scip/pcp.git
synced 2025-12-17 12:00:56 +01:00
started with py crypto, enhanced raw.py generation, better autoconf integration
This commit is contained in:
27
bindings/py/pypcp/stream.py
Normal file
27
bindings/py/pypcp/stream.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from pypcp.dll import *
|
||||
|
||||
|
||||
class Stream(object):
|
||||
def __init__(self, string=None, file=None):
|
||||
if file:
|
||||
fd = open(file, 'r')
|
||||
self._stream = libpcp.ps_new_file(fd)
|
||||
elif string:
|
||||
buf = libpcp.buffer_new_buf('inbuf', string, len(string))
|
||||
self._stream = libpcp.ps_new_inbuffer(buf)
|
||||
else:
|
||||
self._stream = libpcp.ps_new_outbuffer()
|
||||
|
||||
def __del__(self):
|
||||
libpcp.ps_close(self._stream)
|
||||
|
||||
|
||||
class Buffer(object):
|
||||
def __init__(self, string=None):
|
||||
if string:
|
||||
self._buffer = libpcp.buffer_new_buf('pybuf', string, len(string))
|
||||
else:
|
||||
self._buffer = libpcp.buffer_new(32, 'pybuf')
|
||||
|
||||
def __del__(self):
|
||||
libpcp.buffer_free(self._buffer)
|
||||
Reference in New Issue
Block a user