luxorasap 0.1.31__py3-none-any.whl → 0.1.33__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 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.31"
16
+ __version__ = "0.1.33"
17
17
 
18
18
  # ─── Lazy loader ─────────────────────────────────────────────────
19
19
  def __getattr__(name: str) -> ModuleType:
@@ -16,6 +16,7 @@ load_dotenv()
16
16
  from luxorasap.datareader import LuxorQuery
17
17
  from luxorasap.utils.dataframe import transforms
18
18
  from luxorasap.ingest import save_table
19
+ from luxorasap.utils.tools.excel import close_excel_worksheet
19
20
 
20
21
  import warnings
21
22
  warnings.warn(
@@ -48,7 +49,7 @@ class DataLoader:
48
49
 
49
50
 
50
51
  def add_file_tracker(self, tracked_file_path, filetype="excel", sheet_names={},
51
- 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):
52
53
  """ Adiciona arquivo na lista para checar por alteracao
53
54
  Args:
54
55
  tracked_file_path (pathlib.Path): caminho completo ate o arquivo,
@@ -104,7 +105,7 @@ class DataLoader:
104
105
  self.tracked_files[tracked_file_path]["last_mtime"] = file_mtime
105
106
 
106
107
 
107
- def load_file_if_modified(self, tracked_file_path, export_to_blob=False, blob_directory='enriched/parquet'):
108
+ def load_file_if_modified(self, tracked_file_path, export_to_blob=False, blob_directory='enriched/parquet', trials=25):
108
109
  """Carrega arquivo no caminho indicado, carregando na base de dados caso modificado.
109
110
  Args:
110
111
  tracked_file_path (pathlib.Path): caminho ate o arquivo(cadastro previamente por add_file_tracker)
@@ -125,7 +126,6 @@ class DataLoader:
125
126
 
126
127
  # tables sera sempre um dicionario de tabelas
127
128
  tables = None
128
- trials = 25
129
129
  t_counter = 1
130
130
  while trials - t_counter > 0:
131
131
  try:
@@ -134,8 +134,11 @@ class DataLoader:
134
134
  except PermissionError:
135
135
 
136
136
  logger.error(f"Erro ao tentar ler arquivo '{tracked_file_path}.\nTentativa {t_counter} de {trials};'.\nSe estiver aberto feche.")
137
- time.sleep(10)
137
+
138
138
  t_counter += 1
139
+ if trials - t_counter == 1:
140
+ close_excel_worksheet(tracked_file_path.name, save=True)
141
+ time.sleep(10)
139
142
 
140
143
  for sheet_name, table_data in tables.items():
141
144
 
@@ -0,0 +1,2 @@
1
+ from .excel import close_excel_worksheet
2
+ __all__ = ["close_excel_worksheet"]
@@ -0,0 +1,27 @@
1
+
2
+
3
+ import win32com.client
4
+
5
+
6
+ def close_excel_worksheet(filename, save=True):
7
+ """
8
+ Fecha um arquivo específico do Excel no Windows.
9
+ :param arquivo: Nome do arquivo aberto no Excel (ex: 'Planilha1.xlsx')
10
+ :param salvar: Se True, salva as alterações antes de fechar
11
+ """
12
+
13
+ try:
14
+ excel = win32com.client.Dispatch("Excel.Application")
15
+ for wb in excel.Workbooks:
16
+ if wb.Name.lower() == filename.lower(): # compara ignorando maiúsc/minúsc
17
+ if save:
18
+ wb.Close(SaveChanges=1) # 1 = salvar alterações
19
+ print(f"O arquivo {filename} foi salvo e fechado com sucesso no Windows.")
20
+ else:
21
+ wb.Close(SaveChanges=0) # 0 = fechar sem salvar
22
+ print(f"O arquivo {filename} foi fechado sem salvar no Windows.")
23
+ return
24
+ print(f"O arquivo {filename} não estava aberto no Excel.")
25
+ except Exception as e:
26
+ print(f"Erro ao tentar fechar {filename} no Windows: {e}")
27
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: luxorasap
3
- Version: 0.1.31
3
+ Version: 0.1.33
4
4
  Summary: Toolbox da Luxor para ingestão, análise e automação de dados financeiros.
5
5
  Author-email: Luxor Group <backoffice@luxor.com.br>
6
6
  License: Proprietary – All rights reserved
@@ -1,4 +1,4 @@
1
- luxorasap/__init__.py,sha256=EVJadSR-Kxx4viyRZ8ZRW4GBhVsRT5D7qxyREND2KMg,1356
1
+ luxorasap/__init__.py,sha256=mpSlRWDGJED_iudLl_phWyq8eSlCOi-YnqB0ZIV-3vQ,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=QJacQpj-b6RadnfZutjobKXbn9zVqMb945eOwgejjeg,12196
10
+ luxorasap/ingest/legacy_local/dataloader.py,sha256=s_8e4pHwF1M6qt4iQi8QFS1617ioRom8K6Pc4vWHqh0,12404
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-0.1.31.dist-info/METADATA,sha256=4lf0aZ_GiFS-dlJcX9nPXbflHN51H9N8lIPR3Gq0Mjo,3804
18
- luxorasap-0.1.31.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
19
- luxorasap-0.1.31.dist-info/entry_points.txt,sha256=XFh-dOwUhlya9DmGvgookMI0ezyUJjcOvTIHDEYS44g,52
20
- luxorasap-0.1.31.dist-info/top_level.txt,sha256=9YOL6bUIpzY06XFBRkUW1e4rgB32Ds91fQPGwUEjxzU,10
21
- luxorasap-0.1.31.dist-info/RECORD,,
17
+ luxorasap/utils/tools/__init__.py,sha256=dvK7Z4xnNQAuEiObVN7qjeLWAvP49JeFn2Oq9GdgmXs,76
18
+ luxorasap/utils/tools/excel.py,sha256=pLXDA9_PqqmZgUOr3KGjwaJx6qpx9LHNpRHMntnOyfA,1042
19
+ luxorasap-0.1.33.dist-info/METADATA,sha256=iHsYcfvIkGLEt1KJKl7xQHzxekaizvN1iePyNz32SQw,3804
20
+ luxorasap-0.1.33.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
21
+ luxorasap-0.1.33.dist-info/entry_points.txt,sha256=XFh-dOwUhlya9DmGvgookMI0ezyUJjcOvTIHDEYS44g,52
22
+ luxorasap-0.1.33.dist-info/top_level.txt,sha256=9YOL6bUIpzY06XFBRkUW1e4rgB32Ds91fQPGwUEjxzU,10
23
+ luxorasap-0.1.33.dist-info/RECORD,,