File: TclSup.py

package info (click to toggle)
plplot 5.15.0%2Bdfsg2-15
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 31,396 kB
  • sloc: ansic: 79,703; xml: 28,583; cpp: 20,033; ada: 19,456; tcl: 12,081; f90: 11,431; ml: 7,276; java: 6,863; python: 6,792; sh: 3,274; perl: 828; lisp: 75; makefile: 74; sed: 34; fortran: 6
file content (33 lines) | stat: -rw-r--r-- 819 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
26
27
28
29
30
31
32
33
# Tcl Support module.  For coping with Tcl-esque things in Python.

#from regsub import *
import re;

def TclList2Py(s):
    r = []
    if len(s) > 0:
        if s[0] == '{':
            # List elements enclosed in braces.
            j = 0
            itm = ""
            btwn_items = 1
            for i in range(len(s)):
                if btwn_items:
                    if s[i] == '{':
                        itm = ""
                        btwn_items = 0
                        continue

                if s[i] == '}':
                    # Finishing up an item.
                    r.append( itm )
                    btwn_items = 1
                    continue

                itm = itm + s[i]

        else:
            # List elements delimited by spaces
            r = re.split( s, ' ')

    return r