Repository: python-babel/babel (python)

Issue:
Very small decimal with disabled decimal_quantization
How to reproduce:
```
from babel.numbers import format_decimal
from decimal import Decimal

format_decimal(Decimal('0.00000011'), locale='en', decimal_quantization=False)
```
Result:
```
  File "babel/numbers.py", line 386, in format_decimal
    number, locale, decimal_quantization=decimal_quantization)
  File "babel/numbers.py", line 857, in apply
    number = self._quantize_value(value, locale, frac_prec)
  File "babel/numbers.py", line 930, in _quantize_value
    self._format_frac(b or '0', locale, frac_prec))
  File "babel/numbers.py", line 937, in _format_frac
    if max == 0 or (min == 0 and int(value) == 0):
ValueError: invalid literal for int() with base 10: '1E-7'
```
My solution:
```
def _quantize_value(self, value, locale, frac_prec):
    quantum = get_decimal_quantum(frac_prec[1])
    rounded = value.quantize(quantum)
    # a, sep, b = str(rounded).partition(".")
    a, sep, b = "{:f}".format(rounded).partition(".")
    number = (self._format_int(a, self.int_prec[0],
                               self.int_prec[1], locale) +
              self._format_frac(b or '0', locale, frac_prec))
    return number
```

Pull request description:
Fix amalgamation
Includes the code from these two PRs:

* Closes #662
  * Resolves #636 
* Closes #678 

Patch:
diff --git a/babel/messages/extract.py b/babel/messages/extract.py
index db429b2..e7d7ad7 100644
--- a/babel/messages/extract.py
+++ b/babel/messages/extract.py
@@ -236,9 +236,12 @@ def extract_from_file(method, filename, keywords=DEFAULT_KEYWORDS,
     :returns: list of tuples of the form ``(lineno, message, comments, context)``
     :rtype: list[tuple[int, str|tuple[str], list[str], str|None]
     """
+    if method == 'ignore':
+        return []
+
     with open(filename, 'rb') as fileobj:
-        return list(extract(method, fileobj, keywords, comment_tags, options,
-                            strip_comment_tags))
+        return list(extract(method, fileobj, keywords, comment_tags,
+                            options, strip_comment_tags))
 
 
 def extract(method, fileobj, keywords=DEFAULT_KEYWORDS, comment_tags=(),
diff --git a/babel/numbers.py b/babel/numbers.py
index 6888c9c..cf819fc 100644
--- a/babel/numbers.py
+++ b/babel/numbers.py
@@ -1063,7 +1063,7 @@ class NumberPattern(object):
     def _quantize_value(self, value, locale, frac_prec):
         quantum = get_decimal_quantum(frac_prec[1])
         rounded = value.quantize(quantum)
-        a, sep, b = str(rounded).partition(".")
+        a, sep, b = "{:f}".format(rounded).partition(".")
         number = (self._format_int(a, self.int_prec[0],
                                    self.int_prec[1], locale) +
                   self._format_frac(b or '0', locale, frac_prec))


Test patch:
diff --git a/tests/test_numbers.py b/tests/test_numbers.py
index 6e26fe9..a980a66 100644
--- a/tests/test_numbers.py
+++ b/tests/test_numbers.py
@@ -690,3 +690,7 @@ def test_parse_decimal_nbsp_heuristics():
     n = decimal.Decimal("12345.123")
     assert numbers.parse_decimal("12 345.123", locale="fi") == n
     assert numbers.parse_decimal(numbers.format_decimal(n, locale="fi"), locale="fi") == n
+
+
+def test_very_small_decimal_no_quantization():
+    assert numbers.format_decimal(decimal.Decimal('1E-7'), locale='en', decimal_quantization=False) == '0.0000001'