def create_data_base(self): el.echo('Creating database...') # database folder path cwd = os.path.join(self.fullpath, '_database') # creating database folder os.mkdir(cwd) ## CREATE MAIN.CONFIG FILE # create config file in the show root directory main_config_path = os.path.join(self.fullpath, 'main.config') os.system(f'touch {main_config_path}') # # dump the base data to config file data = {"base_show_path": self.fullpath} dump_yaml(main_config_path, data) ## CREATE SHOWS.JSON FILE show_json_path = os.path.join(self.fullpath, 'Shows.json') os.system(f'touch {show_json_path}') # empty data data_json = {"shows": []} dump_json(show_json_path, data_json)
def create_seq(cls, seq_name): # READ SHOTS DATA shots_level_file = os.path.join(os.getcwd(), 'shots', 'shots.lvl') data = read_json(shots_level_file) BASE_SEQ = 400 if len(data['all_seq']) == 0: if seq_name: seq_num = str(BASE_SEQ) + '_' + seq_name else: seq_num = str(BASE_SEQ) seq_num_only = seq_num[:3] data['all_seq'].append(str(seq_num_only)) else: last_seq_number = data['all_seq'][-1][:3] seq_num = int(last_seq_number) + 1 if seq_name: seq_num = str(seq_num) + "_" + seq_name # Strip the name seq_num = str(seq_num) seq_num_only = seq_num[:3] data['all_seq'].append(str(seq_num_only)) seq_path = os.path.join(os.getcwd(), 'shots', str(seq_num)) # Create directories os.mkdir(seq_path) created_on = strftime("%d %b %Y", gmtime()) # create shot json file seq_data = {"sequence": seq_num, "created-on": created_on, "shots": []} data['shots']['sequences'].append(seq_data) seq_level_file = os.path.join(seq_path, 'seq.lvl') dump_json(seq_level_file, seq_data) dump_json(shots_level_file, data=data) ## MESSAGE el.echo("New Sequence Created") el.echo(f"{seq_num}")
def initialize_dir(self): # check if any other shows has been configured config_data = read_yaml(CONFIG_FILE_PATH) try: if config_data['base_show_path']: el.echo( 'You cannot Initialize a new "Shows" when a "Shows" directory already exists', lvl="ERROR") msg = f''' Current running "Shows" directory: {config_data['base_show_path']} Go the to current runnig "Show" by using the command 'el goshow' ''' el.echo(msg=msg) self.output = False except: # check if the show directory already exists if not os.path.isdir(self.fullpath): os.mkdir(self.fullpath) self.output = True else: el.echo('Main Show directory already exists.') self.output = False return self.output
def check_cwd(path): # read main.config file try: config_read = read_yaml(os.path.join(path,"main.config")) if config_read['base_show_path'] == path: return True else: el.echo("You cannot create a new show unless your in the root directory","WARNING:") el.echo("Use `el goshow` command to move to the root directory.") return False except: el.echo("You cannot create a new show unless your in the root directory","WARNING:") el.echo("Use `el goshow` command to move to the root directory.") return False
def goshow(cls, showname): data = cls.goshow_data() # check if the show exists shows = [] for j_showname in data['shows']: shows.append(j_showname['name']) if showname in shows: el.echo(f"Moving to show '{showname}'") el.echo('Currently under show level') show_path = os.path.join(cls.show_base_path, showname) el.cwd(show_path) else: el.echo(f"Show by the name '{showname}' does not exists.")
def go_asset(cls,cat, asset_name): path = os.path.join(os.getcwd(),'asset_build', cat, asset_name) if os.path.isdir(path): el.cwd(path) else: el.echo("The asset doesn't exsits under this category.",lvl="ERROR")