def get_resource_lang_mapping(self, resource): """Get language mappings for a specific resource.""" lang_map = Flipdict() try: args = self.config.get("main", "lang_map") for arg in args.replace(' ', '').split(','): k, v = arg.split(":") lang_map.update({k: v}) except ConfigParser.NoOptionError: pass except (ValueError, KeyError): raise Exception("Your lang map configuration is not correct.") if self.config.has_section(resource): res_lang_map = Flipdict() try: args = self.config.get(resource, "lang_map") for arg in args.replace(' ', '').split(','): k, v = arg.split(":") res_lang_map.update({k: v}) except ConfigParser.NoOptionError: pass except (ValueError, KeyError): raise Exception("Your lang map configuration is not correct.") # merge the lang maps and return result lang_map.update(res_lang_map) return lang_map
def get_resource_lang_mapping(self, resource): """Get language mappings for a specific resource.""" lang_map = Flipdict() try: args = self.config.get("main", "lang_map") for arg in args.replace(' ', '').split(','): k,v = arg.split(":") lang_map.update({k:v}) except configparser.NoOptionError: pass except (ValueError, KeyError): raise Exception("Your lang map configuration is not correct.") if self.config.has_section(resource): res_lang_map = Flipdict() try: args = self.config.get(resource, "lang_map") for arg in args.replace(' ', '').split(','): k,v = arg.split(":") res_lang_map.update({k:v}) except configparser.NoOptionError: pass except (ValueError, KeyError): raise Exception("Your lang map configuration is not correct.") # merge the lang maps and return result lang_map.update(res_lang_map) return lang_map
def setUp(self): super(TestProjectPull, self).setUp() self.p = Project(init=False) self.p.minimum_perc = None self.p.resource = "resource" self.p.host = 'foo' self.p.project_slug = 'foo' self.p.resource_slug = 'foo' self.stats = { 'en': { 'completed': '100%', 'last_update': '2011-11-01 15:00:00', }, 'el': { 'completed': '60%', 'last_update': '2011-11-01 15:00:00', }, 'pt': { 'completed': '70%', 'last_update': '2011-11-01 15:00:00', }, } self.langs = list(self.stats.keys()) self.files = dict(list(zip(self.langs, itertools.repeat(None)))) self.details = {'available_languages': []} for lang in self.langs: self.details['available_languages'].append({'code': lang}) self.slang = 'en' self.lang_map = Flipdict()