Compare commits

...

10 Commits

Author SHA1 Message Date
openeuler-ci-bot
8ad380b462
!20 fix test failuer due to python3.11
From: @cherry530 
Reviewed-by: @caodongxia 
Signed-off-by: @caodongxia
2023-07-22 08:14:25 +00:00
cherry530
efbb638cbf fix test failure
Signed-off-by: cherry530 <707078654@qq.com>
2023-07-22 15:42:59 +08:00
openeuler-ci-bot
885127fdce
!17 Add script for detecting character widths and dumping width tables
From: @zhang-liang-pengkun 
Reviewed-by: @Charlie_li 
Signed-off-by: @Charlie_li
2023-01-17 07:33:37 +00:00
zhangliangpengkun
05e47c0725 Add script for detecting character widths and dumping width tables
Signed-off-by: zhangliangpengkun <zhangliangpengkun@xfusion.com>
2023-01-17 11:36:51 +08:00
openeuler-ci-bot
dd88eb94c8
!12 fix: use trio.lowlevel instead of trio.hazmat with Trio >= 0.15
From: @zhang-liang-pengkun 
Reviewed-by: @Charlie_li 
Signed-off-by: @Charlie_li
2023-01-13 10:55:16 +00:00
zhangliangpengkun
b19920a6c8 fix: use trio.lowlevel instead of trio.hazmat with Trio >= 0.15
Signed-off-by: zhangliangpengkun <zhangliangpengkun@xfusion.com>
2023-01-13 17:36:33 +08:00
openeuler-ci-bot
32dec01552
!11 Add buildrequires glibc-all-langpacks to fix build failed
From: @lyn1001 
Reviewed-by: @small_leek 
Signed-off-by: @small_leek
2022-06-07 06:55:20 +00:00
lyn1001
1b367b3bbc Addbuildrequires glibc-all-langpacks to fix build failed 2022-06-07 14:24:28 +08:00
openeuler-ci-bot
7b6407f1e1 !6 update to 2.1.2
From: @lyn1001
Reviewed-by: @small_leek
Signed-off-by: @small_leek
2021-07-27 06:36:47 +00:00
lyn1001
8dcf6cebb6 update to 2.1.2 2021-07-27 11:31:10 +08:00
6 changed files with 304 additions and 6 deletions

View File

@ -0,0 +1,208 @@
From e57d55a11d3df86c8da12a27ba6146aa052ef359 Mon Sep 17 00:00:00 2001
From: Tony Cebzanov <tonycpsu@gmail.com>
Date: Sat, 13 Jun 2020 20:45:05 -0400
Subject: [PATCH] Add script for detecting character widths and dumping width
tables
New char_width_tools.py script. Usage:
To detect character widths for the current terminal:
./char_width_tools.py analyze terminal.csv
To print the widths of each character in a string:
./char_width_tools.py test "string"
To load a file saved with "analyze" as C/Python source to be pasted
into str_util.c and old_str_util.python:
./char_width_tools.py dump terminal.csv c
./char_width_tools.py dump terminal.csv python
---
bin/char_width_tools.py | 172 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 172 insertions(+)
create mode 100644 bin/char_width_tools.py
diff --git a/bin/char_width_tools.py b/bin/char_width_tools.py
new file mode 100644
index 0000000..8ab40ed
--- /dev/null
+++ b/bin/char_width_tools.py
@@ -0,0 +1,172 @@
+#!/usr/bin/env python
+
+# Build a table of unicode character widths as rendered by the current terminal.
+
+import sys
+import tty
+import termios
+from select import select
+import re
+import argparse
+import csv
+
+MIN_CODE_POINT = 0
+MAX_CODE_POINT = 0x110000
+
+ESC = "\x1b"
+CLEAR = ESC + "[2J"
+
+BEGINNING_OF_LINE = ESC +"[1;2H"
+
+def getpos():
+
+ buf = ""
+ stdin = sys.stdin.fileno()
+ tattr = termios.tcgetattr(stdin)
+
+ try:
+ tty.setcbreak(stdin, termios.TCSANOW)
+ sys.stdout.write("\x1b[6n")
+ sys.stdout.flush()
+
+ while True:
+ buf += sys.stdin.read(1)
+ if buf[-1] == "R":
+ break
+
+ finally:
+ termios.tcsetattr(stdin, termios.TCSANOW, tattr)
+
+ return [
+ int(x)
+ for x in re.match(r"^\x1b\[(\d*);(\d*)R", buf).groups()
+ ]
+
+
+def get_width(i):
+ c = chr(i)
+ print(BEGINNING_OF_LINE)
+ try:
+ sys.stdout.write(c)
+ except UnicodeEncodeError:
+ return None
+ return getpos()[1]-1
+
+
+def test_string(s):
+
+ widths = []
+ for c in s:
+ widths.append(get_width(ord(c)))
+
+ print(CLEAR)
+
+ for c, w in zip(s, widths):
+ print("%s\t%d" %(c, w))
+ print()
+ print("total\t%d" %(sum(widths)))
+
+def write_table(filename):
+ widths = list()
+ last_width = None
+
+ try:
+ for i in range(MIN_CODE_POINT, MAX_CODE_POINT):
+ w = get_width(i)
+ if w is None:
+ continue
+ if i != MIN_CODE_POINT and w != last_width:
+ widths.append((i-1, last_width))
+ last_width = w
+ if not i % 1000:
+ pct = i / MAX_CODE_POINT
+ print()
+ print("%d/%d (%.02f%%)" %(i, MAX_CODE_POINT, pct*100))
+ widths.append((i, last_width))
+
+ finally:
+ with open(filename, "w") as f:
+ writer = csv.writer(f)
+ for w in widths:
+ writer.writerow("%d\t%d\n" %(w[0], w[1]))
+
+
+def dump(infile, lang):
+
+ widths = list()
+ last_width = None
+
+ with open(infile) as f:
+ reader = csv.reader(f)
+ for row in reader:
+ widths.append((row[0], row[1]))
+
+ if args.lang == "c":
+ print("static const int widths[] = {")
+ elif args.lang == "python":
+ print("widths = [")
+
+ for i, w in widths:
+ if lang == "c":
+ print(" %s, %s," %(i, w))
+
+ elif lang == "python":
+ print(" (%s, %s)," %(i, w))
+ else:
+ raise RuntimeError("unknown language")
+
+ if lang == "c":
+ print(" NULL")
+ print("};")
+ elif lang == "python":
+ print("]")
+
+def main():
+
+ global args
+ parser = argparse.ArgumentParser()
+
+ subparsers = parser.add_subparsers(dest="command", required=True)
+
+ analyze_parser = subparsers.add_parser(
+ "analyze",
+ help="analyze character widths and save them to csv file"
+ )
+ analyze_parser.add_argument(
+ "outfile", metavar="FILE",
+ help="write character widths to this file"
+ )
+ analyze_parser.set_defaults(func=lambda args: write_table(args.outfile))
+
+ test_parser = subparsers.add_parser(
+ "test",
+ help="analyze a set of characters specified on the command line"
+ )
+ test_parser.add_argument(
+ "string", metavar="CHAR",
+ help="character to test"
+ )
+ test_parser.set_defaults(func=lambda args: test_string(args.string))
+
+ dump_parser = subparsers.add_parser(
+ "dump",
+ help="generate source code for width tables from a saved file"
+ )
+ dump_parser.add_argument(
+ "infile", metavar="FILE",
+ help="read character widths from this file"
+ )
+ dump_parser.add_argument(
+ "lang", metavar="LANGUAGE", choices=["c", "python"],
+ help="Language to dump data for."
+ )
+ dump_parser.set_defaults(func=lambda args: dump(args.infile, args.lang))
+
+ args = parser.parse_args()
+
+ print(CLEAR)
+
+ args.func(args)
+
+if __name__ == "__main__":
+ main()
--
2.39.0.windows.2

View File

@ -0,0 +1,19 @@
--- urwid-2.1.2.orig/urwid/tests/test_event_loops.py
+++ urwid-2.1.2/urwid/tests/test_event_loops.py
@@ -201,15 +201,14 @@ else:
evl.alarm(0.5, lambda: 1 / 0) # Simulate error in event loop
self.assertRaises(ZeroDivisionError, evl.run)
- def test_coroutine_error(self):
+ async def test_coroutine_error(self):
evl = self.evl
- @asyncio.coroutine
- def error_coro():
+ async def error_coro():
result = 1 / 0 # Simulate error in coroutine
yield result
- asyncio.ensure_future(error_coro())
+ asyncio.ensure_future(await error_coro())
self.assertRaises(ZeroDivisionError, evl.run)

View File

@ -0,0 +1,53 @@
From a57465c94ba3a401531853b42e1bd071bcd2e93c Mon Sep 17 00:00:00 2001
From: Tamas Nepusz <ntamas@gmail.com>
Date: Mon, 2 Nov 2020 15:48:51 +0100
Subject: [PATCH] fix: use trio.lowlevel instead of trio.hazmat with Trio >=
0.15
---
urwid/_async_kw_event_loop.py | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/urwid/_async_kw_event_loop.py b/urwid/_async_kw_event_loop.py
index d146a49..4038405 100644
--- a/urwid/_async_kw_event_loop.py
+++ b/urwid/_async_kw_event_loop.py
@@ -42,7 +42,11 @@ class TrioEventLoop(EventLoop):
self._nursery = None
self._sleep = trio.sleep
- self._wait_readable = trio.hazmat.wait_readable
+ try:
+ self._wait_readable = trio.lowlevel.wait_readable
+ except AttributeError:
+ # Trio 0.14 or older
+ self._wait_readable = trio.hazmat.wait_readable
def alarm(self, seconds, callback):
"""Calls `callback()` a given time from now. No parameters are passed
@@ -155,12 +159,20 @@ class TrioEventLoop(EventLoop):
emulate_idle_callbacks = TrioIdleCallbackInstrument()
+ try:
+ add_instrument = self._trio.lowlevel.add_instrument
+ remove_instrument = self._trio.lowlevel.remove_instrument
+ except AttributeError:
+ # Trio 0.14 or older
+ add_instrument = self._trio.hazmat.add_instrument
+ remove_instrument = self._trio.hazmat.remove_instrument
+
with self._trio.MultiError.catch(self._handle_main_loop_exception):
- self._trio.hazmat.add_instrument(emulate_idle_callbacks)
+ add_instrument(emulate_idle_callbacks)
try:
await self._main_task()
finally:
- self._trio.hazmat.remove_instrument(emulate_idle_callbacks)
+ remove_instrument(emulate_idle_callbacks)
def watch_file(self, fd, callback):
"""Calls `callback()` when the given file descriptor has some data
--
2.39.0.windows.2

View File

@ -1,10 +1,13 @@
Name: python-urwid Name: python-urwid
Version: 2.0.1 Version: 2.1.2
Release: 7 Release: 5
Summary: Console user interface library Summary: Console user interface library
License: LGPLv2+ License: LGPLv2+
URL: http://excess.org/urwid/ URL: http://excess.org/urwid/
Source0: https://pypi.python.org/packages/source/u/urwid/urwid-2.0.1.tar.gz Source0: https://pypi.python.org/packages/source/u/urwid/urwid-%{version}.tar.gz
Patch0: fix-use-trio-lowlevel-instead-of-trio.patch
Patch1: Add-script-for-detecting-character-widths-and-dumping-width-tables.patch
Patch2: fix-test-failure-due-to-python11.patch
%description %description
Urwid is a console user interface library for Python. It includes Urwid is a console user interface library for Python. It includes
@ -13,14 +16,14 @@ many features useful for text console application developers
%package -n python3-urwid %package -n python3-urwid
Summary: %summary Summary: %summary
%{?python_provide:%python_provide python3-urwid} %{?python_provide:%python_provide python3-urwid}
BuildRequires: python3-devel python3-setuptools python3-test /usr/bin/2to3 gcc BuildRequires: python3-devel python3-setuptools python3-test /usr/bin/2to3 gcc glibc-all-langpacks
%description -n python3-urwid %description -n python3-urwid
Urwid is a console user interface library for Python. It includes Urwid is a console user interface library for Python. It includes
many features useful for text console application developers many features useful for text console application developers
%prep %prep
%autosetup -n urwid-2.0.1 -p1 %autosetup -n urwid-%{version} -p1
find urwid -type f -name "*.py" -exec sed -i -e '/^#!\//, 1d' {} \; find urwid -type f -name "*.py" -exec sed -i -e '/^#!\//, 1d' {} \;
find urwid -type f -name "*.py" -exec chmod 644 {} \; find urwid -type f -name "*.py" -exec chmod 644 {} \;
@ -37,9 +40,24 @@ PYTHON=%{__python3} %{__python3} setup.py test
%files -n python3-urwid %files -n python3-urwid
%doc README.rst examples docs COPYING %doc README.rst examples docs COPYING
%{python3_sitearch}/urwid %{python3_sitearch}/urwid
%{python3_sitearch}/urwid-2.0.1*.egg-info %{python3_sitearch}/urwid-%{version}*.egg-info
%changelog %changelog
* Sat Jul 22 2023 xu_ping<707078654@qq.com> - 2.1.2-5
- fix test failure due to python11
* Tue Jan 17 2023 zhangliangpengkun<zhangliangpengkun@xfusion.com> - 2.1.2-4
- Add-script-for-detecting-character-widths-and-dumping-width-tables.patch
* Fri Jan 13 2023 zhangliangpengkun<zhangliangpengkun@xfusion.com> - 2.1.2-3
- fix-use-trio-lowlevel-instead-of-trio.patch
* Tue Jul 27 2021 liyanan <liyanan32@huawei.com> - 2.1.2-2
- Add buildrequires glibc-all-langpacks to fix build failed
* Tue Jul 27 2021 liyanan <liyanan32@huawei.com> - 2.1.2-1
- update to 2.1.2
* Mon May 31 2021 huanghaitao <huanghaitao8@huawei.com> - 2.3-7 * Mon May 31 2021 huanghaitao <huanghaitao8@huawei.com> - 2.3-7
- Completing build dependencies - Completing build dependencies

Binary file not shown.

BIN
urwid-2.1.2.tar.gz Normal file

Binary file not shown.