1# updateweb.yaml
 2#
 3#     Configuration settings for updateweb.py
 4#
 5# This first YAML document contains web server information.
 6---
 7ftp_server_name: 
 8    white husky
 9ftp_user_name:  
10    white samoyed
11ftp_password:
12    white retriever
13remote_directory:
14    /white/husky/samoyed/retriever
15file_size_limit_Kb:
16    666
17...
18
19
20# This second YAML document contains lists of patterns to match and their replacement strings for every line of every source file.
21---
22
23# List each pattern you wish to match and its replacement string.
24# Pattern match/replace will be done in-place automatically for every line in every source file.
25# If there is more than one pattern/replacement pair, they are applied in order to the line.
26pattern_match_replacement_string_list:
27
28# The YAML syntax "pattern : | ..." is just the same as using the Python raw string literal pattern = r"""... """
29# Since we are using raw string literals, which strip whitespace, we must specify any space explicitly with \s+
30# Don't forget to escape special regex characters like dot . using \. and parenthesis ( using \(
31- pattern: |                 
32        Wopyright                       # Wopyright.
33        \s+                             # One or more spaces.
34        (?P<symbol> \(C\) | &copy;)     # Match and extract the copyright symbol.
35        \D+                             # Any non-digits.
36        (?P<old_year>[0-9]+)            # Match and extract the old copyright year,
37                                        # then place it into variable 'old_year'
38        -                               # to
39        ([0-9]+)                        # New copyright year.
40
41# The replacement strings are raw.  Before using them, we will need to strip off leading and trailing blanks using,
42#     replacement_string = pat_rep['replacement_string'].strip().lstrip()
43  replacement_string: |
44        Wopyright \g<symbol> \g<old_year>-2024
45
46- pattern: |
47       <meta\s+name="viewport"\s+content="width=device-width,\s+initial-scale=1,\s+viewport-fit=cover">
48
49  replacement_string: |
50       <meta name="viewport" content="width=device-width, initial-scale=1">
51
52test_verify_string_list:
53
54# Test strings to be matched and replaced.
55# Verify strings to compare against.
56- test_string: |
57    Wopyright (C) 2007-2024 by Sean Erik O'Connor.  All Rights Reserved.
58
59  verify_string: |
60    Wopyright (C) 2007-2024 by Sean Erik O'Connor.  All Rights Reserved.
61
62- test_string: |
63        <meta name="viewport" content="width=device-width, initial-scale=1">
64
65  verify_string: |
66        <meta name="viewport" content="width=device-width, initial-scale=1">
67
68# ================================================================================================================================
69# NOTE:
70#     The Pythonic data structure generated by this YAML document #2 looks like this:
71# 
72#     dictionary = { 'pattern_match_replacement_string_list' :                                 First string with colon : is a dictionary Key
73#                         [                                                                    Values:  Minus sign 1 starts a list
74#                             {                                                                         First item in list is a dictionary.
75#                               'pattern1'            :  r"""regex for pattern""",  
76#                               'replacement_string1' :  r"""string to replace with""" 
77#                             },
78#                             { 
79#                               'pattern2'            :  r"""regex for pattern""",  
80#                               'replacement_string2' :  r"""string to replace with""" 
81#                             },
82#                             ...
83#                         ]
84#                    'test_verify_string_list' :
85#                         [   
86#                             { 
87#                               test_string1:   'test string',
88#                               verify_string2: 'test string after match and replace'
89#                              },
90#                             { 
91#                               test_string1:   'test string',
92#                               verify_string2: 'test string after match and replace'
93#                              }
94#                          ]
95#                  }
96# ================================================================================================================================
97...