~ubuntu-branches/ubuntu/raring/wxwidgets2.8/raring

« back to all changes in this revision

Viewing changes to wxPython/wx/tools/Editra/plugins/codebrowser/codebrowser/gentag/tcltags.py

  • Committer: Package Import Robot
  • Author(s): Stéphane Graber
  • Date: 2012-01-07 13:59:25 UTC
  • mfrom: (1.1.9) (5.1.10 sid)
  • Revision ID: package-import@ubuntu.com-20120107135925-2601miy9ullcon9j
Tags: 2.8.12.1-6ubuntu1
* Resync from Debian, changes that were kept:
  - debian/rules: re-enable mediactrl. This allows libwx_gtk2u_media-2.8 to be
    built, as this is required by some applications (LP: #632984)
  - debian/control: Build-dep on libxt-dev for mediactrl.
  - Patches
    + fix-bashism-in-example
* Add conflict on python-wxgtk2.8 (<< 2.8.12.1-6ubuntu1~) to python-wxversion
  to guarantee upgrade ordering when moving from pycentral to dh_python2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
"""
18
18
 
19
19
__author__ = "Cody Precord <cprecord@editra.org>"
20
 
__svnid__ = "$Id: tcltags.py 56505 2008-10-25 03:04:13Z CJP $"
21
 
__revision__ = "$Revision: 56505 $"
 
20
__svnid__ = "$Id: tcltags.py 64494 2010-06-05 22:03:14Z CJP $"
 
21
__revision__ = "$Revision: 64494 $"
22
22
 
23
23
#--------------------------------------------------------------------------#
24
24
# Dependancies
34
34
    """
35
35
    rtags = taglib.DocStruct()
36
36
    rtags.SetElementDescription('procedure', "Procedure Definitions")
 
37
    rtags.SetElementDescription('class', "SNIT")
 
38
 
 
39
    # Scope tracking for SNIT blocks
 
40
    insnit = False
 
41
    cursnit = None
 
42
    openparens = 0
37
43
 
38
44
    for lnum, line in enumerate(buff):
39
45
        line = line.strip()
42
48
        if line.startswith(u"#") or not line:
43
49
            continue
44
50
 
 
51
        if insnit and cursnit is not None:
 
52
            if parselib.IsToken(line, 0, u'method') or \
 
53
               parselib.IsToken(line, 0, u'typemethod'):
 
54
                parts = line.split()
 
55
                if len(parts) > 1:
 
56
                    name = parts[1]
 
57
                    cursnit.AddMethod(taglib.Method(name, lnum))
 
58
            elif parselib.IsToken(line, 0, u'typevariable') or \
 
59
                 parselib.IsToken(line, 0, u'variable'):
 
60
                parts = line.split()
 
61
                if len(parts) > 1:
 
62
                    name = parts[1]
 
63
                    cursnit.AddVariable(taglib.Variable(name, lnum))
 
64
            elif parselib.IsToken(u'constructor', 0, line) or \
 
65
                 parselib.IsToken(u'destructor', 0, line):
 
66
                 name = parselib.GetFirstIdentifier(line)
 
67
                 cursnit.AddMethod(taglib.Method(name, lnum))
 
68
            elif parselib.IsToken(line, 0, u"package"):
 
69
                 pkg = GetPackage(line, lnum)
 
70
                 if pkg:
 
71
                     cursnit.AddElement('package', pkg)
 
72
 
 
73
            # Update Scope
 
74
            openparens += GetParenCount(line)
 
75
            if openparens == 0:
 
76
                insnit = False
 
77
                cursnit = None
 
78
            continue
 
79
 
45
80
        # Check for Procedure defs
46
81
        if parselib.IsToken(line, 0, u'proc'):
47
82
            parts = line.split()
56
91
                    space_l.AddElement('procedure', taglib.Procedure(spaces[-1], lnum))
57
92
                else:
58
93
                    rtags.AddElement('procedure', taglib.Procedure(parts[1], lnum))
 
94
        elif line.startswith(u'snit::'):
 
95
            parts = line.split()
 
96
            if len(parts) > 1:
 
97
                insnit = True
 
98
                openparens = GetParenCount(line)
 
99
                name = parts[1]
 
100
                cursnit = taglib.Class(name, lnum)
 
101
                rtags.AddClass(cursnit)
 
102
        elif parselib.IsToken(line, 0, u"package"):
 
103
             pkg = GetPackage(line, lnum)
 
104
             if pkg:
 
105
                 rtags.AddElement('package', pkg)
59
106
 
60
107
    return rtags
61
108
 
 
109
 
 
110
# Helper functions
 
111
 
 
112
def GetParenCount(line):
 
113
    """Get the delta of parens on the given line"""
 
114
    openparens = line.count(u"{")
 
115
    openparens -= line.count(u"}")
 
116
    return openparens
 
117
 
 
118
def GetPackage(line, lnum):
 
119
    """Get a package object from the current line
 
120
    @precondition: line has a package def on it
 
121
 
 
122
    """
 
123
    package = None
 
124
    parts = line.split()
 
125
    # package require name version
 
126
    if len(parts) >= 3:
 
127
        name = u" ".join(parts[2:])
 
128
        package = taglib.Package(name, lnum)
 
129
    return package
 
130
 
62
131
#-----------------------------------------------------------------------------#
63
132
# Test
64
133
if __name__ == '__main__':