From ffa06abc4b62ad05fa625b31bfa04364f8613999 Mon Sep 17 00:00:00 2001 From: cosme12 Date: Thu, 9 Feb 2017 20:36:24 -0300 Subject: [PATCH 01/27] Fix invalid input error --- sheetmaker/sheet_wizard.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sheetmaker/sheet_wizard.py b/sheetmaker/sheet_wizard.py index bb9041f..b3063c8 100644 --- a/sheetmaker/sheet_wizard.py +++ b/sheetmaker/sheet_wizard.py @@ -65,7 +65,7 @@ def menu_language(self): elif answer == "2": self.lang_strings = language_strings.espanol else: - self.menu_language() + return(self.menu_language()) def intro(self): @@ -97,7 +97,7 @@ def main_menu(self): self.end() else: print(self.lang_strings["INVALID_INPUT_MESSAGE"]) - self.main_menu() + return(self.main_menu()) def config_sheet(self): @@ -130,7 +130,7 @@ def config_sheet(self): color = int(color) else: print(self.lang_strings["INVALID_INPUT_MESSAGE"]) - self.config_sheet() + return(self.config_sheet()) self.NewSheet = HtmlSheet(self.title, datetime.date.today()) #Creates a HtmlSheet object with title attrib self.NewSheet.create_empty_sheet() @@ -187,7 +187,7 @@ def add_block(self): self.end() else: print(self.lang_strings["INVALID_INPUT_MESSAGE"]) - self.add_block() + return(self.add_block()) def block_rows(self): @@ -203,7 +203,7 @@ def block_rows(self): column_selected = int(column_selected) else: print(self.lang_strings["INVALID_INPUT_MESSAGE"]) - self.block_rows() + return(self.block_rows()) options = { 1: "What is the title of the block?" } title = self.input_handler(options) @@ -213,7 +213,7 @@ def block_rows(self): rows_number = int(self.input_handler(options)) #Check if input is an int except: print(self.lang_strings["INVALID_INPUT_MESSAGE"]) - self.block_rows() + return(self.block_rows()) options = { 1: "What is the text of each row? (text row1. # text row2. # text row3)" } text = self.input_handler(options) From 741af72a67b8c3a33f12866ace7137baff72f972 Mon Sep 17 00:00:00 2001 From: cosme12 Date: Sat, 11 Feb 2017 16:33:37 -0300 Subject: [PATCH 02/27] Add exe download to Readme --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fd8f71b..34a54a2 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Features - Html generator - Export to pdf (WIP) -- Previewer +- Previewer (WIP) Examples @@ -28,6 +28,7 @@ Installation ------------ No installation is required. Just run `sheetmaker.py` +You can download a Windows .exe file here: [Source Code](https://github.com/cosme12/cheatsheet-maker/releases) Contribute From bac246d66db8dd8e71884a8e57458965f00108f8 Mon Sep 17 00:00:00 2001 From: cosme12 Date: Sat, 11 Feb 2017 16:34:01 -0300 Subject: [PATCH 03/27] Changed version number --- sheetmaker/constants.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sheetmaker/constants.py b/sheetmaker/constants.py index 8fb43c1..1266e85 100644 --- a/sheetmaker/constants.py +++ b/sheetmaker/constants.py @@ -1,3 +1,3 @@ """Constant file.""" -VERSION = "1.0" \ No newline at end of file +VERSION = "1.0.1" \ No newline at end of file From befc6414daf66148087709c30d9ff68d2ed21700 Mon Sep 17 00:00:00 2001 From: cosme12 Date: Sat, 11 Feb 2017 16:36:46 -0300 Subject: [PATCH 04/27] Translation system improved Fixes #13 --- sheetmaker/language_strings.py | 42 +++++++++++++++++++++++++++-- sheetmaker/sheet_wizard.py | 48 +++++++++++++++++----------------- 2 files changed, 64 insertions(+), 26 deletions(-) diff --git a/sheetmaker/language_strings.py b/sheetmaker/language_strings.py index 524b3d2..15aabc4 100644 --- a/sheetmaker/language_strings.py +++ b/sheetmaker/language_strings.py @@ -7,18 +7,56 @@ english = { "INTRO_MESSAGE" : "Welcome to CheatSheet Maker", + "MAIN_MENU_OPTIONS" : { 1: "Create sheet", + 2: "Export (NOT CODED YET)", + 3: "Help (NOT CODED YET)", + 4: "Exit", + }, "MENU_MESSAGE" : "Type the number to choose your option.", "CONFIG_SHEET_MESSAGE1" : "Building the basic layout... answer the next questions.", "CONFIG_SHEET_MESSAGE2" : "How many columns your sheet will have?", "CONFIG_SHEET_MESSAGE3" : "Which color style do you prefer?", + "CONFIG_SHEET_OPTIONS1" : { 1: "What is your sheet title? ('CheatSheet' is added automatically)" + }, + "CONFIG_SHEET_OPTIONS2" : { 1: "1 main column", + 2: "2 main columns", + 3: "3 main columns" + }, + "CONFIG_SHEET_OPTIONS3" : { 1: "Orange", + 2: "Black and white" + }, "HEADER_MESSAGE" : "Building the header... answer the next questions.", + "HEADER_OPTIONS" : { 1: "What is the author name?" + }, "FOOTER_MESSAGE" : "Building the footer... answer the next questions.", + "FOOTER_OPTIONS1" : { 1: "What is the author picture url?" + }, + "FOOTER_OPTIONS2" : { 1: "What is the author website url? (use http://)" + }, + "FOOTER_OPTIONS3" : { 1: "What is the sponsor name?" + }, + "FOOTER_OPTIONS4" : { 1: "What is the sponsor webite url? (use http://)" + }, "BLOCK_MESSAGE" : "Building the blocks... answer the next questions.", + "BLOCK_OPTIONS" : { 1: "Create text block", + 2: "Create block with rows", + 0: "Done" + }, "BLOCK_ROWS_MESSAGE1" : "Building block with rows... answer the next questions.", "BLOCK_ROWS_MESSAGE2" : "In what main column do you want to build it?", + "BLOCK_ROWS_OPTIONS1" : { 1: "What is the title of the block?" + }, + "BLOCK_ROWS_OPTIONS2" : { 1: "How many rows does it have?" + }, + "BLOCK_ROWS_OPTIONS3" : { 1: "What is the text of each row? (text row1. # text row2. # text row3)" + }, "TEXT_BLOCK_MESSAGE" : "Building text block... answer the next questions.", + "TEXT_BLOCK_EXTRA" : "main column", + "TEXT_BLOCK_OPTIONS1" : { 1: "What is the title of the block?" + }, + "TEXT_BLOCK_OPTIONS2" : { 1: "What is the text for the block (use
for new line or any html tag for formatting)" + }, "END_MESSAGE" : "Thanks for using CheatSheet Maker. Feel free to share your ideas at http://github.com/cosme12/cheasheet-maker", "EXIT_MESSAGE" : "Press any key to exit", "INVALID_INPUT_MESSAGE" : "Invalid input. Try again.", -} - +} \ No newline at end of file diff --git a/sheetmaker/sheet_wizard.py b/sheetmaker/sheet_wizard.py index b3063c8..286df1c 100644 --- a/sheetmaker/sheet_wizard.py +++ b/sheetmaker/sheet_wizard.py @@ -81,10 +81,10 @@ def intro(self): def main_menu(self): """Displays and handles all menu options""" print(self.lang_strings["MENU_MESSAGE"]) - options = { 1: "Create sheet", - 2: "Export (NOT CODED YET)", - 3: "Help (NOT CODED YET)", - 4: "Exit", + options = { 1: self.lang_strings["MAIN_MENU_OPTIONS"][1], + 2: self.lang_strings["MAIN_MENU_OPTIONS"][2], + 3: self.lang_strings["MAIN_MENU_OPTIONS"][3], + 4: self.lang_strings["MAIN_MENU_OPTIONS"][4], } answer = self.input_handler(options) if answer == "1": @@ -107,13 +107,13 @@ def config_sheet(self): """ print("##################################################################") print(self.lang_strings["CONFIG_SHEET_MESSAGE1"]) - options = { 1: "What is your sheet title? ('CheatSheet' is added automatically)" + options = { 1: self.lang_strings["CONFIG_SHEET_OPTIONS1"][1], } self.title = self.input_handler(options) print(self.lang_strings["CONFIG_SHEET_MESSAGE2"]) - options = { 1: "1 main column", - 2: "2 main columns", - 3: "3 main columns" + options = { 1: self.lang_strings["CONFIG_SHEET_OPTIONS2"][1], + 2: self.lang_strings["CONFIG_SHEET_OPTIONS2"][2], + 3: self.lang_strings["CONFIG_SHEET_OPTIONS2"][3], } columns = self.input_handler(options) if columns in ("1","2","3"): @@ -122,8 +122,8 @@ def config_sheet(self): print(self.lang_strings["INVALID_INPUT_MESSAGE"]) self.config_sheet() print(self.lang_strings["CONFIG_SHEET_MESSAGE3"]) - options = { 1: "Orange", - 2: "Black and white" + options = { 1: self.lang_strings["CONFIG_SHEET_OPTIONS3"][1], + 2: self.lang_strings["CONFIG_SHEET_OPTIONS3"][2], } color = self.input_handler(options) if color in ("1", "2"): @@ -143,7 +143,7 @@ def add_header(self): """Displays header options selector""" print("##################################################################") print(self.lang_strings["HEADER_MESSAGE"]) - options = { 1: "What is the author name?" + options = { 1: self.lang_strings["HEADER_OPTIONS"][1], } author_name = self.input_handler(options) self.NewSheet.build_header(author_name) @@ -154,16 +154,16 @@ def add_footer(self): """Displays footer options selector""" print("##################################################################") print(self.lang_strings["FOOTER_MESSAGE"]) - options = { 1: "What is the author picture url?" + options = { 1: self.lang_strings["FOOTER_OPTIONS1"][1], } author_picture = self.input_handler(options) - options = { 1: "What is the author website url? (use http://)" + options = { 1: self.lang_strings["FOOTER_OPTIONS2"][1], } author_web = self.input_handler(options) - options = { 1: "What is the sponsor name?" + options = { 1: self.lang_strings["FOOTER_OPTIONS3"][1], } sponsor_name = self.input_handler(options) - options = { 1: "What is the sponsor webite url? (use http://)" + options = { 1: self.lang_strings["FOOTER_OPTIONS4"][1], } sponsor_web = self.input_handler(options) self.NewSheet.build_footer(author_picture, author_web, sponsor_name, sponsor_web) @@ -174,9 +174,9 @@ def add_block(self): """Displays block options selector""" print("##################################################################") print(self.lang_strings["BLOCK_MESSAGE"]) - options = { 1: "Create text block", - 2: "Create block with rows", - 0: "Done" + options = { 1: self.lang_strings["BLOCK_OPTIONS"][1], + 2: self.lang_strings["BLOCK_OPTIONS"][2], + 0: self.lang_strings["BLOCK_OPTIONS"][0], } answer = self.input_handler(options) if answer == "1": @@ -204,17 +204,17 @@ def block_rows(self): else: print(self.lang_strings["INVALID_INPUT_MESSAGE"]) return(self.block_rows()) - options = { 1: "What is the title of the block?" + options = { 1: self.lang_strings["BLOCK_ROWS_OPTIONS1"][1], } title = self.input_handler(options) - options = { 1: "How many rows does it have?" + options = { 1: self.lang_strings["BLOCK_ROWS_OPTIONS2"][1], } try: rows_number = int(self.input_handler(options)) #Check if input is an int except: print(self.lang_strings["INVALID_INPUT_MESSAGE"]) return(self.block_rows()) - options = { 1: "What is the text of each row? (text row1. # text row2. # text row3)" + options = { 1: self.lang_strings["BLOCK_ROWS_OPTIONS3"][1], } text = self.input_handler(options) text = text.split("#") @@ -229,17 +229,17 @@ def block_text(self): print(self.lang_strings["BLOCK_ROWS_MESSAGE2"]) options = {} for i in range(self.columns): - options[i+1] = str(i+1) + " main column" + options[i+1] = "{0} {1}".format(str(i+1), self.lang_strings["TEXT_BLOCK_EXTRA"]) column_selected = self.input_handler(options) if column_selected in ("1", "2", "3"): column_selected = int(column_selected) else: print(self.lang_strings["INVALID_INPUT_MESSAGE"]) self.block_text() - options = { 1: "What is the title of the block?" + options = { 1: self.lang_strings["TEXT_BLOCK_OPTIONS1"][1], } title = self.input_handler(options) - options = { 1: "What is the text for the block (use
for new line or any html tag for formatting)" + options = { 1: self.lang_strings["TEXT_BLOCK_OPTIONS2"][1], } text = self.input_handler(options) self.NewSheet.build_text_block(column_selected, title, text) From 9d9b3e0c7c251d72e38c0358b88f718bc41260a9 Mon Sep 17 00:00:00 2001 From: cosme12 Date: Sat, 11 Feb 2017 16:37:12 -0300 Subject: [PATCH 05/27] Spanish translation added --- sheetmaker/language_strings.py | 56 ++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/sheetmaker/language_strings.py b/sheetmaker/language_strings.py index 15aabc4..9a236e6 100644 --- a/sheetmaker/language_strings.py +++ b/sheetmaker/language_strings.py @@ -59,4 +59,60 @@ "END_MESSAGE" : "Thanks for using CheatSheet Maker. Feel free to share your ideas at http://github.com/cosme12/cheasheet-maker", "EXIT_MESSAGE" : "Press any key to exit", "INVALID_INPUT_MESSAGE" : "Invalid input. Try again.", +} + +espanol = { + "INTRO_MESSAGE" : "Bienvenido a CheatSheet Maker", + "MAIN_MENU_OPTIONS" : { 1: "Crear hoja", + 2: "Exportar (NOT CODED YET)", + 3: "Ayuda (NOT CODED YET)", + 4: "Salir", + }, + "MENU_MESSAGE" : "Escribe el numero para elegir tu opcion", + "CONFIG_SHEET_MESSAGE1" : "Cosntruyendo la estructura basica... responde las siguientes preguntas.", + "CONFIG_SHEET_MESSAGE2" : "Cuantas columnas tiene tu hoja?", + "CONFIG_SHEET_MESSAGE3" : "Que color de estilo prefieres?", + "CONFIG_SHEET_OPTIONS1" : { 1: "Cual es el titulo de tu hoja? ('CheatSheet' se agrega automaticamente)" + }, + "CONFIG_SHEET_OPTIONS2" : { 1: "1 columna principal", + 2: "2 columnas principales", + 3: "3 columnas principales" + }, + "CONFIG_SHEET_OPTIONS3" : { 1: "Naranja", + 2: "Negro y Blanco" + }, + "HEADER_MESSAGE" : "Cosntruyendo el encabezado... contesta las siguientes preguntas.", + "HEADER_OPTIONS" : { 1: "Cual es el nombre del autor?" + }, + "FOOTER_MESSAGE" : "Construyendo el pie de pagina... contesta las siguientes preguntas.", + "FOOTER_OPTIONS1" : { 1: "Cual es la url de la imagen del autor?" + }, + "FOOTER_OPTIONS2" : { 1: "Cual es la url del sitio web del autor? (use http://)" + }, + "FOOTER_OPTIONS3" : { 1: "Cual es el nombre del sponsor?" + }, + "FOOTER_OPTIONS4" : { 1: "Cual es la url del sitio web del sponsor? (use http://)" + }, + "BLOCK_MESSAGE" : "Construyendo los bloques... contesta las siguientes preguntas.", + "BLOCK_OPTIONS" : { 1: "Crear bloque de texto", + 2: "Crear bloque con filas", + 0: "Fin" + }, + "BLOCK_ROWS_MESSAGE1" : "Construyendo bloque con filas... contesta las siguientes preguntas.", + "BLOCK_ROWS_MESSAGE2" : "En que columna principal quieres construilo?", + "BLOCK_ROWS_OPTIONS1" : { 1: "Cual es el titulo del bloque?" + }, + "BLOCK_ROWS_OPTIONS2" : { 1: "Cuantas filas tiene?" + }, + "BLOCK_ROWS_OPTIONS3" : { 1: "Cual es el texto de cada fila? (texto fila1. # texto fila2. # texto fila3.)" + }, + "TEXT_BLOCK_MESSAGE" : "Construyendo bloque de texto... contesta las siguientes preguntas.", + "TEXT_BLOCK_EXTRA" : "columna principal", + "TEXT_BLOCK_OPTIONS1" : { 1: "Cual es el titulo del bloque?" + }, + "TEXT_BLOCK_OPTIONS2" : { 1: "Cual es el texto para el bloque? (usa
para nueva linea o cualquier html tag para dar formato)" + }, + "END_MESSAGE" : "Gracias por utilizar CheatSheet Maker. Comparte tus ideas en http://github.com/cosme12/cheasheet-maker", + "EXIT_MESSAGE" : "Presiona cualquier tecla para salir", + "INVALID_INPUT_MESSAGE" : "Entrada invalida. Pruba otra vez.", } \ No newline at end of file From 5ed0129e71ec532601458763775d20099ef7af5c Mon Sep 17 00:00:00 2001 From: cosme12 Date: Sat, 11 Feb 2017 16:43:06 -0300 Subject: [PATCH 06/27] Fix bug when row block divisor is lower than expected --- sheetmaker/sheet_wizard.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sheetmaker/sheet_wizard.py b/sheetmaker/sheet_wizard.py index 286df1c..28edcd7 100644 --- a/sheetmaker/sheet_wizard.py +++ b/sheetmaker/sheet_wizard.py @@ -217,6 +217,9 @@ def block_rows(self): options = { 1: self.lang_strings["BLOCK_ROWS_OPTIONS3"][1], } text = self.input_handler(options) + if text.count("#") < rows_number - 1: #Deny lower rows text divisor + print(self.lang_strings["INVALID_INPUT_MESSAGE"]) + return(self.block_rows()) text = text.split("#") self.NewSheet.build_rows_block(column_selected, title, rows_number, text) self.add_block() From 8767efaf155024523d284e4e8de678377de66e04 Mon Sep 17 00:00:00 2001 From: cosme12 Date: Sat, 11 Feb 2017 16:52:45 -0300 Subject: [PATCH 07/27] Clean readme file --- README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 34a54a2..dd63e46 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ CheatSheet Maker Cheatsheet (or quick reference) generator. Use it to create guides, instructions or study. Made in Python 3. -Work in progress. Just learning how to code, don't expect much from this project. Help is always welcomed. +Work in progress. Just learning how to code properly in Python, and how to deal with a project . Help is always welcomed. Features @@ -19,7 +19,6 @@ Examples Check [/sheetmaker/example](/sheetmaker/example) for an example of what you can do with CheatSheet Maker. -relative ![alt tag](https://raw.githubusercontent.com/cosme12/cheatsheet-maker/develop/sheetmaker/example/example.png) @@ -27,8 +26,8 @@ relative Installation ------------ -No installation is required. Just run `sheetmaker.py` -You can download a Windows .exe file here: [Source Code](https://github.com/cosme12/cheatsheet-maker/releases) +- No installation is required. Just run `sheetmaker.py` +- You can download the last Windows .exe file here: [Windows release](https://github.com/cosme12/cheatsheet-maker/releases) Contribute From c400b44cdbd658785e9127d117ca7dff3d5e4c3c Mon Sep 17 00:00:00 2001 From: cosme12 Date: Sat, 11 Feb 2017 23:57:27 -0300 Subject: [PATCH 08/27] Add more color styles Fixes #6 --- sheetmaker/html_builder.py | 12 ++++++++++-- sheetmaker/language_strings.py | 12 ++++++++++-- sheetmaker/sheet_wizard.py | 6 +++++- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/sheetmaker/html_builder.py b/sheetmaker/html_builder.py index 87e6136..ec8167f 100644 --- a/sheetmaker/html_builder.py +++ b/sheetmaker/html_builder.py @@ -72,11 +72,19 @@ def set_style(self, color_number): """ self.color = color_number - color_main = {1: "#fa6900", #main color - 2: "#000000", + color_main = {1: "#fa6900", #main color - orange + 2: "#000000", #black + 3: "#b60205", #red + 4: "#fbca04", #yellow + 5: "#0e8a16", #green + 6: "#1d76db", #blue } color_secundary = {1: "#fee5d3", #secundary color, lighter than main color 2: "#cccccc", + 3: "#e99695", + 4: "#fef2c0", + 5: "#c2e0c6", + 6: "#bfd4f2", } html = """ body {{ diff --git a/sheetmaker/language_strings.py b/sheetmaker/language_strings.py index 9a236e6..56e136e 100644 --- a/sheetmaker/language_strings.py +++ b/sheetmaker/language_strings.py @@ -23,7 +23,11 @@ 3: "3 main columns" }, "CONFIG_SHEET_OPTIONS3" : { 1: "Orange", - 2: "Black and white" + 2: "Black and white", + 3: "Red", + 4: "Yellow", + 5: "Green", + 6: "Blue", }, "HEADER_MESSAGE" : "Building the header... answer the next questions.", "HEADER_OPTIONS" : { 1: "What is the author name?" @@ -79,7 +83,11 @@ 3: "3 columnas principales" }, "CONFIG_SHEET_OPTIONS3" : { 1: "Naranja", - 2: "Negro y Blanco" + 2: "Negro y Blanco", + 3: "Rojo", + 4: "Amarillo", + 5: "Verde", + 6: "Azul", }, "HEADER_MESSAGE" : "Cosntruyendo el encabezado... contesta las siguientes preguntas.", "HEADER_OPTIONS" : { 1: "Cual es el nombre del autor?" diff --git a/sheetmaker/sheet_wizard.py b/sheetmaker/sheet_wizard.py index 28edcd7..f58f81a 100644 --- a/sheetmaker/sheet_wizard.py +++ b/sheetmaker/sheet_wizard.py @@ -124,9 +124,13 @@ def config_sheet(self): print(self.lang_strings["CONFIG_SHEET_MESSAGE3"]) options = { 1: self.lang_strings["CONFIG_SHEET_OPTIONS3"][1], 2: self.lang_strings["CONFIG_SHEET_OPTIONS3"][2], + 3: self.lang_strings["CONFIG_SHEET_OPTIONS3"][3], + 4: self.lang_strings["CONFIG_SHEET_OPTIONS3"][4], + 5: self.lang_strings["CONFIG_SHEET_OPTIONS3"][5], + 6: self.lang_strings["CONFIG_SHEET_OPTIONS3"][6], } color = self.input_handler(options) - if color in ("1", "2"): + if color in ("1", "2", "3", "4", "5", "6"): color = int(color) else: print(self.lang_strings["INVALID_INPUT_MESSAGE"]) From 06746c23a651e00d2585809c7741d17fd227f871 Mon Sep 17 00:00:00 2001 From: cosme12 Date: Sun, 12 Feb 2017 10:32:44 -0300 Subject: [PATCH 09/27] Clean import idiomatic --- sheetmaker/sheet_wizard.py | 4 ++-- sheetmaker/sheetmaker.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sheetmaker/sheet_wizard.py b/sheetmaker/sheet_wizard.py index f58f81a..b27dd31 100644 --- a/sheetmaker/sheet_wizard.py +++ b/sheetmaker/sheet_wizard.py @@ -6,7 +6,7 @@ """ import datetime -from html_builder import HtmlSheet +import html_builder import language_strings @@ -136,7 +136,7 @@ def config_sheet(self): print(self.lang_strings["INVALID_INPUT_MESSAGE"]) return(self.config_sheet()) - self.NewSheet = HtmlSheet(self.title, datetime.date.today()) #Creates a HtmlSheet object with title attrib + self.NewSheet = html_builder.HtmlSheet(self.title, datetime.date.today()) #Creates a HtmlSheet object with title attrib self.NewSheet.create_empty_sheet() self.NewSheet.set_style(color) self.NewSheet.build_columns(self.columns) diff --git a/sheetmaker/sheetmaker.py b/sheetmaker/sheetmaker.py index 72ecb0e..ea92be3 100644 --- a/sheetmaker/sheetmaker.py +++ b/sheetmaker/sheetmaker.py @@ -12,12 +12,12 @@ import sys import constants -from sheet_wizard import SheetWizard +import sheet_wizard def main(): """Main entry point for the script.""" - new_wizard = SheetWizard(constants.VERSION) + new_wizard = sheet_wizard.SheetWizard(constants.VERSION) new_wizard.menu_language() new_wizard.intro() new_wizard.main_menu() From d459814569c251157e7f2048d0377de0d43a42f6 Mon Sep 17 00:00:00 2001 From: cosme12 Date: Sun, 12 Feb 2017 13:05:06 -0300 Subject: [PATCH 10/27] Reorganize methods --- sheetmaker/html_builder.py | 44 ++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/sheetmaker/html_builder.py b/sheetmaker/html_builder.py index ec8167f..c590fd9 100644 --- a/sheetmaker/html_builder.py +++ b/sheetmaker/html_builder.py @@ -181,6 +181,26 @@ def set_style(self, color_number): self.update_html_file(html, "") + def build_columns(self, columns_number): + """Creates main_columns html + + Args: + columns_number (int): Main columns for the html file (1,2 or 3 only allowed). + + """ + self.columns_number = columns_number + if self.columns_number == 1: + html = """ """ + elif self.columns_number == 2: + html = """ + """ + elif self.columns_number == 3: + html = """ + + """ + self.update_html_file(html, "") + + def build_header(self, author_name): """Creates html header. @@ -232,29 +252,7 @@ def build_footer(self, author_picture, author_web, sponsor_name, sponsor_web): """.format(self.author_picture, self.author_name, self.author_web, self.date, self.sponsor_name, self.sponsor_web) self.update_html_file(html, "") - - def build_columns(self, columns_number): - """Creates main_columns html - - Args: - columns_number (int): Main columns for the html file (1,2 or 3 only allowed). - - """ - self.columns_number = columns_number - if self.columns_number == 1: - html = """ """ - elif self.columns_number == 2: - html = """ - """ - elif self.columns_number == 3: - html = """ - - """ - else: - #error - pass - self.update_html_file(html, "") - + def build_rows_block(self, selected_column, title, rows_number, text): """Creates a html rows block. From 4e3005c76172c3080661eb17b4b964fa20a27fd5 Mon Sep 17 00:00:00 2001 From: cosme12 Date: Sun, 12 Feb 2017 14:19:18 -0300 Subject: [PATCH 11/27] Improve code organization Fixes #12 --- sheetmaker/constants.py | 188 +++++++++++++++++++++++++++++++++- sheetmaker/html_builder.py | 205 +++++-------------------------------- sheetmaker/sheet_wizard.py | 23 +++-- sheetmaker/sheetmaker.py | 5 +- 4 files changed, 228 insertions(+), 193 deletions(-) diff --git a/sheetmaker/constants.py b/sheetmaker/constants.py index 1266e85..da24add 100644 --- a/sheetmaker/constants.py +++ b/sheetmaker/constants.py @@ -1,3 +1,187 @@ -"""Constant file.""" +"""Html Constant file.""" + +EMPTY_SHEET = """ + + + {0} + + + +
+
+
+ +
+ + + + +
+ +
+
+ +""" + + +COLOR_STYLE = """ + body {{ + background: #dddfdd none repeat scroll 0 0; + color: #46473b; + font-family: "Lucida Grande","Lucida Sans Unicode",Arial,Helvetica,sans-serif; + font-size: 80%; + line-height: 1.7; + margin: 0; + padding: 0; + text-align: center; + }} + #content {{ + background: white none repeat scroll 0 0; + margin: 0 auto; + padding: 0; + position: relative; + text-align: left; + width: 980px; + }} + #body_inner {{ + padding: 20px; + }} + .main_title_block {{ + display: inline-flex; + margin-bottom: 4%; + }} + .main_logo{{ + background-color: #000000; + border-top: 10px solid {1}; + padding: 10px 20px; + //width: 50%; + }} + .main_title {{ + padding-left: 4%; + width: 100%; + }} + .block {{ + background: {0} none repeat scroll 0 0; + border-bottom: 3px solid {0}; + border-radius: 3px; + margin-bottom: 12px; + padding-bottom: 0; + }} + .block_title {{ + //color: #fee5d3; + color: #ffffff; + margin: 0; + padding: 6px 8px; + text-align: left; + }} + i {{ + vertical-align: sub + }} + .block_text{{ + padding: 5px 10px; + background: {1} none repeat scroll 0 0; + }} + .rows_table {{ + background: white none repeat scroll 0 0; + border-collapse: collapse; + margin: 0; + padding: 0; + page-break-inside: avoid; + width: 100%; + }} + .row_even td{{ + background: {1} none repeat scroll 0 0; + padding: 5px 10px; + }} + .row_odd td {{ + padding: 5px 10px; + }} + .block_footer {{ + margin-top: 10%; + border-top: solid 3px #ccc; + display: inline-flex; + width: 100% + }} + .block_footer_inner {{ + display: inline-flex; + margin-bottom: 4%; + margin-left: 4%; + }} + .image_footer {{ + width: 64px; + height: 64px; + margin-top: 10px; + }} + .text_footer{{ + margin-top: 16px; + margin-left: 10px; + }}""" + + +COLUMNS1 = """ """ +COLUMNS2 = """ + """ +COLUMNS3 = """ + + """ + + +HEADER = """ + + +

{0} CheatSheet

by {1} via CheatSheet Maker
""" + + +FOOTER = """ + + + + """ + + +ROWS_BLOCK_EVEN = """ + +
{0}
+ + """ +ROWS_BLOCK_ODD = """ + +
{0}
+ + """ +ROWS_BLOCK = """
+

{0}

+ + + {1} + +
+
""" + + +TEXT_BLOCK = """
+

{0}

+
{1}
+
""" + -VERSION = "1.0.1" \ No newline at end of file diff --git a/sheetmaker/html_builder.py b/sheetmaker/html_builder.py index c590fd9..9753b7f 100644 --- a/sheetmaker/html_builder.py +++ b/sheetmaker/html_builder.py @@ -6,6 +6,8 @@ * """ +import constants + class HtmlSheet(object): """The html sheet to be created and customized.""" @@ -35,33 +37,8 @@ def __init__(self, title, date): def create_empty_sheet(self): """Create a basic html file and a files folder that will be used to make the sheet.""" - html = """ - - - {0} - - - -
-
-
- -
- - - - -
- -
-
- -""".format(self.title) - self.update_html_file(html) + html = constants.EMPTY_SHEET.format(self.title) + return(html, None) def set_style(self, color_number): @@ -86,99 +63,8 @@ def set_style(self, color_number): 5: "#c2e0c6", 6: "#bfd4f2", } - html = """ - body {{ - background: #dddfdd none repeat scroll 0 0; - color: #46473b; - font-family: "Lucida Grande","Lucida Sans Unicode",Arial,Helvetica,sans-serif; - font-size: 80%; - line-height: 1.7; - margin: 0; - padding: 0; - text-align: center; - }} - #content {{ - background: white none repeat scroll 0 0; - margin: 0 auto; - padding: 0; - position: relative; - text-align: left; - width: 980px; - }} - #body_inner {{ - padding: 20px; - }} - .main_title_block {{ - display: inline-flex; - margin-bottom: 4%; - }} - .main_logo{{ - background-color: #000000; - border-top: 10px solid {1}; - padding: 10px 20px; - //width: 50%; - }} - .main_title {{ - padding-left: 4%; - width: 100%; - }} - .block {{ - background: {0} none repeat scroll 0 0; - border-bottom: 3px solid {0}; - border-radius: 3px; - margin-bottom: 12px; - padding-bottom: 0; - }} - .block_title {{ - //color: #fee5d3; - color: #ffffff; - margin: 0; - padding: 6px 8px; - text-align: left; - }} - i {{ - vertical-align: sub - }} - .block_text{{ - padding: 5px 10px; - background: {1} none repeat scroll 0 0; - }} - .rows_table {{ - background: white none repeat scroll 0 0; - border-collapse: collapse; - margin: 0; - padding: 0; - page-break-inside: avoid; - width: 100%; - }} - .row_even td{{ - background: {1} none repeat scroll 0 0; - padding: 5px 10px; - }} - .row_odd td {{ - padding: 5px 10px; - }} - .block_footer {{ - margin-top: 10%; - border-top: solid 3px #ccc; - display: inline-flex; - width: 100% - }} - .block_footer_inner {{ - display: inline-flex; - margin-bottom: 4%; - margin-left: 4%; - }} - .image_footer {{ - width: 64px; - height: 64px; - margin-top: 10px; - }} - .text_footer{{ - margin-top: 16px; - margin-left: 10px; - }}""".format(color_main[self.color], color_secundary[self.color]) - self.update_html_file(html, "") + html = constants.COLOR_STYLE.format(color_main[self.color], color_secundary[self.color]) + return(html, "") def build_columns(self, columns_number): @@ -190,15 +76,12 @@ def build_columns(self, columns_number): """ self.columns_number = columns_number if self.columns_number == 1: - html = """ """ + html = constants.COLUMNS1 elif self.columns_number == 2: - html = """ - """ + html = constants.COLUMNS2 elif self.columns_number == 3: - html = """ - - """ - self.update_html_file(html, "") + html = constants.COLUMNS3 + return(html, "") def build_header(self, author_name): @@ -209,11 +92,8 @@ def build_header(self, author_name): """ self.author_name = author_name - html = """ - - -

{0} CheatSheet

by {1} via CheatSheet Maker
""".format(self.title, self.author_name) - self.update_html_file(html, "") + html = constants.HEADER.format(self.title, self.author_name) + return(html, "") def build_footer(self, author_picture, author_web, sponsor_name, sponsor_web): @@ -229,28 +109,8 @@ def build_footer(self, author_picture, author_web, sponsor_name, sponsor_web): self.author_web = author_web self.sponsor_name = sponsor_name self.sponsor_web = sponsor_web - html = """ - - - - """.format(self.author_picture, self.author_name, self.author_web, self.date, self.sponsor_name, self.sponsor_web) - self.update_html_file(html, "") + html = constants.FOOTER.format(self.author_picture, self.author_name, self.author_web, self.date, self.sponsor_name, self.sponsor_web) + return(html, "") @@ -267,26 +127,11 @@ def build_rows_block(self, selected_column, title, rows_number, text): rows = "" for i in range(rows_number): if i % 2 == 0: - rows += """ - -
{0}
- - """.format(text[i]) + rows += constants.ROWS_BLOCK_EVEN.format(text[i]) else: - rows += """ - -
{0}
- - """.format(text[i]) - html = """
-

{0}

- - - {1} - -
-
""".format(title, rows) - self.update_html_file(html, "") + rows += constants.ROWS_BLOCK_ODD.format(text[i]) + html = constants.ROWS_BLOCK.format(title, rows) + return(html, "") def build_text_block(self, selected_column, title, text): @@ -298,22 +143,20 @@ def build_text_block(self, selected_column, title, text): text (str): Text for block. """ - html = """
-

{0}

-
{1}
-
""".format(title, text) - self.update_html_file(html, "") + html = constants.TEXT_BLOCK.format(title, text) + return(html, "") - def update_html_file(self, new_html, from_here=None): + def update_html_file(self, html_to_add): """Reads html file, appends new html and writes it to file Args: - html (str): Text to write in file. - from_here (str): Text string to continue writting from there. + html_to_add (tuple): Text to write in file and Text string to continue writting from there. """ #Only reads file if it exists. + new_html = html_to_add[0] + from_here = html_to_add[1] if from_here: with open(self.title + ".html", 'r') as sheet: html = (sheet.read()) diff --git a/sheetmaker/sheet_wizard.py b/sheetmaker/sheet_wizard.py index b27dd31..88fc24f 100644 --- a/sheetmaker/sheet_wizard.py +++ b/sheetmaker/sheet_wizard.py @@ -73,7 +73,7 @@ def intro(self): print("##################################################################") print("# #") print("# #") - print("# {0} {1} #".format(self.lang_strings["INTRO_MESSAGE"] ,self.version)) + print("# {0} {1} #".format(self.lang_strings["INTRO_MESSAGE"] ,self.version)) print("# #") print("# #") print("##################################################################") @@ -137,9 +137,12 @@ def config_sheet(self): return(self.config_sheet()) self.NewSheet = html_builder.HtmlSheet(self.title, datetime.date.today()) #Creates a HtmlSheet object with title attrib - self.NewSheet.create_empty_sheet() - self.NewSheet.set_style(color) - self.NewSheet.build_columns(self.columns) + new_html = self.NewSheet.create_empty_sheet() + self.NewSheet.update_html_file(new_html) + new_html = self.NewSheet.set_style(color) + self.NewSheet.update_html_file(new_html) + new_html = self.NewSheet.build_columns(self.columns) + self.NewSheet.update_html_file(new_html) self.add_header() @@ -150,7 +153,8 @@ def add_header(self): options = { 1: self.lang_strings["HEADER_OPTIONS"][1], } author_name = self.input_handler(options) - self.NewSheet.build_header(author_name) + new_html = self.NewSheet.build_header(author_name) + self.NewSheet.update_html_file(new_html) self.add_footer() @@ -170,7 +174,8 @@ def add_footer(self): options = { 1: self.lang_strings["FOOTER_OPTIONS4"][1], } sponsor_web = self.input_handler(options) - self.NewSheet.build_footer(author_picture, author_web, sponsor_name, sponsor_web) + new_html = self.NewSheet.build_footer(author_picture, author_web, sponsor_name, sponsor_web) + self.NewSheet.update_html_file(new_html) self.add_block() @@ -225,7 +230,8 @@ def block_rows(self): print(self.lang_strings["INVALID_INPUT_MESSAGE"]) return(self.block_rows()) text = text.split("#") - self.NewSheet.build_rows_block(column_selected, title, rows_number, text) + new_html = self.NewSheet.build_rows_block(column_selected, title, rows_number, text) + self.NewSheet.update_html_file(new_html) self.add_block() @@ -249,7 +255,8 @@ def block_text(self): options = { 1: self.lang_strings["TEXT_BLOCK_OPTIONS2"][1], } text = self.input_handler(options) - self.NewSheet.build_text_block(column_selected, title, text) + new_html = self.NewSheet.build_text_block(column_selected, title, text) + self.NewSheet.update_html_file(new_html) self.add_block() diff --git a/sheetmaker/sheetmaker.py b/sheetmaker/sheetmaker.py index ea92be3..c4fab03 100644 --- a/sheetmaker/sheetmaker.py +++ b/sheetmaker/sheetmaker.py @@ -11,13 +11,14 @@ import sys -import constants import sheet_wizard +VERSION = "1.0.1" + def main(): """Main entry point for the script.""" - new_wizard = sheet_wizard.SheetWizard(constants.VERSION) + new_wizard = sheet_wizard.SheetWizard(VERSION) new_wizard.menu_language() new_wizard.intro() new_wizard.main_menu() From f538bc66071ae4c87e6e99ec5a261f58b550833a Mon Sep 17 00:00:00 2001 From: cosme12 Date: Sun, 12 Feb 2017 15:55:11 -0300 Subject: [PATCH 12/27] Basic tests created Fixes #9 Still need improvments --- sheetmaker/html_builder.py | 27 ++--- tests/data/test_html_constants.py | 175 ++++++++++++++++++++++++++++++ tests/test_html_builder.py | 92 ++++++++++++++++ 3 files changed, 279 insertions(+), 15 deletions(-) create mode 100644 tests/data/test_html_constants.py create mode 100644 tests/test_html_builder.py diff --git a/sheetmaker/html_builder.py b/sheetmaker/html_builder.py index 9753b7f..7762473 100644 --- a/sheetmaker/html_builder.py +++ b/sheetmaker/html_builder.py @@ -6,13 +6,21 @@ * """ -import constants +#Fix PATH tests and main program +try: #Path when running tests + import sys + import os + sys.path.insert(0, os.path.abspath('..')) + from sheetmaker import constants +except: #Path when running sheetmaker.py + import constants + class HtmlSheet(object): """The html sheet to be created and customized.""" - def __init__(self, title, date): + def __init__(self, title, date, author_name=None): """Return a new HtmlSheet object. Args: @@ -25,6 +33,7 @@ def __init__(self, title, date): date (str): Creation date displayed in footer. color (int): Color code style. main_columns (int): Number of columns for sheet structure. + author_name (str): Name of the author author_picture (str): Url path to picture, displayed in footer. author_web (str): Url displayed in footer. sponsor_name (str): Name displayed in footer. @@ -33,6 +42,7 @@ def __init__(self, title, date): """ self.title = title self.date = date + self.author_name = author_name def create_empty_sheet(self): @@ -166,16 +176,3 @@ def update_html_file(self, html_to_add): with open(self.title + ".html", 'w') as sheet: sheet.write(html) - -"""TEST CODE -new = HtmlSheet("prueba") -new.create_empty_sheet() -new.set_style(1) -new.build_header("Cosme12") -new.build_footer("images/dave.jpg", "www.mywebsite.com", "Sponsor Name", "www.sponsor.com") -new.build_columns(3) -text = ["Blocks are organised into columns by you.", - "PDFs organise blocks into columns automatically.", - "Try to keep the columns roughly even in length - it makes the cheat sheets easier to use online."] -new.build_rows_block("Block title", 1, 3, text) -""" \ No newline at end of file diff --git a/tests/data/test_html_constants.py b/tests/data/test_html_constants.py new file mode 100644 index 0000000..95de3ad --- /dev/null +++ b/tests/data/test_html_constants.py @@ -0,0 +1,175 @@ +"""Test html constants""" + +TEST_EMPTY_SHEET = """ + + + title + + + +
+
+
+ +
+ + + + +
+ +
+
+ +""" + +TEST_COLOR_STYLE = """ + body { + background: #dddfdd none repeat scroll 0 0; + color: #46473b; + font-family: "Lucida Grande","Lucida Sans Unicode",Arial,Helvetica,sans-serif; + font-size: 80%; + line-height: 1.7; + margin: 0; + padding: 0; + text-align: center; + } + #content { + background: white none repeat scroll 0 0; + margin: 0 auto; + padding: 0; + position: relative; + text-align: left; + width: 980px; + } + #body_inner { + padding: 20px; + } + .main_title_block { + display: inline-flex; + margin-bottom: 4%; + } + .main_logo{ + background-color: #000000; + border-top: 10px solid #fee5d3; + padding: 10px 20px; + //width: 50%; + } + .main_title { + padding-left: 4%; + width: 100%; + } + .block { + background: #fa6900 none repeat scroll 0 0; + border-bottom: 3px solid #fa6900; + border-radius: 3px; + margin-bottom: 12px; + padding-bottom: 0; + } + .block_title { + //color: #fee5d3; + color: #ffffff; + margin: 0; + padding: 6px 8px; + text-align: left; + } + i { + vertical-align: sub + } + .block_text{ + padding: 5px 10px; + background: #fee5d3 none repeat scroll 0 0; + } + .rows_table { + background: white none repeat scroll 0 0; + border-collapse: collapse; + margin: 0; + padding: 0; + page-break-inside: avoid; + width: 100%; + } + .row_even td{ + background: #fee5d3 none repeat scroll 0 0; + padding: 5px 10px; + } + .row_odd td { + padding: 5px 10px; + } + .block_footer { + margin-top: 10%; + border-top: solid 3px #ccc; + display: inline-flex; + width: 100% + } + .block_footer_inner { + display: inline-flex; + margin-bottom: 4%; + margin-left: 4%; + } + .image_footer { + width: 64px; + height: 64px; + margin-top: 10px; + } + .text_footer{ + margin-top: 16px; + margin-left: 10px; + }""" + +TEST_COLUMNS = """ + + """ + +TEST_HEADER = """ + + +

title CheatSheet

by author via CheatSheet Maker
""" + +TEST_FOOTER = """ + + + + """ + +TEST_ROWS_BLOCK = """
+

block title

+ + + + + + + + +
+
row1
+
+
row2
+
+
""" + +TEST_TEXT_BLOCK = """
+

block title

+
text text text
+
""" + diff --git a/tests/test_html_builder.py b/tests/test_html_builder.py new file mode 100644 index 0000000..e5ef720 --- /dev/null +++ b/tests/test_html_builder.py @@ -0,0 +1,92 @@ +import os +import sys +import unittest + +sys.path.insert(0, os.path.abspath('..')) +from sheetmaker import html_builder +from data import test_html_constants + + +class HtmlBuilderTestCase(unittest.TestCase): + """Tests for `html_builder.py`.""" + + def test_create_empty_sheet(self): + """Is empty sheet html created succesfully?""" + self.title = "title" + empty_sheet = html_builder.HtmlSheet(self.title, None) + test_html = empty_sheet.create_empty_sheet() + self.assertEqual(test_html[0], test_html_constants.TEST_EMPTY_SHEET) + self.assertEqual(test_html[1], None) + + + def test_set_style(self): + """Is color style created succesfully?""" + self.title = "title" + empty_sheet = html_builder.HtmlSheet(self.title, None) + test_html = empty_sheet.set_style(1) + self.assertEqual(test_html[0], test_html_constants.TEST_COLOR_STYLE) + self.assertEqual(test_html[1], "") + + + def test_build_columns(self): + """Are columns created succesfully?""" + self.title = "title" + empty_sheet = html_builder.HtmlSheet(self.title, None) + test_html = empty_sheet.build_columns(3) + self.assertEqual(test_html[0], test_html_constants.TEST_COLUMNS) + self.assertEqual(test_html[1], "") + + + def test_build_header(self): + """Is header created succesfully?""" + self.title = "title" + empty_sheet = html_builder.HtmlSheet(self.title, None) + test_html = empty_sheet.build_header("author") + self.assertEqual(test_html[0], test_html_constants.TEST_HEADER) + self.assertEqual(test_html[1], "") + + + def test_build_footer(self): + """Is footer created succesfully?""" + self.title = "test" + empty_sheet = html_builder.HtmlSheet(self.title, None, "author") + test_html = empty_sheet.build_footer("author.png", "http://author.com", "sponsor", "http://sponsor.com") + self.assertEqual(test_html[0], test_html_constants.TEST_FOOTER) + self.assertEqual(test_html[1], "") + + + def test_build_rows_block(self): + """Is rows block created succesfully?""" + self.title = "test" + empty_sheet = html_builder.HtmlSheet(self.title, None) + test_html = empty_sheet.build_rows_block(1, "block title", 2, ["row1", "row2"]) + self.assertEqual(test_html[0], test_html_constants.TEST_ROWS_BLOCK) + self.assertEqual(test_html[1], "") + + + def test_build_text_block(self): + """Is text block created succesfully?""" + self.title = "test" + empty_sheet = html_builder.HtmlSheet(self.title, None) + test_html = empty_sheet.build_text_block(2, "block title", "text text text") + self.assertEqual(test_html[0], test_html_constants.TEST_TEXT_BLOCK) + self.assertEqual(test_html[1], "") + + + def tearDown(self): + """Removes extra files generated during tests + + Args: + file_name (str): File to be removed. + """ + try: + #os.remove(self.test_file_name + ".html") + pass + except OSError as oserr: + print(oserr) + + + +if __name__ == '__main__': + unittest.main() + From 8da526cbed1355944eb12b4acf6ff24bd2d20fb5 Mon Sep 17 00:00:00 2001 From: cosme12 Date: Sun, 12 Feb 2017 17:32:26 -0300 Subject: [PATCH 13/27] Travis CI tests --- .travis.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..6d00862 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,10 @@ +language: python +python: + - "3.4" + - "3.5" + - "3.6" +cache: pip +install: + - pip install -r requirements.txt +script: + - python test_html_builder.py -v \ No newline at end of file From 6c27c1ac9042bb1200a9a5042449a41e28b96c0d Mon Sep 17 00:00:00 2001 From: cosme12 Date: Sun, 12 Feb 2017 17:49:54 -0300 Subject: [PATCH 14/27] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 6d00862..57179b3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,4 +7,4 @@ cache: pip install: - pip install -r requirements.txt script: - - python test_html_builder.py -v \ No newline at end of file + - python tests/test_html_builder.py -v From cabc0142ce42067cc12fe6db067eed25c5e00dda Mon Sep 17 00:00:00 2001 From: cosme12 Date: Sun, 12 Feb 2017 18:31:41 -0300 Subject: [PATCH 15/27] Import paths change --- .travis.yml | 2 +- tests/test_html_builder.py | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6d00862..73bbf90 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,4 +7,4 @@ cache: pip install: - pip install -r requirements.txt script: - - python test_html_builder.py -v \ No newline at end of file + - python tests/test_html_builder.py -v \ No newline at end of file diff --git a/tests/test_html_builder.py b/tests/test_html_builder.py index e5ef720..d1d838c 100644 --- a/tests/test_html_builder.py +++ b/tests/test_html_builder.py @@ -2,9 +2,13 @@ import sys import unittest -sys.path.insert(0, os.path.abspath('..')) -from sheetmaker import html_builder -from data import test_html_constants +try: + sys.path.insert(0, os.path.abspath('..')) + from sheetmaker import html_builder + from data import test_html_constants +except: + import html_builder + from tests.data import test_html_constants class HtmlBuilderTestCase(unittest.TestCase): From c98d601800081e92e8f5d083f53860a8130dfea4 Mon Sep 17 00:00:00 2001 From: cosme12 Date: Sun, 12 Feb 2017 18:36:21 -0300 Subject: [PATCH 16/27] Update travis --- .travis.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6d00862..9bea185 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,8 @@ language: python python: - - "3.4" - - "3.5" - "3.6" cache: pip install: - pip install -r requirements.txt script: - - python test_html_builder.py -v \ No newline at end of file + - python tests/test_html_builder.py -v \ No newline at end of file From e9a82ec57ba288bc3a9eddb8062ebef9492be252 Mon Sep 17 00:00:00 2001 From: cosme12 Date: Sun, 12 Feb 2017 18:42:04 -0300 Subject: [PATCH 17/27] Path changes --- tests/test_html_builder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_html_builder.py b/tests/test_html_builder.py index d1d838c..810a47c 100644 --- a/tests/test_html_builder.py +++ b/tests/test_html_builder.py @@ -3,7 +3,7 @@ import unittest try: - sys.path.insert(0, os.path.abspath('..')) + #sys.path.insert(0, os.path.abspath('..')) from sheetmaker import html_builder from data import test_html_constants except: From 907e0b4c826c5f77015f8599cfc0c665e26dbd74 Mon Sep 17 00:00:00 2001 From: cosme12 Date: Sun, 12 Feb 2017 18:47:24 -0300 Subject: [PATCH 18/27] Path changes --- tests/test_html_builder.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/test_html_builder.py b/tests/test_html_builder.py index 810a47c..865fad1 100644 --- a/tests/test_html_builder.py +++ b/tests/test_html_builder.py @@ -3,11 +3,12 @@ import unittest try: - #sys.path.insert(0, os.path.abspath('..')) - from sheetmaker import html_builder + sys.path.insert(0, os.path.abspath('..')) + #from sheetmaker import html_builder + from sheetmaker.html_builder import * from data import test_html_constants except: - import html_builder + from sheetmaker.html_builder import * from tests.data import test_html_constants From 8045ec7e1c87f7d987550d5b62d40a1411fdb522 Mon Sep 17 00:00:00 2001 From: cosme12 Date: Sun, 12 Feb 2017 19:24:03 -0300 Subject: [PATCH 19/27] Path changes --- tests/test_html_builder.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_html_builder.py b/tests/test_html_builder.py index 865fad1..e301f97 100644 --- a/tests/test_html_builder.py +++ b/tests/test_html_builder.py @@ -3,12 +3,12 @@ import unittest try: - sys.path.insert(0, os.path.abspath('..')) - #from sheetmaker import html_builder - from sheetmaker.html_builder import * + #sys.path.insert(0, os.path.abspath('..')) + from sheetmaker import html_builder from data import test_html_constants except: - from sheetmaker.html_builder import * + sys.path.insert(0, os.path.abspath('..')) + from sheetmaker import html_builder from tests.data import test_html_constants From dcf6b7d0ed8ba25958644034827254b655447ff8 Mon Sep 17 00:00:00 2001 From: cosme12 Date: Sun, 12 Feb 2017 19:32:18 -0300 Subject: [PATCH 20/27] Path changes --- .travis.yml | 2 +- tests/test_html_builder.py | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9bea185..13afaf7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,4 +5,4 @@ cache: pip install: - pip install -r requirements.txt script: - - python tests/test_html_builder.py -v \ No newline at end of file + - python tests/test_html_builder.py \ No newline at end of file diff --git a/tests/test_html_builder.py b/tests/test_html_builder.py index e301f97..77f6b4d 100644 --- a/tests/test_html_builder.py +++ b/tests/test_html_builder.py @@ -1,13 +1,15 @@ import os import sys +print(sys.path) import unittest try: - #sys.path.insert(0, os.path.abspath('..')) + sys.path.insert(0, os.path.abspath('..')) + print(sys.path) from sheetmaker import html_builder from data import test_html_constants except: - sys.path.insert(0, os.path.abspath('..')) + #sys.path.insert(0, os.path.abspath('..')) from sheetmaker import html_builder from tests.data import test_html_constants From e312bbf49fc9678ffd6542e68d9df666d05df4f1 Mon Sep 17 00:00:00 2001 From: cosme12 Date: Sun, 12 Feb 2017 19:40:48 -0300 Subject: [PATCH 21/27] Path changes --- tests/test_html_builder.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/test_html_builder.py b/tests/test_html_builder.py index 77f6b4d..ab5247f 100644 --- a/tests/test_html_builder.py +++ b/tests/test_html_builder.py @@ -4,14 +4,15 @@ import unittest try: - sys.path.insert(0, os.path.abspath('..')) + #sys.path.insert(0, os.path.abspath('..')) print(sys.path) from sheetmaker import html_builder from data import test_html_constants except: - #sys.path.insert(0, os.path.abspath('..')) + sys.path.insert(0, os.path.abspath('.')) + print(sys.path) from sheetmaker import html_builder - from tests.data import test_html_constants + from data import test_html_constants class HtmlBuilderTestCase(unittest.TestCase): From 78dd32619732c9d91925668422924463d999a69b Mon Sep 17 00:00:00 2001 From: cosme12 Date: Sun, 12 Feb 2017 19:45:12 -0300 Subject: [PATCH 22/27] Fixes Travis CI paths --- .travis.yml | 4 +++- tests/test_html_builder.py | 8 ++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 13afaf7..73bbf90 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,10 @@ language: python python: + - "3.4" + - "3.5" - "3.6" cache: pip install: - pip install -r requirements.txt script: - - python tests/test_html_builder.py \ No newline at end of file + - python tests/test_html_builder.py -v \ No newline at end of file diff --git a/tests/test_html_builder.py b/tests/test_html_builder.py index ab5247f..624f52a 100644 --- a/tests/test_html_builder.py +++ b/tests/test_html_builder.py @@ -1,17 +1,13 @@ import os import sys -print(sys.path) import unittest try: - #sys.path.insert(0, os.path.abspath('..')) - print(sys.path) + sys.path.insert(0, os.path.abspath('..')) #Works for local from sheetmaker import html_builder from data import test_html_constants except: - sys.path.insert(0, os.path.abspath('.')) - print(sys.path) - from sheetmaker import html_builder + from sheetmaker import html_builder #Works for Travis CI from data import test_html_constants From 601b55aca479befbdc77ea65c4c3936c81f0e92a Mon Sep 17 00:00:00 2001 From: cosme12 Date: Sun, 12 Feb 2017 19:55:10 -0300 Subject: [PATCH 23/27] Fix Travis CI Paths --- tests/test_html_builder.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_html_builder.py b/tests/test_html_builder.py index 624f52a..b67940e 100644 --- a/tests/test_html_builder.py +++ b/tests/test_html_builder.py @@ -7,7 +7,8 @@ from sheetmaker import html_builder from data import test_html_constants except: - from sheetmaker import html_builder #Works for Travis CI + sys.path.insert(0, os.path.abspath('.')) #Works for Travis CI + from sheetmaker import html_builder from data import test_html_constants From d0f70522c21aa374855d21d3f87df264d744f3ea Mon Sep 17 00:00:00 2001 From: cosme12 Date: Sun, 12 Feb 2017 20:05:08 -0300 Subject: [PATCH 24/27] Build status - Travis CI badge --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index dd63e46..4f2a2e1 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ CheatSheet Maker ================ +[![Build Status](https://travis-ci.org/cosme12/cheatsheet-maker.svg?branch=master)](https://travis-ci.org/cosme12/cheatsheet-maker) Cheatsheet (or quick reference) generator. Use it to create guides, instructions or study. Made in Python 3. From 1a7558634123376125844bbd1d5a4b6a940af469 Mon Sep 17 00:00:00 2001 From: cosme12 Date: Sun, 12 Feb 2017 20:10:21 -0300 Subject: [PATCH 25/27] Remove "not coded yet" tag from Spanish language --- sheetmaker/sheet_wizard.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sheetmaker/sheet_wizard.py b/sheetmaker/sheet_wizard.py index 88fc24f..18b5660 100644 --- a/sheetmaker/sheet_wizard.py +++ b/sheetmaker/sheet_wizard.py @@ -2,7 +2,7 @@ Todo: * Add color text in command line - * Add translation to options + * """ import datetime @@ -57,7 +57,7 @@ def menu_language(self): """Displays language selector""" print("Choose your language:") options = { 1: "English", - 2: "Español (NOT CODED YET)", + 2: "Español", } answer = self.input_handler(options) if answer == "1": From 0fc996da61a96b615b26d6cfda31af6ca7bfbfce Mon Sep 17 00:00:00 2001 From: cosme12 Date: Sun, 12 Feb 2017 23:50:15 -0300 Subject: [PATCH 26/27] Add coveralls badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4f2a2e1..7557603 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ CheatSheet Maker ================ -[![Build Status](https://travis-ci.org/cosme12/cheatsheet-maker.svg?branch=master)](https://travis-ci.org/cosme12/cheatsheet-maker) +[![Build Status](https://travis-ci.org/cosme12/cheatsheet-maker.svg?branch=master)](https://travis-ci.org/cosme12/cheatsheet-maker) [![Coverage Status](https://coveralls.io/repos/github/cosme12/cheatsheet-maker/badge.svg?branch=master)](https://coveralls.io/github/cosme12/cheatsheet-maker?branch=master) Cheatsheet (or quick reference) generator. Use it to create guides, instructions or study. Made in Python 3. From ad1c93e79cabfdb7816841a7b65f0c8b3bf49283 Mon Sep 17 00:00:00 2001 From: cosme12 Date: Sun, 12 Feb 2017 23:58:32 -0300 Subject: [PATCH 27/27] Import paths changed --- sheetmaker/sheet_wizard.py | 12 ++++++++++-- tests/test_html_builder.py | 13 ------------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/sheetmaker/sheet_wizard.py b/sheetmaker/sheet_wizard.py index 18b5660..94a46d3 100644 --- a/sheetmaker/sheet_wizard.py +++ b/sheetmaker/sheet_wizard.py @@ -6,8 +6,16 @@ """ import datetime -import html_builder -import language_strings +#Fix PATH tests and main program +try: #Path when running tests + import sys + import os + sys.path.insert(0, os.path.abspath('..')) + from sheetmaker import html_builder + from sheetmaker import language_strings +except: #Path when running sheetmaker.py + import html_builder + import language_strings diff --git a/tests/test_html_builder.py b/tests/test_html_builder.py index b67940e..15b9e4d 100644 --- a/tests/test_html_builder.py +++ b/tests/test_html_builder.py @@ -78,19 +78,6 @@ def test_build_text_block(self): self.assertEqual(test_html[1], "") - def tearDown(self): - """Removes extra files generated during tests - - Args: - file_name (str): File to be removed. - """ - try: - #os.remove(self.test_file_name + ".html") - pass - except OSError as oserr: - print(oserr) - - if __name__ == '__main__': unittest.main()