This file is indexed.

/usr/share/pyshared/ase/gui/graphene.py is in python-ase 3.6.0.2515-1.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
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
# encoding: utf-8
"""nanotube.py - Window for setting up Graphene sheets and ribbons.
"""


import gtk
from gettext import gettext as _
from ase.gui.widgets import pack, cancel_apply_ok, oops
from ase.gui.setupwindow import SetupWindow
from ase.gui.pybutton import PyButton
from ase.structure import graphene_nanoribbon
import ase
import numpy as np

introtext = _("""\
Set up a graphene sheet or a graphene nanoribbon.  A nanoribbon may
optionally be saturated with hydrogen (or another element).\
""")

py_template = """
from ase.structure import nanotube

atoms = nanotube(%(n)i, %(m)i, length=%(length)i, bond=%(bl).3f, symbol=%(symb)s)
"""

class SetupGraphene(SetupWindow):
    "Window for setting up a graphene sheet or nanoribbon."
    def __init__(self, gui):
        SetupWindow.__init__(self)
        self.set_title(_("Graphene"))
        vbox = gtk.VBox()

        # Intoductory text
        self.packtext(vbox, introtext)

        # Choose structure
        label = gtk.Label(_("Structure: "))
        self.struct = gtk.combo_box_new_text()
        for s in (_("Infinite sheet"), _("Unsaturated ribbon"), 
                  _("Saturated ribbon")):
            self.struct.append_text(s)
        self.struct.set_active(0)
        self.struct.connect('changed', self.update_gui)
        pack(vbox, [label, self.struct])

        # Orientation
        label = gtk.Label(_("Orientation: "))
        self.orient = gtk.combo_box_new_text()
        self.orient_text = []
        for s in (_("zigzag"), _("armchair")):
            self.orient.append_text(s)
            self.orient_text.append(s)
        self.orient.set_active(0)
        self.orient.connect('changed', self.update_gui)
        pack(vbox, [label, self.orient])
        pack(vbox, gtk.Label(""))


        # Choose the element and bond length
        label1 = gtk.Label("Element: ")
        #label.set_alignment(0.0, 0.2)
        self.element = gtk.Entry(max=3)
        self.element.set_text("C")
        self.element.connect('activate', self.update_element)
        self.bondlength = gtk.Adjustment(1.42, 0.0, 1000.0, 0.01)
        label2 = gtk.Label(_("  Bond length: "))
        label3 = gtk.Label(_("Å"))
        bond_box = gtk.SpinButton(self.bondlength, 10.0, 3)
        pack(vbox, [label1, self.element, label2, bond_box, label3])

        # Choose the saturation element and bond length
        self.sat_label1 = gtk.Label(_("Saturation: "))
        #label.set_alignment(0.0, 0.2)
        self.element2 = gtk.Entry(max=3)
        self.element2.set_text(_("H"))
        self.element2.connect('activate', self.update_element)
        self.bondlength2 = gtk.Adjustment(1.12, 0.0, 1000.0, 0.01)
        self.sat_label2 = gtk.Label(_("  Bond length: "))
        self.sat_label3 = gtk.Label(_("Å"))
        self.bond_box = gtk.SpinButton(self.bondlength2, 10.0, 3)
        pack(vbox, [self.sat_label1, self.element2, self.sat_label2,
                    self.bond_box, self.sat_label3])

        self.elementinfo = gtk.Label("")
        self.elementinfo.modify_fg(gtk.STATE_NORMAL,
                                   gtk.gdk.color_parse('#FF0000'))
        pack(vbox, [self.elementinfo])
        pack(vbox, gtk.Label(""))

        # Size
        label1 = gtk.Label(_("Width: "))
        label2 = gtk.Label(_("  Length: "))
        self.n = gtk.Adjustment(1, 1, 100, 1)
        self.m = gtk.Adjustment(1, 1, 100, 1)
        spinn = gtk.SpinButton(self.n, 0, 0)
        spinm = gtk.SpinButton(self.m, 0, 0)
        pack(vbox, [label1, spinn, label2, spinm])

        # Vacuum
        label1 = gtk.Label(_("Vacuum: "))
        self.vacuum = gtk.Adjustment(5.0, 0.0, 1000.0, 0.1)
        label2 = gtk.Label(_("Å"))
        vac_box = gtk.SpinButton(self.vacuum, 10.0, 2)
        pack(vbox, [label1, vac_box, label2])
        pack(vbox, gtk.Label(""))


        # Buttons
        #self.pybut = PyButton("Creating a nanoparticle.")
        #self.pybut.connect('clicked', self.makeatoms)
        buts = cancel_apply_ok(cancel=lambda widget: self.destroy(),
                               apply=self.apply,
                               ok=self.ok)
        pack(vbox, [buts], end=True, bottom=True)

        # Finalize setup
        self.update_gui()
        self.add(vbox)
        vbox.show()
        self.show()
        self.gui = gui

    def update_element(self, *args):
        "Called when a new element may have been entered."
        # Assumes the element widget is self.element and that a label
        # for errors is self.elementinfo.  The chemical symbol is
        # placed in self.legalelement - or None if the element is
        # invalid.
        symb = []
        if self.struct.get_active() == 2:
            # Saturated nanoribbon
            elements = (self.element.get_text(), self.element2.get_text())
        else:
            elements = (self.element.get_text(), )
            
        for elem in elements:
            if not elem:
                self.invalid_element(_("  No element specified!"))
                return False
            try:
                z = int(elem)
            except ValueError:
                # Probably a symbol
                try:
                    z = ase.data.atomic_numbers[elem]
                except KeyError:
                    self.invalid_element()
                    return False
            try:
                symb.append(ase.data.chemical_symbols[z])
            except KeyError:
                self.invalid_element()
                return False
        self.elementinfo.set_text("")
        self.legal_element = symb[0]
        if len(symb) == 2:
            self.legal_element2 = symb[1]
        else:
            self.legal_element2 = None
        return True
        
    def update_gui(self, *args):
        # Saturation element is only relevant for saturated nanoribbons
        satur = self.struct.get_active() == 2
        for w in (self.element2, self.bond_box):
            w.set_sensitive(satur)
        # Infinite zigzag sheets must have even width
        if self.struct.get_active() == 0 and self.orient.get_active() == 0:
            if self.n.value % 2 == 1:
                self.n.value += 1
            self.n.lower = 2
            self.n.step_increment = 2
        else:
            self.n.lower = 1
            self.n.step_increment = 1
        
    def makeatoms(self, *args):
        self.update_element()
        if self.legal_element is None or (self.struct.get_active() == 2 and
                                          self.legal_element2 is None):
            self.atoms = None
            self.pybut.python = None
        else:
            n = int(self.n.value)
            m = int(self.m.value)
            CC = self.bondlength.value
            vacuum = self.vacuum.value
            orient = self.orient_text[self.orient.get_active()]
            elem = self.legal_element
            if self.struct.get_active() == 0:
                # Extended sheet
                self.atoms = graphene_nanoribbon(n, m, type=orient, C_C=CC,
                                                 vacc=vacuum, sheet=True,
                                                 main_element=elem)
            elif self.struct.get_active() == 1:
                # Unsaturated nanoribbon
                self.atoms = graphene_nanoribbon(n, m, type=orient, C_C=CC,
                                                 vacc=vacuum,
                                                 main_element=elem)
            elif self.struct.get_active() == 2:
                # Saturated nanoribbon
                elem2 = self.legal_element2
                self.atoms = graphene_nanoribbon(n, m, type=orient, C_C=CC,
                                                 C_H=self.bondlength2.value,
                                                 vacuum=vacuum,
                                                 saturated=True,
                                                 main_element=elem,
                                                 saturate_element=elem2)
            else:
                raise RuntimeError("Unknown structure in SetupGraphene!")
        # Now, rotate into the xy plane (ase.gui's default view plane)
        pos = self.atoms.get_positions()
        cell = self.atoms.get_cell()
        pbc = self.atoms.get_pbc()
        cell[1,1], cell[2,2] = cell[2,2], cell[1,1]
        x = pos[:,1].copy()
        z = pos[:,2].copy()
        pos[:,1] = z
        pos[:,2] = x
        self.atoms.set_cell(cell)
        self.atoms.set_positions(pos)
        self.atoms.set_pbc([pbc[0], pbc[2], pbc[1]])

    def apply(self, *args):
        self.makeatoms()
        if self.atoms is not None:
            self.gui.new_atoms(self.atoms)
            return True
        else:
            oops(_("No valid atoms."),
                 _("You have not (yet) specified a consistent set of "
                   "parameters."))
            return False

    def ok(self, *args):
        if self.apply():
            self.destroy()