luxorasap 0.1.30__py3-none-any.whl → 0.1.32__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.
- luxorasap/__init__.py +1 -1
- luxorasap/ingest/legacy_local/dataloader.py +13 -5
- luxorasap/utils/tools/__init__.py +2 -0
- luxorasap/utils/tools/excel.py +38 -0
- {luxorasap-0.1.30.dist-info → luxorasap-0.1.32.dist-info}/METADATA +1 -1
- {luxorasap-0.1.30.dist-info → luxorasap-0.1.32.dist-info}/RECORD +9 -7
- {luxorasap-0.1.30.dist-info → luxorasap-0.1.32.dist-info}/WHEEL +0 -0
- {luxorasap-0.1.30.dist-info → luxorasap-0.1.32.dist-info}/entry_points.txt +0 -0
- {luxorasap-0.1.30.dist-info → luxorasap-0.1.32.dist-info}/top_level.txt +0 -0
luxorasap/__init__.py
CHANGED
|
@@ -13,7 +13,7 @@ from types import ModuleType
|
|
|
13
13
|
try:
|
|
14
14
|
__version__: str = metadata.version(__name__)
|
|
15
15
|
except metadata.PackageNotFoundError: # editable install
|
|
16
|
-
__version__ = "0.1.
|
|
16
|
+
__version__ = "0.1.32"
|
|
17
17
|
|
|
18
18
|
# ─── Lazy loader ─────────────────────────────────────────────────
|
|
19
19
|
def __getattr__(name: str) -> ModuleType:
|
|
@@ -15,6 +15,8 @@ load_dotenv()
|
|
|
15
15
|
|
|
16
16
|
from luxorasap.datareader import LuxorQuery
|
|
17
17
|
from luxorasap.utils.dataframe import transforms
|
|
18
|
+
from luxorasap.ingest import save_table
|
|
19
|
+
from luxorasap.utils.tools.excel import close_excel_worksheet
|
|
18
20
|
|
|
19
21
|
import warnings
|
|
20
22
|
warnings.warn(
|
|
@@ -47,7 +49,7 @@ class DataLoader:
|
|
|
47
49
|
|
|
48
50
|
|
|
49
51
|
def add_file_tracker(self, tracked_file_path, filetype="excel", sheet_names={},
|
|
50
|
-
excel_size_limit = None,index=False, index_name="index",normalize_columns=False):
|
|
52
|
+
excel_size_limit = None,index=False, index_name="index", normalize_columns=False):
|
|
51
53
|
""" Adiciona arquivo na lista para checar por alteracao
|
|
52
54
|
Args:
|
|
53
55
|
tracked_file_path (pathlib.Path): caminho completo ate o arquivo,
|
|
@@ -133,8 +135,11 @@ class DataLoader:
|
|
|
133
135
|
except PermissionError:
|
|
134
136
|
|
|
135
137
|
logger.error(f"Erro ao tentar ler arquivo '{tracked_file_path}.\nTentativa {t_counter} de {trials};'.\nSe estiver aberto feche.")
|
|
136
|
-
|
|
138
|
+
|
|
137
139
|
t_counter += 1
|
|
140
|
+
if trials - t_counter == 1:
|
|
141
|
+
close_excel_worksheet(tracked_file_path.name, save=True)
|
|
142
|
+
time.sleep(10)
|
|
138
143
|
|
|
139
144
|
for sheet_name, table_data in tables.items():
|
|
140
145
|
|
|
@@ -143,9 +148,12 @@ class DataLoader:
|
|
|
143
148
|
if table_name == "trades":
|
|
144
149
|
table_data["ID"] = table_data.index
|
|
145
150
|
|
|
146
|
-
self.__export_table(table_name, table_data, index=file_data["index"], index_name=file_data["index_name"],
|
|
147
|
-
|
|
148
|
-
|
|
151
|
+
#self.__export_table(table_name, table_data, index=file_data["index"], index_name=file_data["index_name"],
|
|
152
|
+
# normalize_columns=file_data["normalize_columns"], export_to_blob=export_to_blob,
|
|
153
|
+
# blob_directory=blob_directory)
|
|
154
|
+
save_table(table_name, table_data, index=file_data["index"], index_name=file_data["index_name"],
|
|
155
|
+
normalize_columns=file_data["normalize_columns"], directory=blob_directory)
|
|
156
|
+
|
|
149
157
|
self.tracked_files[tracked_file_path]["last_mtime"] = file_last_update
|
|
150
158
|
|
|
151
159
|
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
|
|
2
|
+
import platform
|
|
3
|
+
|
|
4
|
+
try:
|
|
5
|
+
if platform.system() == "Windows":
|
|
6
|
+
import win32com.client as win32 # type: ignore
|
|
7
|
+
else:
|
|
8
|
+
win32 = None # type: ignore
|
|
9
|
+
except Exception:
|
|
10
|
+
win32 = None # type: ignore
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def close_excel_worksheet(filename, save=True):
|
|
14
|
+
"""
|
|
15
|
+
Fecha um arquivo específico do Excel no Windows.
|
|
16
|
+
:param arquivo: Nome do arquivo aberto no Excel (ex: 'Planilha1.xlsx')
|
|
17
|
+
:param salvar: Se True, salva as alterações antes de fechar
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
if platform.system() != "Windows" or win32 is None:
|
|
21
|
+
# Em Linux/WSL/macOS não faz nada e não quebra
|
|
22
|
+
print("close_excel_worksheet: ignorado (requer Windows/pywin32).")
|
|
23
|
+
return False
|
|
24
|
+
|
|
25
|
+
try:
|
|
26
|
+
excel = win32com.client.Dispatch("Excel.Application")
|
|
27
|
+
for wb in excel.Workbooks:
|
|
28
|
+
if wb.Name.lower() == filename.lower(): # compara ignorando maiúsc/minúsc
|
|
29
|
+
if save:
|
|
30
|
+
wb.Close(SaveChanges=1) # 1 = salvar alterações
|
|
31
|
+
print(f"O arquivo {filename} foi salvo e fechado com sucesso no Windows.")
|
|
32
|
+
else:
|
|
33
|
+
wb.Close(SaveChanges=0) # 0 = fechar sem salvar
|
|
34
|
+
print(f"O arquivo {filename} foi fechado sem salvar no Windows.")
|
|
35
|
+
return
|
|
36
|
+
print(f"O arquivo {filename} não estava aberto no Excel.")
|
|
37
|
+
except Exception as e:
|
|
38
|
+
print(f"Erro ao tentar fechar {filename} no Windows: {e}")
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
luxorasap/__init__.py,sha256=
|
|
1
|
+
luxorasap/__init__.py,sha256=WimStV4TUq_bGK0DA6s9ZKn8P9mXZIWuzfRtiVleAtA,1356
|
|
2
2
|
luxorasap/btgapi/__init__.py,sha256=QUlfb5oiBY6K1Q5x4-a-x2wECe1At5wc2962I5odOJk,620
|
|
3
3
|
luxorasap/btgapi/auth.py,sha256=PvyCtbEyBO2B1CIeAlNXWugKW1OgiKfPcVzS6K5FBnQ,1872
|
|
4
4
|
luxorasap/btgapi/reports.py,sha256=ZVEMLoJPXc0r3XjPJPMsKQN0zZd1Npd7umNpAj1bncs,8040
|
|
@@ -7,15 +7,17 @@ luxorasap/datareader/__init__.py,sha256=41RAvbrQ4R6oj67S32CrKqolx0CJ2W8cbOF6g5Cq
|
|
|
7
7
|
luxorasap/datareader/core.py,sha256=aPFEu6Wk7wGRxlyBUmaAznp2KXxOduWy93nliFWdwN4,156151
|
|
8
8
|
luxorasap/ingest/__init__.py,sha256=XhxDTN2ar-u6UCPhnxNU_to-nWiit-SpQ6cA_N9eMSs,795
|
|
9
9
|
luxorasap/ingest/cloud/__init__.py,sha256=7yqEgeDxplkqYTzZNB0kfkSQ8PXF-77BXMW2DMYtJbU,2911
|
|
10
|
-
luxorasap/ingest/legacy_local/dataloader.py,sha256=
|
|
10
|
+
luxorasap/ingest/legacy_local/dataloader.py,sha256=yoTf1pJOvc2k07XnKdRsICP25UzUagdORtPPmstwtjk,12421
|
|
11
11
|
luxorasap/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
12
|
luxorasap/utils/dataframe/__init__.py,sha256=heKpmq58FmX35syzzwrHqlOWKYBkH2Z1jyqaQ_Vg-00,265
|
|
13
13
|
luxorasap/utils/dataframe/reader.py,sha256=Vzjdw-AeS1lnWEHQ8RZNh0kK93NWTp0NWVi_B6mN5N0,616
|
|
14
14
|
luxorasap/utils/dataframe/transforms.py,sha256=OIvlTTcjFX6bUhuQp_syEp7ssm4sLzwvgsag6n2Wl3k,2438
|
|
15
15
|
luxorasap/utils/storage/__init__.py,sha256=U3XRq94yzRp3kgBSUcRzs2tQgJ4o8h8a1ZzwiscA5XM,67
|
|
16
16
|
luxorasap/utils/storage/blob.py,sha256=0QnwrUP-9vWYK8ffa6NqE7rV_t6RdScRM8GQnMxY_4w,3184
|
|
17
|
-
luxorasap
|
|
18
|
-
luxorasap
|
|
19
|
-
luxorasap-0.1.
|
|
20
|
-
luxorasap-0.1.
|
|
21
|
-
luxorasap-0.1.
|
|
17
|
+
luxorasap/utils/tools/__init__.py,sha256=dvK7Z4xnNQAuEiObVN7qjeLWAvP49JeFn2Oq9GdgmXs,76
|
|
18
|
+
luxorasap/utils/tools/excel.py,sha256=RCrnblkiI_1d-F3x7bZslZsxvMhPJnJoBpEBZQRhP20,1443
|
|
19
|
+
luxorasap-0.1.32.dist-info/METADATA,sha256=nib6vLaqt2MtOJ1O-XrUrNSJYoLzy0uzmT6fgIyLUpo,3804
|
|
20
|
+
luxorasap-0.1.32.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
21
|
+
luxorasap-0.1.32.dist-info/entry_points.txt,sha256=XFh-dOwUhlya9DmGvgookMI0ezyUJjcOvTIHDEYS44g,52
|
|
22
|
+
luxorasap-0.1.32.dist-info/top_level.txt,sha256=9YOL6bUIpzY06XFBRkUW1e4rgB32Ds91fQPGwUEjxzU,10
|
|
23
|
+
luxorasap-0.1.32.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|