diff --git a/.gitignore b/.gitignore index 6042030..aa5dfc8 100644 --- a/.gitignore +++ b/.gitignore @@ -7,5 +7,4 @@ __pycache__ dist *.egg-info .tox -build -test*.py \ No newline at end of file +build \ No newline at end of file diff --git a/scripts/dropdown_item.py b/scripts/dropdown_item.py index 67266de..b73a747 100644 --- a/scripts/dropdown_item.py +++ b/scripts/dropdown_item.py @@ -4,20 +4,15 @@ ts = TS() ts.loads(url) -dashboard = ts.getDashboard() +workbook = ts.getWorkbook() +# show parameters columns/values +parameters = workbook.getParameters() +print(parameters) -# show dropdown input name -inputNames = dashboard.getDropdownInputs() -print(inputNames) - -# show dropdown values for a given input name -values = dashboard.getDropdownValues("P.League 2") -print(values) - -# select that value -dashboard = dashboard.setDropdown("P.League 2", "Ligue 1") +# set parameter +workbook = workbook.setParameter("P.League 2", "Ligue 1") # display worksheets -for t in dashboard.worksheets: +for t in workbook.worksheets: print(t.data) diff --git a/scripts/get_worksheets.py b/scripts/get_worksheets.py index 1ca0d64..c80d7ae 100644 --- a/scripts/get_worksheets.py +++ b/scripts/get_worksheets.py @@ -4,9 +4,9 @@ ts = TS() ts.loads(url) -dashboard = ts.getDashboard() +workbook = ts.getWorkbook() -for t in dashboard.worksheets: +for t in workbook.worksheets: # show worksheet name print(f"WORKSHEET NAME : {t.name}") # show dataframe for this worksheet diff --git a/scripts/prompt.py b/scripts/prompt.py index 6e71077..2f1a2f1 100644 --- a/scripts/prompt.py +++ b/scripts/prompt.py @@ -10,7 +10,7 @@ parser.add_argument( "-get", "--get", - choices=["dashboard", "dropdown", "select"], + choices=["workbook", "parameter", "select"], help="type of action", required=True, ) @@ -26,17 +26,17 @@ # with open('info.json', 'w', encoding='utf-8') as f: # json.dump(ts.info, f, ensure_ascii=False, indent=4) -if args.get == "dashboard": - dashboard = ts.promptDashboard() -elif args.get == "dropdown": - dashboard = ts.promptDropdown() +if args.get == "workbook": + workbook = ts.promptDashboard() +elif args.get == "parameter": + workbook = ts.promptParameters() elif args.get == "select": - dashboard = ts.promptSelect() + workbook = ts.promptSelect() with pd.option_context( "display.max_rows", None, "display.max_columns", 5, "display.width", 1000 ): - for idx, worksheet in enumerate(dashboard.worksheets): + for idx, worksheet in enumerate(workbook.worksheets): if idx == 0: print("|" + ("-" * (os.get_terminal_size().columns - 2)) + "|") print("|" + worksheet.name.center(os.get_terminal_size().columns - 2) + "|") @@ -44,20 +44,20 @@ print(worksheet.data) print("") # selectable values - selectableColumns = worksheet.getSelectableColumns() - print(f"selectable columns for this worksheet : {len(selectableColumns)}") - for columnName in selectableColumns: - print("• " + columnName) - # for value in worksheet.getValues(columnName): - # print("\t•" + value) + selection = worksheet.getSelectableItems() + print( + f"selectable items for this worksheet : {len(selection)}") + for select in selection: + print(f'column: ${select["column"]}') + print(f'values: {select["values"]}') + print("--------------") print("") print("|" + ("-" * (os.get_terminal_size().columns - 2)) + "|") - # dropdown list - dropdownInputs = dashboard.getDropdownInputs() - print(f"drop down lists for this dashboard : {len(dropdownInputs)}") - for inputName in dropdownInputs: - print("• " + inputName) - for inputValue in dashboard.getDropdownValues(inputName): - print("\t• " + inputValue) + # parameters list + parameters = workbook.getParameters() + print(f"parameters lists for this workbook : {len(parameters)}") + for param in parameters: + print(param) + print(param["values"]) diff --git a/scripts/select_item.py b/scripts/select_item.py index d51aca1..2ec21e3 100644 --- a/scripts/select_item.py +++ b/scripts/select_item.py @@ -5,18 +5,14 @@ ts = TS() ts.loads(url) -# show selectable columns -columns = ts.getWorksheet("ATT MID CREATIVE COMP").getSelectableColumns() -print(columns) +ws = ts.getWorksheet("ATT MID CREATIVE COMP") -# show values by column name -values = ts.getWorksheet("ATT MID CREATIVE COMP").getValues("ATTR(Player)") -print(values) +# show selectable values +selections = ws.getSelectableItems() +print(selections) # select that value -dashboard = ts.getWorksheet("ATT MID CREATIVE COMP").select( - "ATTR(Player)", "Vinicius Júnior" -) +dashboard = ws.select("ATTR(Player)", "Vinicius Júnior") # display worksheets for t in dashboard.worksheets: