From d27fd11cf2a15569ad2eb0f92d613e7a2c2e1810 Mon Sep 17 00:00:00 2001 From: nrg12 Date: Wed, 8 Feb 2017 14:33:00 -0500 Subject: [PATCH] fixed cross platform compatibility issue --- crawl_subject_files.py | 2 +- mirror_script/mirror_directory.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crawl_subject_files.py b/crawl_subject_files.py index e74a2c2..4e04873 100644 --- a/crawl_subject_files.py +++ b/crawl_subject_files.py @@ -473,7 +473,7 @@ def copy_files(self, lst): for tup in lst: filepath = tup[0] drive, localdir = os.path.splitdrive(filepath) - savepath = os.path.join(self.output_dir, os.path.normpath(os.path.dirname(localdir)).lstrip('\\')) + savepath = os.path.join(self.output_dir,os.path.normpath(os.path.dirname(localdir)).lstrip(r"\\").lstrip("/")) try: with open(savepath) as f: pass except IOError as e: diff --git a/mirror_script/mirror_directory.py b/mirror_script/mirror_directory.py index bf9316b..0121cae 100644 --- a/mirror_script/mirror_directory.py +++ b/mirror_script/mirror_directory.py @@ -117,7 +117,7 @@ def mirror_files(self, lst): def mirror_files_to_csv(self, lst): self.getSavePath() x = self.save_filename - if not re.match("(.csv)$", self.save_filename): + if not x.endswith('.csv'): x+=".csv" with open(self.output_dir+'/'+x, 'a') as f: writer = csv.writer(f) @@ -131,7 +131,7 @@ def mirror_files_recursive(self, lst): filepath = tup[0] base_name = os.path.basename(filepath) drive, localdir = os.path.splitdrive(filepath) - savepath = os.path.join(self.output_dir,os.path.normpath(os.path.dirname(localdir)).lstrip('\\')) + savepath = os.path.join(self.output_dir,os.path.normpath(os.path.dirname(localdir)).lstrip(r"\\").lstrip("/")) try: with open(savepath): pass except IOError: