def _emit_snippet_class_doc_string(c): """Emits class doc string.""" doc_string = "" if not c.doc_string else c.doc_string if doc_string: doc_string = "{0}{1}{2}".format(doc_string, gu.emit_line_return(2), gu.emit_indent()) return "{0}{1}{2}".format(gu.emit_line_return(2), gu.emit_indent(), doc_string)
def emit_code(code, c): code += gu.emit_indent() code += c.op_full_name code += ',' code += gu.emit_line_return() return code
def emit_code(code, t): code += "{0}\'{1}\',{2}".format( gu.emit_indent(), t.op_name, gu.emit_line_return()) return code
def emit_code(code, p): code += "{0}{1}{2}# {3}{4}".format( gu.emit_indent(2), pgu.get_property_ctor(p), ''.ljust(50 - len(pgu.get_property_ctor(p))), pgu.get_type_doc_name(p.type), gu.emit_line_return() ) return code
def emit_code(code, p): code += gu.emit_indent() code += "('{0}', {1}, {2}, {3}),".format( pgu.get_property_name(p), pgu.get_type_functional_name(p.type, True), p.is_required, p.is_iterative) code += gu.emit_line_return() return code
def emit_code(code, cnt): prp = c.get_property(cnt[0]) if prp is not None: code += '{0}self.{1} = {2}("{3}"){4}'.format( gu.emit_indent(2), cnt[0], pgu.get_type_functional_name(prp.type), cnt[1], gu.emit_line_return() ) return code
def _emit_snippet_decoding(prp, decoding, type): """Emits a class property decoding.""" def get_decoding_function(): # ... simple/enum types - return type functional name # (is directly mapped to a convertor function). if prp.type.is_simple or prp.type.is_enum: return '\'{0}\''.format(pgu.get_type_functional_name(prp.type)) # ... complex classes - return class functional name. elif prp.type.is_class: type_name = prp.type.name if type is None else type return _get_decoder_function_name(type_name) tmpl = '{0}(\'{1}\', {2}, {3}, \'{4}\'),' return tmpl.format(gu.emit_line_return() + gu.emit_indent(2), prp.name, prp.is_iterative, get_decoding_function(), '' if decoding is None else decoding)
def _emit_snippet_decoding(prp, decoding, type): """Emits a class property decoding.""" def get_decoding_function(): # ... simple/enum types - return type functional name # (is directly mapped to a convertor function). if prp.type.is_simple or prp.type.is_enum: return '\'{0}\''.format(pgu.get_type_functional_name(prp.type)) # ... complex classes - return class functional name. elif prp.type.is_class: type_name = prp.type.name if type is None else type return _get_decoder_function_name(type_name) tmpl = '{0}(\'{1}\', {2}, {3}, \'{4}\'),' return tmpl.format( gu.emit_line_return() + gu.emit_indent(2), prp.name, prp.is_iterative, get_decoding_function(), '' if decoding is None else decoding)