GandaG / pyfomod

A high-level fomod library written in Python.

Home Page:https://pyfomod.rtfd.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Validate Error when no file is given in plugin section

erri120 opened this issue · comments

<plugin name="None"> <description> Uses vanilla ragdolls </description> <image path="fomod\1.jpg"/> <typeDescriptor> <type name="Optional"/> </typeDescriptor> </plugin>
This is invalid because after the description, it expects either a sequence with 'files'+'conditionFlags' or a sequence with 'conditionFlags'+ 'files'. I don't even know if you're still active but if you see this let me know and maybe post an idea. My work around: creating a new tree and inserting the files section with no content.

<xs:complexType name="plugin">
        <xs:sequence>
            <xs:element name="description" type="xs:string">
                <xs:annotation>
                    <xs:documentation>
                        A description of the plugin.
                    </xs:documentation>
                </xs:annotation>
            </xs:element>
            <xs:element name="image" type="image" minOccurs="0">
                <xs:annotation>
                    <xs:documentation>
                        The image associated with the plugin.
                    </xs:documentation>
                </xs:annotation>
            </xs:element>
            <xs:choice>
                <xs:sequence>
                    <xs:element name="files" type="fileList">
                        <xs:annotation>
                            <xs:documentation>
                                The list of files and folders that need
                                to be installed if the plugin is selected.
                            </xs:documentation>
                        </xs:annotation>
                    </xs:element>
                    <xs:element name="conditionFlags" type="conditionFlagList" minOccurs="0">
                        <xs:annotation>
                            <xs:documentation>
                                The list of flags to set if the plugin is selected.
                            </xs:documentation>
                        </xs:annotation>
                    </xs:element>
                </xs:sequence>
                <xs:sequence>
                    <xs:element name="conditionFlags" type="conditionFlagList">
                        <xs:annotation>
                            <xs:documentation>
                                The list of flags to set if the plugin is selected.
                            </xs:documentation>
                        </xs:annotation>
                    </xs:element>
                    <xs:element name="files" type="fileList" minOccurs="0">
                        <xs:annotation>
                            <xs:documentation>
                                The list of files and folders that need
                                to be installed if the plugin is selected.
                            </xs:documentation>
                        </xs:annotation>
                    </xs:element>
                </xs:sequence>
            </xs:choice>
            <xs:element name="typeDescriptor" type="pluginTypeDescriptor">
                <xs:annotation>
                    <xs:documentation>
                        Describes the type of the plugin.
                    </xs:documentation>
                </xs:annotation>
            </xs:element>
        </xs:sequence>
        <xs:attribute name="name" type="xs:string" use="required">
            <xs:annotation>
                <xs:documentation>
                    The name of the plugin.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:complexType>

This is the section for the plugin. I tried to implement the xs:all element because it allows the elements "files" and "conditionFlags" to be in any order and not even necessary, but the parent of xs:all can't be xs:choice. Tried to put a xs:group befor xs;all but got errors from lxml.etree. Do you think that xs:all could help?

The tree was created by pyfomod in it's directory in site-packages of Python 3.5.

That was an excerpt of a ModuleConfig.xml I tried to read using a program I currently develop. The file is from the mod 'Realistic Ragdolls and Force' (Skyrim SE mod). NMM (Nexus Mod Manager) read it correctly and it's one of the most downloaded mod for SSE. I now realize how bad I started this comment.
To clarify: I want to validate info.xml and ModuleConfig.xml of any mod and the your pyfomod.validate tells me that it shouldn't have found typeDescriptor but rather some files.

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://qconsulting.ca/fo3/ModConfig5.0.xsd">
  <moduleName>Realistic Ragdolls and Force</moduleName>
  <installSteps order="Explicit">
    <installStep name="Custom">
      <optionalFileGroups order="Explicit">
        <group name="Force" type="SelectExactlyOne">
          <plugins order="Explicit">
			<plugin name="Realistic">
              <description>
			   Ragdolls will crumble to the ground when killed. Represents realistic body weight and force of attacks.
              </description>
			  <image path="fomod\1.jpg"/>
              <files>
				<file source="plugins\dD - Realistic Ragdoll Force - Realistic.esp" destination="dD - Realistic Ragdoll Force - Realistic.esp"/>
              </files>
              <typeDescriptor>
                <type name="Optional"/>
              </typeDescriptor>
            </plugin>
			<plugin name="Reduced">
              <description>
               Ragdolls will have increased reactions when killed. More feedback from final hits.
              </description>
			  <image path="fomod\1.jpg"/>
              <files>
				<file source="plugins\dD - Realistic Ragdoll Force - Reduced.esp" destination="dD - Realistic Ragdoll Force - Reduced.esp"/>
              </files>
              <typeDescriptor>
                <type name="Optional"/>
              </typeDescriptor>
            </plugin>
			<plugin name="Medium">
              <description>
               Ragdolls will react more greatly to melee and range kills. Closer to vanilla, but ranged weapons and magic will not have the force of a cannon.
              </description>
			  <image path="fomod\1.jpg"/>
              <files>
				<file source="plugins\dD - Realistic Ragdoll Force - Medium.esp" destination="dD - Realistic Ragdoll Force - Medium.esp"/>
              </files>
              <typeDescriptor>
                <type name="Optional"/>
              </typeDescriptor>
            </plugin>
			<plugin name="High">
              <description>
               Very high force for melee and range attacks. Action movies.
              </description>
			  <image path="fomod\1.jpg"/>
              <files>
				<file source="plugins\dD - Realistic Ragdoll Force - High.esp" destination="dD - Realistic Ragdoll Force - High.esp"/>
              </files>
              <typeDescriptor>
                <type name="Optional"/>
              </typeDescriptor>
            </plugin>
		</plugins>
      </group>
        <group name="Ragdolls" type="SelectExactlyOne">
          <plugins order="Explicit">
			<plugin name="All">
              <description>
                Replaces all ragdolls
              </description>
			  <image path="fomod\1.jpg"/>
							<files>
								<folder source="ragdolls\Others" destination="meshes"/>
								<folder source="ragdolls\Players" destination="meshes"/>
							</files>
              <typeDescriptor>
                <type name="Optional"/>
              </typeDescriptor>
            </plugin>
			<plugin name="Cretures Only">
              <description>
                Replace creatures and animals only. Use this to avoid conflict with mods that also replace the playable race skeletons. If you using any compatibility skeleton patch use this option.
              </description>
			  <image path="fomod\1.jpg"/>
							<files>
								<folder source="ragdolls\Others" destination="meshes"/>
							</files>
              <typeDescriptor>
                <type name="Optional"/>
              </typeDescriptor>
            </plugin>
			<plugin name="None">
              <description>
                Uses vanilla ragdolls
              </description>
			  <image path="fomod\1.jpg"/>
              <typeDescriptor>
                <type name="Optional"/>
              </typeDescriptor>
            </plugin>
		</plugins>
		</group>
	 </optionalFileGroups>
    </installStep>
  </installSteps>
</config>

(in case you want to see how the whole ModuleConfig.xml)

As of 7ca2955 pyfomod should ignore this "error" and still be able to parse the installer, although when the user validates it will still complain this is not a good practice.