We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[Easy] Get rid of pathlib library
Most of the code uses standard `os` library as a filesystem utility but some modules (init.py) use `pathlib`. Let's get rid of `pathlib`. It will unify the code and decrease the package size.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `setup.py`
Content:
```
1 import platform
2 from setuptools import setup, find_packages
3 from distutils.errors import DistutilsPlatformError
4 from dvc import VERSION
5 
6 install_requires = [
7     'altgraph',
8     'appdirs',
9     'backports.shutil-get-terminal-size',
10     'boto',
11     'cachetools',
12     'configparser',
13     'decorator',
14     'dill',
15     'enum34',
16     'fasteners',
17     'funcsigs',
18     'future',
19     'futures',
20     'gapic-google-cloud-datastore-v1',
21     'gapic-google-cloud-error-reporting-v1beta1',
22     'gapic-google-cloud-logging-v2',
23     'gapic-google-cloud-pubsub-v1',
24     'gapic-google-cloud-spanner-admin-database-v1',
25     'gapic-google-cloud-spanner-admin-instance-v1',
26     'gapic-google-cloud-spanner-v1',
27     'gapic-google-cloud-speech-v1beta1',
28     'gapic-google-cloud-vision-v1',
29     'google-auth',
30     'google-auth-httplib2',
31     'google-cloud',
32     'google-cloud-bigquery',
33     'google-cloud-bigtable',
34     'google-cloud-core',
35     'google-cloud-datastore',
36     'google-cloud-dns',
37     'google-cloud-error-reporting',
38     'google-cloud-language',
39     'google-cloud-logging',
40     'google-cloud-monitoring',
41     'google-cloud-pubsub',
42     'google-cloud-resource-manager',
43     'google-cloud-runtimeconfig',
44     'google-cloud-spanner',
45     'google-cloud-speech',
46     'google-cloud-storage',
47     'google-cloud-translate',
48     'google-cloud-vision',
49     'google-gax',
50     'googleapis-common-protos',
51     'grpc-google-iam-v1',
52     'grpcio',
53     'httplib2',
54     'ipython',
55     'ipython-genutils',
56     'macholib',
57     'mock',
58     'modulegraph',
59     'monotonic',
60     'nose',
61     'oauth2client',
62     'packaging',
63     'pathlib',
64     'pathlib2',
65     'pbr',
66     'pexpect',
67     'pickleshare',
68     'ply',
69     'prompt-toolkit',
70     'proto-google-cloud-datastore-v1',
71     'proto-google-cloud-error-reporting-v1beta1',
72     'proto-google-cloud-logging-v2',
73     'proto-google-cloud-pubsub-v1',
74     'proto-google-cloud-spanner-admin-database-v1',
75     'proto-google-cloud-spanner-admin-instance-v1',
76     'proto-google-cloud-spanner-v1',
77     'proto-google-cloud-speech-v1beta1',
78     'proto-google-cloud-vision-v1',
79     'protobuf',
80     'ptyprocess',
81     'pyasn1',
82     'pyasn1-modules',
83     'Pygments',
84     'PyInstaller',
85     'pyparsing',
86     'requests',
87     'rsa',
88     'scandir',
89     'simplegeneric',
90     'six',
91     'traitlets',
92     'wcwidth',
93     'colorama',
94     'google-compute-engine'
95 ]
96 
97 if platform.system() == 'Darwin':
98     install_requires.append('appnope')
99     install_requires.append('py2app')
100 
101 setup(
102     name='dvc',
103     version=VERSION,
104     description='Data Version Control makes your data science projects reproducible and shareable.',
105     author='Dmitry Petrov',
106     author_email='dmitry@dataversioncontrol.com',
107     url='https://github.com/dataversioncontrol/dvc.git',
108     license='Apache License 2.0',
109     install_requires=install_requires,
110     keywords='data science, data version control, machine learning',
111     classifiers=[
112         'Development Status :: 4 - Beta',
113         'Programming Language :: Python :: 2',
114         'Programming Language :: Python :: 3',
115     ],
116     packages=find_packages(exclude=['bin', 'tests', 'functests']),
117     include_package_data=True,
118     download_url='http://dataversioncontrol.com',
119     entry_points={
120         'console_scripts': ['dvc = dvc.main:main']
121     },
122     zip_safe=False
123 )
124
```

Path: `dvc/command/init.py`
Content:
```
1 import os
2 from pathlib import Path
3 
4 from dvc.command.base import CmdBase
5 from dvc.logger import Logger
6 from dvc.config import Config
7 from dvc.exceptions import DvcException
8 from dvc.state_file import StateFile
9 from dvc.system import System
10 
11 
12 class InitError(DvcException):
13     def __init__(self, msg):
14         DvcException.__init__(self, 'Init error: {}'.format(msg))
15 
16 
17 class CmdInit(CmdBase):
18     CONFIG_TEMPLATE = '''[Global]
19 DataDir = {}
20 CacheDir = {}
21 StateDir = {}
22 TargetFile = {}
23 
24 # Supported clouds: AWS, GCP
25 Cloud = AWS
26 StoragePath =
27 
28 # Log levels: Debug, Info, Warning and Error
29 LogLevel = Info
30 
31 [AWS]
32 StoragePath = dvc/tutorial
33 
34 CredentialPath =
35 
36 Region = us-east-1
37 Zone = us-east-1a
38 
39 Image = ami-2d39803a
40 
41 InstanceType = t2.nano
42 
43 SpotPrice =
44 SpotTimeout = 300
45 
46 Storage = my-100gb-drive-io
47 
48 KeyDir = ~/.ssh
49 KeyName = dvc-key
50 
51 SecurityGroup = dvc-group
52 
53 [GCP]
54 StoragePath =
55 ProjectName =
56 '''
57 
58     EMPTY_FILE_NAME = 'empty'
59     EMPTY_FILE_CHECKSUM = '0000000'
60 
61     def __init__(self, settings):
62         super(CmdInit, self).__init__(settings)
63 
64     def get_not_existing_path(self, dir):
65         path = Path(os.path.join(self.git.git_dir, dir))
66         if path.exists():
67             raise InitError('Path "{}" already exist'.format(path.name))
68         return path
69 
70     def get_not_existing_conf_file_name(self):
71         file_name = os.path.join(self.git.git_dir, Config.CONFIG)
72         if os.path.exists(file_name):
73             raise InitError('Configuration file "{}" already exist'.format(file_name))
74         return file_name
75 
76     def run(self):
77         if not self.no_git_actions and not self.git.is_ready_to_go():
78             return 1
79 
80         if os.path.realpath(os.path.curdir) != self.settings.git.git_dir_abs:
81             Logger.error('DVC error: initialization could be done only from git root directory {}'.format(
82                 self.settings.git.git_dir_abs
83             ))
84             return 1
85 
86         data_dir_path = self.get_not_existing_path(self.parsed_args.data_dir)
87         cache_dir_path = self.get_not_existing_path(self.parsed_args.cache_dir)
88         state_dir_path = self.get_not_existing_path(self.parsed_args.state_dir)
89         target_file_path = self.get_not_existing_path(self.parsed_args.target_file)
90 
91         self.settings.config.set(self.parsed_args.data_dir,
92                                  self.parsed_args.cache_dir,
93                                  self.parsed_args.state_dir,
94                                  target_file_path)
95 
96         conf_file_name = self.get_not_existing_conf_file_name()
97 
98         data_dir_path.mkdir()
99         cache_dir_path.mkdir()
100         state_dir_path.mkdir()
101         target_file_path.touch()
102         Logger.info('Directories {}/, {}/, {}/ and target file {} were created'.format(
103             data_dir_path.name,
104             cache_dir_path.name,
105             state_dir_path.name,
106             target_file_path.name))
107 
108         self.create_empty_file()
109 
110         conf_file = open(conf_file_name, 'wt')
111         conf_file.write(self.CONFIG_TEMPLATE.format(data_dir_path.name,
112                                                     cache_dir_path.name,
113                                                     state_dir_path.name,
114                                                     target_file_path.name))
115         conf_file.close()
116 
117         message = 'DVC init. data dir {}, cache dir {}, state dir {}, '.format(
118                         data_dir_path.name,
119                         cache_dir_path.name,
120                         state_dir_path.name
121         )
122         if self.commit_if_needed(message) == 1:
123             return 1
124 
125         self.modify_gitignore(cache_dir_path.name)
126         return self.commit_if_needed('DVC init. Commit .gitignore file')
127 
128     def create_empty_file(self):
129         empty_data_path = os.path.join(self.parsed_args.data_dir, self.EMPTY_FILE_NAME)
130         cache_file_suffix = self.EMPTY_FILE_NAME + '_' + self.EMPTY_FILE_CHECKSUM
131         empty_cache_path = os.path.join(self.parsed_args.cache_dir, cache_file_suffix)
132         empty_state_path = os.path.join(self.parsed_args.state_dir, self.EMPTY_FILE_NAME + '.state')
133 
134         open(empty_cache_path, 'w').close()
135         System.symlink(os.path.join('..', empty_cache_path), empty_data_path)
136 
137         StateFile(StateFile.COMMAND_EMPTY_FILE,
138                   empty_state_path,
139                   self.settings,
140                   input_files=[],
141                   output_files=[],
142                   lock=False).save()
143         pass
144 
145     def modify_gitignore(self, cache_dir_name):
146         gitignore_file = os.path.join(self.git.git_dir, '.gitignore')
147         if not os.path.exists(gitignore_file):
148             open(gitignore_file, 'a').close()
149             Logger.info('File .gitignore was created')
150         with open(gitignore_file, 'a') as fd:
151             fd.write('\n{}'.format(cache_dir_name))
152             fd.write('\n{}'.format(os.path.basename(self.git.lock_file)))
153 
154         Logger.info('Directory {} was added to .gitignore file'.format(cache_dir_name))
155
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/dvc/command/init.py b/dvc/command/init.py
--- a/dvc/command/init.py
+++ b/dvc/command/init.py
@@ -1,5 +1,4 @@
 import os
-from pathlib import Path
 
 from dvc.command.base import CmdBase
 from dvc.logger import Logger
@@ -62,10 +61,10 @@
         super(CmdInit, self).__init__(settings)
 
     def get_not_existing_path(self, dir):
-        path = Path(os.path.join(self.git.git_dir, dir))
-        if path.exists():
-            raise InitError('Path "{}" already exist'.format(path.name))
-        return path
+        path = os.path.join(self.git.git_dir, dir)
+        if os.path.exists(path):
+            raise InitError('Path "{}" already exist'.format(path))
+        return os.path.basename(path), path
 
     def get_not_existing_conf_file_name(self):
         file_name = os.path.join(self.git.git_dir, Config.CONFIG)
@@ -83,10 +82,10 @@
             ))
             return 1
 
-        data_dir_path = self.get_not_existing_path(self.parsed_args.data_dir)
-        cache_dir_path = self.get_not_existing_path(self.parsed_args.cache_dir)
-        state_dir_path = self.get_not_existing_path(self.parsed_args.state_dir)
-        target_file_path = self.get_not_existing_path(self.parsed_args.target_file)
+        data_dir, data_dir_path = self.get_not_existing_path(self.parsed_args.data_dir)
+        cache_dir, cache_dir_path = self.get_not_existing_path(self.parsed_args.cache_dir)
+        state_dir, state_dir_path = self.get_not_existing_path(self.parsed_args.state_dir)
+        target_file, target_file_path = self.get_not_existing_path(self.parsed_args.target_file)
 
         self.settings.config.set(self.parsed_args.data_dir,
                                  self.parsed_args.cache_dir,
@@ -95,34 +94,34 @@
 
         conf_file_name = self.get_not_existing_conf_file_name()
 
-        data_dir_path.mkdir()
-        cache_dir_path.mkdir()
-        state_dir_path.mkdir()
-        target_file_path.touch()
+        os.mkdir(data_dir_path)
+        os.mkdir(cache_dir_path)
+        os.mkdir(state_dir_path)
+        open(target_file_path, 'w').close()
         Logger.info('Directories {}/, {}/, {}/ and target file {} were created'.format(
-            data_dir_path.name,
-            cache_dir_path.name,
-            state_dir_path.name,
-            target_file_path.name))
+            data_dir,
+            cache_dir,
+            state_dir,
+            target_file))
 
         self.create_empty_file()
 
         conf_file = open(conf_file_name, 'wt')
-        conf_file.write(self.CONFIG_TEMPLATE.format(data_dir_path.name,
-                                                    cache_dir_path.name,
-                                                    state_dir_path.name,
-                                                    target_file_path.name))
+        conf_file.write(self.CONFIG_TEMPLATE.format(data_dir,
+                                                    cache_dir,
+                                                    state_dir,
+                                                    target_file))
         conf_file.close()
 
         message = 'DVC init. data dir {}, cache dir {}, state dir {}, '.format(
-                        data_dir_path.name,
-                        cache_dir_path.name,
-                        state_dir_path.name
+                        data_dir,
+                        cache_dir,
+                        state_dir
         )
         if self.commit_if_needed(message) == 1:
             return 1
 
-        self.modify_gitignore(cache_dir_path.name)
+        self.modify_gitignore(cache_dir)
         return self.commit_if_needed('DVC init. Commit .gitignore file')
 
     def create_empty_file(self):
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -60,8 +60,6 @@
     'nose',
     'oauth2client',
     'packaging',
-    'pathlib',
-    'pathlib2',
     'pbr',
     'pexpect',
     'pickleshare',

{"golden_diff": "diff --git a/dvc/command/init.py b/dvc/command/init.py\n--- a/dvc/command/init.py\n+++ b/dvc/command/init.py\n@@ -1,5 +1,4 @@\n import os\n-from pathlib import Path\n \n from dvc.command.base import CmdBase\n from dvc.logger import Logger\n@@ -62,10 +61,10 @@\n         super(CmdInit, self).__init__(settings)\n \n     def get_not_existing_path(self, dir):\n-        path = Path(os.path.join(self.git.git_dir, dir))\n-        if path.exists():\n-            raise InitError('Path \"{}\" already exist'.format(path.name))\n-        return path\n+        path = os.path.join(self.git.git_dir, dir)\n+        if os.path.exists(path):\n+            raise InitError('Path \"{}\" already exist'.format(path))\n+        return os.path.basename(path), path\n \n     def get_not_existing_conf_file_name(self):\n         file_name = os.path.join(self.git.git_dir, Config.CONFIG)\n@@ -83,10 +82,10 @@\n             ))\n             return 1\n \n-        data_dir_path = self.get_not_existing_path(self.parsed_args.data_dir)\n-        cache_dir_path = self.get_not_existing_path(self.parsed_args.cache_dir)\n-        state_dir_path = self.get_not_existing_path(self.parsed_args.state_dir)\n-        target_file_path = self.get_not_existing_path(self.parsed_args.target_file)\n+        data_dir, data_dir_path = self.get_not_existing_path(self.parsed_args.data_dir)\n+        cache_dir, cache_dir_path = self.get_not_existing_path(self.parsed_args.cache_dir)\n+        state_dir, state_dir_path = self.get_not_existing_path(self.parsed_args.state_dir)\n+        target_file, target_file_path = self.get_not_existing_path(self.parsed_args.target_file)\n \n         self.settings.config.set(self.parsed_args.data_dir,\n                                  self.parsed_args.cache_dir,\n@@ -95,34 +94,34 @@\n \n         conf_file_name = self.get_not_existing_conf_file_name()\n \n-        data_dir_path.mkdir()\n-        cache_dir_path.mkdir()\n-        state_dir_path.mkdir()\n-        target_file_path.touch()\n+        os.mkdir(data_dir_path)\n+        os.mkdir(cache_dir_path)\n+        os.mkdir(state_dir_path)\n+        open(target_file_path, 'w').close()\n         Logger.info('Directories {}/, {}/, {}/ and target file {} were created'.format(\n-            data_dir_path.name,\n-            cache_dir_path.name,\n-            state_dir_path.name,\n-            target_file_path.name))\n+            data_dir,\n+            cache_dir,\n+            state_dir,\n+            target_file))\n \n         self.create_empty_file()\n \n         conf_file = open(conf_file_name, 'wt')\n-        conf_file.write(self.CONFIG_TEMPLATE.format(data_dir_path.name,\n-                                                    cache_dir_path.name,\n-                                                    state_dir_path.name,\n-                                                    target_file_path.name))\n+        conf_file.write(self.CONFIG_TEMPLATE.format(data_dir,\n+                                                    cache_dir,\n+                                                    state_dir,\n+                                                    target_file))\n         conf_file.close()\n \n         message = 'DVC init. data dir {}, cache dir {}, state dir {}, '.format(\n-                        data_dir_path.name,\n-                        cache_dir_path.name,\n-                        state_dir_path.name\n+                        data_dir,\n+                        cache_dir,\n+                        state_dir\n         )\n         if self.commit_if_needed(message) == 1:\n             return 1\n \n-        self.modify_gitignore(cache_dir_path.name)\n+        self.modify_gitignore(cache_dir)\n         return self.commit_if_needed('DVC init. Commit .gitignore file')\n \n     def create_empty_file(self):\ndiff --git a/setup.py b/setup.py\n--- a/setup.py\n+++ b/setup.py\n@@ -60,8 +60,6 @@\n     'nose',\n     'oauth2client',\n     'packaging',\n-    'pathlib',\n-    'pathlib2',\n     'pbr',\n     'pexpect',\n     'pickleshare',\n", "issue": "[Easy] Get rid of pathlib library\nMost of the code uses standard `os` library as a filesystem utility but some modules (init.py) use `pathlib`. Let's get rid of `pathlib`. It will unify the code and decrease the package size.\n", "before_files": [{"content": "import platform\nfrom setuptools import setup, find_packages\nfrom distutils.errors import DistutilsPlatformError\nfrom dvc import VERSION\n\ninstall_requires = [\n    'altgraph',\n    'appdirs',\n    'backports.shutil-get-terminal-size',\n    'boto',\n    'cachetools',\n    'configparser',\n    'decorator',\n    'dill',\n    'enum34',\n    'fasteners',\n    'funcsigs',\n    'future',\n    'futures',\n    'gapic-google-cloud-datastore-v1',\n    'gapic-google-cloud-error-reporting-v1beta1',\n    'gapic-google-cloud-logging-v2',\n    'gapic-google-cloud-pubsub-v1',\n    'gapic-google-cloud-spanner-admin-database-v1',\n    'gapic-google-cloud-spanner-admin-instance-v1',\n    'gapic-google-cloud-spanner-v1',\n    'gapic-google-cloud-speech-v1beta1',\n    'gapic-google-cloud-vision-v1',\n    'google-auth',\n    'google-auth-httplib2',\n    'google-cloud',\n    'google-cloud-bigquery',\n    'google-cloud-bigtable',\n    'google-cloud-core',\n    'google-cloud-datastore',\n    'google-cloud-dns',\n    'google-cloud-error-reporting',\n    'google-cloud-language',\n    'google-cloud-logging',\n    'google-cloud-monitoring',\n    'google-cloud-pubsub',\n    'google-cloud-resource-manager',\n    'google-cloud-runtimeconfig',\n    'google-cloud-spanner',\n    'google-cloud-speech',\n    'google-cloud-storage',\n    'google-cloud-translate',\n    'google-cloud-vision',\n    'google-gax',\n    'googleapis-common-protos',\n    'grpc-google-iam-v1',\n    'grpcio',\n    'httplib2',\n    'ipython',\n    'ipython-genutils',\n    'macholib',\n    'mock',\n    'modulegraph',\n    'monotonic',\n    'nose',\n    'oauth2client',\n    'packaging',\n    'pathlib',\n    'pathlib2',\n    'pbr',\n    'pexpect',\n    'pickleshare',\n    'ply',\n    'prompt-toolkit',\n    'proto-google-cloud-datastore-v1',\n    'proto-google-cloud-error-reporting-v1beta1',\n    'proto-google-cloud-logging-v2',\n    'proto-google-cloud-pubsub-v1',\n    'proto-google-cloud-spanner-admin-database-v1',\n    'proto-google-cloud-spanner-admin-instance-v1',\n    'proto-google-cloud-spanner-v1',\n    'proto-google-cloud-speech-v1beta1',\n    'proto-google-cloud-vision-v1',\n    'protobuf',\n    'ptyprocess',\n    'pyasn1',\n    'pyasn1-modules',\n    'Pygments',\n    'PyInstaller',\n    'pyparsing',\n    'requests',\n    'rsa',\n    'scandir',\n    'simplegeneric',\n    'six',\n    'traitlets',\n    'wcwidth',\n    'colorama',\n    'google-compute-engine'\n]\n\nif platform.system() == 'Darwin':\n    install_requires.append('appnope')\n    install_requires.append('py2app')\n\nsetup(\n    name='dvc',\n    version=VERSION,\n    description='Data Version Control makes your data science projects reproducible and shareable.',\n    author='Dmitry Petrov',\n    author_email='dmitry@dataversioncontrol.com',\n    url='https://github.com/dataversioncontrol/dvc.git',\n    license='Apache License 2.0',\n    install_requires=install_requires,\n    keywords='data science, data version control, machine learning',\n    classifiers=[\n        'Development Status :: 4 - Beta',\n        'Programming Language :: Python :: 2',\n        'Programming Language :: Python :: 3',\n    ],\n    packages=find_packages(exclude=['bin', 'tests', 'functests']),\n    include_package_data=True,\n    download_url='http://dataversioncontrol.com',\n    entry_points={\n        'console_scripts': ['dvc = dvc.main:main']\n    },\n    zip_safe=False\n)\n", "path": "setup.py"}, {"content": "import os\nfrom pathlib import Path\n\nfrom dvc.command.base import CmdBase\nfrom dvc.logger import Logger\nfrom dvc.config import Config\nfrom dvc.exceptions import DvcException\nfrom dvc.state_file import StateFile\nfrom dvc.system import System\n\n\nclass InitError(DvcException):\n    def __init__(self, msg):\n        DvcException.__init__(self, 'Init error: {}'.format(msg))\n\n\nclass CmdInit(CmdBase):\n    CONFIG_TEMPLATE = '''[Global]\nDataDir = {}\nCacheDir = {}\nStateDir = {}\nTargetFile = {}\n\n# Supported clouds: AWS, GCP\nCloud = AWS\nStoragePath =\n\n# Log levels: Debug, Info, Warning and Error\nLogLevel = Info\n\n[AWS]\nStoragePath = dvc/tutorial\n\nCredentialPath =\n\nRegion = us-east-1\nZone = us-east-1a\n\nImage = ami-2d39803a\n\nInstanceType = t2.nano\n\nSpotPrice =\nSpotTimeout = 300\n\nStorage = my-100gb-drive-io\n\nKeyDir = ~/.ssh\nKeyName = dvc-key\n\nSecurityGroup = dvc-group\n\n[GCP]\nStoragePath =\nProjectName =\n'''\n\n    EMPTY_FILE_NAME = 'empty'\n    EMPTY_FILE_CHECKSUM = '0000000'\n\n    def __init__(self, settings):\n        super(CmdInit, self).__init__(settings)\n\n    def get_not_existing_path(self, dir):\n        path = Path(os.path.join(self.git.git_dir, dir))\n        if path.exists():\n            raise InitError('Path \"{}\" already exist'.format(path.name))\n        return path\n\n    def get_not_existing_conf_file_name(self):\n        file_name = os.path.join(self.git.git_dir, Config.CONFIG)\n        if os.path.exists(file_name):\n            raise InitError('Configuration file \"{}\" already exist'.format(file_name))\n        return file_name\n\n    def run(self):\n        if not self.no_git_actions and not self.git.is_ready_to_go():\n            return 1\n\n        if os.path.realpath(os.path.curdir) != self.settings.git.git_dir_abs:\n            Logger.error('DVC error: initialization could be done only from git root directory {}'.format(\n                self.settings.git.git_dir_abs\n            ))\n            return 1\n\n        data_dir_path = self.get_not_existing_path(self.parsed_args.data_dir)\n        cache_dir_path = self.get_not_existing_path(self.parsed_args.cache_dir)\n        state_dir_path = self.get_not_existing_path(self.parsed_args.state_dir)\n        target_file_path = self.get_not_existing_path(self.parsed_args.target_file)\n\n        self.settings.config.set(self.parsed_args.data_dir,\n                                 self.parsed_args.cache_dir,\n                                 self.parsed_args.state_dir,\n                                 target_file_path)\n\n        conf_file_name = self.get_not_existing_conf_file_name()\n\n        data_dir_path.mkdir()\n        cache_dir_path.mkdir()\n        state_dir_path.mkdir()\n        target_file_path.touch()\n        Logger.info('Directories {}/, {}/, {}/ and target file {} were created'.format(\n            data_dir_path.name,\n            cache_dir_path.name,\n            state_dir_path.name,\n            target_file_path.name))\n\n        self.create_empty_file()\n\n        conf_file = open(conf_file_name, 'wt')\n        conf_file.write(self.CONFIG_TEMPLATE.format(data_dir_path.name,\n                                                    cache_dir_path.name,\n                                                    state_dir_path.name,\n                                                    target_file_path.name))\n        conf_file.close()\n\n        message = 'DVC init. data dir {}, cache dir {}, state dir {}, '.format(\n                        data_dir_path.name,\n                        cache_dir_path.name,\n                        state_dir_path.name\n        )\n        if self.commit_if_needed(message) == 1:\n            return 1\n\n        self.modify_gitignore(cache_dir_path.name)\n        return self.commit_if_needed('DVC init. Commit .gitignore file')\n\n    def create_empty_file(self):\n        empty_data_path = os.path.join(self.parsed_args.data_dir, self.EMPTY_FILE_NAME)\n        cache_file_suffix = self.EMPTY_FILE_NAME + '_' + self.EMPTY_FILE_CHECKSUM\n        empty_cache_path = os.path.join(self.parsed_args.cache_dir, cache_file_suffix)\n        empty_state_path = os.path.join(self.parsed_args.state_dir, self.EMPTY_FILE_NAME + '.state')\n\n        open(empty_cache_path, 'w').close()\n        System.symlink(os.path.join('..', empty_cache_path), empty_data_path)\n\n        StateFile(StateFile.COMMAND_EMPTY_FILE,\n                  empty_state_path,\n                  self.settings,\n                  input_files=[],\n                  output_files=[],\n                  lock=False).save()\n        pass\n\n    def modify_gitignore(self, cache_dir_name):\n        gitignore_file = os.path.join(self.git.git_dir, '.gitignore')\n        if not os.path.exists(gitignore_file):\n            open(gitignore_file, 'a').close()\n            Logger.info('File .gitignore was created')\n        with open(gitignore_file, 'a') as fd:\n            fd.write('\\n{}'.format(cache_dir_name))\n            fd.write('\\n{}'.format(os.path.basename(self.git.lock_file)))\n\n        Logger.info('Directory {} was added to .gitignore file'.format(cache_dir_name))\n", "path": "dvc/command/init.py"}], "after_files": [{"content": "import platform\nfrom setuptools import setup, find_packages\nfrom distutils.errors import DistutilsPlatformError\nfrom dvc import VERSION\n\ninstall_requires = [\n    'altgraph',\n    'appdirs',\n    'backports.shutil-get-terminal-size',\n    'boto',\n    'cachetools',\n    'configparser',\n    'decorator',\n    'dill',\n    'enum34',\n    'fasteners',\n    'funcsigs',\n    'future',\n    'futures',\n    'gapic-google-cloud-datastore-v1',\n    'gapic-google-cloud-error-reporting-v1beta1',\n    'gapic-google-cloud-logging-v2',\n    'gapic-google-cloud-pubsub-v1',\n    'gapic-google-cloud-spanner-admin-database-v1',\n    'gapic-google-cloud-spanner-admin-instance-v1',\n    'gapic-google-cloud-spanner-v1',\n    'gapic-google-cloud-speech-v1beta1',\n    'gapic-google-cloud-vision-v1',\n    'google-auth',\n    'google-auth-httplib2',\n    'google-cloud',\n    'google-cloud-bigquery',\n    'google-cloud-bigtable',\n    'google-cloud-core',\n    'google-cloud-datastore',\n    'google-cloud-dns',\n    'google-cloud-error-reporting',\n    'google-cloud-language',\n    'google-cloud-logging',\n    'google-cloud-monitoring',\n    'google-cloud-pubsub',\n    'google-cloud-resource-manager',\n    'google-cloud-runtimeconfig',\n    'google-cloud-spanner',\n    'google-cloud-speech',\n    'google-cloud-storage',\n    'google-cloud-translate',\n    'google-cloud-vision',\n    'google-gax',\n    'googleapis-common-protos',\n    'grpc-google-iam-v1',\n    'grpcio',\n    'httplib2',\n    'ipython',\n    'ipython-genutils',\n    'macholib',\n    'mock',\n    'modulegraph',\n    'monotonic',\n    'nose',\n    'oauth2client',\n    'packaging',\n    'pbr',\n    'pexpect',\n    'pickleshare',\n    'ply',\n    'prompt-toolkit',\n    'proto-google-cloud-datastore-v1',\n    'proto-google-cloud-error-reporting-v1beta1',\n    'proto-google-cloud-logging-v2',\n    'proto-google-cloud-pubsub-v1',\n    'proto-google-cloud-spanner-admin-database-v1',\n    'proto-google-cloud-spanner-admin-instance-v1',\n    'proto-google-cloud-spanner-v1',\n    'proto-google-cloud-speech-v1beta1',\n    'proto-google-cloud-vision-v1',\n    'protobuf',\n    'ptyprocess',\n    'pyasn1',\n    'pyasn1-modules',\n    'Pygments',\n    'PyInstaller',\n    'pyparsing',\n    'requests',\n    'rsa',\n    'scandir',\n    'simplegeneric',\n    'six',\n    'traitlets',\n    'wcwidth',\n    'colorama',\n    'google-compute-engine'\n]\n\nif platform.system() == 'Darwin':\n    install_requires.append('appnope')\n    install_requires.append('py2app')\n\nsetup(\n    name='dvc',\n    version=VERSION,\n    description='Data Version Control makes your data science projects reproducible and shareable.',\n    author='Dmitry Petrov',\n    author_email='dmitry@dataversioncontrol.com',\n    url='https://github.com/dataversioncontrol/dvc.git',\n    license='Apache License 2.0',\n    install_requires=install_requires,\n    keywords='data science, data version control, machine learning',\n    classifiers=[\n        'Development Status :: 4 - Beta',\n        'Programming Language :: Python :: 2',\n        'Programming Language :: Python :: 3',\n    ],\n    packages=find_packages(exclude=['bin', 'tests', 'functests']),\n    include_package_data=True,\n    download_url='http://dataversioncontrol.com',\n    entry_points={\n        'console_scripts': ['dvc = dvc.main:main']\n    },\n    zip_safe=False\n)\n", "path": "setup.py"}, {"content": "import os\n\nfrom dvc.command.base import CmdBase\nfrom dvc.logger import Logger\nfrom dvc.config import Config\nfrom dvc.exceptions import DvcException\nfrom dvc.state_file import StateFile\nfrom dvc.system import System\n\n\nclass InitError(DvcException):\n    def __init__(self, msg):\n        DvcException.__init__(self, 'Init error: {}'.format(msg))\n\n\nclass CmdInit(CmdBase):\n    CONFIG_TEMPLATE = '''[Global]\nDataDir = {}\nCacheDir = {}\nStateDir = {}\nTargetFile = {}\n\n# Supported clouds: AWS, GCP\nCloud = AWS\nStoragePath =\n\n# Log levels: Debug, Info, Warning and Error\nLogLevel = Info\n\n[AWS]\nStoragePath = dvc/tutorial\n\nCredentialPath =\n\nRegion = us-east-1\nZone = us-east-1a\n\nImage = ami-2d39803a\n\nInstanceType = t2.nano\n\nSpotPrice =\nSpotTimeout = 300\n\nStorage = my-100gb-drive-io\n\nKeyDir = ~/.ssh\nKeyName = dvc-key\n\nSecurityGroup = dvc-group\n\n[GCP]\nStoragePath =\nProjectName =\n'''\n\n    EMPTY_FILE_NAME = 'empty'\n    EMPTY_FILE_CHECKSUM = '0000000'\n\n    def __init__(self, settings):\n        super(CmdInit, self).__init__(settings)\n\n    def get_not_existing_path(self, dir):\n        path = os.path.join(self.git.git_dir, dir)\n        if os.path.exists(path):\n            raise InitError('Path \"{}\" already exist'.format(path))\n        return os.path.basename(path), path\n\n    def get_not_existing_conf_file_name(self):\n        file_name = os.path.join(self.git.git_dir, Config.CONFIG)\n        if os.path.exists(file_name):\n            raise InitError('Configuration file \"{}\" already exist'.format(file_name))\n        return file_name\n\n    def run(self):\n        if not self.no_git_actions and not self.git.is_ready_to_go():\n            return 1\n\n        if os.path.realpath(os.path.curdir) != self.settings.git.git_dir_abs:\n            Logger.error('DVC error: initialization could be done only from git root directory {}'.format(\n                self.settings.git.git_dir_abs\n            ))\n            return 1\n\n        data_dir, data_dir_path = self.get_not_existing_path(self.parsed_args.data_dir)\n        cache_dir, cache_dir_path = self.get_not_existing_path(self.parsed_args.cache_dir)\n        state_dir, state_dir_path = self.get_not_existing_path(self.parsed_args.state_dir)\n        target_file, target_file_path = self.get_not_existing_path(self.parsed_args.target_file)\n\n        self.settings.config.set(self.parsed_args.data_dir,\n                                 self.parsed_args.cache_dir,\n                                 self.parsed_args.state_dir,\n                                 target_file_path)\n\n        conf_file_name = self.get_not_existing_conf_file_name()\n\n        os.mkdir(data_dir_path)\n        os.mkdir(cache_dir_path)\n        os.mkdir(state_dir_path)\n        open(target_file_path, 'w').close()\n        Logger.info('Directories {}/, {}/, {}/ and target file {} were created'.format(\n            data_dir,\n            cache_dir,\n            state_dir,\n            target_file))\n\n        self.create_empty_file()\n\n        conf_file = open(conf_file_name, 'wt')\n        conf_file.write(self.CONFIG_TEMPLATE.format(data_dir,\n                                                    cache_dir,\n                                                    state_dir,\n                                                    target_file))\n        conf_file.close()\n\n        message = 'DVC init. data dir {}, cache dir {}, state dir {}, '.format(\n                        data_dir,\n                        cache_dir,\n                        state_dir\n        )\n        if self.commit_if_needed(message) == 1:\n            return 1\n\n        self.modify_gitignore(cache_dir)\n        return self.commit_if_needed('DVC init. Commit .gitignore file')\n\n    def create_empty_file(self):\n        empty_data_path = os.path.join(self.parsed_args.data_dir, self.EMPTY_FILE_NAME)\n        cache_file_suffix = self.EMPTY_FILE_NAME + '_' + self.EMPTY_FILE_CHECKSUM\n        empty_cache_path = os.path.join(self.parsed_args.cache_dir, cache_file_suffix)\n        empty_state_path = os.path.join(self.parsed_args.state_dir, self.EMPTY_FILE_NAME + '.state')\n\n        open(empty_cache_path, 'w').close()\n        System.symlink(os.path.join('..', empty_cache_path), empty_data_path)\n\n        StateFile(StateFile.COMMAND_EMPTY_FILE,\n                  empty_state_path,\n                  self.settings,\n                  input_files=[],\n                  output_files=[],\n                  lock=False).save()\n        pass\n\n    def modify_gitignore(self, cache_dir_name):\n        gitignore_file = os.path.join(self.git.git_dir, '.gitignore')\n        if not os.path.exists(gitignore_file):\n            open(gitignore_file, 'a').close()\n            Logger.info('File .gitignore was created')\n        with open(gitignore_file, 'a') as fd:\n            fd.write('\\n{}'.format(cache_dir_name))\n            fd.write('\\n{}'.format(os.path.basename(self.git.lock_file)))\n\n        Logger.info('Directory {} was added to .gitignore file'.format(cache_dir_name))\n", "path": "dvc/command/init.py"}]}