diff options
Diffstat (limited to 'uprofile.py')
-rwxr-xr-x[-rw-r--r--] | uprofile.py | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/uprofile.py b/uprofile.py index e69de29..ad96eed 100644..100755 --- a/uprofile.py +++ b/uprofile.py @@ -0,0 +1,81 @@ +#!/usr/bin/env python +# Copyright 1999-2009 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# Universal Select Tool +# Profiling Tool +# uprofile.py mephx.x@gmail.com + +import os +import re +import sys +import stat +import string +import traceback + +from umodule import * +from uio import * + +class Profile: + + def __init__(self, name): + self.name = name + self.description = 'Empty' + return + +class UniversalProfileTool: + + def __init__(self): + self.profiles = [] + return + + def get_profiles(self): + """ Returns the list of available uprofiles """ + for profile in filesystem.list_dir('.uprofile/'): + self.profiles.append(Profile(profile)) + return + + def parse_argv(self, args): + global verbose, version + profile = None + profiles = None + printsystem.use_colors(True) + for arg in args: + if arg == '-v': + verbose = True + printsystem.verbose() + args = args[1:] + elif arg == '-nc': + printsystem.use_colors(False) + args = args[1:] + + if len(args) < 1: + self.get_profiles() + profiles = self.profiles + + if len(args) == 2: + args = None + else: + args = args[2:] + + return [profile, profiles, args] + + +def main(): + uprofile = UniversalProfileTool() + try: + list = uprofile.parse_argv(sys.argv[1:]) + + printsystem.print_uprofile_ui(profile = list[0], \ + profiles = list[1], args = list[2]) + + except UserWarning, warning: + printsystem.print_exception(warning, True) + except Exception, exception: + printsystem.print_exception(exception) + if not verbose: + traceback.print_exc() + printsystem.print_line('') + exit(1) + exit(0) + +if __name__ == '__main__': main() |