Non-standard configuration file analysis method and device, equipment and storage medium
By building a rule base to parse non-standard configuration files and convert them to standard formats, the problem of non-standard configuration files in Linux operating systems is solved, and the system development and maintenance costs are reduced.
Patent Information
- Application Number
- CN202510706774.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-28
- Publication Date
- 2025-08-12
AI Technical Summary
The existing technology is difficult to effectively deal with a large number of configuration files that use non-standard syntax in Linux operating systems, resulting in developers needing to invest a lot of resources in custom parser development, increasing system development and maintenance costs and version iteration risks.
By reading the configuration files to be converted based on the configuration file path, a rule library containing separators, type inference and hierarchical identifier rules is built, the configuration files are parsed and converted into standard formats, and the standard format parser is called for parsing.
It reduces the system development and maintenance costs and version iteration risks, and realizes efficient parsing of non-standard configuration files.
Smart Images

Figure CN120469696A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of software engineering, and in particular to a non-standard configuration file parsing method, a non-standard configuration file parsing device, an electronic device, and a computer-readable storage medium. Background Art
[0002] In the Linux operating system, configuration files are a crucial component of system configuration and management. As the core control medium for system services and applications, their formats are characterized by significant heterogeneity. Traditional solutions primarily parse these files using predefined syntax rules. However, in practice, a large number of critical configuration files utilize non-standard syntax. Existing parsing solutions struggle to effectively handle these non-standard features, forcing developers to invest significant resources in developing customized parsers, significantly increasing system development and maintenance costs and the risk of version iterations. Summary of the Invention
[0003] The purpose of the present invention is to provide a non-standard configuration file parsing method, device, equipment and storage medium, which are applied to the field of software engineering. The method converts configuration files in multiple formats into a standard format configuration file and parses the configuration file through a standard format parser. There is no need to develop a separate parser for each format of configuration file, thereby reducing system development and maintenance costs and version iteration risks.
[0004] To solve the above technical problems, the present invention provides a non-standard configuration file parsing method, comprising:
[0005] Reading a configuration file to be converted based on the configuration file path, and determining a target file type of the configuration file to be converted based on a standardized identifier;
[0006] Build a rule base that includes delimiter rules, type inference rules, and hierarchical identifier rules;
[0007] Parsing the configuration file to be converted based on the rule base to obtain key-value pairs of the target file type and a hierarchical structure between the key-value pairs;
[0008] A configuration file of the target file type is constructed based on the key-value pairs and the hierarchical structure between the key-value pairs, and a parser of the target file type is called to parse the configuration file.
[0009] Optionally, parsing the configuration file to be converted based on the rule base to obtain key-value pairs of the target file type and a hierarchical structure between the key-value pairs includes:
[0010] Reading the number and position of non-alphanumeric characters in the configuration file to be converted, and matching the delimiters in the delimiter rule based on the number and position of the non-alphanumeric characters;
[0011] Determining the key-value pair in the configuration file to be converted based on the delimiter;
[0012] Identify semantic information in the key-value pair based on a type inference rule to obtain the key-value pair of the target file type;
[0013] The hierarchical structure of each of the key-value pairs is read based on the hierarchical identifier rule.
[0014] Optionally, reading the hierarchical structure of each key-value pair based on the hierarchical identifier rule includes:
[0015] Reading the indentation format of the configuration file to be converted;
[0016] Determining a hierarchical identifier for each hierarchical structure in the configuration file to be converted based on the hierarchical identifier rule;
[0017] The hierarchical structure of each of the key-value pairs is read based on the indentation format and / or the hierarchical identifier.
[0018] Optionally, the method further includes:
[0019] Adding annotation rules to the rule base;
[0020] Reading the number and position of non-alphanumeric characters in the configuration file to be converted, and matching annotation characters in the annotation character rule based on the number and position of the non-alphanumeric characters;
[0021] Reading comments of the configuration file to be converted based on the comment symbol;
[0022] Accordingly, constructing a configuration file of the target file type based on the key-value pairs and the hierarchical structure between the key-value pairs includes:
[0023] The configuration file of the target file type is constructed based on the annotations, the key-value pairs, and the hierarchical structure between the key-value pairs.
[0024] Optionally, the method further includes:
[0025] Adding script identification rules to the rule base;
[0026] Identifying a script in the configuration file to be converted based on the script identification rule;
[0027] Accordingly, constructing a configuration file of the target file type based on the key-value pairs and the hierarchical structure between the key-value pairs includes:
[0028] The configuration file of the target file type is constructed based on the script, the key-value pairs, and the hierarchical structure between the key-value pairs.
[0029] Optionally, calling a parser of the target file type to parse the configuration file includes:
[0030] Calling system tools to verify the legitimacy of the configuration file;
[0031] If the configuration file passes the validity check, calling the parser of the target file type to parse the configuration file;
[0032] If the configuration file fails the validity check, an error log of the configuration file to be converted is generated.
[0033] Optionally, the method further includes:
[0034] When the file type of the configuration file to be converted is a third-party self-defined type, the separator rule, the type inference rule, and the level identifier rule of the third-party self-defined type are added to the rule library.
[0035] In order to solve the above technical problems, the present invention provides a non-standard configuration file parsing device, comprising:
[0036] The first module is configured to read a configuration file to be converted based on a configuration file path, and determine a target file type of the configuration file to be converted based on a standardized identifier;
[0037] The second module is used to build a rule base including separator rules, type inference rules and hierarchical identifier rules;
[0038] A third module is configured to parse the configuration file to be converted based on the rule base to obtain key-value pairs of the target file type and a hierarchical structure between the key-value pairs;
[0039] The fourth module is configured to construct a configuration file of the target file type based on the key-value pairs and the hierarchical structure between the key-value pairs, and call a parser of the target file type to parse the configuration file.
[0040] To solve the above technical problems, the present invention provides an electronic device, comprising:
[0041] Memory for storing computer programs;
[0042] A processor is configured to implement the above-mentioned non-standard configuration file parsing method when executing the computer program.
[0043] To solve the above technical problems, the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions. When the computer-executable instructions are executed by a processor, the above-mentioned non-standard configuration file parsing method is implemented.
[0044] It can be seen that the method of the present invention reads the configuration file to be converted based on the configuration file path, determines the target file type of the configuration file to be converted based on the standardized identifier; constructs a rule base containing separator rules, type inference rules and hierarchical identifier rules; parses the configuration file to be converted based on the rule base to obtain the key-value pairs of the target file type and the hierarchical structure between the key-value pairs; constructs the configuration file of the target file type based on the key-value pairs and the hierarchical structure between the key-value pairs, and calls the parser of the target file type to parse the configuration file.
[0045] The method of the present invention converts configuration files in multiple formats into a standardized format and parses the configuration files using a standardized parser, eliminating the need to develop separate parsers for each configuration file format. This reduces system development and maintenance costs and the risk of version iterations. The corresponding devices, equipment, and storage media also have the aforementioned beneficial effects. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are merely embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
[0047] Figure 1 A flowchart of a non-standard configuration file parsing method provided by an embodiment of the present invention;
[0048] Figure 2 This is a structural block diagram of a non-standard configuration file parsing device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0049] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.
[0050] In the Linux operating system, configuration files, as the core control medium for system services and applications, exhibit significant heterogeneity in their formats. Traditional solutions rely primarily on Python built-in libraries (such as configparser, json, and xml.etree) and third-party libraries (such as PyYAML) to parse standardized configuration files in formats such as INI, JSON, YAML, and XML. These structured data can be accurately parsed using predefined syntax rules. However, in real-world Linux applications, a large number of critical configuration files utilize non-standard syntax. Typical examples include, but are not limited to, Nginx virtual host configuration, Keepalived high-availability cluster configuration, and user-defined business rule configuration. Existing parsing solutions struggle to effectively handle these non-standard features, forcing developers to invest significant resources in developing customized parsers, significantly increasing system maintenance costs and version iteration risks. To address these issues, a user-defined dynamic conversion system is urgently needed to convert non-standard configuration files into standard ones based on user needs, enabling precise configuration file modifications.
[0051] The following combination Figure 1 , Figure 1 A flowchart of a non-standard configuration file parsing method provided by an embodiment of the present invention may include:
[0052] S101: Reading a configuration file to be converted based on a configuration file path, and determining a target file type of the configuration file to be converted based on a standardized identifier.
[0053] In this embodiment, two key parameters, the configuration file and the target file type, can be obtained through command line interaction.
[0054] Specifically, the configuration file path to be converted can be obtained, such as the absolute / relative path and file name of the file. The target file type can be determined by declaring a standardized identifier for the file format. In this embodiment, the configuration file path and the standardized identifier can be verified for legitimacy. If the verification is successful, the configuration file to be converted is converted.
[0055] The configuration file to be converted in this embodiment can generally be an uncommon format in the Linux common configuration file format, or a custom format developed by the user through a third party. This embodiment does not limit the specific definition of uncommon formats. Generally, except for the common configuration file format, the other common configuration file formats can be uncommon formats. This embodiment does not limit the specific types of common configuration file formats, which can generally include: JSON (JavaScript Object Notation), YAML (YAML Ain't Markup Language, data serialization language), INI (Initialization), TOML (Tom's Obvious Minimal Language, an easy-to-read and easy-to-write configuration file format) and XML (Extensible Markup Language), etc.
[0056] In this embodiment, the target file type of the configuration file to be converted can be determined based on the standardized identifier. If the standardized identifier read is JSON, it can be determined that the format of the configuration file to be converted needs to be converted into JSON format.
[0057] S102: Construct a rule library including separator rules, type inference rules, and hierarchical identifier rules.
[0058] In this embodiment, a rule base may be constructed to parse the configuration file to be converted through the rule base, and the content in the configuration file to be converted may be parsed into common content.
[0059] This embodiment does not limit the specific method of constructing the rule base. General rules may include separator rules, type inference rules, and hierarchical identifier rules.
[0060] In this embodiment, the delimiter rule specifically declares the type of the delimiter. For example, symbols such as ":", "=", "space", and "\t (tab)" can be determined as delimiters in the delimiter rule.
[0061] In this embodiment, the type of the hierarchical identifier is specifically declared in the hierarchical identifier rule, for example, the section start character can be "[", the section end character can be "]", the block start character can be "{", and the block end character can be "}".
[0062] In this embodiment, the type inference rules in the rule base can be constructed in the form of regular expressions, and the semantic recognition of each content in the configuration file to be converted can be performed through the regular expressions in the type inference rules. Specifically, the type inference rules can include regular expressions:
[0063] "^(true|on|yes)$":"boolean_true"; Identify the boolean value (true) in the key-value pair;
[0064] "^(false|off|no)$":"boolean_false"; Identify the boolean value (false) in the key-value pair;
[0065] "^\\d+$":"integer"; Identify the integer in the key-value pair;
[0066] "^\\${.*}$":"environment_variable"; Identify the environment variable reference in the key-value pair;
[0067] Furthermore, in this embodiment, the configuration file to be converted may also include content such as scripts and comments. Then, comment symbol rules and script recognition rules can be added to the rule library.
[0068] In this embodiment, the comment symbol rules specifically declare the types of comment symbols. For example, the comment prefix symbols can be "#" and " / / ", and the multi-line comment symbols can be " / *" and "* / ".
[0069] In this embodiment, the script recognition rules in the rule library can be constructed in the form of regular expressions, and the script blocks in the configuration file to be converted are recognized through the regular expressions in the script recognition rules. Specifically, the script recognition rules may include the regular expression:
[0070] "^#! / .+\\b(bash|sh|python)\\b"; Identify the special characters in the first line of the script file.
[0071] The script recognition rules can also identify the scripts in the file by declaring script markers. For example, the script markers can be "<<EOF" and "EOF".
[0072] The rule library in this embodiment can include the general rules of the configuration file and can also include user-defined third-party custom rules. That is, when the file type of the configuration file to be converted is a third-party custom type, delimiter rules, type inference rules, and hierarchical identifier rules for the third-party custom type are added to the rule library. The configuration file to be converted is parsed through the delimiter rules, type inference rules, and hierarchical identifier rules for the third-party custom type. And when the configuration file to be converted contains scripts and comments, comment symbol rules and script recognition rules for the third-party custom type need to be added to the rule library synchronously.
[0073] S103: Parse the configuration file to be converted based on the rule library to obtain the key-value pairs of the target file type and the hierarchical structure between the key-value pairs.
[0074] In this embodiment, the configuration file to be converted can be parsed based on the rule base to obtain key-value pairs of the target file type and the hierarchical structure between the key-value pairs.
[0075] This embodiment can read the number and position of non-alphanumeric symbols in the configuration file to be converted, match the delimiters in the delimiter rule based on the number and position of non-alphanumeric symbols; determine the key-value pairs in the configuration file to be converted based on the delimiters; identify the semantic information in the key-value pairs based on the type inference rule to obtain the key-value pairs of the target file type; and read the hierarchical structure of each key-value pair based on the hierarchical identifier rule.
[0076] First, key-value pairs and hierarchical structures can be automatically identified based on statistical features (high-frequency symbols, indentation patterns). By identifying the number and position of non-alphanumeric characters and matching the delimiters in the delimiter rules based on the number and position of non-alphanumeric characters, the delimiters of the configuration files to be converted can be obtained. The delimiters can then be used to identify the key-value pairs of the configuration files to be converted.
[0077] Furthermore, type inference rules can be used to identify the semantic information in the key-value pair and obtain the key-value pair of the target file type. For example, the identified true, on, and yes can be determined as Boolean values (true). That is, if the key-value pair is debug_mode:on, it can be identified as debug_mode":true.
[0078] Furthermore, the hierarchical structure of each key-value pair can be read based on a hierarchical identifier rule. The hierarchical structure of the key-value pair, i.e., the nested relationship of the key-value pairs, can be determined by the hierarchical identifier in the hierarchical identifier rule based on the number and position of non-alphanumeric characters.
[0079] In this embodiment, the hierarchical structure of key-value pairs can also be reflected through indentation. For example, in general, the smaller the indentation, the larger the key-value pair hierarchy, i.e., the outermost nesting within the nesting. Therefore, this embodiment can read the indentation of the configuration file to be converted; determine the hierarchical identifiers of each hierarchical structure in the configuration file to be converted based on the hierarchical identifier rule; and read the hierarchical structure of each key-value pair based on the indentation and / or hierarchical identifier.
[0080] In this embodiment, comments in the configuration file to be converted can be identified using annotation rules in a rule base. The number and position of non-alphanumeric characters in the configuration file to be converted are read, and annotation characters in the annotation rules are matched based on the number and position of the non-alphanumeric characters; and the comments in the configuration file to be converted are read based on the annotation characters.
[0081] In this embodiment, scripts in the configuration file to be converted can be recognized through the script recognition rules in the rule library. For example, interpreter declarations such as #! / bin / bash at the beginning of the file are matched, and the subsequent content is marked as a script block. Syntax boundary analysis is performed on the script block to identify the script syntax structure (such as if...fi, {...}), and complete code segments are extracted.
[0082] Specifically, the overall process can convert non-standard configurations into a standardized tree structure (dictionary nesting), retaining comments, blank lines, and original format metadata. Three structural patterns are recognized: flat key-value pairs (such as key=value); block-level configuration sections (such as [section]); multi-line text values (such as <<<EOT...EOT). Further, through parsing by the rule library, semantic information such as boolean values (on is recognized as true), numerical values (8080 is recognized as an integer), and environment variable references (${PATH}) is identified. The positions and contents of the recognized comments (associated with specific configuration items) are retained; the positions of blank lines; original format information: indentation type (space / tab), line break type (\n / \r\n), text alignment method, etc. Further assembly can be performed according to the syntax characteristics of the target file type to obtain a configuration file of the target file type.
[0083] In this embodiment, dynamic parsing of non-standard configurations is supported: support for mixed delimiters, mixed parsing of free text and structured data; support for semantic retention and compatibility: retaining non-functional content such as comments and script blocks to ensure the integrity and executability of the converted configuration; support for intelligent type inference: automatically identifying and converting semantic types such as boolean values, numerical values, and environment variables.
[0084] S104: Construct a configuration file of the target file type based on the key-value pairs and the hierarchical structure between the key-value pairs, and call the parser of the target file type to parse the configuration file.
[0085] In this embodiment, a configuration file of the target file type can be constructed based on the key-value pairs and the hierarchical structure between the key-value pairs. Or, a configuration file of the target file type can be constructed based on comments, key-value pairs, and the hierarchical structure between the key-value pairs. Or, a configuration file of the target file type can be constructed based on scripts, key-value pairs, and the hierarchical structure between the key-value pairs. Or, a configuration file of the target file type can be constructed simultaneously based on scripts, comments, key-value pairs, and the hierarchical structure between the key-value pairs.
[0086] Further, call the system tool to perform a legality check on the configuration file; if the configuration file passes the legality check, call the parser of the target file type to parse the configuration file; if the configuration file fails the legality check, generate an error log for the configuration file to be converted.
[0087] Based on the above embodiments, the method of the present invention converts configuration files in multiple formats into configuration files in a standard format and parses the configuration files through a parser in a standard format. This eliminates the need to develop a separate parser for each format of configuration files, thereby reducing system development and maintenance costs and version iteration risks.
[0088] The following combination Figure 2 , Figure 2 This is a structural block diagram of a non-standard configuration file parsing device provided by an embodiment of the present invention. The device may include:
[0089] The first module 100 is configured to read a configuration file to be converted based on a configuration file path, and determine a target file type of the configuration file to be converted based on a standardized identifier;
[0090] The second module 200 is used to build a rule base including separator rules, type inference rules and hierarchical identifier rules;
[0091] The third module 300 is configured to parse the configuration file to be converted based on the rule base to obtain key-value pairs of the target file type and a hierarchical structure between the key-value pairs;
[0092] The fourth module 400 is configured to construct a configuration file of the target file type based on the key-value pairs and the hierarchical structure between the key-value pairs, and call a parser of the target file type to parse the configuration file.
[0093] Based on the above embodiments, the method of the present invention converts configuration files in multiple formats into configuration files in a standard format and parses the configuration files through a parser in a standard format. This eliminates the need to develop a separate parser for each format of configuration files, thereby reducing system development and maintenance costs and version iteration risks.
[0094] Based on the above embodiment, the third module 300 may include:
[0095] The first unit is configured to read the number and positions of non-alphanumeric characters in the configuration file to be converted, and match the delimiters in the delimiter rule based on the number and positions of the non-alphanumeric characters;
[0096] A second unit is configured to determine the key-value pair in the configuration file to be converted based on the delimiter;
[0097] A third unit is configured to identify semantic information in the key-value pair based on a type inference rule to obtain the key-value pair of the target file type;
[0098] The fourth unit is configured to read the hierarchical structure of each of the key-value pairs based on the hierarchical identifier rule.
[0099] Based on the above embodiments, the fourth unit may include:
[0100] The first subunit is configured to read the indentation format of the configuration file to be converted;
[0101] A second subunit is configured to determine a hierarchical identifier of each hierarchical structure in the configuration file to be converted based on the hierarchical identifier rule;
[0102] The third subunit is configured to read the hierarchical structure of each of the key-value pairs based on the indentation format and / or the hierarchical identifier.
[0103] Based on the above embodiments, the device may further include:
[0104] A fifth module is used to add annotation rules in the rule base;
[0105] A sixth module is configured to read the number and position of non-alphanumeric symbols in the configuration file to be converted, and match annotation symbols in the annotation symbol rule based on the number and position of the non-alphanumeric symbols;
[0106] A seventh module is configured to read comments of the configuration file to be converted based on the comment symbol;
[0107] Accordingly, the fourth module 400 may include:
[0108] The fifth unit is configured to construct the configuration file of the target file type based on the annotations, the key-value pairs, and the hierarchical structure between the key-value pairs.
[0109] Based on the above embodiments, the device may further include:
[0110] An eighth module is used to add script identification rules to the rule base;
[0111] A ninth module is configured to identify a script in the configuration file to be converted based on the script identification rule;
[0112] Accordingly, the fourth module 400 may include:
[0113] The sixth unit is configured to construct the configuration file of the target file type based on the script, the key-value pairs, and the hierarchical structure between the key-value pairs.
[0114] Based on the above embodiments, the fourth module 400 may include:
[0115] The seventh unit is used to call a system tool to perform a validity check on the configuration file;
[0116] An eighth unit is configured to call the parser of the target file type to parse the configuration file if the configuration file passes the validity check;
[0117] The ninth unit is configured to generate an error log of the configuration file to be converted if the configuration file fails the validity check.
[0118] Based on the above embodiments, the device may further include:
[0119] The tenth module is configured to add the separator rule, the type inference rule, and the level identifier rule of the third-party custom type to the rule base when the file type of the configuration file to be converted is a third-party custom type.
[0120] Based on the above embodiments, the present invention further provides an electronic device, which may include a memory and a processor. The memory stores a computer program, and the processor, when invoking the computer program in the memory, can implement the steps provided in the above embodiments. Of course, the device may also include various necessary network interfaces, a power supply, and other components.
[0121] The present invention also provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by an execution terminal or a processor, the method provided in the embodiment of the present invention can be implemented. The storage medium may include: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, etc., various media that can store program codes.
[0122] In this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or apparatus comprising the element.
Claims
1. A non-standard configuration file parsing method, characterized in that: include: Reading a configuration file to be converted based on the configuration file path, and determining a target file type of the configuration file to be converted based on a standardized identifier; Build a rule base that includes delimiter rules, type inference rules, and hierarchical identifier rules; Parsing the configuration file to be converted based on the rule base to obtain key-value pairs of the target file type and a hierarchical structure between the key-value pairs; A configuration file of the target file type is constructed based on the key-value pairs and the hierarchical structure between the key-value pairs, and a parser of the target file type is called to parse the configuration file.
2. The non-standard configuration file parsing method according to claim 1, characterized in that: Parsing the configuration file to be converted based on the rule base to obtain key-value pairs of the target file type and a hierarchical structure between the key-value pairs includes: Reading the number and position of non-alphanumeric characters in the configuration file to be converted, and matching the delimiters in the delimiter rule based on the number and position of the non-alphanumeric characters; Determining the key-value pair in the configuration file to be converted based on the delimiter; Identify semantic information in the key-value pair based on a type inference rule to obtain the key-value pair of the target file type; The hierarchical structure of each of the key-value pairs is read based on the hierarchical identifier rule.
3. The non-standard configuration file parsing method according to claim 2, characterized in that: Reading the hierarchical structure of each of the key-value pairs based on the hierarchical identifier rule includes: Reading the indentation format of the configuration file to be converted; Determining a hierarchical identifier for each hierarchical structure in the configuration file to be converted based on the hierarchical identifier rule; The hierarchical structure of each of the key-value pairs is read based on the indentation format and / or the hierarchical identifier.
4. The non-standard configuration file parsing method according to claim 1, characterized in that: Also includes: Adding annotation rules to the rule base; Reading the number and position of non-alphanumeric characters in the configuration file to be converted, and matching annotation characters in the annotation character rule based on the number and position of the non-alphanumeric characters; Reading comments of the configuration file to be converted based on the comment symbol; Accordingly, constructing a configuration file of the target file type based on the key-value pairs and the hierarchical structure between the key-value pairs includes: The configuration file of the target file type is constructed based on the annotations, the key-value pairs, and the hierarchical structure between the key-value pairs.
5. The non-standard configuration file parsing method according to claim 1, characterized in that: Also includes: Adding script identification rules to the rule base; Identifying a script in the configuration file to be converted based on the script identification rule; Accordingly, constructing a configuration file of the target file type based on the key-value pairs and the hierarchical structure between the key-value pairs includes: The configuration file of the target file type is constructed based on the script, the key-value pairs, and the hierarchical structure between the key-value pairs.
6. The non-standard configuration file parsing method according to claim 1, characterized in that: Calling a parser of the target file type to parse the configuration file includes: Calling system tools to verify the legitimacy of the configuration file; If the configuration file passes the validity check, calling the parser of the target file type to parse the configuration file; If the configuration file fails the validity check, an error log of the configuration file to be converted is generated.
7. The non-standard configuration file parsing method according to claim 1, characterized in that: Also includes: When the file type of the configuration file to be converted is a third-party self-defined type, the separator rule, the type inference rule, and the level identifier rule of the third-party self-defined type are added to the rule library.
8. A non-standard configuration file parsing device, characterized in that: include: The first module is configured to read a configuration file to be converted based on a configuration file path, and determine a target file type of the configuration file to be converted based on a standardized identifier; The second module is used to build a rule base including separator rules, type inference rules and hierarchical identifier rules; A third module is configured to parse the configuration file to be converted based on the rule base to obtain key-value pairs of the target file type and a hierarchical structure between the key-value pairs; The fourth module is configured to construct a configuration file of the target file type based on the key-value pairs and the hierarchical structure between the key-value pairs, and call a parser of the target file type to parse the configuration file.
9. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the non-standard configuration file parsing method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, the non-standard configuration file parsing method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Method and device for analyzing non-standard JSON string
CN113468866A
Data cleaning processing method and device, equipment and computer readable storage medium
CN116881632A
Articulated naturality web equipment linkage method and device, electronic device and storage medium
CN118643068A
Cited By
Method and system for automatically classifying and analyzing configuration files of network equipment
CN121541922A
A network device configuration file automatic classification and analysis method and system
CN121541922B