diff options
author | Joel Fernandes <joelaf@google.com> | 2017-06-29 14:28:01 -0700 |
---|---|---|
committer | Joel Fernandes <joelaf@google.com> | 2017-06-29 14:28:01 -0700 |
commit | fd162b6790ae666d00624faa339e402a11e16e1d (patch) | |
tree | 63190954ffc31c9be6117afd219b077d43949ead | |
parent | c81a3b1eb6a8b4fe9a2b137d838f68872548e306 (diff) | |
download | trappy-fd162b6790ae666d00624faa339e402a11e16e1d.tar.gz |
Revert "trappy: Optimize integer conversion in generate_data_dict"
This reverts commit c0a49a16d85ef5b732fafe02faad73c67df7b665.
-rw-r--r-- | trappy/base.py | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/trappy/base.py b/trappy/base.py index 3c4c7bd..4f06af2 100644 --- a/trappy/base.py +++ b/trappy/base.py @@ -179,12 +179,6 @@ class Base(object): self.line_array.append(line) self.data_array.append(data) - def conv_to_int(self, value): - # Handle false-positives for negative numbers - if value.lstrip("-").isdigit(): - value = int(value) - return value - def generate_data_dict(self, data_str): data_dict = {} prev_key = None @@ -196,7 +190,10 @@ class Base(object): data_dict[prev_key] += ' ' + field continue (key, value) = field.split('=', 1) - value = self.conv_to_int(value) + try: + value = int(value) + except ValueError: + pass data_dict[key] = value prev_key = key return data_dict |