Back to index

plone3  3.1.7
utils.py
Go to the documentation of this file.
00001 import re
00002 import glob
00003 from unittest import TestSuite
00004 from sys import modules
00005 from os.path import join, abspath, dirname, basename
00006 
00007 def normalize_html(s):
00008     s = re.sub(r"\s+", " ", s)
00009     s = re.sub(r"(?s)\s+<", "<", s)
00010     s = re.sub(r"(?s)>\s+", ">", s)
00011     s = re.sub(r"\r", "", s)
00012     return s
00013 
00014 PREFIX = abspath(dirname(__file__))
00015 
00016 def input_file_path(file):
00017     return join(PREFIX, 'input', file)
00018 
00019 def output_file_path(file):
00020     return join(PREFIX, 'output', file)
00021 
00022 def matching_inputs(pattern):
00023     return [basename(path) for path in glob.glob(join(PREFIX, "input", pattern))]
00024 
00025 def load(dotted_name, globals=None):
00026     """ load a python module from it's name """
00027     mod = __import__(dotted_name, globals)
00028     components = dotted_name.split('.')
00029     for comp in components[1:]:
00030         mod = getattr(mod, comp)
00031     return mod