コード例 #1
0
ファイル: graph.py プロジェクト: anubnair/pants
def parse_address_family(address_mapper, path, build_files_content):
  """Given the contents of the build files in one directory, return an AddressFamily.

  The AddressFamily may be empty, but it will not be None.
  """
  address_maps = []
  for filepath, filecontent in build_files_content.dependencies:
    address_maps.append(AddressMap.parse(filepath,
                                         filecontent,
                                         address_mapper.symbol_table_cls,
                                         address_mapper.parser_cls))
  return AddressFamily.create(path.path, address_maps)
コード例 #2
0
ファイル: build_files.py プロジェクト: benjyw/pants
def parse_address_family(address_mapper, path, build_files):
  """Given the contents of the build files in one directory, return an AddressFamily.

  The AddressFamily may be empty, but it will not be None.
  """
  files_content = build_files.files_content.dependencies
  if not files_content:
    raise ResolveError('Directory "{}" does not contain build files.'.format(path))
  address_maps = []
  paths = (f.path for f in files_content)
  ignored_paths = set(address_mapper.build_ignore_patterns.match_files(paths))
  for filecontent_product in files_content:
    if filecontent_product.path in ignored_paths:
      continue
    address_maps.append(AddressMap.parse(filecontent_product.path,
                                         filecontent_product.content,
                                         address_mapper.parser))
  return AddressFamily.create(path.path, address_maps)
コード例 #3
0
ファイル: build_files.py プロジェクト: foursquare/pants
def parse_address_family(address_mapper, directory):
  """Given an AddressMapper and a directory, return an AddressFamily.

  The AddressFamily may be empty, but it will not be None.
  """
  patterns = tuple(join(directory.path, p) for p in address_mapper.build_patterns)
  path_globs = PathGlobs(include=patterns,
                         exclude=address_mapper.build_ignore_patterns)
  snapshot = yield Get(Snapshot, PathGlobs, path_globs)
  files_content = yield Get(FilesContent, DirectoryDigest, snapshot.directory_digest)

  if not files_content:
    raise ResolveError('Directory "{}" does not contain any BUILD files.'.format(directory.path))
  address_maps = []
  for filecontent_product in files_content.dependencies:
    address_maps.append(AddressMap.parse(filecontent_product.path,
                                         filecontent_product.content,
                                         address_mapper.parser))
  yield AddressFamily.create(directory.path, address_maps)
コード例 #4
0
ファイル: build_files.py プロジェクト: pantsbuild-osx/pants
def parse_address_family(address_mapper, path, build_files_content):
    """Given the contents of the build files in one directory, return an AddressFamily.

  The AddressFamily may be empty, but it will not be None.
  """
    if not build_files_content.dependencies:
        raise ResolveError('Directory "{}" does not contain build files.'.format(path))
    address_maps = []
    for filecontent_product in build_files_content.dependencies:
        address_maps.append(
            AddressMap.parse(
                filecontent_product.path,
                filecontent_product.content,
                address_mapper.symbol_table_cls,
                address_mapper.parser_cls,
                address_mapper.exclude_patterns,
            )
        )
    return AddressFamily.create(path.path, address_maps)
コード例 #5
0
ファイル: test_mapper.py プロジェクト: RobinTec/pants
 def parse_address_map(self, json):
   path = '/dev/null'
   address_map = AddressMap.parse(path, json, self._symbol_table_cls, self._parser_cls)
   self.assertEqual(path, address_map.path)
   yield address_map
コード例 #6
0
ファイル: test_mapper.py プロジェクト: baroquebobcat/pants
 def parse_address_map(self, json):
   path = '/dev/null'
   address_map = AddressMap.parse(path, json, self._parser)
   self.assertEqual(path, address_map.path)
   yield address_map
コード例 #7
0
 def parse_address_map(self, json):
     path = '/dev/null'
     address_map = AddressMap.parse(path, json, self._parser)
     self.assertEqual(path, address_map.path)
     yield address_map
コード例 #8
0
 def test_duplicate_names(self):
     with self.assertRaises(DuplicateNameError):
         AddressFamily.create('name/space', [
             AddressMap('name/space/0', {'one': Thing(name='one', age=42)}),
             AddressMap('name/space/1', {'one': Thing(name='one', age=37)})
         ])
コード例 #9
0
 def test_mismatching_paths(self):
     with self.assertRaises(DifferingFamiliesError):
         AddressFamily.create('one', [
             AddressMap('/dev/null/one/0', {}),
             AddressMap('/dev/null/two/0', {})
         ])
コード例 #10
0
ファイル: test_mapper.py プロジェクト: jayvaidya/pants
 def parse_address_map(self, json, exclude_patterns=None):
     path = '/dev/null'
     address_map = AddressMap.parse(path, json, self._symbol_table_cls,
                                    self._parser_cls, exclude_patterns)
     self.assertEqual(path, address_map.path)
     yield address_map
コード例 #11
0
 def test_mismatching_paths(self) -> None:
     with self.assertRaises(DifferingFamiliesError):
         AddressFamily.create(
             "one", [AddressMap("/dev/null/one/0", {}), AddressMap("/dev/null/two/0", {})]
         )