10
0
mirror of https://github.com/LCPQ/quantum_package synced 2024-07-22 18:57:31 +02:00

And remove ancestor

This commit is contained in:
Thomas Applencourt 2015-06-23 10:04:59 +02:00
parent 1b53c55a1c
commit a0407bf89f
4 changed files with 39 additions and 27 deletions

View File

@ -18,9 +18,8 @@ p = re.compile(ur'-I IRPF90_temp/\S*\s+')
mod = re.compile(ur'module\s+(?P<mod>\S+).+end\s?module\s+(?P=mod)?', mod = re.compile(ur'module\s+(?P<mod>\S+).+end\s?module\s+(?P=mod)?',
re.MULTILINE | re.IGNORECASE) re.MULTILINE | re.IGNORECASE)
tmpdir_root = os.environ.get("TMPDIR",failobj="/dev/shm") tmpdir_root = os.environ.get("TMPDIR", failobj="/dev/shm")
TMPDIR = os.path.join(tmpdir_root,os.environ["USER"],"qp_compiler") TMPDIR = os.path.join(tmpdir_root, os.environ["USER"], "qp_compiler")
def return_filename_to_cache(command): def return_filename_to_cache(command):

View File

@ -19,10 +19,10 @@ Options:
import os import os
import sys import sys
import os.path import os.path
from collections import namedtuple
try: try:
from docopt import docopt from docopt import docopt
from qp_path import QP_SRC
except ImportError: except ImportError:
print "source .quantum_package.rc" print "source .quantum_package.rc"
raise raise
@ -36,8 +36,7 @@ def get_dict_child(l_root_abs=None):
d_ref = dict() d_ref = dict()
if not l_root_abs: if not l_root_abs:
qp_root = os.environ['QP_ROOT'] l_root_abs = [QP_SRC]
l_root_abs = [os.path.join(qp_root, 'src')]
for root_abs in l_root_abs: for root_abs in l_root_abs:
for module_rel in os.listdir(root_abs): for module_rel in os.listdir(root_abs):

View File

@ -5,8 +5,8 @@ Usage:
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>...] qp_install_module.py download -n <name> [<path_folder>...]
qp_install_module.py install <name>... qp_install_module.py install <name>...
qp_install_module.py list (--installed|--avalaible-local|--avalaible-remote) qp_install_module.py list (--installed|--avalaible-local)
qp_install_module.py uninstall <name>... qp_install_module.py uninstall <name>... [--and_ancestor]
Options: Options:
@ -22,6 +22,8 @@ try:
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 module_handler import get_l_module_descendant
from update_README import Doc_key, Needed_key from update_README import Doc_key, Needed_key
from qp_path import QP_ROOT, QP_SRC, QP_PLUGINS
except ImportError: except ImportError:
print "source .quantum_package.rc" print "source .quantum_package.rc"
raise raise
@ -59,15 +61,13 @@ 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")
if arguments["list"]: if arguments["list"]:
if arguments["--installed"]: if arguments["--installed"]:
l_repository = [qp_root_src] l_repository = [QP_SRC]
if arguments["--avalaible-local"]: elif arguments["--avalaible-local"]:
l_repository = [qp_root_plugin] l_repository = [QP_PLUGINS]
m_instance = ModuleHandler(l_repository) m_instance = ModuleHandler(l_repository)
@ -75,11 +75,11 @@ if __name__ == '__main__':
print "* {0}".format(module) print "* {0}".format(module)
elif arguments["create"]: elif arguments["create"]:
m_instance = ModuleHandler([qp_root_src]) m_instance = ModuleHandler([QP_SRC])
l_children = arguments["<children_module>"] l_children = arguments["<children_module>"]
path = os.path.join(qp_root_src, arguments["<name>"]) path = os.path.join(QP_SRC, arguments["<name>"])
print "You will create the module:" print "You will create the module:"
print path print path
@ -88,6 +88,7 @@ if __name__ == '__main__':
if children not in m_instance.dict_descendant: if children not in m_instance.dict_descendant:
print "This module ({0}) is not a valide module.".format(children) print "This module ({0}) is not a valide module.".format(children)
print "Run `list` flag for the list of module avalaible" print "Run `list` flag for the list of module avalaible"
print "Maybe you need to install some module first"
print "Aborting..." print "Aborting..."
sys.exit(1) sys.exit(1)
@ -104,7 +105,7 @@ if __name__ == '__main__':
elif arguments["download"]: elif arguments["download"]:
pass pass
# d_local = get_dict_child([qp_root_src]) # d_local = get_dict_child([QP_SRC])
# d_remote = get_dict_child(arguments["<path_folder>"]) # d_remote = get_dict_child(arguments["<path_folder>"])
# #
# d_child = d_local.copy() # d_child = d_local.copy()
@ -119,8 +120,8 @@ if __name__ == '__main__':
elif arguments["install"]: elif arguments["install"]:
d_local = get_dict_child([qp_root_src]) d_local = get_dict_child([QP_SRC])
d_plugin = get_dict_child([qp_root_plugin]) d_plugin = get_dict_child([QP_PLUGINS])
d_child = d_local.copy() d_child = d_local.copy()
d_child.update(d_plugin) d_child.update(d_plugin)
@ -143,31 +144,43 @@ if __name__ == '__main__':
print "Installation...", print "Installation...",
for module_to_cp in l_module_to_cp: for module_to_cp in l_module_to_cp:
src = os.path.join(qp_root_plugin, module_to_cp) src = os.path.join(QP_PLUGINS, module_to_cp)
des = os.path.join(qp_root_src, module_to_cp) des = os.path.join(QP_SRC, module_to_cp)
try: try:
os.symlink(src, des) os.symlink(src, des)
except OSError: except OSError:
print "Your src directory is broken. Please remove %s"%des print "Your src directory is broken. Please remove %s" % des
raise raise
print "Done" print "Done"
print "You can now compile as usual" print "You can now compile as usual"
elif arguments["uninstall"]: elif arguments["uninstall"]:
d_local = get_dict_child([qp_root_src]) m_instance = ModuleHandler([QP_SRC])
d_descendant = m_instance.dict_descendant
d_local = get_dict_child([QP_SRC])
l_name = arguments["<name>"] l_name = arguments["<name>"]
l_failed = [ name for name in l_name if name not in d_local ] l_failed = [name for name in l_name if name not in d_local]
if l_failed: if l_failed:
print "Modules not installed:" print "Modules not installed:"
for name in sorted(l_failed): for name in sorted(l_failed):
print "* %s"%name print "* %s" % name
sys.exit(1) sys.exit(1)
else: else:
if arguments["--and_ancestor"]:
l_name_to_remove = l_name + [module for module in m_instance.l_module for name in l_name if name in d_descendant[module]]
print "You will remove all of:"
print l_name_to_remove
else:
l_name_to_remove = l_name
def unlink(x): def unlink(x):
try: try:
os.unlink(os.path.join(qp_root_src,x)) os.unlink(os.path.join(QP_SRC, x))
except OSError: except OSError:
print "%s is a core module which can not be renmoved"%x print "%s is a core module which can not be renmoved" % x
map(unlink,l_name) map(unlink, l_name_to_remove)

View File

@ -11,5 +11,6 @@ except:
sys.exit(1) sys.exit(1)
else: else:
QP_SRC = os.path.join(QP_ROOT, "src") QP_SRC = os.path.join(QP_ROOT, "src")
QP_PLUGINS = os.path.join(QP_ROOT, "plugins")
QP_EZFIO = os.path.join(QP_ROOT, "install", "EZFIO") QP_EZFIO = os.path.join(QP_ROOT, "install", "EZFIO")
QP_OCAML = os.path.join(QP_ROOT, "ocaml") QP_OCAML = os.path.join(QP_ROOT, "ocaml")