+
   }'.S~c                   s@   ^ RI Ht ^ RI Ht ^ RI Ht ^ RI Ht ^ RIt^ RIt^ RIt^ RIt^ RI	t	R R lt
]
! 4       t ! R R	4      t]R
8X  EdS   ]! ]P                  ]P                  ]P                   R7      t]P%                  4        ]P&                  '       d   ]P)                  ]P*                  R7       ]P-                  ]P.                  4       ]P0                  '       d   ]P3                  4        ]P4                  '       d   ]P7                  4        ]P8                  '       d   ]P;                  4        ]P<                  '       d   ]P?                  4        ]P@                  '       d   ]PC                  4        ]PD                  '       d   ]PG                  4        R# R# R# )    )List)Tuple)DictAnyNc                s$    V ^8  d   QhR\         /# )   returnr   )formats   "6/usr/share/ibus-typing-booster/engine/tabstatistics.py__annotate__r
   #   s     e eC e    c            
      s   \         P                  ! R R7      p V P                  RRRRRRR7       V P                  R	R
R\        RRRR7       V P                  RRR\        R\	        R4      RR7       V P                  RRRRRRR7       V P                  RRRRRRR7       V P                  RRR RRR!R7       V P                  R"R#R$\        RR%R&R7       V P                  R'R(RRR)R7       V P                  R*R+RRR,R7       V P                  R-R.RRR/R7       V P                  R0R1R2RRR3R7       V P                  R4R5R6RRR7R7       V P                  4       # )8z7Tool for inspecting the user database of Typing Booster)Zdescriptionz-vz	--verboseverboseZ
store_trueFz4Print more verbose information. default: %(default)s)destactiondefaulthelpz-fz--filefileZstorez*~/.local/share/ibus-typing-booster/user.dbzAFull path of the database file to inspect, default: "%(default)s")r   Ztyper   r   r   z-mz
--max-rowsmax_rowsP  zFMaximum number of rows to keep in the database. default: "%(default)s"z-rz--rowsrowsz4Print all rows of the database, default: %(default)sz-sz--sortsort	user_freqzPSort order when printing all rows. Can be "user_freq|time". default: %(default)sz-tz--total-rows
total_rowsz@Print total number of rows in the database. default: %(default)sz-pz--periodperiodnonezPrint keystrokes saved by period. Period can be "none|second(s)|minute(s)|hour(s)|day(s)|week(s)|month(s)|year(s)|total(s)". "none" means do not print saved keystrokes. default: "%(default)s"z--time_newesttime_newestz?Show the newest timestamp in the database. default: %(default)sz--time_oldesttime_oldestz?Show the oldest timestamp in the database. default: %(default)sz
--time_nowtime_nowuW   Show the timestamp used for “now” when doing the calculations. default: %(default)sz-uz--user_freq_distributionuser_freq_distributionzShow the distribution of user frequencies, i.e. how many rows are there wich have been used once, how many rows have been  used twice, etc. ... default: %(default)sz-dz--decaydecayu   Show information about which rows would be decayed or deleted. (Just shows information, doesn’t change the database!) default: %(default)s)argparseZArgumentParserZadd_argumentstrint
parse_args)Zparsers    r	   r"   r"   #   s    $$MOF
k$  & h<'  ) lE
'  ) h%  ' h%  ' n%  ' j%  ' %  ' %  ' %  ' (%%  ' i%  ' r   c                   s  a  ] tR t^t o RV 3R lR lltV 3R lR ltV 3R lR ltV 3R lR ltV 3R	 lR
 ltV 3R lR lt	RV 3R lR llt
V 3R lR lt]RV 3R lR ll4       tRV 3R lR lltV 3R lR ltV 3R lR ltRtV tR# )
DbContentsc                s0   < V ^8  d   QhRS[ RS[RS[RR/# )r   user_db_filer   r   r   N)r    r!   Zboolr   __classdict__   "r	   r
   DbContents.__annotate__   s3     ; ;; ; 	; '+	;r   c                s.   W n         W0n        \        P                  ! 4       V n        \        P
                  P                  V4      V n        \        P                  ! V P                  4      V n
        . V n        V P                  P                  R 4      P                  4       V n        V P                  4        RV n        RV n        V P                  '       dA   V P                  ^ ,          ^,          V n        V P                  R,          ^,          V n        R# R# )zSELECT * FROM phrases;        N)	_max_rows_verbosetime	_time_nowosZpathZ
expanduser_user_db_filesqlite3Zconnect	_database_original_rowsZexecuteZfetchallsort_by_time_ascending_time_oldest_time_newest)selfr$   r   r   s   &&&&r	   __init__ZDbContents.__init__   s    
 "WW//= ););<PR"nn445MNWWY##% $ 3 3A 6q 9D $ 3 3B 7 :D r   c                   < V ^8  d   QhRR/# r   r   N r%   r'   r	   r
   r(      s     B- B-T B-r   c                s*   V P                  4        \        R V P                   24       \        V P                  4      p^ p. pV P                   Fz  pV^,          pWP                  8  dE   V\
        P                  8  d0   V^,          pV P                  '       d   V P                  VRR7       MVP                  V4       V^,          pK|  	  \        RV 24       \        VR R7      pV P                  '       d   V F  pV P                  VRR7       K  	  \        V4      p\        RV 24       \        V P                  R,          4      p\        R	V 24       ^ p^ pV F  pV^,          pW8  dz   V\
        P                  8  de   V^8X  d0   V^,          pV P                  '       d   V P                  VR
R7       M.V^,          pV P                  '       d   V P                  VRR7       V^,          pK  	  \        RV 24       \        RV 24       R# )z)1st pass: Maximum number of rows to keep=z1st pass delete: )prefixz61st pass: Number of rows to delete above maximum size=c                 &    V ^,          V ^ ,          3# i   r;   Zx   &r	   <lambda>Z(DbContents.print_decay.<locals>.<lambda>   s     t t,r   Zkeyz1st pass kept: z1st pass: Number of rows kept=g+?z2nd pass: Index for decay=z2nd pass delete: z2nd pass decay: z"2nd pass: Number of rows to decay=z#2nd pass: Number of rows to delete=N) sort_by_user_freq_time_ascendingprintr+   lenr3   itb_utilZSHORTCUT_USER_FREQr,   
_print_rowZappendsortedr!   )	r7   indexZnumber_delete_above_maxZ	rows_keptrowr   Zindex_decayZnumber_of_rows_to_decayZnumber_of_rows_to_deletes	   &        r	   print_decayZDbContents.print_decay   s   --/9 " 	#D''("#FH	&&CAI& ; ;;'1,'===OOC0COD  %QJE ' 	F()+ 	,$ 9"	
 === ,=> !I.ug67$..501*;-89"##$ CAI# ; ;;>,1,}}}4GH+q0+}}}4FGQJE  	2()+ 	,3)*, 	-r   c                r9   r:   r;   r%   r'   r	   r
   r(      s     B B$ Br   c                sH    \        R \        V P                  4       24       R# )zTotal number of rows=N)rD   rE   r3   r7   r@   r	   print_total_rowsZDbContents.print_total_rows   s    %c$*=*=&>%?@Ar   c                r9   r:   r;   r%   r'   r	   r
   r(           2 24 2r   c                x    \        R V P                   R\        P                  ! V P                  4       24       R# )zOldest timestamp= N)rD   r5   r-   ctimerL   r@   r	   print_time_oldestZDbContents.print_time_oldest   4    !$"3"3!4AD--./1 	2r   c                r9   r:   r;   r%   r'   r	   r
   r(      rN   r   c                rO   )zNewest timestamp=rP   N)rD   r6   r-   rQ   rL   r@   r	   print_time_newestZDbContents.print_time_newest   rS   r   c                r9   r:   r;   r%   r'   r	   r
   r(      s     / / /r   c                rO   )zNow timestamp=rP   N)rD   r.   r-   rQ   rL   r@   r	   print_time_nowZDbContents.print_time_now   s/    t~~.aDNN+,. 	/r   c                $   < V ^8  d   QhRS[ RR/# )r   r   r   Nr    r%   r'   r	   r
   r(      s     Z4 Z4C Z4T Z4r   c                s   / p/ p/ p/ p/ p/ pR ^ R^R^<RRRRRRRRRRR	V P                   V P                  ,
          /	pVP                  V^ 4      p	V	'       g/   VP                  R
4      '       d   VRR pVP                  V^ 4      p	V P                   EF  p
V
^,          pV
^,          p\        V
^,          4      V,          p\        V
^,          4      V,          pV	^ 8  g   KQ  \        V P                   V,
          V	,          4      pVR	8X  d   ^ pW8  g   K  W9   dX   W/;;,          V,          uu&   W?;;,          V,          uu&   W8  d)   W_;;,          V,          uu&   Wo;;,          V,          uu&   MWV&   WV&   W8  d
   WV&   WV&   M^ W_&   ^ Wo&   W?,          '       d-   RW?,          W/,          ,
          ,          W?,          ,          WO&   MRWO&   Wo,          '       d/   RWo,          W_,          ,
          ,          Wo,          ,          W&   EK{  RW&   EK  	  \        VRR7       FW  p\        V RVR RVV,          R RVV,          R RVV,          R RVV,          R RVV,          R RVV,          R R24       KY  	  R# )r   ZsecondZminuteZhouri  ZdayZweekZmonthZyearZtotalZsNg      Y@r)   T)ZreverserP   Z3: 7z6.4z% Z%iQ i:	 i ' i3r*   )	r.   r5   ZgetZendswithr3   rE   r!   rH   rD   )r7   r   Zlength_typedZlength_committedZpercent_savedZlength_typed_bZlength_committed_bZpercent_saved_bZperiod_lengths_in_secondsZperiod_length_in_secondsrJ   r   Z	timestampZlength_typed_rowZlength_committed_rowZperiod_indexrI   s   &&               r	   print_savingsZDbContents.print_savings   s   ')+-*,)+-/,.AabD9M^OT^^d&7&77
%
! $=#@#@#K 'FOOC,@,@CR[F'@'D'DVQ'O$&&CAIAI  #3q6{Y6 $'s1v;#: '!+"DNNY$>BZ#Z[W$#$L'; $3$26FF2(6:NN6/B*8<LL8.<@TT<5E\29M6/B;K<8?S|<;<N8?@.<'55!%5%C'3'A&B C.<= &3
 7:3)77!%7%E'5'C&D E0>? (5
 9<5w 'x ,d;EVHAeAYb!%(+1%e,Q/q"5)#.b#E*1-Q'.q1$U+C03 4 <r   c                r9   r:   r;   r%   r'   r	   r
   r(   W  s     
5 
5d 
5r   c                s    / pV P                    F,  pV^,          pW19   d   W;;,          ^,          uu&   K(  ^W&   K.  	  \        V4       F  p\        VR RW,           24       K  	  R# )   rY   rX   N)r3   rH   rD   )r7   Z
user_freqsrJ   r   Zcounts   &    r	   print_user_freq_distributionZ'DbContents.print_user_freq_distributionW  sf    %'
&&CAI&%*%()
% ' J'EU1IR
 1234 (r   c          	      sT   < V ^8  d   QhRS[ S[S[S[S[S[S[S[3,          RS[RR/# )r   rJ   r<   r   N)r   r!   r    Zfloatr%   r'   r	   r
   r(   d  s9      c3S#sEAB(,r   c                s   \        V V^ ,          R RV^,          R R\        P                  ! R\        P                  ! V^,          4      4       \	        V^,          \        V^,          4      ,
          4      R,           R\        V^,          4       R\        V^,          4       R\        V^,          4       R\        V^,          4       R24       R# )r    rY   rP   z%Y-%m-%d %H:%M:%S:i   i   NN)rD   r-   ZstrftimeZgmtimer    r!   Zrepr)ZclsrJ   r<   s   &&&r	   rG   ZDbContents._print_rowc  s     	Q
!Q
!2DKKA4GHISVCAK'(-.ac!fac!fac!fac!fa! 		r   c                rV   )r   r   r   NrW   r%   r'   r	   r
   r(   r  s     	! 	! 	!t 	!r   c                s    VR 8X  d   V P                  4        MVR8X  d   V P                  4        MR# V P                   F  pV P                  V4       K  	  R# )r   r-   N)rC   r4   r3   rG   )r7   r   rJ   s   && r	   dumpZDbContents.dumpr  sH    ;113V^'')&&COOC  'r   c                r9   r:   r;   r%   r'   r	   r
   r(   }  s     ( ( (r   c                @    \        V P                  R  R7      V n        R# )c                 r=   r>   r;   r?   r@   r	   rA   Z3DbContents.sort_by_time_ascending.<locals>.<lambda>  s    )*1)*16'r   rB   NrH   r3   rL   r@   r	   r4   Z!DbContents.sort_by_time_ascending}  s    $T%8%8,'(r   c                r9   r:   r;   r%   r'   r	   r
   r(     s     ( ($ (r   c                r^   )c                 s6    V ^,          V ^,          V ^ ,          3# )r[   r;   r?   r@   r	   rA   Z=DbContents.sort_by_user_freq_time_ascending.<locals>.<lambda>  s    )*1)*1)*16'r   rB   Nr_   rL   r@   r	   rC   Z+DbContents.sort_by_user_freq_time_ascending  s    $T%8%8,'(r   )r2   r+   r3   r6   r.   r5   r0   r,   N) r   F)r   )r`   )r   )__name__Z
__module__Z__qualname__Z__firstlineno__r8   rK   rM   rR   rT   rU   rZ   r\   ZclassmethodrG   r]   r4   rC   Z__static_attributes__Z__classdictcell__)r&   s   @r	   r#   r#      s     ; ;(B- B-HB B2 2
2 2
/ /
Z4 Z4x
5 
5   	! 	!( (( (r   r#   Z__main__)r$   r   r   )r   )$Ztypingr   r   r   r   r/   r-   r1   r   rF   r"   Z_ARGSr#   ra   r   r   r   Z
dbcontentsrC   r   r]   r   rZ   r   r   r\   r   rR   r   rT   r   rU   r   rK   r   rM   r;   r   r	   <module>rb      s6  0     	    eN 	@( @(D z$)MM%*^^5J //1zzzUZZ(U\\*###//1$$&$$&~~~!!#{{{ ##% % r   