1 | APP1 = 'proj.app1'
|
---|
2 | APP2 = 'proj.app2'
|
---|
3 | APP3 = 'proj.app3'
|
---|
4 | APP4 = 'proj.app4'
|
---|
5 | APP5 = 'proj.app5'
|
---|
6 | APP6 = 'proj.app6'
|
---|
7 | APP7 = 'proj.app7'
|
---|
8 | APP8 = 'proj.app8'
|
---|
9 | APP9 = 'proj.app9'
|
---|
10 |
|
---|
11 | DEPENDENCIES = {
|
---|
12 | APP2: [APP6, APP4, APP3],
|
---|
13 | APP5: [APP6, APP2],
|
---|
14 | APP6: [APP7, APP9, APP8, APP2],
|
---|
15 | }
|
---|
16 |
|
---|
17 | SPECIFIED_APPS = [
|
---|
18 | APP1,
|
---|
19 | APP2,
|
---|
20 | ]
|
---|
21 |
|
---|
22 | def dependency_track(dependencies, specs):
|
---|
23 | results = set()
|
---|
24 | dependencies_to_process = specs
|
---|
25 | while dependencies_to_process:
|
---|
26 | dependency = dependencies_to_process.pop()
|
---|
27 | if dependency not in results:
|
---|
28 | results.add(dependency)
|
---|
29 | if dependency in dependencies:
|
---|
30 | dependencies_to_process.extend(
|
---|
31 | [d for d in dependencies[dependency] if d not in results]
|
---|
32 | )
|
---|
33 | return tuple(results)
|
---|
34 |
|
---|
35 | INSTALLED_APPS = (
|
---|
36 | 'django.contrib.auth',
|
---|
37 | 'django.contrib.contenttypes',
|
---|
38 | 'django.contrib.sessions',
|
---|
39 | 'django.contrib.sites',
|
---|
40 | ) + dependency_track(DEPENDENCIES, SPECIFIED_APPS)
|
---|
41 |
|
---|
42 | print INSTALLED_APPS
|
---|
43 |
|
---|