mirror of
https://github.com/LCPQ/quantum_package
synced 2024-06-29 16:34:50 +02:00
It will be not that hard to implement module repositories
This commit is contained in:
parent
8c5c1069e0
commit
e11998adcf
|
@ -61,7 +61,7 @@ def get_dict_child(l_root_abs=None):
|
||||||
return d_ref
|
return d_ref
|
||||||
|
|
||||||
|
|
||||||
def l_module_descendant(d_child, l_module):
|
def get_l_module_descendant(d_child, l_module):
|
||||||
"""
|
"""
|
||||||
From a list of module return the module and descendant
|
From a list of module return the module and descendant
|
||||||
"""
|
"""
|
||||||
|
@ -71,7 +71,7 @@ def l_module_descendant(d_child, l_module):
|
||||||
if module not in l:
|
if module not in l:
|
||||||
l.append(module)
|
l.append(module)
|
||||||
try:
|
try:
|
||||||
l.extend(l_module_descendant(d_child, d_child[module]))
|
l.extend(get_l_module_descendant(d_child, d_child[module]))
|
||||||
except KeyError:
|
except KeyError:
|
||||||
print >> sys.stderr, "`{0}` not submodule".format(module)
|
print >> sys.stderr, "`{0}` not submodule".format(module)
|
||||||
print >> sys.stderr, "Check the corresponding NEEDED_CHILDREN_MODULES"
|
print >> sys.stderr, "Check the corresponding NEEDED_CHILDREN_MODULES"
|
||||||
|
@ -113,8 +113,8 @@ class ModuleHandler():
|
||||||
d_child = self.dict_child
|
d_child = self.dict_child
|
||||||
|
|
||||||
for module_name in d_child:
|
for module_name in d_child:
|
||||||
d[module_name] = l_module_descendant(d_child,
|
d[module_name] = get_l_module_descendant(d_child,
|
||||||
d_child[module_name])
|
d_child[module_name])
|
||||||
|
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,15 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
"""
|
"""
|
||||||
Usage: qp_install_module.py list
|
Usage: qp_install_module.py list [--installed|--avalaible-local|--avalaible-remote]
|
||||||
|
qp_install_module.py install -n <name>
|
||||||
qp_install_module.py create -n <name> [<children_module>...]
|
qp_install_module.py create -n <name> [<children_module>...]
|
||||||
|
qp_install_module.py download -n <name> [<path_folder>...]
|
||||||
|
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
list: List all the module avalaible
|
list: List all the module avalaible
|
||||||
create: Create a new module
|
create: Create a new module
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
@ -15,6 +18,7 @@ import os
|
||||||
try:
|
try:
|
||||||
from docopt import docopt
|
from docopt import docopt
|
||||||
from module_handler import ModuleHandler, get_dict_child
|
from module_handler import ModuleHandler, get_dict_child
|
||||||
|
from module_handler import get_l_module_descendant
|
||||||
from update_README import Doc_key, Needed_key
|
from update_README import Doc_key, Needed_key
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print "source .quantum_package.rc"
|
print "source .quantum_package.rc"
|
||||||
|
@ -53,17 +57,26 @@ def save_new_module(path, l_child):
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
arguments = docopt(__doc__)
|
arguments = docopt(__doc__)
|
||||||
|
qp_root_src = os.path.join(os.environ['QP_ROOT'], "src")
|
||||||
|
qp_root_plugin = os.path.join(os.environ['QP_ROOT'], "plugins")
|
||||||
|
|
||||||
m_instance = ModuleHandler()
|
|
||||||
if arguments["list"]:
|
if arguments["list"]:
|
||||||
|
|
||||||
|
if arguments["--installed"]:
|
||||||
|
l_repository = [qp_root_src]
|
||||||
|
|
||||||
|
m_instance = ModuleHandler(l_repository)
|
||||||
|
|
||||||
for module in m_instance.l_module:
|
for module in m_instance.l_module:
|
||||||
print module
|
print module
|
||||||
|
|
||||||
elif arguments["create"]:
|
elif arguments["create"]:
|
||||||
|
m_instance = ModuleHandler(l_repository)
|
||||||
|
|
||||||
l_children = arguments["<children_module>"]
|
l_children = arguments["<children_module>"]
|
||||||
|
|
||||||
qpackage_root = os.environ['QP_ROOT']
|
qp_root = os.environ['QP_ROOT']
|
||||||
path = os.path.join(qpackage_root, "src", arguments["<name>"])
|
path = os.path.join(qp_root_src, arguments["<name>"])
|
||||||
|
|
||||||
print "You will create the module:"
|
print "You will create the module:"
|
||||||
print path
|
print path
|
||||||
|
@ -85,3 +98,35 @@ if __name__ == '__main__':
|
||||||
l_child_reduce = m_instance.l_reduce_tree(l_children)
|
l_child_reduce = m_instance.l_reduce_tree(l_children)
|
||||||
print l_child_reduce
|
print l_child_reduce
|
||||||
save_new_module(path, l_child_reduce)
|
save_new_module(path, l_child_reduce)
|
||||||
|
|
||||||
|
elif arguments["download"]:
|
||||||
|
|
||||||
|
d_local = get_dict_child([qp_root_src])
|
||||||
|
d_remote = get_dict_child(arguments["<path_folder>"])
|
||||||
|
|
||||||
|
d_child = d_local.copy()
|
||||||
|
d_child.update(d_remote)
|
||||||
|
|
||||||
|
name = arguments["<name>"]
|
||||||
|
l_module_descendant = get_l_module_descendant(d_child, [name])
|
||||||
|
|
||||||
|
for module in l_module_descendant:
|
||||||
|
if module not in d_local:
|
||||||
|
print "you need to install", module
|
||||||
|
|
||||||
|
elif arguments["install"]:
|
||||||
|
|
||||||
|
d_local = get_dict_child([qp_root_src])
|
||||||
|
|
||||||
|
d_plugin = get_dict_child([qp_root_plugin])
|
||||||
|
|
||||||
|
d_child = d_local.copy()
|
||||||
|
d_child.update(d_plugin)
|
||||||
|
|
||||||
|
name = arguments["<name>"]
|
||||||
|
l_module_descendant = get_l_module_descendant(d_child, [name])
|
||||||
|
|
||||||
|
module_to_cp = [module for module in l_module_descendant if module not in d_local]
|
||||||
|
|
||||||
|
print "For ln -s by hand the module"
|
||||||
|
print module_to_cp
|
||||||
|
|
Loading…
Reference in New Issue
Block a user