~mmcg069/software-center/star-tweaks

« back to all changes in this revision

Viewing changes to softwarecenter/db/application.py

  • Committer: Matthew McGowan
  • Date: 2011-03-23 10:45:21 UTC
  • mfrom: (1556.1.62 trunk)
  • Revision ID: matthew.joseph.mcgowan@gmail.com-20110323104521-0lysrjm8kudev4nb
merge w trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
            raise ValueError("Need either appname or pkgname or request")
48
48
        # defaults
49
49
        self.pkgname = pkgname.replace("$kernel", os.uname()[2])
50
 
        self.appname = appname
 
50
        if appname:
 
51
            self.appname = unicode(appname)
 
52
        else:
 
53
            self.appname = ''
51
54
        # the request can take additional "request" data like apturl
52
55
        # strings or the path of a local deb package
53
56
        self.request = request
71
74
        """ return a new AppDetails object for this application """
72
75
        return AppDetails(db, application=self)
73
76
 
 
77
    def get_untranslated_app(self, db):
 
78
        """ return a Application object with the untranslated application
 
79
            name 
 
80
        """
 
81
        try:
 
82
            doc = db.get_xapian_document(self.appname, self.pkgname)
 
83
        except IndexError:
 
84
            return self
 
85
        untranslated_application = doc.get_value(XAPIAN_VALUE_APPNAME_UNTRANSLATED)
 
86
        uapp = Application(untranslated_application, self.pkgname)
 
87
        return uapp
 
88
 
74
89
    @staticmethod
75
90
    def get_display_name(db, doc):
76
91
        """ Return the application name as it should be displayed in the UI
102
117
        return self.apps_cmp(self, other)
103
118
    def __str__(self):
104
119
        return "%s,%s" % (self.appname, self.pkgname)
 
120
    def __repr__(self):
 
121
        return "[Application: appname=%s pkgname=%s]" % (self.appname, self.pkgname)
105
122
    @staticmethod
106
123
    def apps_cmp(x, y):
107
124
        """ sort method for the applications """