diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 15c92b78..a2cb7a2f 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,13 +1,21 @@ Change log ================================================================================ +0.7.10 - unreleased +-------------------------------------------------------------------------------- + +**Updated** + +#. `#393 `_: Rendered + content output to stdout twice + 0.7.9 - 06.08.2020 -------------------------------------------------------------------------------- **Updated** #. `#390 `_: single render action - will print to stdout by defafult + will print to stdout by default 0.7.8 - 09.06.2020 -------------------------------------------------------------------------------- diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst index fd901cbc..7b8bbafb 100644 --- a/CONTRIBUTORS.rst +++ b/CONTRIBUTORS.rst @@ -8,4 +8,5 @@ In alphabetical order: * `John Vandenberg `_ * `Joshua Chung `_ * `PRAJWAL M `_ +* `salotz `_ * `SerekKiri `_ diff --git a/moban/core/moban_factory.py b/moban/core/moban_factory.py index 6413c022..366ba89a 100644 --- a/moban/core/moban_factory.py +++ b/moban/core/moban_factory.py @@ -156,21 +156,40 @@ def render_string_to_file( self.buffered_writer.close() def apply_template(self, template_abs_path, template, data, output_file): + + # render the content rendered_content = self.engine.apply_template( template, data, output_file ) + + # convert to utf8 if not already if not isinstance(rendered_content, bytes): rendered_content = rendered_content.encode("utf-8") + # attempt to output to the file and printing to stdout instead + # if not found try: + + # check if any of the files have changed flag = HASH_STORE.is_file_changed( output_file, rendered_content, template_abs_path ) + + # if they have re-render things if flag: + + # write the content to the output file self.buffered_writer.write_file_out( output_file, rendered_content ) - if not file_system.is_zip_alike_url(output_file): + + # attempt to copy the file permissions of the template + # file to the output file + + # if it isn't an archive proceed or stdout + if (not file_system.is_zip_alike_url(output_file) and + output_file != '-'): + try: file_system.file_permissions_copy( template_abs_path, output_file