This repository was archived by the owner on Jan 25, 2023. It is now read-only.
forked from pythonnet/pythonnet
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpythonnet.py
More file actions
106 lines (79 loc) · 2.75 KB
/
pythonnet.py
File metadata and controls
106 lines (79 loc) · 2.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import io
import threading
import sys
class ThreadedDemuxerTextIO(io.TextIOBase):
"""Base class for text I/O.
This class provides a character and line based interface to stream
I/O. There is no readinto method because Python's character strings
are immutable. There is no public constructor.
"""
def __init__(self, original_text_io):
self._original_io = original_text_io;
self._threadToIo = {}
### Internal ###
def _get_current_io(self):
cur_thread_id = threading.get_ident()
if (cur_thread_id in self._threadToIo):
result = self._threadToIo[cur_thread_id]
return result;
return self._original_io
def _unsupported(self, name):
"""Internal: raise an OSError exception for unsupported operations."""
raise io.UnsupportedOperation("%s.%s() not supported" %
(self.__class__.__name__, name))
def read(self, size=-1):
return self._get_current_io().write(size)
def write(self, s):
return self._get_current_io().write(s)
def truncate(self, pos=None):
return self._get_current_io().truncate(pos)
def readline(self):
return self._get_current_io().readline()
def detach(self):
self._unsupported("detach")
@property
def cur_thread_io(self):
return self._get_current_io()
@cur_thread_io.setter
def cur_thread_io(self, value):
cur_thread_id = threading.get_ident()
self._threadToIo[cur_thread_id] = value
@property
def encoding(self):
return self._get_current_io().encoding
@property
def newlines(self):
return self._get_current_io().newlines
@property
def errors(self):
return self._get_current_io().errors
@property
def line_buffering(self):
return self._get_current_io().line_buffering
@property
def buffer(self):
return self._get_current_io().buffer
def seekable(self):
return self._get_current_io().seakable()
def readable(self):
return self._get_current_io().readable()
def writable(self):
return self._get_current_io().writable()
def flush(self):
return self._get_current_io().flush()
def close(self):
return self._get_current_io().close()
@property
def closed(self):
return self._get_current_io().closed
@property
def name(self):
return self._get_current_io().name
def fileno(self):
return self._get_current_io().fileno()
def isatty(self):
return self._get_current_io().isatty()
def tell(self):
return self._get_current_io().tell()
def seek(self, cookie, whence=0):
return self._get_current_io().seek(cookie, whence)