Esempio n. 1
0
 def test_required_keys(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.parse_pkg_info(contents, 'dummy_file', valid, required)
Esempio n. 2
0
 def test_required_keys(self):
     expected_error = "Required key 'BAR' missing from info file: 'dummy_file'"
     contents = 'FOO=bar\n'
     valid = ['FOO']
     required = ['BAR']
     with self.assertRaisesRegex(error.Error, expected_error):
         pkg_info.parse_pkg_info(contents, 'dummy_file', valid, required)
Esempio n. 3
0
 def test_valid_keys(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.parse_pkg_info(contents, 'dummy_file', valid, required)
Esempio n. 4
0
 def test_valid_keys(self):
     expected_error = "Invalid key 'BAR' in info file dummy_file:2"
     contents = 'FOO=bar\nBAR=baz\n'
     valid = ['FOO']
     required = []
     with self.assertRaisesRegex(error.Error, expected_error):
         pkg_info.parse_pkg_info(contents, 'dummy_file', valid, required)
Esempio n. 5
0
  def parse_index(self, index_data):
    if not index_data:
      return

    for info_files in index_data.split('\n\n'):
      info = pkg_info.parse_pkg_info(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. 6
0
  def parse_info(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.parse_pkg_info(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. 7
0
    def parse_info(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.parse_pkg_info(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. 8
0
 def test_comments(self):
   result = pkg_info.parse_pkg_info('NAME=foo # tail\n# line\nVERSION=bar',
                                    'dummy_file')
   self.assertEqual(result, {'NAME': 'foo', 'VERSION': 'bar'})
Esempio n. 9
0
 def test_blank_line(self):
   result = pkg_info.parse_pkg_info('NAME=foo\n\nVERSION=bar', 'dummy_file')
   self.assertEqual(result, {'NAME': 'foo', 'VERSION': 'bar'})
Esempio n. 10
0
 def test_invalid_line(self):
   expected_error = 'Invalid info line dummy_file:1'
   with self.assertRaisesRegexp(error.Error, expected_error):
     pkg_info.parse_pkg_info('line without equals sign', 'dummy_file')
Esempio n. 11
0
 def test_comments(self):
     result = pkg_info.parse_pkg_info(
         'NAME=foo # tail\n# line\nVERSION=bar', 'dummy_file')
     self.assertEqual(result, {'NAME': 'foo', 'VERSION': 'bar'})
Esempio n. 12
0
 def test_blank_line(self):
     result = pkg_info.parse_pkg_info('NAME=foo\n\nVERSION=bar',
                                      'dummy_file')
     self.assertEqual(result, {'NAME': 'foo', 'VERSION': 'bar'})
Esempio n. 13
0
 def test_invalid_line(self):
     expected_error = 'Invalid info line dummy_file:1'
     with self.assertRaisesRegex(error.Error, expected_error):
         pkg_info.parse_pkg_info('line without equals sign', 'dummy_file')