Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- '''
- imports user from csv in format:
- <email address>, <first name>, <last name>
- '''
- import csv
- from subprocess import call as run
- FILE='example.csv'
- def output_csv():
- ''':returns: list of lines without newline character from file'''
- return [_.replace('\n','') for _ in open(FILE, newline='')]
- def wp_command(email, first, last):
- ''':returns: wp cli command in format for subprocess.call parameters'''
- return f"wp user create \"{first}\" {email} --role=subscriber --first_name=\"{first}\" --last_name=\"{last}".split(' ')
- def main():
- '''driver code to import users from csv'''
- for row in output_csv():
- run(wp_command(*row.split(',')))
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement