ash/webui/file_manager/resources/gen_main_html.py
def GenerateSwaMainHtml(source, target):
  """Copy source file to target, do SWA edits, then add BUILD time stamp."""

  # Copy source (main.html) file to the target (main.html) file.
  shutil.copyfile(source, target)

  # Edit the target file.
  for line in fileinput.input(target, inplace=True):
    # Add _SWA <script> tag after the <head> tag.
    if line.find('<head>') >= 0:
      print(line + '    ' + _SWA)
    # Add <meta> charset="utf-8" attribute.
    elif line.find('<meta ') >= 0:
      sys.stdout.write(line.replace('<meta ', '<meta charset="utf-8" '))
    # Ignore HTML Imports and its polyfil.
    elif 'rel="import"' in line or 'html-imports' in line:
      continue
    # Remove files app foreground/js <script> tags: SWA app must load
    # them after the SWA app has initialized needed resources.
    elif line.find('src="foreground/js/main.') == -1:
      sys.stdout.write(line)

  # Create a BUILD time stamp for the target file.
  open(target + '.stamp', 'a').close()
Copy source file to target, do SWA edits, then add BUILD time stamp.
Copy source file to target, do SWA edits, then add BUILD time stamp.
Copy source file to target do SWA edits then add BUILD time stamp .
def GenerateSwaMainHtml(source, target):
  shutil.copyfile(source, target)
  for line in fileinput.input(target, inplace=True):
    if line.find('<head>') >= 0:
      print(line + '    ' + _SWA)
    elif line.find('<meta ') >= 0:
      sys.stdout.write(line.replace('<meta ', '<meta charset="utf-8" '))
    elif 'rel="import"' in line or 'html-imports' in line:
      continue
    elif line.find('src="foreground/js/main.') == -1:
      sys.stdout.write(line)
  open(target + '.stamp', 'a').close()
def GenerateSwaMainHtml ( source , target ) : shutil . copyfile ( source , target ) for line in fileinput . input ( target , inplace = True ) : if line . find ( '<head>' ) >= 0 : print ( line + '    ' + _SWA ) elif line . find ( '<meta ' ) >= 0 : sys . stdout . write ( line . replace ( '<meta ' , '<meta charset="utf-8" ' ) ) elif 'rel="import"' in line or 'html-imports' in line : continue elif line . find ( 'src="foreground/js/main.' ) == - 1 : sys . stdout . write ( line ) open ( target + '.stamp' , 'a' ) . close ( )
Copy source file to target, do SWA edits, then add BUILD time stamp.
Copy source file to target do SWA edits then add BUILD time stamp .
"""Copy source file to target, do SWA edits, then add BUILD time stamp.""" # Copy source (main.html) file to the target (main.html) file. # Edit the target file. # Add _SWA <script> tag after the <head> tag. # Add <meta> charset="utf-8" attribute. # Ignore HTML Imports and its polyfil. # Remove files app foreground/js <script> tags: SWA app must load # them after the SWA app has initialized needed resources. # Create a BUILD time stamp for the target file.
source
target