import os
from . import cdfread
from . import cdfwrite
from .epochs import CDFepoch as cdfepoch  # noqa: F401

# This function determines if we are reading or writing a file


def CDF(path, cdf_spec=None, delete=False, validate=None):
    path = os.path.expanduser(path)
    if (os.path.exists(path)):
        if delete:
            os.remove(path)
            return
        else:
            return cdfread.CDF(path, validate=validate)
    else:
        return cdfwrite.CDF(path, cdf_spec=cdf_spec, delete=delete)

@@ -1,14 +1,4 @@
-import os%0A
 from
@@ -93,16 +93,40 @@
 a: F401%0A
+from pathlib import Path
 %0A# This 
@@ -253,23 +253,26 @@
  path = 
-os.
+Path(
 path
+)
 .expandu
@@ -279,42 +279,31 @@
 ser(
-path
 )%0A
+%0A
     if 
-(os.
 path.
-exists(path)
+is_file(
 ):%0A 
@@ -336,22 +336,20 @@
     
-os.remove(path
+path.unlink(
 )%0A  

use pathlib.Path intrinsic