Skip to content

Instantly share code, notes, and snippets.

@copyleftdev
Last active March 9, 2016 20:08
Show Gist options
  • Save copyleftdev/53afd696368dd3c1c20f to your computer and use it in GitHub Desktop.
Save copyleftdev/53afd696368dd3c1c20f to your computer and use it in GitHub Desktop.
seedv2
#!/usr/bin/env/python
import os
import random
import shutil
from faker import Factory
fake = Factory.create()
"""
PII Seeding Utility
"""
def copy_docs(src, dest):
"""copy_docs from src to dest"""
try:
shutil.copytree(src, dest)
except:
print "Unable to copy files."
def random_seek_insert(target_file, seed_data):
"""randomly seek and insert data into a file"""
size_of_file = os.path.getsize(target_file)
randpos = random.randint(0, size_of_file)
with open(target_file, 'w+') as seekfn:
seekfn.seek(randpos)
seekfn.write(seed_data)
def get_file_list(root_folder, randomize=False):
"""recursive function to get a lists of files from a target folder with a
passing a boolean True = radomize the list False = return full list"""
file_list = []
for(dirpath, _, files) in os.walk(root_folder):
for filename in files:
file_list.append(os.path.join(dirpath, filename))
if randomize is False:
return file_list
elif randomize is True:
return random.sample(file_list)
def seed_cc_pii(root_folder):
"""seed document with credit card information"""
# TODO: create a function to inject cc information from major providers.
pass
def seed_ssn_pii(root_folder):
"""seed a document with ssn information"""
# TODO: create a function to inject ssn information into a file
pass
def seed_phone_number(root_folder):
"""seed a document with phone numbers"""
# TODO: create a function to inject phone number information into a file
pass
def seed_trade_pii(root_folder, keywords):
"""seed a document with series of keywords"""
# TODO: create a function to inject ssn information into a file
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment