def resource(name): result = {} try: r = ResourceBundle.getBundle("properties/" + name, Locale.getDefault(), imp.getSyspathJavaLoader()) for key in r.getKeys(): result[key] = r.getString(key) except MissingResourceException, e: pass
def format_message(key, *args): bundle = ResourceBundle.getBundle(TestingConstants.RESOURCE_BUNDLE_NAME) message = bundle.getString(key) if len(args) > 0: message = MessageFormat.format(message, list(args)) #message = MessageFormat.format(message, args) return message
def __init__(self, app): #name: reference code for this tool used for exmaple in 'config.cfg' self.name = self.title.lower().replace(" ", "_") if self.name in app.toolsStatus: self.isActive = app.toolsStatus[self.name] else: self.isActive = True #localization if self.isTranslated: localeDir = File.separator.join([self.app.SCRIPTDIR, "tools", "data", self.title.replace(" ", ""), "locale"]) urls = [File(localeDir).toURI().toURL()] loader = URLClassLoader(urls) currentLocale = Locale.getDefault() self.strings = ResourceBundle.getBundle("MessagesBundle", currentLocale, loader) if self.name == "favourites": self.title = self.strings.getString("Favourites") if self.name == "favourites": ref = "Favourites" else: ref = self.title.replace(" ", "") self.bigIcon = ImageIcon(File.separator.join([app.SCRIPTDIR, "tools", "data", ref, "icons", "tool_24.png"])) self.smallIcon = ImageIcon(File.separator.join([app.SCRIPTDIR, "tools", "data", ref, "icons", "tool_16.png"])) if not hasattr(self, "isLocal") or not self.isLocal: self.isLocal = False if self.name in app.toolsPrefs: self.update_preferences() if not hasattr(self, "markerPosition"): self.markerPosition = None self.views = [] for viewName, checksList in self.toolInfo.iteritems(): self.views.append(View(app, self, viewName, checksList))
def get_message(key, *args): """ Get the formatted message from the resource bundle. :param key: the message key :param args: the token values :return: the formatted message string """ bundle = ResourceBundle.getBundle(TestingConstants.RESOURCE_BUNDLE_NAME) message = bundle.getString(key) if len(args) > 0: message = MessageFormat.format(message, list(args)) return message
def set_i18n(path=None, basename="sos.po.sos"): """Use this method to change the default i18n behavior from gettext to java ResourceBundle.getString. This is really only useful when using jython. Path is expected to be the path to a jarfile that contains the translation files (.properties)""" # Since we are trying to modify the module-level _sos variable # we have to declare it global global _sos try: from java.util import ResourceBundle, Locale rb = ResourceBundle.getBundle(basename, Locale.getDefault(), _get_classloader(path)) def _java(msg): try: return rb.getString(msg).encode('utf-8') except: return msg _sos = _java except: pass
def __init__(self): self.SCRIPTDIR = SCRIPTDIR #Localization urls = [ File(File.separator.join([self.SCRIPTDIR, "data", "locale"])).toURI().toURL() ] loader = URLClassLoader(urls) currentLocale = Locale.getDefault() self.strings = ResourceBundle.getBundle("MessagesBundle", currentLocale, loader) #Read config self.favZone = None self.zones = None self.config = ConfigLoader(self) """Build tools instances""" self.allTools = AllTools(self).tools for tool in self.allTools: if tool.name == "favourites": self.favouritesTool = tool break self.realTools = [ tool for tool in self.allTools if tool.name not in ("favourites", "localfile") ] #remove tools disabled from config file self.tools = [ tool for tool in self.allTools if tool.isActive or tool.name in ("favourites") ] #add favourite checks to Favourites tool if "favourites" in self.toolsPrefs: favChecks = self.toolsPrefs["favourites"]["checks"] if favChecks != "": for favCheck in favChecks.split("|"): (toolName, viewName, checkName) = favCheck.split(".") for tool in self.tools: if tool.name == toolName: for view in tool.views: if view.name == viewName: for check in view.checks: if check.name == checkName: self.favouritesTool.views[ 0].checks.append(check) """Build dialog for manual reporting of false positive""" self.falsePositiveDlg = FalsePositiveDialog( Main.parent, self.strings.getString("false_positives_title"), True, self) """Build qat_script toggleDialog""" #BUG: it steals icon from validator. #Is it possible ot use an icon not from 'dialogs' dir? icon = "validator.png" self.dlg = QatDialog(self.strings.getString("qat_dialog_title"), icon, "Show ", None, 250, self) self.create_new_dataset_if_empty() Main.map.addToggleDialog(self.dlg) """Build processing dialog""" self.downloadAndReadDlg = DownloadAndReadDialog( Main.parent, self.strings.getString("download_dialog_title"), False, self) """Build quality assurance tools menu""" self.menu = QatMenu(self, "QA Tools") menu.add(self.menu) menu.repaint() """Initialization""" #Read ids of OSM objects that the user wants to be ignored self.ignore_file = File.separator.join( [self.SCRIPTDIR, "data", "ignoreids.csv"]) self.read_ignore() self.falsePositive = [] # info regarding false positive self.selectedTool = self.tools[0] self.selectedView = self.selectedTool.views[0] # first view self.selectedTableModel = self.selectedView.tableModel self.selectedChecks = [] self.downloadingChecks = [] self.clickedError = None self.errorsData = None self.zoneBbox = None # bbox of current JOSM view self.selectedError = None self.url = None # url of errors self.errorLayers = [] # list of layers with error markers self.selectionChangedFromMenuOrLayer = False self.dlg.toolsCombo.setSelectedIndex(0) print "\nINFO: Quality Assurance Tools script is running: ", self.SCRIPTVERSION # Check if using the latest version if self.checkUpdate == "on": update_checker.Updater(self, "auto")
def __init__(self): self.SCRIPTDIR = SCRIPTDIR #Localization urls = [File(File.separator.join([self.SCRIPTDIR, "data", "locale"])).toURI().toURL()] loader = URLClassLoader(urls) currentLocale = Locale.getDefault() self.strings = ResourceBundle.getBundle("MessagesBundle", currentLocale, loader) #Read config self.favZone = None self.zones = None self.config = ConfigLoader(self) """Build tools instances""" self.allTools = AllTools(self).tools for tool in self.allTools: if tool.name == "favourites": self.favouritesTool = tool break self.realTools = [tool for tool in self.allTools if tool.name not in ("favourites", "localfile")] #remove tools disabled from config file self.tools = [tool for tool in self.allTools if tool.isActive or tool.name in ("favourites")] #add favourite checks to Favourites tool if "favourites" in self.toolsPrefs: favChecks = self.toolsPrefs["favourites"]["checks"] if favChecks != "": for favCheck in favChecks.split("|"): (toolName, viewName, checkName) = favCheck.split(".") for tool in self.tools: if tool.name == toolName: for view in tool.views: if view.name == viewName: for check in view.checks: if check.name == checkName: self.favouritesTool.views[0].checks.append(check) """Build dialog for manual reporting of false positive""" self.falsePositiveDlg = FalsePositiveDialog( Main.parent, self.strings.getString("false_positives_title"), True, self) """Build qat_script toggleDialog""" #BUG: it steals icon from validator. #Is it possible ot use an icon not from 'dialogs' dir? icon = "validator.png" self.dlg = QatDialog(self.strings.getString("qat_dialog_title"), icon, "Show ", None, 250, self) self.create_new_dataset_if_empty() Main.map.addToggleDialog(self.dlg) """Build processing dialog""" self.downloadAndReadDlg = DownloadAndReadDialog(Main.parent, self.strings.getString("download_dialog_title"), False, self) """Build quality assurance tools menu""" self.menu = QatMenu(self, "QA Tools") menu.add(self.menu) menu.repaint() """Initialization""" #Read ids of OSM objects that the user wants to be ignored self.ignore_file = File.separator.join([self.SCRIPTDIR, "data", "ignoreids.csv"]) self.read_ignore() self.falsePositive = [] # info regarding false positive self.selectedTool = self.tools[0] self.selectedView = self.selectedTool.views[0] # first view self.selectedTableModel = self.selectedView.tableModel self.selectedChecks = [] self.downloadingChecks = [] self.clickedError = None self.errorsData = None self.zoneBbox = None # bbox of current JOSM view self.selectedError = None self.url = None # url of errors self.errorLayers = [] # list of layers with error markers self.selectionChangedFromMenuOrLayer = False self.dlg.toolsCombo.setSelectedIndex(0) print "\nINFO: Quality Assurance Tools script is running: ", self.SCRIPTVERSION # Check if using the latest version if self.checkUpdate == "on": update_checker.Updater(self, "auto")
#! /bin/false import java.util.ResourceBundle as rsb import os import shutil import weblogic.security bootproperties=rsb.getBundle("boot") es=weblogic.security.internal.SerializedSystemIni.getEncryptionService("/home/andresaquino/Downloads/security") ces=weblogic.security.internal.encryption.ClearOrEncryptedService(es) print '\tUser: '******'\tPassword: ' + ces.decrypt(bootproperties.getString("password"))
#! /bin/false import java.util.ResourceBundle as rsb import os import shutil import weblogic.security bootproperties = rsb.getBundle("boot") es = weblogic.security.internal.SerializedSystemIni.getEncryptionService( "/home/andresaquino/Downloads/security") ces = weblogic.security.internal.encryption.ClearOrEncryptedService(es) print '\tUser: '******'\tPassword: ' + ces.decrypt(bootproperties.getString("password"))
## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## You should have received a copy of the GNU General Public License ## along with this program; if not, write to the Free Software ## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. __version__ = "@SOSVERSION@" try: from java.util import ResourceBundle rb = ResourceBundle.getBundle("sos.po.sos") def _sos(msg): try: return rb.getString(msg).encode('utf-8') except: return msg except: import gettext gettext_dir = "/usr/share/locale" gettext_app = "sos" gettext.bindtextdomain(gettext_app, gettext_dir) def _sos(msg): return gettext.dgettext(gettext_app, msg)