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

booger plug that adapts as-is strfry write policy plugins for use with booger #4

Open
huumn opened this issue Jun 19, 2023 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@huumn
Copy link
Member

huumn commented Jun 19, 2023

There might folks using strfry write policy plugins that they'd like to continue using with booger.

We can support this with a booger plug that allows strfry policies to be dropped in a folder and used with booger.

@huumn huumn added enhancement New feature or request good first issue Good for newcomers labels Jun 19, 2023
@meuamigopedro
Copy link

import os

class BoogerPlugin:
    def __init__(self, policy_folder):
        self.policy_folder = policy_folder

    def apply_strfry_policies(self):
        # Get a list of files in the policy folder
        policy_files = [f for f in os.listdir(self.policy_folder) if os.path.isfile(os.path.join(self.policy_folder, f))]

        # Apply each strfry policy
        for policy_file in policy_files:
            policy_path = os.path.join(self.policy_folder, policy_file)
            strfry_policy = self.load_strfry_policy(policy_path)
            self.apply_policy(strfry_policy)

    def load_strfry_policy(self, policy_path):
        # Load strfry policy from the given file path
        # Implement logic to parse the policy file and return the policy object
        pass

    def apply_policy(self, strfry_policy):
        # Apply the strfry policy
        # Implement logic to integrate strfry policy with booger
        pass

# Example usage
booger_plugin = BoogerPlugin(policy_folder='/path/to/strfry_policies')
booger_plugin.apply_strfry_policies()

Implementation Description:

This Python code defines a BoogerPlugin class responsible for handling the integration of strfry write policies with the booger system. Here's a breakdown of the implementation:

  1. Initialization (__init__):

    • The class is initialized with the path to the folder containing strfry write policies.
  2. Applying Strfry Policies (apply_strfry_policies):

    • Retrieves a list of policy files from the specified folder.
    • Iterates through each policy file, loads the strfry policy, and applies it.
  3. Loading Strfry Policy (load_strfry_policy):

    • Placeholder method to load a strfry policy from a given file path.
    • You should implement logic to parse the policy file and return the policy object.
  4. Applying Policy (apply_policy):

    • Placeholder method to apply a strfry policy.
    • Implement logic to integrate the strfry policy with the booger system.
  5. Example Usage:

    • Creates an instance of BoogerPlugin with the path to the folder containing strfry policies.
    • Applies strfry policies using the apply_strfry_policies method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants