Project

General

Profile

1
#!/usr/bin/env python
2
# Expands XPath abbreviations
3
# Filters one XPath per line from stdin to stdout
4

    
5
import re
6
import sys
7

    
8
def main():
9
    while True:
10
        line = sys.stdin.readline()
11
        if line == '': break
12
        # Forward * abbrs
13
        line = re.sub(r'\*(?=\w*(?:->/[^/]*)?/(\w+))', r'\1', line)
14
        # Backward * abbrs
15
        line = re.sub(r'((\w+)->/[^/]*/[^/]*\[)\*', r'\1\2', line)
16
        sys.stdout.write(line)
17

    
18
main()
(13-13/45)