Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 

Repository files navigation

File-Update-Algorithm

mkdir src touch src/file_update.py touch README.md touch .gitignore

Assign the file name to a variable

import_file = "allow_list.txt"

Use a with statement to open the file and ensure it is properly closed after the block of code

with open(import_file, 'r') as file: # The file is now open and can be accessed using the file variable ip_addresses = file.read()

Convert the string of IP addresses into a list

ip_list = ip_addresses.split('\n')

Assuming remove_list is defined elsewhere and contains IP addresses to remove

remove_list = [] # Example remove list for element in remove_list: if element in ip_list: ip_list.remove(element)

Convert the list back into a string, each IP address on a new line

ip_addresses_string = '\n'.join(ip_list)

Open the file in write mode to update it

with open(import_file, 'w') as file: file.write(ip_addresses_string)

File Update Algorithm in Python

Project Description

This project contains a Python script to update an access control list based on employee IP addresses. The script ensures that only authorized personnel can access sensitive patient records by maintaining an up-to-date allow list.

How to Use

  1. Place the allow_list.txt file in the same directory as the script.
  2. Define the remove_list variable with the IP addresses to be removed.
  3. Run the file_update.py script to update the allow list.

Script Explanation

  • Open the file that contains the allow list.
  • Read the file contents into a string.
  • Convert the string into a list.
  • Iterate through the remove list and remove IP addresses.
  • Update the file with the revised list of IP addresses.

git add . git commit -m "Initial commit with algorithm and README" git push origin main

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors