From 020a3e26340f118d267318349d89f5566eb61ae9 Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Sun, 26 Jul 2015 00:41:42 +0000 Subject: [PATCH] superfluous since same can be (even more flexibly) accomplished with: reLabel -l old -s old+tag --- processing/post/tagLabel.py | 79 ------------------------------------- 1 file changed, 79 deletions(-) delete mode 100755 processing/post/tagLabel.py diff --git a/processing/post/tagLabel.py b/processing/post/tagLabel.py deleted file mode 100755 index 8a229eeed..000000000 --- a/processing/post/tagLabel.py +++ /dev/null @@ -1,79 +0,0 @@ -#!/usr/bin/env python -# -*- coding: UTF-8 no BOM -*- - -import os,re,sys,math,string -import damask -from optparse import OptionParser - -scriptID = string.replace('$Id$','\n','\\n') -scriptName = os.path.splitext(scriptID.split()[1])[0] - -# -------------------------------------------------------------------- -# MAIN -# -------------------------------------------------------------------- - -parser = OptionParser(option_class=damask.extendableOption, usage='%prog [options] dfile[s]', description = """ -Tag scalar, vectorial, and/or tensorial data header labels by specified suffix. - -""", version = scriptID) - -parser.add_option('-t','--tag', dest='tag', metavar='string', - help='tag to use as suffix for labels') -parser.add_option('-l','--label', dest='label', action='extend', metavar='', - help='columns to tag') - -parser.set_defaults(tag = '') -parser.set_defaults(label = []) - -(options,filenames) = parser.parse_args() - -# --- loop over input files ------------------------------------------------------------------------- -if filenames == []: - filenames = ['STDIN'] - -for name in filenames: - if name == 'STDIN': - file = {'name':'STDIN', 'input':sys.stdin, 'output':sys.stdout, 'croak':sys.stderr} - file['croak'].write('\033[1m'+scriptName+'\033[0m\n') - else: - if not os.path.exists(name): continue - file = {'name':name, 'input':open(name), 'output':open(name+'_tmp','w'), 'croak':sys.stderr} - file['croak'].write('\033[1m'+scriptName+'\033[0m: '+file['name']+'\n') - - table = damask.ASCIItable(file['input'],file['output'],buffered=False) # make unbuffered ASCII_table - table.head_read() - table.info_append(scriptID + '\t' + ' '.join(sys.argv[1:])) # read ASCII header info - - -# ------------------------------------------ process labels --------------------------------------- - - if options.label == []: # default to tagging all labels - for i,label in enumerate(table.labels): - table.labels[i] += options.tag - else: # tag individual candidates - indices = table.label_index (options.label) - dimensions = table.label_dimension(options.label) - for i,index in enumerate(indices): - if index == -1: - file['croak'].write('label %s not present...\n'%options.label[i]) - else: - for j in xrange(dimensions[i]): - table.labels[index+j] += options.tag - -# ------------------------------------------ assemble header --------------------------------------- - - table.head_write() - -# ------------------------------------------ process data --------------------------------------- - - outputAlive = True - while outputAlive and table.data_read(): # read next data line of ASCII table - outputAlive = table.data_write() # output processed line - -# ------------------------------------------ output result --------------------------------------- - - outputAlive and table.output_flush() # just in case of buffered ASCII table - - table.close() # close ASCII tables - if file['name'] != 'STDIN': - os.rename(file['name']+'_tmp',file['name']) # overwrite old one with tmp new