# Path: anchorhub/lib/filetolist.py
# class FileToList(object):
#     """
#     FileToList is a helper class used to import text files and turn them into
#     lists, with each index in the list representing a single line from the
#     text file.
#     """
#     @staticmethod
#     def to_list(file_path):
#         """
#         Static method. Takes in a file path, and outputs a list of stings.
#         Each element in the list corresponds to a line in the file.
#         :param file_path: string file path
#         :return: A list of strings, with elements in the list corresponding
#         to lines in the file pointed to in file_path
#         """
#         l = []
#         f = open(file_path, 'r')
#         for line in f:
#             l.append(line)
#         f.close()
#         return l
# 
# Path: anchorhub/util/stripprefix.py
# def strip_prefix(string, strip):
#     """
#     Strips a prefix from a string, if the string starts with the prefix.
# 
#     :param string: String that should have its prefix removed
#     :param strip: Prefix to be removed
#     :return: string with the prefix removed if it has the prefix, or else it
#         just returns the original string
#     """
#     import re
#     strip_esc = re.escape(strip)
#     if re.match(strip_esc, string):
#         return string[len(strip):]
#     else:
#         return string


import os
import os.path
import sys
from abc import ABCMeta, abstractmethod
from anchorhub.lib.filetolist import FileToList
from anchorhub.util.stripprefix import strip_prefix
            # Flip any switches that are triggered by this line
            self._try_switches(lines, i)
            if self._no_switches_on():
                for n, s in enumerate(self._strategies):
                    if s.test(modified_line, lines, i):
                        # Strategy detected that it may modify this line
                        mod = s.modify(modified_line, anchors, file_path)
                        if modified_line != mod:
                            # Strategy modified the line
                            modified_line = mod
                            self._counter[n][0] += 1  # Strategy counter +1
                            file_is_modified = True  # Must rewrite this file
            new_text.append(modified_line)
            self._arm_switches()
        if file_is_modified:
            self._write_with_opts(file_path, new_text, opts)
        return self._counter

    def _write_with_opts(self, file_path, lines, opts):
        """

        :param file_path:
        :param lines:
        :param opts
        """
        if opts.overwrite:
            self._write_file_with_list(file_path, lines)
        else:
            if opts.is_dir:
                # Directory style output

# Path: anchorhub/lib/filetolist.py
# class FileToList(object):
#     """
#     FileToList is a helper class used to import text files and turn them into
#     lists, with each index in the list representing a single line from the
#     text file.
#     """
#     @staticmethod
#     def to_list(file_path):
#         """
#         Static method. Takes in a file path, and outputs a list of stings.
#         Each element in the list corresponds to a line in the file.
#         :param file_path: string file path
#         :return: A list of strings, with elements in the list corresponding
#         to lines in the file pointed to in file_path
#         """
#         l = []
#         f = open(file_path, 'r')
#         for line in f:
#             l.append(line)
#         f.close()
#         return l
# 
# Path: anchorhub/util/stripprefix.py
# def strip_prefix(string, strip):
#     """
#     Strips a prefix from a string, if the string starts with the prefix.
# 
#     :param string: String that should have its prefix removed
#     :param strip: Prefix to be removed
#     :return: string with the prefix removed if it has the prefix, or else it
#         just returns the original string
#     """
#     import re
#     strip_esc = re.escape(strip)
#     if re.match(strip_esc, string):
#         return string[len(strip):]
#     else:
#         return string


# Path: anchorhub/writer.py
import os
import os.path
import sys
from abc import ABCMeta, abstractmethod
from anchorhub.lib.filetolist import FileToList
from anchorhub.util.stripprefix import strip_prefix

            # Flip any switches that are triggered by this line
            self._try_switches(lines, i)
            if self._no_switches_on():
                for n, s in enumerate(self._strategies):
                    if s.test(modified_line, lines, i):
                        # Strategy detected that it may modify this line
                        mod = s.modify(modified_line, anchors, file_path)
                        if modified_line != mod:
                            # Strategy modified the line
                            modified_line = mod
                            self._counter[n][0] += 1  # Strategy counter +1
                            file_is_modified = True  # Must rewrite this file
            new_text.append(modified_line)
            self._arm_switches()
        if file_is_modified:
            self._write_with_opts(file_path, new_text, opts)
        return self._counter

    def _write_with_opts(self, file_path, lines, opts):
        """

        :param file_path:
        :param lines:
        :param opts
        """
        if opts.overwrite:
            self._write_file_with_list(file_path, lines)
        else:
            if opts.is_dir:
                # Directory style output

                write_path = opts.abs_output + strip_prefix(file_path,