| 137 | |
| 138 | |
| 139 | def add_presentation(path): |
| 140 | session = "" |
| 141 | while not session or session not in 'pktldo': |
| 142 | session = input("[P]resentation, [K]eynote, [T]utorial, " + |
| 143 | "[L]ighting/Lunch, [D]emo, P[o]ster? ").lower() |
| 144 | |
| 145 | SESSION_MAP = { |
| 146 | 'p': ('Presentations', 'Presentation'), |
| 147 | 'k': ('Keynotes', 'Keynote'), |
| 148 | 't': ('Tutorials', 'Tutorial'), |
| 149 | 'l': ('Lightning Talks and Lunch Sessions', |
| 150 | 'Lightning Talk and Lunch Session'), |
| 151 | 'd': ('Demos', 'Demo'), |
| 152 | 'o': ('Posters', 'Poster') |
| 153 | } |
| 154 | folder = SESSION_MAP[session][0] |
| 155 | session_type = SESSION_MAP[session][1] |
| 156 | |
| 157 | filename = split(path)[-1] |
| 158 | ext = splitext(filename)[-1] |
| 159 | title = "" |
| 160 | author = "" |
| 161 | |
| 162 | if ext == '.md': |
| 163 | readme_header_regex = re.compile(r"\*\*(.*)\*\* by \*\*(.*)\*\*") |
| 164 | |
| 165 | with open(filename, mode='rb') as readme: |
| 166 | heading = readme.readline().decode() |
| 167 | match = readme_header_regex.match(heading) |
| 168 | |
| 169 | if match: |
| 170 | title = match.group(1) |
| 171 | author = match.group(2) |
| 172 | else: |
| 173 | title_author_regex = re.compile("(.*) - (.*) - CppCon " + |
| 174 | str(CPPCON_YEAR) + r"\.[^.]*$") |
| 175 | |
| 176 | title_author_match = title_author_regex.search(filename) |
| 177 | if title_author_match: |
| 178 | title = title_author_match.group(1) |
| 179 | author = title_author_match.group(2) |
| 180 | |
| 181 | print("\nExtension is", ext) |
| 182 | |
| 183 | if not title or not author: |
| 184 | title = input("Title: ") |
| 185 | author = input("Author: ") |
| 186 | |
| 187 | ok = '' |
| 188 | while ok != 'y': |
| 189 | if ok != 'n': |
| 190 | print("\n\nTitle:", title) |
| 191 | print("Author:", author.encode().decode(sys.stdout.encoding, |
| 192 | errors='ignore')) |
| 193 | ok = input('OK? [y/n]: ').lower() |
| 194 | |
| 195 | if ok == 'n': |
| 196 | title = input("Title: ") |