-
Notifications
You must be signed in to change notification settings - Fork 29
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
59 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
This is a test | ||
Test |
62 changes: 58 additions & 4 deletions
62
mil_common/utils/mil_tools/scripts/preflight/preflightFileIO.py
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 |
---|---|---|
@@ -1,8 +1,62 @@ | ||
#!/usr/bin/env python3 | ||
|
||
SubCheckList = open("SubChecklist.txt", "a+") | ||
line = ["This is a test\n"] | ||
SubCheckList.writelines(line) | ||
# Systems[] | ||
# Global variable that contains all the systems. Used to standardized file name. Ex Subjugator or Navigator | ||
|
||
# writeTests(fileName, topicsToCheck[]) | ||
# fileName should standardized, this input should be from a selected number of names | ||
# topicsToCheck[] this array should only contain valid topics that we will make sure data is in. | ||
# What ever program calls this function should only pass in valid topics. This will be a list of strings. | ||
# This should not delete old topicsToCheck only add new ones. | ||
|
||
SubCheckList.close() | ||
# deleteTests(fileName, topicsToCheck[]) | ||
# fileName should standardized, this input should be from a selected number of names | ||
# topicsToCheck[] this array should only contain valid topics that we will make sure data is in. | ||
# What ever program calls this function should only pass in valid topics. This will be a list of strings. | ||
# delete tests from the file. | ||
|
||
# readTests(filename) | ||
# reads and runs all the tests in the file. | ||
# returns whether each test pass or fail | ||
|
||
|
||
def writeTests(filename, topicsToCheck): | ||
tests = open(filename, "a+") | ||
lines = tests.readlines() | ||
|
||
# If the topic to add is not already in the list add it | ||
for topic in topicsToCheck: | ||
topic += "\n" | ||
if topic not in lines: | ||
tests.write(topic) | ||
tests.close() | ||
|
||
|
||
def deleteTests(filename, topicsToCheck): | ||
tests = open(filename) | ||
lines = tests.readlines() | ||
tests.close() | ||
|
||
# If the topic to add is not already in the list add it | ||
for topic in topicsToCheck: | ||
topic += "\n" | ||
if topic in lines: | ||
lines.remove(topic) | ||
|
||
tests = open(filename, "w") | ||
tests.writelines(lines) | ||
|
||
|
||
def readTests(filename): | ||
tests = open(filename) | ||
lines = tests.readlines() | ||
for i in range(len(lines)): | ||
lines[i] = lines[i][:-1] | ||
|
||
print(lines) | ||
# We need to call the ros topic and verify the data WIP | ||
|
||
|
||
writeTests("SubChecklist.txt", ["Test", "testing"]) | ||
deleteTests("SubChecklist.txt", ["testing"]) | ||
readTests("SubChecklist.txt") |