Code Duplication    Length = 15-17 lines in 2 locations

tests/test_hooks.py 2 locations

@@ 39-55 (lines=17) @@
36
        f.write("f = open('python_pre.txt', 'w')\n")
37
        f.write("f.close()\n")
38
39
    if sys.platform.startswith('win'):
40
        post = 'post_gen_project.bat'
41
        with open(os.path.join(hook_dir, post), 'w') as f:
42
            f.write("@echo off\n")
43
            f.write("\n")
44
            f.write("echo post generation hook\n")
45
            f.write("echo. >shell_post.txt\n")
46
    else:
47
        post = 'post_gen_project.sh'
48
        filename = os.path.join(hook_dir, post)
49
        with open(filename, 'w') as f:
50
            f.write("#!/bin/bash\n")
51
            f.write("\n")
52
            f.write("echo 'post generation hook';\n")
53
            f.write("touch 'shell_post.txt'\n")
54
        # Set the execute bit
55
        os.chmod(filename, os.stat(filename).st_mode | stat.S_IXUSR)
56
57
    return post
58
@@ 143-157 (lines=15) @@
140
141
        hook_path = os.path.join(self.hooks_path, 'post_gen_project.sh')
142
143
        if sys.platform.startswith('win'):
144
            post = 'post_gen_project.bat'
145
            with open(os.path.join(self.hooks_path, post), 'w') as f:
146
                f.write("@echo off\n")
147
                f.write("\n")
148
                f.write("echo post generation hook\n")
149
                f.write("echo. >{{cookiecutter.file}}\n")
150
        else:
151
            with open(hook_path, 'w') as fh:
152
                fh.write("#!/bin/bash\n")
153
                fh.write("\n")
154
                fh.write("echo 'post generation hook';\n")
155
                fh.write("touch 'shell_post.txt'\n")
156
                fh.write("touch '{{cookiecutter.file}}'\n")
157
                os.chmod(hook_path, os.stat(hook_path).st_mode | stat.S_IXUSR)
158
159
        hooks.run_script_with_context(
160
            os.path.join(self.hooks_path, self.post_hook),