Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
silkaj
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
clients
python
silkaj
Commits
d9a4ddc6
Commit
d9a4ddc6
authored
2 years ago
by
matograine
Committed by
Moul
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[enh] tx_history: Migrate from tabulate to texttable (
#203
)
parent
a89e7105
No related branches found
No related tags found
1 merge request
!199
#203: Harmonize tables style using Texttable
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
silkaj/tx_history.py
+12
-16
12 additions, 16 deletions
silkaj/tx_history.py
with
12 additions
and
16 deletions
silkaj/tx_history.py
+
12
−
16
View file @
d9a4ddc6
...
...
@@ -13,7 +13,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with Silkaj. If not, see <https://www.gnu.org/licenses/>.
import
shutil
from
operator
import
eq
,
itemgetter
,
ne
,
neg
from
typing
import
Any
,
List
,
Optional
,
Tuple
from
urllib.error
import
HTTPError
...
...
@@ -24,7 +23,6 @@ from duniterpy.api.client import Client
from
duniterpy.documents.transaction
import
OutputSource
,
Transaction
from
duniterpy.grammars.output
import
Condition
from
pendulum
import
from_timestamp
,
now
from
texttable
import
Texttable
from
silkaj
import
wot_tools
as
wt
from
silkaj.constants
import
ALL
,
ALL_DIGITAL
...
...
@@ -32,7 +30,7 @@ from silkaj.crypto_tools import check_pubkey_format, validate_checksum
from
silkaj.money
import
amount_in_current_base
,
get_amount_from_pubkey
,
get_ud_value
from
silkaj.network_tools
import
client_instance
from
silkaj.tools
import
get_currency_symbol
from
silkaj.tui
import
gen_pubkey_checksum
from
silkaj.tui
import
Table
,
gen_pubkey_checksum
@command
(
"
history
"
,
help
=
"
Display transaction history
"
)
...
...
@@ -51,11 +49,19 @@ def transaction_history(pubkey: str, uids: bool, full_pubkey: bool) -> None:
received_txs
,
sent_txs
=
[],
[]
# type: List[Transaction], List[Transaction]
get_transactions_history
(
client
,
pubkey
,
received_txs
,
sent_txs
)
remove_duplicate_txs
(
received_txs
,
sent_txs
)
txs_list
=
generate_table
(
received_txs
,
sent_txs
,
pubkey
,
ud_value
,
currency_symbol
,
uids
,
full_pubkey
)
table
=
Texttable
(
max_width
=
shutil
.
get_terminal_size
().
columns
)
table
.
add_rows
(
txs_list
)
table_headers
=
[
"
Date
"
,
"
Issuers/Recipients
"
,
f
"
Amounts
{
currency_symbol
}
"
,
f
"
Amounts UD
{
currency_symbol
}
"
,
"
Comment
"
,
]
table
=
Table
()
table
.
fill_rows
(
txs_list
,
table_headers
)
echo_via_pager
(
header
+
table
.
draw
())
...
...
@@ -109,9 +115,8 @@ def generate_table(
full_pubkey
:
bool
,
)
->
List
:
"""
Generate information in a list of lists for texttabe
Generate information in a list of lists for texttab
l
e
Merge received and sent txs
Insert table header at the end not to disturb its generation
Sort txs temporarily
"""
...
...
@@ -125,15 +130,6 @@ def generate_table(
parse_sent_tx
(
sent_txs_table
,
sent_txs
,
pubkey
,
ud_value
,
uids
,
full_pubkey
)
txs_table
=
received_txs_table
+
sent_txs_table
table_titles
=
[
"
Date
"
,
"
Issuers/Recipients
"
,
f
"
Amounts
{
currency_symbol
}
"
,
f
"
Amounts UD
{
currency_symbol
}
"
,
"
Comment
"
,
]
txs_table
.
insert
(
0
,
table_titles
)
txs_table
.
sort
(
key
=
itemgetter
(
0
),
reverse
=
True
)
return
txs_table
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment