Пример #1
0
    def get_lang(config):
        def_lang = config.get_value_default(
            'requirements.input.default_language', 'en_GB')

        if def_lang in DescWords.words:
            return DescWords.words[def_lang]
        tracer.warn("Language [%s] not supported, using en_GB." % def_lang)
        return DescWords.words["en_GB"]
Пример #2
0
    def get_lang(config):
        def_lang = config.get_value_default(
                'requirements.input.default_language', 'en_GB')

        if def_lang in DescWords.words:
            return DescWords.words[def_lang]
        tracer.warn("Language [%s] not supported, using en_GB." % def_lang)
        return DescWords.words["en_GB"]
Пример #3
0
    def get_lang(config):
        """Get the language from the config.

        If not present, return en_GB as default.
        """
        def_lang = config.get_value_default(
            'requirements.input.default_language', 'en_GB')

        if def_lang in DescWords.words:
            return DescWords.words[def_lang]
        tracer.warn("Language [%s] not supported, using en_GB", def_lang)
        return DescWords.words["en_GB"]
Пример #4
0
 def write(self):
     '''Writes the current content to the file.'''
     tracer.debug("Write preferences data to file")
     try:
         tmpfilename = self.__write_tmp()
         tracer.debug("Wrote data to [%s]" % tmpfilename)
         self.__move_tmp(tmpfilename)
     except Exception as ex:
         tracer.warn("Exception during writing data [%s]: [%s]" 
                     % (self.__rel_filename, ex))            
     finally:
         self.__remove_tmp(tmpfilename)
     tracer.debug("Finished writing properties to file.")
Пример #5
0
 def write(self):
     '''Writes the current content to the file.'''
     tracer.debug("Write preferences data to file")
     try:
         tmpfilename = self.__write_tmp()
         tracer.debug("Wrote data to [%s]" % tmpfilename)
         self.__move_tmp(tmpfilename)
     except Exception as ex:
         tracer.warn("Exception during writing data [%s]: [%s]" %
                     (self.__rel_filename, ex))
     finally:
         self.__remove_tmp(tmpfilename)
     tracer.debug("Finished writing properties to file.")
Пример #6
0
 def __write_tmp(self):
     '''Write the data to a temporaty file and return the filename.'''
     tracer.debug("called")
     try:
         tracer.debug("Create temp file")
         tfile = tempfile.NamedTemporaryFile(dir=self.__base_dir, 
                                             delete=False)
         tracer.debug("Write to temp file [%s]." % tfile.name)
         tfile.write(json.dumps(self.__dict, sort_keys=True, indent=2))
         tracer.debug("Wrote to temp file")
     except Exception as ex:
         tracer.warn("Exception during writing temp data [%s]" % ex)
     finally:
         tracer.debug("Close temp file")
         tfile.close()
     tracer.debug("finished")
     return tfile.name
Пример #7
0
 def __write_tmp(self):
     '''Write the data to a temporaty file and return the filename.'''
     tracer.debug("called")
     try:
         tracer.debug("Create temp file")
         tfile = tempfile.NamedTemporaryFile(dir=self.__base_dir,
                                             delete=False)
         tracer.debug("Write to temp file [%s]." % tfile.name)
         tfile.write(json.dumps(self.__dict, sort_keys=True, indent=2))
         tracer.debug("Wrote to temp file")
     except Exception as ex:
         tracer.warn("Exception during writing temp data [%s]" % ex)
     finally:
         tracer.debug("Close temp file")
         tfile.close()
     tracer.debug("finished")
     return tfile.name