This file is indexed.

/usr/share/bauble/plugins/plants/geography.py is in bauble 0.9.7-2.1build1.

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
#
# geography.py
#
from datetime import datetime

from sqlalchemy import *
from sqlalchemy.orm import *

import bauble
import bauble.db as db
from bauble.view import ResultSet
from bauble.utils.log import debug


def get_species_in_geography(geo):
    # get all the geography children under geo
    from bauble.plugins.plants.species import SpeciesDistribution, \
         species_distribution_table, Species, species_table
    geo_kids = []
    # TODO: getting the kids is too slow, is there a better way?
    # TODO: it might be better to put this in a tasklet or something so
    # that we can atleast do a set_busy() on the gui so the user only clicks
    # on the item once, or just disable double clicking until everything has
    # expanded properly....that's probably not a bad idea in general, just
    # before we get an items children in the results view we should disable
    # clicking in the view and once the item has expanded we reenable it
    #
    # TODO: need to change this to use the new queries on the mapper
    # or to update the select statements if we don't want to create
    # full on Geography objects
    raise NotImplementedError
    kids_stmt = select([geography_table.c.id],
                       geography_table.c.parent_id==bindparam('parent_id'))
    def get_kids(parent_id):
        for kid_id, in kids_stmt.execute(parent_id=parent_id):
            geo_kids.append(kid_id)
            get_kids(kid_id)
        geo_kids.append(parent_id)
    get_kids(geo.id)
    session = object_session(geo)
    species_ids = select([species_distribution_table.c.species_id],
                    species_distribution_table.c.geography_id.in_(geo_kids))
    return ResultSet(session.query(Species).\
                     filter(species_table.c.id.in_(species_ids)))



class Geography(db.Base):
    """
    Represents a geography unit.

    :Table name: geography

    :Columns:
        *name*:

        *tdwg_code*:

        *iso_code*:

        *parent_id*:

    :Properties:
        *children*:

    :Constraints:
    """
    __tablename__ = 'geography'

    # columns
    name = Column(Unicode(255), nullable=False)
    tdwg_code = Column(String(6))
    iso_code = Column(String(7))
    parent_id = Column(Integer, ForeignKey('geography.id'))


    def __str__(self):
        return self.name


# late bindings
Geography.children = relation(Geography,
                              primaryjoin=Geography.parent_id==Geography.id,
                              cascade='all',
                              backref=backref("parent",
                                    remote_side=[Geography.__table__.c.id]),
                              order_by=[Geography.name])