Commit adc680b1 authored by kpetersn's avatar kpetersn
Browse files

Initial commit of working script. Outputs to stdout. Redirect to a file to create the alias db.

parents
#!/APSshare/anaconda/x86_64/bin/python
#
# Generate alias statements for each record in a database.
#
import argparse as ap
import os.path
import re
aliasLines = []
def main(dbName):
recTest = re.compile('^record|^grecord')
recNmTest = re.compile('"(.*)"')
dbfd = open(dbName, 'r')
for line in dbfd:
if recTest.match(line):
recName = recNmTest.search(line).groups()[0]
#!print recName
aliasName = "A)".join(recName.split(")"))
#!print aliasName
aliasLine = 'alias("{0}", "{1}")'.format(recName, aliasName)
print(aliasLine)
dbfd.close()
if __name__ == '__main__':
parser = ap.ArgumentParser()
parser.add_argument("db", help="EPICS database containing records to be aliased")
args = parser.parse_args()
#!print args
#!print args.db
if os.path.isfile(args.db):
main(args.db)
else:
print('Error: database does not exist: {0}'.format(args.db))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment