Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Cédric Le Ninivin
erp5
Commits
8257e0ac
Commit
8257e0ac
authored
May 18, 2011
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix bt5 dependency sort and detect circular dependency
parent
661f6a24
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
18 deletions
+59
-18
product/ERP5/Tool/TemplateTool.py
product/ERP5/Tool/TemplateTool.py
+59
-18
No files found.
product/ERP5/Tool/TemplateTool.py
View file @
8257e0ac
...
...
@@ -972,28 +972,69 @@ class TemplateTool (BaseTool):
bt_list
:
list
of
(
repository
,
id
)
tuple
.
"""
def isDepend(a, b):
# return True if a depends on b.
dependency_list = [x.split(' ')[0] for x in a['dependency_list']]
provision_list = list(b['provision_list']) + [b['title']]
for i in provision_list:
if i in dependency_list:
return True
return False
sorted_bt_list = []
# Calculate the dependency graph
dependency_dict = {}
provition_dict = {}
repository_dict = {}
undependent_list = []
for repository, bt_id in bt_list:
repository_dict[bt_id] = repository
bt = [x for x in self.repository_dict[repository]
\
if x['id'] == bt_id][0]
for j in range(len(sorted_bt_list)):
if isDepend(sorted_bt_list[j][1], bt):
sorted_bt_list.insert(j, (repository, bt))
break
else:
sorted_bt_list.append((repository, bt))
sorted_bt_list = [(repository, bt['id']) for repository, bt
\
in sorted_bt_list]
return sorted_bt_list
dependency_dict[bt_id] = [x.split(' ')[0] for x in bt['dependency_list']]
if not dependency_dict[bt_id]:
del dependency_dict[bt_id]
for provision in list(bt['provision_list']):
provition_dict[provision] = bt_id
undependent_list.append(bt_id)
# Calculate the reverse dependency graph
reverse_dependency_dict = {}
for bt_id, dependency_id_list in dependency_dict.items():
update_dependency_id_list = []
for dependency_id in dependency_id_list:
# Get ride of provision id
if dependency_id in provition_dict:
dependency_id = provition_dict[dependency_id]
update_dependency_id_list.append(dependency_id)
# Fill incoming edge dict
if dependency_id in reverse_dependency_dict:
reverse_dependency_dict[dependency_id].append(bt_id)
else:
reverse_dependency_dict[dependency_id] = [bt_id]
# Remove from free node list
try:
undependent_list.remove(dependency_id)
except ValueError:
pass
dependency_dict[bt_id] = update_dependency_id_list
# Let's sort the bt5!
while undependent_list:
bt_id = undependent_list.pop(0)
sorted_bt_list.insert(0, (repository_dict[bt_id], bt_id))
for dependency_id in dependency_dict.get(bt_id, []):
local_dependency_list = reverse_dependency_dict[dependency_id]
local_dependency_list.remove(bt_id)
if local_dependency_list:
reverse_dependency_dict[dependency_id] = local_dependency_list
else:
del reverse_dependency_dict[dependency_id]
undependent_list.append(dependency_id)
if len(sorted_bt_list) != len(bt_list):
raise NotImplementedError,
\
"Circular dependencies on %s" % reverse_dependency_dict.keys()
else:
return sorted_bt_list
security.declareProtected(Permissions.AccessContentsInformation,
'sortDownloadedBusinessTemplateList')
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment