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

Tried to add refinements for redefining identifiers #6

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

LyubomirT
Copy link

Summary of Changes

In this code modification, I have implemented the following features and improvements:

  • Added support for chaining multiple [ ] (definitions) to refine a previous definition in the filecabinet and notices sections of the configuration.
  • Implemented special empty [ ] to represent resetting or emptying the previous definition.
  • Enhanced the code to handle additive refinements and subtractive refinements for more flexible filtering.
  • Removed unnecessary whitespaces to improve readability.

Resolved Issues

This pull request addresses the following issues: #3

Testing

All changes made in this pull request have successfully passed local testing. The existing tests in the codebase have been executed to ensure that the new features and improvements do not introduce any regressions.

@ma-ilsi ma-ilsi requested review from ma-ilsi and removed request for ma-ilsi October 10, 2023 11:47
@ma-ilsi
Copy link
Owner

ma-ilsi commented Oct 10, 2023

Hey @LyubomirT, thank you for your contribution to Sophie! I just did a quick look through your changes. Here are general comments on the pull request:

Ready to merge:

  • Implemented special empty [ ] to represent resetting or emptying the previous definition.

This was well done, thanks! Please see the echo vs printf comment, though.

  • Removed unnecessary whitespaces to improve readability.

This was an greatly needed enhancement! I deal with a very niche editing environment so didn't realize how my text files end up looking like 😅 . I think I may need to start opening up to industry-wide accepted editors.

Needs more review:

  • Added support for chaining multiple [ ] (definitions) to refine a previous definition in the filecabinet and notices sections of the configuration.
  • Enhanced the code to handle additive refinements and subtractive refinements for more flexible filtering.

Can you please leave a comment in the GitHub code review on where Sophie can now parse a chain on a single line? It would make it much easier for me to find since the whitespace fixes have thrown off the diff.
Example:

net_code[pattern="...";][size="+1k";]

This above, is additive refinement syntax. It increases the scope of the definition to get all files matching the pattern and all files +1kb in size. Technically speaking, the definition ends up being the set of files that fall under the union of the two filters. I think I should update #3 to be clear on the syntax.

@ma-ilsi
Copy link
Owner

ma-ilsi commented Oct 10, 2023

Finally, if you only want to merge the whitespace organization and the special empty syntax for #3, then I can take that alone if the rest of #3 is not complete.

Regardless of how much you are contributing to refinements, whenever you are done, update your branch to main so I can run these workflows to see macOS conformance.

@LyubomirT
Copy link
Author

Hey @LyubomirT, thank you for your contribution to Sophie! I just did a quick look through your changes. Here are general comments on the pull request:

Ready to merge:

  • Implemented special empty [ ] to represent resetting or emptying the previous definition.

This was well done, thanks! Please see the echo vs printf comment, though.

  • Removed unnecessary whitespaces to improve readability.

This was an greatly needed enhancement! I deal with a very niche editing environment so didn't realize how my text files end up looking like 😅 . I think I may need to start opening up to industry-wide accepted editors.

Needs more review:

  • Added support for chaining multiple [ ] (definitions) to refine a previous definition in the filecabinet and notices sections of the configuration.
  • Enhanced the code to handle additive refinements and subtractive refinements for more flexible filtering.

Can you please leave a comment in the GitHub code review on where Sophie can now parse a chain on a single line? It would make it much easier for me to find since the whitespace fixes have thrown off the diff. Example:

net_code[pattern="...";][size="+1k";]

This above, is additive refinement syntax. It increases the scope of the definition to get all files matching the pattern and all files +1kb in size. Technically speaking, the definition ends up being the set of files that fall under the union of the two filters. I think I should update #3 to be clear on the syntax.

Got it, I'll start working on this update right away, thanks for the information.

@ma-ilsi ma-ilsi requested review from ma-ilsi and removed request for ma-ilsi October 10, 2023 16:16
Copy link
Author

@LyubomirT LyubomirT left a comment

Choose a reason for hiding this comment

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

I added comments ( # Handle chaining of multiple filters on a single line ) so it will be easy to find where that is done

@LyubomirT
Copy link
Author

@ma-ilsi Updated the main branch, please let me know if you have any questions or concerns.

@ma-ilsi
Copy link
Owner

ma-ilsi commented Oct 10, 2023

I have run the workflow for basic testing. Please have a look at the results in the checks.
Although macOS is labeled passing, unfortunately it is also failing (which reminds me I need to update the exit codes for Sophie).
I have local testing for macOS-10 which is also failing (I should probably hook that up as a runner to workflows.)

I know the output may seem very confusing because of the differences between each shell. But this is the process of making sure a shell script passes on all major operating systems and is POSIX compliant.

Suggestions:

  • Make sure you are using some type of debugging method (I believe bash has a script debugger built-in).
  • Try to accomplish the changes using the most widely accepted shell syntax.
  • Consider testing using a Ubuntu virtual machine.

@LyubomirT
Copy link
Author

LyubomirT commented Oct 10, 2023

I have run the workflow for basic testing. Please have a look at the results in the checks. Although macOS is labeled passing, unfortunately it is also failing (which reminds me I need to update the exit codes for Sophie). I have local testing for macOS-10 which is also failing (I should probably hook that up as a runner to workflows.)

I know the output may seem very confusing because of the differences between each shell. But this is the process of making sure a shell script passes on all major operating systems and is UNIX compliant.

Suggestions:

  • Make sure you are using some type of debugging method (I believe bash has a script debugger built-in).
  • Try to accomplish the changes using the most widely accepted shell syntax.
  • Consider testing using a Ubuntu virtual machine.

I'm truly sorry for this, I've made some dumb mistakes while updating the code. Fixing them...

EDIT: Almost done with debugging, will be pushing the update soon.

@LyubomirT
Copy link
Author

@ma-ilsi I fixed the glitches, should be working properly now.

sophie.sh Outdated

if [ "$curr_command" = "filecabinet" ]; then
# Identifier
cut_count=$(expr "$line" : '[^=]*="[^"]*"')
Copy link
Owner

Choose a reason for hiding this comment

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

Here we are supposed to match the identifier and the very first opening bracket[. But this regex is going beyond that.

Copy link
Author

Choose a reason for hiding this comment

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

😓 My bad, I'm sorry.

Changed the line to:

cut_count=$(expr "$line" : '[^[]*\[')

I hope this is what you're looking for.

Copy link
Owner

@ma-ilsi ma-ilsi Oct 15, 2023

Choose a reason for hiding this comment

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

No worries, no need to apologize! I will see how it does locally.

@ma-ilsi
Copy link
Owner

ma-ilsi commented Oct 15, 2023

@LyubomirT Thank you for your patience! I would like to get your whitespace changes merged but the refinements code is still not mature. Have a look at issue #8 with a fresh branch off of ma-ilsi/Sophie:main and let me know if you'd like to send in the whitespace fixes only.

The refinement changes might take a while to process. I would recommend getting the whitespace mentioned in #8 done separately and then opening a brand new pull for the refinements step-by-step. Try implementing just the empty special [ ] and then you can try one step higher after that. (The benefit of this approach is that I can read the diffs easier and bugs will be caught faster if each part is done step by step.)

fi

# Remove old
file_cabinet=$(printf "$file_cabinet" | awk -v id="__SOPHIE_IDENTIFIER$curr_identifier=" '!index($0, id)')
Copy link
Owner

Choose a reason for hiding this comment

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

Do you think we should add awk over sed? I think having a few rare instances of awk throws off simplicity and consistency. I was trying to stick to the most basic utils that almost every developer would know: sed, grep, cut, tr are simple to learn and enough for all the parsing needs.

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