Skip to content

Commit

Permalink
update scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
bertrandmartel committed Mar 21, 2021
1 parent 008b7c4 commit ac144cd
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 45 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ __pycache__
dist
*.egg-info
.tox
build
test*.py
build
19 changes: 7 additions & 12 deletions scripts/dropdown_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
4 changes: 2 additions & 2 deletions scripts/get_worksheets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
40 changes: 20 additions & 20 deletions scripts/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
parser.add_argument(
"-get",
"--get",
choices=["dashboard", "dropdown", "select"],
choices=["workbook", "parameter", "select"],
help="type of action",
required=True,
)
Expand All @@ -26,38 +26,38 @@
# 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) + "|")
print("|" + ("-" * (os.get_terminal_size().columns - 2)) + "|")
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"])
14 changes: 5 additions & 9 deletions scripts/select_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit ac144cd

Please sign in to comment.