Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(46)  |  Call(46)  |  Derive(0)  |  Import(0)
Parse number format patterns

        def parse_pattern(pattern):
    """Parse number format patterns"""
    if isinstance(pattern, NumberPattern):
        return pattern

    def _match_number(pattern):
        rv = number_re.search(pattern)
        if rv is None:
            raise ValueError('Invalid number pattern %r' % pattern)
        return rv.groups()

    # Do we have a negative subpattern?
    if ';' in pattern:
        pattern, neg_pattern = pattern.split(';', 1)
        pos_prefix, number, pos_suffix = _match_number(pattern)
        neg_prefix, _, neg_suffix = _match_number(neg_pattern)
    else:
        pos_prefix, number, pos_suffix = _match_number(pattern)
        neg_prefix = '-' + pos_prefix
        neg_suffix = pos_suffix
    if 'E' in number:
        number, exp = number.split('E', 1)
    else:
        exp = None
    if '@' in number:
        if '.' in number and '0' in number:
            raise ValueError('Significant digit patterns can not contain '
                             '"@" or "0"')
    if '.' in number:
        integer, fraction = number.rsplit('.', 1)
    else:
        integer = number
        fraction = ''

    def parse_precision(p):
        """Calculate the min and max allowed digits"""
        min = max = 0
        for c in p:
            if c in '@0':
                min += 1
                max += 1
            elif c == '#':
                max += 1
            elif c == ',':
                continue
            else:
                break
        return min, max

    int_prec = parse_precision(integer)
    frac_prec = parse_precision(fraction)
    if exp:
        frac_prec = parse_precision(integer+fraction)
        exp_plus = exp.startswith('+')
        exp = exp.lstrip('+')
        exp_prec = parse_precision(exp)
    else:
        exp_plus = None
        exp_prec = None
    grouping = parse_grouping(integer)
    return NumberPattern(pattern, (pos_prefix, neg_prefix),
                         (pos_suffix, neg_suffix), grouping,
                         int_prec, frac_prec,
                         exp_prec, exp_plus)
        


src/f/j/fjord-HEAD/vendor/packages/Babel/scripts/import_cldr.py   fjord(Download)
                continue
            pattern = text_type(elem.findtext('./decimalFormat/pattern'))
            decimal_formats[elem.attrib.get('type')] = numbers.parse_pattern(pattern)
 
        scientific_formats = data.setdefault('scientific_formats', {})
                continue
            pattern = text_type(elem.findtext('scientificFormat/pattern'))
            scientific_formats[elem.attrib.get('type')] = numbers.parse_pattern(pattern)
 
        currency_formats = data.setdefault('currency_formats', {})
                continue
            pattern = text_type(elem.findtext('currencyFormat/pattern'))
            currency_formats[elem.attrib.get('type')] = numbers.parse_pattern(pattern)
 
        percent_formats = data.setdefault('percent_formats', {})
                continue
            pattern = text_type(elem.findtext('percentFormat/pattern'))
            percent_formats[elem.attrib.get('type')] = numbers.parse_pattern(pattern)
 
        currency_names = data.setdefault('currency_names', {})

src/z/e/ZenPacks.zenoss.OpenStack-HEAD/src/Babel-1.3/scripts/import_cldr.py   ZenPacks.zenoss.OpenStack(Download)
                continue
            pattern = text_type(elem.findtext('./decimalFormat/pattern'))
            decimal_formats[elem.attrib.get('type')] = numbers.parse_pattern(pattern)
 
        scientific_formats = data.setdefault('scientific_formats', {})
                continue
            pattern = text_type(elem.findtext('scientificFormat/pattern'))
            scientific_formats[elem.attrib.get('type')] = numbers.parse_pattern(pattern)
 
        currency_formats = data.setdefault('currency_formats', {})
                continue
            pattern = text_type(elem.findtext('currencyFormat/pattern'))
            currency_formats[elem.attrib.get('type')] = numbers.parse_pattern(pattern)
 
        percent_formats = data.setdefault('percent_formats', {})
                continue
            pattern = text_type(elem.findtext('percentFormat/pattern'))
            percent_formats[elem.attrib.get('type')] = numbers.parse_pattern(pattern)
 
        currency_names = data.setdefault('currency_names', {})

src/h/u/hue-HEAD/desktop/core/ext-py/Babel-0.9.6/scripts/import_cldr.py   hue(Download)
                continue
            pattern = unicode(elem.findtext('decimalFormat/pattern'))
            decimal_formats[elem.attrib.get('type')] = numbers.parse_pattern(pattern)
 
        scientific_formats = data.setdefault('scientific_formats', {})
                continue
            pattern = unicode(elem.findtext('scientificFormat/pattern'))
            scientific_formats[elem.attrib.get('type')] = numbers.parse_pattern(pattern)
 
        currency_formats = data.setdefault('currency_formats', {})
                continue
            pattern = unicode(elem.findtext('currencyFormat/pattern'))
            currency_formats[elem.attrib.get('type')] = numbers.parse_pattern(pattern)
 
        percent_formats = data.setdefault('percent_formats', {})
                continue
            pattern = unicode(elem.findtext('percentFormat/pattern'))
            percent_formats[elem.attrib.get('type')] = numbers.parse_pattern(pattern)
 
        currency_names = data.setdefault('currency_names', {})

src/b/a/Babel-1.3/scripts/import_cldr.py   Babel(Download)
                continue
            pattern = text_type(elem.findtext('./decimalFormat/pattern'))
            decimal_formats[elem.attrib.get('type')] = numbers.parse_pattern(pattern)
 
        scientific_formats = data.setdefault('scientific_formats', {})
                continue
            pattern = text_type(elem.findtext('scientificFormat/pattern'))
            scientific_formats[elem.attrib.get('type')] = numbers.parse_pattern(pattern)
 
        currency_formats = data.setdefault('currency_formats', {})
                continue
            pattern = text_type(elem.findtext('currencyFormat/pattern'))
            currency_formats[elem.attrib.get('type')] = numbers.parse_pattern(pattern)
 
        percent_formats = data.setdefault('percent_formats', {})
                continue
            pattern = text_type(elem.findtext('percentFormat/pattern'))
            percent_formats[elem.attrib.get('type')] = numbers.parse_pattern(pattern)
 
        currency_names = data.setdefault('currency_names', {})

src/h/o/hortonworks-sandbox-HEAD/desktop/core/ext-py/Babel-0.9.6/scripts/import_cldr.py   hortonworks-sandbox(Download)
                continue
            pattern = unicode(elem.findtext('decimalFormat/pattern'))
            decimal_formats[elem.attrib.get('type')] = numbers.parse_pattern(pattern)
 
        scientific_formats = data.setdefault('scientific_formats', {})
                continue
            pattern = unicode(elem.findtext('scientificFormat/pattern'))
            scientific_formats[elem.attrib.get('type')] = numbers.parse_pattern(pattern)
 
        currency_formats = data.setdefault('currency_formats', {})
                continue
            pattern = unicode(elem.findtext('currencyFormat/pattern'))
            currency_formats[elem.attrib.get('type')] = numbers.parse_pattern(pattern)
 
        percent_formats = data.setdefault('percent_formats', {})
                continue
            pattern = unicode(elem.findtext('percentFormat/pattern'))
            percent_formats[elem.attrib.get('type')] = numbers.parse_pattern(pattern)
 
        currency_names = data.setdefault('currency_names', {})

src/k/i/kitsune-HEAD/vendor/packages/Babel/scripts/import_cldr.py   kitsune(Download)
                continue
            pattern = unicode(elem.findtext('decimalFormat/pattern'))
            decimal_formats[elem.attrib.get('type')] = numbers.parse_pattern(pattern)
 
        scientific_formats = data.setdefault('scientific_formats', {})
                continue
            pattern = unicode(elem.findtext('scientificFormat/pattern'))
            scientific_formats[elem.attrib.get('type')] = numbers.parse_pattern(pattern)
 
        currency_formats = data.setdefault('currency_formats', {})
                continue
            pattern = unicode(elem.findtext('currencyFormat/pattern'))
            currency_formats[elem.attrib.get('type')] = numbers.parse_pattern(pattern)
 
        percent_formats = data.setdefault('percent_formats', {})
                continue
            pattern = unicode(elem.findtext('percentFormat/pattern'))
            percent_formats[elem.attrib.get('type')] = numbers.parse_pattern(pattern)
 
        currency_names = data.setdefault('currency_names', {})

src/w/e/webapp-improved-HEAD/lib/babel/scripts/import_cldr.py   webapp-improved(Download)
                continue
            pattern = unicode(elem.findtext('decimalFormat/pattern'))
            decimal_formats[elem.attrib.get('type')] = numbers.parse_pattern(pattern)
 
        scientific_formats = data.setdefault('scientific_formats', {})
                continue
            pattern = unicode(elem.findtext('scientificFormat/pattern'))
            scientific_formats[elem.attrib.get('type')] = numbers.parse_pattern(pattern)
 
        currency_formats = data.setdefault('currency_formats', {})
                continue
            pattern = unicode(elem.findtext('currencyFormat/pattern'))
            currency_formats[elem.attrib.get('type')] = numbers.parse_pattern(pattern)
 
        percent_formats = data.setdefault('percent_formats', {})
                continue
            pattern = unicode(elem.findtext('percentFormat/pattern'))
            percent_formats[elem.attrib.get('type')] = numbers.parse_pattern(pattern)
 
        currency_names = data.setdefault('currency_names', {})

src/k/u/kuma-lib-HEAD/packages/Babel/scripts/import_cldr.py   kuma-lib(Download)
                continue
            pattern = unicode(elem.findtext('decimalFormat/pattern'))
            decimal_formats[elem.attrib.get('type')] = numbers.parse_pattern(pattern)
 
        scientific_formats = data.setdefault('scientific_formats', {})
                continue
            pattern = unicode(elem.findtext('scientificFormat/pattern'))
            scientific_formats[elem.attrib.get('type')] = numbers.parse_pattern(pattern)
 
        currency_formats = data.setdefault('currency_formats', {})
                continue
            pattern = unicode(elem.findtext('currencyFormat/pattern'))
            currency_formats[elem.attrib.get('type')] = numbers.parse_pattern(pattern)
 
        percent_formats = data.setdefault('percent_formats', {})
                continue
            pattern = unicode(elem.findtext('percentFormat/pattern'))
            percent_formats[elem.attrib.get('type')] = numbers.parse_pattern(pattern)
 
        currency_names = data.setdefault('currency_names', {})

src/i/n/input-lib-HEAD/packages/Babel/scripts/import_cldr.py   input-lib(Download)
                continue
            pattern = unicode(elem.findtext('decimalFormat/pattern'))
            decimal_formats[elem.attrib.get('type')] = numbers.parse_pattern(pattern)
 
        scientific_formats = data.setdefault('scientific_formats', {})
                continue
            pattern = unicode(elem.findtext('scientificFormat/pattern'))
            scientific_formats[elem.attrib.get('type')] = numbers.parse_pattern(pattern)
 
        currency_formats = data.setdefault('currency_formats', {})
                continue
            pattern = unicode(elem.findtext('currencyFormat/pattern'))
            currency_formats[elem.attrib.get('type')] = numbers.parse_pattern(pattern)
 
        percent_formats = data.setdefault('percent_formats', {})
                continue
            pattern = unicode(elem.findtext('percentFormat/pattern'))
            percent_formats[elem.attrib.get('type')] = numbers.parse_pattern(pattern)
 
        currency_names = data.setdefault('currency_names', {})

src/b/a/babel-HEAD/scripts/import_cldr.py   babel(Download)
                continue
            pattern = unicode(elem.findtext('decimalFormat/pattern'))
            decimal_formats[elem.attrib.get('type')] = numbers.parse_pattern(pattern)
 
        scientific_formats = data.setdefault('scientific_formats', {})
                continue
            pattern = unicode(elem.findtext('scientificFormat/pattern'))
            scientific_formats[elem.attrib.get('type')] = numbers.parse_pattern(pattern)
 
        currency_formats = data.setdefault('currency_formats', {})
                continue
            pattern = unicode(elem.findtext('currencyFormat/pattern'))
            currency_formats[elem.attrib.get('type')] = numbers.parse_pattern(pattern)
 
        percent_formats = data.setdefault('percent_formats', {})
                continue
            pattern = unicode(elem.findtext('percentFormat/pattern'))
            percent_formats[elem.attrib.get('type')] = numbers.parse_pattern(pattern)
 
        currency_names = data.setdefault('currency_names', {})

  1 | 2  Next