diff options
author | jturner <jturner@gemini.edu> | 2016-08-18 20:23:14 -0400 |
---|---|---|
committer | jturner <jturner@gemini.edu> | 2016-08-18 20:23:14 -0400 |
commit | 085281eed1349fa23926754e58d5cd0021f5fe6a (patch) | |
tree | 11b2ab993a4dd2a717245facc9df79557fd61ecc /scripts | |
parent | cc32b6e0d83b7bdf67fd245d5a83f15eb737af95 (diff) | |
download | astroconda-iraf-helpers-085281eed1349fa23926754e58d5cd0021f5fe6a.tar.gz |
Improve handling of extra blank lines etc. with respect to the template.
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/update_extern_pkg | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/scripts/update_extern_pkg b/scripts/update_extern_pkg index 536ca38..ce04650 100755 --- a/scripts/update_extern_pkg +++ b/scripts/update_extern_pkg @@ -59,13 +59,21 @@ with open(template_path, 'r') as template_file: # the others. The template ur_extern.pkg files must not contain backslashes. replacements = OrderedDict(( - ('spec_nospace', (r'([][.^${}\|*?])', r'\\\1')), - ('spec_space', (r'[ \t]*([=+()])[ \t]*', r'[ \t]*\\\1[ \t]*')), - ('extra_space', (r'[ \t]+', r'[ \t]+')), - ('end_space', (r'(^|$)', r'[ \t]*')), - ('path_sub', (path_sub, r'.*')), + ('special_nospace', (r'([][.^${}\|*?])', r'\\\1')), + ('special_sp_end', (r'[ \t]*([=+()])[ \t]*$', r'[ \t]*\\\1')), + ('special_space', (r'[ \t]*([=+()])[ \t]*', r'[ \t]*\\\1[ \t]*')), + ('lead_space', (r'^[ \t]+', r'')), + ('end_space', (r'[ \t]+$', r'')), + ('extra_space', (r'[ \t]+', r'[ \t]+')), + ('line_space', (r'\s*\n\s*', r'\s*\n\s*')), # see below + ('path_sub', (path_sub, r'.*')), )) +# Note that ^ and $ only match in conjunction with their adjoining character, +# which, unlike the \n above, can get consumed by a prior pattern. Also, +# certain other combinations of \s and other space seem to cause "catastrophic +# backtracking" when there's no match, which can take 11 minutes! + # Concatenate individual expressions for replacement, so they can be done # simultaneously on the original buffer (otherwise they trip each other up): cat_re = '|'.join(['(?P<{0}>{1})'.format(key, regex) \ |