/
easyblocks_setup.py
58 lines (49 loc) · 1.8 KB
/
easyblocks_setup.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
##
# Copyright 2009-2012 Stijn Deweirdt, Dries Verdegem, Kenneth Hoste, Pieter De Baets, Jens Timmerman
#
# This file is part of EasyBuild,
# originally created by the HPC team of the University of Ghent (http://ugent.be/hpc).
#
# http://github.com/hpcugent/easybuild
#
# EasyBuild is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation v2.
#
# EasyBuild is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with EasyBuild. If not, see <http://www.gnu.org/licenses/>.
##
"""
This script creates the directory structure used by easybuild (https://github.com/easybuild/easybuild)
You can use this to set up your private easyblocks directory
usage: easyblockssetup.py [easyblocks_privatename]
you might want to put this directory under revision control
"""
import os
import sys
if len(sys.argv) > 2:
sys.stderr.write("Usage: %s [prefix]\n" % sys.argv[0])
PREFIX = "easyblocks"
if len(sys.argv) == 2:
PREFIX = sys.argv[1]
# create root dir, with default init
os.mkdir(PREFIX)
f = open(os.path.join(PREFIX, "__init__.py"), 'w')
f.write("""import pkg_resources
pkg_resources.declare_namespace("%s")
""" % os.path.basename(PREFIX))
# create subdirectories Aa, Bb, ..., Zz, 0-9, _other_
def createDir(dirName):
os.mkdir(os.path.join(PREFIX, dirName))
fh = open(os.path.join(PREFIX, dirName, "__init__.py"), 'w')
fh.close()
alphabet = [chr(x) for x in xrange(ord('a'), ord('z') + 1)]
for letter in alphabet:
createDir(letter)
createDir("0-9")
createDir("_other_")