72
|
1 |
#!/usr/bin/python
|
|
2 |
#
|
|
3 |
# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
4 |
# All rights reserved.
|
|
5 |
# This component and the accompanying materials are made available
|
|
6 |
# under the terms of "Eclipse Public License v1.0"
|
|
7 |
# which accompanies this distribution, and is available
|
|
8 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
9 |
#
|
|
10 |
# Initial Contributors:
|
|
11 |
# Nokia Corporation - initial contribution.
|
|
12 |
#
|
|
13 |
# Contributors:
|
|
14 |
#
|
|
15 |
# Description:
|
|
16 |
# Checks for empty directories (ignoring .svn directories) recursively
|
|
17 |
# starting from the given path. This check is done because Mercurial does
|
|
18 |
# not support empty directories.
|
|
19 |
|
|
20 |
import sys, os, re
|
|
21 |
|
|
22 |
def main():
|
|
23 |
|
|
24 |
def visitFun(arg, dirname, names):
|
|
25 |
|
|
26 |
# Skip SVN directories
|
80
|
27 |
if dirname.endswith(".svn"):
|
|
28 |
names[:] = []
|
72
|
29 |
return
|
|
30 |
|
|
31 |
# Check if the directory is empty (except for the .svn subdirectory)
|
|
32 |
if len(names) == 0 or (len(names) == 1 and names[0] == ".svn"):
|
|
33 |
print dirname
|
|
34 |
|
|
35 |
root = sys.argv[1]
|
|
36 |
os.path.walk(root, visitFun, None)
|
|
37 |
|
|
38 |
|
|
39 |
if __name__ == "__main__":
|
|
40 |
main()
|