Skip to content

Commit

Permalink
fix gppc namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
moxxos committed Oct 7, 2022
1 parent 3189919 commit 0e53b5e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 28 deletions.
2 changes: 1 addition & 1 deletion src/gppc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"""

from gppc.__version__ import __version__
from gppc.gppc import _main, _search_item_data
from gppc._gppc import _main, _search_item_data


def search(item: str) -> list[tuple[str, str, str, str]]:
Expand Down
26 changes: 2 additions & 24 deletions src/gppc/_display.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,5 @@ def _print_item_data(item_data: list[tuple[str, str, str, str, str, str]]) -> No
item[0] + '\033]8;;\033\\', end='')
print(item_str[n1:n2], end='')
print(' \u251C\u2500 ' + item[2] + item_str[n2:n3], end='')
print(' \u2514 ' + item[3] + item_str[n3:], end='')


def _print_item_data_old(item_data: list[tuple[str, str, str, str]]) -> None:
longest_prop = [0, 0, 0, 0]
for item in item_data:
longest_prop = list(
map(lambda a, b: max(a, len(b)), longest_prop, item))

item_pic = _ready_test_image()

for item in item_data:
# 4 element array of 2-tuples containing padding for
# the left and right of each item property:
# [(name_padding_left, name_padding_right), ...]
padding_array = list(
map(lambda a, b: ((x := abs((y := len(b) - a))//2), x + (y % 2 > 0)), longest_prop, item))
item_str = " | Item: %(name_pad_l)s%(name)s%(name_pad_r)s | ID: %(id_pad_l)s%(id)s%(id_pad_r)s | Price: %(price_pad_l)s%(price)s%(price_pad_r)s | 24h Change: %(change_pad_l)s%(change)s%(change_pad_r)s" % {
'name': item[0], 'name_pad_l': ' '*padding_array[0][0], 'name_pad_r': ' '*padding_array[0][1],
'id': item[1], 'id_pad_l': ' '*padding_array[1][0], 'id_pad_r': ' '*padding_array[1][1],
'price': item[2], 'price_pad_l': ' '*padding_array[2][0], 'price_pad_r': ' '*padding_array[2][1],
'change': item[3], 'change_pad_l': ' '*padding_array[3][0], 'change_pad_r': ' '*padding_array[3][1]}
item_str = item_pic[0:159+164] + item_str + item_pic[159+164:]
print(item_str + ' and the link is ' + item[4])
print(' \u2514\u2500 ' +
item[3].replace(' ', '') + item_str[n3:], end='')
7 changes: 4 additions & 3 deletions src/gppc/gppc.py → src/gppc/_gppc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# Package Modules
from gppc.__description__ import short_description
from gppc import _display
from gppc._display import _print_item_data

# External Packages
import requests
Expand Down Expand Up @@ -166,7 +166,8 @@ def _search_item_data(item: str) -> list[tuple[str, str, str, str, str, str]]:

def _command_line_parser(item_argument: str) -> argparse.ArgumentParser:
"""Creates the command line parser."""
parser = argparse.ArgumentParser(description=short_description)
parser = argparse.ArgumentParser(
description=short_description)
parser.add_argument(
item_argument,
metavar='I',
Expand All @@ -187,7 +188,7 @@ def _main() -> None:
for item in args[item_argument]:
item = item.replace('_', ' ')
total_item_data += _search_item_data(item)
_display._print_item_data(total_item_data)
_print_item_data(total_item_data)


if (__name__ == "__main__"):
Expand Down

0 comments on commit 0e53b5e

Please sign in to comment.