##// END OF EJS Templates
updated documentation on display formatters
Greg Caporaso -
Show More
@@ -148,25 +148,29 b' class FileLinks(FileLink):'
148 See the FileLink (baseclass of LocalDirectory) docstring for
148 See the FileLink (baseclass of LocalDirectory) docstring for
149 information on additional parameters.
149 information on additional parameters.
150
150
151 notebook_display_formatter : func passed to os.path.walk when
151 notebook_display_formatter : func used to format links for display
152 formatting links for display in the notebook. This function
152 in the notebook. See discussion of formatter function below.
153 should be of the form: f(dirname, fnames) where dirname is the
153
154 name of a directory (a string) and fnames is a list of the
154 terminal_display_formatter : func used to format links for display
155 files in that directory (not including subdirectories) and
155 in the terminal. See discussion of formatter function below.
156 returns a list of lines that should be used to print that text
156
157 in the notebook. This function is iterated over for each
157
158 directory in self.path. A default formatter is in place, but
158 Passing custom formatter functions
159 a function can be passed to support alternative formatting.
159 ----------------------------------
160
160 Formatter functions must be of the form:
161 terminal_display_formatter : func passed to os.path.walk when
161 f(dirname, fnames, included_suffixes)
162 formatting links for display in the terminal. This function
162 dirname : the name of a directory (a string),
163 should be of the form: f(dirname, fnames) where dirname is the
163 fnames : a list of the files in that directory
164 name of a directory (a string) and fnames is a list of the
164 included_suffixes : a list of the file suffixes that should be
165 files in that directory (not including subdirectories) and
165 included in the output (passing None means
166 returns a list of lines that should be used to print that text
166 to include all suffixes in the output in
167 in the terminal. This function is iterated over for each
167 the built-in formatters)
168 directory in self.path. A default formatter is in place, but
168
169 a function can be passed to support alternative formatting.
169 returns a list of lines that should will be print in the
170 notebook (if passing notebook_display_formatter) or the terminal
171 (if passing terminal_display_formatter). This function is iterated
172 over for each directory in self.path. Default formatters are in
173 place, can be passed here to support alternative formatting.
170
174
171 """
175 """
172 self.included_suffixes = included_suffixes
176 self.included_suffixes = included_suffixes
@@ -187,8 +191,10 b' class FileLinks(FileLink):'
187 dirname_output_format,
191 dirname_output_format,
188 fname_output_format,
192 fname_output_format,
189 fp_format):
193 fp_format):
190 """ generate function to format output- the resulting function will
194 """ generate built-in formatter function
191 take a list to be populated with the output lines to print,
195
196 this is used to define both the notebook and terminal built-in
197 formatters as they only differ by some wrapper text for each entry
192
198
193 dirname_output_format: string to use for formatting directory
199 dirname_output_format: string to use for formatting directory
194 names, dirname will be substituted for a single "%s" which
200 names, dirname will be substituted for a single "%s" which
General Comments 0
You need to be logged in to leave comments. Login now