tools/json_schema_compiler/preview.py
def _ShowCompiledFile(self, parsed_url, head, body):
    """Show the compiled version of a json or idl file given the path to the
    compiled file.
    """
    api_model = model.Model()

    request_path = self._GetRequestPath(parsed_url)
    (file_root, file_ext) = os.path.splitext(request_path)
    (filedir, filename) = os.path.split(file_root)

    namespace_resolver = NamespaceResolver("./",
                                           filedir,
                                           self.server.include_rules,
                                           self.server.cpp_namespace_pattern)
    try:
      # Get main file.
      namespace = namespace_resolver.ResolveNamespace(filename)
      type_generator = cpp_type_generator.CppTypeGenerator(
           api_model,
           namespace_resolver,
           namespace)

      # Generate code
      if file_ext == '.h':
        cpp_code = (h_generator.HGenerator(type_generator)
            .Generate(namespace).Render())
      elif file_ext == '.cc':
        cpp_code = (cc_generator.CCGenerator(type_generator)
            .Generate(namespace).Render())
      else:
        self.send_error(404, "File not found: %s" % request_path)
        return

      # Do highlighting on the generated code
      (highlighter_param, style_param) = self._GetHighlighterParams(parsed_url)
      head.Append('<style>' +
          self.server.highlighters[highlighter_param].GetCSS(style_param) +
          '</style>')
      body.Append(self.server.highlighters[highlighter_param]
          .GetCodeElement(cpp_code, style_param))
    except IOError:
      self.send_error(404, "File not found: %s" % request_path)
      return
    except (TypeError, KeyError, AttributeError,
        AssertionError, NotImplementedError) as error:
      body.Append('<pre>')
      body.Append('compiler error: %s' % error)
      body.Append('Check server log for more details')
      body.Append('</pre>')
      raise
Show the compiled version of a json or idl file given the path to the
    compiled file.
    
Show the compiled version of a json or idl file given the path to the
compiled file.
Show the compiled version of a json or idl file given the path to the compiled file .
def _ShowCompiledFile(self, parsed_url, head, body):
    api_model = model.Model()
    request_path = self._GetRequestPath(parsed_url)
    (file_root, file_ext) = os.path.splitext(request_path)
    (filedir, filename) = os.path.split(file_root)
    namespace_resolver = NamespaceResolver("./",
                                           filedir,
                                           self.server.include_rules,
                                           self.server.cpp_namespace_pattern)
    try:
      namespace = namespace_resolver.ResolveNamespace(filename)
      type_generator = cpp_type_generator.CppTypeGenerator(
           api_model,
           namespace_resolver,
           namespace)
      if file_ext == '.h':
        cpp_code = (h_generator.HGenerator(type_generator)
            .Generate(namespace).Render())
      elif file_ext == '.cc':
        cpp_code = (cc_generator.CCGenerator(type_generator)
            .Generate(namespace).Render())
      else:
        self.send_error(404, "File not found: %s" % request_path)
        return
      (highlighter_param, style_param) = self._GetHighlighterParams(parsed_url)
      head.Append('<style>' +
          self.server.highlighters[highlighter_param].GetCSS(style_param) +
          '</style>')
      body.Append(self.server.highlighters[highlighter_param]
          .GetCodeElement(cpp_code, style_param))
    except IOError:
      self.send_error(404, "File not found: %s" % request_path)
      return
    except (TypeError, KeyError, AttributeError,
        AssertionError, NotImplementedError) as error:
      body.Append('<pre>')
      body.Append('compiler error: %s' % error)
      body.Append('Check server log for more details')
      body.Append('</pre>')
      raise
def _ShowCompiledFile ( self , parsed_url , head , body ) : api_model = model . Model ( ) request_path = self . _GetRequestPath ( parsed_url ) ( file_root , file_ext ) = os . path . splitext ( request_path ) ( filedir , filename ) = os . path . split ( file_root ) namespace_resolver = NamespaceResolver ( "./" , filedir , self . server . include_rules , self . server . cpp_namespace_pattern ) try : namespace = namespace_resolver . ResolveNamespace ( filename ) type_generator = cpp_type_generator . CppTypeGenerator ( api_model , namespace_resolver , namespace ) if file_ext == '.h' : cpp_code = ( h_generator . HGenerator ( type_generator ) . Generate ( namespace ) . Render ( ) ) elif file_ext == '.cc' : cpp_code = ( cc_generator . CCGenerator ( type_generator ) . Generate ( namespace ) . Render ( ) ) else : self . send_error ( 404 , "File not found: %s" % request_path ) return ( highlighter_param , style_param ) = self . _GetHighlighterParams ( parsed_url ) head . Append ( '<style>' + self . server . highlighters [ highlighter_param ] . GetCSS ( style_param ) + '</style>' ) body . Append ( self . server . highlighters [ highlighter_param ] . GetCodeElement ( cpp_code , style_param ) ) except IOError : self . send_error ( 404 , "File not found: %s" % request_path ) return except ( TypeError , KeyError , AttributeError , AssertionError , NotImplementedError ) as error : body . Append ( '<pre>' ) body . Append ( 'compiler error: %s' % error ) body . Append ( 'Check server log for more details' ) body . Append ( '</pre>' ) raise
Show the compiled version of a json or idl file given the path to the
compiled file.
Show the compiled version of a json or idl file given the path to the compiled file .
"""Show the compiled version of a json or idl file given the path to the
    compiled file.
    """ # Get main file. # Generate code # Do highlighting on the generated code
self
parsed_url
head
body