Skip to content

Nexo Rules Field Description

Rule fields in Nexo checker are divided into three parts: file type check, key data extraction and data condition. The most commonly used fileds are as follows.

Field Chinese Name Data Type Description Example
name Name str Rules
xpath Path str The path to the key data in resource files. The data retrieved through this path will be stored in a list. The data is data={'a': {'b':1,'c':2},'d': {'b':3,'c':4}, if to retrieve a value whose key is b, it should be xpath='data/a/b' or xpath='*/a/b' and the result data will be [1,3].
filter Filter str it can convert or filter the data retrieved through xpath in regular or customized functions. When the filter type is str, re.match(filter,d) will be applied with d as a single data. If the data is ["abcd-1223", "0000-1223"], filter='0000-.*' can be used to filter the data and if so, the filter range will be within ["abcd-1223"].
not_filter Reverse filter str Resource file reverse filter
condition Requirements list If key data meet the requirements, the data will be traversed. Each piece of data will be variable b. Supported conditional statements are exist, exist in, not exist, not exist in, satisfy the expression and exist in the directory. See supplemental notes
only_name File name only bool Use file name as key data
rpath Regular path name str Matching the resource files which satisfy the regular expression through re.match (rpath, file path)
not_rpath Filter regex path name str A reverse rpath, used to check files when the match fails.
subxpath Keyword path in secondary files str Used in cross-file execution. If xpath returns a file name and if this file needs to be checked, subxpath can be used to retrieve data again. The format is the same as that of xpath.
subfilter Secondary filter str Same as Filter. Same as filter.
ignor Include in the checking? str Include in the checking?
desc Description str Description
func_str Additional functions str Filter's customized functions See supplemental notes

Supplemental Notes

1. Example (condition): Condition supports the following statements: exist, exist in, not exist, not exist in, satisfy the expression and exist in the directory. Recommended statements: ['exist'] ['not exist'] ["exist in","../../../../Char/ "] means existing in a certain path. ["satisfy the expression","d == 'PBR_Foliage'"] #d is the traversed single value returned by xpath, for d in data. For example, if xpath returns ['PBR_Foliage', 'PBR_Foliage2'], d will be PBR_Foliage and then PBR_Foliage2.
2. Example (filter's fun_str): Functions that filter out data starting with 0000 def filter_zero(*pdata):     ret = []     data = pdata.get("data",[])     for d in data:         if d.startswith("0000-"):                 continue         ret.append(d)     return ret

Customized Rules Examples

Nexo mainly checks two types of files, xml and binary files. Binary resource files include mesh, gis, png, dds, bmp, tga, and jpg, etc,; XML resource files include scn, gim, sfx, and mtg. Binary file rules are complicated as each format has it own rules. While XML files are more widely used and key data can be obtained by parsing XML.

! 1.png

Take the gim file in the picture as an example.
Example 1. Submesh count of this gim file should be no more than five (reading dom elements). Step 1. To filter out the gim file, a regular expression .*gam$ needs to be applied in the rpath.

Step 2. To find out the SubMesh attributes of this gim file, as it is a XML format file, all SubMesh attributes need to be located */SubMesh{dom}. There is one SubMesh with five child attributes in the picture.

Step 3. Check if the key data satisfy the requirement. All returned data will be put in data=[]. As the rules have it, submesh count should be no more than five. The data will be traversed by the rules with each piece of data as variable b. Thus, the customized, ["Satisfy the expression", "len(d) <= 5"], should suffice.

Example 2. gim file associated files checking (reading attributes) Step 1. To find out the gim file, a regular expression, .*gam$, needs to be applied in the rpath.

Step 2. Read attributes. Locate the needed attributes, FileName, * / * / FileName:value, through fuzzy matches and obtain the value of 'value' under FileName.

Step 3. The value of 'value' is a path. You can change the data through customized filter or filter by subpath.

Example 3. Retrieve values in gim file (the numeric value under tag)

Step 1. To filter out the gim file, a regular expression .*gam$ needs to be applied in the rpath.

Step 2. To obtain the value of name under TEST1, we can use */TEST1.name to obtain the value data=[aaaaa].

Step 3. Customize rules according to the returned value.