# Path: pysaliency/quilt.py
# class PatchFile(object):
#     def __init__(self, patch):
#         self.diffs = []
#         lines = patch.split('\n')
#         while lines:
#             index1 = lines.pop(0)
#             assert index1.startswith('Index: ')
#             index2 = lines.pop(0)
#             assert index2.startswith('==============')
#             diff = []
#             diff.append(lines.pop(0))
#             while lines and not lines[0].startswith('Index: '):
#                 diff.append(lines.pop(0))
#             diff_obj = Diff(diff)
#             self.diffs.append(diff_obj)
# 
#     def apply(self, location, verbose=True):
#         for diff in self.diffs:
#             if verbose:
#                 print("Patching {}".format(diff.source_filename))
#             diff.apply(location)
# 
# class QuiltSeries(object):
#     def __init__(self, patches_location):
#         self.patches_location = patches_location
#         series = open(os.path.join(self.patches_location, 'series')).read()
#         self.patches = []
#         self.patch_names = []
#         for line in series.split('\n'):
#             if not line:
#                 continue
#             patch_content = open(os.path.join(self.patches_location, line)).read()
#             self.patches.append(PatchFile(patch_content))
#             self.patch_names.append(line)
# 
#     def apply(self, location, verbose=True):
#         for patch, name in zip(self.patches, self.patch_names):
#             if verbose:
#                 print("Applying {}".format(name))
#             patch.apply(location, verbose=verbose)


import os
import shutil
import filecmp
import unittest
from pysaliency.quilt import PatchFile, QuiltSeries
from test_helpers import TestWithData, assertDirsEqual
from __future__ import print_function, division, unicode_literals, absolute_import





class TestPatchFile(TestWithData):
    def test_parsing(self):
        p = open('tests/test_quilt/patches/add_numbers.diff').read()

# Path: pysaliency/quilt.py
# class PatchFile(object):
#     def __init__(self, patch):
#         self.diffs = []
#         lines = patch.split('\n')
#         while lines:
#             index1 = lines.pop(0)
#             assert index1.startswith('Index: ')
#             index2 = lines.pop(0)
#             assert index2.startswith('==============')
#             diff = []
#             diff.append(lines.pop(0))
#             while lines and not lines[0].startswith('Index: '):
#                 diff.append(lines.pop(0))
#             diff_obj = Diff(diff)
#             self.diffs.append(diff_obj)
# 
#     def apply(self, location, verbose=True):
#         for diff in self.diffs:
#             if verbose:
#                 print("Patching {}".format(diff.source_filename))
#             diff.apply(location)
# 
# class QuiltSeries(object):
#     def __init__(self, patches_location):
#         self.patches_location = patches_location
#         series = open(os.path.join(self.patches_location, 'series')).read()
#         self.patches = []
#         self.patch_names = []
#         for line in series.split('\n'):
#             if not line:
#                 continue
#             patch_content = open(os.path.join(self.patches_location, line)).read()
#             self.patches.append(PatchFile(patch_content))
#             self.patch_names.append(line)
# 
#     def apply(self, location, verbose=True):
#         for patch, name in zip(self.patches, self.patch_names):
#             if verbose:
#                 print("Applying {}".format(name))
#             patch.apply(location, verbose=verbose)


# Path: tests/test_quilt.py
import os
import shutil
import filecmp
import unittest
from pysaliency.quilt import PatchFile, QuiltSeries
from test_helpers import TestWithData, assertDirsEqual

from __future__ import print_function, division, unicode_literals, absolute_import





class TestPatchFile(TestWithData):
    def test_parsing(self):
        p = open('tests/test_quilt/patches/add_numbers.diff').read()

        patch = PatchFile(p)