diff options
author | Sérgio Almeida <mephx.x@gmail.com> | 2009-07-27 18:28:46 +0100 |
---|---|---|
committer | Sérgio Almeida <mephx.x@gmail.com> | 2009-07-27 18:28:46 +0100 |
commit | 2ce51ba0fb303c4c1953559963255125805aefce (patch) | |
tree | fb4ed329765bdbd6ad87b5d4364e6b268babbcfa /modules | |
parent | Changed modules to plain python (diff) | |
download | uselect-2ce51ba0fb303c4c1953559963255125805aefce.tar.gz uselect-2ce51ba0fb303c4c1953559963255125805aefce.tar.bz2 uselect-2ce51ba0fb303c4c1953559963255125805aefce.zip |
Lacked -a on last commit
Diffstat (limited to 'modules')
-rw-r--r-- | modules/gcc.py | 4 | ||||
-rw-r--r-- | modules/python.py | 53 |
2 files changed, 51 insertions, 6 deletions
diff --git a/modules/gcc.py b/modules/gcc.py index ece02f4..fc18cb8 100644 --- a/modules/gcc.py +++ b/modules/gcc.py @@ -9,9 +9,9 @@ module = Module(name = "gcc", description = "Python GCC Version Switcher", versi bin = Action (name = 'bin', description = "Change GCC's Version", type = "sym") # Define a Symlinking Action gcc = Link(alias = "gcc", target = "/usr/bin/gcc", prefix = "/usr/bin/", regexp = "gcc-([0-9]+\.[0-9]+$)") -gcc_config = Link(alias = "gcc-config", target = "/usr/bin/gcc-config", prefix = "/usr/bin/", regexp = "gcc-config([0-9]+\.[0-9]+$)") +#gcc_config = Link(alias = "gcc-config", target = "/usr/bin/gcc-config", prefix = "/usr/bin/", regexp = "gcc-config([0-9]+\.[0-9]+$)") -gcc.add_link(gcc_config) # For inheritance +#gcc.add_link(gcc_config) # For inheritance testing bin.add_link(gcc) # Adding The Link to the action module.add_action(bin) #Adding the action to the module diff --git a/modules/python.py b/modules/python.py index e6115fc..c850505 100644 --- a/modules/python.py +++ b/modules/python.py @@ -6,15 +6,60 @@ from umodule import * module = Module(name = "python", description = "Python Version Switcher", version = "0.1", author ="mephx.x@gmail.com") # We define the module -bin = Action (name = 'bin', description = "Change Python's Version", type = "sym") # Define a Symlinking Action + +bin = Action (name = 'bin', description = "Change Python's Version", type = "sym") # Define a Symlinking Action python = Link(alias = "python", target = "/usr/bin/python", prefix = "/usr/bin/", regexp = "python([0-9]+\.[0-9]+$)") python_config = Link(alias = "python-config", target = "/usr/bin/python-config", prefix = "/usr/bin/", regexp = "python([0-9]+\.[0-9]+)-config$") -python_config2 = Link(alias = "python-config", target = "/usr/bin/python-config", prefix = "/usr/bin/", regexp = "python([0-9]+\.[0-9]+)-config$") - python.add_link(python_config) # For inheritance -#python_config.add_link(python_config2) # For further inheritance test bin.add_link(python) # Adding The Link to the action + module.add_action(bin) #Adding the action to the module +test = Action (name = 'test', description = 'Test Python Environment', type = 'runnable') + +test.add_parameter('<times>') +test.add_parameter('[<what>]') # optional notation + +test.add_usage("""#!/usr/bin/python +print "Python Test will echo <times> * <what>" +print "Usage can be multi-line Yay!" +print "" +for i in range(5): + print "Usage can have dynamic options! " + str(i) +""") + +test.add_code("""#!/usr/bin/python +import sys + +def is_number(s): + try: + int(s) + return True + except ValueError: + return False + +argv = sys.argv[1:] +times = sys.argv[1:][0] +if is_number(times): + times = int(times) + if len(argv) >= 2: + what = sys.argv[1:][1] + else: + what = 'Hello World...' + print str(what) * times +else: + print 'Invalid Option(s)' + exit(1) +exit(0) +""") + + +module.add_action(test) + +env = Action (name = 'env', description = 'Some env test', type = 'env') +path_var = env.get_var(name = 'PATH') + +path_var.add_value(value = '~/.uselect/bin/') +module.add_action(env) |