+
    ^|i                         R t ^ RIt^ RIHt ^ RIHt ^RIHt ^ RIH	t	H
t
Ht ^RIHt RtRt ! R	 R
]4      t ! R R]4      t ! R R]4      tR# )zb
An application for managing IPython history.

To be invoked as the `ipython history` subcommand.
N)Path)Application)BaseIPythonApplication)BoolIntDict)
ask_yes_nozTrim the IPython history database to the last 1000 entries.

This actually copies the last 1000 entries to a new database, and then replaces
the old file with the new. Use the `--keep=` argument to specify a number
other than 1000.
a  Clear the IPython history database, deleting all entries.

Because this is a destructive operation, IPython will prompt the user if they
really want to do this. Passing a `-f` flag will force clearing without a
prompt.

This is an handy alias to `ipython history trim --keep=0`
c                      a  ] tR t^!t o ]t]! RRR7      P                  RR7      t]	! RRR7      P                  RR7      t
]! ]! R RR//]P                  3R	7      4      t]! ]! R
R7      4      tR tRtV tR# )HistoryTrimFz/Keep the old history file as history.sqlite.<N>helpTconfigi  /Number of recent lines to keep in the database.backup)r   zHistoryTrim.keep)keepc                   \        V P                  P                  4      pVR ,          p\        P                  ! V4      p\        VP                  RV P                  ^,           34      4      p\        V4      V P                  8:  d*   \        RV P                  ,          4       \        R4       R# \        RV P                  ,          4       VP                  4        VP                  4        V'       dI   V^ ,          ^ ,          p\        VP                  RV34      4      p\        VP                  RV34      4      pVP                  4        VR,          p^ p	VP                  4       '       d%   V	^,          p	VR\        V	4      ,           ,          pK:  \        P                  ! V4      p
V
P                  R	4       V
P                  R
4       V
P                  R4       V
P                  4        V'       dJ   V
;_uu_ 4        V
P!                  RX4       V
P!                  RV4       V
P!                  RX4       RRR4       V
P                  4        V P"                  '       db   ^p	VRV	,          ,          pVP                  4       '       d   V	^,          p	VRV	,          ,          pK1  VP%                  V4       \        RV4       MVP'                  4        VP%                  V4       R#   + '       g   i     L; i)zhistory.sqlitez^SELECT session, line, source, source_raw FROM history ORDER BY session DESC, line DESC LIMIT ?z=There are already at most %d entries in the history database.z>Not doing anything. Use --keep= argument to keep fewer entriesNz/Trimming history to the most recent %d entries.zCSELECT session, line, output FROM output_history WHERE session >= ?zMSELECT session, start, end, num_cmds, remark FROM sessions WHERE session >= ?zhistory.sqlite.newzCREATE TABLE IF NOT EXISTS sessions (session integer
                            primary key autoincrement, start timestamp,
                            end timestamp, num_cmds integer, remark text)zCREATE TABLE IF NOT EXISTS history
                        (session integer, line integer, source text, source_raw text,
                        PRIMARY KEY (session, line))zCREATE TABLE IF NOT EXISTS output_history
                        (session integer, line integer, output text,
                        PRIMARY KEY (session, line))z'insert into sessions values (?,?,?,?,?)z$insert into history values (?,?,?,?)z)insert into output_history values (?,?,?)zhistory.sqlite.old.%dz Backed up longer history file to)r   profile_dirlocationsqlite3connectlistexecuter   lenprintpopreversecloseexistsstrcommitexecutemanyr   renameunlink)selfr   	hist_fileconinputsfirst_sessionoutputssessionsnew_hist_fileinew_dbbackup_hist_files   &           9/usr/lib/python3/dist-packages/IPython/core/historyapp.pystartHistoryTrim.start2   sz   4++445"22	ooi( ckk #SUYU^U^_`U`Tbd ev;$))#QTXT]T]]^RS?$))KL

"1IaLM3;; (KMZL\^ _GCKK )FHUGWY ZH		 $&::""$$FA'+?#a&+HIM/ M 	N 	 8 	9 	 8 	9 	 ""#LhW""#I6R""#NPWX	 
 	;;;A*.E.IJ"))++Q#.2IA2M#N -.46FGY'% s   ;7K  K0	 N)__name__
__module____qualname____firstlineno__trim_hist_helpdescriptionr   tagr   r   r   r   dictr   flagsaliasesr0   __static_attributes____classdictcell____classdict__s   @r/   r
   r
   !   s      K%OPTT U F tKLPP Q D mh%56DEE 4/01G@( @(    r
   c                      a  ] tR t^ut o ]t]! ^ RR7      t]! RRR7      P                  RR7      t
]! ]! R RR//]
P                  3RRR//]
P                  3R	7      4      t]! 4       tR
 tRtV tR# )HistoryClearr   r   Fz"Don't prompt user for confirmationTr   forcer
   )rD   fc                    V P                   '       g   \        R RRR7      '       d   \        P                  V 4       R# R# )z#Really delete all ipython history? no)default	interruptN)rD   r   r
   r0   r$   s   &r/   r0   HistoryClear.start   s3    :::144
 
 d#
rA   r2   N)r3   r4   r5   r6   clear_hist_helpr8   r   r   r   r9   rD   r   r:   r   r;   r<   r0   r=   r>   r?   s   @r/   rC   rC   u   s     !KqHIDABFFdFSE"WdO4ejjA/<	
E fG$ $rA   rC   c                      a  ] tR t^t o RtRt]! ]! ]]P
                  P                  4       ^ ,          3]
]
P
                  P                  4       ^ ,          3R7      4      tR tRtV tR# )
HistoryAppzipython-historyz$Manage the IPython history database.)trimclearc           	     8   V P                   ft   \        RRP                  \        \        V P
                  4      4      ,           R,           4       V P                  4        V P                  4        V P                  ^4       R # V P                   P                  4       # )Nz.No subcommand specified. Must specify one of: z, z.
)
subappr   joinmapreprsubcommandsprint_descriptionprint_subcommandsexitr0   rJ   s   &r/   r0   HistoryApp.start   su    ;;@))Cd&6&6789
 ""$""$IIaL;;$$&&rA   r2   N)r3   r4   r5   r6   namer8   r   r:   r
   
splitlinesrC   rV   r0   r=   r>   r?   s   @r/   rN   rN      sb     D8Kt[44??A!DE|77BBDQGH K
' 'rA   rN   )__doc__r   pathlibr   traitlets.config.applicationr   applicationr   	traitletsr   r   r   utils.ior   r7   rL   r
   rC   rN   r2   rA   r/   <module>rc      sW      4 / % % !Q(( Q(h$; $*' 'rA   