-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetuptools_dummy.py
executable file
·65 lines (47 loc) · 1.36 KB
/
setuptools_dummy.py
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env python
"""
A hook into setuptools for files not under VCS.
based on setuptools_git
"""
import re
import os
from os.path import join
VERSION = (0, 1, 0, 0)
__version__ = VERSION
__versionstr__ = '.'.join(map(str, VERSION))
# do not include /build/ dir, /.*, *.egg-info dir and py[co] files
EXCLUDE = re.compile(r'(^build|^\.[^/]+|[^/]+\.egg-info|.*.py[co]$)')
def walk(top):
files = []
def _walk(top, dir):
try:
names = os.listdir(top)
except os.error:
return
for name in names:
_name = join(dir, name)
_top = join(top, name)
if os.path.isdir(_top) and not os.path.islink(_top):
_walk(_top, _name)
else:
files.append(_name)
_walk(top, '')
return files
def dummylsfiles(dirname=""):
if not dirname:
dirname = '.'
try:
files = walk(dirname)
except:
# Something went terribly wrong but the setuptools doc says we
# must be strong in the face of danger. We shall not run away
# in panic.
return []
return [f for f in files if not EXCLUDE.match(f)]
if __name__ == "__main__":
import sys
from pprint import pprint
if len(sys.argv) != 2:
print "USAGE: %s DIRNAME" % sys.argv[0]
sys.exit(1)
pprint(dummylsfiles(sys.argv[1]))