2007-07-19 17:49:08 +00:00
|
|
|
"""This script shows how to compute the list of global entities in a whole
|
|
|
|
|
application, in a project or in a source file"""
|
|
|
|
|
|
2017-06-23 14:46:24 +02:00
|
|
|
from GPS import Project, File
|
2007-07-19 17:49:08 +00:00
|
|
|
|
|
|
|
|
|
2017-06-23 14:46:24 +02:00
|
|
|
def global_entities(where=None):
|
|
|
|
|
"""Return all global entities in where, which should either be an instance
|
2024-06-05 14:41:24 +04:00
|
|
|
of GPS.File, GPS.Project, or None. In the latter case, all global
|
|
|
|
|
entities in the application are returned"""
|
2017-06-23 14:46:24 +02:00
|
|
|
result = []
|
|
|
|
|
if not where:
|
|
|
|
|
for p in Project.root().dependencies(recursive=True):
|
|
|
|
|
result.extend(global_entities(p))
|
2007-07-19 17:49:08 +00:00
|
|
|
|
2017-06-23 14:46:24 +02:00
|
|
|
elif isinstance(where, Project):
|
|
|
|
|
for s in where.sources():
|
|
|
|
|
result.extend(global_entities(s))
|
2007-07-19 17:49:08 +00:00
|
|
|
|
2017-06-23 14:46:24 +02:00
|
|
|
elif isinstance(where, File):
|
|
|
|
|
for e in where.entities():
|
|
|
|
|
if e.attributes()["global"]:
|
|
|
|
|
result.append(e)
|
|
|
|
|
return result
|