Repository: iterative/dvc

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.


Discussion:

Resolving patch:
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 @@ def __init__(self, settings):
         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 @@ def run(self):
             ))
             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 @@ def run(self):
 
         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',


Test patch:
diff --git a/dvc/command/test.py b/dvc/command/test.py
--- a/dvc/command/test.py
+++ b/dvc/command/test.py
@@ -1,8 +1,6 @@
 import os
 import sys
 
-from pathlib import Path
-
 from google.cloud import storage
 
 import dvc