Compare commits

...

10 Commits

Author SHA1 Message Date
openeuler-ci-bot
036100c66e
!19 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:14 +00:00
zhangliangpengkun
8f9712ebe2 Add script for detecting character widths and dumping width tables
Signed-off-by: zhangliangpengkun <zhangliangpengkun@xfusion.com>
2023-01-17 11:38:16 +08:00
openeuler-ci-bot
90acb4b7a0
!14 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:35 +00:00
zhangliangpengkun
6e050309b3 fix: use trio.lowlevel instead of trio.hazmat with Trio >= 0.15
Signed-off-by: zhangliangpengkun <zhangliangpengkun@xfusion.com>
2023-01-13 17:42:41 +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
openeuler-ci-bot
4e36df88b2 !5 Completing build dependencies
From: @hht8
Reviewed-by: @small_leek
Signed-off-by: @small_leek
2021-06-01 16:15:01 +08:00
hht8
3c3b18a8be Completing build dependencies 2021-06-01 14:53:40 +08:00
openeuler-ci-bot
f6ed08271f !4 remove python2 of package python-urwid
From: @zhanghua1831
Reviewed-by: @small_leek
Signed-off-by: @small_leek
2020-10-30 09:38:32 +08:00
zhanghua
68f6f93611 remove python2 of package python-urwid 2020-10-29 15:33:12 +08:00
5 changed files with 285 additions and 34 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,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,71 +1,61 @@
Name: python-urwid Name: python-urwid
Version: 2.0.1 Version: 2.1.2
Release: 5 Release: 3
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
%description %description
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
%package -n python2-urwid
Summary: %summary
%{?python_provide:%python_provide python2-urwid}
BuildRequires: gcc python2-devel python2-setuptools python2-twisted pygobject2 python2-test
%description -n python2-urwid
Urwid is a console user interface library for Python. It includes
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 BuildRequires: python3-devel python3-setuptools python3-test /usr/bin/2to3 gcc
%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 {} \;
rm -rf %{py3dir}
cp -a . %{py3dir}
%build %build
%py2_build
cd %{py3dir}
%py3_build %py3_build
cd -
find examples -type f -exec chmod 0644 \{\} \; find examples -type f -exec chmod 0644 \{\} \;
%check %check
PYTHON=%{__python2} %{__python2} setup.py test
cd %{py3dir}
PYTHON=%{__python3} %{__python3} setup.py test PYTHON=%{__python3} %{__python3} setup.py test
cd -
%install %install
%py2_install
cd %{py3dir}
%py3_install %py3_install
cd -
%files -n python2-urwid
%doc README.rst examples docs COPYING
%{python2_sitearch}/urwid
%{python2_sitearch}/urwid-2.0.1*.egg-info
%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
* Fri Nov 22 2019 sunguoshuai <sunguoshuai@huawei.com> - 2.3-6 * Tue Jan 17 2023 zhangliangpengkun<zhangliangpengkun@xfusion.com> - 2.1.2-3
- Add-script-for-detecting-character-widths-and-dumping-width-tables.patch
* Fri Jan 13 2023 zhangliangpengkun<zhangliangpengkun@xfusion.com> - 2.1.2-2
- fix-use-trio-lowlevel-instead-of-trio.patch
* 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
- Completing build dependencies
* Thu Oct 22 2020 zhanghua <zhanghua40@huawei.com> - 2.3-6
- remove python2 subpackage
* Fri Nov 22 2019 sunguoshuai <sunguoshuai@huawei.com> - 2.3-5
- Package init. - Package init.

Binary file not shown.

BIN
urwid-2.1.2.tar.gz Normal file

Binary file not shown.