当前位置: 首页>>代码示例>>Python>>正文


Python MultiLanguage.MultiLanguage类代码示例

本文整理汇总了Python中MultiLanguage.MultiLanguage的典型用法代码示例。如果您正苦于以下问题:Python MultiLanguage类的具体用法?Python MultiLanguage怎么用?Python MultiLanguage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了MultiLanguage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _gather_sign_info

    def _gather_sign_info(self):
        user_cfg = {}
        # get the path of keystore file
        while True:
            inputed = self._get_user_input(MultiLanguage.get_string('COMPILE_TIP_INPUT_KEYSTORE'))
            inputed = inputed.strip()
            if not os.path.isabs(inputed):
                if self.use_studio:
                    start_path = os.path.join(self.app_android_root, 'app')
                else:
                    start_path = self.app_android_root
                abs_path = os.path.join(start_path, inputed)
            else:
                abs_path = inputed

            if os.path.isfile(abs_path):
                user_cfg[self.key_store_str] = inputed
                break
            else:
                cocos.Logging.warning(MultiLanguage.get_string('COMPILE_INFO_NOT_A_FILE'))

        # get the alias of keystore file
        user_cfg[self.key_alias_str] = self._get_user_input(MultiLanguage.get_string('COMPILE_TIP_INPUT_ALIAS'))

        # get the keystore password
        user_cfg[self.key_store_pass_str] = self._get_user_input(MultiLanguage.get_string('COMPILE_TIP_INPUT_KEY_PASS'))

        # get the alias password
        user_cfg[self.key_alias_pass_str] = self._get_user_input(MultiLanguage.get_string('COMPILE_TIP_INPUT_ALIAS_PASS'))

        # write the config into ant.properties
        self._write_sign_properties(user_cfg)
开发者ID:dabingnn,项目名称:cocosVR,代码行数:32,代码来源:build_android.py

示例2: _scan

    def _scan(self):
        template_pattern = {
            "cpp": 'cpp-template-(.+)',
            "lua": 'lua-template-(.+)',
            "js": 'js-template-(.+)',
        }

        self._template_folders = {}

        for templates_dir in self._templates_paths:
            try:
                dirs = [name for name in os.listdir(templates_dir) if os.path.isdir(
                    os.path.join(templates_dir, name))]
            except Exception:
                continue

            pattern = template_pattern[self._lang]
            for name in dirs:
                match = re.search(pattern, name)
                if match is None:
                    continue

                template_name = match.group(1)
                if template_name in self._template_folders.keys():
                    continue

                self._template_folders[template_name] = os.path.join(templates_dir, name)

        if len(self._template_folders) == 0:
            cur_engine = "cocos2d-x" if self._lang == "js" else "cocos2d-js"
            need_engine = "cocos2d-js" if self._lang == "js" else "cocos2d-x"
            engine_tip = MultiLanguage.get_string('NEW_ERROR_ENGINE_TIP_FMT', need_engine)
            message = MultiLanguage.get_string('NEW_ERROR_TEMPLATE_NOT_FOUND_FMT', (self._lang, engine_tip))
            raise cocos.CCPluginError(message, cocos.CCPluginError.ERROR_PATH_NOT_FOUND)
开发者ID:boruis,项目名称:cocos2dx-lite,代码行数:34,代码来源:project_new.py

示例3: get_build_cfg_json_path

    def get_build_cfg_json_path(self):
        file_path = self._project["proj.android"] + os.sep + "build-cfg.json"
        if not os.path.isfile(file_path):
            print MultiLanguage.get_string('PACKAGE_BUILD_CFG_NOT_FOUND')
            return

        return file_path
开发者ID:DmitryDronov,项目名称:Test1,代码行数:7,代码来源:add_framework_helper.py

示例4: __init__

    def __init__(self, lang, cocos_root, project_name, project_dir, tp_name, tp_dir, project_package, mac_id, ios_id):
        self.lang = lang
        self.cocos_root = cocos_root
        self.project_dir = project_dir
        self.project_name = project_name
        self.package_name = project_package
        self.mac_bundleid = mac_id
        self.ios_bundleid = ios_id

        self.tp_name = tp_name
        self.tp_dir = tp_dir
        self.tp_json = 'cocos-project-template.json'

        tp_json_path = os.path.join(tp_dir, self.tp_json)
        if not os.path.exists(tp_json_path):
            message = MultiLanguage.get_string('NEW_WARNING_FILE_NOT_FOUND_FMT', tp_json_path)
            raise cocos.CCPluginError(message, cocos.CCPluginError.ERROR_PATH_NOT_FOUND)

        f = open(tp_json_path)
        # keep the key order
        tpinfo = json.load(f, encoding='utf8', object_pairs_hook=OrderedDict)

        # read the default creating step
        if 'do_default' not in tpinfo:
            message = (MultiLanguage.get_string('NEW_ERROR_DEFAILT_CFG_NOT_FOUND_FMT', tp_json_path))
            raise cocos.CCPluginError(message, cocos.CCPluginError.ERROR_WRONG_CONFIG)
        self.tp_default_step = tpinfo.pop('do_default')
        # keep the other steps
        self.tp_other_step = tpinfo
开发者ID:boruis,项目名称:cocos2dx-lite,代码行数:29,代码来源:project_new.py

示例5: parse_args

    def parse_args(self, argv):
        """Custom and check param list.
        """
        parser = ArgumentParser(prog="cocos %s" % self.__class__.plugin_name(),
                                description=self.__class__.brief_description())
        parser.add_argument('-c', dest='clean', action="store_true",
                            help=MultiLanguage.get_string('GEN_LIBS_ARG_CLEAN'))
        parser.add_argument('-e', dest='engine_path', help=MultiLanguage.get_string('GEN_LIBS_ARG_ENGINE'))
        parser.add_argument('-p', dest='platform', action="append", choices=['ios', 'mac', 'android', 'win32'],
                            help=MultiLanguage.get_string('GEN_LIBS_ARG_PLATFORM'))
        parser.add_argument('-m', "--mode", dest='compile_mode', default='release', choices=['debug', 'release'],
                            help=MultiLanguage.get_string('GEN_LIBS_ARG_MODE'))
        parser.add_argument('--dis-strip', dest='disable_strip', action="store_true",
                            help=MultiLanguage.get_string('GEN_LIBS_ARG_DISABLE_STRIP'))
        group = parser.add_argument_group(MultiLanguage.get_string('GEN_LIBS_GROUP_WIN'))
        group.add_argument('--vs', dest='vs_version', type=int, default=None,
                           help=MultiLanguage.get_string('GEN_LIBS_ARG_VS'))
        group = parser.add_argument_group(MultiLanguage.get_string('GEN_LIBS_GROUP_ANDROID'))
        group.add_argument("--app-abi", dest="app_abi",
                            help=MultiLanguage.get_string('GEN_LIBS_ARG_ABI'))
        group.add_argument("--ap", dest="android_platform",
                            help=MultiLanguage.get_string('COMPILE_ARG_AP'))

        (args, unknown) = parser.parse_known_args(argv)
        self.init(args)

        return args
开发者ID:FenneX,项目名称:FenneXEmptyProject,代码行数:27,代码来源:gen_libs.py

示例6: run

    def run(self, argv, dependencies):
        """
        """
        self.parse_args(argv)

        # create output directory
        try:
            os.makedirs(self._dst_dir)
        except OSError:
            if os.path.exists(self._dst_dir) == False:
                raise cocos.CCPluginError(MultiLanguage.get_string('LUACOMPILE_ERROR_MKDIR_FAILED_FMT', self._dst_dir),
                                          cocos.CCPluginError.ERROR_PATH_NOT_FOUND)

        # download the bin folder
        jsbcc_exe_path = os.path.join(self._workingdir, "bin", "jsbcc")
        if not os.path.exists(jsbcc_exe_path):
            download_cmd_path = os.path.join(self._workingdir, os.pardir, os.pardir)
            subprocess.call("python %s -f -r no" % (os.path.join(download_cmd_path, "download-bin.py")), shell=True, cwd=download_cmd_path)

        # deep iterate the src directory
        for src_dir in self._src_dir_arr:
            self._current_src_dir = src_dir
            self._js_files[self._current_src_dir] = []
            self.deep_iterate_dir(src_dir)

        self.reorder_js_files()
        self.handle_all_js_files()
        cocos.Logging.info(MultiLanguage.get_string('LUACOMPILE_INFO_FINISHED'))
开发者ID:dios-game,项目名称:dios-cocos,代码行数:28,代码来源:__init__.py

示例7: parse_args

    def parse_args(self, argv):
        if len(argv) < 1:
            print "usage: cocos framework [-h] COMMAND arg [arg ...]"
            print MultiLanguage.get_string('FRAMEWORK_ERROR_TOO_FEW_ARGS')
            return None

        return {"command": argv[0]}
开发者ID:DmitryDronov,项目名称:Test1,代码行数:7,代码来源:plugin_framework.py

示例8: project_rename

    def project_rename(self, v):
        """ will modify the file name of the file
        """
        dst_project_dir = self.project_dir
        dst_project_name = self.project_name
        src_project_name = v['src_project_name']
        if dst_project_name == src_project_name:
            return

        cocos.Logging.info(MultiLanguage.get_string('NEW_INFO_STEP_RENAME_PROJ_FMT',
                                                    (src_project_name, dst_project_name)))
        files = v['files']
        for f in files:
            src = f.replace("PROJECT_NAME", src_project_name)
            dst = f.replace("PROJECT_NAME", dst_project_name)
            src_file_path = os.path.join(dst_project_dir, src)
            dst_file_path = os.path.join(dst_project_dir, dst)
            if os.path.exists(src_file_path):
                if dst_project_name.lower() == src_project_name.lower():
                    temp_file_path = "%s-temp" % src_file_path
                    os.rename(src_file_path, temp_file_path)
                    os.rename(temp_file_path, dst_file_path)
                else:
                    if os.path.exists(dst_file_path):
                        os.remove(dst_file_path)
                    os.rename(src_file_path, dst_file_path)
            else:
                cocos.Logging.warning(MultiLanguage.get_string('NEW_WARNING_FILE_NOT_FOUND_FMT',
                                                               os.path.join(dst_project_dir, src)))
开发者ID:boruis,项目名称:cocos2dx-lite,代码行数:29,代码来源:project_new.py

示例9: update_framework

    def update_framework(cls, project, package_name):
        cls.show_project_info(project)

        package = cls.check_added_package(project, package_name)
        if package is None:
            print MultiLanguage.get_string('PACKAGE_PKG_NOT_FOUND_FMT', package_name)
            return

        engine = get_engine_of_project(project)
        if engine is None:
            print MultiLanguage.get_string('PACKAGE_PROJ_UNKOWN_ENGINE')
            return

        package_data = PackageHelper.get_installed_package_newest_version(package_name, engine)
        if package_data is None:
            print MultiLanguage.get_string('PACKAGE_NOT_FOUND_PKG_FMT', (package_name, engine, package_name))
            return
        newest_version = package_data["version"]

        dir = package["dir_path"]
        if compare_version(newest_version, package["version"]) < 1:
            print MultiLanguage.get_string('PACKAGE_PKG_IS_NEWEST_FMT', (package_name, package_name))
            return
        cls.remove_framework(project, package_name)
        cls.add_framework(project, package_name)
        print MultiLanguage.get_string('PACKAGE_PROJ_PKG_UPDATE_OK')
开发者ID:DmitryDronov,项目名称:Test1,代码行数:26,代码来源:project_helper.py

示例10: load_proj_ios_mac

    def load_proj_ios_mac(self, notSplitLines = False):
        if not "proj.ios_mac" in self._project:
            print MultiLanguage.get_string('PACKAGE_MAC_NOT_FOUND')
            return

        workdir = self._project["proj.ios_mac"]
        files = os.listdir(workdir)
        for filename in files:
            if filename[-10:] == ".xcodeproj":
                proj_dir = filename
                break

        if proj_dir is None:
            print MultiLanguage.get_string('PACKAGE_XCODE_PROJ_NOT_FOUND')
            return

        if not os.path.isdir(workdir + os.sep + proj_dir):
            raise cocos.CCPluginError(MultiLanguage.get_string('PACKAGE_NOT_XCODE_PROJ_FMT', proj_dir),
                                      cocos.CCPluginError.ERROR_PATH_NOT_FOUND)

        proj_file_path = workdir + os.sep + proj_dir + os.sep + "project.pbxproj"
        f = open(proj_file_path, "rb")
        if notSplitLines == True:
            lines = f.read()
        else:
            lines = f.readlines()
        f.close()

        return workdir, proj_file_path, lines
开发者ID:DmitryDronov,项目名称:Test1,代码行数:29,代码来源:add_framework_helper.py

示例11: run

    def run(self, argv, dependencies):
        """
        """
        self.parse_args(argv)

        # tips
        cocos.Logging.warning(MultiLanguage.get_string("LUACOMPILE_WARNING_TIP_MSG"))
        # create output directory
        try:
            os.makedirs(self._dst_dir)
        except OSError:
            if os.path.exists(self._dst_dir) == False:
                raise cocos.CCPluginError(
                    MultiLanguage.get_string("LUACOMPILE_ERROR_MKDIR_FAILED_FMT", self._dst_dir),
                    cocos.CCPluginError.ERROR_PATH_NOT_FOUND,
                )

        # deep iterate the src directory
        for src_dir in self._src_dir_arr:
            self._current_src_dir = src_dir
            self._lua_files[self._current_src_dir] = []
            self.deep_iterate_dir(src_dir)

        self.handle_all_lua_files()

        cocos.Logging.info(MultiLanguage.get_string("LUACOMPILE_INFO_FINISHED"))
开发者ID:quinsmpang,项目名称:cocos2d-x-Fmod,代码行数:26,代码来源:__init__.py

示例12: set_win32

    def set_win32(self, proj_id, build_id):
        text = self.load_install_json()
        if text is None:
            print MultiLanguage.get_string("PACKAGE_ERROR_JSON_READ_FAILED")
            return

        find_tag = '(\{\s*"command":\s*"add_project",\s*"name":\s*"\S*",\s*"project_id":\s*")(\S*)(",\s*"build_id":\s*")(\S*)(",\s*"platform":\s*"win"\s*\})'
        match = re.search(find_tag, text, re.DOTALL)
        if not match is None:
            old_id = match.group(2)
            text = text.replace(old_id, proj_id)
            old_id = match.group(4)
            text = text.replace(old_id, build_id)
            self.save_install_json(text)
            return

        index = text.find("[")
        if index < 0:
            print MultiLanguage.get_string("PACKAGE_ERROR_JSON_ERROR")
            return

        headers = text[0 : index + 1]
        tails = text[index + 1 :]
        skip_str = "\n\t\t"
        str_to_add = "\n\t{"
        str_to_add += skip_str + '"command": "add_project",'
        str_to_add += skip_str + '"name": "' + self._package_name + '",'
        str_to_add += skip_str + '"project_id": "' + proj_id + '",'
        str_to_add += skip_str + '"build_id": "' + build_id + '",'
        str_to_add += skip_str + '"platform": "win"'
        str_to_add += "\n\t},"
        text = headers + str_to_add + tails
        self.save_install_json(text)
开发者ID:quinsmpang,项目名称:cocos2d-x-Fmod,代码行数:33,代码来源:set_framework_helper.py

示例13: add_files_and_dir

    def add_files_and_dir(self, command):
        backup_flag = command["backup_if_override"]
        package_name = self._package_name
        file_list = command["source"]
        src_dir = self._package_path + os.sep + command["src_dir"]
        dst_dir = self._project["path"] + os.sep + command["dst_dir"]

        for filename in file_list:
            src = src_dir + os.sep + filename
            dst = dst_dir + os.sep + filename

            if os.path.exists(dst):
                if backup_flag:
                    bak = dst + "_bak_by_" + package_name
                    if not os.path.exists(bak):
                        os.rename(dst, bak)
                        self.append_uninstall_info({'bak_file':bak, 'ori_file':dst})
                        self.save_uninstall_info()
                    else:
                        print MultiLanguage.get_string('PACKAGE_UNABLE_COPY_FMT', dst)
                        continue
                else:
                    if os.path.isdir(dst):
                        shutil.rmtree(dst)
                    else:
                        os.remove(dst)
            else:
                ensure_directory(os.path.dirname(dst))

            if os.path.isdir(src):
                shutil.copytree(src, dst)
            else:
                shutil.copy(src, dst)
开发者ID:DmitryDronov,项目名称:Test1,代码行数:33,代码来源:add_framework_helper.py

示例14: add_entry_function

    def add_entry_function(self, command):
        declare_str = command["declare"]
        find_tag = '(\S*\s*)(\S*)(\(.*\);)'
        match = re.search(find_tag, declare_str)
        if match is None:
            raise cocos.CCPluginError(MultiLanguage.get_string('PACKAGE_ENTRY_DECLARE_FAILED'),
                                      cocos.CCPluginError.ERROR_PARSE_FILE)
        else:
            str_to_add = 'extern ' + declare_str + '\n\t' + match.group(2) + '();' + '\n\t'

        file_path, all_text = self.load_appdelegate_file()
        find_tag = '(static int register_all_packages\(\)\s*\{.*)(return 0; //flag for packages manager\s*\})'
        match = re.search(find_tag, all_text, re.DOTALL)
        if match is None:
            raise cocos.CCPluginError(MultiLanguage.get_string('PACKAGE_ERROR_IN_FILE_FMT', file_path),
                                      cocos.CCPluginError.ERROR_PARSE_FILE)
        else:
            # add entry funtion
            split_index = match.end(1)
            headers = all_text[0:split_index]
            tails = all_text[split_index:]
            all_text = headers + str_to_add + tails
            self.append_uninstall_info({'file':file_path, 'string':str_to_add})

        self.update_file_content(file_path, all_text)
开发者ID:DmitryDronov,项目名称:Test1,代码行数:25,代码来源:add_framework_helper.py

示例15: parse_args

    def parse_args(self, argv):
        from argparse import ArgumentParser

        parser = ArgumentParser(prog="cocos package %s" % self.__class__.plugin_name(),
                                description=self.__class__.brief_description())
        parser.add_argument("name", metavar="NAME", help=MultiLanguage.get_string('PACKAGE_INFO_ARG_NAME'))
        parser.add_argument('-v', '--version', default='all', help=MultiLanguage.get_string('PACKAGE_INFO_ARG_VERSION'))
        return parser.parse_args(argv)
开发者ID:DmitryDronov,项目名称:Test1,代码行数:8,代码来源:package_info.py


注:本文中的MultiLanguage.MultiLanguage类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。