text
stringlengths
0
828
if not known:
err_exit('No styles', 0)
for style in known:
if style == self.defaults.default_style:
print(style, '(default)')
else:
print(style)
sys.exit(0)"
1431,"def render_file(self, filename):
""""""Convert a reST file to HTML.
""""""
dirname, basename = split(filename)
with changedir(dirname):
infile = abspath(basename)
outfile = abspath('.%s.html' % basename)
self.docutils.publish_file(infile, outfile, self.styles)
return outfile"
1432,"def render_long_description(self, dirname):
""""""Convert a package's long description to HTML.
""""""
with changedir(dirname):
self.setuptools.check_valid_package()
long_description = self.setuptools.get_long_description()
outfile = abspath('.long-description.html')
self.docutils.publish_string(long_description, outfile, self.styles)
return outfile"
1433,"def open_in_browser(self, outfile):
""""""Open the given HTML file in a browser.
""""""
if self.browser == 'default':
webbrowser.open('file://%s' % outfile)
else:
browser = webbrowser.get(self.browser)
browser.open('file://%s' % outfile)"
1434,"def run(self):
""""""Render and display Python package documentation.
""""""
os.environ['JARN_RUN'] = '1'
self.python.check_valid_python()
args = self.parse_options(self.args)
if args:
arg = args[0]
else:
arg = os.curdir
if arg:
arg = expanduser(arg)
if isfile(arg):
outfile = self.render_file(arg)
elif isdir(arg):
outfile = self.render_long_description(arg)
else:
err_exit('No such file or directory: %s' % arg)
self.open_in_browser(outfile)"
1435,"def preprocess_cell(
self, cell: ""NotebookNode"", resources: dict, cell_index: int
) -> Tuple[""NotebookNode"", dict]:
""""""Apply a transformation on each cell.
Parameters
----------
cell : NotebookNode cell
Notebook cell being processed
resources : dictionary
Additional resources used in the conversion process. Allows
preprocessors to pass variables into the Jinja engine.
cell_index : int
Index of the cell being processed (see base.py)
""""""
# Get files directory if it has been specified
output_files_dir = resources.get(""output_files_dir"", None)
# Make sure outputs key exists
if not isinstance(resources[""outputs""], dict):
resources[""outputs""] = {}
# Loop through all of the attachments in the cell
for name, attach in cell.get(""attachments"", {}).items():
orig_name = name
name = re.sub(r""%[\w\d][\w\d]"", ""-"", name)
for mime, data in attach.items():
if mime not in self.extract_output_types:
continue
# Binary files are base64-encoded, SVG is already XML
if mime in {""image/png"", ""image/jpeg"", ""application/pdf""}:
# data is b64-encoded as text (str, unicode),
# we want the original bytes
data = a2b_base64(data)
elif sys.platform == ""win32"":
data = data.replace(""\n"", ""\r\n"").encode(""UTF-8"")
else:
data = data.encode(""UTF-8"")
filename = self.output_filename_template.format(
cell_index=cell_index,
name=name,