mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-29 19:57:12 +08:00
px_romfs_pruner.py: PEP8 and comments fixes
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
############################################################################
|
############################################################################
|
||||||
#
|
#
|
||||||
# Copyright (C) 2014-2016 PX4 Development Team. All rights reserved.
|
# Copyright (C) 2014-2018 PX4 Development Team. All rights reserved.
|
||||||
|
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
# modification, are permitted provided that the following conditions
|
# modification, are permitted provided that the following conditions
|
||||||
@@ -35,10 +35,10 @@
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
px_romfs_pruner.py:
|
px_romfs_pruner.py:
|
||||||
Try to keep size of ROMFS minimal.
|
Try to keep size of the ROMFS minimal.
|
||||||
|
|
||||||
This script goes through the temporarily copied ROMFS data and deletes all
|
This script goes through the temporarily copied ROMFS data and deletes all
|
||||||
comments, empty lines and leading whitespace.
|
comments, empty lines and unnecessary whitespace.
|
||||||
It also deletes hidden files such as auto-saved backups that a text editor
|
It also deletes hidden files such as auto-saved backups that a text editor
|
||||||
might have left in the tree.
|
might have left in the tree.
|
||||||
|
|
||||||
@@ -91,12 +91,14 @@ def main():
|
|||||||
board_excluded = False
|
board_excluded = False
|
||||||
with io.open(file_path, "r", newline=None) as f:
|
with io.open(file_path, "r", newline=None) as f:
|
||||||
for line in f:
|
for line in f:
|
||||||
if re.search(r'\b{0} exclude\b'.format(args.board),line):
|
if re.search(r'\b{0} exclude\b'.format(args.board), line):
|
||||||
board_excluded = True;
|
board_excluded = True
|
||||||
# handle mixer files differently than startup files
|
# handle mixer files differently than startup files
|
||||||
if file_path.endswith(".mix"):
|
if file_path.endswith(".mix"):
|
||||||
if line.startswith(("Z:", "M:", "R: ", "O:", "S:", "H:", "T:", "P:")):
|
if line.startswith(("Z:", "M:", "R: ", "O:", "S:",
|
||||||
# reduce multiple consecutive spaces into a single space
|
"H:", "T:", "P:")):
|
||||||
|
# reduce multiple consecutive spaces into a
|
||||||
|
# single space
|
||||||
line_reduced = re.sub(' +', ' ', line)
|
line_reduced = re.sub(' +', ' ', line)
|
||||||
pruned_content += line_reduced
|
pruned_content += line_reduced
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user