def show(filename): """Show track FILENAME as PNG file. FILENAME is a text file following the track file's conventions. """ track = Track.read(filename) track.show()
def savemd(filename, filename_md, name, description): """Save track FILENAME as MD file.""" track = Track.read(filename, name) p = Path(filename) if filename_md == '': filename_md = p.with_suffix('.md') track.save_md(filename_md, description)
def delrow(filename, row): """Delete row ROW from track FILENAME. ROW is the number of the row to delete. """ track = Track.read(filename) track.del_row(row) track.save_txt(filename)
def delcol(filename, col): """Delete column COL from track FILENAME. COL is the number of the column to delete. """ track = Track.read(filename) track.del_col(col) track.save_txt(filename)
def savepng(filename, filename_png, show): """Save track FILENAME as PNG file.""" track = Track.read(filename) p = Path(filename) if filename_png == '': filename_png = p.with_suffix('.png') track.save_img(filename_png) if show: track.show()
""" Example 2: Importation of a track and exportation to PNG and MD """ from line_track_designer.track import Track if __name__ == "__main__": # Import the track saved in a text file track = Track.read('track_colors/track_colors.txt', 'Colors track') # Export the track as png and markdown files track.save_md('track_colors/track_colors.md', 'A track with colors')
""" Example 3: Importation, exportation and show a track """ from line_track_designer.track import Track if __name__ == "__main__": # Import the track saved in a text file track = Track.read('track_cool_guy/track_cool_guy.txt', 'Cool guy track') # Export the track as png and markdown files track.save_md('track_cool_guy/track_cool_guy.md', 'It looks like a face...') # Show the track track.show()
def addrow(filename): """Add a row to track FILENAME.""" track = Track.read(filename) track.add_row() track.save_txt(filename)
def addcol(filename): """Add a column to track FILENAME.""" track = Track.read(filename) track.add_col() track.save_txt(filename)
def write(filename): """Write track FILENAME in the command prompt.""" track = Track.read(filename) click.echo(track) logging.info('Track writed')
def printing(filename): """Print track FILENAME.""" if click.confirm('Do you want to print the track?'): track = Track.read(filename) track.print_track()
def rotate(filename, n): """Rotate track FILENAME.""" track = Track.read(filename) track.rotate(n) track.save_txt(filename)
""" Example 4: Edition functions """ from line_track_designer.track import Track if __name__ == "__main__": # Import the track saved in a text file track = Track.read('track_hard/track_hard.txt', 'Hard track') # Export the track as png and markdown files track.save_md('track_hard/track_hard.md', 'A very hard track') # Delete a row track.del_row(1) # Rotate the track track.rotate() # Show the track track.show()
def track(): return Track.read(os.path.join(path, 'track.txt'))
def track_hard(): return Track.read(os.path.join(path, 'track_hard.txt'))