Skip to content
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
4 changes: 2 additions & 2 deletions lobster/common/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ def lobster_read(
mh.error(loc, f"unknown schema kind {data['schema']}")
if data["version"] not in supported_schema[data["schema"]]:
mh.error(loc,
"version %u for schema %s is not supported" %
(data["version"], data["schema"]))
f"version {data['version']} for schema "
f"{data['schema']} is not supported")

duplicate_items = []
# Convert to items, and integrate into symbol table
Expand Down
4 changes: 2 additions & 2 deletions lobster/common/items.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ def determine_status(self, config, stab):
if not any(has_trace[src] for src in chain) and \
not has_just_down:
ok_down = False
self.messages.append("missing reference to %s" %
" or ".join(sorted(chain)))
chain_str = " or ".join(sorted(chain))
self.messages.append(f"missing reference to {chain_str}")

# Set status
if self.has_error:
Expand Down
2 changes: 1 addition & 1 deletion lobster/common/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def parse(self):
else:
self.error(self.nt.loc,
"expected: requirements|implementation|activity,"
" found %s instead" % self.nt.value())
f" found {self.nt.value()} instead")

return self.levels

Expand Down
17 changes: 8 additions & 9 deletions lobster/common/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,13 @@ def resolve_references_for_items(self):
# Check versions match, if specified
if dst_tag.version is not None:
if dst_item.tag.version is None:
src_item.error("tracing destination %s is unversioned"
% dst_tag.key())
src_item.error(
f"tracing destination {dst_tag.key()} is unversioned"
)
elif dst_tag.version != dst_item.tag.version:
src_item.error("tracing destination %s has version %s"
" (expected %s)" %
(dst_tag.key(),
dst_item.tag.version,
dst_tag.version))
msg = (f"tracing destination {dst_tag.key()} has version "
f"{dst_item.tag.version} (expected {dst_tag.version})")
src_item.error(msg)

def compute_coverage_for_items(self):
for level_obj in self.coverage.values():
Expand Down Expand Up @@ -237,8 +236,8 @@ def validate_indicated_schema(self, data, loc):
self.mh.error(loc, f"unknown schema kind {data['schema']}")
if data["version"] not in supported_schema[data["schema"]]:
self.mh.error(loc,
"version %u for schema %s is not supported" %
(data["version"], data["schema"]))
f"version {data['version']} for schema "
f"{data['schema']} is not supported")

def validate_basic_structure_of_lobster_file(self, data, loc):
"""
Expand Down
8 changes: 5 additions & 3 deletions lobster/htmldoc/htmldoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,11 @@ def generate(self, doc) -> List[str]:
}

rv = ['<div class="dropdown">']
rv.append('<button class="dropbtn">%s%s</button>' %
(html.escape(self.name),
'<svg class="icon"><use href="#svg-chevron-down"></use></svg>'))
rv.append(
f'<button class="dropbtn">{html.escape(self.name)}'
'<svg class="icon"><use href="#svg-chevron-down"></use></svg>'
'</button>'
)
rv.append('<div class="dropdown-content">')
for item in self.items:
rv += item.generate(doc)
Expand Down
22 changes: 8 additions & 14 deletions lobster/tools/codebeamer/codebeamer.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,9 @@ def get_many_items(cb_config: Config, item_ids: Iterable[int]):
f"({','.join(str(item_id) for item_id in item_ids)})")

while True:
base_url = "%s/items/query?page=%u&pageSize=%u&queryString=%s"\
% (cb_config.base, page_id,
cb_config.page_size, query_string)
base_url = (f"{cb_config.base}/items/query?page={page_id}"
f"&pageSize={cb_config.page_size}"
f"&queryString={query_string}")
data = query_cb_single(cb_config, base_url)
rv += data["items"]
if len(rv) == data["total"]:
Expand All @@ -224,19 +224,13 @@ def get_query(cb_config: Config, query: Union[int, str]):
total_items = None

while total_items is None or len(rv) < total_items:
print("Fetching page %u of query..." % page_id)
print(f"Fetching page {page_id} of query...")
if isinstance(query, int):
url = ("%s/reports/%u/items?page=%u&pageSize=%u" %
(cb_config.base,
query,
page_id,
cb_config.page_size))
url = (f"{cb_config.base}/reports/{query}/items"
f"?page={page_id}&pageSize={cb_config.page_size}")
elif isinstance(query, str):
url = ("%s/items/query?page=%u&pageSize=%u&queryString=%s" %
(cb_config.base,
page_id,
cb_config.page_size,
query))
url = (f"{cb_config.base}/items/query?page={page_id}"
f"&pageSize={cb_config.page_size}&queryString={query}")
data = query_cb_single(cb_config, url)
if len(data) != 4:
raise MismatchException(
Expand Down
34 changes: 18 additions & 16 deletions lobster/tools/core/html_report/html_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,18 +151,18 @@ def create_item_coverage(doc, report):
doc.add_line(
f'<tr class="coverage-table-{level.name.replace(" ", "-").lower()}">'
)
doc.add_line('<td><a href="#sec-%s">%s</a></td>' %
(name_hash(level.name),
html.escape(level.name)))
doc.add_line(
f'<td><a href="#sec-{name_hash(level.name)}">'
f'{html.escape(level.name)}</a></td>'
)
doc.add_line(f"<td>{data.coverage:.1f}%</td>")
doc.add_line("<td>")
doc.add_line('<progress value="%u" max="%u">' %
(data.ok, data.items))
doc.add_line(f'<progress value="{data.ok}" max="{data.items}">')
doc.add_line(f"{data.coverage:.2f}%")
doc.add_line('</progress>')
doc.add_line("</td>")
doc.add_line('<td align="right">%u</td>' % data.ok)
doc.add_line('<td align="right">%u</td>' % data.items)
doc.add_line(f'<td align="right">{data.ok}</td>')
doc.add_line(f'<td align="right">{data.items}</td>')
doc.add_line("</tr>")
doc.add_line("</table>")

Expand Down Expand Up @@ -205,12 +205,13 @@ def write_item_box_begin(doc, item, report):
doc.add_line(f'<div class="item-{html.escape(item.tracing_status.name.lower())}" '
f'id="item-{item.tag.hash()}">')

doc.add_line('<div class="item-name">%s %s</div>' %
('<svg class="icon"><use href="#svg-check-square"></use></svg>'
if item.tracing_status in (Tracing_Status.OK,
Tracing_Status.JUSTIFIED)
else '<svg class="icon"><use href="#svg-alert-triangle"></use></svg>',
xref_item(item, link=False)))
svg_icon = (
'<svg class="icon"><use href="#svg-check-square"></use></svg>'
if item.tracing_status in (Tracing_Status.OK, Tracing_Status.JUSTIFIED)
else '<svg class="icon"><use href="#svg-alert-triangle"></use></svg>'
)
item_div_content = f'{svg_icon} {xref_item(item, link=False)}'
doc.add_line(f'<div class="item-name">{item_div_content}</div>')

doc.add_line('<div class="attribute">Source: ')
doc.add_line('<svg class="icon"><use href="#svg-external-link"></use></svg>')
Expand Down Expand Up @@ -533,9 +534,10 @@ def write_html(report, dot, high_contrast, render_md) -> str:
Github_Reference)):
new_file_heading = item.location.filename
elif isinstance(item.location, Codebeamer_Reference):
new_file_heading = "Codebeamer %s, tracker %u" % \
(item.location.cb_root,
item.location.tracker)
new_file_heading = (
f"Codebeamer {item.location.cb_root},"
f" tracker {item.location.tracker}"
)
else: # pragma: no cover
assert False
if new_file_heading != file_heading:
Expand Down
7 changes: 4 additions & 3 deletions lobster/tools/cpptest/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ def __init__(self, codebeamer_url = ''):

self.codebeamer_link = codebeamer_url + "/issue/"
self.requirement = re.compile(r'@requirement[\s\S]*?(?=@|\Z)')
self.requirement_tag_http = ((r"([@\\]requirement(\s+"
r"(CB-#\d+\s+)*({}\d+\s*,?\s*/*\*?)+)+)")
.format(self.codebeamer_link))
self.requirement_tag_http = (
rf"([@\\]requirement(\s+(CB-#\d+\s+)*"
rf"({self.codebeamer_link}\d+\s*,?\s*/*\*?)+)+)"
)
self.requirement_tag_http_named = rf"({self.codebeamer_link}(?P<number>\d+))"

NON_EXISTING_INFO = "---"
Expand Down
15 changes: 5 additions & 10 deletions lobster/tools/python/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,17 +155,12 @@ def lobster_tag(self):

def warn_ignored(self, reason):
for tag in self.tags:
print("%s: warning: ignored tag %s because "
"%s already has annotations" %
(self.location.to_string(),
tag,
reason))
print(f"{self.location.to_string()}: warning: ignored tag {tag}"
f" because {reason} already has annotations")
for just in self.just:
print("%s: warning: ignored justification '%s' because "
"%s already has annotations" %
(self.location.to_string(),
just,
reason))
print(f"{self.location.to_string()}: warning: "
f"ignored justification '{just}' "
f"because {reason} already has annotations")


class Python_Module(Python_Traceable_Node):
Expand Down
3 changes: 1 addition & 2 deletions pylint3.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ disable=
too-many-arguments,
too-many-locals,
too-many-statements,
too-many-nested-blocks,
consider-using-f-string
too-many-nested-blocks

[REPORTS]
output-format=text
Expand Down
6 changes: 2 additions & 4 deletions util/bump_version_post_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,15 @@
with open(VERSION_FILE, encoding="UTF-8") as fd:
for raw_line in fd:
if raw_line.startswith("VERSION_TUPLE"):
raw_line = 'VERSION_TUPLE = (%u, %u, %u)\n' % (major,
minor,
release)
raw_line = f'VERSION_TUPLE = ({major}, {minor}, {release})\n'
elif raw_line.startswith("VERSION_SUFFIX"):
raw_line = 'VERSION_SUFFIX = "dev"\n'

tmp += raw_line
with open(VERSION_FILE, "w", encoding="UTF-8") as fd:
fd.write(tmp)

LOBSTER_VERSION = "%u.%u.%u-dev" % (major, minor, release)
LOBSTER_VERSION = f"{major}.{minor}.{release}-dev"

# Update changelog and docs, adding a new entry

Expand Down
Loading