From f4f8cebaf11aebde26c4fa1c14bcae685bd0a690 2013-07-23 05:58:54 From: Jonathan Frederic Date: 2013-07-23 05:58:54 Subject: [PATCH] Added a space between pound and comments (@minrk request) --- diff --git a/IPython/nbconvert/nbconvertapp.py b/IPython/nbconvert/nbconvertapp.py index a8adf9a..8d36aeb 100755 --- a/IPython/nbconvert/nbconvertapp.py +++ b/IPython/nbconvert/nbconvertapp.py @@ -15,13 +15,13 @@ Command-line interface for the NbConvert conversion utility. #Imports #----------------------------------------------------------------------------- -#Stdlib imports +# Stdlib imports from __future__ import print_function import sys import os import glob -#From IPython +# From IPython from IPython.core.application import BaseIPythonApplication, base_aliases, base_flags from IPython.config import catch_config_error, Configurable from IPython.utils.traitlets import ( @@ -103,7 +103,7 @@ class NbConvertApp(BaseIPythonApplication): > ipython nbconvert --config mycfg.py """.format(get_export_names())) - #Writer specific variables + # Writer specific variables writer = Instance('IPython.nbconvert.writers.base.WriterBase', help="""Instance of the writer class used to write the results of the conversion.""") @@ -121,7 +121,7 @@ class NbConvertApp(BaseIPythonApplication): self.writer_factory = import_item(new) - #Other configurable variables + # Other configurable variables export_format = CaselessStrEnum(get_export_names(), default_value="full_html", config=True, @@ -153,7 +153,7 @@ class NbConvertApp(BaseIPythonApplication): else: patterns = self.notebooks - #Use glob to replace all the notebook patterns with filenames. + # Use glob to replace all the notebook patterns with filenames. filenames = [] for pattern in patterns: for filename in glob.glob(pattern): @@ -179,18 +179,18 @@ class NbConvertApp(BaseIPythonApplication): """ Convert the notebooks in the self.notebook traitlet """ - #Export each notebook + # Export each notebook conversion_success = 0 for notebook_filename in self.notebooks: - #Get a unique key for the notebook and set it in the resources object. + # Get a unique key for the notebook and set it in the resources object. basename = os.path.basename(notebook_filename) notebook_name = basename[:basename.rfind('.')] resources = {} resources['unique_key'] = notebook_name resources['output_files_dir'] = '%s_files' % notebook_name - #Try to export + # Try to export try: output, resources = export_by_name(self.export_format, notebook_filename, @@ -203,22 +203,22 @@ class NbConvertApp(BaseIPythonApplication): "\n\t" + "\n\t".join(get_export_names()), file=sys.stderr) sys.exit(-1) - #except Exception as e: - #print("Error: could not export '%s'" % notebook_filename, file=sys.stderr) - #print(e, file=sys.stderr) + # except Exception as e: + # print("Error: could not export '%s'" % notebook_filename, file=sys.stderr) + # print(e, file=sys.stderr) else: self.writer.write(output, resources, notebook_name=notebook_name) conversion_success += 1 - #If nothing was converted successfully, help the user. + # If nothing was converted successfully, help the user. if conversion_success == 0: - #No notebooks were specified, show help. + # No notebooks were specified, show help. if len(self.notebooks) == 0: self.print_help() - #Notebooks were specified, but not converted successfully. Show how - #to access help. + # Notebooks were specified, but not converted successfully. Show how + # to access help. else: print('For help, use "ipython nbconvert --help"') diff --git a/IPython/nbconvert/writers/files.py b/IPython/nbconvert/writers/files.py index 3620a5f..58ab601 100644 --- a/IPython/nbconvert/writers/files.py +++ b/IPython/nbconvert/writers/files.py @@ -36,7 +36,7 @@ class FilesWriter(WriterBase): to output to the current directory""") - #Make sure that the output directory exists. + # Make sure that the output directory exists. def _build_directory_changed(self, name, old, new): if new and not os.path.isdir(new): os.makedirs(new) @@ -57,46 +57,46 @@ class FilesWriter(WriterBase): See base for more... """ - #Pull the extension from the resources dict. + # Pull the extension and subdir from the resources dict. output_extension = resources['output_extension'] - #Write all of the extracted resources to the destination directory. - #NOTE: WE WRITE EVERYTHING AS-IF IT'S BINARY. THE EXTRACT FIG - #TRANSFORMER SHOULD HANDLE UNIX/WINDOWS LINE ENDINGS... + # Write all of the extracted resources to the destination directory. + # NOTE: WE WRITE EVERYTHING AS-IF IT'S BINARY. THE EXTRACT FIG + # TRANSFORMER SHOULD HANDLE UNIX/WINDOWS LINE ENDINGS... for filename, data in resources.get('figures', {}).items(): - #Determine where to write the file to + # Determine where to write the file to dest = os.path.join(self.build_directory, filename) path = os.path.dirname(dest) if not os.path.isdir(path): os.makedirs(path) - #Write file + # Write file with io.open(dest, 'wb') as f: f.write(data) - #Copy referenced files to output directory + # Copy referenced files to output directory if self.build_directory: for filename in self.files: - #Copy files that match search pattern + # Copy files that match search pattern for matching_filename in glob.glob(filename): - #Make sure folder exists. + # Make sure folder exists. dest = os.path.join(self.build_directory, filename) path = os.path.dirname(dest) if not os.path.isdir(path): os.makedirs(path) - #Copy if destination is different. + # Copy if destination is different. if not os.path.normpath(dest) == os.path.normpath(matching_filename): shutil.copyfile(matching_filename, dest) - #Determine where to write conversion results. + # Determine where to write conversion results. dest = notebook_name + '.' + output_extension if self.build_directory: dest = os.path.join(self.build_directory, dest) - #Write conversion results. + # Write conversion results. with io.open(dest, 'w') as f: f.write(output)