!75 删除TerminalTable类
Merge pull request !75 from LiHeavy/openEuler-22.03-LTS-Next
This commit is contained in:
commit
74ec3c0321
123
0009-delete-terminal-fix-build-failed.patch
Normal file
123
0009-delete-terminal-fix-build-failed.patch
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
diff --color -Nur a/packageship/application/cli/base.py b/packageship/application/cli/base.py
|
||||||
|
--- a/packageship/application/cli/base.py 2021-08-14 22:23:58.000000000 +0800
|
||||||
|
+++ b/packageship/application/cli/base.py 2022-01-09 11:17:09.842737171 +0800
|
||||||
|
@@ -30,7 +30,6 @@
|
||||||
|
else:
|
||||||
|
from packageship.application.common.constant import ResponseCode
|
||||||
|
from packageship.application.common.constant import ERROR_CON
|
||||||
|
- from packageship.libs.terminal_table import TerminalTable
|
||||||
|
|
||||||
|
|
||||||
|
class BaseCommand():
|
||||||
|
@@ -130,8 +129,7 @@
|
||||||
|
Raises:
|
||||||
|
|
||||||
|
"""
|
||||||
|
- table = TerminalTable(title)
|
||||||
|
- # table.set_style(prettytable.PLAIN_COLUMNS)
|
||||||
|
+ table = prettytable.PrettyTable(title)
|
||||||
|
table.align = 'l'
|
||||||
|
table.horizontal_char = '='
|
||||||
|
table.junction_char = '='
|
||||||
|
diff --color -Nur a/packageship/application/cli/cmd.py b/packageship/application/cli/cmd.py
|
||||||
|
--- a/packageship/application/cli/cmd.py 2021-08-14 22:23:58.000000000 +0800
|
||||||
|
+++ b/packageship/application/cli/cmd.py 2022-01-09 11:17:30.935093041 +0800
|
||||||
|
@@ -26,7 +26,6 @@
|
||||||
|
from packageship.application.common.constant import ResponseCode
|
||||||
|
from packageship.application.common.constant import ListNode
|
||||||
|
from packageship.application.common.constant import UWSIG_PATH
|
||||||
|
- from packageship.libs.terminal_table import TerminalTable
|
||||||
|
from packageship.application.common.constant import ERROR_CON
|
||||||
|
from packageship.application.cli.commands.allpkg import AllPackageCommand
|
||||||
|
from packageship.application.cli.commands.bedepend import BeDependCommand
|
||||||
|
diff --color -Nur a/packageship/libs/terminal_table.py b/packageship/libs/terminal_table.py
|
||||||
|
--- a/packageship/libs/terminal_table.py 2021-08-14 22:23:59.000000000 +0800
|
||||||
|
+++ b/packageship/libs/terminal_table.py 1970-01-01 08:00:00.000000000 +0800
|
||||||
|
@@ -1,87 +0,0 @@
|
||||||
|
-#!/usr/bin/python3
|
||||||
|
-# ******************************************************************************
|
||||||
|
-# Copyright (c) Huawei Technologies Co., Ltd. 2020-2021. All rights reserved.
|
||||||
|
-# licensed under the Mulan PSL v2.
|
||||||
|
-# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||||
|
-# You may obtain a copy of Mulan PSL v2 at:
|
||||||
|
-# http://license.coscl.org.cn/MulanPSL2
|
||||||
|
-# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||||
|
-# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||||
|
-# PURPOSE.
|
||||||
|
-# See the Mulan PSL v2 for more details.
|
||||||
|
-# ******************************************************************************/
|
||||||
|
-"""
|
||||||
|
-Description: Simple encapsulation of pretty table
|
||||||
|
-Class: TerminalTable
|
||||||
|
-"""
|
||||||
|
-import os
|
||||||
|
-from prettytable import PrettyTable
|
||||||
|
-
|
||||||
|
-
|
||||||
|
-class TerminalTable(PrettyTable):
|
||||||
|
- """
|
||||||
|
- Description: Rewrite several methods in prettytable
|
||||||
|
- Attributes:
|
||||||
|
- bottom:Bottom display
|
||||||
|
- _vertical_char:Draw characters with vertical edges
|
||||||
|
- """
|
||||||
|
-
|
||||||
|
- def __init__(self, field_names=None, **kwargs):
|
||||||
|
- super().__init__(field_names, **kwargs)
|
||||||
|
- self.bottom = kwargs.get('bottom') or False
|
||||||
|
- self._vertical_char = kwargs.get('vertical_char') or self._unicode("")
|
||||||
|
-
|
||||||
|
- def _reduce_widths(self, columns, lpad, rpad):
|
||||||
|
- """
|
||||||
|
- Description: Handling over-width columns
|
||||||
|
- Args:
|
||||||
|
- columns:columns
|
||||||
|
- lpad:The number of spaces to the left of the column data
|
||||||
|
- rpad:The number of spaces to the right of the column data
|
||||||
|
- Returns:
|
||||||
|
-
|
||||||
|
- """
|
||||||
|
- extra_width = sum(self._widths) - columns + (lpad + rpad) * len(self._widths)
|
||||||
|
- avg_width = columns / len(self._widths)
|
||||||
|
- gt_avg = filter(lambda x: x > avg_width, self._widths)
|
||||||
|
- denominator = sum(
|
||||||
|
- [(item - avg_width) / avg_width * 1.0 for item in gt_avg])
|
||||||
|
- zoom_width = list()
|
||||||
|
- for width in self._widths:
|
||||||
|
- if width > avg_width:
|
||||||
|
- width = round(width - ((width - avg_width) / avg_width * 1.0) /
|
||||||
|
- denominator * extra_width)
|
||||||
|
- zoom_width.append(width)
|
||||||
|
- self._widths = zoom_width
|
||||||
|
- if sum(self._widths) > columns:
|
||||||
|
- _max_val = max(self._widths)
|
||||||
|
- self._widths[self._widths.index(_max_val)] = _max_val - (sum(self._widths) - columns)
|
||||||
|
-
|
||||||
|
- def _compute_widths(self, rows, options):
|
||||||
|
- """
|
||||||
|
- Description: Calculated width
|
||||||
|
- Args:
|
||||||
|
- rows:row of data, should be a list with as many elements as the table
|
||||||
|
- options:option
|
||||||
|
- Returns:
|
||||||
|
-
|
||||||
|
- """
|
||||||
|
- super()._compute_widths(rows, options)
|
||||||
|
- lpad, rpad = self._get_padding_widths(options)
|
||||||
|
- # Total number of columns
|
||||||
|
- try:
|
||||||
|
- window_width = os.get_terminal_size().columns
|
||||||
|
- except OSError as os_error:
|
||||||
|
- window_width = 100
|
||||||
|
- _columns = window_width - len(self._widths) - 1
|
||||||
|
- if _columns < sum(map(lambda x: x + lpad + rpad, self._widths)):
|
||||||
|
- coefficient = 1
|
||||||
|
- self._reduce_widths(_columns, lpad, rpad)
|
||||||
|
- else:
|
||||||
|
- coefficient = _columns / (sum(map(lambda x: x, self._widths)) * 1.0)
|
||||||
|
- self._widths = list(
|
||||||
|
- map(lambda x: round(x * coefficient - lpad - rpad), self._widths))
|
||||||
|
- if sum(map(lambda x: x + lpad + rpad, self._widths)) > _columns:
|
||||||
|
- _max_val = max(self._widths)
|
||||||
|
- self._widths[self._widths.index(_max_val)] =\
|
||||||
|
- _max_val - (sum(map(lambda x: x + lpad + rpad, self._widths)) - _columns)
|
||||||
@ -1,6 +1,6 @@
|
|||||||
Name: pkgship
|
Name: pkgship
|
||||||
Version: 2.2.0
|
Version: 2.2.0
|
||||||
Release: 8
|
Release: 9
|
||||||
Summary: Pkgship implements rpm package dependence ,maintainer, patch query and so on.
|
Summary: Pkgship implements rpm package dependence ,maintainer, patch query and so on.
|
||||||
License: Mulan 2.0
|
License: Mulan 2.0
|
||||||
URL: https://gitee.com/openeuler/pkgship
|
URL: https://gitee.com/openeuler/pkgship
|
||||||
@ -13,6 +13,7 @@ Patch0005: 0005-update-validate-encoding-format.patch
|
|||||||
Patch0006: 0006-update-copyright.patch
|
Patch0006: 0006-update-copyright.patch
|
||||||
Patch0007: 0007-update-readme-about-docker.patch
|
Patch0007: 0007-update-readme-about-docker.patch
|
||||||
Patch0008: 0008-fix-simplejson-question.patch
|
Patch0008: 0008-fix-simplejson-question.patch
|
||||||
|
Patch0009: 0009-delete-terminal-fix-build-failed.patch
|
||||||
|
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
|
|
||||||
@ -118,6 +119,9 @@ create_dir_file /var/log/pkgship-operation 700 d
|
|||||||
%attr(0640,pkgshipuser,pkgshipuser) /lib/systemd/system/pkgship.service
|
%attr(0640,pkgshipuser,pkgshipuser) /lib/systemd/system/pkgship.service
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Sun Jan 9 2022 Haiwei Li <lihaiwei8@huawei.com> - 2.2.0-9
|
||||||
|
- TerminalTable class Use the deprecated method of PrettyTable, resulting in compilation failure, delete the file.
|
||||||
|
|
||||||
* Thu Nov 18 2021 Haiwei Li <lihaiwei8@huawei.com> - 2.2.0-8
|
* Thu Nov 18 2021 Haiwei Li <lihaiwei8@huawei.com> - 2.2.0-8
|
||||||
- Solve the problem of patch application failure due to the file encoding format being crlf.
|
- Solve the problem of patch application failure due to the file encoding format being crlf.
|
||||||
- Solve the problem of json serialization caused by flask's new dependency on simple-json.
|
- Solve the problem of json serialization caused by flask's new dependency on simple-json.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user