From 66fe5d7098e968c9892415d89cd0a87bc8108182 Mon Sep 17 00:00:00 2001 From: chriskiehl Date: Thu, 24 Dec 2015 16:47:29 -0500 Subject: [PATCH] Project cleanup --- gooey/gui/application.py | 64 ------------------------ gooey/python_bindings/gooey_decorator.py | 34 ------------- 2 files changed, 98 deletions(-) diff --git a/gooey/gui/application.py b/gooey/gui/application.py index d63428a..47f9b85 100644 --- a/gooey/gui/application.py +++ b/gooey/gui/application.py @@ -3,66 +3,12 @@ Main runner entry point for Gooey. ''' import wx -import os -import sys -import json -import argparse from gooey.gui.lang import i18n from gooey.gui.controller import Controller -from gooey.python_bindings import config_generator, source_parser from gooey.gui import image_repository -def main(): - parser = argparse.ArgumentParser( - description='Gooey turns your command line programs into beautiful, user friendly GUIs') - - parser.add_argument( - '-b', '--create-build-script', - dest='build_script', - help='Parse the supplied Python File and generate a runnable Gooey build script' - ) - - parser.add_argument( - '-r', '--run', - dest='run', - nargs='?', - const='', - help='Run Gooey with build_config in local dir OR via the supplied config path' - ) - - args = parser.parse_args() - - if args.build_script: - do_build_script(args.build_script) - elif args.run is not None: - do_run(args) - - -def do_build_script(module_path): - with open(module_path, 'r') as f: - if not source_parser.has_argparse(f.read()): - raise AssertionError('Argparse not found in module. Unable to continue') - - gooey_config = config_generator.create_from_parser(module_path, show_config=True) - outfile = os.path.join(os.getcwd(), 'gooey_config.json') - - print 'Writing config file to: {}'.format(outfile) - - with open(outfile, 'w') as f: - f.write(json.dumps(gooey_config, indent=2)) - - -def do_run(args): - gooey_config = args.run or read_local_dir() - - if not os.path.exists(gooey_config): - raise IOError('Gooey Config not found') - - with open(gooey_config, 'r') as f: - build_spec = json.load(f) - run(build_spec) def run(build_spec): @@ -75,13 +21,3 @@ def run(build_spec): app.MainLoop() -def read_local_dir(): - local_files = os.listdir(os.getcwd()) - if 'gooey_config.json' not in local_files: - print "Bugger! gooey_config.json not found!" - sys.exit(1) - return os.path.join(os.getcwd(), 'gooey_config.json') - - -if __name__ == '__main__': - main() diff --git a/gooey/python_bindings/gooey_decorator.py b/gooey/python_bindings/gooey_decorator.py index eea7672..00d2101 100644 --- a/gooey/python_bindings/gooey_decorator.py +++ b/gooey/python_bindings/gooey_decorator.py @@ -91,39 +91,5 @@ def Gooey(f=None, return build -def store_executable_copy(): - main_module_path = get_caller_path() - _, filename = os.path.split(main_module_path) - cleaned_source = clean_source(main_module_path) - - descriptor, tmp_filepath = tempfile.mkstemp(suffix='.py') - atexit.register(cleanup, descriptor, tmp_filepath) - - with open(tmp_filepath, 'w') as f: - f.write(cleaned_source) - return tmp_filepath - - -def clean_source(module_path): - with open(module_path, 'r') as f: - return ''.join( - line for line in f.readlines() - if '@gooey' not in line.lower()) - - -def get_parser(module_path): - return source_parser.extract_parser(module_path) - - -def get_caller_path(): - tmp_sys = __import__('sys') - return tmp_sys.argv[0] - - -def cleanup(descriptor, filepath): - os.close(descriptor) - os.remove(filepath) - - if __name__ == '__main__': pass