Skip to content

Commit

Permalink
Merge pull request #208 from reportportal/develop
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
HardNorth authored Jan 14, 2025
2 parents 76e8f18 + 91f10c0 commit 85fe599
Show file tree
Hide file tree
Showing 8 changed files with 364 additions and 159 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Changelog

## [Unreleased]
### Added
- `RP_FLATTEN_KEYWORDS` configuration variable, by @HardNorth
- `--flatten-keywords` argument support, by @HardNorth

## [5.6.0]
### Changed
- Client version updated on [5.6.0](https://github.com/reportportal/client-Python/releases/tag/5.6.0), by @HardNorth
- Test end message now posts to the Test description, by @HardNorth
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ NOT REQUIRED:
Also, you can specify a full path to your certificate as the value.
--variable RP_REMOVE_KEYWORDS:"True"
- Default value is "False", remove keywords from reporting, passed with '--remove-keywords' Robot's argument.
--variable RP_FLATTEN_KEYWORDS:"True"
- Default value is "False", flatten keywords on reporting, passed with '--flatten-keywords' Robot's argument.
```

### Logging
Expand Down
48 changes: 24 additions & 24 deletions robotframework_reportportal/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,6 @@
from typing import Iterable, Optional, Tuple


def replace_patterns(text: str, patterns: Iterable[Tuple[re.Pattern, str]]) -> str:
"""Replace given patterns in the text."""
result = text
for p, repl in patterns:
result = p.sub(repl, result)
return result


BARE_LINK_PATTERN = re.compile(r"\[\s*([^]|]+)]")
NAMED_LINK_PATTERN = re.compile(r"\[\s*([^]|]+)\|\s*([^]]+)]")

ROBOT_MARKUP_REPLACEMENT_PATTERS = [
(BARE_LINK_PATTERN, r"<\1>"),
(NAMED_LINK_PATTERN, r"[\2](\1)"),
]

PATTERN_MATCHES_EMPTY_STRING: re.Pattern = re.compile("^$")


def robot_markup_to_markdown(text: str) -> str:
"""Convert Robot Framework's text markup to Markdown format."""
return replace_patterns(text, ROBOT_MARKUP_REPLACEMENT_PATTERS)


def translate_glob_to_regex(pattern: Optional[str]) -> Optional[re.Pattern]:
"""Translate glob string pattern to regex Pattern.
Expand Down Expand Up @@ -72,6 +48,30 @@ def match_pattern(pattern: Optional[re.Pattern], line: Optional[str]) -> bool:
return pattern.fullmatch(line) is not None


def replace_patterns(text: str, patterns: Iterable[Tuple[re.Pattern, str]]) -> str:
"""Replace given patterns in the text."""
result = text
for p, repl in patterns:
result = p.sub(repl, result)
return result


BARE_LINK_PATTERN = re.compile(r"\[\s*([^]|]+)]")
NAMED_LINK_PATTERN = re.compile(r"\[\s*([^]|]+)\|\s*([^]]+)]")

ROBOT_MARKUP_REPLACEMENT_PATTERS = [
(BARE_LINK_PATTERN, r"<\1>"),
(NAMED_LINK_PATTERN, r"[\2](\1)"),
]

PATTERN_MATCHES_EMPTY_STRING: re.Pattern = re.compile("^$")


def robot_markup_to_markdown(text: str) -> str:
"""Convert Robot Framework's text markup to Markdown format."""
return replace_patterns(text, ROBOT_MARKUP_REPLACEMENT_PATTERS)


def _unescape(binary_string: str, stop_at: int = -1):
result = bytearray()
join_list = list()
Expand Down
Loading

0 comments on commit 85fe599

Please sign in to comment.