gpu/gles2_conform_support/generate_gles2_embedded_data.py
def AddFiles(self, scan_dir):
    """Scan a folder and embed the contents of files."""
    files_to_embed = os.listdir(scan_dir)
    sub_dirs = []
    for file_to_embed in files_to_embed:
      full_path = os.path.join(scan_dir, file_to_embed)
      ext = os.path.splitext(file_to_embed)[1]
      base_path = full_path[len(self.scan_dir) + 1:]
      if os.path.isdir(full_path):
        if not file_to_embed in GenerateEmbeddedFiles.paths_to_ignore:
          sub_dirs.append(full_path)
      elif ext in GenerateEmbeddedFiles.extensions_to_include:
        if self.base_dir == None:
          print(full_path.replace("\\", "/"))
        else:
          self.count += 1
          name = "_FILE_%s_%d" % (ext.upper(), self.count)
          name = name.replace(".", "_")

          self.files_data_h.write(
              ("extern const char %s[];\n" % name).encode("utf8"))
          self.files_data_c.write(
              ("const char %s[] = \n" % name).encode("utf8"))

          data = open(full_path, "r")
          lines = data.readlines();
          data.close()

          for line in lines:
            line = line.replace("\n", "")
            line = line.replace("\r", "")
            line = line.replace("\\", "\\\\")
            line = line.replace("\"", "\\\"")

            self.files_data_c.write(('"%s\\n"\n' % line).encode("utf8"))

          self.files_data_c.write(b";\n")
          self.files_toc_c.write(("\t{ \"%s\", %s, 0 },\n" % (
              base_path.replace("\\", "/"), name)).encode("utf8"))

    for sub_dir in sub_dirs:
      self.AddFiles(sub_dir)
Scan a folder and embed the contents of files.
Scan a folder and embed the contents of files.
Scan a folder and embed the contents of files .
def AddFiles(self, scan_dir):
    files_to_embed = os.listdir(scan_dir)
    sub_dirs = []
    for file_to_embed in files_to_embed:
      full_path = os.path.join(scan_dir, file_to_embed)
      ext = os.path.splitext(file_to_embed)[1]
      base_path = full_path[len(self.scan_dir) + 1:]
      if os.path.isdir(full_path):
        if not file_to_embed in GenerateEmbeddedFiles.paths_to_ignore:
          sub_dirs.append(full_path)
      elif ext in GenerateEmbeddedFiles.extensions_to_include:
        if self.base_dir == None:
          print(full_path.replace("\\", "/"))
        else:
          self.count += 1
          name = "_FILE_%s_%d" % (ext.upper(), self.count)
          name = name.replace(".", "_")
          self.files_data_h.write(
              ("extern const char %s[];\n" % name).encode("utf8"))
          self.files_data_c.write(
              ("const char %s[] = \n" % name).encode("utf8"))
          data = open(full_path, "r")
          lines = data.readlines();
          data.close()
          for line in lines:
            line = line.replace("\n", "")
            line = line.replace("\r", "")
            line = line.replace("\\", "\\\\")
            line = line.replace("\"", "\\\"")
            self.files_data_c.write(('"%s\\n"\n' % line).encode("utf8"))
          self.files_data_c.write(b";\n")
          self.files_toc_c.write(("\t{ \"%s\", %s, 0 },\n" % (
              base_path.replace("\\", "/"), name)).encode("utf8"))
    for sub_dir in sub_dirs:
      self.AddFiles(sub_dir)
def AddFiles ( self , scan_dir ) : files_to_embed = os . listdir ( scan_dir ) sub_dirs = [ ] for file_to_embed in files_to_embed : full_path = os . path . join ( scan_dir , file_to_embed ) ext = os . path . splitext ( file_to_embed ) [ 1 ] base_path = full_path [ len ( self . scan_dir ) + 1 : ] if os . path . isdir ( full_path ) : if not file_to_embed in GenerateEmbeddedFiles . paths_to_ignore : sub_dirs . append ( full_path ) elif ext in GenerateEmbeddedFiles . extensions_to_include : if self . base_dir == None : print ( full_path . replace ( "\\" , "/" ) ) else : self . count += 1 name = "_FILE_%s_%d" % ( ext . upper ( ) , self . count ) name = name . replace ( "." , "_" ) self . files_data_h . write ( ( "extern const char %s[];\n" % name ) . encode ( "utf8" ) ) self . files_data_c . write ( ( "const char %s[] = \n" % name ) . encode ( "utf8" ) ) data = open ( full_path , "r" ) lines = data . readlines ( ) ; data . close ( ) for line in lines : line = line . replace ( "\n" , "" ) line = line . replace ( "\r" , "" ) line = line . replace ( "\\" , "\\\\" ) line = line . replace ( "\"" , "\\\"" ) self . files_data_c . write ( ( '"%s\\n"\n' % line ) . encode ( "utf8" ) ) self . files_data_c . write ( b";\n" ) self . files_toc_c . write ( ( "\t{ \"%s\", %s, 0 },\n" % ( base_path . replace ( "\\" , "/" ) , name ) ) . encode ( "utf8" ) ) for sub_dir in sub_dirs : self . AddFiles ( sub_dir )
Scan a folder and embed the contents of files.
Scan a folder and embed the contents of files .
"""Scan a folder and embed the contents of files."""
self
scan_dir