Improvement over old code
@@ -3060,6 +3060,12 @@ if __name__ == '__main__':
Print.error('Exception: ' + str(e))
else:
buffer = 65536
+ if args.text_file:
+ tfile=args.text_file
+ with open(tfile,"r+", encoding='utf8') as filelist:
+ filename = filelist.readline()
+ filename=os.path.abspath(filename.rstrip('\n'))
+ dir=os.path.dirname(os.path.abspath(filename))
if args.ofolder:
for input in args.ofolder:
try:
@@ -3067,16 +3073,17 @@ if __name__ == '__main__':
except BaseException as e:
Print.error('Exception: ' + str(e))
else:
- if args.text_file:
- tfile=args.text_file
- with open(tfile,"r+", encoding='utf8') as filelist:
- filename = filelist.readline()
- filename=os.path.abspath(filename.rstrip('\n'))
- dir=os.path.dirname(os.path.abspath(filename))
ofolder =os.path.join(dir, 'output')
else:
for filename in args.xci_trim:
dir=os.path.dirname(os.path.abspath(filename))
+ if args.ofolder:
+ for input in args.ofolder:
+ try:
+ ofolder = input
+ except BaseException as e:
+ Print.error('Exception: ' + str(e))
+ else:
ofolder =os.path.join(dir, 'output')
if not os.path.exists(ofolder):
os.makedirs(ofolder)
@@ -3091,6 +3098,7 @@ if __name__ == '__main__':
Print.error('Exception: ' + str(e))
else:
fat="exfat"
+ if not args.text_file:
for filepath in args.xci_trim:
if filepath.endswith('.xci'):
try:
@@ -3105,6 +3113,21 @@ if __name__ == '__main__':
f.close()
except BaseException as e:
Print.error('Exception: ' + str(e))
+ else:
+ filepath=filename
+ if filepath.endswith('.xci'):
+ try:
+ f = Fs.factory(filepath)
+ filename=os.path.basename(os.path.abspath(filepath))
+ #print(filename)
+ outfile = os.path.join(ofolder, filename)
+ #print(f.path)
+ f.open(filepath, 'rb')
+ f.trim(buffer,outfile,ofolder,fat)
+ f.flush()
+ f.close()
+ except BaseException as e:
+ Print.error('Exception: ' + str(e))
Status.close()
# ...................................................
# Untrimming for xci files
