Skip to content
Snippets Groups Projects
Commit f93cdf2b authored by Tiago de Freitas Pereira's avatar Tiago de Freitas Pereira
Browse files

Merge branch 'buildout' into 'master'

Adds a script to generate a buildout file automatically based on core.txt and extra.txt [skip ci]

See merge request !24
parents 17bd4f1e 6ab661e4
No related branches found
No related tags found
1 merge request!24Adds a script to generate a buildout file automatically based on core.txt and extra.txt [skip ci]
Pipeline #
[buildout]
parts = scripts
extensions = bob.buildout
mr.developer
auto-checkout = *
debug = true
newest = false
verbose = true
eggs = {eggs}
develop = {develop}
[scripts]
recipe = bob.buildout:scripts
dependent-scripts = true
[sources]
{sources}
#!/usr/bin/env python
"""Generates a buildout configuration file based on the list of the packages
Usage:
%(prog)s <package_list>...
%(prog)s --help
Arguments:
<package_list> The files containing the package list. Each line should
contain only the name of one package. Empty lines and
comments starting with # are allowed.
Options:
-h --help Show this help message and exit
"""
def format_list(package_list, prepend, left_fill):
text = prepend + package_list[0] + '\n'
package_list = package_list[1:]
for pkg in package_list:
text += ' ' * left_fill + prepend + pkg + '\n'
return text
def main(argv=None):
from docopt import docopt
import sys
import os
docs = __doc__ % {'prog': os.path.basename(sys.argv[0])}
args = docopt(docs, argv=argv)
package_list_files = args['<package_list>']
package_list = []
for path in package_list_files:
for line in open(path):
line = line.partition('#')[0].strip()
if not line:
continue
package_list.append(line)
print(package_list)
# read the buildout config template
with open("buildout.cfg.template") as f:
template = f.read()
# eggs
eggs = format_list(package_list, '', 7)
develop = format_list(package_list, 'src/', 10)
source_list = ['{0} = git git@gitlab.idiap.ch:bob/{0}'.format(p)
for p in package_list]
sources = format_list(source_list, '', 0)
with open('buildout.cfg', 'wt') as f:
f.write(template.format(eggs=eggs, develop=develop, sources=sources))
if __name__ == '__main__':
main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment