Skip to content
This repository has been archived by the owner on Dec 16, 2021. It is now read-only.

Commit

Permalink
[Telegraf] Missing dependency in filters
Browse files Browse the repository at this point in the history
  • Loading branch information
nervo committed Oct 21, 2020
1 parent 241c115 commit a4651da
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]
### Fixed
- Missing dependency in filters

## [2.0.7] - 2020-10-20
### Added
Expand Down
16 changes: 9 additions & 7 deletions filter_plugins/manala_telegraf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,16 @@

import re

"""
Config Encoder Filters
More information: https://github.com/jtyr/ansible-config_encoder_filters
"""

try:
basestring
except NameError:
basestring = str

# See: https://github.com/jtyr/ansible-config_encoder_filters
def _is_num(data):
"""Verify if data is either int or float.
Could be replaced by:
Expand All @@ -18,7 +26,6 @@ def _is_num(data):

return isinstance(data, int) or isinstance(data, float)

# See: https://github.com/jtyr/ansible-config_encoder_filters
def _escape(data, quote='"', format=None):
"""Escape special characters in a string."""

Expand All @@ -41,33 +48,28 @@ def _escape(data, quote='"', format=None):
else:
return data

# See: https://github.com/jtyr/ansible-config_encoder_filters
def _str_is_int(data):
"""Verify if data is integer."""

return re.match(r"^[-+]?(0|[1-9][0-9]*)$", str(data))

# See: https://github.com/jtyr/ansible-config_encoder_filters
def _str_is_float(data):
"""Verify if data is float."""

return re.match(
r"^[-+]?(0|[1-9][0-9]*)(\.[0-9]*)?(e[-+]?[0-9]+)?$",
str(data), flags=re.IGNORECASE)

# See: https://github.com/jtyr/ansible-config_encoder_filters
def _str_is_num(data):
"""Verify if data is either integer or float."""

return _str_is_int(data) or _str_is_float(data)

# See: https://github.com/jtyr/ansible-config_encoder_filters
def _str_is_bool(data):
"""Verify if data is boolean."""

return re.match(r"^(true|false)$", str(data), flags=re.IGNORECASE)

# See: https://github.com/jtyr/ansible-config_encoder_filters
def encode_toml(
data, convert_bools=False, convert_nums=False, first=True, quote='"',
table_name="", table_type=None):
Expand Down

0 comments on commit a4651da

Please sign in to comment.