Exemple #1
0
 def gen_makefile(self):
     mako_file = os.path.join(self.__grpc_mako_dir, 'proto.mak')
     filename = os.path.join(self.__proto_dir, 'makefile')
     # makefile
     tool.gen_code_file(
         mako_file,
         filename,
         proto_package_name=self.__proto_package_name,
     )
Exemple #2
0
 def gen_service_type(self):
     mako_file = os.path.join(self.__grpc_mako_dir, 'service_type.go')
     filename = os.path.join(self.__api_dir,
                             "%s.go" % self.__grpc_service_type)
     tool.gen_code_file(
         mako_file,
         filename,
         package_name=self.__package_api_name,
         grpc_service_type=self.__grpc_service_type,
     )
Exemple #3
0
 def gen_init(self):
     out_file = os.path.join(self.service_dir, 'cmd', 'init_gin.go')
     mako_file = os.path.join(self.__gin_mako_dir, 'init.go')
     # if not os.path.exists(out_file):
     tool.gen_code_file(
         mako_file,
         out_file,
         package_api=self.__package_api,
         package_service_dir=self.package_service_dir,
     )
Exemple #4
0
 def gen_init(self):
     mako_file = os.path.join(self.__grpc_mako_dir, 'init_grpc.go')
     filename = os.path.join(self.service_dir, 'cmd', 'init_grpc.go')
     # if not os.path.exists(output_file):
     tool.gen_code_file(
         mako_file,
         filename,
         package_api_dir=self.__package_api_dir,
         package_proto_dir=self.__package_proto_dir,
         package_service_dir=self.package_service_dir,
         grpc_service_name=self.__grpc_service_name,
     )
Exemple #5
0
 def gen_check_arg(self):
     mako_file = os.path.join(self.__grpc_mako_dir, 'check_arg.go')
     filename = os.path.join(self.__api_dir, 'check_arg.go')
     tool.gen_code_file(
         mako_file,
         filename,
         package_name=self.__package_api_name,
         grpc_service_type=self.__grpc_service_type,
         package_proto_dir=self.__package_proto_dir,
         gen_upper_camel=util.gen_upper_camel,
         apis=self.protocol.apis,
     )
Exemple #6
0
 def gen_define(self):
     out_file = os.path.join(self.__define_dir, 'define.go')
     mako_file = os.path.join(self.__gin_mako_dir, 'define.go')
     tool.gen_code_file(
         mako_file,
         out_file,
         package_name=os.path.basename(self.__define_dir),
         nodes=self.protocol.nodes,
         enums=self.protocol.enums,
         has_file=self.protocol.has_file,
         has_time=self.protocol.has_time,
         gen_upper_camel=util.gen_upper_camel,
     )
Exemple #7
0
 def gen_router(self):
     out_file = os.path.join(self.__api_dir, "router.go")
     mako_file = os.path.join(self.__gin_mako_dir, 'router.go')
     tool.gen_code_file(
         mako_file,
         out_file,
         package_name=self.__api_package_name,
         package_define=self.__package_define,
         package_service_dir=self.package_service_dir,
         apis=self.protocol.apis,
         gen_lower_camel=util.gen_lower_camel,
         # has_file=self.protocol.has_file,
         # has_time=self.protocol.has_time,
     )
Exemple #8
0
 def gen_proto(self):
     # proto
     mako_file = os.path.join(self.__grpc_mako_dir, 'grpc.proto')
     filename = os.path.join(self.__proto_dir,
                             '%s.proto' % self.__proto_package_name)
     tool.gen_code_file(
         mako_file,
         filename,
         package_name=self.__proto_package_name,
         apis=self.protocol.apis,
         grpc_service_name=self.__grpc_service_name,
         gen_upper_camel=util.gen_upper_camel,
         nodes=self.protocol.nodes,
         enums=self.protocol.enums,
     )
Exemple #9
0
 def gen_test(self):
     self.init_test(self.__test_dir)
     mako_file = os.path.join(self.__grpc_mako_dir, 'test.go')
     for api in self.protocol.apis:
         filename = "%s_test.go" % util.gen_upper_camel(api.name)
         filename = os.path.join(self.__test_dir, filename)
         tool.gen_code_file(
             mako_file,
             filename,
             api=api,
             package_proto_dir=self.__package_proto_dir,
             package_service_dir=self.package_service_dir,
             grpc_service_name=self.__grpc_service_name,
             json_input=tool.dict2json(api.req.value_map),
             gen_upper_camel=util.gen_upper_camel,
         )
Exemple #10
0
 def gen_api(self):
     mako_file = os.path.join(self.__grpc_mako_dir, 'api.go')
     for api in self.protocol.apis:
         filename = "%s.go" % api.name
         filename = os.path.join(self.__api_dir, filename)
         if not os.path.exists(filename):
             tool.gen_code_file(
                 mako_file,
                 filename,
                 api=api,
                 # package_grpc_api_dir=self.__package_grpc_api_dir,
                 package_proto_dir=self.__package_proto_dir,
                 package_name=self.__package_api_name,
                 package_errno_dir=self.package_errno_dir,
                 json_output=tool.dict2json(api.resp.value_map),
                 gen_upper_camel=util.gen_upper_camel,
             )
Exemple #11
0
 def gen_test(self):
     self.init_test(self.__test_dir)
     mako_file = os.path.join(self.__gin_mako_dir, 'test.go')
     for api in self.protocol.apis:
         filename = "%s_test.go" % util.gen_upper_camel(api.name)
         filename = os.path.join(self.__test_dir, filename)
         input_text = tool.dict2json(api.req.value_map)
         tool.gen_code_file(
             mako_file,
             filename,
             api=api,
             input_text=input_text,
             package_service_dir=self.package_service_dir,
             service_dir=self.service_dir,
             url_param2text=tool.url_param2text,
             gen_upper_camel=util.gen_upper_camel,
         )
Exemple #12
0
 def gen_api(self):
     mako_file = os.path.join(self.__gin_mako_dir, 'api.go')
     for api in self.protocol.apis:
         filename = "%s.go" % api.name
         filename = os.path.join(self.__api_dir, filename)
         if not os.path.exists(filename):
             tool.gen_code_file(
                 mako_file,
                 filename,
                 api=api,
                 package_name=self.__api_package_name,
                 package_go_gin_define=self.__package_define,
                 package_service_dir=self.package_service_dir,
                 gen_lower_camel=util.gen_lower_camel,
                 go_gin_define_dir=self.__define_dir,
                 json_output=tool.dict2json(api.resp.value_map),
             )