예제 #1
0
파일: __init__.py 프로젝트: avanov/Plim
 def test_plim(self):
     cases = [
         'pipe',
         'plim_line',
         'if',
         'unless',
         'python',
         'for',
         'while',
         'until',
         'with',
         'try',
         'def_block',
         'style_script',
         'comment',
         'one_liners',
         'mako_text',
         'early_return',
         'call',
         'multiline_variable',
         'literal_one_liners',
         'no_filtering',
         'linebreak',
         'explicit_space',
         'unicode_attributes',
         'inline_conditions',
         'handlebars',
     ]
     for test_case in cases:
         source = self.get_file_contents(test_case + '_test.plim')
         result = self.get_file_contents(test_case + '_result.mako')
         data = plim.preprocessor(source)
         self.check_relevant_chars(data.strip(), result.strip())
예제 #2
0
파일: __init__.py 프로젝트: spollard/Plim
 def test_plim(self):
     cases = [
         'pipe',
         'plim_line',
         'if',
         'unless',
         'python',
         'for',
         'while',
         'until',
         'with',
         'try',
         'def_block',
         'style_script',
         'comment',
         'one_liners',
         'mako_text',
         'early_return',
         'call',
         'multiline_variable',
         'literal_one_liners',
         'no_filtering',
         'linebreak',
         'explicit_space',
         'unicode_attributes',
         'inline_conditions',
         'handlebars',
     ]
     for test_case in cases:
         source = self.get_file_contents(test_case + '_test.plim')
         result = self.get_file_contents(test_case + '_result.mako')
         data = plim.preprocessor(source)
         self.check_relevant_chars(data.strip(), result.strip())
예제 #3
0
파일: __init__.py 프로젝트: xyb/Plim
 def test_embedded_markup(self):
     test_case = 'embedded'
     source = self.get_file_contents(test_case + '_test.plim')
     result = self.get_file_contents(test_case + '_result.mako')
     data = plim.preprocessor(source)
     # normalize result
     result = result.strip().replace('\n---\n', '')
     self.assertEqual(data.strip(), result)
예제 #4
0
파일: __init__.py 프로젝트: avanov/Plim
 def test_embedded_markup(self):
     test_case = 'embedded'
     source = self.get_file_contents(test_case + '_test.plim')
     result = self.get_file_contents(test_case + '_result.mako')
     data = plim.preprocessor(source)
     # normalize result
     result = result.strip().replace('\n---\n', '')
     self.assertEqual(data.strip(), result)
예제 #5
0
파일: __init__.py 프로젝트: xyb/Plim
 def test_dynamic_attributes(self):
     test_case = 'dynamic_attributes'
     source = self.get_file_contents(test_case + '_test.plim')
     result = self.get_file_contents(test_case + '_result.mako')
     data = plim.preprocessor(source)
     # normalize data
     data = data.replace("<a \n", "<a\n")
     # normalize for Test4
     data = data.replace("\n \n", "\n\n")
     self.assertEqual(data.strip(), result.strip())
예제 #6
0
파일: __init__.py 프로젝트: avanov/Plim
 def test_dynamic_attributes(self):
     test_case = 'dynamic_attributes'
     source = self.get_file_contents(test_case + '_test.plim')
     result = self.get_file_contents(test_case + '_result.mako')
     data = plim.preprocessor(source)
     # normalize data
     data = data.replace("<a \n", "<a\n")
     # normalize for Test4
     data = data.replace("\n \n", "\n\n")
     self.assertEqual(data.strip(), result.strip())
예제 #7
0
파일: gossip.py 프로젝트: jackdesert/arscca
 def html(self, expect_presence=False):
     try:
         with open(f'arscca/templates/gossip/{self.driver_slug}.plim',
                   'r') as gfile:
             text = gfile.read()
             return preprocessor(text)
     except FileNotFoundError as error:
         if expect_presence:
             raise error
         return None
예제 #8
0
파일: __init__.py 프로젝트: xyb/Plim
 def test_inline_loops(self):
     test_case = 'inline_loop'
     source = self.get_file_contents(test_case + '_test.plim')
     result = self.get_file_contents(test_case + '_result.mako')
     data = plim.preprocessor(source)
     self.assertEqual(data.strip(), result.strip())
예제 #9
0
파일: __init__.py 프로젝트: avanov/Plim
 def test_inline_loops(self):
     test_case = 'inline_loop'
     source = self.get_file_contents(test_case + '_test.plim')
     result = self.get_file_contents(test_case + '_result.mako')
     data = plim.preprocessor(source)
     self.assertEqual(data.strip(), result.strip())
예제 #10
0
# AwesomeShop is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License
# along with AwesomeShop. If not, see <http://www.gnu.org/licenses/>.
"""Automatic generation of HTML files from PLIM sources"""

import os
import re

from inotify.adapters import InotifyTree
from plim import preprocessor

FROM='front'
TO='webroot'

i = InotifyTree(FROM)
for event in i.event_gen():
    if event is not None and 'IN_CLOSE_WRITE' in event[1]:
        if event[3].endswith('.plim'):
            filename = os.path.join(event[2], event[3])
            target = re.sub(FROM+'/(.*).plim', TO+r'/\1.html', filename)
            dirname = os.path.dirname(target)
            result = preprocessor(file(filename, 'r').read())
            if not os.path.exists(dirname):
                os.makedirs(dirname)
            file(target, 'w').write(result)
            print "Regenerated", target