KApiDox

framework.py
1 # -*- coding: utf-8 -*-
2 #
3 # SPDX-FileCopyrightText: 2014 Aurélien Gâteau <[email protected]>
4 #
5 # SPDX-License-Identifier: BSD-2-Clause
6 
7 from functools import reduce
8 
9 class Framework(object):
10  """
11  A framework has a tier, a name, a collection of targets it provides.
12  For each target it provides, it knows which targets they depend on.
13 
14  It also has a list of frameworks it depends on, for framework-to-framework
15  dependencies. This is useful for cases when a framework depends on macros
16  provided by another framework.
17  """
18  def __init__(self, tier, name):
19  self.tier = tier
20  self.name = name
21 
22  # A dict of target => set([targets])
23  self._target_dict = {}
24 
25  # A list of other frameworks (not targets!) this framework depends on.
26  self._fw_list = []
27 
28  def add_target(self, target):
29  # Add a new target provided by this framework
30  assert target not in self._target_dict
31  self._target_dict[target] = set()
32 
33  def add_target_dependency(self, target, dep):
34  # Add a new dependency target to a target provided by this framework
35  assert target in self._target_dict
36  self._target_dict[target].add(dep)
37 
38  def get_targets(self):
39  return self._target_dict.keys()
40 
41  def has_target(self, target):
42  return target in self._target_dict
43 
44  def get_all_target_dependencies(self):
45  deps = self._target_dict.values()
46  if not deps:
47  return set()
48  return reduce(lambda x,y: x.union(y), deps)
49 
50  def get_dependencies_for_target(self, target):
51  return self._target_dict[target]
52 
53  def add_extra_framework(self, name):
54  # Add a framework this framework depends on because of a
55  # framework-to-framework dependency
56  self._fw_list.append(name)
57 
58  def get_extra_frameworks(self):
59  # Returns frameworks this framework depends on because of a
60  # framework-to-framework dependency
61  return self._fw_list
62 
63  def __repr__(self):
64  return self.name
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Fri Sep 25 2020 22:54:39 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.