pyvguicom 1.1.1__py3-none-any.whl → 1.1.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pyvguicom might be problematic. Click here for more details.
- pyvguicom/docs/__index__.py +0 -0
- pyvguicom/docs/browsewin.html +956 -0
- pyvguicom/docs/htmledit.html +903 -0
- pyvguicom/docs/pgbox.html +2470 -0
- pyvguicom/docs/pgbutt.html +727 -0
- pyvguicom/docs/pgentry.html +1024 -0
- pyvguicom/docs/pggui.html +5476 -0
- pyvguicom/docs/pgsel.html +1539 -0
- pyvguicom/docs/pgsimp.html +1048 -0
- pyvguicom/docs/pgtextview.html +2421 -0
- pyvguicom/docs/pgutils.html +2664 -0
- pyvguicom/docs/pgwkit.html +2277 -0
- pyvguicom/docs/sutil.html +907 -0
- pyvguicom/pggui.py +1 -1
- {pyvguicom-1.1.1.dist-info → pyvguicom-1.1.2.dist-info}/METADATA +8 -11
- {pyvguicom-1.1.1.dist-info → pyvguicom-1.1.2.dist-info}/RECORD +18 -5
- {pyvguicom-1.1.1.dist-info → pyvguicom-1.1.2.dist-info}/WHEEL +0 -0
- {pyvguicom-1.1.1.dist-info → pyvguicom-1.1.2.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,2664 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
|
|
6
|
+
<meta name="generator" content="pdoc 0.10.0" />
|
|
7
|
+
<title>pgutils API documentation</title>
|
|
8
|
+
<meta name="description" content="" />
|
|
9
|
+
<link rel="preload stylesheet" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/11.0.1/sanitize.min.css" integrity="sha256-PK9q560IAAa6WVRRh76LtCaI8pjTJ2z11v0miyNNjrs=" crossorigin>
|
|
10
|
+
<link rel="preload stylesheet" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/11.0.1/typography.min.css" integrity="sha256-7l/o7C8jubJiy74VsKTidCy1yBkRtiUGbVkYBylBqUg=" crossorigin>
|
|
11
|
+
<link rel="stylesheet preload" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/styles/github.min.css" crossorigin>
|
|
12
|
+
<style>:root{--highlight-color:#fe9}.flex{display:flex !important}body{line-height:1.5em}#content{padding:20px}#sidebar{padding:30px;overflow:hidden}#sidebar > *:last-child{margin-bottom:2cm}.http-server-breadcrumbs{font-size:130%;margin:0 0 15px 0}#footer{font-size:.75em;padding:5px 30px;border-top:1px solid #ddd;text-align:right}#footer p{margin:0 0 0 1em;display:inline-block}#footer p:last-child{margin-right:30px}h1,h2,h3,h4,h5{font-weight:300}h1{font-size:2.5em;line-height:1.1em}h2{font-size:1.75em;margin:1em 0 .50em 0}h3{font-size:1.4em;margin:25px 0 10px 0}h4{margin:0;font-size:105%}h1:target,h2:target,h3:target,h4:target,h5:target,h6:target{background:var(--highlight-color);padding:.2em 0}a{color:#058;text-decoration:none;transition:color .3s ease-in-out}a:hover{color:#e82}.title code{font-weight:bold}h2[id^="header-"]{margin-top:2em}.ident{color:#900}pre code{background:#f8f8f8;font-size:.8em;line-height:1.4em}code{background:#f2f2f1;padding:1px 4px;overflow-wrap:break-word}h1 code{background:transparent}pre{background:#f8f8f8;border:0;border-top:1px solid #ccc;border-bottom:1px solid #ccc;margin:1em 0;padding:1ex}#http-server-module-list{display:flex;flex-flow:column}#http-server-module-list div{display:flex}#http-server-module-list dt{min-width:10%}#http-server-module-list p{margin-top:0}.toc ul,#index{list-style-type:none;margin:0;padding:0}#index code{background:transparent}#index h3{border-bottom:1px solid #ddd}#index ul{padding:0}#index h4{margin-top:.6em;font-weight:bold}@media (min-width:200ex){#index .two-column{column-count:2}}@media (min-width:300ex){#index .two-column{column-count:3}}dl{margin-bottom:2em}dl dl:last-child{margin-bottom:4em}dd{margin:0 0 1em 3em}#header-classes + dl > dd{margin-bottom:3em}dd dd{margin-left:2em}dd p{margin:10px 0}.name{background:#eee;font-weight:bold;font-size:.85em;padding:5px 10px;display:inline-block;min-width:40%}.name:hover{background:#e0e0e0}dt:target .name{background:var(--highlight-color)}.name > span:first-child{white-space:nowrap}.name.class > span:nth-child(2){margin-left:.4em}.inherited{color:#999;border-left:5px solid #eee;padding-left:1em}.inheritance em{font-style:normal;font-weight:bold}.desc h2{font-weight:400;font-size:1.25em}.desc h3{font-size:1em}.desc dt code{background:inherit}.source summary,.git-link-div{color:#666;text-align:right;font-weight:400;font-size:.8em;text-transform:uppercase}.source summary > *{white-space:nowrap;cursor:pointer}.git-link{color:inherit;margin-left:1em}.source pre{max-height:500px;overflow:auto;margin:0}.source pre code{font-size:12px;overflow:visible}.hlist{list-style:none}.hlist li{display:inline}.hlist li:after{content:',\2002'}.hlist li:last-child:after{content:none}.hlist .hlist{display:inline;padding-left:1em}img{max-width:100%}td{padding:0 .5em}.admonition{padding:.1em .5em;margin-bottom:1em}.admonition-title{font-weight:bold}.admonition.note,.admonition.info,.admonition.important{background:#aef}.admonition.todo,.admonition.versionadded,.admonition.tip,.admonition.hint{background:#dfd}.admonition.warning,.admonition.versionchanged,.admonition.deprecated{background:#fd4}.admonition.error,.admonition.danger,.admonition.caution{background:lightpink}</style>
|
|
13
|
+
<style media="screen and (min-width: 700px)">@media screen and (min-width:700px){#sidebar{width:30%;height:100vh;overflow:auto;position:sticky;top:0}#content{width:70%;max-width:100ch;padding:3em 4em;border-left:1px solid #ddd}pre code{font-size:1em}.item .name{font-size:1em}main{display:flex;flex-direction:row-reverse;justify-content:flex-end}.toc ul ul,#index ul{padding-left:1.5em}.toc > ul > li{margin-top:.5em}}</style>
|
|
14
|
+
<style media="print">@media print{#sidebar h1{page-break-before:always}.source{display:none}}@media print{*{background:transparent !important;color:#000 !important;box-shadow:none !important;text-shadow:none !important}a[href]:after{content:" (" attr(href) ")";font-size:90%}a[href][title]:after{content:none}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100% !important}@page{margin:0.5cm}p,h2,h3{orphans:3;widows:3}h1,h2,h3,h4,h5,h6{page-break-after:avoid}}</style>
|
|
15
|
+
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/highlight.min.js" integrity="sha256-Uv3H6lx7dJmRfRvH8TH6kJD1TSK1aFcwgx+mdg3epi8=" crossorigin></script>
|
|
16
|
+
<script>window.addEventListener('DOMContentLoaded', () => hljs.initHighlighting())</script>
|
|
17
|
+
</head>
|
|
18
|
+
<body>
|
|
19
|
+
<main>
|
|
20
|
+
<article id="content">
|
|
21
|
+
<header>
|
|
22
|
+
<h1 class="title">Module <code>pgutils</code></h1>
|
|
23
|
+
</header>
|
|
24
|
+
<section id="section-intro">
|
|
25
|
+
<details class="source">
|
|
26
|
+
<summary>
|
|
27
|
+
<span>Expand source code</span>
|
|
28
|
+
</summary>
|
|
29
|
+
<pre><code class="python">#!/usr/bin/python
|
|
30
|
+
|
|
31
|
+
# pylint: disable=C0103
|
|
32
|
+
# pylint: disable=C0209
|
|
33
|
+
# pylint: disable=C0321
|
|
34
|
+
|
|
35
|
+
import os, sys, getopt, string, math
|
|
36
|
+
import random, time, traceback, stat
|
|
37
|
+
import platform
|
|
38
|
+
|
|
39
|
+
#import warmings
|
|
40
|
+
|
|
41
|
+
if sys.version_info.major < 3:
|
|
42
|
+
pass
|
|
43
|
+
else:
|
|
44
|
+
import inspect
|
|
45
|
+
if inspect.isbuiltin(time.process_time):
|
|
46
|
+
time.clock = time.process_time
|
|
47
|
+
|
|
48
|
+
''' General utility fiunctions '''
|
|
49
|
+
|
|
50
|
+
import gi
|
|
51
|
+
gi.require_version("Gtk", "3.0")
|
|
52
|
+
from gi.repository import Gtk
|
|
53
|
+
from gi.repository import Gdk
|
|
54
|
+
from gi.repository import GObject
|
|
55
|
+
from gi.repository import GdkPixbuf
|
|
56
|
+
|
|
57
|
+
# ------------------------------------------------------------------------
|
|
58
|
+
# Resolve path name
|
|
59
|
+
|
|
60
|
+
def respath(fname):
|
|
61
|
+
|
|
62
|
+
try:
|
|
63
|
+
ppp = str.split(os.environ['PATH'], os.pathsep)
|
|
64
|
+
for aa in ppp:
|
|
65
|
+
ttt = aa + os.sep + fname
|
|
66
|
+
if os.path.isfile(str(ttt)):
|
|
67
|
+
return ttt
|
|
68
|
+
except:
|
|
69
|
+
print ("Cannot resolve path", fname, sys.exc_info())
|
|
70
|
+
return None
|
|
71
|
+
|
|
72
|
+
# ------------------------------------------------------------------------
|
|
73
|
+
# Color conversions
|
|
74
|
+
|
|
75
|
+
def str2col(strx):
|
|
76
|
+
ccc = str2float(strx)
|
|
77
|
+
return float2col(ccc)
|
|
78
|
+
|
|
79
|
+
def str2float( col):
|
|
80
|
+
return ( float(int(col[1:3], base=16)) / 256,
|
|
81
|
+
float(int(col[3:5], base=16)) / 256, \
|
|
82
|
+
float(int(col[5:7], base=16)) / 256 )
|
|
83
|
+
|
|
84
|
+
def float2col(col):
|
|
85
|
+
aa = min(col[0], 1.)
|
|
86
|
+
bb = min(col[1], 1.)
|
|
87
|
+
cc = min(col[2], 1.)
|
|
88
|
+
return Gdk.Color(aa * 65535, bb * 65535, cc * 65535)
|
|
89
|
+
|
|
90
|
+
def float2str(col):
|
|
91
|
+
aa = min(col[0], 1.)
|
|
92
|
+
bb = min(col[1], 1.)
|
|
93
|
+
cc = min(col[2], 1.)
|
|
94
|
+
strx = "#%02x%02x%02x" % (aa * 256, \
|
|
95
|
+
bb * 256, cc * 256)
|
|
96
|
+
return strx
|
|
97
|
+
|
|
98
|
+
def col2float(col):
|
|
99
|
+
rrr = [float(col.red) / 65535,
|
|
100
|
+
float(col.green) / 65535,
|
|
101
|
+
float(col.blue) / 65535]
|
|
102
|
+
return rrr
|
|
103
|
+
|
|
104
|
+
def rgb2str(icol):
|
|
105
|
+
strx = "#%02x%02x%02x" % (int(icol.red) & 0xff, \
|
|
106
|
+
int(icol.green) & 0xff, int(icol.blue) & 0xff)
|
|
107
|
+
return strx
|
|
108
|
+
|
|
109
|
+
def col2str(icol):
|
|
110
|
+
strx = "#%02x%02x%02x" % (int(icol.red / 255), \
|
|
111
|
+
int(icol.green / 255), int(icol.blue / 255))
|
|
112
|
+
return strx
|
|
113
|
+
|
|
114
|
+
def rgb2col(icol):
|
|
115
|
+
#print "rgb2col", icol
|
|
116
|
+
col = [0, 0, 0]
|
|
117
|
+
col[0] = float(icol.red) / 256
|
|
118
|
+
col[1] = float(icol.green) / 256
|
|
119
|
+
col[2] = float(icol.blue) / 256
|
|
120
|
+
return col
|
|
121
|
+
|
|
122
|
+
def put_debug2(xstr):
|
|
123
|
+
try:
|
|
124
|
+
if os.isatty(sys.stdout.fileno()):
|
|
125
|
+
print( xstr)
|
|
126
|
+
else:
|
|
127
|
+
#syslog.syslog(xstr)
|
|
128
|
+
pass
|
|
129
|
+
print(xstr, file=sys.stderr)
|
|
130
|
+
|
|
131
|
+
except:
|
|
132
|
+
print( "Failed on debug output.")
|
|
133
|
+
print( sys.exc_info())
|
|
134
|
+
|
|
135
|
+
def put_exception(xstr):
|
|
136
|
+
|
|
137
|
+
cumm = xstr + " "
|
|
138
|
+
a,b,c = sys.exc_info()
|
|
139
|
+
if a != None:
|
|
140
|
+
cumm += str(a) + " " + str(b) + "\n"
|
|
141
|
+
try:
|
|
142
|
+
#cumm += str(traceback.format_tb(c, 10))
|
|
143
|
+
ttt = traceback.extract_tb(c)
|
|
144
|
+
for aa in ttt:
|
|
145
|
+
cumm += "File: " + os.path.basename(aa[0]) + \
|
|
146
|
+
" Line: " + str(aa[1]) + "\n" + \
|
|
147
|
+
" Context: " + aa[2] + " -> " + aa[3] + "\n"
|
|
148
|
+
except:
|
|
149
|
+
print( "Could not print trace stack. ", sys.exc_info())
|
|
150
|
+
|
|
151
|
+
print(cumm)
|
|
152
|
+
#syslog.syslog("%s %s %s" % (xstr, a, b))
|
|
153
|
+
|
|
154
|
+
def decode_bits(numx):
|
|
155
|
+
mask = 0x80
|
|
156
|
+
retx = ""
|
|
157
|
+
for aa in range(8):
|
|
158
|
+
strx = "0"
|
|
159
|
+
if numx & mask:
|
|
160
|
+
strx = "1"
|
|
161
|
+
retx += "B%d=%s " % (7-aa, strx)
|
|
162
|
+
if aa == 3:
|
|
163
|
+
retx += "\r"
|
|
164
|
+
mask >>= 1
|
|
165
|
+
|
|
166
|
+
return retx
|
|
167
|
+
|
|
168
|
+
# ------------------------------------------------------------------------
|
|
169
|
+
# Remove non printables
|
|
170
|
+
|
|
171
|
+
def clean_str(strx):
|
|
172
|
+
|
|
173
|
+
stry = ""
|
|
174
|
+
for aa in range(len(strx)):
|
|
175
|
+
if strx[aa] == '\r':
|
|
176
|
+
stry += "\\r"
|
|
177
|
+
elif strx[aa] == '\n':
|
|
178
|
+
stry += "\\n"
|
|
179
|
+
elif strx[aa] == '\0':
|
|
180
|
+
stry += "\\0"
|
|
181
|
+
else:
|
|
182
|
+
stry += strx[aa]
|
|
183
|
+
return stry
|
|
184
|
+
|
|
185
|
+
def clean_str2(strx):
|
|
186
|
+
stry = ""
|
|
187
|
+
skip = False
|
|
188
|
+
for aa in range(len(strx)):
|
|
189
|
+
if skip:
|
|
190
|
+
skip = False
|
|
191
|
+
continue
|
|
192
|
+
if strx[aa] == '\\' and strx[aa+1] == 'r':
|
|
193
|
+
skip = True
|
|
194
|
+
if strx[aa] == '\\' and strx[aa+1] == 'n':
|
|
195
|
+
skip = True
|
|
196
|
+
if strx[aa] == '\\' and strx[aa+1] == '0':
|
|
197
|
+
skip = True
|
|
198
|
+
pass
|
|
199
|
+
else:
|
|
200
|
+
stry += strx[aa]
|
|
201
|
+
return stry
|
|
202
|
+
|
|
203
|
+
# This is crafted to Py2 so has clock with the same name
|
|
204
|
+
|
|
205
|
+
start_time = time.clock()
|
|
206
|
+
|
|
207
|
+
def get_time():
|
|
208
|
+
|
|
209
|
+
global start_time
|
|
210
|
+
if sys.version_info.major < 3:
|
|
211
|
+
return time.clock() - start_time
|
|
212
|
+
else:
|
|
213
|
+
return time.process_time()
|
|
214
|
+
|
|
215
|
+
def get_realtime():
|
|
216
|
+
|
|
217
|
+
frac = math.modf(float(get_time()))
|
|
218
|
+
zzz = "%.02f" % frac[0]
|
|
219
|
+
sss = "%s%s" % (time.strftime("%02I:%02M:%02S"), zzz[1:])
|
|
220
|
+
return sss
|
|
221
|
+
|
|
222
|
+
# Get a list of ports
|
|
223
|
+
|
|
224
|
+
'''
|
|
225
|
+
def serial_ports():
|
|
226
|
+
|
|
227
|
+
""" Lists serial port names
|
|
228
|
+
:raises EnvironmentError:
|
|
229
|
+
On unsupported or unknown platforms
|
|
230
|
+
:returns:
|
|
231
|
+
A list of the serial ports available on the system
|
|
232
|
+
"""
|
|
233
|
+
|
|
234
|
+
ports = []
|
|
235
|
+
if sys.platform.startswith('win'):
|
|
236
|
+
ports2 = serial.tools.list_ports.comports()
|
|
237
|
+
for aa in ports2:
|
|
238
|
+
ports.append(aa[0])
|
|
239
|
+
elif sys.platform.startswith('linux') or sys.platform.startswith('cygwin'):
|
|
240
|
+
# this excludes your current terminal "/dev/tty"
|
|
241
|
+
ports = glob.glob('/dev/ttyU[A-Za-z]*')
|
|
242
|
+
elif sys.platform.startswith('darwin'):
|
|
243
|
+
ports = glob.glob('/dev/tty.*')
|
|
244
|
+
else:
|
|
245
|
+
# rely on serial module
|
|
246
|
+
ports2 = serial.tools.list_ports.comports()
|
|
247
|
+
for aa in ports2:
|
|
248
|
+
ports.append(aa[0])
|
|
249
|
+
#raise EnvironmentError('Unsupported platform')
|
|
250
|
+
|
|
251
|
+
#print ("ports", ports)
|
|
252
|
+
result = []
|
|
253
|
+
for port in ports:
|
|
254
|
+
try:
|
|
255
|
+
# no testing performed any more
|
|
256
|
+
#s = serial.Serial(port)
|
|
257
|
+
#s.close()
|
|
258
|
+
result.append(port)
|
|
259
|
+
except (OSError, serial.SerialException):
|
|
260
|
+
pass
|
|
261
|
+
#print ("result", result)
|
|
262
|
+
return result
|
|
263
|
+
'''
|
|
264
|
+
|
|
265
|
+
# ------------------------------------------------------------------------
|
|
266
|
+
# Convert octal string to integer
|
|
267
|
+
|
|
268
|
+
def oct2int(strx):
|
|
269
|
+
retx = 0
|
|
270
|
+
for aa in strx:
|
|
271
|
+
num = ord(aa) - ord("0")
|
|
272
|
+
if num > 7 or num < 0:
|
|
273
|
+
break
|
|
274
|
+
retx <<= 3; retx += num
|
|
275
|
+
#print "oct:", strx, "int:", retx
|
|
276
|
+
return retx
|
|
277
|
+
|
|
278
|
+
# ------------------------------------------------------------------------
|
|
279
|
+
# Convert unicode sequence to unicode char
|
|
280
|
+
|
|
281
|
+
def uni(xtab):
|
|
282
|
+
|
|
283
|
+
#print str.format("{0:b}", xtab[0])
|
|
284
|
+
try:
|
|
285
|
+
unichr
|
|
286
|
+
except NameError:
|
|
287
|
+
unichr = chr
|
|
288
|
+
|
|
289
|
+
cc = 0
|
|
290
|
+
try:
|
|
291
|
+
if xtab[0] & 0xe0 == 0xc0: # two numbers
|
|
292
|
+
cc = (xtab[0] & 0x1f) << 6
|
|
293
|
+
cc += (xtab[1] & 0x3f)
|
|
294
|
+
elif xtab[0] & 0xf0 == 0xe0: # three numbers
|
|
295
|
+
cc = (xtab[0] & 0x0f) << 12
|
|
296
|
+
cc += (xtab[1] & 0x3f) << 6
|
|
297
|
+
cc += (xtab[2] & 0x3f)
|
|
298
|
+
elif xtab[0] & 0xf8 == 0xf0: # four numbers
|
|
299
|
+
cc = (xtab[0] & 0x0e) << 18
|
|
300
|
+
cc += (xtab[1] & 0x3f) << 12
|
|
301
|
+
cc += (xtab[2] & 0x3f) << 6
|
|
302
|
+
cc += (xtab[3] & 0x3f)
|
|
303
|
+
elif xtab[0] & 0xfc == 0xf8: # five numbers
|
|
304
|
+
cc = (xtab[0] & 0x03) << 24
|
|
305
|
+
cc += (xtab[1] & 0x3f) << 18
|
|
306
|
+
cc += (xtab[2] & 0x3f) << 12
|
|
307
|
+
cc += (xtab[3] & 0x3f) << 6
|
|
308
|
+
cc += (xtab[4] & 0x3f)
|
|
309
|
+
elif xtab[0] & 0xfe == 0xf8: # six numbers
|
|
310
|
+
cc = (xtab[0] & 0x01) << 30
|
|
311
|
+
cc += (xtab[1] & 0x3f) << 24
|
|
312
|
+
cc += (xtab[2] & 0x3f) << 18
|
|
313
|
+
cc += (xtab[3] & 0x3f) << 12
|
|
314
|
+
cc += (xtab[4] & 0x3f) << 6
|
|
315
|
+
cc += (xtab[5] & 0x3f)
|
|
316
|
+
|
|
317
|
+
ccc = unichr(cc)
|
|
318
|
+
except:
|
|
319
|
+
pass
|
|
320
|
+
|
|
321
|
+
return ccc
|
|
322
|
+
|
|
323
|
+
def is_ascii(strx):
|
|
324
|
+
|
|
325
|
+
pos = 0; lenx = len(strx)
|
|
326
|
+
while True:
|
|
327
|
+
if pos >= lenx:
|
|
328
|
+
break
|
|
329
|
+
|
|
330
|
+
chh = strx[pos]
|
|
331
|
+
#print (ord(chh))
|
|
332
|
+
if ord(chh) > 127:
|
|
333
|
+
#print (ord(chh))
|
|
334
|
+
if pos == 0: pos += 1
|
|
335
|
+
return pos
|
|
336
|
+
pos+= 1
|
|
337
|
+
|
|
338
|
+
return 0
|
|
339
|
+
|
|
340
|
+
def kill_non_ascii(strx):
|
|
341
|
+
|
|
342
|
+
str2 = ""
|
|
343
|
+
pos = 0; lenx = len(strx)
|
|
344
|
+
while True:
|
|
345
|
+
if pos >= lenx:
|
|
346
|
+
break
|
|
347
|
+
|
|
348
|
+
chh = strx[pos]
|
|
349
|
+
#print (ord(chh))
|
|
350
|
+
if ord(chh) <= 127:
|
|
351
|
+
str2 += chh
|
|
352
|
+
else:
|
|
353
|
+
str2 += "*"
|
|
354
|
+
pos+= 1
|
|
355
|
+
|
|
356
|
+
return str2
|
|
357
|
+
|
|
358
|
+
# ------------------------------------------------------------------------
|
|
359
|
+
# Unescape unicode into displayable sequence
|
|
360
|
+
|
|
361
|
+
xtab = []; xtablen = 0
|
|
362
|
+
|
|
363
|
+
def unescape(strx):
|
|
364
|
+
|
|
365
|
+
#print " x[" + strx + "]x "
|
|
366
|
+
|
|
367
|
+
global xtab, xtablen
|
|
368
|
+
retx = u""; pos = 0; lenx = len(strx)
|
|
369
|
+
|
|
370
|
+
while True:
|
|
371
|
+
if pos >= lenx:
|
|
372
|
+
break
|
|
373
|
+
|
|
374
|
+
chh = strx[pos]
|
|
375
|
+
|
|
376
|
+
if chh == '\\':
|
|
377
|
+
#print "backslash", strx[pos:]
|
|
378
|
+
pos2 = pos + 1; strx2 = ""
|
|
379
|
+
while True:
|
|
380
|
+
if pos2 >= lenx:
|
|
381
|
+
# See if we accumulated anything
|
|
382
|
+
if strx2 != "":
|
|
383
|
+
xtab.append(oct2int(strx2))
|
|
384
|
+
if len(xtab) > 0:
|
|
385
|
+
#print "final:", xtab
|
|
386
|
+
if xtablen == len(xtab):
|
|
387
|
+
retx += uni(xtab)
|
|
388
|
+
xtab = []; xtablen = 0
|
|
389
|
+
pos = pos2 - 1
|
|
390
|
+
break
|
|
391
|
+
chh2 = strx[pos2]
|
|
392
|
+
if chh2 >= "0" and chh2 <= "7":
|
|
393
|
+
strx2 += chh2
|
|
394
|
+
else:
|
|
395
|
+
#print "strx2: '" + strx2 + "'"
|
|
396
|
+
if strx2 != "":
|
|
397
|
+
octx = oct2int(strx2)
|
|
398
|
+
if xtablen == 0:
|
|
399
|
+
if octx & 0xe0 == 0xc0:
|
|
400
|
+
#print "two ",str.format("{0:b}", octx)
|
|
401
|
+
xtablen = 2
|
|
402
|
+
xtab.append(octx)
|
|
403
|
+
elif octx & 0xf0 == 0xe0: # three numbers
|
|
404
|
+
#print "three ",str.format("{0:b}", octx)
|
|
405
|
+
xtablen = 3
|
|
406
|
+
xtab.append(octx)
|
|
407
|
+
elif octx & 0xf8 == 0xf0: # four numbers
|
|
408
|
+
print("four ",str.format("{0:b}", octx))
|
|
409
|
+
xtablen = 4
|
|
410
|
+
xtab.append(octx)
|
|
411
|
+
elif octx & 0xfc == 0xf8: # five numbers
|
|
412
|
+
print("five ",str.format("{0:b}", octx))
|
|
413
|
+
xtablen = 5
|
|
414
|
+
xtab.append(octx)
|
|
415
|
+
elif octx & 0xfe == 0xfc: # six numbers
|
|
416
|
+
print("six ",str.format("{0:b}", octx))
|
|
417
|
+
xtablen = 6
|
|
418
|
+
xtab.append(octx)
|
|
419
|
+
else:
|
|
420
|
+
#print "other ",str.format("{0:b}", octx)
|
|
421
|
+
#retx += unichr(octx)
|
|
422
|
+
retx += chr(octx)
|
|
423
|
+
else:
|
|
424
|
+
xtab.append(octx)
|
|
425
|
+
#print "data ",str.format("{0:b}", octx)
|
|
426
|
+
if xtablen == len(xtab):
|
|
427
|
+
retx += uni(xtab)
|
|
428
|
+
xtab = []; xtablen = 0
|
|
429
|
+
|
|
430
|
+
pos = pos2 - 1
|
|
431
|
+
break
|
|
432
|
+
pos2 += 1
|
|
433
|
+
else:
|
|
434
|
+
|
|
435
|
+
if xtablen == len(xtab) and xtablen != 0:
|
|
436
|
+
retx += uni(xtab)
|
|
437
|
+
xtab=[]; xtablen = 0
|
|
438
|
+
|
|
439
|
+
try:
|
|
440
|
+
retx += chh
|
|
441
|
+
except:
|
|
442
|
+
pass
|
|
443
|
+
pos += 1
|
|
444
|
+
|
|
445
|
+
#print "y[" + retx + "]y"
|
|
446
|
+
return retx
|
|
447
|
+
|
|
448
|
+
# ------------------------------------------------------------------------
|
|
449
|
+
# Give the user the usual options for true / false - 1 / 0 - y / n
|
|
450
|
+
|
|
451
|
+
def isTrue(strx):
|
|
452
|
+
if strx == "1": return True
|
|
453
|
+
if strx == "0": return False
|
|
454
|
+
uuu = strx.upper()
|
|
455
|
+
if uuu == "TRUE": return True
|
|
456
|
+
if uuu == "FALSE": return False
|
|
457
|
+
if uuu == "Y": return True
|
|
458
|
+
if uuu == "N": return False
|
|
459
|
+
return False
|
|
460
|
+
|
|
461
|
+
# ------------------------------------------------------------------------
|
|
462
|
+
# Return True if file exists
|
|
463
|
+
|
|
464
|
+
def isfile(fname):
|
|
465
|
+
|
|
466
|
+
try:
|
|
467
|
+
ss = os.stat(fname)
|
|
468
|
+
except:
|
|
469
|
+
return False
|
|
470
|
+
|
|
471
|
+
if stat.S_ISREG(ss[stat.ST_MODE]):
|
|
472
|
+
return True
|
|
473
|
+
return False
|
|
474
|
+
|
|
475
|
+
def put_exception2_old(xstr):
|
|
476
|
+
|
|
477
|
+
cumm = xstr + " "
|
|
478
|
+
a,b,c = sys.exc_info()
|
|
479
|
+
if a != None:
|
|
480
|
+
cumm += str(a) + " " + str(b) + "\n"
|
|
481
|
+
try:
|
|
482
|
+
#cumm += str(traceback.format_tb(c, 10))
|
|
483
|
+
ttt = traceback.extract_tb(c)
|
|
484
|
+
for aa in ttt:
|
|
485
|
+
cumm += "File: " + os.path.basename(aa[0]) + \
|
|
486
|
+
" Line: " + str(aa[1]) + "\n" + \
|
|
487
|
+
" Context: " + aa[2] + " -> " + aa[3] + "\n"
|
|
488
|
+
except:
|
|
489
|
+
print( "Could not print trace stack. ", sys.exc_info())
|
|
490
|
+
|
|
491
|
+
put_debug2(cumm)
|
|
492
|
+
#syslog.syslog("%s %s %s" % (xstr, a, b))
|
|
493
|
+
|
|
494
|
+
# Create a one way hash of a name. Not cryptographically secure,
|
|
495
|
+
# but it can make a good unique name in hex.
|
|
496
|
+
|
|
497
|
+
def hash_name(strx):
|
|
498
|
+
|
|
499
|
+
lenx = len(strx); hashx = int(0)
|
|
500
|
+
for aa in strx:
|
|
501
|
+
bb = ord(aa)
|
|
502
|
+
hashx += int((bb << 12) + bb)
|
|
503
|
+
hashx &= 0xffffffff
|
|
504
|
+
hashx = int(hashx << 8) + int(hashx >> 8)
|
|
505
|
+
hashx &= 0xffffffff
|
|
506
|
+
|
|
507
|
+
return "%x" % hashx
|
|
508
|
+
|
|
509
|
+
# Expand tabs in string
|
|
510
|
+
def untab_str(strx, tabstop = 4):
|
|
511
|
+
res = ""; idx = 0; cnt = 0
|
|
512
|
+
xlen = len(strx)
|
|
513
|
+
while True:
|
|
514
|
+
if idx >= xlen: break
|
|
515
|
+
chh = strx[idx]
|
|
516
|
+
if chh == "\t":
|
|
517
|
+
# Generate string
|
|
518
|
+
spaces = tabstop - (cnt % tabstop)
|
|
519
|
+
ttt = ""
|
|
520
|
+
for aa in range(spaces):
|
|
521
|
+
ttt += " "
|
|
522
|
+
res += ttt
|
|
523
|
+
cnt += spaces
|
|
524
|
+
else:
|
|
525
|
+
cnt += 1
|
|
526
|
+
res += chh
|
|
527
|
+
idx += 1
|
|
528
|
+
return res
|
|
529
|
+
|
|
530
|
+
# ------------------------------------------------------------------------
|
|
531
|
+
# Get am pm version of a number
|
|
532
|
+
|
|
533
|
+
def ampmstr(bb):
|
|
534
|
+
|
|
535
|
+
dd = "AM"
|
|
536
|
+
if bb == 12:
|
|
537
|
+
dd = "PM"
|
|
538
|
+
elif bb > 12:
|
|
539
|
+
bb -= 12
|
|
540
|
+
dd = "PM"
|
|
541
|
+
return "%02d %s" % (bb, dd)
|
|
542
|
+
|
|
543
|
+
# It's totally optional to do this, you could just manually insert icons
|
|
544
|
+
# and have them not be themeable, especially if you never expect people
|
|
545
|
+
# to theme your app.
|
|
546
|
+
|
|
547
|
+
def register_stock_icons():
|
|
548
|
+
''' This function registers our custom toolbar icons, so they
|
|
549
|
+
can be themed.
|
|
550
|
+
'''
|
|
551
|
+
#items = [('demo-gtk-logo', '_GTK!', 0, 0, '')]
|
|
552
|
+
# Register our stock items
|
|
553
|
+
#Gtk.stock_add(items)
|
|
554
|
+
|
|
555
|
+
# Add our custom icon factory to the list of defaults
|
|
556
|
+
factory = Gtk.IconFactory()
|
|
557
|
+
factory.add_default()
|
|
558
|
+
|
|
559
|
+
img_dir = os.path.join(os.path.dirname(__file__), 'images')
|
|
560
|
+
img_path = os.path.join(img_dir, 'gtk-logo-rgb.gif')
|
|
561
|
+
|
|
562
|
+
#print( img_path)
|
|
563
|
+
try:
|
|
564
|
+
#pixbuf = Gdk.pixbuf_new_from_file(img_path)
|
|
565
|
+
# Register icon to accompany stock item
|
|
566
|
+
|
|
567
|
+
# The gtk-logo-rgb icon has a white background, make it transparent
|
|
568
|
+
# the call is wrapped to (gboolean, guchar, guchar, guchar)
|
|
569
|
+
#transparent = pixbuf.add_alpha(True, chr(255), chr(255),chr(255))
|
|
570
|
+
#icon_set = Gtk.IconSet(transparent)
|
|
571
|
+
#factory.add('demo-gtk-logo', icon_set)
|
|
572
|
+
pass
|
|
573
|
+
except GObject.GError as error:
|
|
574
|
+
#print( 'failed to load GTK logo ... trying local')
|
|
575
|
+
try:
|
|
576
|
+
#img_path = os.path.join(img_dir, 'gtk-logo-rgb.gif')
|
|
577
|
+
xbuf = Gdk.pixbuf_new_from_file('gtk-logo-rgb.gif')
|
|
578
|
+
#Register icon to accompany stock item
|
|
579
|
+
#The gtk-logo-rgb icon has a white background, make it transparent
|
|
580
|
+
#the call is wrapped to (gboolean, guchar, guchar, guchar)
|
|
581
|
+
transparent = xbuf.add_alpha(True, chr(255), chr(255),chr(255))
|
|
582
|
+
icon_set = Gtk.IconSet(transparent)
|
|
583
|
+
factory.add('demo-gtk-logo', icon_set)
|
|
584
|
+
|
|
585
|
+
except GObject.GError as error:
|
|
586
|
+
print('failed to load GTK logo for toolbar')
|
|
587
|
+
|
|
588
|
+
# ------------------------------------------------------------------------
|
|
589
|
+
# Let the higher level deal with errors.
|
|
590
|
+
|
|
591
|
+
def readfile(strx, sep = None):
|
|
592
|
+
|
|
593
|
+
text = []
|
|
594
|
+
|
|
595
|
+
if strx == "":
|
|
596
|
+
return text
|
|
597
|
+
|
|
598
|
+
# Now read and parse
|
|
599
|
+
f = open(strx, "rb"); buff2 = f.read(); f.close()
|
|
600
|
+
if sys.version_info.major < 3:
|
|
601
|
+
buff = buff2
|
|
602
|
+
else:
|
|
603
|
+
try:
|
|
604
|
+
buff = buff2.decode('UTF-8')
|
|
605
|
+
except UnicodeDecodeError:
|
|
606
|
+
buff = buff2.decode('cp437')
|
|
607
|
+
|
|
608
|
+
buff2 = ""
|
|
609
|
+
|
|
610
|
+
if not sep:
|
|
611
|
+
# Deteremine separator, use a partial length search
|
|
612
|
+
if buff.find("\r\n", 0, 300) >= 0:
|
|
613
|
+
sep = "\r\n"
|
|
614
|
+
elif buff.find("\n\r", 0, 300) >= 0:
|
|
615
|
+
sep = "\n\r"
|
|
616
|
+
elif buff.find("\r", 0, 300) >= 0:
|
|
617
|
+
sep = "\r"
|
|
618
|
+
else:
|
|
619
|
+
sep = "\n"
|
|
620
|
+
|
|
621
|
+
text2 = str.split(buff, sep)
|
|
622
|
+
|
|
623
|
+
#if "Makefile" in strx:
|
|
624
|
+
# print(strx, "sep: '"+ sep + "'", ord(sep[0]), ord(sep[1]))
|
|
625
|
+
|
|
626
|
+
# Clean out spuriously occurring \r and \n
|
|
627
|
+
# Example: ST Microelectronics Makefiles
|
|
628
|
+
|
|
629
|
+
text = []
|
|
630
|
+
for aa in text2:
|
|
631
|
+
#print("'%s\n" % aa)
|
|
632
|
+
bb = aa.replace("\r", "")
|
|
633
|
+
cc = bb.replace("\n", "")
|
|
634
|
+
text.append(cc)
|
|
635
|
+
#text2 = []
|
|
636
|
+
|
|
637
|
+
return text
|
|
638
|
+
|
|
639
|
+
# ------------------------------------------------------------------------
|
|
640
|
+
# Handle command line. Interpret optarray and decorate the class
|
|
641
|
+
# This allows a lot of sub utils to have a common set of options.
|
|
642
|
+
|
|
643
|
+
class Config:
|
|
644
|
+
|
|
645
|
+
def __init__(self, optarr):
|
|
646
|
+
self.optarr = optarr
|
|
647
|
+
self.verbose = False
|
|
648
|
+
self.debug = False
|
|
649
|
+
|
|
650
|
+
def comline(self, argv):
|
|
651
|
+
optletters = ""
|
|
652
|
+
for aa in self.optarr:
|
|
653
|
+
optletters += aa[0]
|
|
654
|
+
#print( optletters )
|
|
655
|
+
# Create defaults:
|
|
656
|
+
err = 0
|
|
657
|
+
for bb in range(len(self.optarr)):
|
|
658
|
+
if self.optarr[bb][1]:
|
|
659
|
+
# Coerse type
|
|
660
|
+
if type(self.optarr[bb][2]) == type(0):
|
|
661
|
+
self.__dict__[self.optarr[bb][1]] = int(self.optarr[bb][2])
|
|
662
|
+
if type(self.optarr[bb][2]) == type(""):
|
|
663
|
+
self.__dict__[self.optarr[bb][1]] = str(self.optarr[bb][2])
|
|
664
|
+
try:
|
|
665
|
+
opts, args = getopt.getopt(argv, optletters)
|
|
666
|
+
#except getopt.GetoptError, err:
|
|
667
|
+
except:
|
|
668
|
+
print( "Invalid option(s) on command line:", err)
|
|
669
|
+
#support.put_exception("comline")
|
|
670
|
+
return ()
|
|
671
|
+
|
|
672
|
+
#print( "opts", opts, "args", args)
|
|
673
|
+
for aa in opts:
|
|
674
|
+
for bb in range(len(self.optarr)):
|
|
675
|
+
if aa[0][1] == self.optarr[bb][0][0]:
|
|
676
|
+
#print( "match", aa, self.optarr[bb])
|
|
677
|
+
if len(self.optarr[bb][0]) > 1:
|
|
678
|
+
#print( "arg", self.optarr[bb][1], aa[1])
|
|
679
|
+
if self.optarr[bb][2] != None:
|
|
680
|
+
if type(self.optarr[bb][2]) == type(0):
|
|
681
|
+
self.__dict__[self.optarr[bb][1]] = int(aa[1])
|
|
682
|
+
if type(self.optarr[bb][2]) == type(""):
|
|
683
|
+
self.__dict__[self.optarr[bb][1]] = str(aa[1])
|
|
684
|
+
else:
|
|
685
|
+
#print( "set", self.optarr[bb][1], self.optarr[bb][2])
|
|
686
|
+
if self.optarr[bb][2] != None:
|
|
687
|
+
self.__dict__[self.optarr[bb][1]] = 1
|
|
688
|
+
#print( "call", self.optarr[bb][3])
|
|
689
|
+
if self.optarr[bb][3] != None:
|
|
690
|
+
self.optarr[bb][3]()
|
|
691
|
+
return args
|
|
692
|
+
|
|
693
|
+
def about(progname, verstr = "1.0.0", imgfile = "icon.png"):
|
|
694
|
+
|
|
695
|
+
''' Show About dialog: '''
|
|
696
|
+
|
|
697
|
+
dialog = Gtk.AboutDialog()
|
|
698
|
+
dialog.set_name(progname)
|
|
699
|
+
|
|
700
|
+
dialog.set_version(verstr)
|
|
701
|
+
gver = (Gtk.get_major_version(), \
|
|
702
|
+
Gtk.get_minor_version(), \
|
|
703
|
+
Gtk.get_micro_version())
|
|
704
|
+
|
|
705
|
+
dialog.set_position(Gtk.WindowPosition.CENTER)
|
|
706
|
+
#dialog.set_transient_for(pedconfig.conf.pedwin.mywin)
|
|
707
|
+
|
|
708
|
+
#"\nRunning PyGObject %d.%d.%d" % GObject.pygobject_version +\
|
|
709
|
+
|
|
710
|
+
ddd = os.path.join(os.path.dirname(__file__))
|
|
711
|
+
|
|
712
|
+
# GLib.pyglib_version
|
|
713
|
+
vvv = gi.version_info
|
|
714
|
+
comm = \
|
|
715
|
+
"Running PyGtk %d.%d.%d" % vvv +\
|
|
716
|
+
"\non GTK %d.%d.%d" % gver +\
|
|
717
|
+
"\nRunning Python %s" % platform.python_version() +\
|
|
718
|
+
"\non %s %s" % (platform.system(), platform.release()) +\
|
|
719
|
+
"\nExe Path:\n%s" % os.path.realpath(ddd)
|
|
720
|
+
|
|
721
|
+
dialog.set_comments(comm)
|
|
722
|
+
dialog.set_copyright(progname + " Created by Peter Glen.\n"
|
|
723
|
+
"Project is in the Public Domain.")
|
|
724
|
+
dialog.set_program_name(progname)
|
|
725
|
+
img_path = os.path.join(os.path.dirname(__file__), imgfile)
|
|
726
|
+
|
|
727
|
+
try:
|
|
728
|
+
pixbuf = GdkPixbuf.Pixbuf.new_from_file(img_path)
|
|
729
|
+
#print "loaded pixbuf"
|
|
730
|
+
dialog.set_logo(pixbuf)
|
|
731
|
+
|
|
732
|
+
except:
|
|
733
|
+
print("Cannot load logo for about dialog", img_path)
|
|
734
|
+
print(sys.exc_info())
|
|
735
|
+
|
|
736
|
+
#dialog.set_website("")
|
|
737
|
+
|
|
738
|
+
## Close dialog on user response
|
|
739
|
+
dialog.connect ("response", lambda d, r: d.destroy())
|
|
740
|
+
dialog.connect("key-press-event", _about_key)
|
|
741
|
+
|
|
742
|
+
dialog.show()
|
|
743
|
+
|
|
744
|
+
def _about_key(win, event):
|
|
745
|
+
#print "about_key", event
|
|
746
|
+
if event.type == Gdk.EventType.KEY_PRESS:
|
|
747
|
+
if event.keyval == Gdk.KEY_x or event.keyval == Gdk.KEY_X:
|
|
748
|
+
if event.state & Gdk.ModifierType.MOD1_MASK:
|
|
749
|
+
win.destroy()
|
|
750
|
+
|
|
751
|
+
# ------------------------------------------------------------------------
|
|
752
|
+
# Show a regular message:
|
|
753
|
+
#
|
|
754
|
+
#def message3(strx, title = None):
|
|
755
|
+
#
|
|
756
|
+
# #print("called: message()", strx)
|
|
757
|
+
#
|
|
758
|
+
# icon = Gtk.STOCK_INFO
|
|
759
|
+
# dialog = Gtk.MessageDialog(buttons=Gtk.ButtonsType.CLOSE,
|
|
760
|
+
# message_type=Gtk.MessageType.INFO)
|
|
761
|
+
# dialog.props.text = strx
|
|
762
|
+
# #dialog.set_transient_for()
|
|
763
|
+
# if title:
|
|
764
|
+
# dialog.set_title(title)
|
|
765
|
+
# else:
|
|
766
|
+
# dialog.set_title("PyEdPro")
|
|
767
|
+
# dialog.set_position(Gtk.WindowPosition.CENTER)
|
|
768
|
+
# # Close dialog on user response
|
|
769
|
+
# dialog.connect("response", lambda d, r: d.destroy())
|
|
770
|
+
# dialog.show()
|
|
771
|
+
# dialog.run()
|
|
772
|
+
|
|
773
|
+
# -----------------------------------------------------------------------
|
|
774
|
+
# Call func with all processes, func called with stat as its argument
|
|
775
|
+
# Function may return True to stop iteration
|
|
776
|
+
|
|
777
|
+
def withps(func, opt = None):
|
|
778
|
+
|
|
779
|
+
ret = False
|
|
780
|
+
dl = os.listdir("/proc")
|
|
781
|
+
for aa in dl:
|
|
782
|
+
fname = "/proc/" + aa + "/stat"
|
|
783
|
+
if os.path.isfile(fname):
|
|
784
|
+
ff = open(fname, "r").read().split()
|
|
785
|
+
ret = func(ff, opt)
|
|
786
|
+
if ret:
|
|
787
|
+
break
|
|
788
|
+
return ret
|
|
789
|
+
|
|
790
|
+
# ------------------------------------------------------------------------
|
|
791
|
+
# Find
|
|
792
|
+
|
|
793
|
+
def find(self):
|
|
794
|
+
|
|
795
|
+
head = "Find in text"
|
|
796
|
+
|
|
797
|
+
dialog = Gtk.Dialog(head,
|
|
798
|
+
None,
|
|
799
|
+
Gtk.DIALOG_MODAL | Gtk.DIALOG_DESTROY_WITH_PARENT,
|
|
800
|
+
(Gtk.STOCK_CANCEL, Gtk.RESPONSE_REJECT,
|
|
801
|
+
Gtk.STOCK_OK, Gtk.RESPONSE_ACCEPT))
|
|
802
|
+
dialog.set_default_response(Gtk.RESPONSE_ACCEPT)
|
|
803
|
+
|
|
804
|
+
try:
|
|
805
|
+
dialog.set_icon_from_file("epub.png")
|
|
806
|
+
except:
|
|
807
|
+
print ("Cannot load find dialog icon", sys.exc_info())
|
|
808
|
+
|
|
809
|
+
self.dialog = dialog
|
|
810
|
+
|
|
811
|
+
label3 = Gtk.Label(" "); label4 = Gtk.Label(" ")
|
|
812
|
+
label5 = Gtk.Label(" "); label6 = Gtk.Label(" ")
|
|
813
|
+
label7 = Gtk.Label(" "); label8 = Gtk.Label(" ")
|
|
814
|
+
|
|
815
|
+
#warmings.simplefilter("ignore")
|
|
816
|
+
entry = Gtk.Entry()
|
|
817
|
+
#warmings.simplefilter("default")
|
|
818
|
+
entry.set_text(self.oldfind)
|
|
819
|
+
|
|
820
|
+
entry.set_activates_default(True)
|
|
821
|
+
|
|
822
|
+
dialog.vbox.pack_start(label4)
|
|
823
|
+
|
|
824
|
+
hbox2 = Gtk.HBox()
|
|
825
|
+
hbox2.pack_start(label6, False)
|
|
826
|
+
hbox2.pack_start(entry)
|
|
827
|
+
hbox2.pack_start(label7, False)
|
|
828
|
+
|
|
829
|
+
dialog.vbox.pack_start(hbox2)
|
|
830
|
+
|
|
831
|
+
dialog.checkbox = Gtk.CheckButton("Search _Backwards")
|
|
832
|
+
dialog.checkbox2 = Gtk.CheckButton("Case In_sensitive")
|
|
833
|
+
dialog.vbox.pack_start(label5)
|
|
834
|
+
|
|
835
|
+
hbox = Gtk.HBox()
|
|
836
|
+
#hbox.pack_start(label1); hbox.pack_start(dialog.checkbox)
|
|
837
|
+
#hbox.pack_start(label2); hbox.pack_start(dialog.checkbox2)
|
|
838
|
+
hbox.pack_start(label3)
|
|
839
|
+
dialog.vbox.pack_start(hbox)
|
|
840
|
+
dialog.vbox.pack_start(label8)
|
|
841
|
+
|
|
842
|
+
label32 = Gtk.Label(" ")
|
|
843
|
+
hbox4 = Gtk.HBox()
|
|
844
|
+
|
|
845
|
+
hbox4.pack_start(label32)
|
|
846
|
+
dialog.vbox.pack_start(hbox4)
|
|
847
|
+
|
|
848
|
+
dialog.show_all()
|
|
849
|
+
response = dialog.run()
|
|
850
|
+
self.srctxt = entry.get_text()
|
|
851
|
+
|
|
852
|
+
dialog.destroy()
|
|
853
|
+
|
|
854
|
+
if response != Gtk.RESPONSE_ACCEPT:
|
|
855
|
+
return None
|
|
856
|
+
|
|
857
|
+
return self.srctxt, dialog.checkbox.get_active(), \
|
|
858
|
+
dialog.checkbox2.get_active()
|
|
859
|
+
|
|
860
|
+
disp = Gdk.Display.get_default()
|
|
861
|
+
scr = disp.get_default_screen()
|
|
862
|
+
|
|
863
|
+
#print( "num_mon", scr.get_n_monitors() )
|
|
864
|
+
#for aa in range(scr.get_n_monitors()):
|
|
865
|
+
# print( "mon", aa, scr.get_monitor_geometry(aa);)
|
|
866
|
+
|
|
867
|
+
# ------------------------------------------------------------------------
|
|
868
|
+
# Get current screen (monitor) width and height
|
|
869
|
+
|
|
870
|
+
def get_screen_wh():
|
|
871
|
+
|
|
872
|
+
ptr = disp.get_pointer()
|
|
873
|
+
mon = scr.get_monitor_at_point(ptr[1], ptr[2])
|
|
874
|
+
geo = scr.get_monitor_geometry(mon)
|
|
875
|
+
www = geo.width; hhh = geo.height
|
|
876
|
+
if www == 0 or hhh == 0:
|
|
877
|
+
www = Gdk.get_screen_width()
|
|
878
|
+
hhh = Gdk.get_screen_height()
|
|
879
|
+
return www, hhh
|
|
880
|
+
|
|
881
|
+
# ------------------------------------------------------------------------
|
|
882
|
+
# Get current screen (monitor) upper left corner xx / yy
|
|
883
|
+
|
|
884
|
+
def get_screen_xy():
|
|
885
|
+
|
|
886
|
+
ptr = disp.get_pointer()
|
|
887
|
+
mon = scr.get_monitor_at_point(ptr[1], ptr[2])
|
|
888
|
+
geo = scr.get_monitor_geometry(mon)
|
|
889
|
+
return geo.x, geo.y
|
|
890
|
+
|
|
891
|
+
# ------------------------------------------------------------------------
|
|
892
|
+
# Print( an exception as the system would print it)
|
|
893
|
+
|
|
894
|
+
def print_exception(xstr):
|
|
895
|
+
cumm = xstr + " "
|
|
896
|
+
a,b,c = sys.exc_info()
|
|
897
|
+
if a != None:
|
|
898
|
+
cumm += str(a) + " " + str(b) + "\n"
|
|
899
|
+
try:
|
|
900
|
+
#cumm += str(traceback.format_tb(c, 10))
|
|
901
|
+
ttt = traceback.extract_tb(c)
|
|
902
|
+
for aa in ttt:
|
|
903
|
+
cumm += "File: " + os.path.basename(aa[0]) + \
|
|
904
|
+
" Line: " + str(aa[1]) + "\n" + \
|
|
905
|
+
" Context: " + aa[2] + " -> " + aa[3] + "\n"
|
|
906
|
+
except:
|
|
907
|
+
print("Could not print trace stack. ", sys.exc_info())
|
|
908
|
+
print( cumm)
|
|
909
|
+
|
|
910
|
+
# -----------------------------------------------------------------------
|
|
911
|
+
# Sleep just a little, but allow the system to breed
|
|
912
|
+
|
|
913
|
+
def usleep(msec):
|
|
914
|
+
|
|
915
|
+
if sys.version_info[0] < 3 or \
|
|
916
|
+
(sys.version_info[0] == 3 and sys.version_info[1] < 3):
|
|
917
|
+
timefunc = time.clock
|
|
918
|
+
else:
|
|
919
|
+
timefunc = time.process_time
|
|
920
|
+
|
|
921
|
+
got_clock = timefunc() + float(msec) / 1000
|
|
922
|
+
#print( got_clock)
|
|
923
|
+
while True:
|
|
924
|
+
if timefunc() > got_clock:
|
|
925
|
+
break
|
|
926
|
+
#print ("Sleeping")
|
|
927
|
+
Gtk.main_iteration_do(False)
|
|
928
|
+
|
|
929
|
+
# ------------------------------------------------------------------------
|
|
930
|
+
# Create temporary file, return name. Empty string ("") if error.
|
|
931
|
+
|
|
932
|
+
def tmpname(indir, template):
|
|
933
|
+
|
|
934
|
+
fname = ""
|
|
935
|
+
if not os.access(indir, os.W_OK):
|
|
936
|
+
print( "Cannot access ", indir)
|
|
937
|
+
return fname
|
|
938
|
+
|
|
939
|
+
cnt = 1
|
|
940
|
+
while True:
|
|
941
|
+
tmp = indir + "/" + template + "_" + str(cnt)
|
|
942
|
+
if not os.access(tmp, os.R_OK):
|
|
943
|
+
fname = tmp
|
|
944
|
+
break
|
|
945
|
+
# Safety valve
|
|
946
|
+
if cnt > 10000:
|
|
947
|
+
break
|
|
948
|
+
return fname
|
|
949
|
+
|
|
950
|
+
# ------------------------------------------------------------------------
|
|
951
|
+
# Execute man loop
|
|
952
|
+
|
|
953
|
+
def mainloop():
|
|
954
|
+
while True:
|
|
955
|
+
ev = Gdk.event_peek()
|
|
956
|
+
#print( ev)
|
|
957
|
+
if ev:
|
|
958
|
+
if ev.type == Gdk.EventType.DELETE:
|
|
959
|
+
break
|
|
960
|
+
if ev.type == Gdk.EventType.UNMAP:
|
|
961
|
+
break
|
|
962
|
+
if Gtk.main_iteration_do(True):
|
|
963
|
+
break
|
|
964
|
+
|
|
965
|
+
class Unbuffered(object):
|
|
966
|
+
def __init__(self, stream):
|
|
967
|
+
self.stream = stream
|
|
968
|
+
|
|
969
|
+
def write(self, data):
|
|
970
|
+
self.stream.write(data)
|
|
971
|
+
self.stream.flush()
|
|
972
|
+
|
|
973
|
+
def writelines(self, datas):
|
|
974
|
+
self.stream.writelines(datas)
|
|
975
|
+
self.stream.flush()
|
|
976
|
+
|
|
977
|
+
def __getattr__(self, attr):
|
|
978
|
+
return getattr(self.stream, attr)
|
|
979
|
+
|
|
980
|
+
# Time to str and str to time
|
|
981
|
+
|
|
982
|
+
def time_n2s(ttt):
|
|
983
|
+
sss = time.ctime(ttt)
|
|
984
|
+
return sss
|
|
985
|
+
|
|
986
|
+
def time_s2n(sss):
|
|
987
|
+
rrr = time.strptime(sss)
|
|
988
|
+
ttt = time.mktime(rrr)
|
|
989
|
+
return ttt
|
|
990
|
+
|
|
991
|
+
def opendialog(parent=None):
|
|
992
|
+
|
|
993
|
+
# We create an array, so it is passed around by reference
|
|
994
|
+
fname = [""]
|
|
995
|
+
|
|
996
|
+
def makefilter(mask, name):
|
|
997
|
+
filter = Gtk.FileFilter.new()
|
|
998
|
+
filter.add_pattern(mask)
|
|
999
|
+
filter.set_name(name)
|
|
1000
|
+
return filter
|
|
1001
|
+
|
|
1002
|
+
def done_open_fc(win, resp, fname):
|
|
1003
|
+
#print "done_open_fc", win, resp
|
|
1004
|
+
if resp == Gtk.ButtonsType.OK:
|
|
1005
|
+
fname[0] = win.get_filename()
|
|
1006
|
+
if not fname[0]:
|
|
1007
|
+
#print "Must have filename"
|
|
1008
|
+
pass
|
|
1009
|
+
elif os.path.isdir(fname[0]):
|
|
1010
|
+
os.chdir(fname[0])
|
|
1011
|
+
win.set_current_folder(fname[0])
|
|
1012
|
+
return
|
|
1013
|
+
else:
|
|
1014
|
+
#print("OFD", fname[0])
|
|
1015
|
+
pass
|
|
1016
|
+
win.destroy()
|
|
1017
|
+
|
|
1018
|
+
but = "Cancel", Gtk.ButtonsType.CANCEL,\
|
|
1019
|
+
"Open File", Gtk.ButtonsType.OK
|
|
1020
|
+
|
|
1021
|
+
fc = Gtk.FileChooserDialog("Open file", parent, \
|
|
1022
|
+
Gtk.FileChooserAction.OPEN \
|
|
1023
|
+
, but)
|
|
1024
|
+
|
|
1025
|
+
filters = []
|
|
1026
|
+
filters.append(makefilter("*.mup", "MarkUp files (*.py)"))
|
|
1027
|
+
filters.append(makefilter("*.*", "All files (*.*)"))
|
|
1028
|
+
|
|
1029
|
+
if filters:
|
|
1030
|
+
for aa in filters:
|
|
1031
|
+
fc.add_filter(aa)
|
|
1032
|
+
|
|
1033
|
+
fc.set_default_response(Gtk.ButtonsType.OK)
|
|
1034
|
+
fc.set_current_folder(os.getcwd())
|
|
1035
|
+
fc.connect("response", done_open_fc, fname)
|
|
1036
|
+
#fc.connect("current-folder-changed", self.folder_ch )
|
|
1037
|
+
#fc.set_current_name(self.fname)
|
|
1038
|
+
fc.run()
|
|
1039
|
+
#print("OFD2", fname[0])
|
|
1040
|
+
return fname[0]
|
|
1041
|
+
|
|
1042
|
+
def savedialog(resp):
|
|
1043
|
+
|
|
1044
|
+
#print "File dialog"
|
|
1045
|
+
fname = [""] # So it is passed around as a reference
|
|
1046
|
+
|
|
1047
|
+
def makefilter(mask, name):
|
|
1048
|
+
filterx = Gtk.FileFilter.new()
|
|
1049
|
+
filterx.add_pattern(mask)
|
|
1050
|
+
filterx.set_name(name)
|
|
1051
|
+
return filterx
|
|
1052
|
+
|
|
1053
|
+
def done_fc(win, resp, fname):
|
|
1054
|
+
#print( "done_fc", win, resp)
|
|
1055
|
+
if resp == Gtk.ResponseType.OK:
|
|
1056
|
+
fname[0] = win.get_filename()
|
|
1057
|
+
if not fname[0]:
|
|
1058
|
+
print("Must have filename")
|
|
1059
|
+
else:
|
|
1060
|
+
pass
|
|
1061
|
+
win.destroy()
|
|
1062
|
+
|
|
1063
|
+
but = "Cancel", Gtk.ResponseType.CANCEL, \
|
|
1064
|
+
"Save File", Gtk.ResponseType.OK
|
|
1065
|
+
fc = Gtk.FileChooserDialog("Save file as ... ", None,
|
|
1066
|
+
Gtk.FileChooserAction.SAVE, but)
|
|
1067
|
+
|
|
1068
|
+
#fc.set_do_overwrite_confirmation(True)
|
|
1069
|
+
|
|
1070
|
+
filters = []
|
|
1071
|
+
filters.append(makefilter("*.mup", "MarkUp files (*.py)"))
|
|
1072
|
+
filters.append(makefilter("*.*", "All files (*.*)"))
|
|
1073
|
+
|
|
1074
|
+
if filters:
|
|
1075
|
+
for aa in filters:
|
|
1076
|
+
fc.add_filter(aa)
|
|
1077
|
+
|
|
1078
|
+
fc.set_current_name(os.path.basename(fname[0]))
|
|
1079
|
+
fc.set_current_folder(os.path.dirname(fname[0]))
|
|
1080
|
+
fc.set_default_response(Gtk.ResponseType.OK)
|
|
1081
|
+
fc.connect("response", done_fc, fname)
|
|
1082
|
+
fc.run()
|
|
1083
|
+
return fname[0]
|
|
1084
|
+
|
|
1085
|
+
# ------------------------------------------------------------------------
|
|
1086
|
+
|
|
1087
|
+
def leadspace(strx):
|
|
1088
|
+
|
|
1089
|
+
''' Count lead spaces '''
|
|
1090
|
+
|
|
1091
|
+
cnt = 0
|
|
1092
|
+
for aa in range(len(strx)):
|
|
1093
|
+
bb = strx[aa]
|
|
1094
|
+
if bb == " ":
|
|
1095
|
+
cnt += 1
|
|
1096
|
+
elif bb == "\t":
|
|
1097
|
+
cnt += 1
|
|
1098
|
+
elif bb == "\r":
|
|
1099
|
+
cnt += 1
|
|
1100
|
+
elif bb == "\n":
|
|
1101
|
+
cnt += 1
|
|
1102
|
+
else:
|
|
1103
|
+
break
|
|
1104
|
+
return cnt
|
|
1105
|
+
|
|
1106
|
+
def wrapscroll(what):
|
|
1107
|
+
|
|
1108
|
+
scroll2 = Gtk.ScrolledWindow()
|
|
1109
|
+
scroll2.add(what)
|
|
1110
|
+
frame2 = Gtk.Frame()
|
|
1111
|
+
frame2.add(scroll2)
|
|
1112
|
+
return frame2
|
|
1113
|
+
|
|
1114
|
+
if __name__ == '__main__':
|
|
1115
|
+
print("This file was not meant to run directly")
|
|
1116
|
+
|
|
1117
|
+
# EOF</code></pre>
|
|
1118
|
+
</details>
|
|
1119
|
+
</section>
|
|
1120
|
+
<section>
|
|
1121
|
+
</section>
|
|
1122
|
+
<section>
|
|
1123
|
+
</section>
|
|
1124
|
+
<section>
|
|
1125
|
+
<h2 class="section-title" id="header-functions">Functions</h2>
|
|
1126
|
+
<dl>
|
|
1127
|
+
<dt id="pgutils.about"><code class="name flex">
|
|
1128
|
+
<span>def <span class="ident">about</span></span>(<span>progname, verstr='1.0.0', imgfile='icon.png')</span>
|
|
1129
|
+
</code></dt>
|
|
1130
|
+
<dd>
|
|
1131
|
+
<div class="desc"><p>Show About dialog:</p></div>
|
|
1132
|
+
<details class="source">
|
|
1133
|
+
<summary>
|
|
1134
|
+
<span>Expand source code</span>
|
|
1135
|
+
</summary>
|
|
1136
|
+
<pre><code class="python">def about(progname, verstr = "1.0.0", imgfile = "icon.png"):
|
|
1137
|
+
|
|
1138
|
+
''' Show About dialog: '''
|
|
1139
|
+
|
|
1140
|
+
dialog = Gtk.AboutDialog()
|
|
1141
|
+
dialog.set_name(progname)
|
|
1142
|
+
|
|
1143
|
+
dialog.set_version(verstr)
|
|
1144
|
+
gver = (Gtk.get_major_version(), \
|
|
1145
|
+
Gtk.get_minor_version(), \
|
|
1146
|
+
Gtk.get_micro_version())
|
|
1147
|
+
|
|
1148
|
+
dialog.set_position(Gtk.WindowPosition.CENTER)
|
|
1149
|
+
#dialog.set_transient_for(pedconfig.conf.pedwin.mywin)
|
|
1150
|
+
|
|
1151
|
+
#"\nRunning PyGObject %d.%d.%d" % GObject.pygobject_version +\
|
|
1152
|
+
|
|
1153
|
+
ddd = os.path.join(os.path.dirname(__file__))
|
|
1154
|
+
|
|
1155
|
+
# GLib.pyglib_version
|
|
1156
|
+
vvv = gi.version_info
|
|
1157
|
+
comm = \
|
|
1158
|
+
"Running PyGtk %d.%d.%d" % vvv +\
|
|
1159
|
+
"\non GTK %d.%d.%d" % gver +\
|
|
1160
|
+
"\nRunning Python %s" % platform.python_version() +\
|
|
1161
|
+
"\non %s %s" % (platform.system(), platform.release()) +\
|
|
1162
|
+
"\nExe Path:\n%s" % os.path.realpath(ddd)
|
|
1163
|
+
|
|
1164
|
+
dialog.set_comments(comm)
|
|
1165
|
+
dialog.set_copyright(progname + " Created by Peter Glen.\n"
|
|
1166
|
+
"Project is in the Public Domain.")
|
|
1167
|
+
dialog.set_program_name(progname)
|
|
1168
|
+
img_path = os.path.join(os.path.dirname(__file__), imgfile)
|
|
1169
|
+
|
|
1170
|
+
try:
|
|
1171
|
+
pixbuf = GdkPixbuf.Pixbuf.new_from_file(img_path)
|
|
1172
|
+
#print "loaded pixbuf"
|
|
1173
|
+
dialog.set_logo(pixbuf)
|
|
1174
|
+
|
|
1175
|
+
except:
|
|
1176
|
+
print("Cannot load logo for about dialog", img_path)
|
|
1177
|
+
print(sys.exc_info())
|
|
1178
|
+
|
|
1179
|
+
#dialog.set_website("")
|
|
1180
|
+
|
|
1181
|
+
## Close dialog on user response
|
|
1182
|
+
dialog.connect ("response", lambda d, r: d.destroy())
|
|
1183
|
+
dialog.connect("key-press-event", _about_key)
|
|
1184
|
+
|
|
1185
|
+
dialog.show()</code></pre>
|
|
1186
|
+
</details>
|
|
1187
|
+
</dd>
|
|
1188
|
+
<dt id="pgutils.ampmstr"><code class="name flex">
|
|
1189
|
+
<span>def <span class="ident">ampmstr</span></span>(<span>bb)</span>
|
|
1190
|
+
</code></dt>
|
|
1191
|
+
<dd>
|
|
1192
|
+
<div class="desc"></div>
|
|
1193
|
+
<details class="source">
|
|
1194
|
+
<summary>
|
|
1195
|
+
<span>Expand source code</span>
|
|
1196
|
+
</summary>
|
|
1197
|
+
<pre><code class="python">def ampmstr(bb):
|
|
1198
|
+
|
|
1199
|
+
dd = "AM"
|
|
1200
|
+
if bb == 12:
|
|
1201
|
+
dd = "PM"
|
|
1202
|
+
elif bb > 12:
|
|
1203
|
+
bb -= 12
|
|
1204
|
+
dd = "PM"
|
|
1205
|
+
return "%02d %s" % (bb, dd)</code></pre>
|
|
1206
|
+
</details>
|
|
1207
|
+
</dd>
|
|
1208
|
+
<dt id="pgutils.clean_str"><code class="name flex">
|
|
1209
|
+
<span>def <span class="ident">clean_str</span></span>(<span>strx)</span>
|
|
1210
|
+
</code></dt>
|
|
1211
|
+
<dd>
|
|
1212
|
+
<div class="desc"></div>
|
|
1213
|
+
<details class="source">
|
|
1214
|
+
<summary>
|
|
1215
|
+
<span>Expand source code</span>
|
|
1216
|
+
</summary>
|
|
1217
|
+
<pre><code class="python">def clean_str(strx):
|
|
1218
|
+
|
|
1219
|
+
stry = ""
|
|
1220
|
+
for aa in range(len(strx)):
|
|
1221
|
+
if strx[aa] == '\r':
|
|
1222
|
+
stry += "\\r"
|
|
1223
|
+
elif strx[aa] == '\n':
|
|
1224
|
+
stry += "\\n"
|
|
1225
|
+
elif strx[aa] == '\0':
|
|
1226
|
+
stry += "\\0"
|
|
1227
|
+
else:
|
|
1228
|
+
stry += strx[aa]
|
|
1229
|
+
return stry</code></pre>
|
|
1230
|
+
</details>
|
|
1231
|
+
</dd>
|
|
1232
|
+
<dt id="pgutils.clean_str2"><code class="name flex">
|
|
1233
|
+
<span>def <span class="ident">clean_str2</span></span>(<span>strx)</span>
|
|
1234
|
+
</code></dt>
|
|
1235
|
+
<dd>
|
|
1236
|
+
<div class="desc"></div>
|
|
1237
|
+
<details class="source">
|
|
1238
|
+
<summary>
|
|
1239
|
+
<span>Expand source code</span>
|
|
1240
|
+
</summary>
|
|
1241
|
+
<pre><code class="python">def clean_str2(strx):
|
|
1242
|
+
stry = ""
|
|
1243
|
+
skip = False
|
|
1244
|
+
for aa in range(len(strx)):
|
|
1245
|
+
if skip:
|
|
1246
|
+
skip = False
|
|
1247
|
+
continue
|
|
1248
|
+
if strx[aa] == '\\' and strx[aa+1] == 'r':
|
|
1249
|
+
skip = True
|
|
1250
|
+
if strx[aa] == '\\' and strx[aa+1] == 'n':
|
|
1251
|
+
skip = True
|
|
1252
|
+
if strx[aa] == '\\' and strx[aa+1] == '0':
|
|
1253
|
+
skip = True
|
|
1254
|
+
pass
|
|
1255
|
+
else:
|
|
1256
|
+
stry += strx[aa]
|
|
1257
|
+
return stry</code></pre>
|
|
1258
|
+
</details>
|
|
1259
|
+
</dd>
|
|
1260
|
+
<dt id="pgutils.col2float"><code class="name flex">
|
|
1261
|
+
<span>def <span class="ident">col2float</span></span>(<span>col)</span>
|
|
1262
|
+
</code></dt>
|
|
1263
|
+
<dd>
|
|
1264
|
+
<div class="desc"></div>
|
|
1265
|
+
<details class="source">
|
|
1266
|
+
<summary>
|
|
1267
|
+
<span>Expand source code</span>
|
|
1268
|
+
</summary>
|
|
1269
|
+
<pre><code class="python">def col2float(col):
|
|
1270
|
+
rrr = [float(col.red) / 65535,
|
|
1271
|
+
float(col.green) / 65535,
|
|
1272
|
+
float(col.blue) / 65535]
|
|
1273
|
+
return rrr</code></pre>
|
|
1274
|
+
</details>
|
|
1275
|
+
</dd>
|
|
1276
|
+
<dt id="pgutils.col2str"><code class="name flex">
|
|
1277
|
+
<span>def <span class="ident">col2str</span></span>(<span>icol)</span>
|
|
1278
|
+
</code></dt>
|
|
1279
|
+
<dd>
|
|
1280
|
+
<div class="desc"></div>
|
|
1281
|
+
<details class="source">
|
|
1282
|
+
<summary>
|
|
1283
|
+
<span>Expand source code</span>
|
|
1284
|
+
</summary>
|
|
1285
|
+
<pre><code class="python">def col2str(icol):
|
|
1286
|
+
strx = "#%02x%02x%02x" % (int(icol.red / 255), \
|
|
1287
|
+
int(icol.green / 255), int(icol.blue / 255))
|
|
1288
|
+
return strx</code></pre>
|
|
1289
|
+
</details>
|
|
1290
|
+
</dd>
|
|
1291
|
+
<dt id="pgutils.decode_bits"><code class="name flex">
|
|
1292
|
+
<span>def <span class="ident">decode_bits</span></span>(<span>numx)</span>
|
|
1293
|
+
</code></dt>
|
|
1294
|
+
<dd>
|
|
1295
|
+
<div class="desc"></div>
|
|
1296
|
+
<details class="source">
|
|
1297
|
+
<summary>
|
|
1298
|
+
<span>Expand source code</span>
|
|
1299
|
+
</summary>
|
|
1300
|
+
<pre><code class="python">def decode_bits(numx):
|
|
1301
|
+
mask = 0x80
|
|
1302
|
+
retx = ""
|
|
1303
|
+
for aa in range(8):
|
|
1304
|
+
strx = "0"
|
|
1305
|
+
if numx & mask:
|
|
1306
|
+
strx = "1"
|
|
1307
|
+
retx += "B%d=%s " % (7-aa, strx)
|
|
1308
|
+
if aa == 3:
|
|
1309
|
+
retx += "\r"
|
|
1310
|
+
mask >>= 1
|
|
1311
|
+
|
|
1312
|
+
return retx</code></pre>
|
|
1313
|
+
</details>
|
|
1314
|
+
</dd>
|
|
1315
|
+
<dt id="pgutils.find"><code class="name flex">
|
|
1316
|
+
<span>def <span class="ident">find</span></span>(<span>self)</span>
|
|
1317
|
+
</code></dt>
|
|
1318
|
+
<dd>
|
|
1319
|
+
<div class="desc"></div>
|
|
1320
|
+
<details class="source">
|
|
1321
|
+
<summary>
|
|
1322
|
+
<span>Expand source code</span>
|
|
1323
|
+
</summary>
|
|
1324
|
+
<pre><code class="python">def find(self):
|
|
1325
|
+
|
|
1326
|
+
head = "Find in text"
|
|
1327
|
+
|
|
1328
|
+
dialog = Gtk.Dialog(head,
|
|
1329
|
+
None,
|
|
1330
|
+
Gtk.DIALOG_MODAL | Gtk.DIALOG_DESTROY_WITH_PARENT,
|
|
1331
|
+
(Gtk.STOCK_CANCEL, Gtk.RESPONSE_REJECT,
|
|
1332
|
+
Gtk.STOCK_OK, Gtk.RESPONSE_ACCEPT))
|
|
1333
|
+
dialog.set_default_response(Gtk.RESPONSE_ACCEPT)
|
|
1334
|
+
|
|
1335
|
+
try:
|
|
1336
|
+
dialog.set_icon_from_file("epub.png")
|
|
1337
|
+
except:
|
|
1338
|
+
print ("Cannot load find dialog icon", sys.exc_info())
|
|
1339
|
+
|
|
1340
|
+
self.dialog = dialog
|
|
1341
|
+
|
|
1342
|
+
label3 = Gtk.Label(" "); label4 = Gtk.Label(" ")
|
|
1343
|
+
label5 = Gtk.Label(" "); label6 = Gtk.Label(" ")
|
|
1344
|
+
label7 = Gtk.Label(" "); label8 = Gtk.Label(" ")
|
|
1345
|
+
|
|
1346
|
+
#warmings.simplefilter("ignore")
|
|
1347
|
+
entry = Gtk.Entry()
|
|
1348
|
+
#warmings.simplefilter("default")
|
|
1349
|
+
entry.set_text(self.oldfind)
|
|
1350
|
+
|
|
1351
|
+
entry.set_activates_default(True)
|
|
1352
|
+
|
|
1353
|
+
dialog.vbox.pack_start(label4)
|
|
1354
|
+
|
|
1355
|
+
hbox2 = Gtk.HBox()
|
|
1356
|
+
hbox2.pack_start(label6, False)
|
|
1357
|
+
hbox2.pack_start(entry)
|
|
1358
|
+
hbox2.pack_start(label7, False)
|
|
1359
|
+
|
|
1360
|
+
dialog.vbox.pack_start(hbox2)
|
|
1361
|
+
|
|
1362
|
+
dialog.checkbox = Gtk.CheckButton("Search _Backwards")
|
|
1363
|
+
dialog.checkbox2 = Gtk.CheckButton("Case In_sensitive")
|
|
1364
|
+
dialog.vbox.pack_start(label5)
|
|
1365
|
+
|
|
1366
|
+
hbox = Gtk.HBox()
|
|
1367
|
+
#hbox.pack_start(label1); hbox.pack_start(dialog.checkbox)
|
|
1368
|
+
#hbox.pack_start(label2); hbox.pack_start(dialog.checkbox2)
|
|
1369
|
+
hbox.pack_start(label3)
|
|
1370
|
+
dialog.vbox.pack_start(hbox)
|
|
1371
|
+
dialog.vbox.pack_start(label8)
|
|
1372
|
+
|
|
1373
|
+
label32 = Gtk.Label(" ")
|
|
1374
|
+
hbox4 = Gtk.HBox()
|
|
1375
|
+
|
|
1376
|
+
hbox4.pack_start(label32)
|
|
1377
|
+
dialog.vbox.pack_start(hbox4)
|
|
1378
|
+
|
|
1379
|
+
dialog.show_all()
|
|
1380
|
+
response = dialog.run()
|
|
1381
|
+
self.srctxt = entry.get_text()
|
|
1382
|
+
|
|
1383
|
+
dialog.destroy()
|
|
1384
|
+
|
|
1385
|
+
if response != Gtk.RESPONSE_ACCEPT:
|
|
1386
|
+
return None
|
|
1387
|
+
|
|
1388
|
+
return self.srctxt, dialog.checkbox.get_active(), \
|
|
1389
|
+
dialog.checkbox2.get_active()</code></pre>
|
|
1390
|
+
</details>
|
|
1391
|
+
</dd>
|
|
1392
|
+
<dt id="pgutils.float2col"><code class="name flex">
|
|
1393
|
+
<span>def <span class="ident">float2col</span></span>(<span>col)</span>
|
|
1394
|
+
</code></dt>
|
|
1395
|
+
<dd>
|
|
1396
|
+
<div class="desc"></div>
|
|
1397
|
+
<details class="source">
|
|
1398
|
+
<summary>
|
|
1399
|
+
<span>Expand source code</span>
|
|
1400
|
+
</summary>
|
|
1401
|
+
<pre><code class="python">def float2col(col):
|
|
1402
|
+
aa = min(col[0], 1.)
|
|
1403
|
+
bb = min(col[1], 1.)
|
|
1404
|
+
cc = min(col[2], 1.)
|
|
1405
|
+
return Gdk.Color(aa * 65535, bb * 65535, cc * 65535)</code></pre>
|
|
1406
|
+
</details>
|
|
1407
|
+
</dd>
|
|
1408
|
+
<dt id="pgutils.float2str"><code class="name flex">
|
|
1409
|
+
<span>def <span class="ident">float2str</span></span>(<span>col)</span>
|
|
1410
|
+
</code></dt>
|
|
1411
|
+
<dd>
|
|
1412
|
+
<div class="desc"></div>
|
|
1413
|
+
<details class="source">
|
|
1414
|
+
<summary>
|
|
1415
|
+
<span>Expand source code</span>
|
|
1416
|
+
</summary>
|
|
1417
|
+
<pre><code class="python">def float2str(col):
|
|
1418
|
+
aa = min(col[0], 1.)
|
|
1419
|
+
bb = min(col[1], 1.)
|
|
1420
|
+
cc = min(col[2], 1.)
|
|
1421
|
+
strx = "#%02x%02x%02x" % (aa * 256, \
|
|
1422
|
+
bb * 256, cc * 256)
|
|
1423
|
+
return strx</code></pre>
|
|
1424
|
+
</details>
|
|
1425
|
+
</dd>
|
|
1426
|
+
<dt id="pgutils.get_realtime"><code class="name flex">
|
|
1427
|
+
<span>def <span class="ident">get_realtime</span></span>(<span>)</span>
|
|
1428
|
+
</code></dt>
|
|
1429
|
+
<dd>
|
|
1430
|
+
<div class="desc"></div>
|
|
1431
|
+
<details class="source">
|
|
1432
|
+
<summary>
|
|
1433
|
+
<span>Expand source code</span>
|
|
1434
|
+
</summary>
|
|
1435
|
+
<pre><code class="python">def get_realtime():
|
|
1436
|
+
|
|
1437
|
+
frac = math.modf(float(get_time()))
|
|
1438
|
+
zzz = "%.02f" % frac[0]
|
|
1439
|
+
sss = "%s%s" % (time.strftime("%02I:%02M:%02S"), zzz[1:])
|
|
1440
|
+
return sss</code></pre>
|
|
1441
|
+
</details>
|
|
1442
|
+
</dd>
|
|
1443
|
+
<dt id="pgutils.get_screen_wh"><code class="name flex">
|
|
1444
|
+
<span>def <span class="ident">get_screen_wh</span></span>(<span>)</span>
|
|
1445
|
+
</code></dt>
|
|
1446
|
+
<dd>
|
|
1447
|
+
<div class="desc"></div>
|
|
1448
|
+
<details class="source">
|
|
1449
|
+
<summary>
|
|
1450
|
+
<span>Expand source code</span>
|
|
1451
|
+
</summary>
|
|
1452
|
+
<pre><code class="python">def get_screen_wh():
|
|
1453
|
+
|
|
1454
|
+
ptr = disp.get_pointer()
|
|
1455
|
+
mon = scr.get_monitor_at_point(ptr[1], ptr[2])
|
|
1456
|
+
geo = scr.get_monitor_geometry(mon)
|
|
1457
|
+
www = geo.width; hhh = geo.height
|
|
1458
|
+
if www == 0 or hhh == 0:
|
|
1459
|
+
www = Gdk.get_screen_width()
|
|
1460
|
+
hhh = Gdk.get_screen_height()
|
|
1461
|
+
return www, hhh</code></pre>
|
|
1462
|
+
</details>
|
|
1463
|
+
</dd>
|
|
1464
|
+
<dt id="pgutils.get_screen_xy"><code class="name flex">
|
|
1465
|
+
<span>def <span class="ident">get_screen_xy</span></span>(<span>)</span>
|
|
1466
|
+
</code></dt>
|
|
1467
|
+
<dd>
|
|
1468
|
+
<div class="desc"></div>
|
|
1469
|
+
<details class="source">
|
|
1470
|
+
<summary>
|
|
1471
|
+
<span>Expand source code</span>
|
|
1472
|
+
</summary>
|
|
1473
|
+
<pre><code class="python">def get_screen_xy():
|
|
1474
|
+
|
|
1475
|
+
ptr = disp.get_pointer()
|
|
1476
|
+
mon = scr.get_monitor_at_point(ptr[1], ptr[2])
|
|
1477
|
+
geo = scr.get_monitor_geometry(mon)
|
|
1478
|
+
return geo.x, geo.y</code></pre>
|
|
1479
|
+
</details>
|
|
1480
|
+
</dd>
|
|
1481
|
+
<dt id="pgutils.get_time"><code class="name flex">
|
|
1482
|
+
<span>def <span class="ident">get_time</span></span>(<span>)</span>
|
|
1483
|
+
</code></dt>
|
|
1484
|
+
<dd>
|
|
1485
|
+
<div class="desc"></div>
|
|
1486
|
+
<details class="source">
|
|
1487
|
+
<summary>
|
|
1488
|
+
<span>Expand source code</span>
|
|
1489
|
+
</summary>
|
|
1490
|
+
<pre><code class="python">def get_time():
|
|
1491
|
+
|
|
1492
|
+
global start_time
|
|
1493
|
+
if sys.version_info.major < 3:
|
|
1494
|
+
return time.clock() - start_time
|
|
1495
|
+
else:
|
|
1496
|
+
return time.process_time()</code></pre>
|
|
1497
|
+
</details>
|
|
1498
|
+
</dd>
|
|
1499
|
+
<dt id="pgutils.hash_name"><code class="name flex">
|
|
1500
|
+
<span>def <span class="ident">hash_name</span></span>(<span>strx)</span>
|
|
1501
|
+
</code></dt>
|
|
1502
|
+
<dd>
|
|
1503
|
+
<div class="desc"></div>
|
|
1504
|
+
<details class="source">
|
|
1505
|
+
<summary>
|
|
1506
|
+
<span>Expand source code</span>
|
|
1507
|
+
</summary>
|
|
1508
|
+
<pre><code class="python">def hash_name(strx):
|
|
1509
|
+
|
|
1510
|
+
lenx = len(strx); hashx = int(0)
|
|
1511
|
+
for aa in strx:
|
|
1512
|
+
bb = ord(aa)
|
|
1513
|
+
hashx += int((bb << 12) + bb)
|
|
1514
|
+
hashx &= 0xffffffff
|
|
1515
|
+
hashx = int(hashx << 8) + int(hashx >> 8)
|
|
1516
|
+
hashx &= 0xffffffff
|
|
1517
|
+
|
|
1518
|
+
return "%x" % hashx</code></pre>
|
|
1519
|
+
</details>
|
|
1520
|
+
</dd>
|
|
1521
|
+
<dt id="pgutils.isTrue"><code class="name flex">
|
|
1522
|
+
<span>def <span class="ident">isTrue</span></span>(<span>strx)</span>
|
|
1523
|
+
</code></dt>
|
|
1524
|
+
<dd>
|
|
1525
|
+
<div class="desc"></div>
|
|
1526
|
+
<details class="source">
|
|
1527
|
+
<summary>
|
|
1528
|
+
<span>Expand source code</span>
|
|
1529
|
+
</summary>
|
|
1530
|
+
<pre><code class="python">def isTrue(strx):
|
|
1531
|
+
if strx == "1": return True
|
|
1532
|
+
if strx == "0": return False
|
|
1533
|
+
uuu = strx.upper()
|
|
1534
|
+
if uuu == "TRUE": return True
|
|
1535
|
+
if uuu == "FALSE": return False
|
|
1536
|
+
if uuu == "Y": return True
|
|
1537
|
+
if uuu == "N": return False
|
|
1538
|
+
return False</code></pre>
|
|
1539
|
+
</details>
|
|
1540
|
+
</dd>
|
|
1541
|
+
<dt id="pgutils.is_ascii"><code class="name flex">
|
|
1542
|
+
<span>def <span class="ident">is_ascii</span></span>(<span>strx)</span>
|
|
1543
|
+
</code></dt>
|
|
1544
|
+
<dd>
|
|
1545
|
+
<div class="desc"></div>
|
|
1546
|
+
<details class="source">
|
|
1547
|
+
<summary>
|
|
1548
|
+
<span>Expand source code</span>
|
|
1549
|
+
</summary>
|
|
1550
|
+
<pre><code class="python">def is_ascii(strx):
|
|
1551
|
+
|
|
1552
|
+
pos = 0; lenx = len(strx)
|
|
1553
|
+
while True:
|
|
1554
|
+
if pos >= lenx:
|
|
1555
|
+
break
|
|
1556
|
+
|
|
1557
|
+
chh = strx[pos]
|
|
1558
|
+
#print (ord(chh))
|
|
1559
|
+
if ord(chh) > 127:
|
|
1560
|
+
#print (ord(chh))
|
|
1561
|
+
if pos == 0: pos += 1
|
|
1562
|
+
return pos
|
|
1563
|
+
pos+= 1
|
|
1564
|
+
|
|
1565
|
+
return 0</code></pre>
|
|
1566
|
+
</details>
|
|
1567
|
+
</dd>
|
|
1568
|
+
<dt id="pgutils.isfile"><code class="name flex">
|
|
1569
|
+
<span>def <span class="ident">isfile</span></span>(<span>fname)</span>
|
|
1570
|
+
</code></dt>
|
|
1571
|
+
<dd>
|
|
1572
|
+
<div class="desc"></div>
|
|
1573
|
+
<details class="source">
|
|
1574
|
+
<summary>
|
|
1575
|
+
<span>Expand source code</span>
|
|
1576
|
+
</summary>
|
|
1577
|
+
<pre><code class="python">def isfile(fname):
|
|
1578
|
+
|
|
1579
|
+
try:
|
|
1580
|
+
ss = os.stat(fname)
|
|
1581
|
+
except:
|
|
1582
|
+
return False
|
|
1583
|
+
|
|
1584
|
+
if stat.S_ISREG(ss[stat.ST_MODE]):
|
|
1585
|
+
return True
|
|
1586
|
+
return False</code></pre>
|
|
1587
|
+
</details>
|
|
1588
|
+
</dd>
|
|
1589
|
+
<dt id="pgutils.kill_non_ascii"><code class="name flex">
|
|
1590
|
+
<span>def <span class="ident">kill_non_ascii</span></span>(<span>strx)</span>
|
|
1591
|
+
</code></dt>
|
|
1592
|
+
<dd>
|
|
1593
|
+
<div class="desc"></div>
|
|
1594
|
+
<details class="source">
|
|
1595
|
+
<summary>
|
|
1596
|
+
<span>Expand source code</span>
|
|
1597
|
+
</summary>
|
|
1598
|
+
<pre><code class="python">def kill_non_ascii(strx):
|
|
1599
|
+
|
|
1600
|
+
str2 = ""
|
|
1601
|
+
pos = 0; lenx = len(strx)
|
|
1602
|
+
while True:
|
|
1603
|
+
if pos >= lenx:
|
|
1604
|
+
break
|
|
1605
|
+
|
|
1606
|
+
chh = strx[pos]
|
|
1607
|
+
#print (ord(chh))
|
|
1608
|
+
if ord(chh) <= 127:
|
|
1609
|
+
str2 += chh
|
|
1610
|
+
else:
|
|
1611
|
+
str2 += "*"
|
|
1612
|
+
pos+= 1
|
|
1613
|
+
|
|
1614
|
+
return str2</code></pre>
|
|
1615
|
+
</details>
|
|
1616
|
+
</dd>
|
|
1617
|
+
<dt id="pgutils.leadspace"><code class="name flex">
|
|
1618
|
+
<span>def <span class="ident">leadspace</span></span>(<span>strx)</span>
|
|
1619
|
+
</code></dt>
|
|
1620
|
+
<dd>
|
|
1621
|
+
<div class="desc"><p>Count lead spaces</p></div>
|
|
1622
|
+
<details class="source">
|
|
1623
|
+
<summary>
|
|
1624
|
+
<span>Expand source code</span>
|
|
1625
|
+
</summary>
|
|
1626
|
+
<pre><code class="python">def leadspace(strx):
|
|
1627
|
+
|
|
1628
|
+
''' Count lead spaces '''
|
|
1629
|
+
|
|
1630
|
+
cnt = 0
|
|
1631
|
+
for aa in range(len(strx)):
|
|
1632
|
+
bb = strx[aa]
|
|
1633
|
+
if bb == " ":
|
|
1634
|
+
cnt += 1
|
|
1635
|
+
elif bb == "\t":
|
|
1636
|
+
cnt += 1
|
|
1637
|
+
elif bb == "\r":
|
|
1638
|
+
cnt += 1
|
|
1639
|
+
elif bb == "\n":
|
|
1640
|
+
cnt += 1
|
|
1641
|
+
else:
|
|
1642
|
+
break
|
|
1643
|
+
return cnt</code></pre>
|
|
1644
|
+
</details>
|
|
1645
|
+
</dd>
|
|
1646
|
+
<dt id="pgutils.mainloop"><code class="name flex">
|
|
1647
|
+
<span>def <span class="ident">mainloop</span></span>(<span>)</span>
|
|
1648
|
+
</code></dt>
|
|
1649
|
+
<dd>
|
|
1650
|
+
<div class="desc"></div>
|
|
1651
|
+
<details class="source">
|
|
1652
|
+
<summary>
|
|
1653
|
+
<span>Expand source code</span>
|
|
1654
|
+
</summary>
|
|
1655
|
+
<pre><code class="python">def mainloop():
|
|
1656
|
+
while True:
|
|
1657
|
+
ev = Gdk.event_peek()
|
|
1658
|
+
#print( ev)
|
|
1659
|
+
if ev:
|
|
1660
|
+
if ev.type == Gdk.EventType.DELETE:
|
|
1661
|
+
break
|
|
1662
|
+
if ev.type == Gdk.EventType.UNMAP:
|
|
1663
|
+
break
|
|
1664
|
+
if Gtk.main_iteration_do(True):
|
|
1665
|
+
break</code></pre>
|
|
1666
|
+
</details>
|
|
1667
|
+
</dd>
|
|
1668
|
+
<dt id="pgutils.oct2int"><code class="name flex">
|
|
1669
|
+
<span>def <span class="ident">oct2int</span></span>(<span>strx)</span>
|
|
1670
|
+
</code></dt>
|
|
1671
|
+
<dd>
|
|
1672
|
+
<div class="desc"></div>
|
|
1673
|
+
<details class="source">
|
|
1674
|
+
<summary>
|
|
1675
|
+
<span>Expand source code</span>
|
|
1676
|
+
</summary>
|
|
1677
|
+
<pre><code class="python">def oct2int(strx):
|
|
1678
|
+
retx = 0
|
|
1679
|
+
for aa in strx:
|
|
1680
|
+
num = ord(aa) - ord("0")
|
|
1681
|
+
if num > 7 or num < 0:
|
|
1682
|
+
break
|
|
1683
|
+
retx <<= 3; retx += num
|
|
1684
|
+
#print "oct:", strx, "int:", retx
|
|
1685
|
+
return retx</code></pre>
|
|
1686
|
+
</details>
|
|
1687
|
+
</dd>
|
|
1688
|
+
<dt id="pgutils.opendialog"><code class="name flex">
|
|
1689
|
+
<span>def <span class="ident">opendialog</span></span>(<span>parent=None)</span>
|
|
1690
|
+
</code></dt>
|
|
1691
|
+
<dd>
|
|
1692
|
+
<div class="desc"></div>
|
|
1693
|
+
<details class="source">
|
|
1694
|
+
<summary>
|
|
1695
|
+
<span>Expand source code</span>
|
|
1696
|
+
</summary>
|
|
1697
|
+
<pre><code class="python">def opendialog(parent=None):
|
|
1698
|
+
|
|
1699
|
+
# We create an array, so it is passed around by reference
|
|
1700
|
+
fname = [""]
|
|
1701
|
+
|
|
1702
|
+
def makefilter(mask, name):
|
|
1703
|
+
filter = Gtk.FileFilter.new()
|
|
1704
|
+
filter.add_pattern(mask)
|
|
1705
|
+
filter.set_name(name)
|
|
1706
|
+
return filter
|
|
1707
|
+
|
|
1708
|
+
def done_open_fc(win, resp, fname):
|
|
1709
|
+
#print "done_open_fc", win, resp
|
|
1710
|
+
if resp == Gtk.ButtonsType.OK:
|
|
1711
|
+
fname[0] = win.get_filename()
|
|
1712
|
+
if not fname[0]:
|
|
1713
|
+
#print "Must have filename"
|
|
1714
|
+
pass
|
|
1715
|
+
elif os.path.isdir(fname[0]):
|
|
1716
|
+
os.chdir(fname[0])
|
|
1717
|
+
win.set_current_folder(fname[0])
|
|
1718
|
+
return
|
|
1719
|
+
else:
|
|
1720
|
+
#print("OFD", fname[0])
|
|
1721
|
+
pass
|
|
1722
|
+
win.destroy()
|
|
1723
|
+
|
|
1724
|
+
but = "Cancel", Gtk.ButtonsType.CANCEL,\
|
|
1725
|
+
"Open File", Gtk.ButtonsType.OK
|
|
1726
|
+
|
|
1727
|
+
fc = Gtk.FileChooserDialog("Open file", parent, \
|
|
1728
|
+
Gtk.FileChooserAction.OPEN \
|
|
1729
|
+
, but)
|
|
1730
|
+
|
|
1731
|
+
filters = []
|
|
1732
|
+
filters.append(makefilter("*.mup", "MarkUp files (*.py)"))
|
|
1733
|
+
filters.append(makefilter("*.*", "All files (*.*)"))
|
|
1734
|
+
|
|
1735
|
+
if filters:
|
|
1736
|
+
for aa in filters:
|
|
1737
|
+
fc.add_filter(aa)
|
|
1738
|
+
|
|
1739
|
+
fc.set_default_response(Gtk.ButtonsType.OK)
|
|
1740
|
+
fc.set_current_folder(os.getcwd())
|
|
1741
|
+
fc.connect("response", done_open_fc, fname)
|
|
1742
|
+
#fc.connect("current-folder-changed", self.folder_ch )
|
|
1743
|
+
#fc.set_current_name(self.fname)
|
|
1744
|
+
fc.run()
|
|
1745
|
+
#print("OFD2", fname[0])
|
|
1746
|
+
return fname[0]</code></pre>
|
|
1747
|
+
</details>
|
|
1748
|
+
</dd>
|
|
1749
|
+
<dt id="pgutils.print_exception"><code class="name flex">
|
|
1750
|
+
<span>def <span class="ident">print_exception</span></span>(<span>xstr)</span>
|
|
1751
|
+
</code></dt>
|
|
1752
|
+
<dd>
|
|
1753
|
+
<div class="desc"></div>
|
|
1754
|
+
<details class="source">
|
|
1755
|
+
<summary>
|
|
1756
|
+
<span>Expand source code</span>
|
|
1757
|
+
</summary>
|
|
1758
|
+
<pre><code class="python">def print_exception(xstr):
|
|
1759
|
+
cumm = xstr + " "
|
|
1760
|
+
a,b,c = sys.exc_info()
|
|
1761
|
+
if a != None:
|
|
1762
|
+
cumm += str(a) + " " + str(b) + "\n"
|
|
1763
|
+
try:
|
|
1764
|
+
#cumm += str(traceback.format_tb(c, 10))
|
|
1765
|
+
ttt = traceback.extract_tb(c)
|
|
1766
|
+
for aa in ttt:
|
|
1767
|
+
cumm += "File: " + os.path.basename(aa[0]) + \
|
|
1768
|
+
" Line: " + str(aa[1]) + "\n" + \
|
|
1769
|
+
" Context: " + aa[2] + " -> " + aa[3] + "\n"
|
|
1770
|
+
except:
|
|
1771
|
+
print("Could not print trace stack. ", sys.exc_info())
|
|
1772
|
+
print( cumm)</code></pre>
|
|
1773
|
+
</details>
|
|
1774
|
+
</dd>
|
|
1775
|
+
<dt id="pgutils.put_debug2"><code class="name flex">
|
|
1776
|
+
<span>def <span class="ident">put_debug2</span></span>(<span>xstr)</span>
|
|
1777
|
+
</code></dt>
|
|
1778
|
+
<dd>
|
|
1779
|
+
<div class="desc"></div>
|
|
1780
|
+
<details class="source">
|
|
1781
|
+
<summary>
|
|
1782
|
+
<span>Expand source code</span>
|
|
1783
|
+
</summary>
|
|
1784
|
+
<pre><code class="python">def put_debug2(xstr):
|
|
1785
|
+
try:
|
|
1786
|
+
if os.isatty(sys.stdout.fileno()):
|
|
1787
|
+
print( xstr)
|
|
1788
|
+
else:
|
|
1789
|
+
#syslog.syslog(xstr)
|
|
1790
|
+
pass
|
|
1791
|
+
print(xstr, file=sys.stderr)
|
|
1792
|
+
|
|
1793
|
+
except:
|
|
1794
|
+
print( "Failed on debug output.")
|
|
1795
|
+
print( sys.exc_info())</code></pre>
|
|
1796
|
+
</details>
|
|
1797
|
+
</dd>
|
|
1798
|
+
<dt id="pgutils.put_exception"><code class="name flex">
|
|
1799
|
+
<span>def <span class="ident">put_exception</span></span>(<span>xstr)</span>
|
|
1800
|
+
</code></dt>
|
|
1801
|
+
<dd>
|
|
1802
|
+
<div class="desc"></div>
|
|
1803
|
+
<details class="source">
|
|
1804
|
+
<summary>
|
|
1805
|
+
<span>Expand source code</span>
|
|
1806
|
+
</summary>
|
|
1807
|
+
<pre><code class="python">def put_exception(xstr):
|
|
1808
|
+
|
|
1809
|
+
cumm = xstr + " "
|
|
1810
|
+
a,b,c = sys.exc_info()
|
|
1811
|
+
if a != None:
|
|
1812
|
+
cumm += str(a) + " " + str(b) + "\n"
|
|
1813
|
+
try:
|
|
1814
|
+
#cumm += str(traceback.format_tb(c, 10))
|
|
1815
|
+
ttt = traceback.extract_tb(c)
|
|
1816
|
+
for aa in ttt:
|
|
1817
|
+
cumm += "File: " + os.path.basename(aa[0]) + \
|
|
1818
|
+
" Line: " + str(aa[1]) + "\n" + \
|
|
1819
|
+
" Context: " + aa[2] + " -> " + aa[3] + "\n"
|
|
1820
|
+
except:
|
|
1821
|
+
print( "Could not print trace stack. ", sys.exc_info())
|
|
1822
|
+
|
|
1823
|
+
print(cumm)
|
|
1824
|
+
#syslog.syslog("%s %s %s" % (xstr, a, b))</code></pre>
|
|
1825
|
+
</details>
|
|
1826
|
+
</dd>
|
|
1827
|
+
<dt id="pgutils.put_exception2_old"><code class="name flex">
|
|
1828
|
+
<span>def <span class="ident">put_exception2_old</span></span>(<span>xstr)</span>
|
|
1829
|
+
</code></dt>
|
|
1830
|
+
<dd>
|
|
1831
|
+
<div class="desc"></div>
|
|
1832
|
+
<details class="source">
|
|
1833
|
+
<summary>
|
|
1834
|
+
<span>Expand source code</span>
|
|
1835
|
+
</summary>
|
|
1836
|
+
<pre><code class="python">def put_exception2_old(xstr):
|
|
1837
|
+
|
|
1838
|
+
cumm = xstr + " "
|
|
1839
|
+
a,b,c = sys.exc_info()
|
|
1840
|
+
if a != None:
|
|
1841
|
+
cumm += str(a) + " " + str(b) + "\n"
|
|
1842
|
+
try:
|
|
1843
|
+
#cumm += str(traceback.format_tb(c, 10))
|
|
1844
|
+
ttt = traceback.extract_tb(c)
|
|
1845
|
+
for aa in ttt:
|
|
1846
|
+
cumm += "File: " + os.path.basename(aa[0]) + \
|
|
1847
|
+
" Line: " + str(aa[1]) + "\n" + \
|
|
1848
|
+
" Context: " + aa[2] + " -> " + aa[3] + "\n"
|
|
1849
|
+
except:
|
|
1850
|
+
print( "Could not print trace stack. ", sys.exc_info())
|
|
1851
|
+
|
|
1852
|
+
put_debug2(cumm)
|
|
1853
|
+
#syslog.syslog("%s %s %s" % (xstr, a, b))</code></pre>
|
|
1854
|
+
</details>
|
|
1855
|
+
</dd>
|
|
1856
|
+
<dt id="pgutils.readfile"><code class="name flex">
|
|
1857
|
+
<span>def <span class="ident">readfile</span></span>(<span>strx, sep=None)</span>
|
|
1858
|
+
</code></dt>
|
|
1859
|
+
<dd>
|
|
1860
|
+
<div class="desc"></div>
|
|
1861
|
+
<details class="source">
|
|
1862
|
+
<summary>
|
|
1863
|
+
<span>Expand source code</span>
|
|
1864
|
+
</summary>
|
|
1865
|
+
<pre><code class="python">def readfile(strx, sep = None):
|
|
1866
|
+
|
|
1867
|
+
text = []
|
|
1868
|
+
|
|
1869
|
+
if strx == "":
|
|
1870
|
+
return text
|
|
1871
|
+
|
|
1872
|
+
# Now read and parse
|
|
1873
|
+
f = open(strx, "rb"); buff2 = f.read(); f.close()
|
|
1874
|
+
if sys.version_info.major < 3:
|
|
1875
|
+
buff = buff2
|
|
1876
|
+
else:
|
|
1877
|
+
try:
|
|
1878
|
+
buff = buff2.decode('UTF-8')
|
|
1879
|
+
except UnicodeDecodeError:
|
|
1880
|
+
buff = buff2.decode('cp437')
|
|
1881
|
+
|
|
1882
|
+
buff2 = ""
|
|
1883
|
+
|
|
1884
|
+
if not sep:
|
|
1885
|
+
# Deteremine separator, use a partial length search
|
|
1886
|
+
if buff.find("\r\n", 0, 300) >= 0:
|
|
1887
|
+
sep = "\r\n"
|
|
1888
|
+
elif buff.find("\n\r", 0, 300) >= 0:
|
|
1889
|
+
sep = "\n\r"
|
|
1890
|
+
elif buff.find("\r", 0, 300) >= 0:
|
|
1891
|
+
sep = "\r"
|
|
1892
|
+
else:
|
|
1893
|
+
sep = "\n"
|
|
1894
|
+
|
|
1895
|
+
text2 = str.split(buff, sep)
|
|
1896
|
+
|
|
1897
|
+
#if "Makefile" in strx:
|
|
1898
|
+
# print(strx, "sep: '"+ sep + "'", ord(sep[0]), ord(sep[1]))
|
|
1899
|
+
|
|
1900
|
+
# Clean out spuriously occurring \r and \n
|
|
1901
|
+
# Example: ST Microelectronics Makefiles
|
|
1902
|
+
|
|
1903
|
+
text = []
|
|
1904
|
+
for aa in text2:
|
|
1905
|
+
#print("'%s\n" % aa)
|
|
1906
|
+
bb = aa.replace("\r", "")
|
|
1907
|
+
cc = bb.replace("\n", "")
|
|
1908
|
+
text.append(cc)
|
|
1909
|
+
#text2 = []
|
|
1910
|
+
|
|
1911
|
+
return text</code></pre>
|
|
1912
|
+
</details>
|
|
1913
|
+
</dd>
|
|
1914
|
+
<dt id="pgutils.register_stock_icons"><code class="name flex">
|
|
1915
|
+
<span>def <span class="ident">register_stock_icons</span></span>(<span>)</span>
|
|
1916
|
+
</code></dt>
|
|
1917
|
+
<dd>
|
|
1918
|
+
<div class="desc"><p>This function registers our custom toolbar icons, so they
|
|
1919
|
+
can be themed.</p></div>
|
|
1920
|
+
<details class="source">
|
|
1921
|
+
<summary>
|
|
1922
|
+
<span>Expand source code</span>
|
|
1923
|
+
</summary>
|
|
1924
|
+
<pre><code class="python">def register_stock_icons():
|
|
1925
|
+
''' This function registers our custom toolbar icons, so they
|
|
1926
|
+
can be themed.
|
|
1927
|
+
'''
|
|
1928
|
+
#items = [('demo-gtk-logo', '_GTK!', 0, 0, '')]
|
|
1929
|
+
# Register our stock items
|
|
1930
|
+
#Gtk.stock_add(items)
|
|
1931
|
+
|
|
1932
|
+
# Add our custom icon factory to the list of defaults
|
|
1933
|
+
factory = Gtk.IconFactory()
|
|
1934
|
+
factory.add_default()
|
|
1935
|
+
|
|
1936
|
+
img_dir = os.path.join(os.path.dirname(__file__), 'images')
|
|
1937
|
+
img_path = os.path.join(img_dir, 'gtk-logo-rgb.gif')
|
|
1938
|
+
|
|
1939
|
+
#print( img_path)
|
|
1940
|
+
try:
|
|
1941
|
+
#pixbuf = Gdk.pixbuf_new_from_file(img_path)
|
|
1942
|
+
# Register icon to accompany stock item
|
|
1943
|
+
|
|
1944
|
+
# The gtk-logo-rgb icon has a white background, make it transparent
|
|
1945
|
+
# the call is wrapped to (gboolean, guchar, guchar, guchar)
|
|
1946
|
+
#transparent = pixbuf.add_alpha(True, chr(255), chr(255),chr(255))
|
|
1947
|
+
#icon_set = Gtk.IconSet(transparent)
|
|
1948
|
+
#factory.add('demo-gtk-logo', icon_set)
|
|
1949
|
+
pass
|
|
1950
|
+
except GObject.GError as error:
|
|
1951
|
+
#print( 'failed to load GTK logo ... trying local')
|
|
1952
|
+
try:
|
|
1953
|
+
#img_path = os.path.join(img_dir, 'gtk-logo-rgb.gif')
|
|
1954
|
+
xbuf = Gdk.pixbuf_new_from_file('gtk-logo-rgb.gif')
|
|
1955
|
+
#Register icon to accompany stock item
|
|
1956
|
+
#The gtk-logo-rgb icon has a white background, make it transparent
|
|
1957
|
+
#the call is wrapped to (gboolean, guchar, guchar, guchar)
|
|
1958
|
+
transparent = xbuf.add_alpha(True, chr(255), chr(255),chr(255))
|
|
1959
|
+
icon_set = Gtk.IconSet(transparent)
|
|
1960
|
+
factory.add('demo-gtk-logo', icon_set)
|
|
1961
|
+
|
|
1962
|
+
except GObject.GError as error:
|
|
1963
|
+
print('failed to load GTK logo for toolbar')</code></pre>
|
|
1964
|
+
</details>
|
|
1965
|
+
</dd>
|
|
1966
|
+
<dt id="pgutils.respath"><code class="name flex">
|
|
1967
|
+
<span>def <span class="ident">respath</span></span>(<span>fname)</span>
|
|
1968
|
+
</code></dt>
|
|
1969
|
+
<dd>
|
|
1970
|
+
<div class="desc"></div>
|
|
1971
|
+
<details class="source">
|
|
1972
|
+
<summary>
|
|
1973
|
+
<span>Expand source code</span>
|
|
1974
|
+
</summary>
|
|
1975
|
+
<pre><code class="python">def respath(fname):
|
|
1976
|
+
|
|
1977
|
+
try:
|
|
1978
|
+
ppp = str.split(os.environ['PATH'], os.pathsep)
|
|
1979
|
+
for aa in ppp:
|
|
1980
|
+
ttt = aa + os.sep + fname
|
|
1981
|
+
if os.path.isfile(str(ttt)):
|
|
1982
|
+
return ttt
|
|
1983
|
+
except:
|
|
1984
|
+
print ("Cannot resolve path", fname, sys.exc_info())
|
|
1985
|
+
return None</code></pre>
|
|
1986
|
+
</details>
|
|
1987
|
+
</dd>
|
|
1988
|
+
<dt id="pgutils.rgb2col"><code class="name flex">
|
|
1989
|
+
<span>def <span class="ident">rgb2col</span></span>(<span>icol)</span>
|
|
1990
|
+
</code></dt>
|
|
1991
|
+
<dd>
|
|
1992
|
+
<div class="desc"></div>
|
|
1993
|
+
<details class="source">
|
|
1994
|
+
<summary>
|
|
1995
|
+
<span>Expand source code</span>
|
|
1996
|
+
</summary>
|
|
1997
|
+
<pre><code class="python">def rgb2col(icol):
|
|
1998
|
+
#print "rgb2col", icol
|
|
1999
|
+
col = [0, 0, 0]
|
|
2000
|
+
col[0] = float(icol.red) / 256
|
|
2001
|
+
col[1] = float(icol.green) / 256
|
|
2002
|
+
col[2] = float(icol.blue) / 256
|
|
2003
|
+
return col</code></pre>
|
|
2004
|
+
</details>
|
|
2005
|
+
</dd>
|
|
2006
|
+
<dt id="pgutils.rgb2str"><code class="name flex">
|
|
2007
|
+
<span>def <span class="ident">rgb2str</span></span>(<span>icol)</span>
|
|
2008
|
+
</code></dt>
|
|
2009
|
+
<dd>
|
|
2010
|
+
<div class="desc"></div>
|
|
2011
|
+
<details class="source">
|
|
2012
|
+
<summary>
|
|
2013
|
+
<span>Expand source code</span>
|
|
2014
|
+
</summary>
|
|
2015
|
+
<pre><code class="python">def rgb2str(icol):
|
|
2016
|
+
strx = "#%02x%02x%02x" % (int(icol.red) & 0xff, \
|
|
2017
|
+
int(icol.green) & 0xff, int(icol.blue) & 0xff)
|
|
2018
|
+
return strx</code></pre>
|
|
2019
|
+
</details>
|
|
2020
|
+
</dd>
|
|
2021
|
+
<dt id="pgutils.savedialog"><code class="name flex">
|
|
2022
|
+
<span>def <span class="ident">savedialog</span></span>(<span>resp)</span>
|
|
2023
|
+
</code></dt>
|
|
2024
|
+
<dd>
|
|
2025
|
+
<div class="desc"></div>
|
|
2026
|
+
<details class="source">
|
|
2027
|
+
<summary>
|
|
2028
|
+
<span>Expand source code</span>
|
|
2029
|
+
</summary>
|
|
2030
|
+
<pre><code class="python">def savedialog(resp):
|
|
2031
|
+
|
|
2032
|
+
#print "File dialog"
|
|
2033
|
+
fname = [""] # So it is passed around as a reference
|
|
2034
|
+
|
|
2035
|
+
def makefilter(mask, name):
|
|
2036
|
+
filterx = Gtk.FileFilter.new()
|
|
2037
|
+
filterx.add_pattern(mask)
|
|
2038
|
+
filterx.set_name(name)
|
|
2039
|
+
return filterx
|
|
2040
|
+
|
|
2041
|
+
def done_fc(win, resp, fname):
|
|
2042
|
+
#print( "done_fc", win, resp)
|
|
2043
|
+
if resp == Gtk.ResponseType.OK:
|
|
2044
|
+
fname[0] = win.get_filename()
|
|
2045
|
+
if not fname[0]:
|
|
2046
|
+
print("Must have filename")
|
|
2047
|
+
else:
|
|
2048
|
+
pass
|
|
2049
|
+
win.destroy()
|
|
2050
|
+
|
|
2051
|
+
but = "Cancel", Gtk.ResponseType.CANCEL, \
|
|
2052
|
+
"Save File", Gtk.ResponseType.OK
|
|
2053
|
+
fc = Gtk.FileChooserDialog("Save file as ... ", None,
|
|
2054
|
+
Gtk.FileChooserAction.SAVE, but)
|
|
2055
|
+
|
|
2056
|
+
#fc.set_do_overwrite_confirmation(True)
|
|
2057
|
+
|
|
2058
|
+
filters = []
|
|
2059
|
+
filters.append(makefilter("*.mup", "MarkUp files (*.py)"))
|
|
2060
|
+
filters.append(makefilter("*.*", "All files (*.*)"))
|
|
2061
|
+
|
|
2062
|
+
if filters:
|
|
2063
|
+
for aa in filters:
|
|
2064
|
+
fc.add_filter(aa)
|
|
2065
|
+
|
|
2066
|
+
fc.set_current_name(os.path.basename(fname[0]))
|
|
2067
|
+
fc.set_current_folder(os.path.dirname(fname[0]))
|
|
2068
|
+
fc.set_default_response(Gtk.ResponseType.OK)
|
|
2069
|
+
fc.connect("response", done_fc, fname)
|
|
2070
|
+
fc.run()
|
|
2071
|
+
return fname[0]</code></pre>
|
|
2072
|
+
</details>
|
|
2073
|
+
</dd>
|
|
2074
|
+
<dt id="pgutils.str2col"><code class="name flex">
|
|
2075
|
+
<span>def <span class="ident">str2col</span></span>(<span>strx)</span>
|
|
2076
|
+
</code></dt>
|
|
2077
|
+
<dd>
|
|
2078
|
+
<div class="desc"></div>
|
|
2079
|
+
<details class="source">
|
|
2080
|
+
<summary>
|
|
2081
|
+
<span>Expand source code</span>
|
|
2082
|
+
</summary>
|
|
2083
|
+
<pre><code class="python">def str2col(strx):
|
|
2084
|
+
ccc = str2float(strx)
|
|
2085
|
+
return float2col(ccc)</code></pre>
|
|
2086
|
+
</details>
|
|
2087
|
+
</dd>
|
|
2088
|
+
<dt id="pgutils.str2float"><code class="name flex">
|
|
2089
|
+
<span>def <span class="ident">str2float</span></span>(<span>col)</span>
|
|
2090
|
+
</code></dt>
|
|
2091
|
+
<dd>
|
|
2092
|
+
<div class="desc"></div>
|
|
2093
|
+
<details class="source">
|
|
2094
|
+
<summary>
|
|
2095
|
+
<span>Expand source code</span>
|
|
2096
|
+
</summary>
|
|
2097
|
+
<pre><code class="python">def str2float( col):
|
|
2098
|
+
return ( float(int(col[1:3], base=16)) / 256,
|
|
2099
|
+
float(int(col[3:5], base=16)) / 256, \
|
|
2100
|
+
float(int(col[5:7], base=16)) / 256 )</code></pre>
|
|
2101
|
+
</details>
|
|
2102
|
+
</dd>
|
|
2103
|
+
<dt id="pgutils.time_n2s"><code class="name flex">
|
|
2104
|
+
<span>def <span class="ident">time_n2s</span></span>(<span>ttt)</span>
|
|
2105
|
+
</code></dt>
|
|
2106
|
+
<dd>
|
|
2107
|
+
<div class="desc"></div>
|
|
2108
|
+
<details class="source">
|
|
2109
|
+
<summary>
|
|
2110
|
+
<span>Expand source code</span>
|
|
2111
|
+
</summary>
|
|
2112
|
+
<pre><code class="python">def time_n2s(ttt):
|
|
2113
|
+
sss = time.ctime(ttt)
|
|
2114
|
+
return sss</code></pre>
|
|
2115
|
+
</details>
|
|
2116
|
+
</dd>
|
|
2117
|
+
<dt id="pgutils.time_s2n"><code class="name flex">
|
|
2118
|
+
<span>def <span class="ident">time_s2n</span></span>(<span>sss)</span>
|
|
2119
|
+
</code></dt>
|
|
2120
|
+
<dd>
|
|
2121
|
+
<div class="desc"></div>
|
|
2122
|
+
<details class="source">
|
|
2123
|
+
<summary>
|
|
2124
|
+
<span>Expand source code</span>
|
|
2125
|
+
</summary>
|
|
2126
|
+
<pre><code class="python">def time_s2n(sss):
|
|
2127
|
+
rrr = time.strptime(sss)
|
|
2128
|
+
ttt = time.mktime(rrr)
|
|
2129
|
+
return ttt</code></pre>
|
|
2130
|
+
</details>
|
|
2131
|
+
</dd>
|
|
2132
|
+
<dt id="pgutils.tmpname"><code class="name flex">
|
|
2133
|
+
<span>def <span class="ident">tmpname</span></span>(<span>indir, template)</span>
|
|
2134
|
+
</code></dt>
|
|
2135
|
+
<dd>
|
|
2136
|
+
<div class="desc"></div>
|
|
2137
|
+
<details class="source">
|
|
2138
|
+
<summary>
|
|
2139
|
+
<span>Expand source code</span>
|
|
2140
|
+
</summary>
|
|
2141
|
+
<pre><code class="python">def tmpname(indir, template):
|
|
2142
|
+
|
|
2143
|
+
fname = ""
|
|
2144
|
+
if not os.access(indir, os.W_OK):
|
|
2145
|
+
print( "Cannot access ", indir)
|
|
2146
|
+
return fname
|
|
2147
|
+
|
|
2148
|
+
cnt = 1
|
|
2149
|
+
while True:
|
|
2150
|
+
tmp = indir + "/" + template + "_" + str(cnt)
|
|
2151
|
+
if not os.access(tmp, os.R_OK):
|
|
2152
|
+
fname = tmp
|
|
2153
|
+
break
|
|
2154
|
+
# Safety valve
|
|
2155
|
+
if cnt > 10000:
|
|
2156
|
+
break
|
|
2157
|
+
return fname</code></pre>
|
|
2158
|
+
</details>
|
|
2159
|
+
</dd>
|
|
2160
|
+
<dt id="pgutils.unescape"><code class="name flex">
|
|
2161
|
+
<span>def <span class="ident">unescape</span></span>(<span>strx)</span>
|
|
2162
|
+
</code></dt>
|
|
2163
|
+
<dd>
|
|
2164
|
+
<div class="desc"></div>
|
|
2165
|
+
<details class="source">
|
|
2166
|
+
<summary>
|
|
2167
|
+
<span>Expand source code</span>
|
|
2168
|
+
</summary>
|
|
2169
|
+
<pre><code class="python">def unescape(strx):
|
|
2170
|
+
|
|
2171
|
+
#print " x[" + strx + "]x "
|
|
2172
|
+
|
|
2173
|
+
global xtab, xtablen
|
|
2174
|
+
retx = u""; pos = 0; lenx = len(strx)
|
|
2175
|
+
|
|
2176
|
+
while True:
|
|
2177
|
+
if pos >= lenx:
|
|
2178
|
+
break
|
|
2179
|
+
|
|
2180
|
+
chh = strx[pos]
|
|
2181
|
+
|
|
2182
|
+
if chh == '\\':
|
|
2183
|
+
#print "backslash", strx[pos:]
|
|
2184
|
+
pos2 = pos + 1; strx2 = ""
|
|
2185
|
+
while True:
|
|
2186
|
+
if pos2 >= lenx:
|
|
2187
|
+
# See if we accumulated anything
|
|
2188
|
+
if strx2 != "":
|
|
2189
|
+
xtab.append(oct2int(strx2))
|
|
2190
|
+
if len(xtab) > 0:
|
|
2191
|
+
#print "final:", xtab
|
|
2192
|
+
if xtablen == len(xtab):
|
|
2193
|
+
retx += uni(xtab)
|
|
2194
|
+
xtab = []; xtablen = 0
|
|
2195
|
+
pos = pos2 - 1
|
|
2196
|
+
break
|
|
2197
|
+
chh2 = strx[pos2]
|
|
2198
|
+
if chh2 >= "0" and chh2 <= "7":
|
|
2199
|
+
strx2 += chh2
|
|
2200
|
+
else:
|
|
2201
|
+
#print "strx2: '" + strx2 + "'"
|
|
2202
|
+
if strx2 != "":
|
|
2203
|
+
octx = oct2int(strx2)
|
|
2204
|
+
if xtablen == 0:
|
|
2205
|
+
if octx & 0xe0 == 0xc0:
|
|
2206
|
+
#print "two ",str.format("{0:b}", octx)
|
|
2207
|
+
xtablen = 2
|
|
2208
|
+
xtab.append(octx)
|
|
2209
|
+
elif octx & 0xf0 == 0xe0: # three numbers
|
|
2210
|
+
#print "three ",str.format("{0:b}", octx)
|
|
2211
|
+
xtablen = 3
|
|
2212
|
+
xtab.append(octx)
|
|
2213
|
+
elif octx & 0xf8 == 0xf0: # four numbers
|
|
2214
|
+
print("four ",str.format("{0:b}", octx))
|
|
2215
|
+
xtablen = 4
|
|
2216
|
+
xtab.append(octx)
|
|
2217
|
+
elif octx & 0xfc == 0xf8: # five numbers
|
|
2218
|
+
print("five ",str.format("{0:b}", octx))
|
|
2219
|
+
xtablen = 5
|
|
2220
|
+
xtab.append(octx)
|
|
2221
|
+
elif octx & 0xfe == 0xfc: # six numbers
|
|
2222
|
+
print("six ",str.format("{0:b}", octx))
|
|
2223
|
+
xtablen = 6
|
|
2224
|
+
xtab.append(octx)
|
|
2225
|
+
else:
|
|
2226
|
+
#print "other ",str.format("{0:b}", octx)
|
|
2227
|
+
#retx += unichr(octx)
|
|
2228
|
+
retx += chr(octx)
|
|
2229
|
+
else:
|
|
2230
|
+
xtab.append(octx)
|
|
2231
|
+
#print "data ",str.format("{0:b}", octx)
|
|
2232
|
+
if xtablen == len(xtab):
|
|
2233
|
+
retx += uni(xtab)
|
|
2234
|
+
xtab = []; xtablen = 0
|
|
2235
|
+
|
|
2236
|
+
pos = pos2 - 1
|
|
2237
|
+
break
|
|
2238
|
+
pos2 += 1
|
|
2239
|
+
else:
|
|
2240
|
+
|
|
2241
|
+
if xtablen == len(xtab) and xtablen != 0:
|
|
2242
|
+
retx += uni(xtab)
|
|
2243
|
+
xtab=[]; xtablen = 0
|
|
2244
|
+
|
|
2245
|
+
try:
|
|
2246
|
+
retx += chh
|
|
2247
|
+
except:
|
|
2248
|
+
pass
|
|
2249
|
+
pos += 1
|
|
2250
|
+
|
|
2251
|
+
#print "y[" + retx + "]y"
|
|
2252
|
+
return retx</code></pre>
|
|
2253
|
+
</details>
|
|
2254
|
+
</dd>
|
|
2255
|
+
<dt id="pgutils.uni"><code class="name flex">
|
|
2256
|
+
<span>def <span class="ident">uni</span></span>(<span>xtab)</span>
|
|
2257
|
+
</code></dt>
|
|
2258
|
+
<dd>
|
|
2259
|
+
<div class="desc"></div>
|
|
2260
|
+
<details class="source">
|
|
2261
|
+
<summary>
|
|
2262
|
+
<span>Expand source code</span>
|
|
2263
|
+
</summary>
|
|
2264
|
+
<pre><code class="python">def uni(xtab):
|
|
2265
|
+
|
|
2266
|
+
#print str.format("{0:b}", xtab[0])
|
|
2267
|
+
try:
|
|
2268
|
+
unichr
|
|
2269
|
+
except NameError:
|
|
2270
|
+
unichr = chr
|
|
2271
|
+
|
|
2272
|
+
cc = 0
|
|
2273
|
+
try:
|
|
2274
|
+
if xtab[0] & 0xe0 == 0xc0: # two numbers
|
|
2275
|
+
cc = (xtab[0] & 0x1f) << 6
|
|
2276
|
+
cc += (xtab[1] & 0x3f)
|
|
2277
|
+
elif xtab[0] & 0xf0 == 0xe0: # three numbers
|
|
2278
|
+
cc = (xtab[0] & 0x0f) << 12
|
|
2279
|
+
cc += (xtab[1] & 0x3f) << 6
|
|
2280
|
+
cc += (xtab[2] & 0x3f)
|
|
2281
|
+
elif xtab[0] & 0xf8 == 0xf0: # four numbers
|
|
2282
|
+
cc = (xtab[0] & 0x0e) << 18
|
|
2283
|
+
cc += (xtab[1] & 0x3f) << 12
|
|
2284
|
+
cc += (xtab[2] & 0x3f) << 6
|
|
2285
|
+
cc += (xtab[3] & 0x3f)
|
|
2286
|
+
elif xtab[0] & 0xfc == 0xf8: # five numbers
|
|
2287
|
+
cc = (xtab[0] & 0x03) << 24
|
|
2288
|
+
cc += (xtab[1] & 0x3f) << 18
|
|
2289
|
+
cc += (xtab[2] & 0x3f) << 12
|
|
2290
|
+
cc += (xtab[3] & 0x3f) << 6
|
|
2291
|
+
cc += (xtab[4] & 0x3f)
|
|
2292
|
+
elif xtab[0] & 0xfe == 0xf8: # six numbers
|
|
2293
|
+
cc = (xtab[0] & 0x01) << 30
|
|
2294
|
+
cc += (xtab[1] & 0x3f) << 24
|
|
2295
|
+
cc += (xtab[2] & 0x3f) << 18
|
|
2296
|
+
cc += (xtab[3] & 0x3f) << 12
|
|
2297
|
+
cc += (xtab[4] & 0x3f) << 6
|
|
2298
|
+
cc += (xtab[5] & 0x3f)
|
|
2299
|
+
|
|
2300
|
+
ccc = unichr(cc)
|
|
2301
|
+
except:
|
|
2302
|
+
pass
|
|
2303
|
+
|
|
2304
|
+
return ccc</code></pre>
|
|
2305
|
+
</details>
|
|
2306
|
+
</dd>
|
|
2307
|
+
<dt id="pgutils.untab_str"><code class="name flex">
|
|
2308
|
+
<span>def <span class="ident">untab_str</span></span>(<span>strx, tabstop=4)</span>
|
|
2309
|
+
</code></dt>
|
|
2310
|
+
<dd>
|
|
2311
|
+
<div class="desc"></div>
|
|
2312
|
+
<details class="source">
|
|
2313
|
+
<summary>
|
|
2314
|
+
<span>Expand source code</span>
|
|
2315
|
+
</summary>
|
|
2316
|
+
<pre><code class="python">def untab_str(strx, tabstop = 4):
|
|
2317
|
+
res = ""; idx = 0; cnt = 0
|
|
2318
|
+
xlen = len(strx)
|
|
2319
|
+
while True:
|
|
2320
|
+
if idx >= xlen: break
|
|
2321
|
+
chh = strx[idx]
|
|
2322
|
+
if chh == "\t":
|
|
2323
|
+
# Generate string
|
|
2324
|
+
spaces = tabstop - (cnt % tabstop)
|
|
2325
|
+
ttt = ""
|
|
2326
|
+
for aa in range(spaces):
|
|
2327
|
+
ttt += " "
|
|
2328
|
+
res += ttt
|
|
2329
|
+
cnt += spaces
|
|
2330
|
+
else:
|
|
2331
|
+
cnt += 1
|
|
2332
|
+
res += chh
|
|
2333
|
+
idx += 1
|
|
2334
|
+
return res</code></pre>
|
|
2335
|
+
</details>
|
|
2336
|
+
</dd>
|
|
2337
|
+
<dt id="pgutils.usleep"><code class="name flex">
|
|
2338
|
+
<span>def <span class="ident">usleep</span></span>(<span>msec)</span>
|
|
2339
|
+
</code></dt>
|
|
2340
|
+
<dd>
|
|
2341
|
+
<div class="desc"></div>
|
|
2342
|
+
<details class="source">
|
|
2343
|
+
<summary>
|
|
2344
|
+
<span>Expand source code</span>
|
|
2345
|
+
</summary>
|
|
2346
|
+
<pre><code class="python">def usleep(msec):
|
|
2347
|
+
|
|
2348
|
+
if sys.version_info[0] < 3 or \
|
|
2349
|
+
(sys.version_info[0] == 3 and sys.version_info[1] < 3):
|
|
2350
|
+
timefunc = time.clock
|
|
2351
|
+
else:
|
|
2352
|
+
timefunc = time.process_time
|
|
2353
|
+
|
|
2354
|
+
got_clock = timefunc() + float(msec) / 1000
|
|
2355
|
+
#print( got_clock)
|
|
2356
|
+
while True:
|
|
2357
|
+
if timefunc() > got_clock:
|
|
2358
|
+
break
|
|
2359
|
+
#print ("Sleeping")
|
|
2360
|
+
Gtk.main_iteration_do(False)</code></pre>
|
|
2361
|
+
</details>
|
|
2362
|
+
</dd>
|
|
2363
|
+
<dt id="pgutils.withps"><code class="name flex">
|
|
2364
|
+
<span>def <span class="ident">withps</span></span>(<span>func, opt=None)</span>
|
|
2365
|
+
</code></dt>
|
|
2366
|
+
<dd>
|
|
2367
|
+
<div class="desc"></div>
|
|
2368
|
+
<details class="source">
|
|
2369
|
+
<summary>
|
|
2370
|
+
<span>Expand source code</span>
|
|
2371
|
+
</summary>
|
|
2372
|
+
<pre><code class="python">def withps(func, opt = None):
|
|
2373
|
+
|
|
2374
|
+
ret = False
|
|
2375
|
+
dl = os.listdir("/proc")
|
|
2376
|
+
for aa in dl:
|
|
2377
|
+
fname = "/proc/" + aa + "/stat"
|
|
2378
|
+
if os.path.isfile(fname):
|
|
2379
|
+
ff = open(fname, "r").read().split()
|
|
2380
|
+
ret = func(ff, opt)
|
|
2381
|
+
if ret:
|
|
2382
|
+
break
|
|
2383
|
+
return ret</code></pre>
|
|
2384
|
+
</details>
|
|
2385
|
+
</dd>
|
|
2386
|
+
<dt id="pgutils.wrapscroll"><code class="name flex">
|
|
2387
|
+
<span>def <span class="ident">wrapscroll</span></span>(<span>what)</span>
|
|
2388
|
+
</code></dt>
|
|
2389
|
+
<dd>
|
|
2390
|
+
<div class="desc"></div>
|
|
2391
|
+
<details class="source">
|
|
2392
|
+
<summary>
|
|
2393
|
+
<span>Expand source code</span>
|
|
2394
|
+
</summary>
|
|
2395
|
+
<pre><code class="python">def wrapscroll(what):
|
|
2396
|
+
|
|
2397
|
+
scroll2 = Gtk.ScrolledWindow()
|
|
2398
|
+
scroll2.add(what)
|
|
2399
|
+
frame2 = Gtk.Frame()
|
|
2400
|
+
frame2.add(scroll2)
|
|
2401
|
+
return frame2</code></pre>
|
|
2402
|
+
</details>
|
|
2403
|
+
</dd>
|
|
2404
|
+
</dl>
|
|
2405
|
+
</section>
|
|
2406
|
+
<section>
|
|
2407
|
+
<h2 class="section-title" id="header-classes">Classes</h2>
|
|
2408
|
+
<dl>
|
|
2409
|
+
<dt id="pgutils.Config"><code class="flex name class">
|
|
2410
|
+
<span>class <span class="ident">Config</span></span>
|
|
2411
|
+
<span>(</span><span>optarr)</span>
|
|
2412
|
+
</code></dt>
|
|
2413
|
+
<dd>
|
|
2414
|
+
<div class="desc"></div>
|
|
2415
|
+
<details class="source">
|
|
2416
|
+
<summary>
|
|
2417
|
+
<span>Expand source code</span>
|
|
2418
|
+
</summary>
|
|
2419
|
+
<pre><code class="python">class Config:
|
|
2420
|
+
|
|
2421
|
+
def __init__(self, optarr):
|
|
2422
|
+
self.optarr = optarr
|
|
2423
|
+
self.verbose = False
|
|
2424
|
+
self.debug = False
|
|
2425
|
+
|
|
2426
|
+
def comline(self, argv):
|
|
2427
|
+
optletters = ""
|
|
2428
|
+
for aa in self.optarr:
|
|
2429
|
+
optletters += aa[0]
|
|
2430
|
+
#print( optletters )
|
|
2431
|
+
# Create defaults:
|
|
2432
|
+
err = 0
|
|
2433
|
+
for bb in range(len(self.optarr)):
|
|
2434
|
+
if self.optarr[bb][1]:
|
|
2435
|
+
# Coerse type
|
|
2436
|
+
if type(self.optarr[bb][2]) == type(0):
|
|
2437
|
+
self.__dict__[self.optarr[bb][1]] = int(self.optarr[bb][2])
|
|
2438
|
+
if type(self.optarr[bb][2]) == type(""):
|
|
2439
|
+
self.__dict__[self.optarr[bb][1]] = str(self.optarr[bb][2])
|
|
2440
|
+
try:
|
|
2441
|
+
opts, args = getopt.getopt(argv, optletters)
|
|
2442
|
+
#except getopt.GetoptError, err:
|
|
2443
|
+
except:
|
|
2444
|
+
print( "Invalid option(s) on command line:", err)
|
|
2445
|
+
#support.put_exception("comline")
|
|
2446
|
+
return ()
|
|
2447
|
+
|
|
2448
|
+
#print( "opts", opts, "args", args)
|
|
2449
|
+
for aa in opts:
|
|
2450
|
+
for bb in range(len(self.optarr)):
|
|
2451
|
+
if aa[0][1] == self.optarr[bb][0][0]:
|
|
2452
|
+
#print( "match", aa, self.optarr[bb])
|
|
2453
|
+
if len(self.optarr[bb][0]) > 1:
|
|
2454
|
+
#print( "arg", self.optarr[bb][1], aa[1])
|
|
2455
|
+
if self.optarr[bb][2] != None:
|
|
2456
|
+
if type(self.optarr[bb][2]) == type(0):
|
|
2457
|
+
self.__dict__[self.optarr[bb][1]] = int(aa[1])
|
|
2458
|
+
if type(self.optarr[bb][2]) == type(""):
|
|
2459
|
+
self.__dict__[self.optarr[bb][1]] = str(aa[1])
|
|
2460
|
+
else:
|
|
2461
|
+
#print( "set", self.optarr[bb][1], self.optarr[bb][2])
|
|
2462
|
+
if self.optarr[bb][2] != None:
|
|
2463
|
+
self.__dict__[self.optarr[bb][1]] = 1
|
|
2464
|
+
#print( "call", self.optarr[bb][3])
|
|
2465
|
+
if self.optarr[bb][3] != None:
|
|
2466
|
+
self.optarr[bb][3]()
|
|
2467
|
+
return args</code></pre>
|
|
2468
|
+
</details>
|
|
2469
|
+
<h3>Methods</h3>
|
|
2470
|
+
<dl>
|
|
2471
|
+
<dt id="pgutils.Config.comline"><code class="name flex">
|
|
2472
|
+
<span>def <span class="ident">comline</span></span>(<span>self, argv)</span>
|
|
2473
|
+
</code></dt>
|
|
2474
|
+
<dd>
|
|
2475
|
+
<div class="desc"></div>
|
|
2476
|
+
<details class="source">
|
|
2477
|
+
<summary>
|
|
2478
|
+
<span>Expand source code</span>
|
|
2479
|
+
</summary>
|
|
2480
|
+
<pre><code class="python">def comline(self, argv):
|
|
2481
|
+
optletters = ""
|
|
2482
|
+
for aa in self.optarr:
|
|
2483
|
+
optletters += aa[0]
|
|
2484
|
+
#print( optletters )
|
|
2485
|
+
# Create defaults:
|
|
2486
|
+
err = 0
|
|
2487
|
+
for bb in range(len(self.optarr)):
|
|
2488
|
+
if self.optarr[bb][1]:
|
|
2489
|
+
# Coerse type
|
|
2490
|
+
if type(self.optarr[bb][2]) == type(0):
|
|
2491
|
+
self.__dict__[self.optarr[bb][1]] = int(self.optarr[bb][2])
|
|
2492
|
+
if type(self.optarr[bb][2]) == type(""):
|
|
2493
|
+
self.__dict__[self.optarr[bb][1]] = str(self.optarr[bb][2])
|
|
2494
|
+
try:
|
|
2495
|
+
opts, args = getopt.getopt(argv, optletters)
|
|
2496
|
+
#except getopt.GetoptError, err:
|
|
2497
|
+
except:
|
|
2498
|
+
print( "Invalid option(s) on command line:", err)
|
|
2499
|
+
#support.put_exception("comline")
|
|
2500
|
+
return ()
|
|
2501
|
+
|
|
2502
|
+
#print( "opts", opts, "args", args)
|
|
2503
|
+
for aa in opts:
|
|
2504
|
+
for bb in range(len(self.optarr)):
|
|
2505
|
+
if aa[0][1] == self.optarr[bb][0][0]:
|
|
2506
|
+
#print( "match", aa, self.optarr[bb])
|
|
2507
|
+
if len(self.optarr[bb][0]) > 1:
|
|
2508
|
+
#print( "arg", self.optarr[bb][1], aa[1])
|
|
2509
|
+
if self.optarr[bb][2] != None:
|
|
2510
|
+
if type(self.optarr[bb][2]) == type(0):
|
|
2511
|
+
self.__dict__[self.optarr[bb][1]] = int(aa[1])
|
|
2512
|
+
if type(self.optarr[bb][2]) == type(""):
|
|
2513
|
+
self.__dict__[self.optarr[bb][1]] = str(aa[1])
|
|
2514
|
+
else:
|
|
2515
|
+
#print( "set", self.optarr[bb][1], self.optarr[bb][2])
|
|
2516
|
+
if self.optarr[bb][2] != None:
|
|
2517
|
+
self.__dict__[self.optarr[bb][1]] = 1
|
|
2518
|
+
#print( "call", self.optarr[bb][3])
|
|
2519
|
+
if self.optarr[bb][3] != None:
|
|
2520
|
+
self.optarr[bb][3]()
|
|
2521
|
+
return args</code></pre>
|
|
2522
|
+
</details>
|
|
2523
|
+
</dd>
|
|
2524
|
+
</dl>
|
|
2525
|
+
</dd>
|
|
2526
|
+
<dt id="pgutils.Unbuffered"><code class="flex name class">
|
|
2527
|
+
<span>class <span class="ident">Unbuffered</span></span>
|
|
2528
|
+
<span>(</span><span>stream)</span>
|
|
2529
|
+
</code></dt>
|
|
2530
|
+
<dd>
|
|
2531
|
+
<div class="desc"></div>
|
|
2532
|
+
<details class="source">
|
|
2533
|
+
<summary>
|
|
2534
|
+
<span>Expand source code</span>
|
|
2535
|
+
</summary>
|
|
2536
|
+
<pre><code class="python">class Unbuffered(object):
|
|
2537
|
+
def __init__(self, stream):
|
|
2538
|
+
self.stream = stream
|
|
2539
|
+
|
|
2540
|
+
def write(self, data):
|
|
2541
|
+
self.stream.write(data)
|
|
2542
|
+
self.stream.flush()
|
|
2543
|
+
|
|
2544
|
+
def writelines(self, datas):
|
|
2545
|
+
self.stream.writelines(datas)
|
|
2546
|
+
self.stream.flush()
|
|
2547
|
+
|
|
2548
|
+
def __getattr__(self, attr):
|
|
2549
|
+
return getattr(self.stream, attr)</code></pre>
|
|
2550
|
+
</details>
|
|
2551
|
+
<h3>Methods</h3>
|
|
2552
|
+
<dl>
|
|
2553
|
+
<dt id="pgutils.Unbuffered.write"><code class="name flex">
|
|
2554
|
+
<span>def <span class="ident">write</span></span>(<span>self, data)</span>
|
|
2555
|
+
</code></dt>
|
|
2556
|
+
<dd>
|
|
2557
|
+
<div class="desc"></div>
|
|
2558
|
+
<details class="source">
|
|
2559
|
+
<summary>
|
|
2560
|
+
<span>Expand source code</span>
|
|
2561
|
+
</summary>
|
|
2562
|
+
<pre><code class="python">def write(self, data):
|
|
2563
|
+
self.stream.write(data)
|
|
2564
|
+
self.stream.flush()</code></pre>
|
|
2565
|
+
</details>
|
|
2566
|
+
</dd>
|
|
2567
|
+
<dt id="pgutils.Unbuffered.writelines"><code class="name flex">
|
|
2568
|
+
<span>def <span class="ident">writelines</span></span>(<span>self, datas)</span>
|
|
2569
|
+
</code></dt>
|
|
2570
|
+
<dd>
|
|
2571
|
+
<div class="desc"></div>
|
|
2572
|
+
<details class="source">
|
|
2573
|
+
<summary>
|
|
2574
|
+
<span>Expand source code</span>
|
|
2575
|
+
</summary>
|
|
2576
|
+
<pre><code class="python">def writelines(self, datas):
|
|
2577
|
+
self.stream.writelines(datas)
|
|
2578
|
+
self.stream.flush()</code></pre>
|
|
2579
|
+
</details>
|
|
2580
|
+
</dd>
|
|
2581
|
+
</dl>
|
|
2582
|
+
</dd>
|
|
2583
|
+
</dl>
|
|
2584
|
+
</section>
|
|
2585
|
+
</article>
|
|
2586
|
+
<nav id="sidebar">
|
|
2587
|
+
<h1>Index</h1>
|
|
2588
|
+
<div class="toc">
|
|
2589
|
+
<ul></ul>
|
|
2590
|
+
</div>
|
|
2591
|
+
<ul id="index">
|
|
2592
|
+
<li><h3><a href="#header-functions">Functions</a></h3>
|
|
2593
|
+
<ul class="">
|
|
2594
|
+
<li><code><a title="pgutils.about" href="#pgutils.about">about</a></code></li>
|
|
2595
|
+
<li><code><a title="pgutils.ampmstr" href="#pgutils.ampmstr">ampmstr</a></code></li>
|
|
2596
|
+
<li><code><a title="pgutils.clean_str" href="#pgutils.clean_str">clean_str</a></code></li>
|
|
2597
|
+
<li><code><a title="pgutils.clean_str2" href="#pgutils.clean_str2">clean_str2</a></code></li>
|
|
2598
|
+
<li><code><a title="pgutils.col2float" href="#pgutils.col2float">col2float</a></code></li>
|
|
2599
|
+
<li><code><a title="pgutils.col2str" href="#pgutils.col2str">col2str</a></code></li>
|
|
2600
|
+
<li><code><a title="pgutils.decode_bits" href="#pgutils.decode_bits">decode_bits</a></code></li>
|
|
2601
|
+
<li><code><a title="pgutils.find" href="#pgutils.find">find</a></code></li>
|
|
2602
|
+
<li><code><a title="pgutils.float2col" href="#pgutils.float2col">float2col</a></code></li>
|
|
2603
|
+
<li><code><a title="pgutils.float2str" href="#pgutils.float2str">float2str</a></code></li>
|
|
2604
|
+
<li><code><a title="pgutils.get_realtime" href="#pgutils.get_realtime">get_realtime</a></code></li>
|
|
2605
|
+
<li><code><a title="pgutils.get_screen_wh" href="#pgutils.get_screen_wh">get_screen_wh</a></code></li>
|
|
2606
|
+
<li><code><a title="pgutils.get_screen_xy" href="#pgutils.get_screen_xy">get_screen_xy</a></code></li>
|
|
2607
|
+
<li><code><a title="pgutils.get_time" href="#pgutils.get_time">get_time</a></code></li>
|
|
2608
|
+
<li><code><a title="pgutils.hash_name" href="#pgutils.hash_name">hash_name</a></code></li>
|
|
2609
|
+
<li><code><a title="pgutils.isTrue" href="#pgutils.isTrue">isTrue</a></code></li>
|
|
2610
|
+
<li><code><a title="pgutils.is_ascii" href="#pgutils.is_ascii">is_ascii</a></code></li>
|
|
2611
|
+
<li><code><a title="pgutils.isfile" href="#pgutils.isfile">isfile</a></code></li>
|
|
2612
|
+
<li><code><a title="pgutils.kill_non_ascii" href="#pgutils.kill_non_ascii">kill_non_ascii</a></code></li>
|
|
2613
|
+
<li><code><a title="pgutils.leadspace" href="#pgutils.leadspace">leadspace</a></code></li>
|
|
2614
|
+
<li><code><a title="pgutils.mainloop" href="#pgutils.mainloop">mainloop</a></code></li>
|
|
2615
|
+
<li><code><a title="pgutils.oct2int" href="#pgutils.oct2int">oct2int</a></code></li>
|
|
2616
|
+
<li><code><a title="pgutils.opendialog" href="#pgutils.opendialog">opendialog</a></code></li>
|
|
2617
|
+
<li><code><a title="pgutils.print_exception" href="#pgutils.print_exception">print_exception</a></code></li>
|
|
2618
|
+
<li><code><a title="pgutils.put_debug2" href="#pgutils.put_debug2">put_debug2</a></code></li>
|
|
2619
|
+
<li><code><a title="pgutils.put_exception" href="#pgutils.put_exception">put_exception</a></code></li>
|
|
2620
|
+
<li><code><a title="pgutils.put_exception2_old" href="#pgutils.put_exception2_old">put_exception2_old</a></code></li>
|
|
2621
|
+
<li><code><a title="pgutils.readfile" href="#pgutils.readfile">readfile</a></code></li>
|
|
2622
|
+
<li><code><a title="pgutils.register_stock_icons" href="#pgutils.register_stock_icons">register_stock_icons</a></code></li>
|
|
2623
|
+
<li><code><a title="pgutils.respath" href="#pgutils.respath">respath</a></code></li>
|
|
2624
|
+
<li><code><a title="pgutils.rgb2col" href="#pgutils.rgb2col">rgb2col</a></code></li>
|
|
2625
|
+
<li><code><a title="pgutils.rgb2str" href="#pgutils.rgb2str">rgb2str</a></code></li>
|
|
2626
|
+
<li><code><a title="pgutils.savedialog" href="#pgutils.savedialog">savedialog</a></code></li>
|
|
2627
|
+
<li><code><a title="pgutils.str2col" href="#pgutils.str2col">str2col</a></code></li>
|
|
2628
|
+
<li><code><a title="pgutils.str2float" href="#pgutils.str2float">str2float</a></code></li>
|
|
2629
|
+
<li><code><a title="pgutils.time_n2s" href="#pgutils.time_n2s">time_n2s</a></code></li>
|
|
2630
|
+
<li><code><a title="pgutils.time_s2n" href="#pgutils.time_s2n">time_s2n</a></code></li>
|
|
2631
|
+
<li><code><a title="pgutils.tmpname" href="#pgutils.tmpname">tmpname</a></code></li>
|
|
2632
|
+
<li><code><a title="pgutils.unescape" href="#pgutils.unescape">unescape</a></code></li>
|
|
2633
|
+
<li><code><a title="pgutils.uni" href="#pgutils.uni">uni</a></code></li>
|
|
2634
|
+
<li><code><a title="pgutils.untab_str" href="#pgutils.untab_str">untab_str</a></code></li>
|
|
2635
|
+
<li><code><a title="pgutils.usleep" href="#pgutils.usleep">usleep</a></code></li>
|
|
2636
|
+
<li><code><a title="pgutils.withps" href="#pgutils.withps">withps</a></code></li>
|
|
2637
|
+
<li><code><a title="pgutils.wrapscroll" href="#pgutils.wrapscroll">wrapscroll</a></code></li>
|
|
2638
|
+
</ul>
|
|
2639
|
+
</li>
|
|
2640
|
+
<li><h3><a href="#header-classes">Classes</a></h3>
|
|
2641
|
+
<ul>
|
|
2642
|
+
<li>
|
|
2643
|
+
<h4><code><a title="pgutils.Config" href="#pgutils.Config">Config</a></code></h4>
|
|
2644
|
+
<ul class="">
|
|
2645
|
+
<li><code><a title="pgutils.Config.comline" href="#pgutils.Config.comline">comline</a></code></li>
|
|
2646
|
+
</ul>
|
|
2647
|
+
</li>
|
|
2648
|
+
<li>
|
|
2649
|
+
<h4><code><a title="pgutils.Unbuffered" href="#pgutils.Unbuffered">Unbuffered</a></code></h4>
|
|
2650
|
+
<ul class="">
|
|
2651
|
+
<li><code><a title="pgutils.Unbuffered.write" href="#pgutils.Unbuffered.write">write</a></code></li>
|
|
2652
|
+
<li><code><a title="pgutils.Unbuffered.writelines" href="#pgutils.Unbuffered.writelines">writelines</a></code></li>
|
|
2653
|
+
</ul>
|
|
2654
|
+
</li>
|
|
2655
|
+
</ul>
|
|
2656
|
+
</li>
|
|
2657
|
+
</ul>
|
|
2658
|
+
</nav>
|
|
2659
|
+
</main>
|
|
2660
|
+
<footer id="footer">
|
|
2661
|
+
<p>Generated by <a href="https://pdoc3.github.io/pdoc" title="pdoc: Python API documentation generator"><cite>pdoc</cite> 0.10.0</a>.</p>
|
|
2662
|
+
</footer>
|
|
2663
|
+
</body>
|
|
2664
|
+
</html>
|