CN113504910B - Code text processing method, device, equipment and storage medium - Google Patents

Code text processing method, device, equipment and storage medium Download PDF

Info

Publication number
CN113504910B
CN113504910B CN202110776873.1A CN202110776873A CN113504910B CN 113504910 B CN113504910 B CN 113504910B CN 202110776873 A CN202110776873 A CN 202110776873A CN 113504910 B CN113504910 B CN 113504910B
Authority
CN
China
Prior art keywords
variable
code
processing logic
transfer plug
plug
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202110776873.1A
Other languages
Chinese (zh)
Other versions
CN113504910A (en
Inventor
张涛
刘锦超
吴海浩
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Pingan Zhihui Enterprise Information Management Co ltd
Original Assignee
Shenzhen Pingan Zhihui Enterprise Information Management Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Pingan Zhihui Enterprise Information Management Co ltd filed Critical Shenzhen Pingan Zhihui Enterprise Information Management Co ltd
Priority to CN202110776873.1A priority Critical patent/CN113504910B/en
Publication of CN113504910A publication Critical patent/CN113504910A/en
Application granted granted Critical
Publication of CN113504910B publication Critical patent/CN113504910B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/44Encoding
    • G06F8/447Target code generation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/74Reverse engineering; Extracting design information from source code
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44521Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading
    • G06F9/44526Plug-ins; Add-ons
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/542Event management; Broadcasting; Multicasting; Notifications
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The application relates to the technical field of development assistance, and discloses a processing method, a device, equipment and a storage medium of code text, wherein the processing method comprises the steps of reading Python codes input by a user through a software development tool; based on a D I R function, extracting variable contents in the Python code, and storing the variable contents in a preset variable transfer plug-in, wherein the variable transfer plug-in is pre-deployed in the software development tool; the variable transfer plug-in extracts processing logic corresponding to the variable from the Python code based on the variable in the variable content, the variable transfer plug-in carries out logic operation on the variable according to the processing logic to obtain analysis content, and the variable transfer plug-in replaces the processing logic corresponding to the Python code by utilizing the analysis content. The present application also relates to blockchain techniques in which the processing logic data is stored. The application can make the logic operation process in the code all be carried out in the variable transfer plug-in unit, and reduce the coupling degree of the whole code.

Description

Code text processing method, device, equipment and storage medium
Technical Field
The present application relates to the field of development assistance technologies, and in particular, to a method, an apparatus, a device, and a storage medium for processing a code text.
Background
In the development process of a program, the application of variables is extremely important, and the variables usually assign a short and easy-to-memorize name to each piece of data or other contents which are ready to be used in the program development, and then calculate a result through a specific operation formula. Variables are very important tools throughout the process in program development. In the prior art, the operation formulas corresponding to codes and variables thereof are often mixed together to realize some functions. When a large number of variables are utilized for completing a function, and the variables correspond to a large amount of processing logic, in this case, the codes are subjected to a high coupling condition, so that the codes are tightly connected, the independence is poor, and the expansibility of the whole application program is easily poor. Therefore, how to reduce the existing code high coupling situation becomes a urgent problem to be solved.
Disclosure of Invention
The application provides a method, a device, equipment and a storage medium for processing code text, which are used for solving the problem of high code coupling degree in the prior art.
In order to solve the above problems, the present application provides a method for processing code text, including:
reading a Python code input by a user through a software development tool;
based on a DIR function, extracting variable contents in the Python code, and storing the variable contents in a preset variable transfer plug-in, wherein the variable transfer plug-in is pre-deployed in the software development tool;
the variable transfer plug-in extracts processing logic corresponding to the variable from the Python code based on the variable in the variable content, and the variable transfer plug-in carries out logic operation on the variable according to the processing logic to obtain analysis content;
and the variable transfer plug-in replaces the processing logic corresponding to the Python code by utilizing the analysis content.
Further, after the variable transfer plug-in is pre-deployed in the software development tool, the method further includes:
registering and monitoring communication events between the variable transfer plug-in and the software development tool;
setting a response mode corresponding to the message type of the communication event.
Further, after the variable transfer plug-in is pre-deployed in the software development tool, the method further includes:
detecting whether the variable transfer plug-in is successfully deployed on the software development tool;
if the variable transfer plug-in is detected not to be deployed, acquiring the variable transfer plug-in from a server side;
if the variable transfer plug-in is detected to be deployed, detecting whether the variable transfer plug-in is the latest version or not, if not, acquiring the variable transfer plug-in of the latest version from the server side, and deploying the variable transfer plug-in of the latest version into the software development tool.
Further, the variable transfer plug-in obtains processing logic corresponding to the variable from the Python code based on the variable in the variable content, and the variable transfer plug-in performs logic operation on the variable according to the processing logic, so as to obtain analysis content, where the obtaining includes:
acquiring data source information and type information corresponding to the variables;
acquiring the processing logic corresponding to the variable from the Python code according to the data source information and the type information;
and according to the processing logic and the data source information, carrying out corresponding calculation on the variable to obtain the corresponding analysis content.
Further, before the obtaining the data source information and the type information corresponding to the variable, the method further includes:
acquiring the position of the variable in the variable content in the Python code;
based on a pre-trained recognition model, recognizing the content of the position of the variable in the Python code;
and obtaining a plurality of source channels corresponding to the variables according to the identification result.
Further, the obtaining, according to the data source information and the type information, the processing logic corresponding to the variable from the Python code includes:
based on the data source information and the type information corresponding to the variables, invoking an algorithm formula corresponding to the variables in the Python code through regular matching;
and using the algorithm formula as processing logic corresponding to the variable.
Further, after the processing logic corresponding to the variable is obtained from the Python code according to the data source information and the type information, the processing logic further includes:
when a plurality of variables are identified and corresponding processing logic is acquired, judging whether the processing logic corresponding to the variables is associated with each other or not;
if the variable is related, carrying out logic verification on the processing logic to ensure the normal operation of the variable.
In order to solve the above problems, the present application also provides a processing apparatus of code text, the apparatus comprising:
the reading module is used for reading the Python code input by the user through the software development tool;
the extraction module is used for extracting variable contents in the Python code based on a DIR function, storing the variable contents in a preset variable transfer plug-in, and pre-deploying the variable transfer plug-in the software development tool;
the calculation module is used for extracting processing logic corresponding to the variable from the Python code based on the variable in the variable content, and the variable transfer plug-in performs logic operation on the variable according to the processing logic to obtain analysis content;
and the replacing module is used for replacing the processing logic corresponding to the Python code by the variable transfer plug-in by utilizing the analysis content.
In order to solve the above problems, the present application also provides a computer apparatus comprising:
at least one processor; the method comprises the steps of,
a memory communicatively coupled to the at least one processor; wherein, the liquid crystal display device comprises a liquid crystal display device,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of processing code text as described above.
In order to solve the above-mentioned problems, the present application also provides a non-volatile computer-readable storage medium having stored thereon computer-readable instructions which, when executed by a processor, implement a method of processing code text as described above.
Compared with the prior art, the method, the device, the equipment and the storage medium for processing the code text have at least the following beneficial effects:
the variable transfer plug-in is deployed in a software development tool in advance, a code input by a user is received through the software development tool, a DIR function is utilized to extract variables in the code and store the extracted variables into a preset variable transfer plug-in, the variable transfer plug-in extracts processing logic corresponding to the variables from the Python code based on the variables in the variable content, the variable transfer plug-in carries out logic operation according to the processing logic corresponding to the variables to obtain corresponding analysis content, and the variable transfer plug-in replaces the processing logic corresponding to the Python code according to the analysis content, so that the logic operation process in the code is carried out in the variable transfer plug-in, and the coupling degree of the whole code is reduced.
Drawings
In order to more clearly illustrate the solution of the present application, a brief description will be given below of the drawings required for the description of the embodiments of the present application, and it will be apparent that the drawings in the following description are some embodiments of the present application, and that other drawings may be obtained according to these drawings without the need for inventive effort for a person of ordinary skill in the art.
FIG. 1 is a flow chart illustrating a method for processing code text according to an embodiment of the present application;
FIG. 2 is a schematic block diagram of a code text processing apparatus according to an embodiment of the present application;
fig. 3 is a schematic structural diagram of a computer device according to an embodiment of the application.
Detailed Description
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs; the terminology used in the description of the applications herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application; the terms "comprising" and "having" and any variations thereof in the description of the application and the claims and the description of the drawings above are intended to cover a non-exclusive inclusion. The terms first, second and the like in the description and in the claims or in the above-described figures, are used for distinguishing between different objects and not necessarily for describing a sequential or chronological order.
Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment may be included in at least one embodiment of the application. The appearances of such phrases in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. Those skilled in the art will appreciate, either explicitly or implicitly, that the embodiments described herein may be combined with other embodiments.
The application provides a processing method of a code text. Referring to fig. 1, a flow chart of a method for processing code text according to an embodiment of the application is shown.
In this embodiment, the processing method of the code text includes:
s1, reading a Python code input by a user through a software development tool;
specifically, the code input by the user can be received in real time through the software development tool, the whole code after the user writes can also be received, and the file corresponding to the code can be directly read.
S2, extracting variable contents in the Python code based on a DIR function, and storing the variable contents in a preset variable transfer plug-in, wherein the variable transfer plug-in is pre-deployed in the software development tool;
in the present application, all the variables defined in the specified file can be obtained by using the DIR function, and the specified file refers to the received code in the present application, and the moduleName refers to the module name or the file name through DIR (moduleName). For example, in a plurality of files or modules that receive user input, the files contain code that can be passed directly over dir (maomao), i.e., variables in the filename maomao are extracted. When dir (), variables, functions, classes and the like of the current page can be obtained directly. And locating the position of the variable in the Python code according to the extracted variable.
Further, after the variable transfer plug-in is pre-deployed in the software development tool, the method further includes:
registering and monitoring communication events between the variable transfer plug-in and the software development tool;
setting a response mode corresponding to the message type of the communication event.
Specifically, by monitoring the communication event between the variable transfer plug-in and the software development tool, the data content acquired by the variable transfer plug-in is monitored at any time, and a response mode corresponding to the communication event may be set, for example, when the message type of the communication event is a, a synchronous response is set to the response mode corresponding to the a, and for example, when the message type of the communication event is B, an asynchronous response is set to the response mode corresponding to the B.
The coordination between the variable transfer plug-in and the software development tool is facilitated by monitoring the communication event between the variable transfer plug-in and the software development tool and setting a corresponding response mode according to the message type of the communication event.
Further, after the variable transfer plug-in is pre-deployed in the software development tool, the method further includes:
detecting whether the variable transfer plug-in is successfully deployed on the software development tool;
if the variable transfer plug-in is detected not to be deployed, acquiring the variable transfer plug-in from a server side;
if the variable transfer plug-in is detected to be deployed, detecting whether the variable transfer plug-in is the latest version or not, if not, acquiring the variable transfer plug-in of the latest version from the server side, and deploying the variable transfer plug-in of the latest version into the software development tool.
In particular, to ensure that the launched software development tool is able to provide plug-in services for the developer, it is necessary to ensure that the software development tool has integrated a variable transfer plug-in prior to launching the software development tool.
Detecting whether a variable transfer plug-in is successfully deployed in a software development tool by detecting plug-in identification and other modes, if no variable transfer plug-in is detected, re-acquiring the variable transfer plug-in from a server side, deploying after acquiring the variable transfer plug-in, and if the variable transfer plug-in is detected to be the latest version, further detecting whether the variable transfer plug-in is the latest version;
for example, the latest version number of the variable transfer plug-in is obtained, whether the latest version number is consistent with the version number of the variable transfer plug-in deployed at present is judged, and if not, the latest variable transfer plug-in is obtained from the server side for deployment; if the variable transfer plug-ins are consistent, the variable transfer plug-ins are up to date. To provide the relevant developer with an optimal development service.
By detecting whether the variable transfer plug-in is deployed in the software development tool and whether the variable transfer plug-in is the latest version, the user can use the variable transfer tool and is optimal development service.
S3, extracting processing logic corresponding to the variable from the Python code based on the variable in the variable content by the variable transfer plug-in, and carrying out logic operation on the variable according to the processing logic by the variable transfer plug-in to obtain analysis content;
specifically, after receiving the variable content, the variable transfer plug-in extracts processing logic corresponding to the variable from the Python code based on the variable in the variable content, and the variable transfer plug-in performs logic operation on the variable according to the processing logic to obtain corresponding analysis content. The logical operation is to calculate the variable according to the processing logic corresponding to the variable, such as an algorithm formula and the like.
Further, the variable transfer plug-in obtains processing logic corresponding to the variable from the Python code based on the variable in the variable content, and the variable transfer plug-in performs logic operation on the variable according to the processing logic, so as to obtain analysis content, where the obtaining includes:
acquiring data source information and type information corresponding to the variables;
acquiring the processing logic corresponding to the variable from the Python code according to the data source information and the type information;
and according to the processing logic and the data source information, carrying out corresponding calculation on the variable to obtain the corresponding analysis content.
Specifically, by receiving data source and type information corresponding to a variable input by a user, the variable is visually displayed in a variable transfer plug-in, the user can click on the variable to perform attribute configuration, namely, configure the data source and type information, acquire processing logic corresponding to the variable from the code according to the data source information and the type information, and finally perform corresponding calculation on the variable according to the processing logic and the data source information to obtain corresponding analysis content.
The type information of the variables can be divided into: numbers (int), strings (str), lists (list), tuples (tuple), dictionaries (direct), functions, classes, objects, etc.;
the data source information can be divided into: components, services, caches, URLs, constants, variables themselves, etc. In the application, when the data source is stored in the cache and the corresponding type information is a function, calling out processing logic corresponding to the function, and correspondingly calculating the variable according to the processing logic and the data source information to obtain analysis content. For example, when the type of the variable is a function and the data source is a constant, that is, the variable calculates the constant by using the function to obtain the final content, in this case, the corresponding function is obtained as processing logic by using the position of the variable in the variable content.
And according to the processing logic and the data source information, performing corresponding calculation on the variable, for example, the existing simple variable a, the variable b is directly assigned, b=1, the corresponding processing logic is a= 3+b, and the corresponding calculation on the variable a, namely, a= 3+b, is performed, so as to obtain analysis content a=4.
And after the processing logic corresponding to the variable is obtained through the variable transfer plug-in, carrying out corresponding calculation on the variable, realizing calculation in the variable transfer plug-in, and replacing the processing logic corresponding to the variable, so that the codes in the code text are decoupled.
Further, before the obtaining the data source information and the type information corresponding to the variable, the method further includes:
acquiring the position of the variable in the variable content in the Python code;
based on a pre-trained recognition model, recognizing the content of the position of the variable in the Python code;
and obtaining a plurality of source channels corresponding to the variables according to the identification result.
Specifically, based on variable content, acquiring the position of the variable in a code; and identifying the context content of the position of the code through a pre-trained identification model, and finally obtaining a plurality of identification results, namely corresponding source channels, and generating a to-be-selected list after obtaining a plurality of source channels so as to finally confirm the specific source channels of the variables by a user.
The recognition model is trained through a large number of scattered variables, partial code sentences corresponding to the variables and source channels corresponding to the variables, and a plurality of possible source channels are obtained according to the recognition model by acquiring sentences corresponding to the variables for selection by a user.
When the variable and the corresponding partial code content are obtained, the variable and the corresponding partial code content are identified through an identification model, so that a plurality of close source channels are obtained for the user to select, and the final source channel is determined.
And a plurality of channels possibly corresponding to the variables are obtained through the identification model, so that the processing efficiency is improved.
Still further, the processing logic for obtaining the variable from the Python code according to the data source information and the type information includes:
based on the data source information and the type information corresponding to the variables, invoking an algorithm formula corresponding to the variables in the Python code through regular matching;
and using the algorithm formula as processing logic corresponding to the variable.
Specifically, on the basis of the data source information and the type information corresponding to the variable, an algorithm formula corresponding to the variable in the code is obtained by adopting a regular matching mode, and the algorithm formula is obtained as processing logic corresponding to the variable.
When the algorithm formula is matched with the corresponding algorithm formula in a regular matching mode, the variable transfer plug-in unit can also receive processing logic input by a user, namely, the algorithm formula input by the user.
The algorithm formula corresponding to the variable is extracted in a regular matching mode, so that the processing efficiency is further improved
Further, after the processing logic corresponding to the variable is obtained from the Python code according to the data source information and the type information, the processing logic further includes:
when a plurality of variables are identified and corresponding processing logic is acquired, judging whether the processing logic corresponding to the variables is associated with each other or not;
if the variable is related, carrying out logic verification on the processing logic to ensure the normal operation of the variable.
In the application, since the whole code does not have one variable, when a plurality of variables are identified, whether the processing logic corresponding to the variables are associated or not, namely whether interaction exists between the processing logic is judged, and if the interaction exists, logic verification is carried out on the associated processing logic. In particular, for example
int a,b,c;
a=12;
b=3+a;
c=a+b;
printf ("% d", a+b+c); in the simple code segment, the processing logic corresponding to a, b and c is associated, so that logic verification is required to be performed on the processing logic corresponding to the variable, the logic verification is mainly to judge whether the processing logic has conflict or not, if no conflict exists, the logic verification passes, and the variables can be normally used. If the conflict exists, the logic check is not passed, and the variables which are not passed by the logic check are sent to the user through a software development tool so as to remind the user.
The processing logic of a plurality of related variables is subjected to logic verification, so that smooth running of codes is ensured, and meanwhile, a developer is assisted in verification, and verification efficiency is improved.
And S4, replacing the processing logic corresponding to the Python code by the variable transfer plug-in by utilizing the analysis content.
Specifically, the processing logic corresponding to the variable corresponding to the Python code is replaced by the analysis content, and as a possible implementation manner, the original processing logic is replaced by direct assignment.
It is emphasized that all data of the processing logic may also be stored in nodes of a blockchain in order to further guarantee privacy and security of the data.
The blockchain is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, consensus mechanism, encryption algorithm and the like. The Blockchain (Blockchain), which is essentially a decentralised database, is a string of data blocks that are generated by cryptographic means in association, each data block containing a batch of information of network transactions for verifying the validity of the information (anti-counterfeiting) and generating the next block. The blockchain may include a blockchain underlying platform, a platform product services layer, an application services layer, and the like.
The variable transfer plug-in is deployed in a software development tool in advance, a code input by a user is received through the software development tool, a DIR function is utilized to extract variables in the code and store the extracted variables into a preset variable transfer plug-in, the variable transfer plug-in extracts processing logic corresponding to the variables from the Python code based on the variables in the variable content, the variable transfer plug-in carries out logic operation according to the processing logic corresponding to the variables to obtain corresponding analysis content, and the variable transfer plug-in replaces the processing logic corresponding to the Python code according to the analysis content, so that the logic operation process in the code is carried out in the variable transfer plug-in, and the coupling degree of the whole code is reduced.
As shown in fig. 2, a functional block diagram of the processing device of the code text according to the present application is shown.
The processing apparatus 100 for code text according to the present application may be installed in an electronic device. Depending on the implemented functionality, the processing device 100 of the code text may comprise a reading module 101, an extracting module 102, a calculating module 103 and a replacing module 104. The module of the application, which may also be referred to as a unit, refers to a series of computer program segments, which are stored in the memory of the electronic device, capable of being executed by the processor of the electronic device and of performing a fixed function.
In the present embodiment, the functions concerning the respective modules/units are as follows:
a reading module 101, configured to read, by using a software development tool, a Python code input by a user;
specifically, the reading module 101 may receive, in real time, a code input by a user through a software development tool, or may receive a whole code after the user writes the code, and a file corresponding to the code may also be directly readable.
The extracting module 102 is configured to extract variable contents in the Python code based on a DIR function, and store the extracted variable contents in a preset variable transfer plug-in, where the variable transfer plug-in is pre-deployed in the software development tool;
specifically, the extraction module 102 may obtain all the variables defined in the specified file by using the DIR function, where the specified file refers to the received code in the present application, and the moduleName refers to the module name or the file name through DIR (moduleName).
Further, the processing device 100 of the code text further includes a registration module and a response setting module;
the registration module is used for registering and monitoring communication events between the variable transfer plug-in and the software development tool;
the response setting module is used for setting a response mode corresponding to the message type of the communication event.
And through the cooperation of the registration module and the response setting module, monitoring the communication event between the variable transfer plug-in and the software development tool, and setting a corresponding response mode according to the message type of the communication event, so that the cooperation between the variable transfer plug-in and the software development tool is facilitated.
Further, the processing device 100 of the code text further includes a detection module, an acquisition module, and a version detection module;
the detection module is used for detecting whether the variable transfer plug-in is successfully deployed on the software development tool;
the plug-in acquisition module is used for acquiring the variable transfer plug-in from a server side if the variable transfer plug-in is detected not to be deployed;
the version detection module is used for detecting whether the variable transfer plug-in is the latest version or not if the variable transfer plug-in is detected to be deployed;
and the plug-in acquisition module is further used for acquiring the variable transfer plug-in of the latest version from the server side and deploying the variable transfer plug-in of the latest version into the software development tool when the version detection module detects that the variable transfer plug-in is not of the latest version.
Specifically, the detection module detects whether a variable transfer plug-in is successfully deployed in the software development tool by detecting plug-in identification and the like, and if no variable transfer plug-in is detected, the plug-in acquisition module acquires the variable transfer plug-in again from the server side, and deploys the variable transfer plug-in after acquiring the variable transfer plug-in; if the detection module detects that the variable transfer plug-in is in existence, the version detection module is further utilized to detect whether the variable transfer plug-in is the latest version.
And detecting whether the variable transfer plug-in is deployed in the software development tool or not and whether the variable transfer plug-in is the latest version or not through the cooperation of the detection module, the acquisition module and the version detection module, so that a user can use the variable transfer tool and the variable transfer plug-in is optimal development service.
And the calculating module 103 is configured to extract processing logic corresponding to the variable from the Python code based on the variable in the variable content, where the variable relay plug-in performs logic operation on the variable according to the processing logic, so as to obtain analysis content.
Specifically, the replacing module 103 extracts processing logic corresponding to the variable from the Python code based on the variable in the variable content after receiving the variable content, and the variable transfer plug-in performs logic operation on the variable according to the processing logic to obtain corresponding analysis content.
Further, the computing module 103 includes an acquiring sub-module, a processing logic acquiring sub-module and a computing sub-module;
the acquisition sub-module is used for acquiring data source information and type information corresponding to the variables;
the processing logic acquisition sub-module is used for acquiring the processing logic corresponding to the variable from the Python code according to the data source information and the type information;
and the calculation submodule is used for carrying out corresponding calculation on the variable according to the processing logic and the data source information to obtain the corresponding analysis content.
Specifically, the obtaining submodule receives data source and type information corresponding to a variable input by a user, the variable is visually displayed in a variable transfer plug-in, and the user can click on the variable to perform attribute configuration, namely, the data source and the type information are configured.
The variable transfer plug-in performs corresponding calculation on the variable after the processing logic corresponding to the variable is obtained through the cooperation of the acquisition sub-module, the processing logic acquisition sub-module and the calculation sub-module, so that the calculation is performed in the variable transfer plug-in, the processing logic corresponding to the variable is replaced, and the code in the code text is decoupled.
Still further, the computing module 103 further includes a location acquisition sub-module and an identification sub-module;
the acquisition submodule is used for acquiring the position of the variable in the variable content in the Python code;
the identification sub-module is used for identifying the content of the position of the variable in the Python code based on a pre-trained identification model; and obtaining a plurality of source channels corresponding to the variables according to the identification result.
Specifically, the obtaining submodule obtains the position of the variable in the code based on the content of the variable; the identification sub-module identifies the context content of the position where the code is located through a pre-trained identification model, and finally obtains a plurality of identification results, namely corresponding source channels, and after obtaining a plurality of source channels, generates a to-be-selected list for a user to finally confirm the specific source channels of the variables.
Through the cooperation of the position acquisition sub-module and the identification sub-module, a plurality of channels possibly corresponding to the variables are obtained by utilizing the identification model, and the processing efficiency is improved.
Still further, the processing logic acquisition submodule includes a regular extraction unit;
the regular extraction unit is used for calling an algorithm formula corresponding to the variable in the Python code through regular matching based on the data source information and the type information corresponding to the variable;
and using the algorithm formula as processing logic corresponding to the variable.
Specifically, the regular extraction unit obtains an algorithm formula corresponding to the variable in the code by adopting a regular matching mode on the basis of the data source information and the type information corresponding to the variable, and the algorithm formula is obtained as processing logic corresponding to the variable.
The regular extraction unit extracts an algorithm formula corresponding to the variable in a regular matching mode, so that the processing efficiency is further improved.
Further, the computing module 103 further includes a correlation judging sub-module and a logic verifying sub-module;
the association judging submodule is used for judging whether association exists among the processing logics corresponding to the variables after the variables are identified and obtained and the corresponding processing logics are obtained;
and the logic verification sub-module is used for carrying out logic verification on the processing logic if the logic verification sub-module is related to ensure the normal application of the variable.
The processing logic of a plurality of associated variables is logically verified through the cooperation of the association judgment sub-module and the logic verification sub-module, so that smooth running of codes is ensured, meanwhile, verification is carried out by a developer, and verification efficiency is improved.
And a replacing module 104, configured to replace the processing logic corresponding to the Python code by using the parsing content by using the variable transit plug-in.
Specifically, the processing logic corresponding to the variable corresponding to the Python code is replaced by the analysis content, and as a possible implementation manner, the original processing logic is replaced by direct assignment.
By adopting the device, the processing device 100 of the code text enables the logic operation process in the code to be carried out in the variable transfer plug-in unit through the cooperation of the reading module 101, the extracting module 102, the calculating module 103 and the replacing module 104, so that the coupling degree of the whole code is reduced.
In order to solve the technical problems, the embodiment of the application also provides computer equipment. Referring specifically to fig. 3, fig. 3 is a basic structural block diagram of a computer device according to the present embodiment.
The computer device 4 comprises a memory 41, a processor 42, a network interface 43 communicatively connected to each other via a system bus. It should be noted that only computer device 4 having components 41-43 is shown in the figures, but it should be understood that not all of the illustrated components are required to be implemented and that more or fewer components may be implemented instead. It will be appreciated by those skilled in the art that the computer device herein is a device capable of automatically performing numerical calculations and/or information processing in accordance with predetermined or stored instructions, the hardware of which includes, but is not limited to, microprocessors, application specific integrated circuits (Application Specific Integrated Circuit, ASICs), programmable gate arrays (fields-Programmable Gate Array, FPGAs), digital processors (Digital Signal Processor, DSPs), embedded devices, etc.
The computer equipment can be a desktop computer, a notebook computer, a palm computer, a cloud server and other computing equipment. The computer equipment can perform man-machine interaction with a user through a keyboard, a mouse, a remote controller, a touch pad or voice control equipment and the like.
The memory 41 includes at least one type of readable storage medium including flash memory, hard disk, multimedia card, card memory (e.g., SD or DX memory, etc.), random Access Memory (RAM), static Random Access Memory (SRAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), programmable Read Only Memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the storage 41 may be an internal storage unit of the computer device 4, such as a hard disk or a memory of the computer device 4. In other embodiments, the memory 41 may also be an external storage device of the computer device 4, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash Card (Flash Card) or the like, which are provided on the computer device 4. Of course, the memory 41 may also comprise both an internal memory unit of the computer device 4 and an external memory device. In this embodiment, the memory 41 is typically used for storing an operating system installed on the computer device 4 and various application software, such as computer readable instructions of a processing method of code text, and the like. Further, the memory 41 may be used to temporarily store various types of data that have been output or are to be output.
The processor 42 may be a central processing unit (Central Processing Unit, CPU), controller, microcontroller, microprocessor, or other data processing chip in some embodiments. The processor 42 is typically used to control the overall operation of the computer device 4. In this embodiment, the processor 42 is configured to execute computer readable instructions stored in the memory 41 or process data, such as computer readable instructions for executing a processing method of the code text.
The network interface 43 may comprise a wireless network interface or a wired network interface, which network interface 43 is typically used for establishing a communication connection between the computer device 4 and other electronic devices.
According to the method, when a processor executes computer readable instructions stored in a memory, the steps of the processing method of the code text of the embodiment are realized, a variable transfer plug-in is deployed in a software development tool in advance, a code input by a user is received through the software development tool, a DIR function is utilized to extract a variable in the code and store the variable in the code into a preset variable transfer plug-in, the variable transfer plug-in extracts processing logic corresponding to the variable from the Python code based on the variable in the variable content, the variable transfer plug-in carries out logic operation according to the processing logic corresponding to the variable to obtain corresponding analysis content, and the variable transfer plug-in replaces the processing logic corresponding to the Python code according to the analysis content, so that the logic operation process in the code is carried out in the variable transfer plug-in, and the coupling degree of the whole code is reduced.
The present application also provides another embodiment, namely, provides a computer readable storage medium, where the computer readable storage medium stores computer readable instructions, where the computer readable instructions are executable by at least one processor, so that the at least one processor executes the steps of the processing method of the code text, by deploying a variable relay plug-in a software development tool in advance, receiving a code input by a user through the software development tool, extracting a variable in the code by using a DIR function, and storing the extracted variable in the code into a preset variable relay plug-in, where the variable relay plug-in extracts processing logic corresponding to the variable from the Python code based on a variable in the variable content, and the variable relay plug-in performs logic operation according to the processing logic corresponding to the variable to obtain corresponding parsing content, and the variable relay plug-in replaces the processing logic corresponding to the Python code according to parsing content, so that the logic operation process in the code is performed in the variable relay plug-in, and the coupling degree of the whole code is reduced.
From the above description of the embodiments, it will be clear to those skilled in the art that the above-described embodiment method may be implemented by means of software plus a necessary general hardware platform, but of course may also be implemented by means of hardware, but in many cases the former is a preferred embodiment. Based on such understanding, the technical solution of the present application may be embodied essentially or in a part contributing to the prior art in the form of a software product stored in a storage medium (e.g. ROM/RAM, magnetic disk, optical disk) comprising instructions for causing a terminal device (which may be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to perform the method according to the embodiments of the present application.
It is apparent that the above-described embodiments are only some embodiments of the present application, but not all embodiments, and the preferred embodiments of the present application are shown in the drawings, which do not limit the scope of the patent claims. This application may be embodied in many different forms, but rather, embodiments are provided in order to provide a thorough and complete understanding of the present disclosure. Although the application has been described in detail with reference to the foregoing embodiments, it will be apparent to those skilled in the art that modifications may be made to the embodiments described in the foregoing description, or equivalents may be substituted for elements thereof. All equivalent structures made by the content of the specification and the drawings of the application are directly or indirectly applied to other related technical fields, and are also within the scope of the application.

Claims (10)

1. A method for processing code text, the method comprising:
reading a Python code input by a user through a software development tool;
based on a DIR function, extracting variable contents in the Python code, and storing the variable contents in a preset variable transfer plug-in, wherein the variable transfer plug-in is pre-deployed in the software development tool;
the variable transfer plug-in extracts processing logic corresponding to the variable from the Python code based on the variable in the variable content, and the variable transfer plug-in carries out logic operation on the variable according to the processing logic to obtain analysis content;
and the variable transfer plug-in replaces the processing logic corresponding to the Python code by utilizing the analysis content.
2. The method of processing code text according to claim 1, further comprising, after the variable relay plug-in is pre-deployed in the software development tool:
registering and monitoring communication events between the variable transfer plug-in and the software development tool;
setting a response mode corresponding to the message type of the communication event.
3. The method of processing code text according to claim 1, further comprising, after the variable relay plug-in is pre-deployed in the software development tool:
detecting whether the variable transfer plug-in is successfully deployed on the software development tool;
if the variable transfer plug-in is detected not to be deployed, acquiring the variable transfer plug-in from a server side;
if the variable transfer plug-in is detected to be deployed, detecting whether the variable transfer plug-in is the latest version or not, if not, acquiring the variable transfer plug-in of the latest version from the server side, and deploying the variable transfer plug-in of the latest version into the software development tool.
4. A method for processing a code text according to any one of claims 1 to 3, wherein the variable relay plug-in obtains processing logic corresponding to the variable from the Python code based on the variable in the variable content, and the variable relay plug-in performs logic operation on the variable according to the processing logic, and the obtaining the resolved content includes:
acquiring data source information and type information corresponding to the variables;
acquiring the processing logic corresponding to the variable from the Python code according to the data source information and the type information;
and according to the processing logic and the data source information, carrying out corresponding calculation on the variable to obtain the corresponding analysis content.
5. The method for processing code text according to claim 4, further comprising, before the obtaining the data source information and the type information corresponding to the variable:
acquiring the position of the variable in the variable content in the Python code;
based on a pre-trained recognition model, recognizing the content of the position of the variable in the Python code;
and obtaining a plurality of source channels corresponding to the variables according to the identification result.
6. The method according to claim 4, wherein the obtaining the processing logic corresponding to the variable from the Python code according to the data source information and the type information includes:
based on the data source information and the type information corresponding to the variables, invoking an algorithm formula corresponding to the variables in the Python code through regular matching;
and using the algorithm formula as processing logic corresponding to the variable.
7. The method according to claim 4, further comprising, after the processing logic corresponding to the variable is obtained from the Python code according to the data source information and the type information:
when a plurality of variables are identified and corresponding processing logic is acquired, judging whether the processing logic corresponding to the variables is associated with each other or not;
if the variable is related, carrying out logic verification on the processing logic to ensure the normal operation of the variable.
8. A code text processing apparatus, the apparatus comprising:
the reading module is used for reading the Python code input by the user through the software development tool;
the extraction module is used for extracting variable contents in the Python code based on a DIR function, storing the variable contents in a preset variable transfer plug-in, and pre-deploying the variable transfer plug-in the software development tool;
the calculation module is used for extracting processing logic corresponding to the variable from the Python code based on the variable in the variable content, and the variable transfer plug-in performs logic operation on the variable according to the processing logic to obtain analysis content;
and the replacing module is used for replacing the processing logic corresponding to the Python code by the variable transfer plug-in by utilizing the analysis content.
9. A computer device, the computer device comprising:
at least one processor; the method comprises the steps of,
a memory communicatively coupled to the at least one processor; wherein, the liquid crystal display device comprises a liquid crystal display device,
the memory stores computer readable instructions that when executed by the processor implement the method of processing code text as claimed in any one of claims 1 to 7.
10. A computer readable storage medium, characterized in that the computer readable storage medium has stored thereon computer readable instructions, which when executed by a processor, implement a method of processing a code text according to any of claims 1 to 7.
CN202110776873.1A 2021-07-09 2021-07-09 Code text processing method, device, equipment and storage medium Active CN113504910B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110776873.1A CN113504910B (en) 2021-07-09 2021-07-09 Code text processing method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110776873.1A CN113504910B (en) 2021-07-09 2021-07-09 Code text processing method, device, equipment and storage medium

Publications (2)

Publication Number Publication Date
CN113504910A CN113504910A (en) 2021-10-15
CN113504910B true CN113504910B (en) 2023-09-22

Family

ID=78011930

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110776873.1A Active CN113504910B (en) 2021-07-09 2021-07-09 Code text processing method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113504910B (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103699389A (en) * 2013-12-30 2014-04-02 北京大学 Linux kernel module relation extracting method based on compiling options
CN112231209A (en) * 2020-10-10 2021-01-15 金蝶医疗软件科技有限公司 Parameter acquisition method and device, computer equipment and storage medium

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2017053901A1 (en) * 2015-09-23 2017-03-30 ValueCorp Pacific, Incorporated Systems and methods for automatic distillation of concepts from math problems and dynamic construction and testing of math problems from a collection of math concepts

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103699389A (en) * 2013-12-30 2014-04-02 北京大学 Linux kernel module relation extracting method based on compiling options
CN112231209A (en) * 2020-10-10 2021-01-15 金蝶医疗软件科技有限公司 Parameter acquisition method and device, computer equipment and storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
python中的 dir()内置函数的作用以及使用方法;sunxiaopeng…;《https://blog.csdn.net/sunxiaopengsun/article/details/104568935》;第1-6页 *

Also Published As

Publication number Publication date
CN113504910A (en) 2021-10-15

Similar Documents

Publication Publication Date Title
CN110866258A (en) Method for quickly positioning bug, electronic device and storage medium
CN111783138A (en) Sensitive data detection method and device, computer equipment and storage medium
CN111949708A (en) Multi-task prediction method, device, equipment and medium based on time sequence feature extraction
CN114218110A (en) Account checking test method and device for financial data, computer equipment and storage medium
CN111932413B (en) Case element extraction method, case element extraction device, case element extraction equipment and case element extraction medium
CN113869789A (en) Risk monitoring method and device, computer equipment and storage medium
CN113705691A (en) Image annotation checking method, device, equipment and medium based on artificial intelligence
CN113434400A (en) Test case execution method and device, computer equipment and storage medium
CN113504910B (en) Code text processing method, device, equipment and storage medium
CN112860662A (en) Data blood relationship establishing method and device, computer equipment and storage medium
CN111639903A (en) Review processing method for architecture change and related equipment
CN111639360A (en) Intelligent data desensitization method and device, computer equipment and storage medium
CN111666298A (en) Method and device for detecting user service class based on flink, and computer equipment
CN109446054B (en) Processing method and terminal equipment for override operation request based on big data
CN114637672A (en) Automatic data testing method and device, computer equipment and storage medium
CN112580334A (en) File processing method, file processing device, server and storage medium
CN110321195B (en) Data caching method for operation page, electronic device and readable storage medium
CN116663003A (en) Attack detection method, attack detection device, computer equipment and storage medium
CN115618358A (en) Application file security detection method and device and server
CN115712441A (en) Model deployment method and device, computer equipment and storage medium
CN116993341A (en) Log full-link tracing method, device, equipment and storage medium for operation behaviors
CN112181835A (en) Automatic testing method and device, computer equipment and storage medium
CN117034173A (en) Data processing method, device, computer equipment and storage medium
CN114625442A (en) Cold start recommendation method and device, electronic equipment and readable storage medium
CN114500320A (en) Data monitoring method and device, electronic equipment and computer readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant