Пример #1
0
def setPyICULocale(locale):
    """
      Sets the c{PyICU.Locale} to the value passed in
      c{str} locale argument.

      If the locale passed in not a valid / supported
      PyICU locale a c{I18nException} is raised.

      @param locale: a c{str} locale
      @type locale: ASCII c{str}

    """
    lc = Locale(locale)

    if not isValidPyICULocale(lc):
        raise I18nException, "Invalid PyICU Locale: '%s'" % locale

    Locale.setDefault(lc)

    # Store a reference to the PyICU Locale instance
    global _PYICU_LOCALE
    _PYICU_LOCALE = lc
Пример #2
0
def setPyICULocale(locale):
    """
      Sets the c{PyICU.Locale} to the value passed in
      c{str} locale argument.

      If the locale passed in not a valid / supported
      PyICU locale a c{I18nException} is raised.

      @param locale: a c{str} locale
      @type locale: ASCII c{str}

    """
    lc = Locale(locale)

    if not isValidPyICULocale(lc):
        raise I18nException, "Invalid PyICU Locale: '%s'" % locale

    Locale.setDefault(lc)

    # Store a reference to the PyICU Locale instance
    global _PYICU_LOCALE
    _PYICU_LOCALE = lc
Пример #3
0
#   See the License for the specific language governing permissions and
#   limitations under the License.


from createBase import LocalizationBase
from poUtility import *
from distutils.dir_util import copy_tree, remove_tree, mkpath
from distutils.file_util import copy_file
import os, sys
import build_lib

try:
    from PyICU import Locale
    # We want the English textual representation
    # of the locale to display to the user.
    Locale.setDefault(Locale("en"))

    PYICU_INSTALLED = True
except:
    PYICU_INSTALLED = False

if sys.platform == 'darwin':
    # This might be specific to Intel Mac "Leopard", but playing safe
    # See bug 11645.
    TIMEOUT = -1
else:
    TIMEOUT = 60

def ignore(output):
    pass
 def setUp(self):
     super(DatetimeFrenchFormatTestCase, self).setUp()
     view = self.view
     ICULocale.setDefault(ICULocale.getFrance())
     view.tzinfo.setDefault(view.tzinfo.getInstance("Europe/Paris"))
 def setUp(self):
     super(DatetimeFormatTestCase, self).setUp()
     view = self.view
     ICULocale.setDefault(ICULocale.getUS())
     view.tzinfo.setDefault(view.tzinfo.getInstance("America/Los_Angeles"))
 def tearDown(self):
     if self.oldLocale is not None:
         ICULocale.setDefault(self.oldLocale)
     if self.oldTzinfo is not None:
         self.view.tzinfo.setDefault(self.oldTzinfo)
Пример #7
0
 def setUp(self):
     super(DatetimeFrenchFormatTestCase, self).setUp()
     view = self.view
     ICULocale.setDefault(ICULocale.getFrance())
     view.tzinfo.setDefault(view.tzinfo.getInstance("Europe/Paris"))
Пример #8
0
 def setUp(self):
     super(DatetimeFormatTestCase, self).setUp()
     view = self.view
     ICULocale.setDefault(ICULocale.getUS())
     view.tzinfo.setDefault(view.tzinfo.getInstance("America/Los_Angeles"))
Пример #9
0
 def tearDown(self):
     if self.oldLocale is not None:
         ICULocale.setDefault(self.oldLocale)
     if self.oldTzinfo is not None:
         self.view.tzinfo.setDefault(self.oldTzinfo)
Пример #10
0
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.

from createBase import LocalizationBase
from poUtility import *
from distutils.dir_util import copy_tree, remove_tree, mkpath
from distutils.file_util import copy_file
import os, sys
import build_lib

try:
    from PyICU import Locale
    # We want the English textual representation
    # of the locale to display to the user.
    Locale.setDefault(Locale("en"))

    PYICU_INSTALLED = True
except:
    PYICU_INSTALLED = False

if sys.platform == 'darwin':
    # This might be specific to Intel Mac "Leopard", but playing safe
    # See bug 11645.
    TIMEOUT = -1
else:
    TIMEOUT = 60


def ignore(output):
    pass
Пример #11
0
def initOptions(chandlerDirectory, **kwds):
    """
    Load and parse the command line options, with overrides in **kwds.
    Returns options
    """

    #    option name,  (value, short cmd, long cmd, type flag, default, environment variable, help text)
    _configItems = {
        "parcelPath": ("-p", "--parcelPath", "s", None, "PARCELPATH", "Parcel search path"),
        "webserver": ("-W", "--webserver", "b", False, "CHANDLERWEBSERVER", "Activate the built-in webserver"),
        "profileDir": ("-P", "--profileDir", "s", None, "PROFILEDIR", "location of the Chandler Repository"),
        "profile": ("", "--prof", "b", False, None, "save profiling data"),
        "script": ("-s", "--script", "s", None, None, "script to execute after startup"),
        "scriptFile": ("-f", "--scriptFile", "s", None, None, "script file to execute after startup"),
        "stderr": ("-e", "--stderr", "b", False, None, "Echo error output to log file"),
        "create": ("-c", "--create", "b", False, "CREATE", "Force creation of a new repository"),
        "ramdb": ("-d", "--ramdb", "b", False, None, ""),
        "restore": ("-r", "--restore", "s", None, None, "repository backup to restore from before repository open"),
        "recover": ("-R", "--recover", "b", False, None, "open repository with recovery"),
        "nocatch": ("-n", "--nocatch", "b", False, "CHANDLERNOCATCH", ""),
        "wing": ("-w", "--wing", "b", False, None, ""),
        "komodo": ("-k", "--komodo", "b", False, None, ""),
        "refreshui": ("-u", "--refresh-ui", "b", False, None, "Refresh the UI from the repository during startup"),
        "locale": ("-l", "--locale", "s", None, None, "Set the default locale"),
        "encrypt": ("-S", "--encrypt", "b", False, None, "Request prompt for password for repository encryption"),
        "nosplash": ("-N", "--nosplash", "b", False, "CHANDLERNOSPLASH", ""),
        "logging": ("-L", "--logging", "s", "logging.conf", "CHANDLERLOGCONFIG", "The logging config file"),
        "createData": ("-C", "--createData", "s", None, None, "csv file with items definition to load after startup"),
    }

    # %prog expands to os.path.basename(sys.argv[0])
    usage = "usage: %prog [options]"
    parser = OptionParser(usage=usage, version="%prog " + __version__)

    for key in _configItems:
        (shortCmd, longCmd, optionType, defaultValue, environName, helpText) = _configItems[key]

        if environName and os.environ.has_key(environName):
            defaultValue = os.environ[environName]

        if optionType == "b":
            parser.add_option(shortCmd, longCmd, dest=key, action="store_true", default=defaultValue, help=helpText)
        else:
            parser.add_option(shortCmd, longCmd, dest=key, default=defaultValue, help=helpText)

    (options, args) = parser.parse_args()

    if not options.profileDir:
        profileDir = locateProfileDir()
        if profileDir is None:
            profileDir = chandlerDirectory
        options.profileDir = os.path.expanduser(profileDir)

    for (opt, val) in kwds.iteritems():
        setattr(options, opt, val)

    if options.locale is not None:
        from PyICU import Locale

        Locale.setDefault(Locale(options.locale))

    return options