{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": true }, "outputs": [], "source": [ "import os\n", "from collections import namedtuple" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Set the Lecture Variables" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": true }, "outputs": [], "source": [ "Slide_show_name = \"Materials\"\n", "Week_number = 0\n", "number_of_slides = 8 # Only used without templates" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Base Create Audio File Path" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [], "source": [ "title = Slide_show_name.replace(\" \",\"%20\")\n", "base_audio_path = (\"https://github.com/damontallen/Construction-materials/raw/master/Lecture_Audio\"\n", " \"/Week_%d\"\n", " \"/%s/%s-Slide_Title.mp3\"%(Week_number,title,title))\n", "# By using the lecture title as part of the file name it is far less likely that audio files\n", "# will be overwritten by files for other lectures." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Slide Templates" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": true }, "outputs": [], "source": [ "s_temp = namedtuple(\"SlideTemplate\",\"topic content_stub subslide_count\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Basic Materials" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": true }, "outputs": [], "source": [ "basic_slide_topics = [s_temp(\"Sustainability\",\"In order to make ____ sustainability \",None),\n", " s_temp(\"Toxicity and the Environment\",\"____ is toxic to \",None),\n", " s_temp(\"Recycling\",\"____ can be recycled if \",None),\n", " s_temp(\"Reuse\",\"It is better if ____ can be reused in applications like \",None),\n", " s_temp(\"Material Properties\",None,None),\n", " s_temp(\"Strength\",None,None),\n", " s_temp(\"Structural Failure Modes\",\"____ will fail if it is subjected to \",None),\n", " s_temp(\"Environment Induced Failure Modes\",\"____ can be damaged by repeated exposure to \",\n", " None),\n", " s_temp(\"Chemical Weaknesses\",(\"X is one of the compounds that you must \"\n", " \"avoide having ____ exposed to. It \"),None),\n", " s_temp(\"Safe Operating Temperatures\",(\"____ should only be used in the following \"\n", " \"temperature ranges.\"),None),\n", " s_temp(\"Material Tests\",\"The main material tests that are relevant to ____ are \",None),\n", " s_temp(\"Quality Levels\",\"____ can be found in the following grades.\",None),\n", " s_temp(\"Residential Applications\",\"____ is used in residential arena as \",None),\n", " s_temp(\"Commercial Applications\",\"____ is used in commercial buildings as \",None),\n", " s_temp(\"Industrial Applications\",\"____ is used in the industrial setting as \",None),\n", " s_temp(\"Cost Examples\",\"____ is generally sold as (by the)\",None),\n", " s_temp(\"Material Sources\",\"Depending on the quanity you can purchase ____ from \",None),\n", " s_temp(\"Examples of Installation Tools\",(\"Though you are unlikely to be installing \"\n", " \"any ____ personally, if you did, you are \"\n", " \"likely to need \"),None),\n", " s_temp(\"Famous Failures\",\"One of the more famous instances of a failure of ____\",None),]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Assembled Systems" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": true }, "outputs": [], "source": [ "assembeled_slide_topics = [\"\"]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Special Lectures" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "collapsed": true }, "outputs": [], "source": [ "sustainability_topics = [s_temp(\"Environmental Product Declarations (EPDs)\",None,None),\n", " s_temp(\"Lifecycle Cost\",None,None),\n", " s_temp(\"Carbon Footprint Index (CFI)\",None,None),\n", " s_temp(\"Volatile Organic Compound (VOC)\",None,None),\n", " s_temp(\"LEED\",None,None),\n", " s_temp(\"Cradle to Gate (CTG)\",None,None),\n", " s_temp(\"Sumary\",None,None),]\n", "\n", "materials_topics = [s_temp(\"Introduction\",None,None),\n", " s_temp(\"Material Properties\",None,None),\n", " s_temp(\"Young's Modulus\",None,None),\n", " s_temp(\"Plastic Behavior\",None,None),\n", " s_temp(\"Ultimate Strength\",None,None),\n", " s_temp(\"Energy Absorption - Toughness\",None,None),\n", " s_temp(\"Fracture Point\",None,None),\n", " s_temp(\"Repture\",None,None),\n", " s_temp(\"Shear Failure\",None,None),\n", " s_temp(\"Deformations\",None,None),\n", " s_temp(\"Buckling\",None,None),\n", " s_temp(\"Connections\",None,None),\n", " s_temp(\"Summary\",None,None),]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Pick Slide Template" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "collapsed": true }, "outputs": [], "source": [ "# slide_template = None\n", "#slide_template = basic_slide_topics\n", "#slide_template = assembeled_slide_topics\n", "#slide_template = sustainability_topics\n", "slide_template = materials_topics" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Generate Table of Content" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "collapsed": false }, "outputs": [], "source": [ "if slide_template == None:\n", " content = [r'\"* [%s](#)\\n\"'%Slide_show_name]\n", " content += [r'\" * [Slide %d Title](#/%d)\\n\"'%(i-1, i) for i in range(2,number_of_slides+3)]\n", " content += [r'\" * [References](#/%d)\\n\"'%(number_of_slides+3)]\n", "else:\n", " content = [r'\"* [%s](#)\\n\"'%Slide_show_name]\n", " content += [r'\" * [%s](#/%d)\\n\"'%(s.topic, i+3) for i, s in enumerate(slide_template)]\n", " content += [r'\" * [References](#/%d)\\n\"'%(len(slide_template)+3)]\n", "table_of_content = \",\\n \".join(content)\n", "\n", "table_default = r'''\"* [Lecture Title](#)\\n\",\n", " \" * [Slide Title](#/2)\\n\",\n", " \" * [Sub-Slide Title](#/2/1)\\n\",\n", " \" * [References](#/4)\\n\"'''\n", "\n", "# print(table_of_content)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Set Program Paths" ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "collapsed": true }, "outputs": [], "source": [ "path = \"./Slideshow_source/\"\n", "header = path+\"Blank Lecture Header.txt\"\n", "table = path+\"Table of Contents.txt\"\n", "slide = path+\"Blank Lecture Main Slides.txt\"\n", "subslide = path+\"Blank Lecture Sub Slides.txt\"\n", "footer = path+\"Blank Lecture Footer.txt\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Load Slide-show Templates and Build Lecture" ] }, { "cell_type": "code", "execution_count": 11, "metadata": { "collapsed": false }, "outputs": [], "source": [ "original_title = \"Lecture Title\"\n", "with open(header, 'r') as f:\n", " txt = f.read()\n", " txt = txt.replace(original_title, Slide_show_name)\n", "with open(table, 'r') as f:\n", " empty_table = f.read()\n", "txt+=empty_table.replace(table_default,table_of_content)\n", "with open(slide, 'r') as f:\n", " slide_txt = f.read()\n", "# Fix audio path\n", "# slide_txt = slide_txt.replace(\"Week_1\",\"Week_%d\"%Week_number)\n", "# slide_txt = slide_txt.replace(\"Lecture_Title\",Slide_show_name)\n", "slide_txt = slide_txt.replace('mp3 Path',base_audio_path)\n", "with open(subslide, 'r') as f:\n", " subslide_txt = f.read()\n", "subslide_txt = subslide_txt.replace('mp3 Path',base_audio_path)\n", "if slide_template is None:\n", " for i in range(number_of_slides):\n", " slide = slide_txt.replace(\"Slide Title\", \"Slide %d Title\"%(i+1))\n", " txt += slide\n", "else:\n", " for s in slide_template:\n", " slide = slide_txt.replace(\"Slide Title\", s.topic)\n", " if s.content_stub:\n", " slide = slide.replace(\"Slide Content\", s.content_stub)\n", " slide = slide.replace('Slide_Title',s.topic.replace(' ','%20'))\n", " slide = slide.replace('Edit Slide Audio','')\n", " txt += slide\n", " if s.subslide_count:\n", " for i in range(s.subslide_count):\n", " txt += subslide_txt\n", " \n", "with open(footer, 'r') as f:\n", " txt += f.read()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Make Lecture Audio Entry" ] }, { "cell_type": "code", "execution_count": 12, "metadata": { "collapsed": false }, "outputs": [], "source": [ "d = \"./Lecture_Audio/Week_%d/%s\"%(Week_number,Slide_show_name)\n", "if not os.path.exists(d):\n", " os.makedirs(d)\n", "if slide_template is not None:\n", " for s in slide_template:\n", " file_path = d+'/%s-'%Slide_show_name+s.topic+'.mp3'\n", " with open(file_path,'a') as f:\n", " pass" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Make Blank Lecture" ] }, { "cell_type": "code", "execution_count": 13, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Notebook created!\n" ] } ], "source": [ "notebook = Slide_show_name+\".ipynb\"\n", "if os.path.exists(notebook):\n", " choice = input(\"Notebook already exists! Do you wish to overwrite? y[N] \")\n", " if choice == \"\":\n", " choice = 'n'\n", "else:\n", " choice = 'y'\n", "choice = choice.strip().lower()\n", "if 'y' in choice:\n", " with open(notebook,'w')as f:\n", " f.write(txt)\n", " print(\"Notebook created!\")" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.4.0" } }, "nbformat": 4, "nbformat_minor": 0 }