text
stringlengths
0
828
1571,"def share(self, fmto, **kwargs):
""""""Share the settings of this formatoption with other data objects
Parameters
----------
fmto: Formatoption
The :class:`Formatoption` instance to share the attributes with
``**kwargs``
Any other keyword argument that shall be passed to the update
method of `fmto`
Notes
-----
The Text formatoption sets the 'texts_to_remove' keyword to the
:attr:`_texts_to_remove` attribute of this instance (if not already
specified in ``**kwargs``""""""
kwargs.setdefault('texts_to_remove', self._texts_to_remove)
super(Text, self).share(fmto, **kwargs)"
1572,"def save(self, *args, **kwargs):
""""""
**uid**: :code:`person:{slug}`
""""""
self.slug = uuslug(
self.name,
instance=self,
max_length=100,
separator='-',
start_no=2
)
if not self.uid:
self.uid = 'organization:{}'.format(self.slug)
super(Organization, self).save(*args, **kwargs)"
1573,"def replace_variables(self, source: str, variables: dict) -> str:
""""""Replace {{variable-name}} with stored value.""""""
try:
replaced = re.sub(
""{{(.*?)}}"", lambda m: variables.get(m.group(1), """"), source
)
except TypeError:
replaced = source
return replaced"
1574,"def preprocess_cell(
self, cell: ""NotebookNode"", resources: dict, index: int
) -> Tuple[""NotebookNode"", dict]:
""""""Preprocess 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)
""""""
if cell.cell_type == ""markdown"":
variables = cell[""metadata""].get(""variables"", {})
if len(variables) > 0:
cell.source = self.replace_variables(cell.source, variables)
if resources.get(""delete_pymarkdown"", False):
del cell.metadata[""variables""]
return cell, resources"
1575,"def emit(self, ast_reg, ast_guide):
''' Default emit method: visit both ASTs and return the codegen '''
if (ast_reg):
self.visit(ast_reg)
codegen_reg = self.codegen
self.codegen = self.cg_type()
if (ast_guide):
self.visit(ast_guide)
return (codegen_reg, self.codegen)"
1576,"def index_dir(self, folder):
""""""
Creates a nested dictionary that represents the folder structure of folder.
Also extracts meta data from all markdown posts and adds to the dictionary.
""""""
folder_path = folder
print('Indexing folder: ' + folder_path)
nested_dir = {}
folder = folder_path.rstrip(os.sep)
start = folder.rfind(os.sep) + 1
for root, dirs, files in os.walk(folder):
folders = root[start:].split(os.sep)
# subdir = dict.fromkeys(files)
subdir = {}
for f in files:
# Create an entry for every markdown file
if os.path.splitext(f)[1] == '.md':
with open(os.path.abspath(os.path.join(root, f)), encoding='utf-8') as fp:
try:
_, meta = self.mrk.extract_meta(fp.read())
except:
print(""Skipping indexing "" + f +""; Could not parse metadata"")
meta = {'title': f}
pass
# Value of the entry (the key) is it's metadata