This file is indexed.

/usr/share/sumo/tools/build/checkSvnProps.py is in sumo-tools 0.15.0~dfsg-2.

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

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
#!/usr/bin/env python
"""
@file    checkSvnProps.py
@author  Michael Behrisch
@date    2010
@version $Id: checkSvnProps.py 11671 2012-01-07 20:14:30Z behrisch $

Checks svn property settings for all files.

SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
Copyright (C) 2010-2012 DLR (http://www.dlr.de/) and contributors
All rights reserved
"""

import os, subprocess, sys, xml.sax
from optparse import OptionParser

_SOURCE_EXT = [".h", ".cpp", ".py", ".pl", ".java", ".am"]
_TESTDATA_EXT = [".xml", ".prog", ".complex", ".dfrouter", ".duarouter", ".jtrrouter",
                 ".netconvert", ".netgen", ".od2trips", ".polyconvert", ".sumo",
                 ".meso", ".tools", ".traci", ".activitygen", ".scenario",
                 ".sumocfg", ".netccfg", ".netgcfg"]
_VS_EXT = [".vsprops", ".sln", ".vcproj", ".bat", ".props", ".vcxproj", ".filters"]
_KEYWORDS = "HeadURL Id LastChangedBy LastChangedDate LastChangedRevision"

class PropertyReader(xml.sax.handler.ContentHandler):
    """Reads the svn properties of files as written by svn pl -v --xml"""

    def __init__(self, doFix):
        self._fix = doFix
        self._file = ""
        self._property = None
        self._value = ""
        self._hadEOL = False
        self._hadKeywords = False

    def startElement(self, name, attrs):
        if name == 'target':
            self._file = attrs['path']
            seen.add(os.path.join(svnRoot, self._file))
        if name == 'property':
            self._property = attrs['name']

    def characters(self, content):
        if self._property:
            self._value += content


    def endElement(self, name):
        ext = os.path.splitext(self._file)[1]
        if name == 'property' and self._property == "svn:eol-style":
            self._hadEOL = True
        if name == 'property' and self._property == "svn:keywords":
            self._hadKeywords = True
        if ext in _SOURCE_EXT or ext in _TESTDATA_EXT or ext in _VS_EXT:
            if name == 'property' and self._property == "svn:executable" and ext not in [".py", ".pl", ".bat"]:
                print self._file, self._property, self._value
                if self._fix:
                    subprocess.call(["svn", "pd", "svn:executable", self._file])
            if name == 'property' and self._property == "svn:mime-type":
                print self._file, self._property, self._value
                if self._fix:
                    subprocess.call(["svn", "pd", "svn:mime-type", self._file])
        if ext in _SOURCE_EXT or ext in _TESTDATA_EXT:
            if name == 'property' and self._property == "svn:eol-style" and self._value != "LF"\
               or name == "target" and not self._hadEOL:
                print self._file, "svn:eol-style", self._value
                if self._fix:
                    if os.name == "posix":
                        subprocess.call(["sed", "-i", r's/\r$//', self._file])
                        subprocess.call(["sed", "-i", r's/\r/\n/g', self._file])
                    subprocess.call(["svn", "ps", "svn:eol-style", "LF", self._file])
        if ext in _SOURCE_EXT:
            if name == 'property' and self._property == "svn:keywords" and self._value != _KEYWORDS\
               or name == "target" and not self._hadKeywords:
                print self._file, "svn:keywords", self._value
                if self._fix:
                    subprocess.call(["svn", "ps", "svn:keywords", _KEYWORDS, self._file])
        if ext in _VS_EXT:
            if name == 'property' and self._property == "svn:eol-style" and self._value != "CRLF"\
               or name == "target" and not self._hadEOL:
                print self._file, "svn:eol-style", self._value
                if self._fix:
                    subprocess.call(["svn", "ps", "svn:eol-style", "CRLF", self._file])
        if name == 'property':
            self._value = ""
            self._property = None
        if name == 'target':
            self._hadEOL = False
            self._hadKeywords = False


optParser = OptionParser()
optParser.add_option("-v", "--verbose", action="store_true",
                     default=False, help="tell me what you are doing")
optParser.add_option("-f", "--fix", action="store_true",
                      default=False, help="fix invalid svn properties")
(options, args) = optParser.parse_args()
seen = set()
sumoRoot = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
svnRoots = [sumoRoot]
if len(args) > 0:
    svnRoots = [os.path.abspath(a) for a in args]
else:
    upDir = os.path.dirname(sumoRoot)
    for l in subprocess.Popen(["svn", "pg", "svn:externals", upDir], stdout=subprocess.PIPE, stderr=open(os.devnull, 'w')).communicate()[0].splitlines():
        if l[:5] == "sumo/":
            svnRoots.append(os.path.join(upDir, l.split()[0]))
for svnRoot in svnRoots:
    if options.verbose:
        print "checking", svnRoot 
    output = subprocess.Popen(["svn", "pl", "-v", "-R", "--xml", svnRoot], stdout=subprocess.PIPE).communicate()[0]
    xml.sax.parseString(output, PropertyReader(options.fix))

if options.verbose:
    print "re-checking tree at", sumoRoot 
for root, dirs, files in os.walk(sumoRoot):
    for name in files:
        fullName = os.path.join(root, name)
        if fullName in seen or subprocess.call(["svn", "ls", fullName], stdout=open(os.devnull, 'w'), stderr=subprocess.STDOUT):
            continue
        ext = os.path.splitext(name)[1]
        if ext in _SOURCE_EXT or ext in _TESTDATA_EXT or ext in _VS_EXT:
            print fullName, "svn:eol-style"
            if options.fix:
                if ext in _VS_EXT:
                    subprocess.call(["svn", "ps", "svn:eol-style", "CRLF", fullName])
                else:
                    if os.name == "posix":
                        subprocess.call(["sed", "-i", 's/\r$//', fullName])
                    subprocess.call(["svn", "ps", "svn:eol-style", "LF", fullName])
        if ext in _SOURCE_EXT:
            print fullName, "svn:keywords"
            if options.fix:
                subprocess.call(["svn", "ps", "svn:keywords", _KEYWORDS, fullName])
    for ignoreDir in ['.svn', 'foreign', 'contributed']:
        if ignoreDir in dirs:
            dirs.remove(ignoreDir)