Skip to content

Commit

Permalink
Merge pull request #27 from rruiter87/minimize-id-changes
Browse files Browse the repository at this point in the history
Minimize id changes
  • Loading branch information
ZLLentz authored Jun 18, 2024
2 parents 721af8f + 1978067 commit 7c17620
Show file tree
Hide file tree
Showing 11 changed files with 260 additions and 2 deletions.
8 changes: 7 additions & 1 deletion .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,10 @@
description: Affixes newlines to ST segments
entry: twincat-st-newline
language: python
files: .*\.(TcPOU|TcGVL|TcDUT)$
files: .*\.(TcPOU|TcGVL|TcDUT)$
- id: minimize-id-changes
name: Check minimize id changes checked
description: Checks if the minimize id changes option is checked in the plcproj file.
entry: minimize-id-changes
language: python
files: .*\.plcproj$
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,17 @@ repos:
files: \.(TcPOU|TcDUT|TcGVL)$

- repo: https://github.com/pcdshub/pre-commit-hooks.git
rev: v1.5.0
rev: v1.6.0
hooks:
- id: twincat-leading-tabs-remover
- id: twincat-lineids-remover
- id: twincat-xml-format
- id: check-fixed-library-versions
- id: no-product-version
- id: twincat-st-newline
# Check if minimize id changes is selected in the plc project file.
# See https://www.youtube.com/watch?v=KKpBtaYjfWo&t=935s why to do this.
- id: minimize-id-changes
# Optional, if you use pytmc to generate EPICS IOCs:
# - id: pytmc-pragma-linter
```
Expand Down
3 changes: 3 additions & 0 deletions forTwinCatRepos/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,8 @@ repos:
- id: check-fixed-library-versions
- id: no-product-version
- id: twincat-st-newline
# Check if minimize id changes is selected in the plc project file.
# See https://www.youtube.com/watch?v=KKpBtaYjfWo&t=935s why to do this.
- id: minimize-id-changes
# Optional, if you use pytmc to generate EPICS IOCs:
# - id: pytmc-pragma-linter
38 changes: 38 additions & 0 deletions pre_commit_hooks/minimize_id_changes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import argparse
import xml.etree.ElementTree as ET
from importlib.abc import Traversable
from typing import Union


class PreCommitException(Exception):
pass


def minimize_id_changes_checked(filename: Union[Traversable, str]) -> None:
tree = ET.parse(filename)
root = tree.getroot()

combine_ids_element = root.find('.//{*}CombineIds')

if combine_ids_element is None or combine_ids_element.text.lower() == 'false':
raise PreCommitException(
f"Minimize id changes not checked in {filename}. "
f"To enable this go to Project settings > Common and select 'Minimize Id changes in TwinCAT files.'")


def main(args=None):
if args is None:
parser = argparse.ArgumentParser()
parser.add_argument('filenames', nargs='*')
args = parser.parse_args()
try:
for filename in args.filenames:
minimize_id_changes_checked(filename)
return 0
except Exception as exc:
print(exc)
return 1


if __name__ == "__main__":
exit(main())
Empty file.
Empty file.
94 changes: 94 additions & 0 deletions pre_commit_hooks/tests/data/minimize-id-changes-enabled.plcproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<FileVersion>1.0.0.0</FileVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{1361c63e-c3f2-4555-94a3-e0395dcf0a4c}</ProjectGuid>
<SubObjectsSortedByName>True</SubObjectsSortedByName>
<DownloadApplicationInfo>true</DownloadApplicationInfo>
<WriteProductVersion>true</WriteProductVersion>
<GenerateTpy>false</GenerateTpy>
<Name>PLC</Name>
<ProgramVersion>3.1.4024.0</ProgramVersion>
<Application>{83206d8f-62b4-4fa8-ab05-c17a527dee56}</Application>
<TypeSystem>{a1a8971a-d41a-466d-9815-2a15bc6b2b6a}</TypeSystem>
<Implicit_Task_Info>{73d4ce07-8d5e-4312-9201-83b075010509}</Implicit_Task_Info>
<Implicit_KindOfTask>{3f7c3e20-243c-4cff-be01-d0b2a5768750}</Implicit_KindOfTask>
<Implicit_Jitter_Distribution>{342ed85c-270a-468b-aba0-643e68b731fd}</Implicit_Jitter_Distribution>
<LibraryReferences>{a0dc4117-ad2d-4e28-9ee2-42c77070a57d}</LibraryReferences>
<Released>false</Released>
<CombineIds>true</CombineIds>
</PropertyGroup>
<ItemGroup>
<Compile Include="PlcTask.TcTTO">
<SubType>Code</SubType>
</Compile>
<Compile Include="POUs\MAIN.TcPOU">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<Folder Include="DUTs" />
<Folder Include="GVLs" />
<Folder Include="VISUs" />
<Folder Include="POUs" />
</ItemGroup>
<ItemGroup>
<PlaceholderReference Include="Tc2_Standard">
<DefaultResolution>Tc2_Standard, * (Beckhoff Automation GmbH)</DefaultResolution>
<Namespace>Tc2_Standard</Namespace>
</PlaceholderReference>
<PlaceholderReference Include="Tc2_System">
<DefaultResolution>Tc2_System, * (Beckhoff Automation GmbH)</DefaultResolution>
<Namespace>Tc2_System</Namespace>
</PlaceholderReference>
<PlaceholderReference Include="Tc3_Module">
<DefaultResolution>Tc3_Module, * (Beckhoff Automation GmbH)</DefaultResolution>
<Namespace>Tc3_Module</Namespace>
</PlaceholderReference>
<PlaceholderReference Include="TcUnit">
<DefaultResolution>TcUnit, * (www.tcunit.org)</DefaultResolution>
</PlaceholderReference>
</ItemGroup>
<ProjectExtensions>
<PlcProjectOptions>
<XmlArchive>
<Data>
<o xml:space="preserve" t="OptionKey">
<v n="Name">"&lt;ProjectRoot&gt;"</v>
<d n="SubKeys" t="Hashtable" ckt="String" cvt="OptionKey">
<v>{192FAD59-8248-4824-A8DE-9177C94C195A}</v>
<o>
<v n="Name">"{192FAD59-8248-4824-A8DE-9177C94C195A}"</v>
<d n="SubKeys" t="Hashtable" />
<d n="Values" t="Hashtable" />
</o>
<v>{8F99A816-E488-41E4-9FA3-846536012284}</v>
<o>
<v n="Name">"{8F99A816-E488-41E4-9FA3-846536012284}"</v>
<d n="SubKeys" t="Hashtable" />
<d n="Values" t="Hashtable" />
</o>
<v>{40450F57-0AA3-4216-96F3-5444ECB29763}</v>
<o>
<v n="Name">"{40450F57-0AA3-4216-96F3-5444ECB29763}"</v>
<d n="SubKeys" t="Hashtable" />
<d n="Values" t="Hashtable" ckt="String" cvt="String">
<v>ActiveVisuProfile</v>
<v>IR0whWr8bwfwBwAAiD2qpQAAAABVAgAA37x72QAAAAABAAAAAAAAAAEaUwB5AHMAdABlAG0ALgBTAHQAcgBpAG4AZwACTHsAZgA5ADUAYgBiADQAMgA2AC0ANQA1ADIANAAtADQAYgA0ADUALQA5ADQAMAAwAC0AZgBiADAAZgAyAGUANwA3AGUANQAxAGIAfQADCE4AYQBtAGUABDBUAHcAaQBuAEMAQQBUACAAMwAuADEAIABCAHUAaQBsAGQAIAA0ADAAMgA0AC4ANwAFFlAAcgBvAGYAaQBsAGUARABhAHQAYQAGTHsAMQA2AGUANQA1AGIANgAwAC0ANwAwADQAMwAtADQAYQA2ADMALQBiADYANQBiAC0ANgAxADQANwAxADMAOAA3ADgAZAA0ADIAfQAHEkwAaQBiAHIAYQByAGkAZQBzAAhMewAzAGIAZgBkADUANAA1ADkALQBiADAANwBmAC0ANABkADYAZQAtAGEAZQAxAGEALQBhADgAMwAzADUANgBhADUANQAxADQAMgB9AAlMewA5AGMAOQA1ADgAOQA2ADgALQAyAGMAOAA1AC0ANAAxAGIAYgAtADgAOAA3ADEALQA4ADkANQBmAGYAMQBmAGUAZABlADEAYQB9AAoOVgBlAHIAcwBpAG8AbgALBmkAbgB0AAwKVQBzAGEAZwBlAA0KVABpAHQAbABlAA4aVgBpAHMAdQBFAGwAZQBtAE0AZQB0AGUAcgAPDkMAbwBtAHAAYQBuAHkAEAxTAHkAcwB0AGUAbQARElYAaQBzAHUARQBsAGUAbQBzABIwVgBpAHMAdQBFAGwAZQBtAHMAUwBwAGUAYwBpAGEAbABDAG8AbgB0AHIAbwBsAHMAEyhWAGkAcwB1AEUAbABlAG0AcwBXAGkAbgBDAG8AbgB0AHIAbwBsAHMAFCRWAGkAcwB1AEUAbABlAG0AVABlAHgAdABFAGQAaQB0AG8AcgAVIlYAaQBzAHUATgBhAHQ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0X0AAJGgRFCgsEAwAAAAUAAAANAAAAKAAAANAMC60EAAAA0A0BLRjQDwEtENAZGq0BRRscAdAAHBoCRR0LBAMAAAAFAAAADQAAAAAAAADQHh8tINAhIhoCRSMkAtAAJRoFRQoLBAMAAAADAAAAAAAAAAoAAADQJgutAAAAANADAS0n0CgBLRHQKQEtENAAJRoFRQoLBAMAAAADAAAAAAAAAAoAAADQJgutAQAAANADAS0n0CgBLRHQKQEtEJoqKwFFAAEC0AABLSzQAAEtF9AAHy0t0C4vGgPQMAutAQAAANAxC60XAAAA0DIarQDQMy8aA9AwC60CAAAA0DELrQMAAADQMhqtANA0Gq0A0DUarQA=</v>
</d>
</o>
</d>
<d n="Values" t="Hashtable" />
</o>
</Data>
<TypeList>
<Type n="Hashtable">System.Collections.Hashtable</Type>
<Type n="OptionKey">{54dd0eac-a6d8-46f2-8c27-2f43c7e49861}</Type>
<Type n="String">System.String</Type>
</TypeList>
</XmlArchive>
</PlcProjectOptions>
</ProjectExtensions>
</Project>

92 changes: 92 additions & 0 deletions pre_commit_hooks/tests/data/no-minimize-id-changes.plcproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<FileVersion>1.0.0.0</FileVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{1361c63e-c3f2-4555-94a3-e0395dcf0a4c}</ProjectGuid>
<SubObjectsSortedByName>True</SubObjectsSortedByName>
<DownloadApplicationInfo>true</DownloadApplicationInfo>
<WriteProductVersion>true</WriteProductVersion>
<GenerateTpy>false</GenerateTpy>
<Name>PLC</Name>
<ProgramVersion>3.1.4024.0</ProgramVersion>
<Application>{83206d8f-62b4-4fa8-ab05-c17a527dee56}</Application>
<TypeSystem>{a1a8971a-d41a-466d-9815-2a15bc6b2b6a}</TypeSystem>
<Implicit_Task_Info>{73d4ce07-8d5e-4312-9201-83b075010509}</Implicit_Task_Info>
<Implicit_KindOfTask>{3f7c3e20-243c-4cff-be01-d0b2a5768750}</Implicit_KindOfTask>
<Implicit_Jitter_Distribution>{342ed85c-270a-468b-aba0-643e68b731fd}</Implicit_Jitter_Distribution>
<LibraryReferences>{a0dc4117-ad2d-4e28-9ee2-42c77070a57d}</LibraryReferences>
</PropertyGroup>
<ItemGroup>
<Compile Include="PlcTask.TcTTO">
<SubType>Code</SubType>
</Compile>
<Compile Include="POUs\MAIN.TcPOU">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<Folder Include="DUTs" />
<Folder Include="GVLs" />
<Folder Include="VISUs" />
<Folder Include="POUs" />
</ItemGroup>
<ItemGroup>
<PlaceholderReference Include="Tc2_Standard">
<DefaultResolution>Tc2_Standard, * (Beckhoff Automation GmbH)</DefaultResolution>
<Namespace>Tc2_Standard</Namespace>
</PlaceholderReference>
<PlaceholderReference Include="Tc2_System">
<DefaultResolution>Tc2_System, * (Beckhoff Automation GmbH)</DefaultResolution>
<Namespace>Tc2_System</Namespace>
</PlaceholderReference>
<PlaceholderReference Include="Tc3_Module">
<DefaultResolution>Tc3_Module, * (Beckhoff Automation GmbH)</DefaultResolution>
<Namespace>Tc3_Module</Namespace>
</PlaceholderReference>
<PlaceholderReference Include="TcUnit">
<DefaultResolution>TcUnit, * (www.tcunit.org)</DefaultResolution>
</PlaceholderReference>
</ItemGroup>
<ProjectExtensions>
<PlcProjectOptions>
<XmlArchive>
<Data>
<o xml:space="preserve" t="OptionKey">
<v n="Name">"&lt;ProjectRoot&gt;"</v>
<d n="SubKeys" t="Hashtable" ckt="String" cvt="OptionKey">
<v>{192FAD59-8248-4824-A8DE-9177C94C195A}</v>
<o>
<v n="Name">"{192FAD59-8248-4824-A8DE-9177C94C195A}"</v>
<d n="SubKeys" t="Hashtable" />
<d n="Values" t="Hashtable" />
</o>
<v>{8F99A816-E488-41E4-9FA3-846536012284}</v>
<o>
<v n="Name">"{8F99A816-E488-41E4-9FA3-846536012284}"</v>
<d n="SubKeys" t="Hashtable" />
<d n="Values" t="Hashtable" />
</o>
<v>{40450F57-0AA3-4216-96F3-5444ECB29763}</v>
<o>
<v n="Name">"{40450F57-0AA3-4216-96F3-5444ECB29763}"</v>
<d n="SubKeys" t="Hashtable" />
<d n="Values" t="Hashtable" ckt="String" cvt="String">
<v>ActiveVisuProfile</v>
<v>IR0whWr8bwfwBwAAiD2qpQAAAABVAgAA37x72QAAAAABAAAAAAAAAAEaUwB5AHMAdABlAG0ALgBTAHQAcgBpAG4AZwACTHsAZgA5ADUAYgBiADQAMgA2AC0ANQA1ADIANAAtADQAYgA0ADUALQA5ADQAMAAwAC0AZgBiADAAZgAyAGUANwA3AGUANQAxAGIAfQADCE4AYQBtAGUABDBUAHcAaQBuAEMAQQBUACAAMwAuADEAIABCAHUAaQBsAGQAIAA0ADAAMgA0AC4ANwAFFlAAcgBvAGYAaQBsAGUARABhAHQAYQAGTHsAMQA2AGUANQA1AGIANgAwAC0ANwAwADQAMwAtADQAYQA2ADMALQBiADYANQBiAC0ANgAxADQANwAxADMAOAA3ADgAZAA0ADIAfQAHEkwAaQBiAHIAYQByAGkAZQBzAAhMewAzAGIAZgBkADUANAA1ADkALQBiADAANwBmAC0ANABkADYAZQAtAGEAZQAxAGEALQBhADgAMwAzADUANgBhADUANQAxADQAMgB9AAlMewA5AGMAOQA1ADgAOQA2ADgALQAyAGMAOAA1AC0ANAAxAGIAYgAtADgAOAA3ADEALQA4ADkANQBmAGYAMQBmAGUAZABlADEAYQB9AAoOVgBlAHIAcwBpAG8AbgALBmkAbgB0AAwKVQBzAGEAZwBlAA0KVABpAHQAbABlAA4aVgBpAHMAdQBFAGwAZQBtAE0AZQB0AGUAcgAPDkMAbwBtAHAAYQBuAHkAEAxTAHkAcwB0AGUAbQARElYAaQBzAHUARQBsAGUAbQBzABIwVgBpAHMAdQBFAGwAZQBtAHMAUwBwAGUAYwBpAGEAbABDAG8AbgB0AHIAbwBsAHMAEyhWAGkA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0BLRTQDwEtENAACRoERQoLBAMAAAAFAAAADQAAAAAAAADQDAutAgAAANANAS0V0A8BLRDQAAkaBEUKCwQDAAAABQAAAA0AAAAAAAAA0AwLrQIAAADQDQEtFtAPAS0X0AAJGgRFCgsEAwAAAAUAAAANAAAAKAAAANAMC60EAAAA0A0BLRjQDwEtENAZGq0BRRscAdAAHBoCRR0LBAMAAAAFAAAADQAAAAAAAADQHh8tINAhIhoCRSMkAtAAJRoFRQoLBAMAAAADAAAAAAAAAAoAAADQJgutAAAAANADAS0n0CgBLRHQKQEtENAAJRoFRQoLBAMAAAADAAAAAAAAAAoAAADQJgutAQAAANADAS0n0CgBLRHQKQEtEJoqKwFFAAEC0AABLSzQAAEtF9AAHy0t0C4vGgPQMAutAQAAANAxC60XAAAA0DIarQDQMy8aA9AwC60CAAAA0DELrQMAAADQMhqtANA0Gq0A0DUarQA=</v>
</d>
</o>
</d>
<d n="Values" t="Hashtable" />
</o>
</Data>
<TypeList>
<Type n="Hashtable">System.Collections.Hashtable</Type>
<Type n="OptionKey">{54dd0eac-a6d8-46f2-8c27-2f43c7e49861}</Type>
<Type n="String">System.String</Type>
</TypeList>
</XmlArchive>
</PlcProjectOptions>
</ProjectExtensions>
</Project>

20 changes: 20 additions & 0 deletions pre_commit_hooks/tests/test_minimize_id_changes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from importlib.resources import files

import pre_commit_hooks.tests.data as test_data
import pytest
from pre_commit_hooks.minimize_id_changes import (PreCommitException,
minimize_id_changes_checked)


def test_missing_minimize_id_changes():
plcproj_filename = files(test_data).joinpath("no-minimize-id-changes.plcproj")

with pytest.raises(PreCommitException):
minimize_id_changes_checked(plcproj_filename)


def test_enabled_minimize_id_changes():
plcproj_filename = files(test_data).joinpath("minimize-id-changes-enabled.plcproj")

# Doesnt raise PreCommitException
minimize_id_changes_checked(plcproj_filename)
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
lxml
pytest
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
'check-fixed-library-versions',
'no-product-version',
'twincat-st-newline',
'minimize-id-changes',
]
console_scripts = []
for name in hook_names:
Expand Down

0 comments on commit 7c17620

Please sign in to comment.