File: globals.py

package info (click to toggle)
gnat-gps 5.3dfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 50,360 kB
  • ctags: 11,617
  • sloc: ada: 374,346; ansic: 92,327; python: 15,979; xml: 12,186; sh: 3,277; makefile: 1,113; awk: 154; perl: 128; java: 17
file content (24 lines) | stat: -rw-r--r-- 762 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
"""This script shows how to compute the list of global entities in a whole
   application, in a project or in a source file"""

from GPS import *

def global_entities (where = None):
  """Return all global entities in where, which should either be an instance
     of GPS.File, GPS.Project, or None. In the latter case, all global
     entities in the application are returned"""
  result = []
  if not where:
   for p in Project.root().dependencies (recursive=True):
     result.extend (global_entities (p))

  elif isinstance (where, Project):
    for s in where.sources():
      result.extend (global_entities (s))

  elif isinstance (where, File):
    for e in where.entities():
      if e.attributes()["global"]:
         result.append (e)
  return result