Created
January 19, 2017 17:44
-
-
Save mattdeboard/d5b6aecb1d47abf49b0df2cbabd98b8e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os | |
import random | |
class Follower: | |
def __init__(self, starting_location, current_victim=None): | |
# `starting_location` is a string representing a file system path. | |
self.location = starting_location | |
self.current_victim = current_victim | |
self.victims = [] | |
if self.current_victim is not None: | |
self.victims.append(self.current_victim) | |
def kill(self): | |
self.current_victim.dead = True | |
try: | |
self.current_victim = self.victims.pop() | |
except IndexError: | |
raise IndexError("We're all out of victims!") | |
class Victim: | |
def __init__(self, starting_location): | |
# `starting_location` is a string representing a file system path. | |
self.location = starting_location | |
self.dead = False | |
def move(self): | |
"""Move to a random location in the file system.""" | |
pass | |
def infect(self): | |
return Victim(self.location) | |
def random_directory(root): | |
return random.choice(os.listdir(root)) | |
if __name__ == '__main__': | |
first_victim = Victim(random_directory('~')) | |
follower = Follower(random_directory('~'), first_victim) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment