Пример #1
0
    def get_info(self, app: FlatpakApplication) -> dict:
        if app.installed:
            if app.update_component:
                app_info = {'id': app.id,
                            'name': app.name,
                            'branch': app.branch,
                            'installation': app.installation,
                            'origin': app.origin,
                            'arch': app.arch,
                            'ref': app.ref,
                            'type': 'runtime' if app.runtime else self.i18n['unknown']}
            else:
                version = flatpak.get_version()
                id_ = app.base_id if app.partial and version < VERSION_1_5 else app.id
                app_info = flatpak.get_app_info_fields(id_, app.branch, app.installation)

                if app.partial and version < VERSION_1_5:
                    app_info['id'] = app.id
                    app_info['ref'] = app.ref

                app_info['name'] = app.name
                app_info['type'] = 'runtime' if app.runtime else 'app'
                app_info['description'] = strip_html(app.description) if app.description else ''

                if app.installation:
                    app_info['installation'] = app.installation

                if app_info.get('installed'):
                    app_info['installed'] = app_info['installed'].replace('?', ' ')

            return app_info
        else:
            res = self.http_client.get_json('{}/apps/{}'.format(FLATHUB_API_URL, app.id))

            if res:
                if res.get('categories'):
                    res['categories'] = [c.get('name') for c in res['categories']]

                for to_del in ('screenshots', 'iconMobileUrl', 'iconDesktopUrl'):
                    if res.get(to_del):
                        del res[to_del]

                for to_strip in ('description', 'currentReleaseDescription'):
                    if res.get(to_strip):
                        res[to_strip] = strip_html(res[to_strip])

                for to_date in ('currentReleaseDate', 'inStoreSinceDate'):
                    if res.get(to_date):
                        try:
                            res[to_date] = datetime.strptime(res[to_date], DATE_FORMAT)
                        except:
                            self.context.logger.error('Could not convert date string {} as {}'.format(res[to_date], DATE_FORMAT))
                            pass

                return res
            else:
                return {}
Пример #2
0
    def get_info(self, app: FlatpakApplication) -> dict:
        app_info = flatpak.get_app_info_fields(app.id, app.branch)
        app_info['name'] = app.name
        app_info['type'] = 'runtime' if app.runtime else 'app'
        app_info['description'] = strip_html(
            app.description) if app.description else ''

        if app_info.get('installed'):
            app_info['installed'] = app_info['installed'].replace('?', ' ')

        return app_info
Пример #3
0
    def get_info(self, app: FlatpakApplication) -> dict:
        if app.installed:
            app_info = flatpak.get_app_info_fields(app.id, app.branch)
            app_info['name'] = app.name
            app_info['type'] = 'runtime' if app.runtime else 'app'
            app_info['description'] = strip_html(
                app.description) if app.description else ''

            if app_info.get('installed'):
                app_info['installed'] = app_info['installed'].replace('?', ' ')

            return app_info
        else:
            res = self.http_client.get_json('{}/apps/{}'.format(
                FLATHUB_API_URL, app.id))

            if res:
                if res.get('categories'):
                    res['categories'] = [
                        c.get('name') for c in res['categories']
                    ]

                for to_del in ('screenshots', 'iconMobileUrl',
                               'iconDesktopUrl'):
                    if res.get(to_del):
                        del res[to_del]

                for to_strip in ('description', 'currentReleaseDescription'):
                    if res.get(to_strip):
                        res[to_strip] = strip_html(res[to_strip])

                for to_date in ('currentReleaseDate', 'inStoreSinceDate'):
                    if res.get(to_date):
                        try:
                            res[to_date] = datetime.strptime(
                                res[to_date], DATE_FORMAT)
                        except:
                            self.context.logger.error(
                                'Could not convert date string {} as {}'.
                                format(res[to_date], DATE_FORMAT))
                            pass

                return res
            else:
                return {}