]> git.phdru.name Git - m_lib.git/blobdiff - m_lib/m_shutil.py
Fix string.split for Py3 compatibility
[m_lib.git] / m_lib / m_shutil.py
index 10e5ebf552e4eaaf25f1fc2fe59b9ffd0e498704..b691abc45befad3cd2282731eb89762f84583344 100755 (executable)
@@ -1,11 +1,11 @@
 #! /usr/bin/env python
-"""Broytman's shell utilities. Additional to shutil.py (standard library module)
-
-   Written by Broytman, Oct 1997. Copyright (C) 1997 PhiloSoft Design.
+"""
+Shell utilities. Additional to shutil.py (standard library module).
 """
 
 
-import os, string
+from __future__ import print_function
+import os
 
 
 mkhier_error = "m_shutil.mkhier_error"
@@ -15,14 +15,14 @@ def mkhier(path): # Python implementation of UNIX' mkdir -p /path/to/dir
       return # It's Ok to have the directory already created
 
    if os.path.exists(path):
-      raise mkhier_error, "`%s' is file" % path
+      raise mkhier_error("`%s' is file" % path)
 
-   list_dirs = string.split(path, os.sep)
-   #print list_dirs
+   list_dirs = path.split(os.sep)
+   #print(list_dirs)
    for i in range(0, len(list_dirs)):
-      new_path = string.join(list_dirs[0:i+1], os.sep)
-      if (new_path <> '') and (not os.path.exists(new_path)):
-         #print "Making", new_path
+      new_path = os.sep.join(list_dirs[0:i+1])
+      if (new_path != '') and (not os.path.exists(new_path)):
+         #print("Making", new_path)
          os.mkdir(new_path)