From c24b787a62810a7a9b5b2ccd4eca30111c60c280 Mon Sep 17 00:00:00 2001 From: treangen Date: Thu, 5 Feb 2015 12:21:29 -0500 Subject: [PATCH] update handling of files w/ special characters --- Parsnp.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/Parsnp.py b/Parsnp.py index 17ad09f..59414f1 100755 --- a/Parsnp.py +++ b/Parsnp.py @@ -6,12 +6,14 @@ from multiprocessing import * reroot_tree = True #use --midpoint-reroot + try: import dendropy except ImportError: reroot_tree = False - +#check for sane file names +special_chars = [",","[","]","{","}","(",")","!","\'","\"","*","\%","\<" ,"\>", "|", " ", "`"] CSI=""#"\x1B[" reset=""#CSI+"m" BOLDME = ""#CSI+'\033[1m' @@ -651,7 +653,15 @@ def usage(): reflen = 0 fnafiles1 = [] for file in files: - + nameok = True + for char in special_chars: + if char in file: + + print "WARNING: File %s contains a non-supported special character (\'%s\') in file name. Please remove if you'd like to include. For best practices see: http://support.apple.com/en-us/HT202808"%(file,char) + nameok = False + break + if not nameok: + continue #any file in genome dir will be added.. if file[0] != "." and file[-1] != "~": @@ -678,6 +688,15 @@ def usage(): reflen = len(data) ff.close() for file in files: + nameok = True + + for char in special_chars: + if char in file: + #print "WARNING: File %s contains a non-supported special character (%s) in file name. Please remove if you'd like to include. For best practices see: http://support.apple.com/en-us/HT202808"%(file,char) + nameok = False + break + if not nameok: + continue if file[0] != "." and file[-1] != "~": ff = open(seqdir+os.sep+file,'r') hdr = ff.readline()