aboutsummaryrefslogtreecommitdiff
path: root/Tools/px_romfs_pruner.py
diff options
context:
space:
mode:
authorThomas Gubler <thomasgubler@gmail.com>2014-05-02 13:23:47 +0200
committerThomas Gubler <thomasgubler@gmail.com>2014-05-02 14:26:22 +0200
commit047dfc77141e3eb07b9e392e75879ebc0b4bcd6c (patch)
treef9ea111570b17d0ae938c6865e5eddf0471d5398 /Tools/px_romfs_pruner.py
parentf8704e2183363ea6f9781efd112d222f079bd915 (diff)
downloadpx4-firmware-047dfc77141e3eb07b9e392e75879ebc0b4bcd6c.tar.gz
px4-firmware-047dfc77141e3eb07b9e392e75879ebc0b4bcd6c.tar.bz2
px4-firmware-047dfc77141e3eb07b9e392e75879ebc0b4bcd6c.zip
romfs pruner: do not try to prune .swp files
Diffstat (limited to 'Tools/px_romfs_pruner.py')
-rw-r--r--Tools/px_romfs_pruner.py29
1 files changed, 15 insertions, 14 deletions
diff --git a/Tools/px_romfs_pruner.py b/Tools/px_romfs_pruner.py
index ceef9f9be..9c88ec372 100644
--- a/Tools/px_romfs_pruner.py
+++ b/Tools/px_romfs_pruner.py
@@ -43,29 +43,30 @@ from __future__ import print_function
import argparse
import os
+
def main():
-
+
# Parse commandline arguments
parser = argparse.ArgumentParser(description="ROMFS pruner.")
parser.add_argument('--folder', action="store", help="ROMFS scratch folder.")
args = parser.parse_args()
-
+
print("Pruning ROMFS files.")
-
- # go through
+
+ # go through
for (root, dirs, files) in os.walk(args.folder):
for file in files:
# only prune text files
- if ".zip" in file or ".bin" in file:
+ if ".zip" in file or ".bin" or ".swp" in file:
continue
-
- file_path = os.path.join(root, file)
-
+
+ file_path = os.path.join(root, file)
+
# read file line by line
pruned_content = ""
with open(file_path, "r") as f:
- for line in f:
-
+ for line in f:
+
# handle mixer files differently than startup files
if file_path.endswith(".mix"):
if line.startswith(("Z:", "M:", "R: ", "O:", "S:")):
@@ -73,11 +74,11 @@ def main():
else:
if not line.isspace() and not line.strip().startswith("#"):
pruned_content += line
-
+
# overwrite old scratch file
with open(file_path, "w") as f:
f.write(pruned_content)
-
-
+
+
if __name__ == '__main__':
- main() \ No newline at end of file
+ main()