X7ROOT File Manager
Current Path:
/usr/lib/python2.7/site-packages/blivet
usr
/
lib
/
python2.7
/
site-packages
/
blivet
/
📁
..
📄
__init__.py
(117.33 KB)
📄
__init__.pyc
(100.39 KB)
📄
__init__.pyo
(100.39 KB)
📄
arch.py
(9.45 KB)
📄
arch.pyc
(8.63 KB)
📄
arch.pyo
(8.63 KB)
📄
callbacks.py
(3.55 KB)
📄
callbacks.pyc
(1.85 KB)
📄
callbacks.pyo
(1.85 KB)
📄
deviceaction.py
(32.05 KB)
📄
deviceaction.pyc
(33.21 KB)
📄
deviceaction.pyo
(33.21 KB)
📄
devicefactory.py
(63.97 KB)
📄
devicefactory.pyc
(54.57 KB)
📄
devicefactory.pyo
(54.57 KB)
📁
devicelibs
📁
devices
📄
devicetree.py
(117.74 KB)
📄
devicetree.pyc
(82.74 KB)
📄
devicetree.pyo
(82.74 KB)
📄
errors.py
(5.25 KB)
📄
errors.pyc
(12.1 KB)
📄
errors.pyo
(12.1 KB)
📄
fcoe.py
(7.91 KB)
📄
fcoe.pyc
(7.27 KB)
📄
fcoe.pyo
(7.27 KB)
📄
flags.py
(3.89 KB)
📄
flags.pyc
(2.53 KB)
📄
flags.pyo
(2.53 KB)
📁
formats
📄
i18n.py
(1.21 KB)
📄
i18n.pyc
(756 B)
📄
i18n.pyo
(756 B)
📄
iscsi.py
(19.29 KB)
📄
iscsi.pyc
(16.36 KB)
📄
iscsi.pyo
(16.36 KB)
📄
nvdimm.py
(6.24 KB)
📄
nvdimm.pyc
(6.16 KB)
📄
nvdimm.pyo
(6.16 KB)
📄
partitioning.py
(95.65 KB)
📄
partitioning.pyc
(66.5 KB)
📄
partitioning.pyo
(66.5 KB)
📄
partspec.py
(4.05 KB)
📄
partspec.pyc
(3.34 KB)
📄
partspec.pyo
(3.34 KB)
📄
platform.py
(17.38 KB)
📄
platform.pyc
(18.52 KB)
📄
platform.pyo
(18.52 KB)
📄
size.py
(13.47 KB)
📄
size.pyc
(11.4 KB)
📄
size.pyo
(11.4 KB)
📄
storage_log.py
(2.56 KB)
📄
storage_log.pyc
(3.32 KB)
📄
storage_log.pyo
(3.32 KB)
📄
tsort.py
(3.37 KB)
📄
tsort.pyc
(2.38 KB)
📄
tsort.pyo
(2.38 KB)
📄
udev.py
(28.34 KB)
📄
udev.pyc
(30.19 KB)
📄
udev.pyo
(30.19 KB)
📄
util.py
(15.94 KB)
📄
util.pyc
(19.52 KB)
📄
util.pyo
(19.52 KB)
📄
zfcp.py
(16.01 KB)
📄
zfcp.pyc
(13 KB)
📄
zfcp.pyo
(13 KB)
Editing: tsort.py
# tsort.py # Topological sorting. # # Copyright (C) 2010 Red Hat, Inc. # # This copyrighted material is made available to anyone wishing to use, # modify, copy, or redistribute it subject to the terms and conditions of # the GNU General Public License v.2, or (at your option) any later version. # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY expressed or implied, including the implied warranties of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. You should have received a copy of the # GNU General Public License along with this program; if not, write to the # Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301, USA. Any Red Hat trademarks that are incorporated in the # source code or documentation are not subject to the GNU General Public # License and may only be used or replicated with the express permission of # Red Hat, Inc. # # Red Hat Author(s): Dave Lehman <dlehman@redhat.com> # class CyclicGraphError(Exception): pass def tsort(graph): order = [] # sorted list of items if not graph or not graph['items']: return order # determine which nodes have no incoming edges roots = [n for n in graph['items'] if graph['incoming'][n] == 0] if not roots: raise CyclicGraphError("no root nodes") visited = [] # list of nodes visited, for cycle detection while roots: # remove a root, add it to the order root = roots.pop() if root in visited: raise CyclicGraphError("graph contains cycles") visited.append(root) order.append(root) # remove each edge from the root to another node for (parent, child) in [e for e in graph['edges'] if e[0] == root]: graph['incoming'][child] -= 1 graph['edges'].remove((parent, child)) # if destination node is now a root, add it to roots if graph['incoming'][child] == 0: roots.append(child) if len(graph['items']) != len(visited): raise CyclicGraphError("graph contains cycles") return order def create_graph(items, edges): """ Create a graph based on a list of items and a list of edges. Arguments: items - an iterable containing (hashable) items to sort edges - an iterable containing (parent, child) edge pair tuples Return Value: The return value is a dictionary representing the directed graph. It has three keys: items is the same as the input argument of the same name edges is the same as the input argument of the same name incoming is a dict of incoming edge count hashed by item """ graph = {'items': [], # the items to sort 'edges': [], # partial order info: (parent, child) pairs 'incoming': {}} # incoming edge count for each item graph['items'] = items graph['edges'] = edges for item in items: graph['incoming'][item] = 0 for (_parent, child) in edges: graph['incoming'][child] += 1 return graph def main(): items = [5, 2, 3, 4, 1] edges = [(1, 2), (2, 4), (4, 5), (3, 2)] print(items) print(edges) graph = create_graph(items, edges) print(tsort(graph)) if __name__ == "__main__": main()
Upload File
Create Folder