diff options
-rw-r--r-- | uio.py | 9 | ||||
-rw-r--r-- | umodule.py | 26 | ||||
-rwxr-xr-x | uselect.py | 6 |
3 files changed, 22 insertions, 19 deletions
@@ -20,6 +20,7 @@ bold = lime = red = reset = yellow = notice = '' error = warning = bullet = ok = highlight = '' verbose = False + class Counter: def __init__(self): @@ -31,6 +32,7 @@ class FileSystem: def __init__(self): """ FileSystem Contructor """ self.home = os.getenv('HOME') + self.set_global = False self.uid = pwd.getpwuid(os.getuid())[0] self.environment = self.home + '/.uselect/' @@ -309,10 +311,13 @@ class PrintSystem: def print_options(self): self.print_line(highlight + space + 'Options:' + reset) - self.print_table([ \ + table = [\ [bold + '-v', bullet + space + 'Verbose Mode'], \ [bold + '-nc', bullet + space + 'No Colors'], \ - [bold + '-version', bullet + space + 'Version Information']]) + [bold + '-version', bullet + space + 'Version Information']] + if filesystem.uid == 'root': + table.append([bold + '-global', bullet + space + 'Set Globally']) + self.print_table(table) class ProfilePrintSystem(PrintSystem): @@ -13,9 +13,6 @@ from uio import Counter from uio import filesystem from uio import printsystem - - - modules_dir = '/usr/share/uselect/modules/' class Action: @@ -34,10 +31,10 @@ class Action: elif type == 'env': self.__class__ = Env elif type == 'sym': - if filesystem.uid != 'root': - self.__class__ = Path - else: + if filesystem.set_global: self.__class__ = Sym + else: + self.__class__ = Path elif type == 'profile': self.__class__ = ProfileAction else: @@ -268,16 +265,15 @@ class Sym(Action): """ i = target[2] link = target[1] - if clear: - filesystem.delete_file(link.destination) - self.output.append('Unsetting ' + link.destination\ - + ' success!') + if link.target == None: + target = link.targets[i].split('/').pop() else: - - filesystem.create_symlink(link.targets[i], \ - link.destination) - self.output.append('Setting ' + link.targets[i]\ - + ' success!') + target = link.target + filesystem.create_symlink(link.targets[i], \ + '/' + link.target_dir + target) + + self.output.append('Setting ' + link.targets[i]\ + + ' success!') def add_link(self, link = None): """ @@ -43,8 +43,7 @@ class UniversalSelectTool: __import__(modpath) module = eval(modpath + '.module') self.modules.append(module) - - + def get_module(self, name): import modules modname = name @@ -64,6 +63,9 @@ class UniversalSelectTool: verbose = True printsystem.verbose() args = args[1:] + elif arg == '-global': + filesystem.set_global = True + args = args[1:] elif arg == '-nc': printsystem.use_colors(False) args = args[1:] |