diff options
Diffstat (limited to 'uprofile.py')
-rwxr-xr-x | uprofile.py | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/uprofile.py b/uprofile.py index cd613f2..5c6e68b 100755 --- a/uprofile.py +++ b/uprofile.py @@ -9,7 +9,7 @@ import os import re import sys import stat -import string +import json import traceback from umodule import * @@ -22,21 +22,30 @@ printsystem.set_type('profile') class Profile(Module): - def __init__(self, name): - self.name = name - self.author = 'unnamed' - self.version = '0.1' - self.description = 'Empty' - + def __init__(self, path): self.actions = [] + self.parameters = [] + self.output = [] + + str = '' + for line in filesystem.read_file('.uprofile/' + path): + str += line + + profile = json.loads(str) + + self.profile = profile + + self.name = path[:-5] + self.author = profile['profile']['author'] + self.version = profile['profile']['version'] + self.description = profile['profile']['description'] + self.actions.append(Action(name = 'set', \ description = 'Set this profile for this folder.', \ type = 'profile')) self.actions.append(Action(name = 'default', \ description = 'Set this profile the default profile.', \ type = 'profile')) - self.parameters = [] - self.output = [] class UniversalProfileTool: @@ -46,13 +55,14 @@ class UniversalProfileTool: return def get_profile(self, name): - profile = Profile(name) + profile = Profile(name + '.json') return profile def get_profiles(self): """ Returns the list of available uprofiles """ for profile in filesystem.list_dir('.uprofile/'): - self.profiles.append(Profile(profile)) + if re.match('.*.json$', profile): + self.profiles.append(Profile(profile)) return def parse_argv(self, args): |