Commit 6ab661e4 authored by Amir MOHAMMADI's avatar Amir MOHAMMADI

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

parent 17bd4f1e
Pipeline #14384 skipped
[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()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment