sl@0
|
1 |
# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
# All rights reserved.
|
sl@0
|
3 |
# This component and the accompanying materials are made available
|
sl@0
|
4 |
# under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
# which accompanies this distribution, and is available
|
sl@0
|
6 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
#
|
sl@0
|
8 |
# Initial Contributors:
|
sl@0
|
9 |
# Nokia Corporation - initial contribution.
|
sl@0
|
10 |
#
|
sl@0
|
11 |
# Contributors:
|
sl@0
|
12 |
#
|
sl@0
|
13 |
# Description:
|
sl@0
|
14 |
# Script to filter out components that are not contributed to the foundation for any reason.
|
sl@0
|
15 |
#
|
sl@0
|
16 |
|
sl@0
|
17 |
import re
|
sl@0
|
18 |
import glob
|
sl@0
|
19 |
import sys
|
sl@0
|
20 |
import os
|
sl@0
|
21 |
import shutil
|
sl@0
|
22 |
import stat
|
sl@0
|
23 |
|
sl@0
|
24 |
policyexpression = re.compile(r"^\s*3\s*$")
|
sl@0
|
25 |
|
sl@0
|
26 |
def cleanfolder(folder):
|
sl@0
|
27 |
os.chdir(folder)
|
sl@0
|
28 |
here = os.getcwd()
|
sl@0
|
29 |
if os.path.exists('distribution.policy.s60'):
|
sl@0
|
30 |
f = open('distribution.policy.s60', 'r')
|
sl@0
|
31 |
policy = f.read()
|
sl@0
|
32 |
f.close()
|
sl@0
|
33 |
if not policyexpression.match(policy):
|
sl@0
|
34 |
print 'Deleting ' + os.getcwd() + ' due to policy ' + policy
|
sl@0
|
35 |
for root, dirs, files in os.walk(os.getcwd()):
|
sl@0
|
36 |
for name in files:
|
sl@0
|
37 |
os.chmod(os.path.join(root,name), stat.S_IWRITE)
|
sl@0
|
38 |
os.chdir('\\')
|
sl@0
|
39 |
shutil.rmtree(here)
|
sl@0
|
40 |
return
|
sl@0
|
41 |
for file in glob.glob('*'):
|
sl@0
|
42 |
os.chdir(here)
|
sl@0
|
43 |
if os.path.isdir(file):
|
sl@0
|
44 |
cleanfolder(file)
|
sl@0
|
45 |
|
sl@0
|
46 |
print 'Removing subfolder trees from ' + sys.argv[1] + ' with a distribution.policy.s60 entry other than 3'
|
sl@0
|
47 |
|
sl@0
|
48 |
cleanfolder(sys.argv[1]) |