This file is indexed.

/usr/share/gps/library/simple_project.py is in gnat-gps-common 5.3dfsg-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
"""Ease creation of new projects

This file adds some new menu entries in Project, to facilitate the
creation of new basic project files:
  - Either by just asking the name of the main unit
  - Or by automatically guessing the name of this unit by looking at the
    current source editor
  - Or by asking for a name, and creating both the main unit and the project
"""


############################################################################
## No user customization below this line
############################################################################

import GPS, os.path

GPS.parse_xml ("""
  <action name="simple_project_from_dialog" show-command="false" category="Projects">
     <shell lang="python">simple_project.create_from_dialog()</shell>
  </action>

  <action name="simple_project_from_current" show-command="false" category="Projects">
    <filter id="Source editor" />
    <shell lang="python">simple_project.create_from_context()</shell>
  </action>

  <action name="simple_project_and_main" show-command="false" category="Projects">
    <shell lang="python">simple_project.create_project_and_main()</shell>
  </action>

  <menu action="simple_project_from_dialog">
     <title>/Project/Create from Dialog</title>
  </menu>

  <menu action="simple_project_from_current">
     <title>/Project/Create from Current File</title>
  </menu>

  <menu action="simple_project_and_main">
     <title>/Project/Create Project and Main Unit</title>
  </menu>
  """)

def create_from_main (main_file, create_main=0):
  print "file = " + main_file
  if main_file != "":
     main = os.path.splitext (os.path.basename(main_file)) [0]
     out_file = os.path.dirname (os.path.abspath (main_file)) + os.sep + main + ".gpr"
     out = file (out_file, "w")
     out.write ("project " + main + " is\n")
     out.write ("   for Source_Dirs use (\".\");\n")
     out.write ("   for Main use (\"" + main_file + "\");\n")
     out.write ("end " + main + ";\n")
     out.close()

     if create_main:
        out = file (os.path.splitext (os.path.abspath (main_file))[0] + ".adb", "w")
        out.write ("procedure " + main + " is\n")
        out.write ("begin\n")
        out.write ("   null;\n")
        out.write ("end " + main + ";\n")
        out.close ()

     GPS.Project.load (out_file)


def create_from_dialog():
   """Create a new project file, asking the user for the name of the main unit"""
   main = GPS.MDI.input_dialog \
      ("Please enter file name that contains the main unit", "main unit") [0]
   create_from_main (main)

def create_from_context():
   """Create a new project file, using the current source as main"""
   try:
      create_from_main (GPS.current_context().file().name())
   except:
      pass

def create_project_and_main():
   """Ask the user for a project name, and create a main unit and project file"""
   dir, main = GPS.MDI.input_dialog \
      ("Enter the name of the project", "directory", "name")
   dir = os.path.abspath (dir)
   if not os.path.isdir (dir): os.mkdir (dir)
   os.chdir (dir)
   create_from_main (main, create_main=1)