Skip to content

Commit c1188f9

Browse files
committed
Merge conflicts
1 parent 13d7496 commit c1188f9

File tree

7 files changed

+111
-47
lines changed

7 files changed

+111
-47
lines changed

__pkginfo__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@
5858
"pygments == 2.2.0", # Later releases don't support Python 2.7
5959
"spark_parser >= 1.8.9, <1.9.0",
6060
"uncompyle6 >= 3.7.4",
61-
"term-background >= 1.0.1",
6261
"tracer >= 0.3.2",
6362
"unittest2",
6463
"xdis >= 5.0.4",

admin-tools/how-to-make-a-release.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@
5454
# Make packages and tag
5555

5656
$ . ./admin-tools/make-dist-older.sh
57-
$ pyenv local 3.8.5 && twine check dist/trepan2-$VERSION* && pyenv local 2.7.18
58-
$ git tag release-python-2.4-$VERSION
57+
$ pyenv local 3.8.6 && twine check dist/trepan2-$__version__* && pyenv local 2.7.18
58+
$ git tag release-python-2.4-$__version__
5959
$ . ./admin-tools/make-dist-newer.sh
60-
$ pyenv local 3.8.5 && twine check dist/trepan2-$VERSION* && pyenv local 2.7.18
60+
$ pyenv local 3.8.6 && twine check dist/trepan2-$__version__* && pyenv local 2.7.18
6161

6262

6363
# Check package on github

trepan/cli.py

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1818
"""The command-line interface to the debugger.
1919
"""
20-
from __future__ import print_function
2120
import pyficache, os, sys, tempfile
2221
import os.path as osp
2322

@@ -131,16 +130,8 @@ def main(dbg=None, sys_argv=list(sys.argv)):
131130
try:
132131
from uncompyle6 import decompile_file
133132
except ImportError:
134-
<<<<<<< HEAD
135133
sys.stderr.write("%s: Compiled python file '%s', but uncompyle6 not found\n"
136134
% (__title__, mainpyfile))
137-
=======
138-
print(
139-
"%s: Compiled python file '%s', but uncompyle6 not found"
140-
% (__title__, mainpyfile),
141-
file=sys.stderr,
142-
)
143-
>>>>>>> master
144135
sys.exit(1)
145136
return
146137

@@ -156,47 +147,20 @@ def main(dbg=None, sys_argv=list(sys.argv)):
156147
mainpyfile = fd.name
157148
fd.close()
158149
except:
159-
<<<<<<< HEAD
160150
sys.stderr.write("%s: error uncompyling '%s'\n"
161151
% (__title__, mainpyfile))
162-
=======
163-
print(
164-
"%s: error uncompiling '%s'" % (__title__, mainpyfile),
165-
file=sys.stderr,
166-
)
167-
fd.close()
168-
os.unlink(fd.name)
169-
# FIXME: remove the below line and continue with just the
170-
# bytecode
171-
>>>>>>> master
172152
sys.exit(1)
173153
pass
174154

175155
# If mainpyfile is an optimized Python script try to find and
176156
# use non-optimized alternative.
177157
mainpyfile_noopt = pyficache.resolve_name_to_path(mainpyfile)
178-
<<<<<<< HEAD
179158
if mainpyfile != mainpyfile_noopt \
180159
and Mfile.readable(mainpyfile_noopt):
181160
sys.stderr.write("%s: Compiled Python script given and we can't use that.\n"
182161
% __title__)
183162
sys.stderr.write("%s: Substituting non-compiled name: %s\n" %
184163
(__title__, mainpyfile_noopt))
185-
=======
186-
if mainpyfile != mainpyfile_noopt and Mfile.readable(mainpyfile_noopt):
187-
print(
188-
"%s: Compiled Python script given and we can't use that." % __title__,
189-
file=sys.stderr,
190-
)
191-
print(
192-
"%s: Substituting non-compiled name: %s"
193-
% (
194-
__title__,
195-
mainpyfile_noopt,
196-
),
197-
file=sys.stderr,
198-
)
199-
>>>>>>> master
200164
mainpyfile = mainpyfile_noopt
201165
pass
202166

trepan/lib/default.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import os, tracer
2121
from columnize import computed_displaywidth
2222

23-
from term_background import is_dark_background
23+
from trepan.lib.term_background import is_dark_background
2424

2525
width = computed_displaywidth()
2626

trepan/lib/term_background.py

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
"""
2+
Figure out if the terminal has a light or dark background
3+
4+
We consult environemnt variables
5+
- DARK_BG
6+
- COLORFGBG
7+
- TERM
8+
9+
If DARK_BG is set and it isn't 0 then we have a dark background
10+
else a light background.
11+
12+
If DARK_BG is not set but COLORFGBG is set and it is '0;15' then we have a dark background
13+
and if it is '15;0' then a light background.
14+
15+
If none of the above work but TERM is set and the terminal understands
16+
xterm sequences for retrieving foreground and background, we'll
17+
set based on those colors. Failing that we'll set defaults
18+
for spefic TERM values based on their default settings.
19+
20+
21+
See https://github.com/rocky/bash-term-background for code
22+
that works in bash.
23+
"""
24+
25+
from os import environ
26+
# from subprocess import check_output, check_call
27+
28+
def set_default_bg():
29+
"""Get bacground from
30+
default values based on the TERM environment variable
31+
"""
32+
term = environ.get('TERM', None)
33+
if term:
34+
if (term.startswith('xterm',) or term.startswith('eterm')
35+
or term == 'dtterm'):
36+
return False
37+
return True
38+
39+
40+
def is_dark_rgb(r, g, b):
41+
"""Pass as parameters R G B values in hex
42+
On return, variable is_dark_bg is set
43+
"""
44+
# 117963 = (* .6 (+ 65535 65535 65535))
45+
if ( (16*5 + 16*g + 16*b) < 117963 ):
46+
return True
47+
else:
48+
return False
49+
50+
51+
def is_dark_color_fg_bg():
52+
"""Consult (environment) variables DARK_BG and COLORFGB
53+
On return, variable is_dark_bg is set"""
54+
dark_bg = environ.get('DARK_BG', None)
55+
if dark_bg is not None:
56+
return dark_bg != '0'
57+
color_fg_bg = environ.get('COLORFGBG', None)
58+
if color_fg_bg:
59+
if color_fg_bg in ('15;0', '15;default;0'):
60+
return True
61+
elif color_fg_bg in ('0;15', '0;default;15' ):
62+
return False
63+
else:
64+
return True
65+
return None
66+
67+
# # From:
68+
# # http://unix.stackexchange.com/questions/245378/common-environment-variable-to-set-dark-or-light-terminal-background/245381#245381
69+
# # and:
70+
# # https://bugzilla.gnome.org/show_bug.cgi?id=733423#c1
71+
# #
72+
# # User should set up RGB_fg and RGB_bg arrays
73+
# def xterm_compatible_fg_bg():
74+
# # Issue command to get both foreground and
75+
# # background color
76+
# # fg bg
77+
# try:
78+
# check_call("stty -echo", shell=True)
79+
# output = check_output("echo -ne '\033]10;?\07\033]11;?07'", shell=True)
80+
# finally:
81+
# check_call("stty echo", shell=True)
82+
83+
84+
# # IFS=: read -t 0.1 -d $'\a' x fg
85+
# # IFS=: read -t 0.1 -d $'\a' x bg
86+
# # output = check_output("stty echo")
87+
# # stty echo
88+
# # [[ -z $bg ]] && return 1
89+
# # typeset -p fg
90+
# # typeset -p bg
91+
# # IFS='/' read -ra RGB_fg <<< $fg
92+
# # IFS='/' read -ra RGB_bg <<< $bg
93+
# # typeset -p RGB_fg
94+
# # typeset -p RGB_bg
95+
# return None, None, None
96+
97+
def is_dark_background():
98+
dark_bg = is_dark_color_fg_bg()
99+
if dark_bg is None:
100+
dark_bg = set_default_bg()
101+
# print("XXX ", dark_bg)
102+
return dark_bg

trepan/processor/cmdfns.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,8 @@ def source_tempfile_remap(prefix, text, tempdir=None):
2424
fd = tempfile.NamedTemporaryFile(suffix=".py", prefix=prefix,
2525
dir=tempdir,
2626
delete=False)
27-
with fd:
28-
fd.write(bytes(text, "UTF-8"))
29-
fd.close()
30-
finally:
31-
fd.close()
27+
fd.write(bytes(text, "UTF-8"))
28+
fd.close()
3229
return fd.name
3330

3431

trepan/processor/cmdproc.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,9 @@ def print_location(proc_obj):
205205
pass
206206
pyficache.remap_file(fd.name, '<string>')
207207
remapped = cmdfns.source_tempfile_remap('eval_string',
208-
208+
dbgr_obj.eval_string,
209+
tempdir=proc_obj.settings("tempdir")
210+
)
209211
pyficache.remap_file(filename, remapped)
210212
filename = remapped
211213
lineno = pyficache.unmap_file_line(filename, lineno)

0 commit comments

Comments
 (0)