~ubuntuone-control-tower/software-center/trunk

« back to all changes in this revision

Viewing changes to apt-xapian-index-plugin/origin.py

  • Committer: Michael Vogt
  • Date: 2011-08-11 10:23:09 UTC
  • Revision ID: michael.vogt@ubuntu.com-20110811102309-va9yzc4nc4ts1ksc
some pep8 fixes, but probably not worth the trouble going through all of them

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
import apt
4
4
import os
5
5
 
 
6
 
6
7
class OriginPlugin:
 
8
 
7
9
    def info(self):
8
10
        """
9
11
        Return general information about the plugin.
10
12
 
11
13
        The information returned is a dict with various keywords:
12
 
         
 
14
 
13
15
         timestamp (required)
14
16
           the last modified timestamp of this data source.  This will be used
15
17
           to see if we need to update the database or not.  A timestamp of 0
24
26
        """
25
27
        file = apt.apt_pkg.config.find_file("Dir::Cache::pkgcache")
26
28
        if not os.path.exists(file):
27
 
            return dict(timestamp = 0)
28
 
        return dict(timestamp = os.path.getmtime(file))
 
29
            return dict(timestamp=0)
 
30
        return dict(timestamp=os.path.getmtime(file))
29
31
 
30
32
    def init(self, info, progress):
31
33
        """
50
52
          fullDoc: the full description as a chapter in ReST format
51
53
        """
52
54
        return dict(
53
 
            name = "Origin",
54
 
            shortDesc = "Origin information",
55
 
            fullDoc = """
 
55
            name="Origin",
 
56
            shortDesc="Origin information",
 
57
            fullDoc="""
56
58
            The Origin data source indexes origin information
57
59
            It uses the prefix XO
58
 
            """
59
 
        )
60
 
 
 
60
            """)
61
61
 
62
62
    def index(self, document, pkg):
63
63
        """
67
67
        pkg       is the python-apt Package object for this package
68
68
        """
69
69
        ver = pkg.candidate
70
 
        if ver is None: 
 
70
        if ver is None:
71
71
            return
72
72
        if not ver.downloadable:
73
 
            document.add_term("XOL"+"notdownloadable")
 
73
            document.add_term("XOL" + "notdownloadable")
74
74
        for origin in ver.origins:
75
 
            document.add_term("XOA"+origin.archive)
76
 
            document.add_term("XOC"+origin.component)
77
 
            document.add_term("XOL"+origin.label)
78
 
            document.add_term("XOO"+origin.origin)
79
 
            document.add_term("XOS"+origin.site)
 
75
            document.add_term("XOA" + origin.archive)
 
76
            document.add_term("XOC" + origin.component)
 
77
            document.add_term("XOL" + origin.label)
 
78
            document.add_term("XOO" + origin.origin)
 
79
            document.add_term("XOS" + origin.site)
80
80
 
81
81
        # FIXME: this doesn't really belong in this file, but we can put it in
82
82
        #        here until we get a display_name/display_summary plugin which
83
83
        #        is being prepared in the experimental-fastlist branch.
84
84
        if '-' in pkg.name:
85
85
            # we need this to work around xapian oddness
86
 
            document.add_term(pkg.name.replace('-','_'))
 
86
            document.add_term(pkg.name.replace('-', '_'))
87
87
 
88
88
    def indexDeb822(self, document, pkg):
89
89
        """