<commit_before># -*- coding: utf-8 -*-
"""
Homeshick castle which reimplements (some of) the features of homeshick
"""
import logging
import os
import os.path
import pathlib
from homeslick.castle import Castle

DEV_LOGGER = logging.getLogger(__name__)

def _is_link_to(test_path, dest_path):
    '''
    Return true if test_path is a symlink that points to dest_path
    '''
    try:
        resolved_dest_path = dest_path.resolve()
    except FileNotFoundError as resolve_dest_exception:
        try:
            test_path.resolve()
        except FileNotFoundError as resolve_test_exception:
            return resolve_test_exception.filename == resolve_dest_exception.filename
        else:
            return False
    else:
        try:
            resolved_test_path = test_path.resolve()
        except FileNotFoundError:
            return False
        else:
            return resolved_dest_path == resolved_test_path


class Homeshick(Castle):
    """
    Homeshick castle which reimplements (some of) the features of homeshick
    """
    def _symlink_iterator(self, castle_path, home_path):
        for sub_path in castle_path.iterdir():
            castle_sub_path = sub_path
            home_sub_path = home_path / sub_path.name
            yield castle_sub_path, home_sub_path

            if sub_path.is_dir():
                yield from self._symlink_iterator(castle_sub_path, home_sub_path) # NOQA

    def _symlink_directory(self, castle_path, home_path):
        '''
        Handle symlinking for case where castle entry is a directory
        '''<commit_msg>Add symlinking after pull or init<commit_after># -*- coding: utf-8 -*-
"""
Homeshick castle which reimplements (some of) the features of homeshick
"""
import logging
import os
import os.path
import pathlib
from homeslick.castle import Castle

DEV_LOGGER = logging.getLogger(__name__)

def _is_link_to(test_path, dest_path):
    '''
    Return true if test_path is a symlink that points to dest_path
    '''
    try:
        resolved_dest_path = dest_path.resolve()
    except FileNotFoundError as resolve_dest_exception:
        try:
            test_path.resolve()
        except FileNotFoundError as resolve_test_exception:
            return resolve_test_exception.filename == resolve_dest_exception.filename
        else:
            return False
    else:
        try:
            resolved_test_path = test_path.resolve()
        except FileNotFoundError:
            return False
        else:
            return resolved_dest_path == resolved_test_path


class Homeshick(Castle):
    """
    Homeshick castle which reimplements (some of) the features of homeshick
    """
    def pull():
        super().pull()
        self.symlink()

    def init():
        self.init()
        self.symlink()

    def _symlink_iterator(self, castle_path, home_path):
        for sub_path in castle_path.iterdir():
            castle_sub_path = sub_path
            home_sub_path = home_path / sub_path.name
            yield castle_sub_path, home_sub_path

            if sub_path.is_dir():
                yield from self._symlink_iterator(castle_sub_path, home_sub_path) # NOQA

    def _symlink_directory(self, castle_path, home_path):
        '''
        Handle symlinking for case where castle entry is a directory
        '''
{'fraction_non_alphanumeric': 0.07084468664850137, 'fraction_numerical': 0.0006055101422948834, 'mean_word_length': 2.58351409978308, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2321358', 'n_tokens_mistral': 932, 'n_tokens_neox': 927, 'n_words': 255}