~ubuntu-branches/ubuntu/vivid/youker-assistant/vivid

« back to all changes in this revision

Viewing changes to backends/youker-assistant-daemon/src/cleaner/systemhistory.py

  • Committer: Package Import Robot
  • Author(s): Kobe Lee (kylinkobe)
  • Date: 2013-09-18 16:22:14 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20130918162214-6nqyjyf3cd3ynqky
Tags: 0.2.1-0ubuntu1
* Modify the mouse events of MonitorBall.
* Add reset button for clear pages.
* Add policykit for apt clear in sudodbus.
* Fixed the bug about software status and add masklayer.
* Rewrite the code of system information.
* Add some signals and slots.
* Fixed the bug about Software signals(LP: #1226389).
* Modify KThread and add base.py.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
# -*- coding: utf-8 -*-
 
3
### BEGIN LICENSE
 
4
# Copyright (C) 2013 National University of Defense Technology(NUDT) & Kylin Ltd
 
5
# This program is free software: you can redistribute it and/or modify it
 
6
# under the terms of the GNU General Public License version 3, as published
 
7
# by the Free Software Foundation.
 
8
#
 
9
# This program is distributed in the hope that it will be useful, but
 
10
# WITHOUT ANY WARRANTY; without even the implied warranties of
 
11
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
 
12
# PURPOSE.  See the GNU General Public License for more details.
 
13
#
 
14
# You should have received a copy of the GNU General Public License along
 
15
# with this program.  If not, see <http://www.gnu.org/licenses/>.
 
16
### END LICENSE
 
17
 
 
18
import os
 
19
from xml.etree import ElementTree
 
20
 
 
21
class SystemHistory():
 
22
    def __init__(self):
 
23
        pass
 
24
 
 
25
    def scan_the_xml(self, homedir):
 
26
        if homedir:
 
27
            xml_path = '%s/.local/share/' % homedir
 
28
        else:
 
29
            xml_path = os.path.expanduser('~/.local/share/')
 
30
 
 
31
        full_path = xml_path + 'recently-used.xbel'
 
32
 
 
33
        tree = ElementTree.parse(full_path)
 
34
        nodes = tree.findall("bookmark")
 
35
        hreflist = []
 
36
        for node in nodes:
 
37
            hreflist.append(node.get('href'))
 
38
 
 
39
        return hreflist
 
40
 
 
41
    def clean_the_xml(self, homedir):
 
42
        xml_path = '%s/.local/share/' % homedir
 
43
        full_path = xml_path + 'recently-used.xbel'
 
44
 
 
45
        tree = ElementTree.parse(full_path)
 
46
        root = tree.getroot()
 
47
        root .clear()
 
48
 
 
49
        tree.write(full_path, encoding="UTF-8", xml_declaration=None, default_namespace=None, method="xml")