File: example_exec.py

package info (click to toggle)
pyutilib 6.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 4,924 kB
  • sloc: python: 18,448; xml: 135; perl: 75; makefile: 50; sh: 32
file content (24 lines) | stat: -rw-r--r-- 670 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import os

def strip_example(file):
    base, name = os.path.split(file)
    prefix = os.path.splitext(name)[0]
    if prefix.endswith('_strip'):
        return
    print "STRIPPING",file
    OUTPUT = open(base+'/'+prefix+'_strip.py','w')
    INPUT = open(file,'r')
    for line in INPUT:
        if line[0] == '#' and '@' in line:
            continue
        print >>OUTPUT, line,
    INPUT.close()
    OUTPUT.close()


for root, dirs, files in os.walk(os.path.abspath(os.path.dirname(__file__)), topdown=True):
    for name in files:
        if name == 'example_exec.py':
            continue
        if name.endswith('.py'):
            strip_example(root+'/'+name)