summaryrefslogtreecommitdiff
path: root/pypers/test_re.py
blob: 1839d46c47ef32f4cb4bf75579b7bfc268781f9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
"""This script looks at its own source code and extracts dotted names,
i.e. names containing at least one dot, such as object.attribute or
more general one, such as obj.attr.subattr."""
# Notice that dotted.names in comments and literal strings are ignored
if __name__ == "__main__":
    from oopp import *
    import __main__
    text = inspect.getsource(__main__)
    regexp = Regexp.CODESEP| Regexp.DOTNAME()
    print 'Using the regular expression',regexp
    print "I have found the following dotted names:\n%s" % [
        MO.group() for MO in regexp.finditer(text) if MO.lastgroup=='DOTNAME']