Skip to content

Commit

Permalink
[OpenWrt] Minor regexp optimization for generate method
Browse files Browse the repository at this point in the history
  • Loading branch information
nemesifier committed Feb 16, 2016
1 parent d6f2674 commit 6ec5ce8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion netjsonconfig/backends/openwrt/openwrt.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class OpenWrt(object):
renderers.DefaultRenderer
]
FILE_SECTION_DELIMITER = '# ---------- files ---------- #'
PACKAGE_EXP = re.compile('package ')

def __init__(self, config, templates=[]):
"""
Expand Down Expand Up @@ -173,7 +174,7 @@ def _generate_contents(self, tar):
"""
uci = self.render(files=False)
# create a list with all the packages (and remove empty entries)
packages = re.split('package ', uci)
packages = self.PACKAGE_EXP.split(uci)
if '' in packages:
packages.remove('')
# for each package create a file with its contents in /etc/config
Expand Down

0 comments on commit 6ec5ce8

Please sign in to comment.