def test14_remove_folder(self): # Create hierarchy vfs.make_folder('tests/folder') vfs.make_folder('tests/folder/a') vfs.make_file('tests/folder/a/hello.txt') # Remove and test vfs.remove('tests/folder') self.assertEqual(vfs.exists('tests/folder'), False)
def test21_write_and_truncate(self): # Initialize file = vfs.make_file('tests/toto.txt') try: file.write('hello\n') finally: file.close() # Test file = vfs.open('tests/toto.txt', WRITE) try: file.write('bye\n') finally: file.close() self.assertEqual(open('tests/toto.txt').read(), 'bye\n') # Remove temporary file vfs.remove('tests/toto.txt')
def test20_append(self): # Initialize file = vfs.make_file('tests/toto.txt') try: file.write('hello\n') finally: file.close() # Test file = vfs.open('tests/toto.txt', APPEND) try: file.write('bye\n') finally: file.close() self.assertEqual(open('tests/toto.txt').read(), 'hello\nbye\n') # Remove temporary file vfs.remove('tests/toto.txt')
def save_state_to(self, key): database = self.database # If there is an empty folder in the given key, remove it fs = database.fs if database is not None else vfs if fs.is_folder(key) and not fs.get_names(key): fs.remove(key) # Save the file if database: key = database.normalize_key(key) file = database.fs.make_file(key) else: file = vfs.make_file(key) try: self.save_state_to_file(file) finally: file.close()
def test06_make_file(self): vfs.make_file('tests/file') self.assertEqual(vfs.is_file('tests/file'), True)
def safe_make_file(self, reference): if self.database is None: return vfs.make_file(reference) return self.database.safe_make_file(reference)
units = list(units) except Exception: print print '*' print '* Error:', path print '*' raise relative_path = Path('..').resolve2(path) for source, context, line in units: po.add_unit(relative_path, source, context, line) print # Update locale.pot if not vfs.exists('locale/locale.pot'): vfs.make_file('locale/locale.pot') write('* Update PO template ') data = po.to_str() file = vfs.open('locale/locale.pot', WRITE) try: file.write(data) finally: file.close() print # Update PO files folder = vfs.open('locale') filenames = set([x for x in folder.get_names() if x[-3:] == '.po']) filenames.add('%s.po' % src_language) for language in config.get_value('target_languages'):
units = list(units) except Exception: print print '*' print '* Error:', path print '*' raise relative_path = Path('..').resolve2(path) for source, context, line in units: po.add_unit(relative_path, source, context, line) print # Update locale.pot if not vfs.exists('locale/locale.pot'): vfs.make_file('locale/locale.pot') write('* Update PO template ') data = po.to_str() file = vfs.open('locale/locale.pot', WRITE) try: file.write(data) finally: file.close() print # Update PO files folder = vfs.open('locale') filenames = set([ x for x in folder.get_names() if x[-3:] == '.po' ]) filenames.add('%s.po' % src_language) for language in config.get_value('target_languages'):