Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
[pylint.messages_control]
disable =
C0303, # Trailing whitespace
C0103, # Variable names
C0305, # Trailing newlines
C0304, # Missing final line
C0301, # Line too long
I1101, E1101, # C-modules members
W0621, # Redefine outer name
R0913 # Too many arguments

[MASTER]
ignore-paths = ^tests/ # Ignore the tests folder
119 changes: 0 additions & 119 deletions ITK_dev_shared_components/SAP/sap_login.py

This file was deleted.

71 changes: 0 additions & 71 deletions ITK_dev_shared_components/SAP/tree_util.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import requests
from bs4 import BeautifulSoup

from ITK_dev_shared_components.graph.authentication import GraphAccess
from itk_dev_shared_components.graph.authentication import GraphAccess


@dataclass
Expand Down Expand Up @@ -234,8 +234,6 @@ def delete_email(email: Email, graph_access: GraphAccess, *, permanent: bool=Fal
move_email(email, "deleteditems", graph_access, well_known_folder=True)




def _find_folder(response: dict, target_folder: str) -> str:
"""Find the target folder in

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
"""This module provides static functions to peform common tasks with SAP GuiGridView COM objects."""
"""This module provides static functions to perform common tasks with SAP GuiGridView COM objects."""

def scroll_entire_table(grid_view, return_to_top=False) -> None:
"""This function scrolls through the entire table to load all cells.

Args:
grid_view: A SAP GuiGridView object.
return_to_top: Whether to return the table to the first row after scrolling. Defaults to False.

Returns:
_type_: _description_
"""
"""
if grid_view.RowCount == 0 or grid_view.VisibleRowCount == 0:
return

for i in range(0, grid_view.RowCount, grid_view.VisibleRowCount):
grid_view.FirstVisibleRow = i

if return_to_top:
grid_view.FirstVisibleRow = 0

Expand All @@ -28,7 +27,7 @@ def get_all_rows(grid_view, pre_load=True) -> tuple[tuple[str]]:

Returns:
tuple[tuple[str]]: A 2D tuple of all cell values in the gridview.
"""
"""

if pre_load:
scroll_entire_table(grid_view, True)
Expand All @@ -43,9 +42,9 @@ def get_all_rows(grid_view, pre_load=True) -> tuple[tuple[str]]:
for c in columns:
v = grid_view.GetCellValue(r, c)
row_data.append(v)

output.append(tuple(row_data))

return tuple(output)


Expand All @@ -60,7 +59,7 @@ def get_row(grid_view, row:int, scroll_to_row=False) -> tuple[str]:

Returns:
tuple[str]: A tuple of the row's data.
"""
"""

if scroll_to_row:
grid_view.FirstVisibleRow = row
Expand All @@ -83,7 +82,7 @@ def iterate_rows(grid_view) -> tuple[str]:

Yields:
tuple[str]: A tuple of the next row's data.
"""
"""

row = 0
while row < grid_view.RowCount:
Expand All @@ -104,7 +103,7 @@ def get_column_titles(grid_view) -> tuple[str]:

Returns:
tuple[str]: A tuple of the gridview's column titles.
"""
"""

return tuple(grid_view.GetColumnTitles(c)[0] for c in grid_view.ColumnOrder)

Expand All @@ -123,7 +122,7 @@ def find_row_index_by_value(grid_view, column:str, value:str) -> int:

Returns:
int: The index of the first row which column value matches the given value.
"""
"""

if column not in grid_view.ColumnOrder:
raise ValueError(f"Column '{column}' not in grid_view")
Expand All @@ -132,14 +131,14 @@ def find_row_index_by_value(grid_view, column:str, value:str) -> int:
# Only scroll when row isn't visible
if not grid_view.FirstVisibleRow <= row <= grid_view.FirstVisibleRow + grid_view.VisibleRowCount-1:
grid_view.FirstVisibleRow = row

if grid_view.GetCellValue(row, column) == value:
return row

return -1

def find_all_row_indecies_by_value(grid_view, column:str, value:str) -> list[int]:
"""Find all indecies of the rows where the given column's value
def find_all_row_indices_by_value(grid_view, column:str, value:str) -> list[int]:
"""Find all indices of the rows where the given column's value
match the given value. Returns an empty list if no row is found.

Args:
Expand All @@ -151,8 +150,8 @@ def find_all_row_indecies_by_value(grid_view, column:str, value:str) -> list[int
ValueError: If the column name doesn't exist in the grid view.

Returns:
list[int]: A list of row indecies where the value matches.
"""
list[int]: A list of row indices where the value matches.
"""
if column not in grid_view.ColumnOrder:
raise ValueError(f"Column '{column}' not in grid_view")

Expand All @@ -162,39 +161,8 @@ def find_all_row_indecies_by_value(grid_view, column:str, value:str) -> list[int
# Only scroll when row isn't visible
if not grid_view.FirstVisibleRow <= row <= grid_view.FirstVisibleRow + grid_view.VisibleRowCount-1:
grid_view.FirstVisibleRow = row

if grid_view.GetCellValue(row, column) == value:
rows.append(row)

return rows




if __name__=='__main__':
import win32com.client

SAP = win32com.client.GetObject("SAPGUI")
app = SAP.GetScriptingEngine
connection = app.Connections(0)
session = connection.Sessions(0)

table = session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell")

rows = find_all_row_indecies_by_value(table, "ZZ_PARTNER", '15879880')
print(rows)
table.setCurrentCell(rows[0], "ZZ_PARTNER")

# print(get_row(table, 1, True))

# scroll_entire_table(table)

# data = get_all_rows(table)
# print(len(data), len(data[0]))

# for r in iterate_rows(table):
# print(r)

# print(get_column_titles(table))


return rows
Loading