diff --git a/deltaScripts/16.2.2/DR5411/AddAllCapsEmphasis.py b/deltaScripts/16.2.2/DR5411/AddAllCapsEmphasis.py new file mode 100755 index 0000000000..e9151c0439 --- /dev/null +++ b/deltaScripts/16.2.2/DR5411/AddAllCapsEmphasis.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python +# Delta script to insert productId tag into warngen .vm and .xml files +# Original files will be backed up in *.backup[n] +# + +import glob +import os +import re +import shutil + +SITE_TEMPLATE_PATH = "/awips2/edex/data/utility/common_static/site/*/warngen/*.vm" + +PATTERNS = [ + re.compile(r'\bTAKE\s+COVER\s+NOW\b', re.IGNORECASE | re.MULTILINE), + re.compile(r'\bSEEK\s+SHELTER\s+NOW\b', re.IGNORECASE | re.MULTILINE), + re.compile(r'\bSEEK\s+SHELTER\s+IMMEDIATELY\b', re.IGNORECASE | re.MULTILINE), + + re.compile(r'\bIMMINENT\s+DANGEROUS\s+WEATHER\s+CONDITIONS\b', re.IGNORECASE | re.MULTILINE), + re.compile(r'\bIMMINENT,\s+DANGEROUS,\s+AND\s+POTENTIALLY\s+LIFE-THREATENING\s+WEATHER\s+CONDITIONS\b', re.IGNORECASE | re.MULTILINE), + re.compile(r'\b((EXTREMELY|VERY|PARTICULARLY)\s+)?DANGEROUS\s+SITUATION\b', re.IGNORECASE | re.MULTILINE), +] + +def __backupFile(orig): + """create a unique backup file name from orig""" + + suffix = ".backup" + backup = orig + suffix + count = 0 + while os.path.exists(backup): + count += 1 + backup = orig + suffix + str(count) + + return backup + +def __replaceWithUpper(matchobj): + orig = matchobj.group(0) + repl = orig.upper() + return repl + +def main(): + + for template in glob.glob(SITE_TEMPLATE_PATH): + with open(template, "r") as templateFile: + originalContents = templateFile.read() + + newContents = originalContents + for pattern in PATTERNS: + newContents = re.sub(pattern, __replaceWithUpper, newContents) + + if newContents != originalContents: + print "Updating", template + shutil.copy2(template, __backupFile(template)) + with open(template, "w") as templateFile: + templateFile.write(newContents) + +if __name__ == "__main__": + main() diff --git a/deltaScripts/16.2.2/DR5411/AddProductIdToWarnGenTemplates.py b/deltaScripts/16.2.2/DR5411/AddProductIdToWarnGenTemplates.py new file mode 100755 index 0000000000..d09c405686 --- /dev/null +++ b/deltaScripts/16.2.2/DR5411/AddProductIdToWarnGenTemplates.py @@ -0,0 +1,116 @@ +#!/usr/bin/env python +# Delta script to insert productId tag into warngen .vm and .xml files +# Original files will be backed up in *.backup[n] +# + +import glob +import os +import re +import shutil + +SITE_XML_PATH = "/awips2/edex/data/utility/common_static/site/*/warngen/*.xml" +BASE_TEMPLATE_DIR = "/awips2/edex/data/utility/common_static/base/warngen" + +PID_PATTERN = re.compile("\n\$\{WMOId\} \$\{vtecOffice\} 000000 \$\{BBBId\}\n([A-Z]{3})\$\{siteId\}\n", re.MULTILINE) + +PRODUCT_ID_PATTERN = re.compile("\n[ \t]*([A-Z]{3})", re.MULTILINE) + +PHENSIG_COMMENT_PATTERN = re.compile("\n([ \t]*)\n{0}{1}\n\n" + +def __backupFile(orig): + """create a unique backup file name from orig""" + + suffix = ".backup" + backup = orig + suffix + count = 0 + while os.path.exists(backup): + count += 1 + backup = orig + suffix + str(count) + + return backup + +def main(): + + for siteXml in glob.glob(SITE_XML_PATH): + with open(siteXml, "r") as xmlFile: + siteXmlContents = xmlFile.read() + + if "" not in siteXmlContents: + # not a template configuration file + continue + + match = PRODUCT_ID_PATTERN.search(siteXmlContents) + if match is not None: + # xml already contains productId + continue + + baseXml = os.path.join(BASE_TEMPLATE_DIR, os.path.basename(siteXml)) + siteTemplate = siteXml.replace(".xml", ".vm") + + pid = None + # try to get productId from base xml file + if os.path.exists(baseXml): + with open(baseXml, "r") as xmlFile: + baseXmlContents = xmlFile.read() + + match = PRODUCT_ID_PATTERN.search(baseXmlContents) + if match is not None: + pid = match.group(1) + + if pid is None: + # try to get the productId from the site vm template file + # should only be necessary for a non-baseline template + if os.path.exists(siteTemplate): + template = siteTemplate + + with open(template, "r") as templateFile: + templateContents = templateFile.read() + + match = PID_PATTERN.search(templateContents) + if match is not None: + pid = match.group(1) + + if pid is None: + print "ERROR: Unable to determine productId for", siteXml + continue + + # insert product id tag into the xml file before the phensig tag + match = PHENSIG_COMMENT_PATTERN.search(siteXmlContents) + if match is None: + match = PHENSIG_TAG_PATTERN.search(siteXmlContents) + + if match is None: + print "ERROR: Unable to insert productId into", siteXml + continue + + print "Adding productId",pid, "to", siteXml + indent = match.group(1) + siteXmlContents = siteXmlContents[:match.start(1)] + PRODUCT_ID.format(indent, pid) + siteXmlContents[match.start(1):] + + shutil.copy2(siteXml, __backupFile(siteXml)) + with open(siteXml, "w") as xmlFile: + xmlFile.write(siteXmlContents) + + # if siteTemplate exists attempt to insert productId + if os.path.exists(siteTemplate): + print "Referencing productId in", siteTemplate + + with open(siteTemplate, "r") as templateFile: + templateContents = templateFile.read() + + match = PID_PATTERN.search(templateContents) + while match is not None: + templateContents = templateContents[:match.start(1)] + "${productId}" + templateContents[match.end(1):] + match = PID_PATTERN.search(templateContents) + + shutil.copy2(siteTemplate, __backupFile(siteTemplate)) + with open(siteTemplate, "w") as templateFile: + templateFile.write(templateContents) + + +if __name__ == "__main__": + main() diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.warning/utility/common_static/base/warngen/extremeWindWarningFollowup.vm b/edexOsgi/com.raytheon.uf.common.dataplugin.warning/utility/common_static/base/warngen/extremeWindWarningFollowup.vm index 243f4dc22f..43fc60ffa9 100755 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.warning/utility/common_static/base/warngen/extremeWindWarningFollowup.vm +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.warning/utility/common_static/base/warngen/extremeWindWarningFollowup.vm @@ -232,7 +232,7 @@ Widespread destructive winds of !** **! to !** **! mph will spread across ## #end #if(${list.contains(${bullets}, "takeCoverCTA")}) -Take cover now! Treat these imminent extreme winds as if a tornado was approaching and move immediately to the safe room in your shelter. Take action now to protect your life! +TAKE COVER NOW! Treat these imminent extreme winds as if a tornado was approaching and move immediately to the safe room in your shelter. Take action now to protect your life! #end #if(${list.contains(${bullets}, "safePlacesCTA")})