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

Align cyber #533

Merged
merged 4 commits into from
Feb 12, 2024
Merged

Align cyber #533

merged 4 commits into from
Feb 12, 2024

Conversation

Schamper
Copy link
Member

No description provided.

@Schamper Schamper requested a review from Miauwkeru February 11, 2024 10:28
Copy link

codecov bot commented Feb 11, 2024

Codecov Report

Attention: 31 lines in your changes are missing coverage. Please review.

Comparison is base (23fa496) 73.69% compared to head (a5c7e00) 73.63%.

Files Patch % Lines
dissect/target/helpers/cyber.py 16.12% 26 Missing ⚠️
dissect/target/loaders/cyber.py 28.57% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #533      +/-   ##
==========================================
- Coverage   73.69%   73.63%   -0.07%     
==========================================
  Files         277      277              
  Lines       23058    23080      +22     
==========================================
+ Hits        16992    16994       +2     
- Misses       6066     6086      +20     
Flag Coverage Δ
unittests 73.63% <18.42%> (-0.07%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines 133 to 144
if char != " ":
is_indent = False

if (
("\n" in char or "\r\n" in char)
or (not mask_space and char == " ")
or (not mask_indent and is_indent)
):
if "\n" in char:
is_indent = True
sys.__stdout__.write(char)
continue
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe an idea to add a custom generator function that already pre-checks char for these values? Then you won't have the same code eveywhere

Copy link
Member Author

Choose a reason for hiding this comment

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

Feel free to make a suggestion.

Copy link
Contributor

Choose a reason for hiding this comment

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

Something like this maybe?

def some_good_name_for_a_generator(character_map: Iterator, mask_space, mask_indent) -> Iterator:

    is_indent = True
    for char, *remainder in character_map:
        if char != " ":
             is_indent = False
        if (
            ("\n" in char or "\r\n" in char)
            or (not mask_space and char == " ")
            or (not mask_indent and is_indent)
        ):
            if "\n" in char:
                is_indent = True
            yield True, char, *remainder
        else:
            yield False, char, *remainder

...

    for send_white_space, char, has_ansi, *others in some_good_name_for_a_generator(...):
        if send_white_space:
            sys.__stdout__.write(char)
            continue


if (
("\n" in char or "\r\n" in char)
or (not mask_space and char == " ")
Copy link
Contributor

Choose a reason for hiding this comment

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

It won't mask the indentation, as mask_space will tell it to print the space instead.

Copy link
Member Author

Choose a reason for hiding this comment

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

Works as intended for me.

Copy link
Contributor

Choose a reason for hiding this comment

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

Really? As I find the following to be looking a bit odd
Screenshot from 2024-02-12 14-30-04

I expected the masking behavior to occur for the indentation

Copy link
Member Author

Choose a reason for hiding this comment

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

Should be fixed now.

@Schamper Schamper requested a review from Miauwkeru February 12, 2024 15:19
@Schamper Schamper merged commit e8419be into main Feb 12, 2024
14 of 16 checks passed
@Schamper Schamper deleted the cyber-alignment branch February 12, 2024 17:30
Poeloe pushed a commit that referenced this pull request Feb 29, 2024
Zawadidone pushed a commit to Zawadidone/dissect.target that referenced this pull request Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants