Load a tt dict into |self.tt_dd|.
        |tt| means text transform.
        
        locale: key into |self.tt_dd|.
        tt_d: a tt dict.
352623
def load_tt_dict(self, locale, tt_d):
        
        
        #/ get the old tt dict of the locale
        tt_d_old = self.tt_dd.get(locale, None)
        
        #/ if has old tt dict
        ## N
        if tt_d_old is None:
            #/ use the new tt dict
            self.tt_dd[locale] = tt_d
        ## Y
        else:
            #/ update the old tt dict
            tt_d_old.update(tt_d)
219305
def _from_dict(cls, _dict):
        """"""
        args = {}
        if 'custom_language_model' in _dict:
            args['custom_language_model'] = _dict.get('custom_language_model')
        else:
            raise ValueError(
                'Required property \'custom_language_model\' not present in SupportedFeatures JSON'
            )
        if 'speaker_labels' in _dict:
            args['speaker_labels'] = _dict.get('speaker_labels')
        else:
            raise ValueError(
                'Required property \'speaker_labels\' not present in SupportedFeatures JSON'
            )
        return cls(**args)
341915
def t(key, options = {})
      if (val = super) =~ /class.+?translation_missing/
        val = val.to_s.gsub(/<span[^>]*>/, 'i18n: ').gsub('</span>', '').gsub(', ', '.')
      end

      val
    end
267668
def _locals(self, d):
        

        if not d:
            return self
        c = self._copy()
        c._data.update(d)
        return c
127186
def from_id(cls, _id, language=DEFAULT_LANG):
        
        db_file = DBVuln.get_file_for_id(_id, language=language)
        data = DBVuln.load_from_json(db_file, language=language)
        return cls(**data)
773831
def dict_unicodeize(some_dict):
    """"""

    # some python 2/3 compat
    if isinstance(some_dict, ("".__class__, u"".__class__)):
        if sys.version_info >= (3, 0):
            return some_dict

        return some_dict.decode('utf-8')
    elif isinstance(some_dict, collections.Mapping):
        return dict(map(dict_unicodeize, iteritems(some_dict)))
    elif isinstance(some_dict, collections.Iterable):
        return type(some_dict)(map(dict_unicodeize, some_dict))

    return some_dict
361362
def load_dict(self, dct):
        """"""
        for k, v in dct.items():
            setattr(self, k, v)
886898
def from_dict(cls, d, encoding='base64'):
        '''
        
        '''
        report = Report(Report._decode(d['name'], encoding))
        report.set_status(Report._decode(d['status'], encoding))
        sub_reports = Report._decode(d['sub_reports'], encoding)
        del d['sub_reports']
        for k, v in d.items():
            if k in sub_reports:
                report.add(k, Report.from_dict(v))
            else:
                if k.lower() == 'status':
                    report.set_status(Report._decode(v, encoding))
                else:
                    report.add(k, Report._decode(v, encoding))

        return report
107125
def unicode2encode(text, charmap):
    '''
    
    '''
    if isinstance(text, (list, tuple)):
        unitxt = ''
        for line in text:
            for val,key in charmap.items():
                if key in line:
                    line = line.replace(key, val)
                # end of if val in text:
            unitxt += line
        # end of for line in text:
        return unitxt
    elif isinstance(text, str):
        for val,key in charmap.items():
            if key in text:
                text = text.replace(key, val)
        return text
650467
def load_locale_prefixdata(indir, separator=None):
    
    prefixdata = {}  # prefix => dict mapping locale to description
    for locale in os.listdir(indir):
        if not os.path.isdir(os.path.join(indir, locale)):
            continue
        for filename in glob.glob(os.path.join(indir, locale, "*%s" % PREFIXDATA_SUFFIX)):
            overall_prefix, ext = os.path.splitext(os.path.basename(filename))
            load_locale_prefixdata_file(prefixdata, filename, locale, overall_prefix, separator)
    return prefixdata
1108750
def from_dp(cls, text, use_unicode_for_glyphs=True):
        
        from .grammars.dp import parse as parse_dp
        if isinstance(text, bytes):
            original_bytes = text
            text = text.decode('utf8')
        else:
            original_bytes = text.encode('utf8')
        instance = parse_dp(text, use_unicode_for_glyphs=use_unicode_for_glyphs)
        instance.original_type = 'dp'
        instance.original_bytes = original_bytes
        return instance
1213435
def load_dictionary(self, filename, encoding="utf-8"):
        
        with load_file(filename, encoding) as data:
            self._dictionary.update(json.loads(data.lower(), encoding=encoding))
            self._update_dictionary()
887333
def temporal_from_literal(text):
    '''
    
    '''
    if text.count('/') == 1:
        # This is an ISO date range as preconized by Gov.uk
        # http://guidance.data.gov.uk/dcat_fields.html
        start, end = text.split('/')
        return db.DateRange(
            start=parse_dt(start).date(),
            end=parse_dt(end).date()
        )
    else:
        separators = text.count('-')
        if separators == 0:
            # this is a year
            return db.DateRange(
                start=date(int(text), 1, 1),
                end=date(int(text), 12, 31)
            )
        elif separators == 1:
            # this is a month
            dt = parse_dt(text).date()
            return db.DateRange(
                start=dt.replace(day=1),
                end=dt.replace(day=calendar.monthrange(dt.year, dt.month)[1])
            )
323180
def tabbed_parsing_character_generator(tmp_dir, train):
  """"""
  character_vocab = text_encoder.ByteTextEncoder()
  filename = "parsing_{0}.pairs".format("train" if train else "dev")
  pair_filepath = os.path.join(tmp_dir, filename)
  return text_problems.text2text_generate_encoded(
      text_problems.text2text_txt_tab_iterator(pair_filepath), character_vocab)
1113777
def _from_dict(cls, _dict):
        """"""
        args = {}
        if 'customization_id' in _dict:
            args['customization_id'] = _dict.get('customization_id')
        else:
            raise ValueError(
                'Required property \'customization_id\' not present in VoiceModel JSON'
            )
        if 'name' in _dict:
            args['name'] = _dict.get('name')
        if 'language' in _dict:
            args['language'] = _dict.get('language')
        if 'owner' in _dict:
            args['owner'] = _dict.get('owner')
        if 'created' in _dict:
            args['created'] = _dict.get('created')
        if 'last_modified' in _dict:
            args['last_modified'] = _dict.get('last_modified')
        if 'description' in _dict:
            args['description'] = _dict.get('description')
        if 'words' in _dict:
            args['words'] = [Word._from_dict(x) for x in (_dict.get('words'))]
        return cls(**args)
393604
def localize(dt, tz):
    
    if not isinstance(tz, tzinfo):
        tz = pytz.timezone(tz)

    return tz.localize(dt)
589117
def _encode_dict(d):
    """"""
    def enc(x):
        if isinstance(x, six.text_type):
            return x.encode(_ENCODING)
        else:
            return x

    return dict((enc(k), enc(v)) for k, v in six.iteritems(d))