def settings_specification(self): """The settings specification as JSON string. :rtype: str :return: a JSON string """ settings = [{ "type": "title", "title": _('General settings') }, { "type": "theme", "title": _('Theme'), "desc": _('Select color theme application'), "section": "general", "key": "theme" }, { "type": "optionmapping", "title": _("Language"), "desc": _("Choose your language"), "section": LANGUAGE_SECTION, "key": LANGUAGE_CODE, "options": { code: language_code_to_translation(code) for code in list_languages() } }] return json.dumps(settings)
def BrowseToMWDir(): """Dialog to select Morrowind installation directory. Called by OnInit().""" # --Ask user through dialog. while True: mwDirDialog = wx.DirDialog( None, _(u"Select your Morrowind installation directory.")) result = mwDirDialog.ShowModal() mwDir = mwDirDialog.GetPath() mwDirDialog.Destroy() # --User canceled? if result != wx.ID_OK: return False # --Valid Morrowind install directory? elif os.path.exists(os.path.join(mwDir, u'Morrowind.ini')): conf.settings['mwDir'] = mwDir conf.dirs['app'] = GPath(mwDir) return True # --Retry? retryDialog = wx.MessageDialog( None, _(u"Can't find Morrowind.ini in {!s}! Try again?".format(mwDir)), _(u'Morrowind Install Directory'), wx.YES_NO | wx.ICON_EXCLAMATION) result = retryDialog.ShowModal() retryDialog.Destroy() if result != wx.ID_YES: return False
def continueHangman(): confirm = input(_("do_you_want_to_start_the_game_Yes_No")) while(not response(confirm)): confirm = input(_("do_you_want_to_start_the_game_Yes_No")) if(disagree(confirm)): print(_("thank_you_lets_play_another_time")) exit() print(_("alright_lets_do_it"))
def continueHangmanTuto(): confirm = input(_("do_you_know_the_rules_of_the_game_yes_no")) while(not response(confirm)): confirm = input(_("do_you_know_the_rules_of_the_game_yes_no")) if(disagree(confirm)): hangmanTuto() else: print(_("good_lets_start_the_game"))
def continueGame(): confirm = input(_("do_you_want_to_continue_playing")) while(not response(confirm)): confirm = input(_("do_you_want_to_continue_playing")) if(disagree(confirm)): print(_("thank_you_for_playing_see_you_again")) return False return True
def input_popup(self, input_instance): def on_select(value): dialog.dismiss() if not value or value.isspace(): return input_instance.value = value dialog = input_dialog(title=_('Header'), hint_text=TEXT_INPUT, text_button_ok=_('Yes'), events_callback=on_select, text_button_cancel=_('No'))
def exit_program(self, *args): def close_dialog(): self.exit_dialog.dismiss() self.exit_dialog = None if self.exit_dialog: return self.exit_dialog = dialog( text=_('Do you want to quit?'), title=_("Exit"), dismiss=False, buttons=[[_("Yes"), lambda *x: sys.exit(0)], [_("No"), lambda *x: close_dialog()]])
def status_toggle_btn(self, btn, id): """ Curently only used for connect/disconnect togglebutton, but might useful for more buttons """ if id == 'tgl_btn_connection' and btn.state == 'down': #self.ids.tgl_btn_connection.text = 'Disconnect' if self.connect() else 'Connect' status = self.connect() self.ids.tgl_btn_connection.text = _( 'Disconnect') if status == True else _('Connect') if status == False: btn.state = 'normal' elif id == 'tgl_btn_connection' and btn.state == 'normal': self.disconnect() self.ids.tgl_btn_connection.text = _('Connect')
def dumpTranslator(): """Dumps new translation key file using existing key, value pairs.""" # --Locale Path import locale language = locale.getlocale()[0].split('_', 1)[0] cur_dir = os.path.split(os.getcwd())[0] outPath = cur_dir + '\\l10n\\NEW{!s}.txt'.format(language) outFile = open(outPath, 'w') # --Scan for keys and dump to keyCount = 0 dumpedKeys = set() reKey = re.compile(r'_\([u]?[\'\"](.+?)[\'\"]\)') for pyFile in ('mush.py', 'mosh.py', 'mash.py', 'masher.py', 'errorlog.py', 'exception.py', 'tes3cmd\\gui.py', 'tes3cmd\\tes3cmdgui.py', 'gui\\__init__.py', 'gui\\dialog.py', 'gui\\helpbrowser.py', 'gui\\settings.py', 'gui\\utils.py'): pyText = open(pyFile) print pyFile for lineNum, line in enumerate(pyText): line = re.sub('#.*', '', line) for key in reKey.findall(line): if key in dumpedKeys: continue outFile.write('=== %s, %d\n' % (pyFile, lineNum + 1)) outFile.write(key + '\n>>>>\n') value = _(re.sub(r'\\n', '\n', key)) value = re.sub('\n', r'\\n', value) if value != key: outFile.write(value) outFile.write('\n') dumpedKeys.add(key) keyCount += 1 pyText.close() outFile.close() print keyCount, 'translation keys written to', outPath
def show_license(self): path_to_license = os.path.join(dir, 'assets', 'license_russian.rst') if not os.path.exists(path_to_license): dialog(text=_('File not found'), title=self.title) return text_license = open(path_to_license).read() widget_license = RstDocument(text=text_license) card(widget_license, size=(.9, .8))
def genSchedule(fileName, espName=None): generator = mosh.ScheduleGenerator() generator.loadText(fileName) # --Write to text file? if not espName: outName = os.path.splitext(fileName)[0] + '.mws' generator.dumpText(outName) # --Write to esp file? else: init(2) fileInfo = mosh.modInfos.data.get(espName) if not fileInfo: raise _('No such file: ') + espName generator.save(fileInfo)
def btn_login(self): """ Probably validate input vs. some library card pattern @future If Offlinemode is active, passwords should be ignored (because SIP2 allows logins without password - so one less point of failure when doing checkins/checkouts after offline time. """ username = self.ids.inp_library_card.text password = self.ids.inp_password.text self.ids.patron_login_error.text = '' # Password required? if self.app.config.getint('sip2Rules', 'require_password') == 1 and password == '': self.ids.patron_login_error.text = _('Password may not be empty') return False try: print(username) print(password) # Login successful? status = self.wrapper.login_patron(username, password) if status == True: self.ids.inp_library_card.text = '' self.ids.inp_password.text = '' #self.ids.popup_password.dismiss() pprint(self.wrapper.get_patron_status()) else: print('wrong pw') self.ids.inp_password.text = '' self.ids.inp_password.focus = True self.ids.patron_login_error.text = _('Wrong credentials.') #print(self.wrapper.return_last_request()) #print(self.wrapper.return_last_response()) except Exception as ex: print('exception') print(ex)
def play(vocabulary): score = 0 loss = 0 guess = '' inputWord = '' word = random.choice(vocabulary).lower() inputWord = initInputWord(word, inputWord) while (loss < bodyParts and score < len(word)): guess = input(_("your_guess")) if (correct(guess, word)): score += 1 inputWord = display(word, word.find(guess.lower()), inputWord) else: loss += 1 drawHangman(loss) if (loss == bodyParts): print(_("sorry_you_lose")) else: print(_("you_win"), word.upper())
def build(self): # self.set_language('en_US') self.use_kivy_settings = False self.title = _('First Kivy Project') # заголовок окна программы self.icon = 'assets/logo.png' # иконка окна программы self.settings_cls = CustomSettings self.update_language_from_config() theme = self.config.get('general', 'theme') theme_pallete, theme_style = theme.split(',') self.theme_cls.primary_palette = theme_pallete self.theme_cls.theme_style = theme_style self.screen = StartScreen(events_callback=self.on_event) self.nav_drawer = NavDrawer(title="Меню") return self.screen
def _create_popup(self, instance): content = BoxLayout(orientation='vertical', spacing='5dp') list = MDList() content.add_widget(list) # add all the options uid = str(self.uid) for option, text in sorted(self.options.items(), key=lambda t: t[1]): state = 'down' if option == self.value else 'normal' # active = True if option == self.value else False btn = OneLineChekboxListItem(text=text, state=state, group=uid) btn.bind(on_release=lambda instance, option=option: self. _set_option(option)) list.add_widget(btn) self.popup = card_with_buttons( content, title=self.desc, buttons=[[_('Cancel'), self.close_dialog]])
'File' : 150, 'Modified': 150, 'Size' : 75, }, 'bash.screens.colAligns' : {}, # Wrye Mash: Group and Rating 'mash.mods.groups' : ['Body', 'Bethesda', 'Clothes', 'Creature', 'Fix', 'Last', 'Test', 'Game', 'GFX', 'Location', 'Misc.', 'NPC', 'Quest', 'Race', 'Resource', 'Sound'], 'mash.mods.ratings' : ['+', '1', '2', '3', '4', '5', '=', '~'], # Wrye Mash: RefRemovers 'mash.refRemovers.data' : { }, 'mash.refRemovers.safeCells' : [ _("Balmora, Caius Cosades' House"), _("Indarys Manor"), _("Raven Rock, Factor's Estate"), _("Rethan Manor"), _("Skaal Village, The Blodskaal's House"), _("Solstheim, Thirsk"), _("Tel Uvirith, Tower Lower"), _("Tel Uvirith, Tower Upper"), ], # Wrye Mash: RefReplacers 'mash.refReplacers.data' : { }, # Wrye Mash: Col (Sort) Names 'mash.colNames' : { 'Author' : _('Author'), 'Cell' : _('Cell'),
def connect(self): """ Should be a better way like self.sip2Params = dict(app.config._sections['sip2Params']) from pprint import pprint pprint (self.sip2Params) # for key,value in dict(app.config._sections['sip2Params'].items()): # print ("'%s' with value '%s'" % (key, value)) """ """ Hmpf, does NOT WORK too # In combination with kivy configs I don't know a better way; this is # probably really bad... def unescape(terminated_str): return { '\\r': "\r", '\\n': "\n", '\\r\\n': "\r\n", }.get(terminated_str, "\r") terminator_unescaped = unescape(self.app.config.get('sip2Params', 'msgTerminator')) """ sip2Params = { 'hostName': self.app.config.get('sip2Params', 'hostName'), 'hostPort': self.app.config.getint('sip2Params', 'hostPort'), 'maxretry': self.app.config.getint('sip2Params', 'maxretry'), 'socketTimeout': self.app.config.getint('sip2Params', 'socket_timeout'), 'tlsEnable': self.app.config.getint('sip2Params', 'tlsEnable'), 'tlsAcceptSelfsigned': self.app.config.getint('sip2Params', 'tlsAcceptSelfsigned'), 'hostEncoding': self.app.config.get('sip2Params', 'hostEncoding'), 'fldTerminator': self.app.config.get('sip2Params', 'fldTerminator'), #'msgTerminator' : terminator_unescaped, 'withCrc': self.app.config.getint('sip2Params', 'withCrc'), 'withSeq': self.app.config.getint('sip2Params', 'withSeq'), 'UIDalgorithm': self.app.config.getint('sip2Params', 'UIDalgorithm'), 'PWDalgorithm': self.app.config.getint('sip2Params', 'PWDalgorithm'), 'language': self.app.config.get('sip2Params', 'language'), 'institutionId': self.app.config.get('sip2Params', 'institutionId'), 'terminalPassword': self.app.config.get('sip2Params', 'terminalPassword'), 'scLocation': self.app.config.get('sip2Params', 'scLocation'), 'logfile_path': self.app.config.get('sip2Params', 'logfile_path'), 'loglevel': self.app.config.get('sip2Params', 'loglevel') #'patron' : '12345', #'patronpwd' : 'secret', } # Create instance, but don't connect yet # @todo: if config changed, we probably need a new instance (or even # better, map config values to sip2 properties) if not hasattr(self, 'wrapper'): self.wrapper = Sip2Wrapper( sip2Params, False, self.app.config.get('sip2Params', 'version')) # Now connect try: self.wrapper.connect() # green indicator: self.ids.balbalb #pprint (self.wrapper.return_sc_status()) except Exception as ex: #print (type(ex).__name__) print(ex) print( _("Connection failed. Please check log and config and your connectivity" )) print("GOING INTO OFFLINE MODE!") myAction = 'error' return False # Now Login try: self.wrapper.login_device( self.app.config.get('sip2Params', 'ils_user'), self.app.config.get('sip2Params', 'ils_pass')) except Exception as ex: print(ex) print(_("Login failed. Please check config")) return False # Get possible commands # @todo: make _command_available public or add get method in Sip2; # also refactor logging ("Server does not support command ...") # for such checks # @note: convert to int because configuration does not accept True/False # @note: the _supported_ commands may be disabled by policy; check below for msg_id in range(0, 15): # Don't turn something user override option on if set to off can_override = [1, 2, 9, 14, 15] msg_val = int(self.wrapper._command_available(msg_id)) if self.app.config.get( 'sip2Rules', str(msg_id)) == 1 and msg_id in can_override: self.app.config.set('sip2Rules', str(msg_id), msg_val) else: self.app.config.set('sip2Rules', str(msg_id), msg_val) # Apply SIP2 policies (that may be more restrictive than what's supported) if (self.wrapper.return_sc_status()['fixed']['AcsRenewalPolicy'] == 'N' ): self.app.config.set('sip2Rules', '14', 0) self.app.config.set('sip2Rules', '15', 0) if (self.wrapper.return_sc_status()['fixed']['CheckinOk'] == 'N'): self.app.config.set('sip2Rules', '2', 0) if (self.wrapper.return_sc_status()['fixed']['CheckoutOk'] == 'N'): self.app.config.set('sip2Rules', '1', 0) if (self.wrapper.return_sc_status()['fixed']['StatusUpdateOk'] == 'N'): self.app.config.set('sip2Rules', '3', 0) self.app.config.set('sip2Rules', '12', 0) if (self.wrapper.return_sc_status()['fixed']['OfflineOk'] == 'N'): self.app.config.set('sip2Rules', 'OfflineOk', 0) #if (self.app.config.get('sip2Params', 'socketTimeout') > int(self.wrapper._scStatus['fixed']['TimeoutPeriod'])): # self.app.config.set('sip2Params', 'socketTimeout', int(self.wrapper._scStatus['fixed']['TimeoutPeriod'])) if (int(self.app.config.get('sip2Params', 'maxretry')) > int( self.wrapper.return_sc_status()['fixed']['RetriesAllowed'])): self.app.config.set( 'sip2Params', 'maxretry', int(self.wrapper.return_sc_status()['fixed'] ['RetriesAllowed'])) # Adjust special Gossip policies. Disable what logically cannot be true. # int() feels more true than '0'... hmm current_version = self.app.config.get('sip2Params', 'version') if (current_version != 'Gossip' or self.app.config.getint('sip2Rules', '2') == 0): # No isn't exactly right, but keep in mind, that these settings are only Gossip specific. No means it is disabled. self.app.config.set('sip2RulesGossip', 'commitReservation', 0) # @note immer vorm ausleihen checken, ob reserviert (wie Bibliotheca) self.app.config.set('sip2RulesGossip', 'alertReservation', 0) if (current_version != 'Gossip' or self.app.config.getint('sip2Rules', '14') == 0 or self.app.config.getint('sip2Rules', '15') == 0): self.app.config.set('sip2RulesGossip', 'thirdPartyRenewal', 0) if (current_version != 'Gossip' or self.app.config.getint('sip2Rules', '9') == 0): self.app.config.set('sip2RulesGossip', 'subtotalPayment', 0) self.app.config.set('sip2RulesGossip', 'partialFeePayment', 0) if (current_version != 'Gossip'): self.app.config.set('sip2RulesGossip', 'languageSwitch', 0) if (current_version != 'Gossip' or self.app.config.getint('sip2Rules', '10') == 0): self.app.config.set('sip2RulesGossip', 'provideItemProperties', 0) #pprint (self.wrapper._scStatus) # save the config, otherwise it will be reset to defaults on next app start self.app.config.write() # Destroy setting, so the new settings are actually shown (before an app restart) # Might result in ignored exception on app exit (if config is not opened before again)... self.app.destroy_settings() # Got all the way down here? Return True return True
def startHangman(): print(_("game_start"))
def hangmanTuto(): print(_("hangman_tuto"))
def build_settings(self, settings): settings.add_json_panel(_('First Kivy Project'), self.config, data=self.settings_specification)
def __init__(self,message=_('Argument is out of allowed ranged of values.')): BoltError.__init__(self,message)
def __init__(self,message=_('Section is not coded yet.')): BoltError.__init__(self,message)
def hangmanIntro(): print(_('hi_welcome_to_hangman'))
def showVocabulary(vocabulary): print(_("this_is_the_vocab_that_we_will_be_using")) print(vocabulary)
def modeChoice(): mode = input(_("easy_mode_yes_no")) return True if(response(mode) and agree(mode)) else False
def drawHangman(loss): print(_(hangmanBody.get(loss, 'Incorrect body part index')))
def _set_option(self): app = App.get_running_app() self.value = ','.join( (app.theme_cls.primary_palette, app.theme_cls.theme_style)) self.labelvalue = ', '.join( (_(app.theme_cls.primary_palette), _(app.theme_cls.theme_style)))
def __init__(self,message=None): message = message or _('Access is denied.') BoltError.__init__(self,message)
def __init__(self,message=_('Action aborted by user.')): BoltError.__init__(self, message)
def userIntro(): name = input(_('whats_your_name')) print(_("nice_to_meet_you")+ " [bold magenta]" + name + "[/bold magenta]! "+ _("lets_start_the_game"))
def __init__(self,message=_('Object is in a bad state.')): BoltError.__init__(self,message)
def __init__(self, **kwargs): super(SettingTheme, self).__init__(**kwargs) app = App.get_running_app() self.labelvalue = ', '.join( (_(app.theme_cls.primary_palette), _(app.theme_cls.theme_style)))
def __init__(self,message=_('Abstract section called.')): BoltError.__init__(self,message)
TEXT_INPUT = 'Enter value' # подпись окна для ввода значений BACKGROUND_SECTIONS = [47 / 255., 167 / 255., 212 / 255., 1] # фоновый цвет активного раздела настроек COLOR_TEXT_INPUT = [.9, .9, .9, 1] # цвет текста описания пункта настроек BACKGROUND_IMAGE_TITLE = '' # фоновое изображение описания пункта настроек BACKGROUND_COLOR_TITLE = [.15, .15, .15, .5] # цвет описания пункта настроек BACKGROUND_IMAGE_ITEM = '' # фоновое изображение пункта настроек BACKGROUND_COLOR_ITEM = [47 / 255., 167 / 255., 212 / 255., 0] # цвет пункта настроек BACKGROUND_COLOR = [1, 1, 1, 0] # фоновый цвет настроек SEPARATOR_COLOR = [ 0.12156862745098039, 0.8901960784313725, 0.2, 0.011764705882352941 ] SETTINGS_INTERFACE = InterfaceWithNoMenu _('Pink') _('Blue') _('Indigo') _('BlueGrey') _('Brown') _('LightBlue') _('Purple') _('Grey') _('Yellow') _('LightGreen') _('DeepOrange') _('Green') _('Red') _('Teal') _('Orange') _('Cyan')