py2ls 0.2.4.39__py3-none-any.whl → 0.2.4.41__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
py2ls/ips.py
CHANGED
@@ -3839,7 +3839,7 @@ def get_os(full=False, verbose=False):
|
|
3839
3839
|
import sys
|
3840
3840
|
import platform
|
3841
3841
|
import psutil
|
3842
|
-
import GPUtil
|
3842
|
+
# import GPUtil
|
3843
3843
|
import socket
|
3844
3844
|
import uuid
|
3845
3845
|
import cpuinfo
|
@@ -4246,23 +4246,23 @@ def get_os(full=False, verbose=False):
|
|
4246
4246
|
}
|
4247
4247
|
)
|
4248
4248
|
|
4249
|
-
# GPU Information
|
4250
|
-
gpus = GPUtil.getGPUs()
|
4251
|
-
for gpu in gpus:
|
4252
|
-
|
4253
|
-
|
4254
|
-
|
4255
|
-
|
4256
|
-
|
4257
|
-
|
4258
|
-
|
4259
|
-
|
4260
|
-
|
4261
|
-
|
4262
|
-
|
4263
|
-
|
4264
|
-
|
4265
|
-
|
4249
|
+
# # GPU Information
|
4250
|
+
# gpus = GPUtil.getGPUs()
|
4251
|
+
# for gpu in gpus:
|
4252
|
+
# gpu_info = {
|
4253
|
+
# "name": gpu.name,
|
4254
|
+
# "load (%)": gpu.load * 100,
|
4255
|
+
# "free memory (MB)": gpu.memoryFree,
|
4256
|
+
# "used memory (MB)": gpu.memoryUsed,
|
4257
|
+
# "total memory (MB)": gpu.memoryTotal,
|
4258
|
+
# "driver version": gpu.driver,
|
4259
|
+
# "temperature (°C)": gpu.temperature,
|
4260
|
+
# }
|
4261
|
+
# if hasattr(gpu, "powerDraw"):
|
4262
|
+
# gpu_info["Power Draw (W)"] = gpu.powerDraw
|
4263
|
+
# if hasattr(gpu, "powerLimit"):
|
4264
|
+
# gpu_info["Power Limit (W)"] = gpu.powerLimit
|
4265
|
+
# system_info["gpu"].append(gpu_info)
|
4266
4266
|
|
4267
4267
|
res = system_info if full else get_os_type()
|
4268
4268
|
if verbose:
|
@@ -6330,6 +6330,7 @@ def format_excel(
|
|
6330
6330
|
protect=None, # dict
|
6331
6331
|
number_format=None, # dict: e.g., {1:"0.00", 2:"#,##0",3:"0%",4:"$#,##0.00"}
|
6332
6332
|
data_validation=None, # dict
|
6333
|
+
apply_filter=True, # add filter
|
6333
6334
|
conditional_format=None, # dict
|
6334
6335
|
**kwargs,
|
6335
6336
|
):
|
@@ -6340,7 +6341,7 @@ def format_excel(
|
|
6340
6341
|
from openpyxl.utils import get_column_letter
|
6341
6342
|
from openpyxl.worksheet.datavalidation import DataValidation
|
6342
6343
|
from openpyxl.comments import Comment
|
6343
|
-
from openpyxl.formatting.rule import ColorScaleRule
|
6344
|
+
from openpyxl.formatting.rule import ColorScaleRule, DataBarRule, IconSetRule,IconSet
|
6344
6345
|
|
6345
6346
|
def convert_indices_to_range(row_slice, col_slice):
|
6346
6347
|
"""Convert numerical row and column slices to Excel-style range strings."""
|
@@ -6705,159 +6706,159 @@ def format_excel(
|
|
6705
6706
|
filename = str(datetime.now().strftime("%y%m%d_%H.xlsx"))
|
6706
6707
|
# !show usage:
|
6707
6708
|
func_xample = """
|
6708
|
-
# Example usage
|
6709
|
-
data = {
|
6710
|
-
|
6711
|
-
|
6712
|
-
|
6713
|
-
|
6714
|
-
|
6715
|
-
|
6716
|
-
|
6717
|
-
}
|
6718
|
-
df = pd.DataFrame(data)
|
6719
|
-
|
6720
|
-
|
6721
|
-
format_excel(
|
6722
|
-
df,
|
6723
|
-
filename="example.xlsx",
|
6724
|
-
sheet_name="Sheet1",
|
6725
|
-
cell=[
|
6726
|
-
{
|
6727
|
-
(slice(0, 1), slice(0, len(df.columns))): {
|
6728
|
-
"font": {
|
6729
|
-
"name": "Calibri", # Font name
|
6730
|
-
"size": 14, # Font size
|
6731
|
-
"bold": True, # Bold text
|
6732
|
-
"italic": False, # Italic text
|
6733
|
-
"underline": "single", # Underline (single, double)
|
6734
|
-
"color": "#FFFFFF", # Font color
|
6735
|
-
},
|
6736
|
-
"fill": {
|
6737
|
-
"start_color": "a1cd1e", # Starting color
|
6738
|
-
"end_color": "4F81BD", # Ending color (useful for gradients)
|
6739
|
-
"fill_type": "solid", # Fill type (solid, gradient, etc.)
|
6740
|
-
},
|
6741
|
-
"alignment": {
|
6742
|
-
"horizontal": "center", # Horizontal alignment (left, center, right)
|
6743
|
-
"vertical": "center", # Vertical alignment (top, center, bottom)
|
6744
|
-
"wrap_text": True, # Wrap text in the cell
|
6745
|
-
"shrink_to_fit": True, # Shrink text to fit within cell
|
6746
|
-
"text_rotation": 0, # Text rotation angle
|
6747
|
-
},
|
6748
|
-
"border": {
|
6749
|
-
"left": "thin",
|
6750
|
-
"right": "thin",
|
6751
|
-
"top": "thin",
|
6752
|
-
"bottom": "thin",
|
6753
|
-
"color": "000000", # Border color
|
6754
|
-
},
|
6709
|
+
# Example usage
|
6710
|
+
data = {
|
6711
|
+
"Header 1": [10, 2000000, 30],
|
6712
|
+
"Header 2": [
|
6713
|
+
40000,
|
6714
|
+
'"start_color": "4F81BD", "end_color","start_color": "a1cd1e","start_color": "4F81BD", "end_color","start_color": "a1cd1e"',
|
6715
|
+
60,
|
6716
|
+
],
|
6717
|
+
"Header 3": [70, 80, 90],
|
6755
6718
|
}
|
6756
|
-
|
6757
|
-
|
6758
|
-
|
6759
|
-
|
6760
|
-
|
6761
|
-
|
6762
|
-
|
6763
|
-
|
6764
|
-
|
6765
|
-
|
6719
|
+
df = pd.DataFrame(data)
|
6720
|
+
|
6721
|
+
|
6722
|
+
format_excel(
|
6723
|
+
df,
|
6724
|
+
filename="example.xlsx",
|
6725
|
+
sheet_name="Sheet1",
|
6726
|
+
cell=[
|
6727
|
+
{
|
6728
|
+
(slice(0, 1), slice(0, len(df.columns))): {
|
6729
|
+
"font": {
|
6730
|
+
"name": "Calibri", # Font name
|
6731
|
+
"size": 14, # Font size
|
6732
|
+
"bold": True, # Bold text
|
6733
|
+
"italic": False, # Italic text
|
6734
|
+
"underline": "single", # Underline (single, double)
|
6735
|
+
"color": "#FFFFFF", # Font color
|
6736
|
+
},
|
6737
|
+
"fill": {
|
6738
|
+
"start_color": "a1cd1e", # Starting color
|
6739
|
+
"end_color": "4F81BD", # Ending color (useful for gradients)
|
6740
|
+
"fill_type": "solid", # Fill type (solid, gradient, etc.)
|
6741
|
+
},
|
6742
|
+
"alignment": {
|
6743
|
+
"horizontal": "center", # Horizontal alignment (left, center, right)
|
6744
|
+
"vertical": "center", # Vertical alignment (top, center, bottom)
|
6745
|
+
"wrap_text": True, # Wrap text in the cell
|
6746
|
+
"shrink_to_fit": True, # Shrink text to fit within cell
|
6747
|
+
"text_rotation": 0, # Text rotation angle
|
6748
|
+
},
|
6749
|
+
"border": {
|
6750
|
+
"left": "thin",
|
6751
|
+
"right": "thin",
|
6752
|
+
"top": "thin",
|
6753
|
+
"bottom": "thin",
|
6754
|
+
"color": "000000", # Border color
|
6755
|
+
},
|
6756
|
+
}
|
6757
|
+
},
|
6758
|
+
{
|
6759
|
+
(slice(0, 3), slice(1, 3)): {
|
6760
|
+
"font": {
|
6761
|
+
"name": "Arial", # Font name
|
6762
|
+
"size": 12, # Font size
|
6763
|
+
"bold": False, # Bold text
|
6764
|
+
"italic": True, # Italic text
|
6765
|
+
"underline": None, # No underline
|
6766
|
+
"color": "#000000", # Font color
|
6767
|
+
},
|
6768
|
+
"fill": {
|
6769
|
+
"start_color": "#c61313", # Background color
|
6770
|
+
"end_color": "#490606", # End color
|
6771
|
+
"fill_type": "solid", # Fill type
|
6772
|
+
},
|
6773
|
+
"alignment": {
|
6774
|
+
"horizontal": "left", # Horizontal alignment
|
6775
|
+
"vertical": "top", # Vertical alignment
|
6776
|
+
"wrap_text": True, # Enable text wrapping
|
6777
|
+
"shrink_to_fit": False, # Disable shrink to fit
|
6778
|
+
"indent": 1, # Indentation level
|
6779
|
+
"text_rotation": 0, # Text rotation angle
|
6780
|
+
},
|
6781
|
+
"border": {
|
6782
|
+
"left": "thin", # Left border style
|
6783
|
+
"right": "thin", # Right border style
|
6784
|
+
"top": "thin", # Top border style
|
6785
|
+
"bottom": "thin", # Bottom border style
|
6786
|
+
"color": "000000", # Border color
|
6787
|
+
},
|
6788
|
+
}
|
6789
|
+
# * border settings
|
6790
|
+
# "thin": Thin border line
|
6791
|
+
# "medium": Medium border line
|
6792
|
+
# "thick": Thick border line
|
6793
|
+
# "dotted": Dotted border line
|
6794
|
+
# "dashed": Dashed border line
|
6795
|
+
# "hair": Hairline border (very thin)
|
6796
|
+
# "mediumDashed": Medium dashed border line
|
6797
|
+
# "dashDot": Dash-dot border line
|
6798
|
+
# "dashDotDot": Dash-dot-dot border line
|
6799
|
+
# "slantDashDot": Slant dash-dot border line
|
6800
|
+
},
|
6801
|
+
],
|
6802
|
+
width={2: 30}, # when it is None, it will automatic adjust width
|
6803
|
+
height={2: 50, 3: 25}, # keys are columns
|
6804
|
+
merge=(slice(0, 1), slice(1, 3)),
|
6805
|
+
shade={
|
6806
|
+
(slice(1, 4), slice(1, 3)): {
|
6807
|
+
"bg_color": "FFFF00", # Background color
|
6808
|
+
"pattern_type": "solid", # Fill pattern (e.g., solid, darkGrid, lightGrid)
|
6809
|
+
"fg_color": "#0000FF", # Foreground color, used in patterns
|
6810
|
+
"end_color": "0000FF", # End color, useful for gradients
|
6811
|
+
"fill_type": "solid", # Type of fill (solid, gradient, etc.)
|
6812
|
+
}
|
6766
6813
|
},
|
6767
|
-
"
|
6768
|
-
|
6769
|
-
|
6770
|
-
"
|
6814
|
+
comment={(2, 4): "This is a comment"},
|
6815
|
+
link={(2, 2): "https://example.com"},
|
6816
|
+
protect={
|
6817
|
+
"password": "123", # Password for sheet protection
|
6818
|
+
"sheet": False, # True, # Protect the sheet
|
6819
|
+
"objects": False, # True, # Protect objects
|
6820
|
+
"scenarios": False, # True, # Protect scenarios
|
6821
|
+
"formatCells": False, # Disable formatting cells
|
6822
|
+
"formatColumns": False, # Disable formatting columns
|
6823
|
+
"formatRows": False, # Disable formatting rows
|
6824
|
+
"insertColumns": False, # Disable inserting columns
|
6825
|
+
"insertRows": False, # Disable inserting rows
|
6826
|
+
"deleteColumns": False, # Disable deleting columns
|
6827
|
+
"deleteRows": False, # Disable deleting rows
|
6771
6828
|
},
|
6772
|
-
|
6773
|
-
|
6774
|
-
|
6775
|
-
"
|
6776
|
-
"
|
6777
|
-
"indent": 1, # Indentation level
|
6778
|
-
"text_rotation": 0, # Text rotation angle
|
6829
|
+
number_format={
|
6830
|
+
1: "0.00", # Two decimal places for column index 1
|
6831
|
+
2: "#,##0", # Thousands separator
|
6832
|
+
3: "0%", # Percentage format
|
6833
|
+
4: "$#,##0.00", # Currency format
|
6779
6834
|
},
|
6780
|
-
|
6781
|
-
|
6782
|
-
|
6783
|
-
|
6784
|
-
|
6785
|
-
|
6835
|
+
data_validation={
|
6836
|
+
(slice(1, 2), slice(2, 10)): {
|
6837
|
+
"type": "list",
|
6838
|
+
"formula1": '"Option1,Option2,Option3"', # List of options
|
6839
|
+
"allow_blank": True,
|
6840
|
+
"showDropDown": True,
|
6841
|
+
"showErrorMessage": True,
|
6842
|
+
"errorTitle": "Invalid input",
|
6843
|
+
"error": "Please select a valid option.",
|
6844
|
+
}
|
6786
6845
|
},
|
6787
|
-
|
6788
|
-
|
6789
|
-
|
6790
|
-
|
6791
|
-
|
6792
|
-
|
6793
|
-
|
6794
|
-
|
6795
|
-
|
6796
|
-
|
6797
|
-
|
6798
|
-
|
6799
|
-
|
6800
|
-
|
6801
|
-
|
6802
|
-
|
6803
|
-
merge=(slice(0, 1), slice(1, 3)),
|
6804
|
-
shade={
|
6805
|
-
(slice(1, 4), slice(1, 3)): {
|
6806
|
-
"bg_color": "FFFF00", # Background color
|
6807
|
-
"pattern_type": "solid", # Fill pattern (e.g., solid, darkGrid, lightGrid)
|
6808
|
-
"fg_color": "#0000FF", # Foreground color, used in patterns
|
6809
|
-
"end_color": "0000FF", # End color, useful for gradients
|
6810
|
-
"fill_type": "solid", # Type of fill (solid, gradient, etc.)
|
6811
|
-
}
|
6812
|
-
},
|
6813
|
-
comment={(2, 4): "This is a comment"},
|
6814
|
-
link={(2, 2): "https://example.com"},
|
6815
|
-
protect={
|
6816
|
-
"password": "123", # Password for sheet protection
|
6817
|
-
"sheet": False, # True, # Protect the sheet
|
6818
|
-
"objects": False, # True, # Protect objects
|
6819
|
-
"scenarios": False, # True, # Protect scenarios
|
6820
|
-
"formatCells": False, # Disable formatting cells
|
6821
|
-
"formatColumns": False, # Disable formatting columns
|
6822
|
-
"formatRows": False, # Disable formatting rows
|
6823
|
-
"insertColumns": False, # Disable inserting columns
|
6824
|
-
"insertRows": False, # Disable inserting rows
|
6825
|
-
"deleteColumns": False, # Disable deleting columns
|
6826
|
-
"deleteRows": False, # Disable deleting rows
|
6827
|
-
},
|
6828
|
-
number_format={
|
6829
|
-
1: "0.00", # Two decimal places for column index 1
|
6830
|
-
2: "#,##0", # Thousands separator
|
6831
|
-
3: "0%", # Percentage format
|
6832
|
-
4: "$#,##0.00", # Currency format
|
6833
|
-
},
|
6834
|
-
data_validation={
|
6835
|
-
(slice(1, 2), slice(2, 10)): {
|
6836
|
-
"type": "list",
|
6837
|
-
"formula1": '"Option1,Option2,Option3"', # List of options
|
6838
|
-
"allow_blank": True,
|
6839
|
-
"showDropDown": True,
|
6840
|
-
"showErrorMessage": True,
|
6841
|
-
"errorTitle": "Invalid input",
|
6842
|
-
"error": "Please select a valid option.",
|
6843
|
-
}
|
6844
|
-
},
|
6845
|
-
conditional_format={
|
6846
|
-
(slice(1, 2), slice(2, 10)): [
|
6847
|
-
{
|
6848
|
-
"color_scale": {
|
6849
|
-
"start_type": "min", # Type of start point (min, max, percent)
|
6850
|
-
"start_color": "#FF0000", # Starting color
|
6851
|
-
"end_type": "max", # End type (min, max, percent)
|
6852
|
-
"end_color": "00FF00", # Ending color
|
6853
|
-
"mid_type": "percentile", # Midpoint type (optional)
|
6854
|
-
"mid_value": 50, # Midpoint value (optional)
|
6855
|
-
"mid_color": "FFFF00", # Midpoint color (optional)
|
6856
|
-
}
|
6857
|
-
}
|
6858
|
-
]
|
6859
|
-
},
|
6860
|
-
)
|
6846
|
+
conditional_format={
|
6847
|
+
(slice(1, 2), slice(2, 10)): [
|
6848
|
+
{
|
6849
|
+
"color_scale": {
|
6850
|
+
"start_type": "min", # Type of start point (min, max, percent)
|
6851
|
+
"start_color": "#FF0000", # Starting color
|
6852
|
+
"end_type": "max", # End type (min, max, percent)
|
6853
|
+
"end_color": "00FF00", # Ending color
|
6854
|
+
"mid_type": "percentile", # Midpoint type (optional)
|
6855
|
+
"mid_value": 50, # Midpoint value (optional)
|
6856
|
+
"mid_color": "FFFF00", # Midpoint color (optional)
|
6857
|
+
}
|
6858
|
+
}
|
6859
|
+
]
|
6860
|
+
},
|
6861
|
+
)
|
6861
6862
|
"""
|
6862
6863
|
if usage:
|
6863
6864
|
print(func_xample)
|
@@ -6917,17 +6918,49 @@ format_excel(
|
|
6917
6918
|
col_letter = get_column_letter(col_idx)
|
6918
6919
|
for cell in ws[col_letter][1:]: # Skip the header
|
6919
6920
|
cell.number_format = fmt
|
6920
|
-
|
6921
|
+
|
6922
|
+
if apply_filter:
|
6923
|
+
if isinstance(apply_filter, bool):
|
6924
|
+
# Default: Apply filter to the entire first row (header)
|
6925
|
+
filter_range = f"A1:{get_column_letter(ws.max_column)}1"
|
6926
|
+
ws.auto_filter.ref = filter_range
|
6927
|
+
|
6928
|
+
elif isinstance(apply_filter, tuple):
|
6929
|
+
row_slice, col_slice = apply_filter
|
6930
|
+
|
6931
|
+
# Extract the start and end indices for rows and columns
|
6932
|
+
start_row, end_row = row_slice.start, row_slice.stop
|
6933
|
+
start_col_idx, end_col_idx = col_slice.start, col_slice.stop
|
6934
|
+
|
6935
|
+
# Ensure valid row and column indices
|
6936
|
+
if start_row < 1: start_row = 1 # Row should not be less than 1
|
6937
|
+
if end_row > ws.max_row: end_row = ws.max_row # Ensure within sheet's row limits
|
6938
|
+
if start_col_idx < 1: start_col_idx = 1 # Column should not be less than 1
|
6939
|
+
if end_col_idx > ws.max_column: end_col_idx = ws.max_column # Ensure within sheet's column limits
|
6940
|
+
|
6941
|
+
# Get column letters based on indices
|
6942
|
+
start_col = get_column_letter(start_col_idx)
|
6943
|
+
end_col = get_column_letter(end_col_idx)
|
6944
|
+
|
6945
|
+
# Define the filter range based on specific rows and columns
|
6946
|
+
filter_range = f"{start_col}{start_row}:{end_col}{end_row}"
|
6947
|
+
|
6948
|
+
# Apply the filter
|
6949
|
+
ws.auto_filter.ref = filter_range
|
6921
6950
|
# !widths
|
6922
6951
|
if width is None: # automatic adust width
|
6923
6952
|
for col in ws.columns:
|
6924
|
-
|
6925
|
-
|
6926
|
-
|
6927
|
-
|
6928
|
-
|
6929
|
-
|
6930
|
-
|
6953
|
+
max_length = 0
|
6954
|
+
column = col[0].column_letter # Get the column letter
|
6955
|
+
for cell_ in col:
|
6956
|
+
try:
|
6957
|
+
if cell_.value:
|
6958
|
+
max_length = max(max_length, len(str(cell_.value)))
|
6959
|
+
except Exception:
|
6960
|
+
pass
|
6961
|
+
adjusted_width = max_length + 2 # You can adjust the padding value as needed
|
6962
|
+
ws.column_dimensions[column].width = adjusted_width
|
6963
|
+
|
6931
6964
|
else:
|
6932
6965
|
for col_idx, width_ in width.items():
|
6933
6966
|
col_letter = get_column_letter(col_idx)
|
@@ -7017,6 +7050,7 @@ format_excel(
|
|
7017
7050
|
for indices, rules in conditional_format.items():
|
7018
7051
|
cell_range = convert_indices_to_range(*indices)
|
7019
7052
|
for rule in rules:
|
7053
|
+
# Handle color scale
|
7020
7054
|
if "color_scale" in rule:
|
7021
7055
|
color_scale = rule["color_scale"]
|
7022
7056
|
start_color = hex2argb(color_scale.get("start_color", "FFFFFF"))
|
@@ -7035,6 +7069,32 @@ format_excel(
|
|
7035
7069
|
end_color=end_color,
|
7036
7070
|
)
|
7037
7071
|
ws.conditional_formatting.add(cell_range, color_scale_rule)
|
7072
|
+
# Handle data bar
|
7073
|
+
if "data_bar" in rule:
|
7074
|
+
data_bar = rule["data_bar"]
|
7075
|
+
bar_color = hex2argb(data_bar.get("color", "638EC6"))
|
7076
|
+
|
7077
|
+
data_bar_rule = DataBarRule(
|
7078
|
+
start_type=data_bar.get("start_type", "min"),
|
7079
|
+
start_value=data_bar.get("start_value"),
|
7080
|
+
end_type=data_bar.get("end_type", "max"),
|
7081
|
+
end_value=data_bar.get("end_value"),
|
7082
|
+
color=bar_color,
|
7083
|
+
showValue=data_bar.get("show_value", True),
|
7084
|
+
)
|
7085
|
+
ws.conditional_formatting.add(cell_range, data_bar_rule)
|
7086
|
+
|
7087
|
+
# Handle icon set
|
7088
|
+
if "icon_set" in rule:
|
7089
|
+
icon_set = rule["icon_set"]
|
7090
|
+
icon_set_rule = IconSet(
|
7091
|
+
iconSet=icon_set.get("iconSet", "3TrafficLights1"), # Corrected
|
7092
|
+
showValue=icon_set.get("show_value", True), # Corrected
|
7093
|
+
reverse=icon_set.get("reverse", False) # Corrected
|
7094
|
+
)
|
7095
|
+
ws.conditional_formatting.add(cell_range, icon_set_rule)
|
7096
|
+
|
7097
|
+
|
7038
7098
|
# Save the workbook
|
7039
7099
|
wb.save(filename)
|
7040
7100
|
print(f"Formatted Excel file saved as:\n{filename}")
|
@@ -11011,6 +11071,8 @@ def mouse(
|
|
11011
11071
|
scroll_amount: int = -500,
|
11012
11072
|
fail_safe: bool = True,
|
11013
11073
|
grayscale: bool = False,
|
11074
|
+
n_try: int = 10,
|
11075
|
+
verbose: bool = True,
|
11014
11076
|
**kwargs,
|
11015
11077
|
):
|
11016
11078
|
"""
|
@@ -11037,6 +11099,9 @@ def mouse(
|
|
11037
11099
|
import pyautogui
|
11038
11100
|
import time
|
11039
11101
|
|
11102
|
+
# import logging
|
11103
|
+
# logging.basicConfig(level=logging.DEBUG, filename="debug.log")
|
11104
|
+
|
11040
11105
|
pyautogui.FAILSAFE = fail_safe # Enable/disable fail-safe
|
11041
11106
|
loc_type = "absolute" if "abs" in loc_type else "relative"
|
11042
11107
|
if len(args) == 1:
|
@@ -11045,7 +11110,6 @@ def mouse(
|
|
11045
11110
|
x_offset, y_offset = None, None
|
11046
11111
|
else:
|
11047
11112
|
x_offset, y_offset = args
|
11048
|
-
|
11049
11113
|
elif len(args) == 2:
|
11050
11114
|
x_offset, y_offset = args
|
11051
11115
|
elif len(args) == 3:
|
@@ -11079,38 +11143,35 @@ def mouse(
|
|
11079
11143
|
if region is None:
|
11080
11144
|
w, h = pyautogui.size()
|
11081
11145
|
region = (0, 0, w, h)
|
11082
|
-
|
11083
|
-
|
11084
|
-
|
11085
|
-
|
11086
|
-
|
11087
|
-
|
11088
|
-
|
11089
|
-
|
11090
|
-
|
11146
|
+
retries = 0
|
11147
|
+
while location is None and retries <= n_try:
|
11148
|
+
try:
|
11149
|
+
confidence_ = round(float(confidence - 0.05 * retries), 2)
|
11150
|
+
location = pyautogui.locateOnScreen(
|
11151
|
+
image_path,
|
11152
|
+
confidence=confidence_,
|
11153
|
+
region=region,
|
11154
|
+
grayscale=grayscale,
|
11155
|
+
)
|
11156
|
+
except Exception as e:
|
11157
|
+
if verbose:
|
11158
|
+
print(f"confidence={confidence_},{e}")
|
11159
|
+
location = None
|
11160
|
+
retries += 1
|
11091
11161
|
|
11092
11162
|
# try:
|
11093
11163
|
if location:
|
11094
11164
|
x, y = pyautogui.center(location)
|
11095
11165
|
x += x_offset if x_offset else 0
|
11096
|
-
|
11166
|
+
if x_offset is not None:
|
11167
|
+
x += x_offset
|
11168
|
+
if y_offset is not None:
|
11169
|
+
y += y_offset
|
11097
11170
|
x_offset, y_offset = x, y
|
11098
|
-
print(action)
|
11171
|
+
print(action) if verbose else None
|
11099
11172
|
if action in ["locate"]:
|
11100
11173
|
x, y = pyautogui.position()
|
11101
11174
|
elif action in ["click", "double_click", "triple_click"]:
|
11102
|
-
# if location:
|
11103
|
-
# x, y = pyautogui.center(location)
|
11104
|
-
# x += x_offset
|
11105
|
-
# y += y_offset
|
11106
|
-
# pyautogui.moveTo(x, y, duration=duration)
|
11107
|
-
# if action == "click":
|
11108
|
-
# pyautogui.click(x=x, y=y, clicks=n_click, interval=interval, button=button)
|
11109
|
-
# elif action == "double_click":
|
11110
|
-
# pyautogui.doubleClick(x=x, y=y, interval=interval, button=button)
|
11111
|
-
# elif action=='triple_click':
|
11112
|
-
# pyautogui.tripleClick(x=x,y=y,interval=interval, button=button)
|
11113
|
-
# else:
|
11114
11175
|
if action == "click":
|
11115
11176
|
pyautogui.moveTo(x_offset, y_offset, duration=duration)
|
11116
11177
|
time.sleep(wait)
|
@@ -11136,7 +11197,7 @@ def mouse(
|
|
11136
11197
|
if text is not None:
|
11137
11198
|
pyautogui.typewrite(text, interval=interval)
|
11138
11199
|
else:
|
11139
|
-
|
11200
|
+
print("Text must be provided for the 'type' action.") if verbose else None
|
11140
11201
|
|
11141
11202
|
elif action == "drag":
|
11142
11203
|
if loc_type == "absolute":
|
@@ -11168,15 +11229,7 @@ def mouse(
|
|
11168
11229
|
else:
|
11169
11230
|
raise ValueError(f"Unsupported action: {action}")
|
11170
11231
|
|
11171
|
-
# except pyautogui.ImageNotFoundException:
|
11172
|
-
# print(
|
11173
|
-
# "Image not found. Ensure the image is visible and parameters are correct."
|
11174
|
-
# )
|
11175
|
-
# except Exception as e:
|
11176
|
-
# print(f"An error occurred: {e}")
|
11177
|
-
|
11178
11232
|
|
11179
|
-
|
11180
11233
|
def py2installer(
|
11181
11234
|
script_path: str = None,
|
11182
11235
|
flatform: str = "mingw64",
|
@@ -11399,11 +11452,13 @@ def py2installer(
|
|
11399
11452
|
if any(exclude_import):
|
11400
11453
|
cmd.extend([f"--nofollow-import-to={','.join(exclude_import)}"])
|
11401
11454
|
if include_import is not None:
|
11402
|
-
if any(
|
11455
|
+
if any(
|
11456
|
+
include_import
|
11457
|
+
): # are included in the final build. Some packages may require manual inclusion.
|
11403
11458
|
cmd.extend([f"--include-package={','.join(include_import)}"])
|
11404
11459
|
if plugins:
|
11405
11460
|
for plugin in plugins:
|
11406
|
-
#Adds support for tkinter, ensuring it works correctly in the standalone build.
|
11461
|
+
# Adds support for tkinter, ensuring it works correctly in the standalone build.
|
11407
11462
|
cmd.extend([f"--enable-plugin={plugin}"])
|
11408
11463
|
|
11409
11464
|
if additional_args:
|
@@ -11422,7 +11477,9 @@ def py2installer(
|
|
11422
11477
|
# )
|
11423
11478
|
|
11424
11479
|
if clean_build:
|
11425
|
-
cmd.append(
|
11480
|
+
cmd.append(
|
11481
|
+
"--remove-output"
|
11482
|
+
) # Removes intermediate files created during the build process, keeping only the final executable.
|
11426
11483
|
# Add the script path (final positional argument)
|
11427
11484
|
cmd.append(str(script_path))
|
11428
11485
|
# Ensure Windows shell compatibility
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: py2ls
|
3
|
-
Version: 0.2.4.
|
3
|
+
Version: 0.2.4.41
|
4
4
|
Summary: py(thon)2(too)ls
|
5
5
|
Author: Jianfeng
|
6
6
|
Author-email: Jianfeng.Liu0413@gmail.com
|
@@ -18,7 +18,6 @@ Provides-Extra: full
|
|
18
18
|
Requires-Dist: CacheControl (>=0.13.1)
|
19
19
|
Requires-Dist: Cython (>=3.0.10)
|
20
20
|
Requires-Dist: Deprecated (>=1.2.14)
|
21
|
-
Requires-Dist: GPUtil (>=1.4.0)
|
22
21
|
Requires-Dist: Jinja2 (>=3.1.4)
|
23
22
|
Requires-Dist: Markdown (>=3.6)
|
24
23
|
Requires-Dist: MarkupSafe (>=2.1.5)
|
@@ -243,7 +243,7 @@ py2ls/export_requirements.py,sha256=x2WgUF0jYKz9GfA1MVKN-MdsM-oQ8yUeC6Ua8oCymio,
|
|
243
243
|
py2ls/fetch_update.py,sha256=9LXj661GpCEFII2wx_99aINYctDiHni6DOruDs_fdt8,4752
|
244
244
|
py2ls/freqanalysis.py,sha256=F4218VSPbgL5tnngh6xNCYuNnfR-F_QjECUUxrPYZss,32594
|
245
245
|
py2ls/ich2ls.py,sha256=3E9R8oVpyYZXH5PiIQgT3CN5NxLe4Dwtm2LwaeacE6I,21381
|
246
|
-
py2ls/ips.py,sha256=
|
246
|
+
py2ls/ips.py,sha256=0TSkiUeDnskSJq_kFZcVqP7TC_OqKScibIYMV8CdK3I,427412
|
247
247
|
py2ls/ml2ls.py,sha256=I-JFPdikgEtfQjhv5gBz-QSeorpTJI_Pda_JwkTioBY,209732
|
248
248
|
py2ls/mol.py,sha256=AZnHzarIk_MjueKdChqn1V6e4tUle3X1NnHSFA6n3Nw,10645
|
249
249
|
py2ls/netfinder.py,sha256=OhqD3S9PuwweL2013D-q4GNP1WvJjuYfZzq5BZgGddE,68980
|
@@ -255,6 +255,6 @@ py2ls/sleep_events_detectors.py,sha256=bQA3HJqv5qnYKJJEIhCyhlDtkXQfIzqksnD0YRXso
|
|
255
255
|
py2ls/stats.py,sha256=qBn2rJmNa_QLLUqjwYqXUlGzqmW94sgA1bxJU2FC3r0,39175
|
256
256
|
py2ls/translator.py,sha256=77Tp_GjmiiwFbEIJD_q3VYpQ43XL9ZeJo6Mhl44mvh8,34284
|
257
257
|
py2ls/wb_detector.py,sha256=7y6TmBUj9exCZeIgBAJ_9hwuhkDh1x_-yg4dvNY1_GQ,6284
|
258
|
-
py2ls-0.2.4.
|
259
|
-
py2ls-0.2.4.
|
260
|
-
py2ls-0.2.4.
|
258
|
+
py2ls-0.2.4.41.dist-info/METADATA,sha256=GUlpSQFP_zxyWdEtxXOhxeOMvcYGi5Vj9Ik4Py44O_A,20441
|
259
|
+
py2ls-0.2.4.41.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
260
|
+
py2ls-0.2.4.41.dist-info/RECORD,,
|
File without changes
|