コード例 #1
0
ファイル: provider.py プロジェクト: nextcloud/appstore
    def get_release_info(self, url: str, is_nightly: bool = False) -> Release:
        data = None
        with self.downloader.get_archive(
            url, self.config.download_root, self.config.download_max_timeout,
            self.config.download_max_redirects, self.config.download_max_size
        ) as download:
            meta = self.extractor.extract_app_metadata(download.filename)
            info = parse_app_metadata(meta.info_xml, self.config.info_schema,
                                      self.config.pre_info_xslt,
                                      self.config.info_xslt)
            if meta.database_xml:
                validate_database(meta.database_xml, self.config.db_schema,
                                  self.config.pre_db_xslt)
            info_app_id = info['app']['id']
            if meta.app_id != info_app_id:
                msg = 'Archive app folder is %s but info.xml reports id %s' \
                      % (meta.app_id, info_app_id)
                raise InvalidAppDirectoryException(msg)

            release = info['app']['release']
            info['app']['release']['is_nightly'] = is_nightly
            version = release['version']
            release['changelog'] = meta.changelog
            for code, value in meta.changelog.items():
                release['changelog'][code] = parse_changelog(value, version,
                                                             is_nightly)

            with open(download.filename, 'rb') as f:
                data = f.read()
        return info, data
コード例 #2
0
    def get_release_info(self, url: str, is_nightly: bool = False) -> Release:
        data = None
        with self.downloader.get_archive(
                url, self.config.download_root,
                self.config.download_max_timeout,
                self.config.download_max_redirects,
                self.config.download_max_size) as download:
            meta = self.extractor.extract_app_metadata(download.filename)
            info = parse_app_metadata(meta.info_xml, self.config.info_schema,
                                      self.config.pre_info_xslt,
                                      self.config.info_xslt)
            if meta.database_xml:
                validate_database(meta.database_xml, self.config.db_schema,
                                  self.config.pre_db_xslt)
            info_app_id = info['app']['id']
            if meta.app_id != info_app_id:
                msg = 'Archive app folder is %s but info.xml reports id %s' \
                      % (meta.app_id, info_app_id)
                raise InvalidAppDirectoryException(msg)

            release = info['app']['release']
            info['app']['release']['is_nightly'] = is_nightly
            version = release['version']
            release['changelog'] = meta.changelog
            for code, value in meta.changelog.items():
                release['changelog'][code] = parse_changelog(
                    value, version, is_nightly)

            with open(download.filename, 'rb') as f:
                data = f.read()
        return info, data
コード例 #3
0
ファイル: test_parser.py プロジェクト: Lpunk/appstore
 def test_validate_server_database(self):
     xml = self._get_contents('data/database/server.xml')
     validate_database(xml, self.config.db_schema, self.config.pre_db_xslt)
コード例 #4
0
ファイル: test_parser.py プロジェクト: Lpunk/appstore
 def test_validate_invalid_indexfield_elements_database(self):
     xml = self._get_contents('data/database/invalidindexfield.xml')
     with (self.assertRaises(InvalidAppMetadataXmlException)):
         validate_database(xml, self.config.db_schema,
                           self.config.pre_db_xslt)
コード例 #5
0
ファイル: test_parser.py プロジェクト: Lpunk/appstore
 def test_validate_name_before_decl_database(self):
     xml = self._get_contents('data/database/nameafterdecl.xml')
     with (self.assertRaises(InvalidAppMetadataXmlException)):
         validate_database(xml, self.config.db_schema,
                           self.config.pre_db_xslt)
コード例 #6
0
ファイル: test_parser.py プロジェクト: Lpunk/appstore
 def test_validate_broken_database(self):
     xml = self._get_contents('data/database/broken.xml')
     with (self.assertRaises(InvalidAppMetadataXmlException)):
         validate_database(xml, self.config.db_schema,
                           self.config.pre_db_xslt)
コード例 #7
0
ファイル: test_parser.py プロジェクト: uniblockchain/appstore
 def test_validate_server_database(self):
     xml = self._get_contents('data/database/server.xml')
     validate_database(xml, self.config.db_schema, self.config.pre_db_xslt)
コード例 #8
0
ファイル: test_parser.py プロジェクト: uniblockchain/appstore
 def test_validate_invalid_indexfield_elements_database(self):
     xml = self._get_contents('data/database/invalidindexfield.xml')
     with (self.assertRaises(InvalidAppMetadataXmlException)):
         validate_database(xml, self.config.db_schema,
                           self.config.pre_db_xslt)
コード例 #9
0
ファイル: test_parser.py プロジェクト: uniblockchain/appstore
 def test_validate_name_before_decl_database(self):
     xml = self._get_contents('data/database/nameafterdecl.xml')
     with (self.assertRaises(InvalidAppMetadataXmlException)):
         validate_database(xml, self.config.db_schema,
                           self.config.pre_db_xslt)
コード例 #10
0
ファイル: test_parser.py プロジェクト: uniblockchain/appstore
 def test_validate_broken_database(self):
     xml = self._get_contents('data/database/broken.xml')
     with (self.assertRaises(InvalidAppMetadataXmlException)):
         validate_database(xml, self.config.db_schema,
                           self.config.pre_db_xslt)