Esempio n. 1
0
 def testValidKeys(self):
     expected_error = "Invalid key 'BAR' in info file dummy_file:2"
     contents = 'FOO=bar\nBAR=baz\n'
     valid = ['FOO']
     required = []
     with self.assertRaisesRegexp(error.Error, expected_error):
         pkg_info.ParsePkgInfo(contents, 'dummy_file', valid, required)
Esempio n. 2
0
 def testRequiredKeys(self):
     expected_error = "Required key 'BAR' missing from info file: 'dummy_file'"
     contents = 'FOO=bar\n'
     valid = ['FOO']
     required = ['BAR']
     with self.assertRaisesRegexp(error.Error, expected_error):
         pkg_info.ParsePkgInfo(contents, 'dummy_file', valid, required)
Esempio n. 3
0
    def ParseIndex(self, index_data):
        if not index_data:
            return

        for info_files in index_data.split('\n\n'):
            info = pkg_info.ParsePkgInfo(info_files, self.filename,
                                         self.valid_keys, self.required_keys)
            debug = info['BUILD_CONFIG'] == 'debug'
            config = configuration.Configuration(info['BUILD_ARCH'],
                                                 info['BUILD_TOOLCHAIN'],
                                                 debug)
            key = (info['NAME'], config)
            if key in self.packages:
                error.Error('package index contains duplicate: %s' % str(key))
            self.packages[key] = info
Esempio n. 4
0
    def ParseInfo(self, info_string):
        valid_keys = pkg_info.VALID_KEYS + self.extra_keys
        required_keys = pkg_info.REQUIRED_KEYS + self.extra_keys

        for key in valid_keys:
            if key in self.list_props:
                setattr(self, key, [])
            else:
                setattr(self, key, None)

        # Parse pkg_info file
        info = pkg_info.ParsePkgInfo(info_string, self.info, valid_keys,
                                     required_keys)

        # Set attributres based on pkg_info setttings.
        for key, value in info.items():
            setattr(self, key, value)

        self.Validate()
Esempio n. 5
0
 def testComments(self):
     result = pkg_info.ParsePkgInfo('NAME=foo # tail\n# line\nVERSION=bar',
                                    'dummy_file')
     self.assertEqual(result, {'NAME': 'foo', 'VERSION': 'bar'})
Esempio n. 6
0
 def testBalnkLine(self):
     result = pkg_info.ParsePkgInfo('NAME=foo\n\nVERSION=bar', 'dummy_file')
     self.assertEqual(result, {'NAME': 'foo', 'VERSION': 'bar'})
Esempio n. 7
0
 def testInvalidLine(self):
     expected_error = 'Invalid info line dummy_file:1'
     with self.assertRaisesRegexp(error.Error, expected_error):
         pkg_info.ParsePkgInfo('line without equals sign', 'dummy_file')