mirror of https://github.com/chriskiehl/Gooey.git
Chris Kiehl
10 years ago
30 changed files with 316 additions and 69 deletions
Split View
Diff Options
-
BINsrc/app/__init__.pyc
-
BINsrc/app/dialogs/__init__.pyc
-
BINsrc/app/dialogs/advanced_config.pyc
-
21src/app/dialogs/base_window.py
-
BINsrc/app/dialogs/body.pyc
-
BINsrc/app/dialogs/component_factory.pyc
-
65src/app/dialogs/config_model.py
-
25src/app/dialogs/controller.py
-
BINsrc/app/dialogs/display_main.pyc
-
2src/app/dialogs/footer.py
-
BINsrc/app/dialogs/footer.pyc
-
4src/app/dialogs/header.py
-
BINsrc/app/dialogs/header.pyc
-
11src/app/dialogs/window.py
-
BINsrc/app/images/__init__.pyc
-
14src/app/images/image_store.py
-
BINsrc/app/images/image_store.pyc
-
42src/experiments/command.py
-
25src/languages/eng.py
-
10src/languages/english.json
-
9src/languages/french.json
-
17src/mockapplication/mockapp.py
-
BINsrc/model/__init__.pyc
-
BINsrc/model/codegen.pyc
-
25src/model/gooey.py
-
45src/model/i18n.py
-
25src/model/i18n_unittest.py
-
31src/model/source_parser.py
-
0src/themes/__init__.py
-
14src/themes/thm.py
@ -0,0 +1,65 @@ |
|||
''' |
|||
Created on Jan 23, 2014 |
|||
|
|||
@author: Chris |
|||
''' |
|||
|
|||
import sys |
|||
import types |
|||
from model.source_parser import ArgumentError |
|||
from app.dialogs.action_sorter import ActionSorter |
|||
|
|||
|
|||
|
|||
class Model(object): |
|||
|
|||
def __init__(self, parser): |
|||
self._parser = parser |
|||
self.description = parser.description |
|||
|
|||
self.action_groups = ActionSorter(self._parser._actions) |
|||
|
|||
self._payload = None |
|||
|
|||
|
|||
def HasPositionals(self): |
|||
if self.action_groups._positionals: |
|||
return True |
|||
return False |
|||
|
|||
def IsValidArgString(self, arg_string): |
|||
if isinstance(self._Parse(arg_string), str): |
|||
return False |
|||
return True |
|||
|
|||
def _Parse(self, arg_string): |
|||
try: |
|||
print self._parser.error |
|||
self._parser.parse_args(arg_string.split()) |
|||
return True |
|||
except ArgumentError as e: |
|||
return str(e) |
|||
|
|||
def GetErrorMsg(self, arg_string): |
|||
return self._FormatMsg(self._Parse(arg_string)) |
|||
|
|||
def _FormatMsg(self, msg): |
|||
output = list(msg) |
|||
if ':' in output: |
|||
output[output.index(':')] = ':\n ' |
|||
return ''.join(output) |
|||
|
|||
def AddToArgv(self, arg_string): |
|||
sys.argv.extend(arg_string.split()) |
|||
|
|||
|
|||
|
|||
if __name__ == '__main__': |
|||
pass |
|||
|
|||
|
|||
# print m2 |
|||
|
|||
|
|||
|
|||
|
@ -0,0 +1,25 @@ |
|||
''' |
|||
Created on Jan 25, 2014 |
|||
|
|||
@author: Chris |
|||
''' |
|||
|
|||
import json |
|||
|
|||
|
|||
if __name__ == '__main__': |
|||
english = { |
|||
'settings':'Settings', |
|||
'cancel':'Cancel', |
|||
'next':'Next', |
|||
'simple_config':'Enter Command Line Arguments', |
|||
'required_args_msg':'Required Arguments', |
|||
'optional_args_msg':'Optional Arguments', |
|||
'running':'Running', |
|||
"sure_you_want_to_exit":"Are you sure you want to exit?", |
|||
'close_program': 'Close Program?' |
|||
|
|||
} |
|||
|
|||
with open('english.json', 'wb') as f: |
|||
f.write(json.dumps(english, indent=4, sort_keys=True)) |
@ -1 +1,9 @@ |
|||
{ |
|||
{ |
|||
"cancel": "Cancel", |
|||
"next": "Next", |
|||
"optional_args_msg": "Optional Arguments", |
|||
"required_args_msg": "Required Arguments", |
|||
"running": "Running", |
|||
"settings": "Settings", |
|||
"simple_config": "Enter Command Line Arguments" |
|||
} |
@ -0,0 +1,9 @@ |
|||
{ |
|||
"cancel": "Annuler", |
|||
"next": "Suivant", |
|||
"optional_args_msg": "Arguments optionnels", |
|||
"required_args_msg": "Arguments obligatoires", |
|||
"running": "fonctionnement", |
|||
"settings": "Paramètres", |
|||
"simple_config": "Entrez arguments de ligne de commande" |
|||
} |
@ -0,0 +1,45 @@ |
|||
''' |
|||
Created on Jan 25, 2014 |
|||
|
|||
@author: Chris |
|||
''' |
|||
|
|||
import os |
|||
import sys |
|||
import json |
|||
|
|||
class I18N(object): |
|||
''' |
|||
Provides Internationalization for all text within the |
|||
program. |
|||
''' |
|||
_instance = None |
|||
def __init__(self, language='english'): |
|||
''' Create an I18N object ''' |
|||
self._dict = self._load(language) |
|||
|
|||
def __new__(cls, *a, **kw): |
|||
if cls._instance is None: |
|||
cls._instance = super(I18N, cls).__new__(cls, *a, **kw) |
|||
return cls._instance |
|||
|
|||
def _load(self, language): |
|||
lang_dir = os.path.join(os.getcwd(), '..', 'languages') |
|||
lang_path = os.path.join(lang_dir, language + '.json') |
|||
try: |
|||
with open(lang_path.lower(), 'rb') as f: |
|||
return json.load(f) |
|||
except IOError: |
|||
raise IOError(''.join(['Language "{}" not found. Make sure that your ', |
|||
'translation file is in the languages directory']).format(language)) |
|||
|
|||
def __getitem__(self, item): |
|||
return self._dict[item] |
|||
|
|||
|
|||
if __name__ == '__main__': |
|||
pass |
|||
|
|||
|
|||
|
|||
|
@ -0,0 +1,25 @@ |
|||
''' |
|||
Created on Jan 25, 2014 |
|||
|
|||
@author: Chris |
|||
''' |
|||
|
|||
from i18n import I18N |
|||
import unittest |
|||
|
|||
|
|||
class Test(unittest.TestCase): |
|||
|
|||
|
|||
def setUp(self): |
|||
pass |
|||
|
|||
def testI18nThrowsIOErrorOnBadPath(self): |
|||
with self.assertRaises(IOError): |
|||
I18N('franch') |
|||
|
|||
|
|||
|
|||
if __name__ == "__main__": |
|||
#import sys;sys.argv = ['', 'Test.testName'] |
|||
unittest.main() |
@ -0,0 +1,14 @@ |
|||
''' |
|||
Created on Jan 25, 2014 |
|||
|
|||
@author: Chris |
|||
''' |
|||
|
|||
import json |
|||
|
|||
if __name__ == '__main__': |
|||
a = { |
|||
'font_size': 8, |
|||
'bold_font_family': 'default', |
|||
|
|||
} |
Write
Preview
Loading…
Cancel
Save