def __init__(self, path, dir_paths, run_local=False, excluded_names=None): self.path = path self.dir_paths = dir_paths self.names = Names() self.excluded_names = set(excluded_names) if excluded_names else set( []) self.run_local = run_local self.files = [] self.name_adder = NameAdder(None, path) self.changed_files = {}
def step_through(self): current_file = self.current_files[self.current_file_index] if self.current_phase == self.phases.show_file_name: self.print_blank_line() self.print_line( 'Current File: ' + current_file, left_position=self.INDENT_SIZE, vertical_position=self.vertical_position, color=self.colors.magenta ) self.current_phase = self.phases.enter_names_for_file if self.current_phase == self.phases.enter_names_for_file: message = 'Enter names to add to ' + current_file + ' ' self.print_line( message, left_position=self.INDENT_SIZE, vertical_position=self.vertical_position, color=self.colors.cyan, increment_vertical=False ) self.left_position = self.INDENT_SIZE + len(message) self.line_x0 = self.left_position elif self.current_phase == self.phases.ask_add_name_to_file: message = 'Add ' + str(self.costars) + ' to: ' + current_file + '? ' self.print_line( message, left_position=self.INDENT_SIZE, vertical_position=self.vertical_position, increment_vertical=False, color=self.colors.cyan ) self.left_position = self.INDENT_SIZE + len(message) self.line_x0 = self.left_position elif self.current_phase == self.phases.add_name_to_file: nameAdder = NameAdder([], os.path.join(self.root_path, self.current_name)) new_name = nameAdder.rename_file(current_file, ','.join(self.costars), should_print=False) self.changed_files[current_file] = new_name self.print_moved_file(current_file, new_name) self.reset(reset_full=True) return None
def add_names(self): path = '/Users/agreen/.stage/finished/' # path = '/Volumes/Papa/.finished/' adder = NameAdder(self.args, path) adder.renameFiles() return None