File: detect_self_assignment.py

package info (click to toggle)
gdal 3.12.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 92,396 kB
  • sloc: cpp: 1,224,305; ansic: 206,456; python: 26,284; java: 6,001; xml: 4,769; sh: 3,869; cs: 2,513; yacc: 1,306; makefile: 214
file content (25 lines) | stat: -rwxr-xr-x 549 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
25
#!/usr/bin/python

import sys

f = open(sys.argv[1], "rt")
lines = f.readlines()
ret = 0
for i, line in enumerate(lines):
    if line and line[len(line) - 1] == "\n":
        line = line[0:-1]
    tab = line.split("=")
    if len(tab) != 2:
        continue
    left = tab[0].strip()
    right = tab[1].strip()
    if right and right[len(right) - 1] == ";":
        right = right[0:-1]
    else:
        continue
    right = right.strip()
    if left == right:
        print("%s: %d: %s" % (sys.argv[1], i + 1, line))
        ret = 1

sys.exit(ret)