Script file generation method and device, computer device and storage medium
By using a modular script file generation method, the problem of requiring full modification of Shell scripts is solved, achieving efficient code reuse and automated generation.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-16
- Publication Date
- 2026-03-17
AI Technical Summary
In existing technologies, Shell script generation requires modifying all templates according to different project requirements, which affects code reusability and weakens the advantages of automated generation.
The configuration information generated by the script file is modularized. By receiving the configuration information input by the user, the target functional module is automatically determined from the general or custom modules and the script file is generated.
It improves code reusability, enhances the advantages of automated generation, reduces manual costs, and adapts to the needs of different business scenarios.
Smart Images

Figure CN115756581B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a script file generation method, apparatus, computer device, and storage medium. Background Technology
[0002] In distributed big data engineering development, the production-level deployment of ETL (Extract-Transform-Load) data processing is mainly achieved through Shell scripts.
[0003] Currently, in existing technologies, Shell script generation mainly involves generating existing code by changing variables and recombining extracted script functions. This often involves extracting commonly used script functions to generate a fixed script template, and then replacing parameters according to different project development needs.
[0004] However, the inventors discovered that the existing technology has at least the following technical problems: if there are major changes in requirements when generating scripts using existing code, all script templates must be changed again, which affects the reusability of existing code and weakens the advantages of automated code generation. Summary of the Invention
[0005] This application provides a script file generation method, apparatus, computer device, and storage medium to solve the problem that existing technologies require modifying all script templates when generating scripts using existing code, resulting in low reusability of existing code.
[0006] Firstly, this application provides a script file generation method, applied to a computer device, comprising:
[0007] Receive script configuration files, wherein the script configuration files include script configuration information input by the user;
[0008] Determine the script configuration information type for each script configuration information;
[0009] The target script function module is determined from each script function module according to the script configuration information type; wherein each script function module has a corresponding executor;
[0010] Start the executor corresponding to each target script function module to obtain the script template corresponding to each target script function module, and write the script configuration information corresponding to the target script function module into the script template to obtain the code text corresponding to each target script function module;
[0011] The various code texts are aggregated to generate a script file.
[0012] In one possible design, the user-inputted script configuration information includes basic configuration information and custom configuration information. Accordingly, determining the script configuration information type of each script configuration information includes: reading the script configuration information to identify the script configuration information type of each script configuration information, wherein the script configuration information type includes basic configuration information and custom configuration information. Accordingly, determining the target script function module from each script function module based on the script configuration information type includes: if the script configuration information is basic configuration information, then determining the target general script function module from each general script function module; if the script configuration information is custom configuration information, then determining the target custom script function module from each custom script function module.
[0013] In one possible design, the step of activating the executor corresponding to each target script function module to obtain the script template corresponding to each target script function module, and writing the script configuration information corresponding to the target script function module into the script template to obtain the code text corresponding to each target script function module includes: calling the target general script function module according to the basic configuration information, activating the executor corresponding to each target general script function module to obtain the script template corresponding to each target general script function module; writing the script configuration information corresponding to the target general script function module into the corresponding script template to obtain the code text corresponding to each target general script function module; calling the target custom script function module according to the custom configuration information, activating the executor corresponding to each target custom script function module to obtain the script template corresponding to each target custom script function module; and writing the script configuration information corresponding to the target custom script function module into the corresponding script template to obtain the code text corresponding to each target custom script function module.
[0014] In one possible design, the script configuration information input by the user includes a preset code writing order; the aggregation of the code texts to generate a script file includes: obtaining the corresponding code from each code text; and writing each code into a blank script file in the preset code writing order to generate a script file.
[0015] In one possible design, after aggregating the various code texts to generate a script file, the method further includes: validating the legality of the script configuration information corresponding to the target script function module written in the script template; if the validation fails, outputting a prompt message; if the validation passes, validating the execution logic of the script file; if the validation passes, outputting the script file; if the validation fails, outputting a prompt message.
[0016] Secondly, this application provides a script file generation apparatus, applied to a computer device, comprising:
[0017] A receiving module is used to receive script configuration files, wherein the script configuration files include script configuration information input by the user;
[0018] The first determining module is used to determine the script configuration information type of each script configuration information;
[0019] The second determining module is used to determine the target script function module from each script function module according to the script configuration information type; wherein each script function module is provided with a corresponding executor;
[0020] The writing module is used to start the executor corresponding to each target script function module, obtain the script template corresponding to each target script function module, and write the script configuration information corresponding to the target script function module into the script template to obtain the code text corresponding to each target script function module.
[0021] The aggregation module is used to aggregate various code texts to generate script files.
[0022] In one possible design, the user-inputted script configuration information includes basic configuration information and custom configuration information. The first determining module is specifically configured to read the script configuration information to identify the script configuration information type of each script configuration information. The second determining module is specifically configured to determine a target general script function module from among the general script function modules if the script configuration information is basic configuration information; and to determine a target custom script function module from among the custom script function modules if the script configuration information is custom configuration information.
[0023] In one possible design, the writing module is specifically used to: call the target general script function module according to the basic configuration information; start the executor corresponding to each target general script function module to obtain the script template corresponding to each target general script function module; write the script configuration information corresponding to the target general script function module into the corresponding script template to obtain the code text corresponding to each target general script function module; call the target custom script function module according to the custom configuration information; start the executor corresponding to each target custom script function module to obtain the script template corresponding to each target custom script function module; write the script configuration information corresponding to the target custom script function module into the corresponding script template to obtain the code text corresponding to each target custom script function module.
[0024] Thirdly, this application provides a computer device, including: a memory and a processor;
[0025] The memory is used to store computer programs / instructions; the processor is used to implement the script file generation method as described in the first aspect and any possible design of the first aspect, according to the computer programs / instructions stored in the memory.
[0026] Fourthly, this application provides a readable storage medium storing a computer program / instructions, which, when executed by a processor, are used to implement the script file generation method as described in the first aspect and any possible design of the first aspect.
[0027] The script file generation method, apparatus, computer device, and storage medium provided in this application modularize the configuration information required to generate script files. When writing scripts, only key script configuration information needs to be written into a configuration file. Each module automatically writes the configuration information from the configuration file into a template and aggregates it to generate the script. This enables the addition or deletion of some script functions according to the needs of different user business scenarios by obtaining the configuration information of different modules, without requiring changes to the script template. This results in high code reusability and enhances the advantages of automated code generation. Attached Figure Description
[0028] To more clearly illustrate the technical solutions in this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0029] Figure 1 The flow of a script file generation method provided in an embodiment of this application Figure 1 ;
[0030] Figure 2 An example of a script file generation method provided in an embodiment of this application;
[0031] Figure 3 The flow of a script file generation method provided in an embodiment of this application Figure 2 ;
[0032] Figure 4 A schematic diagram of the structure of a script file generation apparatus provided in an embodiment of this application;
[0033] Figure 5 This is a schematic diagram of the hardware structure of a computer device provided in an embodiment of this application. Detailed Implementation
[0034] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0035] In distributed big data engineering development, the production-level deployment of ETL data processing is primarily implemented through Shell scripts. Shell is a scripting language that provides a way for users to interact with the kernel. It receives user-input commands and sends them to the kernel for execution. Essentially, a script is a file containing instructions in a specific format, which the system can translate or parse using a script interpreter and then execute.
[0036] Currently, in existing technologies, Shell script generation mainly involves generating existing code by changing variables and recombining extracted script functions. This often involves extracting commonly used script functions to generate a fixed script template, and then replacing parameters according to different project development needs.
[0037] However, the generated fixed script templates mostly use a single template, requiring customized script templates for different projects, resulting in high manual costs and limited time savings. Furthermore, if there are significant changes in requirements when generating scripts from existing code, the entire script template must be modified, affecting the reusability of existing code and diminishing the advantages of automated code generation.
[0038] To address the aforementioned issues, this application proposes a script file generation method that modularizes the configuration information required for generating script files. When writing a script, users only need to write the key script configuration information into a configuration file, and each module automatically writes the configuration information from the configuration file into a template and aggregates it to generate the script.
[0039] The technical solutions of this application will be described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments.
[0040] Figure 1 The flow of a script file generation method provided in an embodiment of this application Figure 1 .like Figure 1 As shown, with a computer device as the executing entity, the method in this embodiment may include the following steps:
[0041] S101. Receive the script configuration file, which includes the script configuration information input by the user.
[0042] In this embodiment, the script configuration information input by the user includes basic configuration information and custom configuration information input by the user according to the needs of the project.
[0043] This application primarily uses Python to write the generator part. The basic configuration information input by the user is essential for the generator to run. The main program receives the generator's execution command and the path to the script configuration file, and automatically calls the process controller. The process controller then reads the basic configuration information and custom configuration information from the script configuration file.
[0044] S102. Determine the script configuration information type for each script configuration information.
[0045] In this embodiment, script configuration information is read to identify the script configuration information type of each script configuration information, wherein the script configuration information type includes basic configuration information and custom configuration information.
[0046] Basic configuration information includes: header comment information, public variable configuration information, local log file configuration information, and log library configuration information.
[0047] For example, header comments are used to indicate custom rules, which are then communicated to the system or the Python interpreter. The interpreter is a tool that helps execute Python scripts; the system and the Python interpreter execute the scripts based on these custom rules.
[0048] The information written at the beginning of a Python script, starting with a # symbol, can be a header comment, such as #coding:utf-8. Header comments are not intended to serve the code itself, but rather to be used by the system or interpreter. For example, in #coding:utf-8, the # symbol represents the comment symbol, and the following coding:utf-8 is the comment content.
[0049] The public variable configuration information indicates which public variables to use, the local log file configuration information indicates whether to save the local log file, and the log library configuration information indicates whether to write to the log library.
[0050] S103. Determine the target script function module from each script function module according to the script configuration information type; where each script function module has a corresponding executor.
[0051] In this embodiment, if the script configuration information is basic configuration information, the target general script function module is determined from each general script function module. If the script configuration information is custom configuration information, the target custom script function module is determined from each custom script function module.
[0052] Specifically, the general script function modules include: header comment module, public variable configuration module, local log file configuration module, and log library configuration module. These general script function modules are standardized, generic modules.
[0053] The custom script functionality modules include: a local data import module, an SQL executor module, and personalized functionality modules that users can customize according to their own needs.
[0054] Each module in the general script function module and the custom script function module contains three parts: the script configuration file corresponding to the module, the executor corresponding to the module, and the script template corresponding to the module. When a module needs to be called, the executor is first started. The executor reads the script template corresponding to the module, and then writes the script configuration information in the script configuration file corresponding to the module into the script template corresponding to the module, thus obtaining the code text corresponding to the module.
[0055] S104. Start the executor corresponding to each target script function module to obtain the script template corresponding to each target script function module, and write the script configuration information corresponding to the target script function module into the script template to obtain the code text corresponding to each target script function module.
[0056] In this embodiment, the target general script function modules are invoked based on the basic configuration information, and the executors corresponding to each target general script function module are started to obtain the script templates corresponding to each target general script function module. The script configuration information corresponding to each target general script function module is written into the corresponding script template to obtain the code text corresponding to each target general script function module.
[0057] Based on the custom configuration information, the target custom script function modules are invoked, and the corresponding executors for each target custom script function module are launched to obtain the script templates for each target custom script function module. The script configuration information for each target custom script function module is written into the corresponding script templates to obtain the code text for each target custom script function module.
[0058] Specifically, in this application, after the main program receives the generator's execution instruction and the path to the script configuration file, it automatically calls the process controller. The process controller reads the basic configuration information and custom configuration information in the script configuration file, and then calls the target general script function module according to the basic configuration information and the target custom script function module according to the custom configuration information. The executor corresponding to the module is started, and the executor completes the process of obtaining the code text. This process has been explained in S103 and will not be repeated here.
[0059] S105. Aggregate the various code texts to generate a script file.
[0060] In this embodiment, the script configuration information input by the user in step S101 includes a preset code writing order.
[0061] Specifically, the code texts are aggregated to generate a script file, including: obtaining the corresponding code from each code text, and writing each code into a blank script file in a preset code writing order to generate a script file.
[0062] The script configuration file contains various pre-defined business scenarios based on user needs. Each scenario has a specific code writing order, and this order varies between different scenarios. Based on the script configuration file (i.e., the script configuration information entered by the user), the code writing order is fixed. When it's necessary to aggregate the code text, the code is written to a blank script file according to the pre-defined writing order.
[0063] Figure 2 This is an example of a script file generation method provided in an embodiment of this application. For example... Figure 2 As shown, the script function modules include general script function modules and custom script function modules, and the custom script function modules include semi-custom script function modules and custom script function modules.
[0064] The general script functional modules include: header comment module, public variable configuration module, local log file configuration module, and log database configuration module. Semi-custom script functional modules include: local data import module and SQL executor module, etc. Custom script functional modules include: Custom Module 1 and Custom Module 2, etc., which can be customized to meet specific needs.
[0065] like Figure 2 As shown, the script file generation process is as follows:
[0066] (1) The generator part is written in Python. After the generator is written, the main program receives the generator's execution instructions and the path to the script configuration file. It will automatically call the flow controller, which reads the script configuration information in the script configuration file and determines the target script function module from each script function module according to the script configuration information type. The target script function module must include the target general script function module, and may also include one or more modules from the target semi-custom script function module and the target custom script function module.
[0067] (2) After the target script function modules required by all scripts are determined, the process controller calls the executor of each target script function module. Each executor generates the code text corresponding to each target script function module and temporarily stores the code text in memory.
[0068] (3) After all the target script function modules have generated code files, the process controller will aggregate the execution results of each target script function module executor according to the preset code writing order and write them into a blank script file to verify the legality of the script configuration information corresponding to the target script function module and the running logic of the script file.
[0069] (4) If the verification passes, the process controller will output the generated script file to the specified directory.
[0070] In summary, the script file generation method provided in this application modularizes the configuration information required to generate script files. When writing scripts, only key script configuration information needs to be written into the configuration file. Each module automatically writes the configuration information from the configuration file into the template and aggregates it to generate the script. This enables the addition or deletion of some script functions based on the configuration information of different modules according to the needs of different user business scenarios, without requiring changes to the script template. This results in high code reusability and enhances the advantages of automated code generation.
[0071] Figure 3 The flow of a script file generation method provided in an embodiment of this application Figure 2 .like Figure 3 As shown, with a computer device as the execution entity, the method of this embodiment, after step S105 above, mainly describes the process of verifying the legality of the script configuration information in the script file generation method and verifying the running logic of the generated script file, which may include the following steps:
[0072] S301. Verify the validity of the script configuration information corresponding to the target script function module written into the script template.
[0073] In this embodiment, the validity of the script configuration information written into the script template is verified, including: the script configuration information written into the script template includes various parameter texts, such as file paths, IP addresses, etc. These parameter texts have fixed writing methods. The validity of the script configuration information written into the script template is verified by: verifying these parameter texts according to the fixed writing methods. If the writing of these parameter texts conforms to their fixed writing methods, the verification passes; if they do not conform to their fixed writing methods, the verification fails.
[0074] S302. If the verification fails, output a prompt message; if the verification passes, verify the execution logic of the script file.
[0075] In this embodiment, if the verification fails, a prompt message will be output indicating that the script configuration information corresponding to the target script function module written in the script template is invalid.
[0076] In this embodiment, the execution logic of the script file is verified, including: for a preset business scenario, the execution logic of the script file is also preset, and the execution logic of the script file is verified according to the preset execution logic of the script file.
[0077] For example, the default logic for a script file that a user wants to generate to write local logs is: first create a file, then write the logs to the file, and finally clear the file after execution. If the execution logic of the final generated script file is the same as this default logic, the validation passes; if the execution logic of the script file is different from this default logic, the validation fails.
[0078] S303. If the verification passes, output the script file; if the verification fails, output the prompt message.
[0079] In this embodiment, if the verification fails, a message indicating that the script file's execution logic is invalid will be output.
[0080] In summary, the script file generation method provided in this application can obtain script files that meet the business requirements of the user's preset business scenarios by verifying the legality of the script configuration information corresponding to the target script function module written in the script template and verifying the running logic of the script file, thus ensuring the quality of the generated script files.
[0081] Figure 4 This is a schematic diagram of the structure of a script file generation device provided in an embodiment of this application, as shown below. Figure 4 As shown, the script file generation device of this embodiment is used to implement the operation corresponding to the computer device in any of the above method embodiments. The script file generation device of this embodiment includes: a receiving module 401, a first determining module 402, a second determining module 403, a writing module 404, and an aggregation module 405.
[0082] The receiving module 401 is used to receive the script configuration file, wherein the script configuration file includes the script configuration information input by the user;
[0083] The first determining module 402 is used to determine the script configuration information type of each script configuration information;
[0084] The second determining module 403 is used to determine the target script function module from each script function module according to the script configuration information type; wherein each script function module has a corresponding executor;
[0085] The writing module 404 is used to start the executor corresponding to each target script function module, obtain the script template corresponding to each target script function module, and write the script configuration information corresponding to the target script function module into the script template to obtain the code text corresponding to each target script function module.
[0086] The aggregation module 405 is used to aggregate various code texts to generate a script file.
[0087] In one possible implementation, the script configuration information input by the user includes basic configuration information and custom configuration information. The first determining module 402 is specifically used to read the script configuration information to identify the script configuration information type of each script configuration information. The second determining module 403 is specifically used to determine the target general script function module from each general script function module if the script configuration information is basic configuration information; and to determine the target custom script function module from each custom script function module if the script configuration information is custom configuration information.
[0088] In one possible implementation, the writing module 404 is specifically used to call the target general script function module according to the basic configuration information, start the executor corresponding to each target general script function module, and obtain the script template corresponding to each target general script function module; call the target custom script function module according to the custom configuration information, start the executor corresponding to each target custom script function module, and obtain the script template corresponding to each target custom script function module; write the script configuration information corresponding to the target general script function module into the corresponding script template to obtain the code text corresponding to each target general script function module; and write the script configuration information corresponding to the target custom script function module into the corresponding script template to obtain the code text corresponding to each target custom script function module.
[0089] In one possible implementation, the user-input script configuration information includes a preset code writing order. The aggregation module 405 is specifically used to retrieve the corresponding code from each code text; and to write the code sequentially into a blank script file according to the preset code writing order to generate a script file.
[0090] In one possible implementation, the script file generation device further includes: a verification module 406, used to verify the legality of the script configuration information corresponding to the target script function module written in the script template; if the verification fails, a prompt message is output; if the verification passes, the running logic of the script file is verified; if the verification passes, the script file is output; if the verification fails, a prompt message is output.
[0091] The script file generation device provided in this application embodiment can execute the above method embodiment. Its specific implementation principle and technical effect can be found in the above method embodiment, and will not be repeated here.
[0092] Figure 5 This is a schematic diagram of the hardware structure of a computer device provided in an embodiment of this application. Figure 5 As shown, the computer device is used to implement the operation corresponding to the computer device in any of the above method embodiments. The computer device in this embodiment may include: memory 502 and processor 501.
[0093] Memory 502 is used to store computer programs. Memory 502 may include high-speed random access memory (RAM) and may also include non-volatile memory (NVM), such as at least one disk storage device, or a USB flash drive, external hard drive, read-only memory, disk, or optical disc, etc.
[0094] Processor 501 is used to execute computer programs stored in memory to implement the script file generation method in the above embodiments. For details, please refer to the relevant descriptions in the foregoing method embodiments. The processor 501 can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), etc. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in this invention can be directly manifested as execution by a hardware processor, or execution by a combination of hardware and software modules within the processor.
[0095] Alternatively, the memory 502 can be either standalone or integrated with the processor 501.
[0096] When the memory 502 is a device independent of the processor 501, the computer device may also include a bus 503. This bus 503 is used to connect the memory 502 and the processor 501. The bus 503 may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of illustration, the buses shown in the accompanying drawings are not limited to a single bus or a single type of bus.
[0097] The computer device provided in this embodiment can be used to execute the above-described script file generation method. Its implementation and technical effects are similar, and will not be described again here.
[0098] This application also provides a computer-readable storage medium storing a computer program / instructions, which, when executed by a processor, are used to implement the methods provided in the various embodiments described above.
[0099] The computer-readable storage medium can be a computer storage medium or a communication medium. A communication medium includes any medium that facilitates the transfer of a computer program from one location to another. A computer storage medium can be any available medium accessible to a general-purpose or special-purpose computer. For example, a computer-readable storage medium is coupled to a processor, enabling the processor to read information from and write information to the computer-readable storage medium. Of course, the computer-readable storage medium can also be a component of the processor. The processor and the computer-readable storage medium can reside in an Application Specific Integrated Circuit (ASIC). Alternatively, the ASIC can reside in a user equipment. Of course, the processor and the computer-readable storage medium can also exist as discrete components in a communication device.
[0100] Specifically, the computer-readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as Static Random-Access Memory (SRAM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Erasable Programmable Read Only Memory (EPROM), Programmable Read-Only Memory (PROM), Read-Only Memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. The storage medium can be any available medium accessible to general-purpose or special-purpose computers.
[0101] This application also provides a computer program product comprising a computer program / instructions stored in a computer-readable storage medium. At least one processor of the device can read the computer program / instructions from the computer-readable storage medium, and the at least one processor executes the computer program / instructions to cause the device to perform the methods provided in the various embodiments described above.
[0102] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or modules may be electrical, mechanical, or other forms.
[0103] The modules can be physically separate, for example, installed in different locations within a single device, installed on different devices, distributed across multiple network units, or distributed across multiple processors. Alternatively, the modules can be integrated, for example, installed in the same device, or integrated into a single codebase. The modules can exist in hardware form, software form, or a combination of both. This application can select some or all of the modules to achieve the objectives of this embodiment based on actual needs.
[0104] When the various modules are implemented as integrated software functional modules, they can be stored in a computer-readable storage medium. The aforementioned software functional modules, stored in a storage medium, include several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute some steps of the methods of the various embodiments of this application.
[0105] It should be understood that although the steps in the flowcharts of the above embodiments are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some of the steps in the figures may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the sub-steps or stages of other steps.
[0106] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and not to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features. These modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.
Claims
1. A script file generation method characterized by comprising: The application is applied to a computer device, and comprises: receiving a script configuration file, wherein the script configuration file comprises user-input script configuration information; the user-input script configuration information comprises user-input basic configuration information and custom configuration information; determining the script configuration information type of the script configuration information, comprising reading the script configuration information to identify the script configuration information type of each script configuration information, wherein the script configuration information type comprises basic configuration information and custom configuration information; determining a target script function module from each script function module according to the script configuration information type, comprising determining a target general script function module from each general script function module if the script configuration information is basic configuration information, and determining a target custom script function module from each custom script function module if the script configuration information is custom configuration information; wherein each script function module is provided with a corresponding executor; starting the corresponding executor of each target script function module to obtain the script template corresponding to each target script function module, and writing the script configuration information corresponding to the target script function module into the script template to obtain the code text corresponding to each target script function module, comprising calling the target general script function module according to the basic configuration information, starting the corresponding executor of each target general script function module to obtain the script template corresponding to each target general script function module, and writing the script configuration information corresponding to the target general script function module into the corresponding script template to obtain the code text corresponding to each target general script function module; and calling the target custom script function module according to the custom configuration information, starting the corresponding executor of each target custom script function module to obtain the script template corresponding to each target custom script function module, and writing the script configuration information corresponding to the target custom script function module into the corresponding script template to obtain the code text corresponding to each target custom script function module; aggregating each code text to generate a script file.
2. The method of claim 1, wherein, The user-input script configuration information comprises a preset code writing sequence; the aggregation of each code text to generate a script file comprises: obtaining the corresponding code from each code text; writing each code into a blank script file in the preset code writing sequence to generate a script file.
3. The method according to claim 1 or 2, characterized in that, After the aggregation of each code text to generate a script file, the method further comprises: verifying the legality of the script configuration information corresponding to the target script function module written into the script template; if the verification fails, outputting prompt information; if the verification passes, verifying the running logic of the script file; if the verification passes, outputting the script file; if the verification fails, outputting prompt information.
4. A script file generating apparatus characterized by comprising: The application is applied to a computer device, and comprises: a receiving module configured to receive a script configuration file, wherein the script configuration file comprises user-input script configuration information; the user-input script configuration information comprises user-input basic configuration information and custom configuration information; The first determining module is configured to determine a script configuration information type of each script configuration information; The second determining module is further configured to determine a target script function module from each script function module according to the script configuration information type; each script function module is provided with a corresponding executor; The writing module is configured to start the executor corresponding to each target script function module, to obtain a script template corresponding to each target script function module, and to write script configuration information corresponding to the target script function module into the script template to obtain code text corresponding to each target script function module; The aggregation module is configured to aggregate the code texts to generate a script file; The writing module is specifically configured to call a target general script function module according to basic configuration information, to start the executor corresponding to each target general script function module, to obtain a script template corresponding to each target general script function module, to write script configuration information corresponding to the target general script function module into the corresponding script template to obtain code text corresponding to each target general script function module, to call a target custom script function module according to custom configuration information, to start the executor corresponding to each target custom script function module, to obtain a script template corresponding to each target custom script function module, and to write script configuration information corresponding to the target custom script function module into the corresponding script template to obtain code text corresponding to each target custom script function module; The first determining module is specifically configured to read the script configuration information to identify the script configuration information type of each script configuration information; The second determining module is specifically configured to determine a target general script function module from each general script function module if the script configuration information is basic configuration information, and to determine a target custom script function module from each custom script function module if the script configuration information is custom configuration information.
5. A computer device, comprising: comprise: a memory, a processor; the memory is configured to store computer programs / instructions; the processor is configured to implement the script file generation method according to the computer programs / instructions stored in the memory.
6. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer programs / instructions, and the computer programs / instructions are executed by the processor to implement the script file generation method according to any one of claims 1 to 3.
Citation Information
Patent Citations
Code generation method and code generation device
CN113268229A
Script file generation method and device, equipment and storage medium
CN114035788A
Code generation method and device, electronic equipment and storage medium
CN114741070A