]> git.evergreen-ils.org Git - Evergreen.git/blob - build/i18n/tests/testhelper.py
44f5007b63199e4615fbbbc3e9c413854fcd7061
[Evergreen.git] / build / i18n / tests / testhelper.py
1 import os
2 import re
3 import sys
4
5 def mungepothead(file):
6     """
7     Change POT header to avoid annoying timestamp mismatch
8     """
9     lines = [] 
10     mungefile = open(file)
11     for line in mungefile:
12         line = re.sub(r'^("POT-Creation-Date: ).+"$', r'\1', line)
13         lines.append(line)
14     mungefile.close()
15
16     # Write the changed lines back out
17     mungefile = open(file, 'w')
18     for line in lines:
19         mungefile.write(line)
20     mungefile.close()
21
22 def setUp(self):
23     sys.path.append(os.path.join(self.basedir, '../scripts/'))
24     sys.path.append(self.basedir)
25     self.tearDown()
26     for dir in self.tmpdirs:
27         os.mkdir(dir)
28
29 def tearDown(self):
30     for dir in self.tmpdirs:
31         if os.access(dir, os.F_OK):
32             for file in os.listdir(dir):
33                 os.remove(os.path.join(dir, file))
34             os.rmdir(dir)
35
36