# Path: pytrustnfe/xml/filters.py
# def normalize_str(string):
#     """
#     Remove special characters and strip spaces
#     """
#     if string:
#         if not isinstance(string, str):
#             string = str(string, "utf-8", "replace")
# 
#         string = string.encode("utf-8")
#         return (
#             normalize("NFKD", string.decode("utf-8")).encode("ASCII", "ignore").decode()
#         )
#     return ""
# 
# Path: pytrustnfe/xml/filters.py
# def strip_line_feed(string):
#     if string:
#         if not isinstance(string, str):
#             string = str(string, "utf-8", "replace")
#         remap = {
#             ord("\t"): " ",
#             ord("\n"): " ",
#             ord("\f"): " ",
#             ord("\r"): None,  # Delete
#         }
#         return string.translate(remap).strip()
#     return string
# 
# Path: pytrustnfe/xml/filters.py
# def format_percent(value):
#     if value:
#         return Decimal(value) / 100
# 
# Path: pytrustnfe/xml/filters.py
# def format_date(value):
#     """
#     Format date
#     """
#     dt_format = "%Y-%m-%d"
#     if isinstance(value, date):
#         return value.strftime(dt_format)
#     return value
# 
# Path: pytrustnfe/xml/filters.py
# def format_datetime(value):
#     """
#     Format datetime
#     """
#     dt_format = "%Y-%m-%dT%H:%M:%I"
#     if isinstance(value, datetime):
#         return value.strftime(dt_format)
#     return value


import unittest
from datetime import datetime
from pytrustnfe.xml.filters import normalize_str
from pytrustnfe.xml.filters import strip_line_feed
from pytrustnfe.xml.filters import format_percent
from pytrustnfe.xml.filters import format_date
from pytrustnfe.xml.filters import format_datetime
# coding=utf-8
"""
Created on Jun 14, 2015

@author: danimar
"""


class test_xmlfilters(unittest.TestCase):
    def test_xmlfilters(self):
        word = normalize_str("ação café pó pá veêm")
        self.assertEqual(word, "acao cafe po pa veem")

# Path: pytrustnfe/xml/filters.py
# def normalize_str(string):
#     """
#     Remove special characters and strip spaces
#     """
#     if string:
#         if not isinstance(string, str):
#             string = str(string, "utf-8", "replace")
# 
#         string = string.encode("utf-8")
#         return (
#             normalize("NFKD", string.decode("utf-8")).encode("ASCII", "ignore").decode()
#         )
#     return ""
# 
# Path: pytrustnfe/xml/filters.py
# def strip_line_feed(string):
#     if string:
#         if not isinstance(string, str):
#             string = str(string, "utf-8", "replace")
#         remap = {
#             ord("\t"): " ",
#             ord("\n"): " ",
#             ord("\f"): " ",
#             ord("\r"): None,  # Delete
#         }
#         return string.translate(remap).strip()
#     return string
# 
# Path: pytrustnfe/xml/filters.py
# def format_percent(value):
#     if value:
#         return Decimal(value) / 100
# 
# Path: pytrustnfe/xml/filters.py
# def format_date(value):
#     """
#     Format date
#     """
#     dt_format = "%Y-%m-%d"
#     if isinstance(value, date):
#         return value.strftime(dt_format)
#     return value
# 
# Path: pytrustnfe/xml/filters.py
# def format_datetime(value):
#     """
#     Format datetime
#     """
#     dt_format = "%Y-%m-%dT%H:%M:%I"
#     if isinstance(value, datetime):
#         return value.strftime(dt_format)
#     return value


# Path: tests/test_xml.py
import unittest
from datetime import datetime
from pytrustnfe.xml.filters import normalize_str
from pytrustnfe.xml.filters import strip_line_feed
from pytrustnfe.xml.filters import format_percent
from pytrustnfe.xml.filters import format_date
from pytrustnfe.xml.filters import format_datetime

# coding=utf-8
"""
Created on Jun 14, 2015

@author: danimar
"""


class test_xmlfilters(unittest.TestCase):
    def test_xmlfilters(self):
        word = normalize_str("ação café pó pá veêm")
        self.assertEqual(word, "acao cafe po pa veem")

        self.assertEqual(1.5, format_percent(150))