o
    àý°jÔ  ã                   @   sŒ   d dl mZ d dl mZ d dlZd dlZd dlZd dlmZ d dlm	Z	 d dl
mZ dd„ Zd	d
„ Zdd„ ZedkrDeƒ  e d¡ dS dS )é    )Údivision)Úprint_functionN)Úlogger)Úversion)ÚESENT_DBc                 C   s   |   |¡}| ¡  d S )N)ÚgetPageÚdump)ÚeseÚpageNumÚdata© r   úˆ/root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/../../../bin/esentutl.pyÚdumpPage!   s   
r   c                 C   sÄ   |   |¡}|d u rt d| ¡ d S d}td| ƒ 	 z|  |¡}W n ty7   tjddd� t d¡ Y qw |d u r>d S td| ƒ t| ¡ ƒD ]}|| d ur\td	||| f ƒ qJ|d7 }q)
Nz Can"t get a cursor for table: %sé   z	Table: %sTz
Exception:)Úexc_infoz5Error while calling getNextRow(), trying the next onez*** %dz	%-30s: %r)	Ú	openTableÚloggingÚerrorÚprintÚ
getNextRowÚ	ExceptionÚdebugÚlistÚkeys)r	   Ú	tableNameÚcursorÚiÚrecordÚjr   r   r   ÚexportTable%   s.   

ý€òr   c               
   C   s¶  t tjƒ tjddd�} | jdddd� | jdd	d
d� | jdd	dd� | jdddd� | jddd�}|jddd�}|jddddd� |jddd� |jddd�}|jddddd� tt	j
ƒdkrj|  ¡  t	 d¡ |  ¡ }t |j|j¡ t|jƒ}z3|j ¡ dkrˆ| ¡  n%|j ¡ dkr˜t|t|jƒƒ n|j ¡ dkr¦t||jƒ ntd |j ƒ‚W n& tyÔ } zt ¡ jtj krÆd!d l!}| "¡  t |ƒ W Y d }~nd }~ww | #¡  d S )"NTzKExtensive Storage Engine utility. Allows dumping catalog, pages and tables.)Úadd_helpÚdescriptionÚdatabaseFileÚstorezESE to open)ÚactionÚhelpz-debugÚ
store_truezTurn DEBUG output ONz-tsz&Adds timestamp to every logging outputz-pagezpage to openÚactionsr$   )r%   Údestr   zdumps an specific page)r%   zpage to dump)r$   Úrequiredr%   Úinfoz!dumps the catalog info for the DBÚexportz-tableztable to dumpr   ÚINFOÚDUMPÚEXPORTzUnknown action %s r   )$r   r   ÚBANNERÚargparseÚArgumentParserÚadd_argumentÚadd_subparsersÚ
add_parserÚlenÚsysÚargvÚ
print_helpÚexitÚ
parse_argsr   ÚinitÚtsr   r   r"   r$   ÚupperÚprintCatalogr   ÚintÚpager   Útabler   r   Ú	getLoggerÚlevelÚDEBUGÚ	tracebackÚ	print_excÚclose)ÚparserÚ
subparsersÚdump_parserÚexport_parserÚoptionsr	   ÚerE   r   r   r   Úmain=   sF   



€€ürN   Ú__main__r   )Ú
__future__r   r   r6   r   r0   Úimpacket.examplesr   Úimpacketr   Úimpacket.eser   r   r   rN   Ú__name__r9   r   r   r   r   Ú<module>   s   2þ