Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update style to satisfy new flake8 plugins #107

Merged
merged 1 commit into from
Aug 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ament_cmake_core/cmake/core/package_xml_2_cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
except ImportError as e:
sys.exit("ImportError: 'from ament_package import parse_package_string' "
"failed: %s\nMake sure that you have installed 'ament_package', "
"it is up to date and on the PYTHONPATH." % e)
'it is up to date and on the PYTHONPATH.' % e)


def main(argv=sys.argv[1:]):
Expand Down
26 changes: 10 additions & 16 deletions ament_cmake_test/cmake/run_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import errno
import os
import re
import sys
import subprocess
import sys
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you had to run the test manually to find those? they are not tested automatically right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those showed up in my awesome :atom: so I "had to fix" them while I was editing the file 🚀

from xml.etree.ElementTree import ElementTree
from xml.etree.ElementTree import ParseError
from xml.sax.saxutils import quoteattr
Expand Down Expand Up @@ -91,10 +91,7 @@ def main(argv=sys.argv[1:]):

if args.skip_test:
# generate a skipped test result file
skipped_result_file = _generate_result(
args.result_file,
skip=True
)
skipped_result_file = _generate_result(args.result_file, skip=True)
with open(args.result_file, 'w') as h:
h.write(skipped_result_file)
return 0
Expand All @@ -103,8 +100,7 @@ def main(argv=sys.argv[1:]):
# in case the command segfaults or timeouts and does not generate one
failure_result_file = _generate_result(
args.result_file,
failure_message='The test did not generate a result file.'
)
failure_message='The test did not generate a result file.')
with open(args.result_file, 'w') as h:
h.write(failure_result_file)

Expand Down Expand Up @@ -173,8 +169,7 @@ def log(msg, **kwargs):
try:
proc = subprocess.Popen(
args.command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
env=env
)
env=env)
while True:
line = proc.stdout.readline()
if not line:
Expand Down Expand Up @@ -219,8 +214,7 @@ def log(msg, **kwargs):
# regenerate result file to include output / exception of the invoked command
failure_result_file = _generate_result(
args.result_file,
failure_message='The test did not generate a result file:\n\n' + output
)
failure_message='The test did not generate a result file:\n\n' + output)
with open(args.result_file, 'w') as h:
h.write(failure_result_file)

Expand Down Expand Up @@ -273,12 +267,12 @@ def _generate_result(result_file, *, failure_message=None, skip=False):
skipped_message = \
'<skipped type="skip" message="">![CDATA[Test Skipped by developer]]</skipped>' \
if skip else ''
return '''<?xml version="1.0" encoding="UTF-8"?>
return """<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="%s" tests="1" failures="%d" time="0" errors="0" skip="%d">
<testcase classname="%s" name="%s.missing_result" status="%s" time="0">
%s%s
</testcase>
</testsuite>\n''' % \
</testsuite>\n""" % \
(
pkgname,
1 if failure_message else 0,
Expand Down Expand Up @@ -314,7 +308,7 @@ def _tidy_xml(filename):
char = unichr
except NameError:
char = chr
RE_XML_ILLEGAL = (
re_xml_illegal = (
'([%s-%s%s-%s%s-%s%s-%s])' +
'|' +
'([%s-%s][^%s-%s])|([^%s-%s][%s-%s])|([%s-%s]$)|(^[%s-%s])') % \
Expand All @@ -323,9 +317,9 @@ def _tidy_xml(filename):
char(0xd800), char(0xdbff), char(0xdc00), char(0xdfff),
char(0xd800), char(0xdbff), char(0xdc00), char(0xdfff),
char(0xd800), char(0xdbff), char(0xdc00), char(0xdfff))
SAFE_XML_REGEX = re.compile(RE_XML_ILLEGAL)
safe_xml_regex = re.compile(re_xml_illegal)

for match in SAFE_XML_REGEX.finditer(data):
for match in safe_xml_regex.finditer(data):
data = data[:match.start()] + '?' + data[match.end():]

with open(filename, 'w') as h:
Expand Down