summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--uio.py21
-rw-r--r--umodule.py7
-rwxr-xr-xuprofile.py19
3 files changed, 30 insertions, 17 deletions
diff --git a/uio.py b/uio.py
index d99d958..610ebca 100644
--- a/uio.py
+++ b/uio.py
@@ -272,7 +272,7 @@ class PrintSystem:
self.print_table([[bold + action.name + reset, \
action.description]])
- def print_action(self, module, action):
+ def print_action(self, action):
self.print_table([[bold + action.description + reset, '']])
self.print_line('')
self.print_table(self.format_action(action))
@@ -312,18 +312,24 @@ class ProfilePrintSystem(PrintSystem):
def print_ui(self, profile = None, profiles = None, args = None, \
action = None):
- self.print_usage(profile = profile, action = action)
- self.print_line('')
+
if profile == None:
+ self.print_usage(profile = profile, action = action)
+ self.print_line('')
self.print_options()
self.print_line('')
self.print_profiles(profiles)
self.print_line('')
- elif profiles == None:
+ elif profiles == None and action == None:
+ self.print_usage(profile = profile, action = action)
+ self.print_line('')
self.print_profile(profile)
self.print_line('')
self.print_actions(profile)
self.print_line('')
+ else:
+ for line in action.output:
+ print line
def print_profiles(self, profiles):
self.print_line(highlight + space + 'Profiles:' + reset)
@@ -338,13 +344,6 @@ class ProfilePrintSystem(PrintSystem):
self.print_line(space * 4 + bold + 'Author:' + reset + space + \
profile.author + space + bold + 'Version:' + reset + space \
+ profile.version)
-
-
-
- def print_action(self, module, action):
- self.print_table([[bold + action.description + reset, '']])
- self.print_line('')
- self.print_table(self.format_action(action))
def print_version(self, version):
self.print_line(bold + 'Universal Profile Tool - ' \
diff --git a/umodule.py b/umodule.py
index 567e7fb..3ce2887 100644
--- a/umodule.py
+++ b/umodule.py
@@ -302,7 +302,12 @@ class Var():
class ProfileAction(Action):
def do_action(self, args):
- print 'Done!'
+ if args[0] == 'set':
+ self.output.append('Folder Profile set!')
+ elif args[0] == 'default':
+ self.output.append('Default Profile set!')
+ def build(self):
+ self.parameters = []
def setup(self):
return
diff --git a/uprofile.py b/uprofile.py
index 3945ebf..cd613f2 100755
--- a/uprofile.py
+++ b/uprofile.py
@@ -20,13 +20,14 @@ from uio import printsystem
verbose = False
printsystem.set_type('profile')
-class Profile:
+class Profile(Module):
def __init__(self, name):
self.name = name
self.author = 'unnamed'
self.version = '0.1'
self.description = 'Empty'
+
self.actions = []
self.actions.append(Action(name = 'set', \
description = 'Set this profile for this folder.', \
@@ -34,8 +35,10 @@ class Profile:
self.actions.append(Action(name = 'default', \
description = 'Set this profile the default profile.', \
type = 'profile'))
- return
+ self.parameters = []
+ self.output = []
+
class UniversalProfileTool:
def __init__(self):
@@ -56,6 +59,7 @@ class UniversalProfileTool:
global verbose, version
profile = None
profiles = None
+ action = None
printsystem.use_colors(True)
for arg in args:
if arg == '-v':
@@ -65,18 +69,23 @@ class UniversalProfileTool:
elif arg == '-nc':
printsystem.use_colors(False)
args = args[1:]
-
+
if len(args) < 1:
self.get_profiles()
profiles = self.profiles
elif len(args) == 1:
profile = self.get_profile(args[0])
+ elif len(args) == 2:
+ profile = self.get_profile(args[0])
+ action = profile.get_action(args[1])
+ action.build()
+ action.do_action(args[1:])
if len(args) == 2:
args = None
else:
args = args[2:]
- return [profile, profiles, args]
+ return [profile, profiles, args, action]
def main():
@@ -85,7 +94,7 @@ def main():
list = uprofile.parse_argv(sys.argv[1:])
printsystem.print_ui(profile = list[0], \
- profiles = list[1], args = list[2])
+ profiles = list[1], action = list[3], args = list[2])
except UserWarning, warning:
printsystem.print_exception(warning, True)