Commits

Tomas Zulberti committed df061d2

Cleaned the code

Comments (0)

Files changed (1)

pet_builder/commands.py

     create_basic_structure()
     html_articles_folder = os.path.join(settings.pet_folder, 'templates', 'pdf', 'articles')
 
-    # TODO use a parameter to get the articles order
-    articles_folders = os.listdir('.')
-    articles_files = map(lambda article_folder: os.path.join(article_folder, '%s.%s.rst' % (article_folder, settings.language)), articles_folders)
+    articles_files = map(lambda article_folder: os.path.join(article_folder, '%s.%s.rst' % (article_folder, settings.language)), os.listdir('.'))
 
     additional_data = dict(articles = articles_files)
-    pdf_master_template = os.path.join('pdf/pdfmaster.%s.rst' % settings.language)
+    pdf_master_template = os.path.join('pdf', 'pdfmaster.%s.rst' % settings.language)
     for page_size in PDF_PAGE_SIZES:
-        for orientation in PAGE_ORIENTATIONS:
-            folder_name = '%s_%s' % (page_size, orientation)
+        for page_orientation in PAGE_ORIENTATIONS:
+
+            folder_name = '%s_%s' % (page_size, page_orientation)
             destination_folder = os.path.join(settings.pet_folder, 'templates', 'pdf', folder_name)
             copy_render_template(pdf_master_template, destination_folder, additional_data)
 
             articles_destination_folder = os.path.join(destination_folder, 'articles')
             images_destination = os.path.join(destination_folder, 'images')
-            create_folders([images_destination])
 
             for article in articles_files:
                 article_folder = os.path.dirname(article)
 
                 # resize the image used by the article.
                 article_images_folder = os.path.join(article_folder, 'images')
-                size = IMAGE_SIZES[orientation]
+                size = IMAGE_SIZES[page_orientation]
                 for article_image in os.listdir(article_images_folder):
                     image_name = os.path.join(article_images_folder, article_image)
                     image_final_name = os.path.join(images_destination, os.path.basename(article_image))