3 import xml
.etree
.ElementTree
as ET
5 parser
= argparse
.ArgumentParser()
11 help='path to your llpp.conf; default to ~/.config/llpp.conf',
12 default
='~/.config/llpp.conf')
17 help='entries saved earlier than this date will be removed')
22 help='entries with path matching the keyword will be removed')
23 parser
.add_argument(dest
='dest',
26 help='path to output config file')
28 args
= parser
.parse_args()
31 keyword
= args
.keyword
34 tree
= ET
.parse(os
.path
.expanduser(source
))
37 print('Removing the following entries in llpp.conf:')
39 for doc
in root
.findall('doc'):
40 # skip entries with bookmarks
41 if doc
.find('bookmarks'):
43 # remove entries older than 2019.9.1
44 ts
= int(doc
.get('last-visit'))
45 if cts
is not None and ts
< cts
:
46 print(doc
.get('path'))
50 # remove entries whose path contains the keyword
51 if keyword
is not None and keyword
in doc
.get('path'):
52 print(doc
.get('path'))
56 print(i
, 'entries have been removed.',
57 'The new configuration file has been saved to', dest
)