-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import re | ||
import sys | ||
|
||
|
||
def rearrange(filename): | ||
with open(filename, 'r') as file: | ||
content = file.read() | ||
|
||
# Regex to find the blocks of code to rearrange | ||
pattern = re.compile(r'(putIndex\(new SimpleSubscriberInfo\(.*?\)\);)', re.DOTALL) | ||
blocks = pattern.findall(content) | ||
|
||
# Sort blocks based on the class names mentioned in SimpleSubscriberInfo instances | ||
sorted_blocks = sorted(blocks, key=lambda x: re.search(r'SimpleSubscriberInfo\((.*?),', x).group(1)) | ||
|
||
# Replace the original blocks with the sorted blocks | ||
sorted_content = pattern.sub(lambda match: sorted_blocks.pop(0), content) | ||
|
||
with open(filename, 'w') as file: | ||
file.write(sorted_content) | ||
|
||
|
||
# Project root relative to the script | ||
project_root = __file__[:-len('/app/scripts/fixEventBus.py')] | ||
|
||
path = './build/generated/ap_generated_sources/release/out/eu/basicairdata/graziano/gpslogger/EventBusIndex.java' | ||
|
||
# Print the path to the file to stderr | ||
print(path, file=sys.stderr) | ||
|
||
# Call the function with the path to EventBusIndex.java | ||
rearrange(path) |