711770a0ca29d71d2ce8227a787be163f05f577d max Wed Jun 17 05:24:30 2020 -0700 adding trackDb for your data hub static html converter to ra format, refs #25745 diff --git src/hg/oneShot/tfydToRa/tfydToRa src/hg/oneShot/tfydToRa/tfydToRa new file mode 100755 index 0000000..614dd21 --- /dev/null +++ src/hg/oneShot/tfydToRa/tfydToRa @@ -0,0 +1,104 @@ +#!/usr/bin/env python + +import logging, sys, optparse +from collections import defaultdict +from os.path import join, basename, dirname, isfile + +# ==== functions ===== + +def parseArgs(): + " setup logging, parse command line arguments and options. -h shows auto-generated help page " + parser = optparse.OptionParser("usage: %prog [options] inFname outFname - convert the 'trackDb for your datahub' format aka. trackDbLibrary.shtml to an .ra file") + + parser.add_option("-d", "--debug", dest="debug", action="store_true", help="show debug messages") + #parser.add_option("-f", "--file", dest="file", action="store", help="run on file") + #parser.add_option("", "--test", dest="test", action="store_true", help="do something") + (options, args) = parser.parse_args() + + if args==[]: + parser.print_help() + exit(1) + + if options.debug: + logging.basicConfig(level=logging.DEBUG) + logging.getLogger().setLevel(logging.DEBUG) + else: + logging.basicConfig(level=logging.INFO) + logging.getLogger().setLevel(logging.INFO) + + return args, options +# ----------- main -------------- +# there is no need to make this clean code. The plan is to run this script once and then be done +# with trackDbLibrary forever. Do not overdo codereview on this script, possibly no code review at all +# is fine. +def main(): + args, options = parseArgs() + + filename = args[0] + + #ofh = open(outFname, "w") + descLines = [] + relTags = [] + + grabDesc = False + isIntro = False + foundStart = False + skipDiv = False + for line in open(filename): + #
track
Required: Yes
+ #print("* ", line) + line = line.rstrip("\n") + if line.startswith("