partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
BaseCellReader.read
Read one cell from the given lines, and return the cell, plus the position of the next cell
jupytext/cell_reader.py
def read(self, lines): """Read one cell from the given lines, and return the cell, plus the position of the next cell """ # Do we have an explicit code marker on the first line? self.metadata_and_language_from_option_line(lines[0]) if self.metadata and 'language' in sel...
def read(self, lines): """Read one cell from the given lines, and return the cell, plus the position of the next cell """ # Do we have an explicit code marker on the first line? self.metadata_and_language_from_option_line(lines[0]) if self.metadata and 'language' in sel...
[ "Read", "one", "cell", "from", "the", "given", "lines", "and", "return", "the", "cell", "plus", "the", "position", "of", "the", "next", "cell" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_reader.py#L105-L140
[ "def", "read", "(", "self", ",", "lines", ")", ":", "# Do we have an explicit code marker on the first line?", "self", ".", "metadata_and_language_from_option_line", "(", "lines", "[", "0", "]", ")", "if", "self", ".", "metadata", "and", "'language'", "in", "self", ...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
BaseCellReader.metadata_and_language_from_option_line
Parse code options on the given line. When a start of a code cell is found, self.metadata is set to a dictionary.
jupytext/cell_reader.py
def metadata_and_language_from_option_line(self, line): """Parse code options on the given line. When a start of a code cell is found, self.metadata is set to a dictionary.""" if self.start_code_re.match(line): self.language, self.metadata = self.options_to_metadata(self.start_code_r...
def metadata_and_language_from_option_line(self, line): """Parse code options on the given line. When a start of a code cell is found, self.metadata is set to a dictionary.""" if self.start_code_re.match(line): self.language, self.metadata = self.options_to_metadata(self.start_code_r...
[ "Parse", "code", "options", "on", "the", "given", "line", ".", "When", "a", "start", "of", "a", "code", "cell", "is", "found", "self", ".", "metadata", "is", "set", "to", "a", "dictionary", "." ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_reader.py#L142-L146
[ "def", "metadata_and_language_from_option_line", "(", "self", ",", "line", ")", ":", "if", "self", ".", "start_code_re", ".", "match", "(", "line", ")", ":", "self", ".", "language", ",", "self", ".", "metadata", "=", "self", ".", "options_to_metadata", "(",...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
BaseCellReader.find_cell_content
Parse cell till its end and set content, lines_to_next_cell. Return the position of next cell start
jupytext/cell_reader.py
def find_cell_content(self, lines): """Parse cell till its end and set content, lines_to_next_cell. Return the position of next cell start""" cell_end_marker, next_cell_start, self.explicit_eoc = self.find_cell_end(lines) # Metadata to dict if self.metadata is None: ...
def find_cell_content(self, lines): """Parse cell till its end and set content, lines_to_next_cell. Return the position of next cell start""" cell_end_marker, next_cell_start, self.explicit_eoc = self.find_cell_end(lines) # Metadata to dict if self.metadata is None: ...
[ "Parse", "cell", "till", "its", "end", "and", "set", "content", "lines_to_next_cell", ".", "Return", "the", "position", "of", "next", "cell", "start" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_reader.py#L157-L215
[ "def", "find_cell_content", "(", "self", ",", "lines", ")", ":", "cell_end_marker", ",", "next_cell_start", ",", "self", ".", "explicit_eoc", "=", "self", ".", "find_cell_end", "(", "lines", ")", "# Metadata to dict", "if", "self", ".", "metadata", "is", "None...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
MarkdownCellReader.find_cell_end
Return position of end of cell marker, and position of first line after cell
jupytext/cell_reader.py
def find_cell_end(self, lines): """Return position of end of cell marker, and position of first line after cell""" if self.in_region: self.cell_type = 'markdown' for i, line in enumerate(lines): if self.end_region_re.match(line): return...
def find_cell_end(self, lines): """Return position of end of cell marker, and position of first line after cell""" if self.in_region: self.cell_type = 'markdown' for i, line in enumerate(lines): if self.end_region_re.match(line): return...
[ "Return", "position", "of", "end", "of", "cell", "marker", "and", "position", "of", "first", "line", "after", "cell" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_reader.py#L261-L321
[ "def", "find_cell_end", "(", "self", ",", "lines", ")", ":", "if", "self", ".", "in_region", ":", "self", ".", "cell_type", "=", "'markdown'", "for", "i", ",", "line", "in", "enumerate", "(", "lines", ")", ":", "if", "self", ".", "end_region_re", ".", ...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
RScriptCellReader.find_cell_end
Return position of end of cell marker, and position of first line after cell
jupytext/cell_reader.py
def find_cell_end(self, lines): """Return position of end of cell marker, and position of first line after cell""" if self.metadata is None and lines[0].startswith("#'"): self.cell_type = 'markdown' for i, line in enumerate(lines): if not line.startswith("...
def find_cell_end(self, lines): """Return position of end of cell marker, and position of first line after cell""" if self.metadata is None and lines[0].startswith("#'"): self.cell_type = 'markdown' for i, line in enumerate(lines): if not line.startswith("...
[ "Return", "position", "of", "end", "of", "cell", "marker", "and", "position", "of", "first", "line", "after", "cell" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_reader.py#L381-L426
[ "def", "find_cell_end", "(", "self", ",", "lines", ")", ":", "if", "self", ".", "metadata", "is", "None", "and", "lines", "[", "0", "]", ".", "startswith", "(", "\"#'\"", ")", ":", "self", ".", "cell_type", "=", "'markdown'", "for", "i", ",", "line",...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
LightScriptCellReader.find_cell_end
Return position of end of cell marker, and position of first line after cell
jupytext/cell_reader.py
def find_cell_end(self, lines): """Return position of end of cell marker, and position of first line after cell""" if self.metadata is None and not (self.cell_marker_end and self.end_code_re.match(lines[0])) \ and paragraph_is_fully_commented(lines, self.comment, self.default_language): ...
def find_cell_end(self, lines): """Return position of end of cell marker, and position of first line after cell""" if self.metadata is None and not (self.cell_marker_end and self.end_code_re.match(lines[0])) \ and paragraph_is_fully_commented(lines, self.comment, self.default_language): ...
[ "Return", "position", "of", "end", "of", "cell", "marker", "and", "position", "of", "first", "line", "after", "cell" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_reader.py#L491-L507
[ "def", "find_cell_end", "(", "self", ",", "lines", ")", ":", "if", "self", ".", "metadata", "is", "None", "and", "not", "(", "self", ".", "cell_marker_end", "and", "self", ".", "end_code_re", ".", "match", "(", "lines", "[", "0", "]", ")", ")", "and"...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
LightScriptCellReader.find_region_end
Find the end of the region started with start and end markers
jupytext/cell_reader.py
def find_region_end(self, lines): """Find the end of the region started with start and end markers""" if self.metadata and 'cell_type' in self.metadata: self.cell_type = self.metadata.pop('cell_type') else: self.cell_type = 'code' parser = StringParser(self.langu...
def find_region_end(self, lines): """Find the end of the region started with start and end markers""" if self.metadata and 'cell_type' in self.metadata: self.cell_type = self.metadata.pop('cell_type') else: self.cell_type = 'code' parser = StringParser(self.langu...
[ "Find", "the", "end", "of", "the", "region", "started", "with", "start", "and", "end", "markers" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_reader.py#L509-L557
[ "def", "find_region_end", "(", "self", ",", "lines", ")", ":", "if", "self", ".", "metadata", "and", "'cell_type'", "in", "self", ".", "metadata", ":", "self", ".", "cell_type", "=", "self", ".", "metadata", ".", "pop", "(", "'cell_type'", ")", "else", ...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
DoublePercentScriptCellReader.metadata_and_language_from_option_line
Parse code options on the given line. When a start of a code cell is found, self.metadata is set to a dictionary.
jupytext/cell_reader.py
def metadata_and_language_from_option_line(self, line): """Parse code options on the given line. When a start of a code cell is found, self.metadata is set to a dictionary.""" if self.start_code_re.match(line): self.language, self.metadata = self.options_to_metadata(line[line.find('%...
def metadata_and_language_from_option_line(self, line): """Parse code options on the given line. When a start of a code cell is found, self.metadata is set to a dictionary.""" if self.start_code_re.match(line): self.language, self.metadata = self.options_to_metadata(line[line.find('%...
[ "Parse", "code", "options", "on", "the", "given", "line", ".", "When", "a", "start", "of", "a", "code", "cell", "is", "found", "self", ".", "metadata", "is", "set", "to", "a", "dictionary", "." ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_reader.py#L572-L578
[ "def", "metadata_and_language_from_option_line", "(", "self", ",", "line", ")", ":", "if", "self", ".", "start_code_re", ".", "match", "(", "line", ")", ":", "self", ".", "language", ",", "self", ".", "metadata", "=", "self", ".", "options_to_metadata", "(",...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
DoublePercentScriptCellReader.find_cell_content
Parse cell till its end and set content, lines_to_next_cell. Return the position of next cell start
jupytext/cell_reader.py
def find_cell_content(self, lines): """Parse cell till its end and set content, lines_to_next_cell. Return the position of next cell start""" cell_end_marker, next_cell_start, explicit_eoc = self.find_cell_end(lines) # Metadata to dict if self.start_code_re.match(lines[0]) or se...
def find_cell_content(self, lines): """Parse cell till its end and set content, lines_to_next_cell. Return the position of next cell start""" cell_end_marker, next_cell_start, explicit_eoc = self.find_cell_end(lines) # Metadata to dict if self.start_code_re.match(lines[0]) or se...
[ "Parse", "cell", "till", "its", "end", "and", "set", "content", "lines_to_next_cell", ".", "Return", "the", "position", "of", "next", "cell", "start" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_reader.py#L583-L612
[ "def", "find_cell_content", "(", "self", ",", "lines", ")", ":", "cell_end_marker", ",", "next_cell_start", ",", "explicit_eoc", "=", "self", ".", "find_cell_end", "(", "lines", ")", "# Metadata to dict", "if", "self", ".", "start_code_re", ".", "match", "(", ...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
DoublePercentScriptCellReader.find_cell_end
Return position of end of cell marker, and position of first line after cell
jupytext/cell_reader.py
def find_cell_end(self, lines): """Return position of end of cell marker, and position of first line after cell""" if self.metadata and 'cell_type' in self.metadata: self.cell_type = self.metadata.pop('cell_type') else: self.cell_type = 'code' next_cell ...
def find_cell_end(self, lines): """Return position of end of cell marker, and position of first line after cell""" if self.metadata and 'cell_type' in self.metadata: self.cell_type = self.metadata.pop('cell_type') else: self.cell_type = 'code' next_cell ...
[ "Return", "position", "of", "end", "of", "cell", "marker", "and", "position", "of", "first", "line", "after", "cell" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_reader.py#L614-L633
[ "def", "find_cell_end", "(", "self", ",", "lines", ")", ":", "if", "self", ".", "metadata", "and", "'cell_type'", "in", "self", ".", "metadata", ":", "self", ".", "cell_type", "=", "self", ".", "metadata", ".", "pop", "(", "'cell_type'", ")", "else", "...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
SphinxGalleryScriptCellReader.start_of_new_markdown_cell
Does this line starts a new markdown cell? Then, return the cell marker
jupytext/cell_reader.py
def start_of_new_markdown_cell(self, line): """Does this line starts a new markdown cell? Then, return the cell marker""" for empty_markdown_cell in ['""', "''"]: if line == empty_markdown_cell: return empty_markdown_cell for triple_quote in ['"""', "'''"]: ...
def start_of_new_markdown_cell(self, line): """Does this line starts a new markdown cell? Then, return the cell marker""" for empty_markdown_cell in ['""', "''"]: if line == empty_markdown_cell: return empty_markdown_cell for triple_quote in ['"""', "'''"]: ...
[ "Does", "this", "line", "starts", "a", "new", "markdown", "cell?", "Then", "return", "the", "cell", "marker" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_reader.py#L656-L670
[ "def", "start_of_new_markdown_cell", "(", "self", ",", "line", ")", ":", "for", "empty_markdown_cell", "in", "[", "'\"\"'", ",", "\"''\"", "]", ":", "if", "line", "==", "empty_markdown_cell", ":", "return", "empty_markdown_cell", "for", "triple_quote", "in", "["...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
SphinxGalleryScriptCellReader.find_cell_end
Return position of end of cell, and position of first line after cell, and whether there was an explicit end of cell marker
jupytext/cell_reader.py
def find_cell_end(self, lines): """Return position of end of cell, and position of first line after cell, and whether there was an explicit end of cell marker""" if self.cell_type == 'markdown': # Empty cell "" or '' if len(self.markdown_marker) <= 2: ...
def find_cell_end(self, lines): """Return position of end of cell, and position of first line after cell, and whether there was an explicit end of cell marker""" if self.cell_type == 'markdown': # Empty cell "" or '' if len(self.markdown_marker) <= 2: ...
[ "Return", "position", "of", "end", "of", "cell", "and", "position", "of", "first", "line", "after", "cell", "and", "whether", "there", "was", "an", "explicit", "end", "of", "cell", "marker" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_reader.py#L681-L727
[ "def", "find_cell_end", "(", "self", ",", "lines", ")", ":", "if", "self", ".", "cell_type", "==", "'markdown'", ":", "# Empty cell \"\" or ''", "if", "len", "(", "self", ".", "markdown_marker", ")", "<=", "2", ":", "if", "len", "(", "lines", ")", "==", ...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
SphinxGalleryScriptCellReader.find_cell_content
Parse cell till its end and set content, lines_to_next_cell. Return the position of next cell start
jupytext/cell_reader.py
def find_cell_content(self, lines): """Parse cell till its end and set content, lines_to_next_cell. Return the position of next cell start""" cell_end_marker, next_cell_start, explicit_eoc = self.find_cell_end(lines) # Metadata to dict cell_start = 0 if self.cell_type ==...
def find_cell_content(self, lines): """Parse cell till its end and set content, lines_to_next_cell. Return the position of next cell start""" cell_end_marker, next_cell_start, explicit_eoc = self.find_cell_end(lines) # Metadata to dict cell_start = 0 if self.cell_type ==...
[ "Parse", "cell", "till", "its", "end", "and", "set", "content", "lines_to_next_cell", ".", "Return", "the", "position", "of", "next", "cell", "start" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_reader.py#L729-L775
[ "def", "find_cell_content", "(", "self", ",", "lines", ")", ":", "cell_end_marker", ",", "next_cell_start", ",", "explicit_eoc", "=", "self", ".", "find_cell_end", "(", "lines", ")", "# Metadata to dict", "cell_start", "=", "0", "if", "self", ".", "cell_type", ...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
base_path
Given a path and options for a format (ext, suffix, prefix), return the corresponding base path
jupytext/paired_paths.py
def base_path(main_path, fmt): """Given a path and options for a format (ext, suffix, prefix), return the corresponding base path""" if not fmt: return os.path.splitext(main_path)[0] fmt = long_form_one_format(fmt) fmt_ext = fmt['extension'] suffix = fmt.get('suffix') prefix = fmt.get('...
def base_path(main_path, fmt): """Given a path and options for a format (ext, suffix, prefix), return the corresponding base path""" if not fmt: return os.path.splitext(main_path)[0] fmt = long_form_one_format(fmt) fmt_ext = fmt['extension'] suffix = fmt.get('suffix') prefix = fmt.get('...
[ "Given", "a", "path", "and", "options", "for", "a", "format", "(", "ext", "suffix", "prefix", ")", "return", "the", "corresponding", "base", "path" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/paired_paths.py#L13-L58
[ "def", "base_path", "(", "main_path", ",", "fmt", ")", ":", "if", "not", "fmt", ":", "return", "os", ".", "path", ".", "splitext", "(", "main_path", ")", "[", "0", "]", "fmt", "=", "long_form_one_format", "(", "fmt", ")", "fmt_ext", "=", "fmt", "[", ...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
full_path
Return the full path for the notebook, given the base path
jupytext/paired_paths.py
def full_path(base, fmt): """Return the full path for the notebook, given the base path""" ext = fmt['extension'] suffix = fmt.get('suffix') prefix = fmt.get('prefix') full = base if prefix: prefix_dir, prefix_file_name = os.path.split(prefix) notebook_dir, notebook_file_name =...
def full_path(base, fmt): """Return the full path for the notebook, given the base path""" ext = fmt['extension'] suffix = fmt.get('suffix') prefix = fmt.get('prefix') full = base if prefix: prefix_dir, prefix_file_name = os.path.split(prefix) notebook_dir, notebook_file_name =...
[ "Return", "the", "full", "path", "for", "the", "notebook", "given", "the", "base", "path" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/paired_paths.py#L61-L94
[ "def", "full_path", "(", "base", ",", "fmt", ")", ":", "ext", "=", "fmt", "[", "'extension'", "]", "suffix", "=", "fmt", ".", "get", "(", "'suffix'", ")", "prefix", "=", "fmt", ".", "get", "(", "'prefix'", ")", "full", "=", "base", "if", "prefix", ...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
find_base_path_and_format
Return the base path and the format corresponding to the given path
jupytext/paired_paths.py
def find_base_path_and_format(main_path, formats): """Return the base path and the format corresponding to the given path""" for fmt in formats: try: return base_path(main_path, fmt), fmt except InconsistentPath: continue raise InconsistentPath(u"Path '{}' matches no...
def find_base_path_and_format(main_path, formats): """Return the base path and the format corresponding to the given path""" for fmt in formats: try: return base_path(main_path, fmt), fmt except InconsistentPath: continue raise InconsistentPath(u"Path '{}' matches no...
[ "Return", "the", "base", "path", "and", "the", "format", "corresponding", "to", "the", "given", "path" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/paired_paths.py#L97-L108
[ "def", "find_base_path_and_format", "(", "main_path", ",", "formats", ")", ":", "for", "fmt", "in", "formats", ":", "try", ":", "return", "base_path", "(", "main_path", ",", "fmt", ")", ",", "fmt", "except", "InconsistentPath", ":", "continue", "raise", "Inc...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
paired_paths
Return the list of paired notebooks, given main path, and the list of formats
jupytext/paired_paths.py
def paired_paths(main_path, fmt, formats): """Return the list of paired notebooks, given main path, and the list of formats""" if not formats: return [(main_path, {'extension': os.path.splitext(main_path)[1]})] formats = long_form_multiple_formats(formats) # Is there a format that matches the ...
def paired_paths(main_path, fmt, formats): """Return the list of paired notebooks, given main path, and the list of formats""" if not formats: return [(main_path, {'extension': os.path.splitext(main_path)[1]})] formats = long_form_multiple_formats(formats) # Is there a format that matches the ...
[ "Return", "the", "list", "of", "paired", "notebooks", "given", "main", "path", "and", "the", "list", "of", "formats" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/paired_paths.py#L111-L131
[ "def", "paired_paths", "(", "main_path", ",", "fmt", ",", "formats", ")", ":", "if", "not", "formats", ":", "return", "[", "(", "main_path", ",", "{", "'extension'", ":", "os", ".", "path", ".", "splitext", "(", "main_path", ")", "[", "1", "]", "}", ...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
metadata_to_rmd_options
Convert language and metadata information to their rmd representation :param language: :param metadata: :return:
jupytext/cell_metadata.py
def metadata_to_rmd_options(language, metadata): """ Convert language and metadata information to their rmd representation :param language: :param metadata: :return: """ options = (language or 'R').lower() if 'name' in metadata: options += ' ' + metadata['name'] + ',' del...
def metadata_to_rmd_options(language, metadata): """ Convert language and metadata information to their rmd representation :param language: :param metadata: :return: """ options = (language or 'R').lower() if 'name' in metadata: options += ' ' + metadata['name'] + ',' del...
[ "Convert", "language", "and", "metadata", "information", "to", "their", "rmd", "representation", ":", "param", "language", ":", ":", "param", "metadata", ":", ":", "return", ":" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_metadata.py#L63-L95
[ "def", "metadata_to_rmd_options", "(", "language", ",", "metadata", ")", ":", "options", "=", "(", "language", "or", "'R'", ")", ".", "lower", "(", ")", "if", "'name'", "in", "metadata", ":", "options", "+=", "' '", "+", "metadata", "[", "'name'", "]", ...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
update_metadata_from_rmd_options
Update metadata using the _BOOLEAN_OPTIONS_DICTIONARY mapping :param name: option name :param value: option value :param metadata: :return:
jupytext/cell_metadata.py
def update_metadata_from_rmd_options(name, value, metadata): """ Update metadata using the _BOOLEAN_OPTIONS_DICTIONARY mapping :param name: option name :param value: option value :param metadata: :return: """ for jupyter_option, rmd_option, rev in _BOOLEAN_OPTIONS_DICTIONARY: if ...
def update_metadata_from_rmd_options(name, value, metadata): """ Update metadata using the _BOOLEAN_OPTIONS_DICTIONARY mapping :param name: option name :param value: option value :param metadata: :return: """ for jupyter_option, rmd_option, rev in _BOOLEAN_OPTIONS_DICTIONARY: if ...
[ "Update", "metadata", "using", "the", "_BOOLEAN_OPTIONS_DICTIONARY", "mapping", ":", "param", "name", ":", "option", "name", ":", "param", "value", ":", "option", "value", ":", "param", "metadata", ":", ":", "return", ":" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_metadata.py#L98-L113
[ "def", "update_metadata_from_rmd_options", "(", "name", ",", "value", ",", "metadata", ")", ":", "for", "jupyter_option", ",", "rmd_option", ",", "rev", "in", "_BOOLEAN_OPTIONS_DICTIONARY", ":", "if", "name", "==", "rmd_option", ":", "try", ":", "metadata", "[",...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
parse_rmd_options
Given a R markdown option line, returns a list of pairs name,value :param line: :return:
jupytext/cell_metadata.py
def parse_rmd_options(line): """ Given a R markdown option line, returns a list of pairs name,value :param line: :return: """ parsing_context = ParsingContext(line) result = [] prev_char = '' name = '' value = '' for char in ',' + line + ',': if parsing_context.in_...
def parse_rmd_options(line): """ Given a R markdown option line, returns a list of pairs name,value :param line: :return: """ parsing_context = ParsingContext(line) result = [] prev_char = '' name = '' value = '' for char in ',' + line + ',': if parsing_context.in_...
[ "Given", "a", "R", "markdown", "option", "line", "returns", "a", "list", "of", "pairs", "name", "value", ":", "param", "line", ":", ":", "return", ":" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_metadata.py#L167-L210
[ "def", "parse_rmd_options", "(", "line", ")", ":", "parsing_context", "=", "ParsingContext", "(", "line", ")", "result", "=", "[", "]", "prev_char", "=", "''", "name", "=", "''", "value", "=", "''", "for", "char", "in", "','", "+", "line", "+", "','", ...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
rmd_options_to_metadata
Parse rmd options and return a metadata dictionary :param options: :return:
jupytext/cell_metadata.py
def rmd_options_to_metadata(options): """ Parse rmd options and return a metadata dictionary :param options: :return: """ options = re.split(r'\s|,', options, 1) if len(options) == 1: language = options[0] chunk_options = [] else: language, others = options ...
def rmd_options_to_metadata(options): """ Parse rmd options and return a metadata dictionary :param options: :return: """ options = re.split(r'\s|,', options, 1) if len(options) == 1: language = options[0] chunk_options = [] else: language, others = options ...
[ "Parse", "rmd", "options", "and", "return", "a", "metadata", "dictionary", ":", "param", "options", ":", ":", "return", ":" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_metadata.py#L213-L251
[ "def", "rmd_options_to_metadata", "(", "options", ")", ":", "options", "=", "re", ".", "split", "(", "r'\\s|,'", ",", "options", ",", "1", ")", "if", "len", "(", "options", ")", "==", "1", ":", "language", "=", "options", "[", "0", "]", "chunk_options"...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
metadata_to_md_options
Encode {'class':None, 'key':'value'} into 'class key="value"'
jupytext/cell_metadata.py
def metadata_to_md_options(metadata): """Encode {'class':None, 'key':'value'} into 'class key="value"' """ return ' '.join(["{}={}".format(key, dumps(metadata[key])) if metadata[key] is not None else key for key in metadata])
def metadata_to_md_options(metadata): """Encode {'class':None, 'key':'value'} into 'class key="value"' """ return ' '.join(["{}={}".format(key, dumps(metadata[key])) if metadata[key] is not None else key for key in metadata])
[ "Encode", "{", "class", ":", "None", "key", ":", "value", "}", "into", "class", "key", "=", "value" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_metadata.py#L254-L258
[ "def", "metadata_to_md_options", "(", "metadata", ")", ":", "return", "' '", ".", "join", "(", "[", "\"{}={}\"", ".", "format", "(", "key", ",", "dumps", "(", "metadata", "[", "key", "]", ")", ")", "if", "metadata", "[", "key", "]", "is", "not", "Non...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
parse_md_code_options
Parse 'python class key="value"' into [('python', None), ('class', None), ('key', 'value')]
jupytext/cell_metadata.py
def parse_md_code_options(options): """Parse 'python class key="value"' into [('python', None), ('class', None), ('key', 'value')]""" metadata = [] while options: name_and_value = re.split(r'[\s=]+', options, maxsplit=1) name = name_and_value[0] # Equal sign in between name and wha...
def parse_md_code_options(options): """Parse 'python class key="value"' into [('python', None), ('class', None), ('key', 'value')]""" metadata = [] while options: name_and_value = re.split(r'[\s=]+', options, maxsplit=1) name = name_and_value[0] # Equal sign in between name and wha...
[ "Parse", "python", "class", "key", "=", "value", "into", "[", "(", "python", "None", ")", "(", "class", "None", ")", "(", "key", "value", ")", "]" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_metadata.py#L261-L298
[ "def", "parse_md_code_options", "(", "options", ")", ":", "metadata", "=", "[", "]", "while", "options", ":", "name_and_value", "=", "re", ".", "split", "(", "r'[\\s=]+'", ",", "options", ",", "maxsplit", "=", "1", ")", "name", "=", "name_and_value", "[", ...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
md_options_to_metadata
Parse markdown options and return language and metadata
jupytext/cell_metadata.py
def md_options_to_metadata(options): """Parse markdown options and return language and metadata""" metadata = parse_md_code_options(options) if metadata: language = metadata[0][0] for lang in _JUPYTER_LANGUAGES + ['julia', 'scheme', 'c++']: if language.lower() == lang.lower(): ...
def md_options_to_metadata(options): """Parse markdown options and return language and metadata""" metadata = parse_md_code_options(options) if metadata: language = metadata[0][0] for lang in _JUPYTER_LANGUAGES + ['julia', 'scheme', 'c++']: if language.lower() == lang.lower(): ...
[ "Parse", "markdown", "options", "and", "return", "language", "and", "metadata" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_metadata.py#L301-L311
[ "def", "md_options_to_metadata", "(", "options", ")", ":", "metadata", "=", "parse_md_code_options", "(", "options", ")", "if", "metadata", ":", "language", "=", "metadata", "[", "0", "]", "[", "0", "]", "for", "lang", "in", "_JUPYTER_LANGUAGES", "+", "[", ...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
try_eval_metadata
Evaluate given metadata to a python object, if possible
jupytext/cell_metadata.py
def try_eval_metadata(metadata, name): """Evaluate given metadata to a python object, if possible""" value = metadata[name] if not isinstance(value, (str, unicode)): return if (value.startswith('"') and value.endswith('"')) or (value.startswith("'") and value.endswith("'")): if name in [...
def try_eval_metadata(metadata, name): """Evaluate given metadata to a python object, if possible""" value = metadata[name] if not isinstance(value, (str, unicode)): return if (value.startswith('"') and value.endswith('"')) or (value.startswith("'") and value.endswith("'")): if name in [...
[ "Evaluate", "given", "metadata", "to", "a", "python", "object", "if", "possible" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_metadata.py#L314-L330
[ "def", "try_eval_metadata", "(", "metadata", ",", "name", ")", ":", "value", "=", "metadata", "[", "name", "]", "if", "not", "isinstance", "(", "value", ",", "(", "str", ",", "unicode", ")", ")", ":", "return", "if", "(", "value", ".", "startswith", ...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
json_options_to_metadata
Read metadata from its json representation
jupytext/cell_metadata.py
def json_options_to_metadata(options, add_brackets=True): """Read metadata from its json representation""" try: options = loads('{' + options + '}' if add_brackets else options) return options except ValueError: return {}
def json_options_to_metadata(options, add_brackets=True): """Read metadata from its json representation""" try: options = loads('{' + options + '}' if add_brackets else options) return options except ValueError: return {}
[ "Read", "metadata", "from", "its", "json", "representation" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_metadata.py#L333-L339
[ "def", "json_options_to_metadata", "(", "options", ",", "add_brackets", "=", "True", ")", ":", "try", ":", "options", "=", "loads", "(", "'{'", "+", "options", "+", "'}'", "if", "add_brackets", "else", "options", ")", "return", "options", "except", "ValueErr...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
is_active
Is the cell active for the given file extension?
jupytext/cell_metadata.py
def is_active(ext, metadata): """Is the cell active for the given file extension?""" if metadata.get('run_control', {}).get('frozen') is True: return False if 'active' not in metadata: return True return ext.replace('.', '') in re.split('\\.|,', metadata['active'])
def is_active(ext, metadata): """Is the cell active for the given file extension?""" if metadata.get('run_control', {}).get('frozen') is True: return False if 'active' not in metadata: return True return ext.replace('.', '') in re.split('\\.|,', metadata['active'])
[ "Is", "the", "cell", "active", "for", "the", "given", "file", "extension?" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_metadata.py#L350-L356
[ "def", "is_active", "(", "ext", ",", "metadata", ")", ":", "if", "metadata", ".", "get", "(", "'run_control'", ",", "{", "}", ")", ".", "get", "(", "'frozen'", ")", "is", "True", ":", "return", "False", "if", "'active'", "not", "in", "metadata", ":",...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
double_percent_options_to_metadata
Parse double percent options
jupytext/cell_metadata.py
def double_percent_options_to_metadata(options): """Parse double percent options""" matches = _PERCENT_CELL.findall('# %%' + options) # Fail safe when regexp matching fails #116 # (occurs e.g. if square brackets are found in the title) if not matches: return {'title': options.strip()} ...
def double_percent_options_to_metadata(options): """Parse double percent options""" matches = _PERCENT_CELL.findall('# %%' + options) # Fail safe when regexp matching fails #116 # (occurs e.g. if square brackets are found in the title) if not matches: return {'title': options.strip()} ...
[ "Parse", "double", "percent", "options" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_metadata.py#L359-L395
[ "def", "double_percent_options_to_metadata", "(", "options", ")", ":", "matches", "=", "_PERCENT_CELL", ".", "findall", "(", "'# %%'", "+", "options", ")", "# Fail safe when regexp matching fails #116", "# (occurs e.g. if square brackets are found in the title)", "if", "not", ...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
metadata_to_double_percent_options
Metadata to double percent lines
jupytext/cell_metadata.py
def metadata_to_double_percent_options(metadata): """Metadata to double percent lines""" options = [] if 'cell_depth' in metadata: options.append('%' * metadata.pop('cell_depth')) if 'title' in metadata: options.append(metadata.pop('title')) if 'cell_type' in metadata: option...
def metadata_to_double_percent_options(metadata): """Metadata to double percent lines""" options = [] if 'cell_depth' in metadata: options.append('%' * metadata.pop('cell_depth')) if 'title' in metadata: options.append(metadata.pop('title')) if 'cell_type' in metadata: option...
[ "Metadata", "to", "double", "percent", "lines" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_metadata.py#L398-L410
[ "def", "metadata_to_double_percent_options", "(", "metadata", ")", ":", "options", "=", "[", "]", "if", "'cell_depth'", "in", "metadata", ":", "options", ".", "append", "(", "'%'", "*", "metadata", ".", "pop", "(", "'cell_depth'", ")", ")", "if", "'title'", ...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
ParsingContext.in_global_expression
Currently inside an expression
jupytext/cell_metadata.py
def in_global_expression(self): """Currently inside an expression""" return (self.parenthesis_count == 0 and self.curly_bracket_count == 0 and self.square_bracket_count == 0 and not self.in_single_quote and not self.in_double_quote)
def in_global_expression(self): """Currently inside an expression""" return (self.parenthesis_count == 0 and self.curly_bracket_count == 0 and self.square_bracket_count == 0 and not self.in_single_quote and not self.in_double_quote)
[ "Currently", "inside", "an", "expression" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_metadata.py#L129-L133
[ "def", "in_global_expression", "(", "self", ")", ":", "return", "(", "self", ".", "parenthesis_count", "==", "0", "and", "self", ".", "curly_bracket_count", "==", "0", "and", "self", ".", "square_bracket_count", "==", "0", "and", "not", "self", ".", "in_sing...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
ParsingContext.count_special_chars
Update parenthesis counters
jupytext/cell_metadata.py
def count_special_chars(self, char, prev_char): """Update parenthesis counters""" if char == '(': self.parenthesis_count += 1 elif char == ')': self.parenthesis_count -= 1 if self.parenthesis_count < 0: raise RMarkdownOptionParsingError( ...
def count_special_chars(self, char, prev_char): """Update parenthesis counters""" if char == '(': self.parenthesis_count += 1 elif char == ')': self.parenthesis_count -= 1 if self.parenthesis_count < 0: raise RMarkdownOptionParsingError( ...
[ "Update", "parenthesis", "counters" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_metadata.py#L135-L164
[ "def", "count_special_chars", "(", "self", ",", "char", ",", "prev_char", ")", ":", "if", "char", "==", "'('", ":", "self", ".", "parenthesis_count", "+=", "1", "elif", "char", "==", "')'", ":", "self", ".", "parenthesis_count", "-=", "1", "if", "self", ...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
get_format_implementation
Return the implementation for the desired format
jupytext/formats.py
def get_format_implementation(ext, format_name=None): """Return the implementation for the desired format""" # remove pre-extension if any ext = '.' + ext.split('.')[-1] formats_for_extension = [] for fmt in JUPYTEXT_FORMATS: if fmt.extension == ext: if fmt.format_name == format...
def get_format_implementation(ext, format_name=None): """Return the implementation for the desired format""" # remove pre-extension if any ext = '.' + ext.split('.')[-1] formats_for_extension = [] for fmt in JUPYTEXT_FORMATS: if fmt.extension == ext: if fmt.format_name == format...
[ "Return", "the", "implementation", "for", "the", "desired", "format" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/formats.py#L151-L170
[ "def", "get_format_implementation", "(", "ext", ",", "format_name", "=", "None", ")", ":", "# remove pre-extension if any", "ext", "=", "'.'", "+", "ext", ".", "split", "(", "'.'", ")", "[", "-", "1", "]", "formats_for_extension", "=", "[", "]", "for", "fm...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
read_metadata
Return the header metadata
jupytext/formats.py
def read_metadata(text, ext): """Return the header metadata""" ext = '.' + ext.split('.')[-1] lines = text.splitlines() if ext in ['.md', '.Rmd']: comment = '' else: comment = _SCRIPT_EXTENSIONS.get(ext, {}).get('comment', '#') metadata, _, _, _ = header_to_metadata_and_cell(li...
def read_metadata(text, ext): """Return the header metadata""" ext = '.' + ext.split('.')[-1] lines = text.splitlines() if ext in ['.md', '.Rmd']: comment = '' else: comment = _SCRIPT_EXTENSIONS.get(ext, {}).get('comment', '#') metadata, _, _, _ = header_to_metadata_and_cell(li...
[ "Return", "the", "header", "metadata" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/formats.py#L173-L187
[ "def", "read_metadata", "(", "text", ",", "ext", ")", ":", "ext", "=", "'.'", "+", "ext", ".", "split", "(", "'.'", ")", "[", "-", "1", "]", "lines", "=", "text", ".", "splitlines", "(", ")", "if", "ext", "in", "[", "'.md'", ",", "'.Rmd'", "]",...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
read_format_from_metadata
Return the format of the file, when that information is available from the metadata
jupytext/formats.py
def read_format_from_metadata(text, ext): """Return the format of the file, when that information is available from the metadata""" metadata = read_metadata(text, ext) rearrange_jupytext_metadata(metadata) return format_name_for_ext(metadata, ext, explicit_default=False)
def read_format_from_metadata(text, ext): """Return the format of the file, when that information is available from the metadata""" metadata = read_metadata(text, ext) rearrange_jupytext_metadata(metadata) return format_name_for_ext(metadata, ext, explicit_default=False)
[ "Return", "the", "format", "of", "the", "file", "when", "that", "information", "is", "available", "from", "the", "metadata" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/formats.py#L190-L194
[ "def", "read_format_from_metadata", "(", "text", ",", "ext", ")", ":", "metadata", "=", "read_metadata", "(", "text", ",", "ext", ")", "rearrange_jupytext_metadata", "(", "metadata", ")", "return", "format_name_for_ext", "(", "metadata", ",", "ext", ",", "explic...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
guess_format
Guess the format and format options of the file, given its extension and content
jupytext/formats.py
def guess_format(text, ext): """Guess the format and format options of the file, given its extension and content""" lines = text.splitlines() metadata = read_metadata(text, ext) if ('jupytext' in metadata and set(metadata['jupytext']) .difference(['encoding', 'executable', 'main_language']...
def guess_format(text, ext): """Guess the format and format options of the file, given its extension and content""" lines = text.splitlines() metadata = read_metadata(text, ext) if ('jupytext' in metadata and set(metadata['jupytext']) .difference(['encoding', 'executable', 'main_language']...
[ "Guess", "the", "format", "and", "format", "options", "of", "the", "file", "given", "its", "extension", "and", "content" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/formats.py#L197-L276
[ "def", "guess_format", "(", "text", ",", "ext", ")", ":", "lines", "=", "text", ".", "splitlines", "(", ")", "metadata", "=", "read_metadata", "(", "text", ",", "ext", ")", "if", "(", "'jupytext'", "in", "metadata", "and", "set", "(", "metadata", "[", ...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
divine_format
Guess the format of the notebook, based on its content #148
jupytext/formats.py
def divine_format(text): """Guess the format of the notebook, based on its content #148""" try: nbformat.reads(text, as_version=4) return 'ipynb' except nbformat.reader.NotJSONError: pass lines = text.splitlines() for comment in ['', '#'] + _COMMENT_CHARS: metadata, ...
def divine_format(text): """Guess the format of the notebook, based on its content #148""" try: nbformat.reads(text, as_version=4) return 'ipynb' except nbformat.reader.NotJSONError: pass lines = text.splitlines() for comment in ['', '#'] + _COMMENT_CHARS: metadata, ...
[ "Guess", "the", "format", "of", "the", "notebook", "based", "on", "its", "content", "#148" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/formats.py#L279-L299
[ "def", "divine_format", "(", "text", ")", ":", "try", ":", "nbformat", ".", "reads", "(", "text", ",", "as_version", "=", "4", ")", "return", "'ipynb'", "except", "nbformat", ".", "reader", ".", "NotJSONError", ":", "pass", "lines", "=", "text", ".", "...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
check_file_version
Raise if file version in source file would override outputs
jupytext/formats.py
def check_file_version(notebook, source_path, outputs_path): """Raise if file version in source file would override outputs""" if not insert_or_test_version_number(): return _, ext = os.path.splitext(source_path) if ext.endswith('.ipynb'): return version = notebook.metadata.get('jup...
def check_file_version(notebook, source_path, outputs_path): """Raise if file version in source file would override outputs""" if not insert_or_test_version_number(): return _, ext = os.path.splitext(source_path) if ext.endswith('.ipynb'): return version = notebook.metadata.get('jup...
[ "Raise", "if", "file", "version", "in", "source", "file", "would", "override", "outputs" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/formats.py#L302-L333
[ "def", "check_file_version", "(", "notebook", ",", "source_path", ",", "outputs_path", ")", ":", "if", "not", "insert_or_test_version_number", "(", ")", ":", "return", "_", ",", "ext", "=", "os", ".", "path", ".", "splitext", "(", "source_path", ")", "if", ...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
format_name_for_ext
Return the format name for that extension
jupytext/formats.py
def format_name_for_ext(metadata, ext, cm_default_formats=None, explicit_default=True): """Return the format name for that extension""" # Is the format information available in the text representation? text_repr = metadata.get('jupytext', {}).get('text_representation', {}) if text_repr.get('extension', ...
def format_name_for_ext(metadata, ext, cm_default_formats=None, explicit_default=True): """Return the format name for that extension""" # Is the format information available in the text representation? text_repr = metadata.get('jupytext', {}).get('text_representation', {}) if text_repr.get('extension', ...
[ "Return", "the", "format", "name", "for", "that", "extension" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/formats.py#L336-L354
[ "def", "format_name_for_ext", "(", "metadata", ",", "ext", ",", "cm_default_formats", "=", "None", ",", "explicit_default", "=", "True", ")", ":", "# Is the format information available in the text representation?", "text_repr", "=", "metadata", ".", "get", "(", "'jupyt...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
identical_format_path
Do the two (long representation) of formats target the same file?
jupytext/formats.py
def identical_format_path(fmt1, fmt2): """Do the two (long representation) of formats target the same file?""" for key in ['extension', 'prefix', 'suffix']: if fmt1.get(key) != fmt2.get(key): return False return True
def identical_format_path(fmt1, fmt2): """Do the two (long representation) of formats target the same file?""" for key in ['extension', 'prefix', 'suffix']: if fmt1.get(key) != fmt2.get(key): return False return True
[ "Do", "the", "two", "(", "long", "representation", ")", "of", "formats", "target", "the", "same", "file?" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/formats.py#L357-L362
[ "def", "identical_format_path", "(", "fmt1", ",", "fmt2", ")", ":", "for", "key", "in", "[", "'extension'", ",", "'prefix'", ",", "'suffix'", "]", ":", "if", "fmt1", ".", "get", "(", "key", ")", "!=", "fmt2", ".", "get", "(", "key", ")", ":", "retu...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
update_jupytext_formats_metadata
Update the jupytext_format metadata in the Jupyter notebook
jupytext/formats.py
def update_jupytext_formats_metadata(metadata, new_format): """Update the jupytext_format metadata in the Jupyter notebook""" new_format = long_form_one_format(new_format) formats = long_form_multiple_formats(metadata.get('jupytext', {}).get('formats', '')) if not formats: return for fmt in...
def update_jupytext_formats_metadata(metadata, new_format): """Update the jupytext_format metadata in the Jupyter notebook""" new_format = long_form_one_format(new_format) formats = long_form_multiple_formats(metadata.get('jupytext', {}).get('formats', '')) if not formats: return for fmt in...
[ "Update", "the", "jupytext_format", "metadata", "in", "the", "Jupyter", "notebook" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/formats.py#L365-L377
[ "def", "update_jupytext_formats_metadata", "(", "metadata", ",", "new_format", ")", ":", "new_format", "=", "long_form_one_format", "(", "new_format", ")", "formats", "=", "long_form_multiple_formats", "(", "metadata", ".", "get", "(", "'jupytext'", ",", "{", "}", ...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
rearrange_jupytext_metadata
Convert the jupytext_formats metadata entry to jupytext/formats, etc. See #91
jupytext/formats.py
def rearrange_jupytext_metadata(metadata): """Convert the jupytext_formats metadata entry to jupytext/formats, etc. See #91""" # Backward compatibility with nbrmd for key in ['nbrmd_formats', 'nbrmd_format_version']: if key in metadata: metadata[key.replace('nbrmd', 'jupytext')] = metad...
def rearrange_jupytext_metadata(metadata): """Convert the jupytext_formats metadata entry to jupytext/formats, etc. See #91""" # Backward compatibility with nbrmd for key in ['nbrmd_formats', 'nbrmd_format_version']: if key in metadata: metadata[key.replace('nbrmd', 'jupytext')] = metad...
[ "Convert", "the", "jupytext_formats", "metadata", "entry", "to", "jupytext", "/", "formats", "etc", ".", "See", "#91" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/formats.py#L380-L422
[ "def", "rearrange_jupytext_metadata", "(", "metadata", ")", ":", "# Backward compatibility with nbrmd", "for", "key", "in", "[", "'nbrmd_formats'", ",", "'nbrmd_format_version'", "]", ":", "if", "key", "in", "metadata", ":", "metadata", "[", "key", ".", "replace", ...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
long_form_one_format
Parse 'sfx.py:percent' into {'suffix':'sfx', 'extension':'py', 'format_name':'percent'}
jupytext/formats.py
def long_form_one_format(jupytext_format, metadata=None, update=None): """Parse 'sfx.py:percent' into {'suffix':'sfx', 'extension':'py', 'format_name':'percent'}""" if isinstance(jupytext_format, dict): if update: jupytext_format.update(update) return validate_one_format(jupytext_for...
def long_form_one_format(jupytext_format, metadata=None, update=None): """Parse 'sfx.py:percent' into {'suffix':'sfx', 'extension':'py', 'format_name':'percent'}""" if isinstance(jupytext_format, dict): if update: jupytext_format.update(update) return validate_one_format(jupytext_for...
[ "Parse", "sfx", ".", "py", ":", "percent", "into", "{", "suffix", ":", "sfx", "extension", ":", "py", "format_name", ":", "percent", "}" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/formats.py#L425-L467
[ "def", "long_form_one_format", "(", "jupytext_format", ",", "metadata", "=", "None", ",", "update", "=", "None", ")", ":", "if", "isinstance", "(", "jupytext_format", ",", "dict", ")", ":", "if", "update", ":", "jupytext_format", ".", "update", "(", "update"...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
long_form_multiple_formats
Convert a concise encoding of jupytext.formats to a list of formats, encoded as dictionaries
jupytext/formats.py
def long_form_multiple_formats(jupytext_formats, metadata=None): """Convert a concise encoding of jupytext.formats to a list of formats, encoded as dictionaries""" if not jupytext_formats: return [] if not isinstance(jupytext_formats, list): jupytext_formats = [fmt for fmt in jupytext_forma...
def long_form_multiple_formats(jupytext_formats, metadata=None): """Convert a concise encoding of jupytext.formats to a list of formats, encoded as dictionaries""" if not jupytext_formats: return [] if not isinstance(jupytext_formats, list): jupytext_formats = [fmt for fmt in jupytext_forma...
[ "Convert", "a", "concise", "encoding", "of", "jupytext", ".", "formats", "to", "a", "list", "of", "formats", "encoded", "as", "dictionaries" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/formats.py#L470-L480
[ "def", "long_form_multiple_formats", "(", "jupytext_formats", ",", "metadata", "=", "None", ")", ":", "if", "not", "jupytext_formats", ":", "return", "[", "]", "if", "not", "isinstance", "(", "jupytext_formats", ",", "list", ")", ":", "jupytext_formats", "=", ...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
short_form_one_format
Represent one jupytext format as a string
jupytext/formats.py
def short_form_one_format(jupytext_format): """Represent one jupytext format as a string""" if not isinstance(jupytext_format, dict): return jupytext_format fmt = jupytext_format['extension'] if 'suffix' in jupytext_format: fmt = jupytext_format['suffix'] + fmt elif fmt.startswith('....
def short_form_one_format(jupytext_format): """Represent one jupytext format as a string""" if not isinstance(jupytext_format, dict): return jupytext_format fmt = jupytext_format['extension'] if 'suffix' in jupytext_format: fmt = jupytext_format['suffix'] + fmt elif fmt.startswith('....
[ "Represent", "one", "jupytext", "format", "as", "a", "string" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/formats.py#L483-L500
[ "def", "short_form_one_format", "(", "jupytext_format", ")", ":", "if", "not", "isinstance", "(", "jupytext_format", ",", "dict", ")", ":", "return", "jupytext_format", "fmt", "=", "jupytext_format", "[", "'extension'", "]", "if", "'suffix'", "in", "jupytext_forma...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
short_form_multiple_formats
Convert jupytext formats, represented as a list of dictionaries, to a comma separated list
jupytext/formats.py
def short_form_multiple_formats(jupytext_formats): """Convert jupytext formats, represented as a list of dictionaries, to a comma separated list""" if not isinstance(jupytext_formats, list): return jupytext_formats jupytext_formats = [short_form_one_format(fmt) for fmt in jupytext_formats] retu...
def short_form_multiple_formats(jupytext_formats): """Convert jupytext formats, represented as a list of dictionaries, to a comma separated list""" if not isinstance(jupytext_formats, list): return jupytext_formats jupytext_formats = [short_form_one_format(fmt) for fmt in jupytext_formats] retu...
[ "Convert", "jupytext", "formats", "represented", "as", "a", "list", "of", "dictionaries", "to", "a", "comma", "separated", "list" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/formats.py#L503-L509
[ "def", "short_form_multiple_formats", "(", "jupytext_formats", ")", ":", "if", "not", "isinstance", "(", "jupytext_formats", ",", "list", ")", ":", "return", "jupytext_formats", "jupytext_formats", "=", "[", "short_form_one_format", "(", "fmt", ")", "for", "fmt", ...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
validate_one_format
Validate extension and options for the given format
jupytext/formats.py
def validate_one_format(jupytext_format): """Validate extension and options for the given format""" if not isinstance(jupytext_format, dict): raise JupytextFormatError('Jupytext format should be a dictionary') for key in jupytext_format: if key not in _VALID_FORMAT_INFO + _VALID_FORMAT_OPTI...
def validate_one_format(jupytext_format): """Validate extension and options for the given format""" if not isinstance(jupytext_format, dict): raise JupytextFormatError('Jupytext format should be a dictionary') for key in jupytext_format: if key not in _VALID_FORMAT_INFO + _VALID_FORMAT_OPTI...
[ "Validate", "extension", "and", "options", "for", "the", "given", "format" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/formats.py#L517-L538
[ "def", "validate_one_format", "(", "jupytext_format", ")", ":", "if", "not", "isinstance", "(", "jupytext_format", ",", "dict", ")", ":", "raise", "JupytextFormatError", "(", "'Jupytext format should be a dictionary'", ")", "for", "key", "in", "jupytext_format", ":", ...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
black_invariant
Remove characters that may be changed when reformatting the text with black
jupytext/combine.py
def black_invariant(text, chars=None): """Remove characters that may be changed when reformatting the text with black""" if chars is None: chars = [' ', '\t', '\n', ',', "'", '"', '(', ')', '\\'] for char in chars: text = text.replace(char, '') return text
def black_invariant(text, chars=None): """Remove characters that may be changed when reformatting the text with black""" if chars is None: chars = [' ', '\t', '\n', ',', "'", '"', '(', ')', '\\'] for char in chars: text = text.replace(char, '') return text
[ "Remove", "characters", "that", "may", "be", "changed", "when", "reformatting", "the", "text", "with", "black" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/combine.py#L13-L20
[ "def", "black_invariant", "(", "text", ",", "chars", "=", "None", ")", ":", "if", "chars", "is", "None", ":", "chars", "=", "[", "' '", ",", "'\\t'", ",", "'\\n'", ",", "','", ",", "\"'\"", ",", "'\"'", ",", "'('", ",", "')'", ",", "'\\\\'", "]",...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
combine_inputs_with_outputs
Copy outputs of the second notebook into the first one, for cells that have matching inputs
jupytext/combine.py
def combine_inputs_with_outputs(nb_source, nb_outputs, fmt=None): """Copy outputs of the second notebook into the first one, for cells that have matching inputs""" output_code_cells = [cell for cell in nb_outputs.cells if cell.cell_type == 'code'] output_other_cells = [cell for cell in nb_outputs.cells...
def combine_inputs_with_outputs(nb_source, nb_outputs, fmt=None): """Copy outputs of the second notebook into the first one, for cells that have matching inputs""" output_code_cells = [cell for cell in nb_outputs.cells if cell.cell_type == 'code'] output_other_cells = [cell for cell in nb_outputs.cells...
[ "Copy", "outputs", "of", "the", "second", "notebook", "into", "the", "first", "one", "for", "cells", "that", "have", "matching", "inputs" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/combine.py#L28-L101
[ "def", "combine_inputs_with_outputs", "(", "nb_source", ",", "nb_outputs", ",", "fmt", "=", "None", ")", ":", "output_code_cells", "=", "[", "cell", "for", "cell", "in", "nb_outputs", ".", "cells", "if", "cell", ".", "cell_type", "==", "'code'", "]", "output...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
kernelspec_from_language
Return the kernel specification for the first kernel with a matching language
jupytext/contentsmanager.py
def kernelspec_from_language(language): """Return the kernel specification for the first kernel with a matching language""" try: for name in find_kernel_specs(): kernel_specs = get_kernel_spec(name) if kernel_specs.language == language or (language == 'c++' and kernel_specs.langu...
def kernelspec_from_language(language): """Return the kernel specification for the first kernel with a matching language""" try: for name in find_kernel_specs(): kernel_specs = get_kernel_spec(name) if kernel_specs.language == language or (language == 'c++' and kernel_specs.langu...
[ "Return", "the", "kernel", "specification", "for", "the", "first", "kernel", "with", "a", "matching", "language" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/contentsmanager.py#L33-L42
[ "def", "kernelspec_from_language", "(", "language", ")", ":", "try", ":", "for", "name", "in", "find_kernel_specs", "(", ")", ":", "kernel_specs", "=", "get_kernel_spec", "(", "name", ")", "if", "kernel_specs", ".", "language", "==", "language", "or", "(", "...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
preferred_format
Return the preferred format for the given extension
jupytext/contentsmanager.py
def preferred_format(incomplete_format, preferred_formats): """Return the preferred format for the given extension""" incomplete_format = long_form_one_format(incomplete_format) if 'format_name' in incomplete_format: return incomplete_format for fmt in long_form_multiple_formats(preferred_forma...
def preferred_format(incomplete_format, preferred_formats): """Return the preferred format for the given extension""" incomplete_format = long_form_one_format(incomplete_format) if 'format_name' in incomplete_format: return incomplete_format for fmt in long_form_multiple_formats(preferred_forma...
[ "Return", "the", "preferred", "format", "for", "the", "given", "extension" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/contentsmanager.py#L45-L60
[ "def", "preferred_format", "(", "incomplete_format", ",", "preferred_formats", ")", ":", "incomplete_format", "=", "long_form_one_format", "(", "incomplete_format", ")", "if", "'format_name'", "in", "incomplete_format", ":", "return", "incomplete_format", "for", "fmt", ...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
TextFileContentsManager.drop_paired_notebook
Remove the current notebook from the list of paired notebooks
jupytext/contentsmanager.py
def drop_paired_notebook(self, path): """Remove the current notebook from the list of paired notebooks""" if path not in self.paired_notebooks: return fmt, formats = self.paired_notebooks.pop(path) prev_paired_paths = paired_paths(path, fmt, formats) for alt_path, _ ...
def drop_paired_notebook(self, path): """Remove the current notebook from the list of paired notebooks""" if path not in self.paired_notebooks: return fmt, formats = self.paired_notebooks.pop(path) prev_paired_paths = paired_paths(path, fmt, formats) for alt_path, _ ...
[ "Remove", "the", "current", "notebook", "from", "the", "list", "of", "paired", "notebooks" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/contentsmanager.py#L162-L171
[ "def", "drop_paired_notebook", "(", "self", ",", "path", ")", ":", "if", "path", "not", "in", "self", ".", "paired_notebooks", ":", "return", "fmt", ",", "formats", "=", "self", ".", "paired_notebooks", ".", "pop", "(", "path", ")", "prev_paired_paths", "=...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
TextFileContentsManager.update_paired_notebooks
Update the list of paired notebooks to include/update the current pair
jupytext/contentsmanager.py
def update_paired_notebooks(self, path, fmt, formats): """Update the list of paired notebooks to include/update the current pair""" if not formats: self.drop_paired_notebook(path) return new_paired_paths = paired_paths(path, fmt, formats) for alt_path, _ in new_p...
def update_paired_notebooks(self, path, fmt, formats): """Update the list of paired notebooks to include/update the current pair""" if not formats: self.drop_paired_notebook(path) return new_paired_paths = paired_paths(path, fmt, formats) for alt_path, _ in new_p...
[ "Update", "the", "list", "of", "paired", "notebooks", "to", "include", "/", "update", "the", "current", "pair" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/contentsmanager.py#L173-L189
[ "def", "update_paired_notebooks", "(", "self", ",", "path", ",", "fmt", ",", "formats", ")", ":", "if", "not", "formats", ":", "self", ".", "drop_paired_notebook", "(", "path", ")", "return", "new_paired_paths", "=", "paired_paths", "(", "path", ",", "fmt", ...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
TextFileContentsManager.set_default_format_options
Set default format option
jupytext/contentsmanager.py
def set_default_format_options(self, format_options, read=False): """Set default format option""" if self.default_notebook_metadata_filter: format_options.setdefault('notebook_metadata_filter', self.default_notebook_metadata_filter) if self.default_cell_metadata_filter: f...
def set_default_format_options(self, format_options, read=False): """Set default format option""" if self.default_notebook_metadata_filter: format_options.setdefault('notebook_metadata_filter', self.default_notebook_metadata_filter) if self.default_cell_metadata_filter: f...
[ "Set", "default", "format", "option" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/contentsmanager.py#L191-L204
[ "def", "set_default_format_options", "(", "self", ",", "format_options", ",", "read", "=", "False", ")", ":", "if", "self", ".", "default_notebook_metadata_filter", ":", "format_options", ".", "setdefault", "(", "'notebook_metadata_filter'", ",", "self", ".", "defau...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
TextFileContentsManager.default_formats
Return the default formats, if they apply to the current path #157
jupytext/contentsmanager.py
def default_formats(self, path): """Return the default formats, if they apply to the current path #157""" formats = long_form_multiple_formats(self.default_jupytext_formats) for fmt in formats: try: base_path(path, fmt) return self.default_jupytext_for...
def default_formats(self, path): """Return the default formats, if they apply to the current path #157""" formats = long_form_multiple_formats(self.default_jupytext_formats) for fmt in formats: try: base_path(path, fmt) return self.default_jupytext_for...
[ "Return", "the", "default", "formats", "if", "they", "apply", "to", "the", "current", "path", "#157" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/contentsmanager.py#L206-L216
[ "def", "default_formats", "(", "self", ",", "path", ")", ":", "formats", "=", "long_form_multiple_formats", "(", "self", ".", "default_jupytext_formats", ")", "for", "fmt", "in", "formats", ":", "try", ":", "base_path", "(", "path", ",", "fmt", ")", "return"...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
TextFileContentsManager.create_prefix_dir
Create the prefix dir, if missing
jupytext/contentsmanager.py
def create_prefix_dir(self, path, fmt): """Create the prefix dir, if missing""" create_prefix_dir(self._get_os_path(path.strip('/')), fmt)
def create_prefix_dir(self, path, fmt): """Create the prefix dir, if missing""" create_prefix_dir(self._get_os_path(path.strip('/')), fmt)
[ "Create", "the", "prefix", "dir", "if", "missing" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/contentsmanager.py#L218-L220
[ "def", "create_prefix_dir", "(", "self", ",", "path", ",", "fmt", ")", ":", "create_prefix_dir", "(", "self", ".", "_get_os_path", "(", "path", ".", "strip", "(", "'/'", ")", ")", ",", "fmt", ")" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
TextFileContentsManager.save
Save the file model and return the model with no content.
jupytext/contentsmanager.py
def save(self, model, path=''): """Save the file model and return the model with no content.""" if model['type'] != 'notebook': return super(TextFileContentsManager, self).save(model, path) nbk = model['content'] try: metadata = nbk.get('metadata') re...
def save(self, model, path=''): """Save the file model and return the model with no content.""" if model['type'] != 'notebook': return super(TextFileContentsManager, self).save(model, path) nbk = model['content'] try: metadata = nbk.get('metadata') re...
[ "Save", "the", "file", "model", "and", "return", "the", "model", "with", "no", "content", "." ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/contentsmanager.py#L222-L293
[ "def", "save", "(", "self", ",", "model", ",", "path", "=", "''", ")", ":", "if", "model", "[", "'type'", "]", "!=", "'notebook'", ":", "return", "super", "(", "TextFileContentsManager", ",", "self", ")", ".", "save", "(", "model", ",", "path", ")", ...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
TextFileContentsManager.get
Takes a path for an entity and returns its model
jupytext/contentsmanager.py
def get(self, path, content=True, type=None, format=None, load_alternative_format=True): """ Takes a path for an entity and returns its model""" path = path.strip('/') ext = os.path.splitext(path)[1] # Not a notebook? if not self.exists(path) or (type != 'notebook' if type else ...
def get(self, path, content=True, type=None, format=None, load_alternative_format=True): """ Takes a path for an entity and returns its model""" path = path.strip('/') ext = os.path.splitext(path)[1] # Not a notebook? if not self.exists(path) or (type != 'notebook' if type else ...
[ "Takes", "a", "path", "for", "an", "entity", "and", "returns", "its", "model" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/contentsmanager.py#L295-L426
[ "def", "get", "(", "self", ",", "path", ",", "content", "=", "True", ",", "type", "=", "None", ",", "format", "=", "None", ",", "load_alternative_format", "=", "True", ")", ":", "path", "=", "path", ".", "strip", "(", "'/'", ")", "ext", "=", "os", ...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
TextFileContentsManager.trust_notebook
Trust the current notebook
jupytext/contentsmanager.py
def trust_notebook(self, path): """Trust the current notebook""" if path.endswith('.ipynb') or path not in self.paired_notebooks: super(TextFileContentsManager, self).trust_notebook(path) return fmt, formats = self.paired_notebooks[path] for alt_path, alt_fmt in ...
def trust_notebook(self, path): """Trust the current notebook""" if path.endswith('.ipynb') or path not in self.paired_notebooks: super(TextFileContentsManager, self).trust_notebook(path) return fmt, formats = self.paired_notebooks[path] for alt_path, alt_fmt in ...
[ "Trust", "the", "current", "notebook" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/contentsmanager.py#L428-L437
[ "def", "trust_notebook", "(", "self", ",", "path", ")", ":", "if", "path", ".", "endswith", "(", "'.ipynb'", ")", "or", "path", "not", "in", "self", ".", "paired_notebooks", ":", "super", "(", "TextFileContentsManager", ",", "self", ")", ".", "trust_notebo...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
TextFileContentsManager.rename_file
Rename the current notebook, as well as its alternative representations
jupytext/contentsmanager.py
def rename_file(self, old_path, new_path): """Rename the current notebook, as well as its alternative representations""" if old_path not in self.paired_notebooks: try: # we do not know yet if this is a paired notebook (#190) # -> to get this information we ope...
def rename_file(self, old_path, new_path): """Rename the current notebook, as well as its alternative representations""" if old_path not in self.paired_notebooks: try: # we do not know yet if this is a paired notebook (#190) # -> to get this information we ope...
[ "Rename", "the", "current", "notebook", "as", "well", "as", "its", "alternative", "representations" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/contentsmanager.py#L439-L468
[ "def", "rename_file", "(", "self", ",", "old_path", ",", "new_path", ")", ":", "if", "old_path", "not", "in", "self", ".", "paired_notebooks", ":", "try", ":", "# we do not know yet if this is a paired notebook (#190)", "# -> to get this information we open the notebook", ...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
next_instruction_is_function_or_class
Is the first non-empty, non-commented line of the cell either a function or a class?
jupytext/pep8.py
def next_instruction_is_function_or_class(lines): """Is the first non-empty, non-commented line of the cell either a function or a class?""" for i, line in enumerate(lines): if not line.strip(): # empty line if i > 0 and not lines[i - 1].strip(): return False con...
def next_instruction_is_function_or_class(lines): """Is the first non-empty, non-commented line of the cell either a function or a class?""" for i, line in enumerate(lines): if not line.strip(): # empty line if i > 0 and not lines[i - 1].strip(): return False con...
[ "Is", "the", "first", "non", "-", "empty", "non", "-", "commented", "line", "of", "the", "cell", "either", "a", "function", "or", "a", "class?" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/pep8.py#L5-L18
[ "def", "next_instruction_is_function_or_class", "(", "lines", ")", ":", "for", "i", ",", "line", "in", "enumerate", "(", "lines", ")", ":", "if", "not", "line", ".", "strip", "(", ")", ":", "# empty line", "if", "i", ">", "0", "and", "not", "lines", "[...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
cell_ends_with_function_or_class
Does the last line of the cell belong to an indented code?
jupytext/pep8.py
def cell_ends_with_function_or_class(lines): """Does the last line of the cell belong to an indented code?""" non_quoted_lines = [] parser = StringParser('python') for line in lines: if not parser.is_quoted(): non_quoted_lines.append(line) parser.read_line(line) # find t...
def cell_ends_with_function_or_class(lines): """Does the last line of the cell belong to an indented code?""" non_quoted_lines = [] parser = StringParser('python') for line in lines: if not parser.is_quoted(): non_quoted_lines.append(line) parser.read_line(line) # find t...
[ "Does", "the", "last", "line", "of", "the", "cell", "belong", "to", "an", "indented", "code?" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/pep8.py#L21-L44
[ "def", "cell_ends_with_function_or_class", "(", "lines", ")", ":", "non_quoted_lines", "=", "[", "]", "parser", "=", "StringParser", "(", "'python'", ")", "for", "line", "in", "lines", ":", "if", "not", "parser", ".", "is_quoted", "(", ")", ":", "non_quoted_...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
cell_ends_with_code
Is the last line of the cell a line with code?
jupytext/pep8.py
def cell_ends_with_code(lines): """Is the last line of the cell a line with code?""" if not lines: return False if not lines[-1].strip(): return False if lines[-1].startswith('#'): return False return True
def cell_ends_with_code(lines): """Is the last line of the cell a line with code?""" if not lines: return False if not lines[-1].strip(): return False if lines[-1].startswith('#'): return False return True
[ "Is", "the", "last", "line", "of", "the", "cell", "a", "line", "with", "code?" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/pep8.py#L47-L55
[ "def", "cell_ends_with_code", "(", "lines", ")", ":", "if", "not", "lines", ":", "return", "False", "if", "not", "lines", "[", "-", "1", "]", ".", "strip", "(", ")", ":", "return", "False", "if", "lines", "[", "-", "1", "]", ".", "startswith", "(",...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
cell_has_code
Is there any code in this cell?
jupytext/pep8.py
def cell_has_code(lines): """Is there any code in this cell?""" for i, line in enumerate(lines): stripped_line = line.strip() if stripped_line.startswith('#'): continue # Two consecutive blank lines? if not stripped_line: if i > 0 and not lines[i - 1].str...
def cell_has_code(lines): """Is there any code in this cell?""" for i, line in enumerate(lines): stripped_line = line.strip() if stripped_line.startswith('#'): continue # Two consecutive blank lines? if not stripped_line: if i > 0 and not lines[i - 1].str...
[ "Is", "there", "any", "code", "in", "this", "cell?" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/pep8.py#L58-L73
[ "def", "cell_has_code", "(", "lines", ")", ":", "for", "i", ",", "line", "in", "enumerate", "(", "lines", ")", ":", "stripped_line", "=", "line", ".", "strip", "(", ")", "if", "stripped_line", ".", "startswith", "(", "'#'", ")", ":", "continue", "# Two...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
pep8_lines_between_cells
How many blank lines should be added between the two python paragraphs to make them pep8?
jupytext/pep8.py
def pep8_lines_between_cells(prev_lines, next_lines, ext): """How many blank lines should be added between the two python paragraphs to make them pep8?""" if not next_lines: return 1 if not prev_lines: return 0 if ext != '.py': return 1 if cell_ends_with_function_or_class(pre...
def pep8_lines_between_cells(prev_lines, next_lines, ext): """How many blank lines should be added between the two python paragraphs to make them pep8?""" if not next_lines: return 1 if not prev_lines: return 0 if ext != '.py': return 1 if cell_ends_with_function_or_class(pre...
[ "How", "many", "blank", "lines", "should", "be", "added", "between", "the", "two", "python", "paragraphs", "to", "make", "them", "pep8?" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/pep8.py#L76-L88
[ "def", "pep8_lines_between_cells", "(", "prev_lines", ",", "next_lines", ",", "ext", ")", ":", "if", "not", "next_lines", ":", "return", "1", "if", "not", "prev_lines", ":", "return", "0", "if", "ext", "!=", "'.py'", ":", "return", "1", "if", "cell_ends_wi...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
filtered_cell
Cell type, metadata and source from given cell
jupytext/compare.py
def filtered_cell(cell, preserve_outputs, cell_metadata_filter): """Cell type, metadata and source from given cell""" metadata = copy(cell.metadata) filter_metadata(metadata, cell_metadata_filter, _IGNORE_CELL_METADATA) filtered = {'cell_type': cell.cell_type, 'source': cell.source, ...
def filtered_cell(cell, preserve_outputs, cell_metadata_filter): """Cell type, metadata and source from given cell""" metadata = copy(cell.metadata) filter_metadata(metadata, cell_metadata_filter, _IGNORE_CELL_METADATA) filtered = {'cell_type': cell.cell_type, 'source': cell.source, ...
[ "Cell", "type", "metadata", "and", "source", "from", "given", "cell" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/compare.py#L16-L30
[ "def", "filtered_cell", "(", "cell", ",", "preserve_outputs", ",", "cell_metadata_filter", ")", ":", "metadata", "=", "copy", "(", "cell", ".", "metadata", ")", "filter_metadata", "(", "metadata", ",", "cell_metadata_filter", ",", "_IGNORE_CELL_METADATA", ")", "fi...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
filtered_notebook_metadata
Notebook metadata, filtered for metadata added by Jupytext itself
jupytext/compare.py
def filtered_notebook_metadata(notebook): """Notebook metadata, filtered for metadata added by Jupytext itself""" metadata = copy(notebook.metadata) metadata = filter_metadata(metadata, notebook.metadata.get('jupytext', {}).get('notebook_metadata_filter'), ...
def filtered_notebook_metadata(notebook): """Notebook metadata, filtered for metadata added by Jupytext itself""" metadata = copy(notebook.metadata) metadata = filter_metadata(metadata, notebook.metadata.get('jupytext', {}).get('notebook_metadata_filter'), ...
[ "Notebook", "metadata", "filtered", "for", "metadata", "added", "by", "Jupytext", "itself" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/compare.py#L33-L41
[ "def", "filtered_notebook_metadata", "(", "notebook", ")", ":", "metadata", "=", "copy", "(", "notebook", ".", "metadata", ")", "metadata", "=", "filter_metadata", "(", "metadata", ",", "notebook", ".", "metadata", ".", "get", "(", "'jupytext'", ",", "{", "}...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
same_content
Is the content of two cells the same, except for an optional final blank line?
jupytext/compare.py
def same_content(ref_source, test_source, allow_removed_final_blank_line): """Is the content of two cells the same, except for an optional final blank line?""" if ref_source == test_source: return True if not allow_removed_final_blank_line: return False # Is ref identical to test, plus...
def same_content(ref_source, test_source, allow_removed_final_blank_line): """Is the content of two cells the same, except for an optional final blank line?""" if ref_source == test_source: return True if not allow_removed_final_blank_line: return False # Is ref identical to test, plus...
[ "Is", "the", "content", "of", "two", "cells", "the", "same", "except", "for", "an", "optional", "final", "blank", "line?" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/compare.py#L48-L66
[ "def", "same_content", "(", "ref_source", ",", "test_source", ",", "allow_removed_final_blank_line", ")", ":", "if", "ref_source", "==", "test_source", ":", "return", "True", "if", "not", "allow_removed_final_blank_line", ":", "return", "False", "# Is ref identical to t...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
compare_notebooks
Compare the two notebooks, and raise with a meaningful message that explains the differences, if any
jupytext/compare.py
def compare_notebooks(notebook_expected, notebook_actual, fmt=None, allow_expected_differences=True, raise_on_first_difference=True, compare_outputs=False): """Compare the two notebooks, and raise with a me...
def compare_notebooks(notebook_expected, notebook_actual, fmt=None, allow_expected_differences=True, raise_on_first_difference=True, compare_outputs=False): """Compare the two notebooks, and raise with a me...
[ "Compare", "the", "two", "notebooks", "and", "raise", "with", "a", "meaningful", "message", "that", "explains", "the", "differences", "if", "any" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/compare.py#L69-L218
[ "def", "compare_notebooks", "(", "notebook_expected", ",", "notebook_actual", ",", "fmt", "=", "None", ",", "allow_expected_differences", "=", "True", ",", "raise_on_first_difference", "=", "True", ",", "compare_outputs", "=", "False", ")", ":", "fmt", "=", "long_...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
cell_source
Return the source of the current cell, as an array of lines
jupytext/cell_to_text.py
def cell_source(cell): """Return the source of the current cell, as an array of lines""" source = cell.source if source == '': return [''] if source.endswith('\n'): return source.splitlines() + [''] return source.splitlines()
def cell_source(cell): """Return the source of the current cell, as an array of lines""" source = cell.source if source == '': return [''] if source.endswith('\n'): return source.splitlines() + [''] return source.splitlines()
[ "Return", "the", "source", "of", "the", "current", "cell", "as", "an", "array", "of", "lines" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_to_text.py#L17-L24
[ "def", "cell_source", "(", "cell", ")", ":", "source", "=", "cell", ".", "source", "if", "source", "==", "''", ":", "return", "[", "''", "]", "if", "source", ".", "endswith", "(", "'\\n'", ")", ":", "return", "source", ".", "splitlines", "(", ")", ...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
endofcell_marker
Issues #31 #38: does the cell contain a blank line? In that case we add an end-of-cell marker
jupytext/cell_to_text.py
def endofcell_marker(source, comment): """Issues #31 #38: does the cell contain a blank line? In that case we add an end-of-cell marker""" endofcell = '-' while True: endofcell_re = re.compile(r'^{}( )'.format(comment) + endofcell + r'\s*$') if list(filter(endofcell_re.match, source)): ...
def endofcell_marker(source, comment): """Issues #31 #38: does the cell contain a blank line? In that case we add an end-of-cell marker""" endofcell = '-' while True: endofcell_re = re.compile(r'^{}( )'.format(comment) + endofcell + r'\s*$') if list(filter(endofcell_re.match, source)): ...
[ "Issues", "#31", "#38", ":", "does", "the", "cell", "contain", "a", "blank", "line?", "In", "that", "case", "we", "add", "an", "end", "-", "of", "-", "cell", "marker" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_to_text.py#L182-L191
[ "def", "endofcell_marker", "(", "source", ",", "comment", ")", ":", "endofcell", "=", "'-'", "while", "True", ":", "endofcell_re", "=", "re", ".", "compile", "(", "r'^{}( )'", ".", "format", "(", "comment", ")", "+", "endofcell", "+", "r'\\s*$'", ")", "i...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
BaseCellExporter.is_code
Is this cell a code cell?
jupytext/cell_to_text.py
def is_code(self): """Is this cell a code cell?""" if self.cell_type == 'code': return True if self.cell_type == 'raw' and 'active' in self.metadata: return True return False
def is_code(self): """Is this cell a code cell?""" if self.cell_type == 'code': return True if self.cell_type == 'raw' and 'active' in self.metadata: return True return False
[ "Is", "this", "cell", "a", "code", "cell?" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_to_text.py#L66-L72
[ "def", "is_code", "(", "self", ")", ":", "if", "self", ".", "cell_type", "==", "'code'", ":", "return", "True", "if", "self", ".", "cell_type", "==", "'raw'", "and", "'active'", "in", "self", ".", "metadata", ":", "return", "True", "return", "False" ]
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
BaseCellExporter.cell_to_text
Return the text representation for the cell
jupytext/cell_to_text.py
def cell_to_text(self): """Return the text representation for the cell""" if self.is_code(): return self.code_to_text() source = copy(self.source) if not self.comment: escape_code_start(source, self.ext, None) return self.markdown_to_text(source)
def cell_to_text(self): """Return the text representation for the cell""" if self.is_code(): return self.code_to_text() source = copy(self.source) if not self.comment: escape_code_start(source, self.ext, None) return self.markdown_to_text(source)
[ "Return", "the", "text", "representation", "for", "the", "cell" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_to_text.py#L74-L82
[ "def", "cell_to_text", "(", "self", ")", ":", "if", "self", ".", "is_code", "(", ")", ":", "return", "self", ".", "code_to_text", "(", ")", "source", "=", "copy", "(", "self", ".", "source", ")", "if", "not", "self", ".", "comment", ":", "escape_code...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
BaseCellExporter.markdown_to_text
Escape the given source, for a markdown cell
jupytext/cell_to_text.py
def markdown_to_text(self, source): """Escape the given source, for a markdown cell""" if self.comment and self.comment != "#'": source = copy(source) comment_magic(source, self.language, self.comment_magics) return comment_lines(source, self.comment)
def markdown_to_text(self, source): """Escape the given source, for a markdown cell""" if self.comment and self.comment != "#'": source = copy(source) comment_magic(source, self.language, self.comment_magics) return comment_lines(source, self.comment)
[ "Escape", "the", "given", "source", "for", "a", "markdown", "cell" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_to_text.py#L84-L90
[ "def", "markdown_to_text", "(", "self", ",", "source", ")", ":", "if", "self", ".", "comment", "and", "self", ".", "comment", "!=", "\"#'\"", ":", "source", "=", "copy", "(", "source", ")", "comment_magic", "(", "source", ",", "self", ".", "language", ...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
MarkdownCellExporter.cell_to_text
Return the text representation of a cell
jupytext/cell_to_text.py
def cell_to_text(self): """Return the text representation of a cell""" if self.cell_type == 'markdown': # Is an explicit region required? if self.metadata or self.cell_reader(self.fmt).read(self.source)[1] < len(self.source): if self.metadata: ...
def cell_to_text(self): """Return the text representation of a cell""" if self.cell_type == 'markdown': # Is an explicit region required? if self.metadata or self.cell_reader(self.fmt).read(self.source)[1] < len(self.source): if self.metadata: ...
[ "Return", "the", "text", "representation", "of", "a", "cell" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_to_text.py#L116-L134
[ "def", "cell_to_text", "(", "self", ")", ":", "if", "self", ".", "cell_type", "==", "'markdown'", ":", "# Is an explicit region required?", "if", "self", ".", "metadata", "or", "self", ".", "cell_reader", "(", "self", ".", "fmt", ")", ".", "read", "(", "se...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
MarkdownCellExporter.code_to_text
Return the text representation of a code cell
jupytext/cell_to_text.py
def code_to_text(self): """Return the text representation of a code cell""" source = copy(self.source) comment_magic(source, self.language, self.comment_magics) options = [] if self.cell_type == 'code' and self.language: options.append(self.language) filtere...
def code_to_text(self): """Return the text representation of a code cell""" source = copy(self.source) comment_magic(source, self.language, self.comment_magics) options = [] if self.cell_type == 'code' and self.language: options.append(self.language) filtere...
[ "Return", "the", "text", "representation", "of", "a", "code", "cell" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_to_text.py#L136-L151
[ "def", "code_to_text", "(", "self", ")", ":", "source", "=", "copy", "(", "self", ".", "source", ")", "comment_magic", "(", "source", ",", "self", ".", "language", ",", "self", ".", "comment_magics", ")", "options", "=", "[", "]", "if", "self", ".", ...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
LightScriptCellExporter.code_to_text
Return the text representation of a code cell
jupytext/cell_to_text.py
def code_to_text(self): """Return the text representation of a code cell""" active = is_active(self.ext, self.metadata) if self.language != self.default_language and 'active' not in self.metadata: active = False source = copy(self.source) escape_code_start(source, se...
def code_to_text(self): """Return the text representation of a code cell""" active = is_active(self.ext, self.metadata) if self.language != self.default_language and 'active' not in self.metadata: active = False source = copy(self.source) escape_code_start(source, se...
[ "Return", "the", "text", "representation", "of", "a", "code", "cell" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_to_text.py#L218-L255
[ "def", "code_to_text", "(", "self", ")", ":", "active", "=", "is_active", "(", "self", ".", "ext", ",", "self", ".", "metadata", ")", "if", "self", ".", "language", "!=", "self", ".", "default_language", "and", "'active'", "not", "in", "self", ".", "me...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
LightScriptCellExporter.explicit_start_marker
Does the python representation of this cell requires an explicit start of cell marker?
jupytext/cell_to_text.py
def explicit_start_marker(self, source): """Does the python representation of this cell requires an explicit start of cell marker?""" if not self.use_cell_markers: return False if self.metadata: return True if self.cell_marker_start: start_code...
def explicit_start_marker(self, source): """Does the python representation of this cell requires an explicit start of cell marker?""" if not self.use_cell_markers: return False if self.metadata: return True if self.cell_marker_start: start_code...
[ "Does", "the", "python", "representation", "of", "this", "cell", "requires", "an", "explicit", "start", "of", "cell", "marker?" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_to_text.py#L257-L275
[ "def", "explicit_start_marker", "(", "self", ",", "source", ")", ":", "if", "not", "self", ".", "use_cell_markers", ":", "return", "False", "if", "self", ".", "metadata", ":", "return", "True", "if", "self", ".", "cell_marker_start", ":", "start_code_re", "=...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
LightScriptCellExporter.remove_eoc_marker
Remove end of cell marker when next cell has an explicit start marker
jupytext/cell_to_text.py
def remove_eoc_marker(self, text, next_text): """Remove end of cell marker when next cell has an explicit start marker""" if self.cell_marker_start: return text if self.is_code() and text[-1] == self.comment + ' -': # remove end of cell marker when redundant with next ex...
def remove_eoc_marker(self, text, next_text): """Remove end of cell marker when next cell has an explicit start marker""" if self.cell_marker_start: return text if self.is_code() and text[-1] == self.comment + ' -': # remove end of cell marker when redundant with next ex...
[ "Remove", "end", "of", "cell", "marker", "when", "next", "cell", "has", "an", "explicit", "start", "marker" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_to_text.py#L277-L300
[ "def", "remove_eoc_marker", "(", "self", ",", "text", ",", "next_text", ")", ":", "if", "self", ".", "cell_marker_start", ":", "return", "text", "if", "self", ".", "is_code", "(", ")", "and", "text", "[", "-", "1", "]", "==", "self", ".", "comment", ...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
LightScriptCellExporter.simplify_soc_marker
Simplify start of cell marker when previous line is blank
jupytext/cell_to_text.py
def simplify_soc_marker(self, text, prev_text): """Simplify start of cell marker when previous line is blank""" if self.cell_marker_start: return text if self.is_code() and text and text[0] == self.comment + ' + {}': if not prev_text or not prev_text[-1].strip(): ...
def simplify_soc_marker(self, text, prev_text): """Simplify start of cell marker when previous line is blank""" if self.cell_marker_start: return text if self.is_code() and text and text[0] == self.comment + ' + {}': if not prev_text or not prev_text[-1].strip(): ...
[ "Simplify", "start", "of", "cell", "marker", "when", "previous", "line", "is", "blank" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_to_text.py#L302-L311
[ "def", "simplify_soc_marker", "(", "self", ",", "text", ",", "prev_text", ")", ":", "if", "self", ".", "cell_marker_start", ":", "return", "text", "if", "self", ".", "is_code", "(", ")", "and", "text", "and", "text", "[", "0", "]", "==", "self", ".", ...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
RScriptCellExporter.code_to_text
Return the text representation of a code cell
jupytext/cell_to_text.py
def code_to_text(self): """Return the text representation of a code cell""" active = is_active(self.ext, self.metadata) source = copy(self.source) escape_code_start(source, self.ext, self.language) if active: comment_magic(source, self.language, self.comment_magics) ...
def code_to_text(self): """Return the text representation of a code cell""" active = is_active(self.ext, self.metadata) source = copy(self.source) escape_code_start(source, self.ext, self.language) if active: comment_magic(source, self.language, self.comment_magics) ...
[ "Return", "the", "text", "representation", "of", "a", "code", "cell" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_to_text.py#L327-L346
[ "def", "code_to_text", "(", "self", ")", ":", "active", "=", "is_active", "(", "self", ".", "ext", ",", "self", ".", "metadata", ")", "source", "=", "copy", "(", "self", ".", "source", ")", "escape_code_start", "(", "source", ",", "self", ".", "ext", ...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
DoublePercentCellExporter.cell_to_text
Return the text representation for the cell
jupytext/cell_to_text.py
def cell_to_text(self): """Return the text representation for the cell""" if self.cell_type != 'code': self.metadata['cell_type'] = self.cell_type active = is_active('py', self.metadata) if self.language != self.default_language and 'active' not in self.metadata: ...
def cell_to_text(self): """Return the text representation for the cell""" if self.cell_type != 'code': self.metadata['cell_type'] = self.cell_type active = is_active('py', self.metadata) if self.language != self.default_language and 'active' not in self.metadata: ...
[ "Return", "the", "text", "representation", "for", "the", "cell" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_to_text.py#L354-L378
[ "def", "cell_to_text", "(", "self", ")", ":", "if", "self", ".", "cell_type", "!=", "'code'", ":", "self", ".", "metadata", "[", "'cell_type'", "]", "=", "self", ".", "cell_type", "active", "=", "is_active", "(", "'py'", ",", "self", ".", "metadata", "...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
SphinxGalleryCellExporter.cell_to_text
Return the text representation for the cell
jupytext/cell_to_text.py
def cell_to_text(self): """Return the text representation for the cell""" if self.cell_type == 'code': source = copy(self.source) return comment_magic(source, self.language, self.comment_magics) if 'cell_marker' in self.metadata: cell_marker = self.metadata.p...
def cell_to_text(self): """Return the text representation for the cell""" if self.cell_type == 'code': source = copy(self.source) return comment_magic(source, self.language, self.comment_magics) if 'cell_marker' in self.metadata: cell_marker = self.metadata.p...
[ "Return", "the", "text", "representation", "for", "the", "cell" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/cell_to_text.py#L406-L424
[ "def", "cell_to_text", "(", "self", ")", ":", "if", "self", ".", "cell_type", "==", "'code'", ":", "source", "=", "copy", "(", "self", ".", "source", ")", "return", "comment_magic", "(", "source", ",", "self", ".", "language", ",", "self", ".", "commen...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
pandoc
Execute pandoc with the given arguments
jupytext/pandoc.py
def pandoc(args, filein=None, fileout=None): """Execute pandoc with the given arguments""" cmd = [u'pandoc'] if filein: cmd.append(filein) if fileout: cmd.append('-o') cmd.append(fileout) cmd.extend(args.split()) proc = subprocess.Popen(cmd, stdout=subprocess.PIPE) ...
def pandoc(args, filein=None, fileout=None): """Execute pandoc with the given arguments""" cmd = [u'pandoc'] if filein: cmd.append(filein) if fileout: cmd.append('-o') cmd.append(fileout) cmd.extend(args.split()) proc = subprocess.Popen(cmd, stdout=subprocess.PIPE) ...
[ "Execute", "pandoc", "with", "the", "given", "arguments" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/pandoc.py#L15-L32
[ "def", "pandoc", "(", "args", ",", "filein", "=", "None", ",", "fileout", "=", "None", ")", ":", "cmd", "=", "[", "u'pandoc'", "]", "if", "filein", ":", "cmd", ".", "append", "(", "filein", ")", "if", "fileout", ":", "cmd", ".", "append", "(", "'...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
pandoc_version
Pandoc's version number
jupytext/pandoc.py
def pandoc_version(): """Pandoc's version number""" version = pandoc(u'--version').splitlines()[0].split()[1] if parse_version(version) < parse_version('2.7.2'): raise PandocError('Please install pandoc>=2.7.2 (found version {})'.format(version)) return version
def pandoc_version(): """Pandoc's version number""" version = pandoc(u'--version').splitlines()[0].split()[1] if parse_version(version) < parse_version('2.7.2'): raise PandocError('Please install pandoc>=2.7.2 (found version {})'.format(version)) return version
[ "Pandoc", "s", "version", "number" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/pandoc.py#L44-L50
[ "def", "pandoc_version", "(", ")", ":", "version", "=", "pandoc", "(", "u'--version'", ")", ".", "splitlines", "(", ")", "[", "0", "]", ".", "split", "(", ")", "[", "1", "]", "if", "parse_version", "(", "version", ")", "<", "parse_version", "(", "'2....
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
md_to_notebook
Convert a Markdown text to a Jupyter notebook, using Pandoc
jupytext/pandoc.py
def md_to_notebook(text): """Convert a Markdown text to a Jupyter notebook, using Pandoc""" tmp_file = tempfile.NamedTemporaryFile(delete=False) tmp_file.write(text.encode('utf-8')) tmp_file.close() pandoc(u'--from markdown --to ipynb -s --atx-headers --wrap=preserve --preserve-tabs', tmp_file.name...
def md_to_notebook(text): """Convert a Markdown text to a Jupyter notebook, using Pandoc""" tmp_file = tempfile.NamedTemporaryFile(delete=False) tmp_file.write(text.encode('utf-8')) tmp_file.close() pandoc(u'--from markdown --to ipynb -s --atx-headers --wrap=preserve --preserve-tabs', tmp_file.name...
[ "Convert", "a", "Markdown", "text", "to", "a", "Jupyter", "notebook", "using", "Pandoc" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/pandoc.py#L53-L65
[ "def", "md_to_notebook", "(", "text", ")", ":", "tmp_file", "=", "tempfile", ".", "NamedTemporaryFile", "(", "delete", "=", "False", ")", "tmp_file", ".", "write", "(", "text", ".", "encode", "(", "'utf-8'", ")", ")", "tmp_file", ".", "close", "(", ")", ...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
notebook_to_md
Convert a notebook to its Markdown representation, using Pandoc
jupytext/pandoc.py
def notebook_to_md(notebook): """Convert a notebook to its Markdown representation, using Pandoc""" tmp_file = tempfile.NamedTemporaryFile(delete=False) tmp_file.write(ipynb_writes(notebook).encode('utf-8')) tmp_file.close() pandoc(u'--from ipynb --to markdown -s --atx-headers --wrap=preserve --pre...
def notebook_to_md(notebook): """Convert a notebook to its Markdown representation, using Pandoc""" tmp_file = tempfile.NamedTemporaryFile(delete=False) tmp_file.write(ipynb_writes(notebook).encode('utf-8')) tmp_file.close() pandoc(u'--from ipynb --to markdown -s --atx-headers --wrap=preserve --pre...
[ "Convert", "a", "notebook", "to", "its", "Markdown", "representation", "using", "Pandoc" ]
mwouts/jupytext
python
https://github.com/mwouts/jupytext/blob/eb7d6aee889f80ad779cfc53441c648f0db9246d/jupytext/pandoc.py#L68-L80
[ "def", "notebook_to_md", "(", "notebook", ")", ":", "tmp_file", "=", "tempfile", ".", "NamedTemporaryFile", "(", "delete", "=", "False", ")", "tmp_file", ".", "write", "(", "ipynb_writes", "(", "notebook", ")", ".", "encode", "(", "'utf-8'", ")", ")", "tmp...
eb7d6aee889f80ad779cfc53441c648f0db9246d
train
_int_size
Return the smallest size int that can store the value
python/pywatchman/pybser.py
def _int_size(x): """Return the smallest size int that can store the value""" if -0x80 <= x <= 0x7F: return 1 elif -0x8000 <= x <= 0x7FFF: return 2 elif -0x80000000 <= x <= 0x7FFFFFFF: return 4 elif long(-0x8000000000000000) <= x <= long(0x7FFFFFFFFFFFFFFF): return 8 ...
def _int_size(x): """Return the smallest size int that can store the value""" if -0x80 <= x <= 0x7F: return 1 elif -0x8000 <= x <= 0x7FFF: return 2 elif -0x80000000 <= x <= 0x7FFFFFFF: return 4 elif long(-0x8000000000000000) <= x <= long(0x7FFFFFFFFFFFFFFF): return 8 ...
[ "Return", "the", "smallest", "size", "int", "that", "can", "store", "the", "value" ]
facebook/watchman
python
https://github.com/facebook/watchman/blob/d416c249dd8f463dc69fc2691d0f890598c045a9/python/pywatchman/pybser.py#L75-L86
[ "def", "_int_size", "(", "x", ")", ":", "if", "-", "0x80", "<=", "x", "<=", "0x7F", ":", "return", "1", "elif", "-", "0x8000", "<=", "x", "<=", "0x7FFF", ":", "return", "2", "elif", "-", "0x80000000", "<=", "x", "<=", "0x7FFFFFFF", ":", "return", ...
d416c249dd8f463dc69fc2691d0f890598c045a9
train
loads
Deserialize a BSER-encoded blob. @param buf: The buffer to deserialize. @type buf: bytes @param mutable: Whether to return mutable results. @type mutable: bool @param value_encoding: Optional codec to use to decode values. If unspecified or None, return values as bytest...
python/pywatchman/pybser.py
def loads(buf, mutable=True, value_encoding=None, value_errors=None): """Deserialize a BSER-encoded blob. @param buf: The buffer to deserialize. @type buf: bytes @param mutable: Whether to return mutable results. @type mutable: bool @param value_encoding: Optional codec to use to decode value...
def loads(buf, mutable=True, value_encoding=None, value_errors=None): """Deserialize a BSER-encoded blob. @param buf: The buffer to deserialize. @type buf: bytes @param mutable: Whether to return mutable results. @type mutable: bool @param value_encoding: Optional codec to use to decode value...
[ "Deserialize", "a", "BSER", "-", "encoded", "blob", "." ]
facebook/watchman
python
https://github.com/facebook/watchman/blob/d416c249dd8f463dc69fc2691d0f890598c045a9/python/pywatchman/pybser.py#L498-L530
[ "def", "loads", "(", "buf", ",", "mutable", "=", "True", ",", "value_encoding", "=", "None", ",", "value_errors", "=", "None", ")", ":", "info", "=", "_pdu_info_helper", "(", "buf", ")", "expected_len", "=", "info", "[", "2", "]", "pos", "=", "info", ...
d416c249dd8f463dc69fc2691d0f890598c045a9
train
run_command
The stdout of most fbcode_builder utilities is meant to be parsed.
build/fbcode_builder/utils.py
def run_command(*cmd, **kwargs): 'The stdout of most fbcode_builder utilities is meant to be parsed.' logging.debug('Running: {0} with {1}'.format(cmd, kwargs)) kwargs['stdout'] = sys.stderr subprocess.check_call(cmd, **kwargs)
def run_command(*cmd, **kwargs): 'The stdout of most fbcode_builder utilities is meant to be parsed.' logging.debug('Running: {0} with {1}'.format(cmd, kwargs)) kwargs['stdout'] = sys.stderr subprocess.check_call(cmd, **kwargs)
[ "The", "stdout", "of", "most", "fbcode_builder", "utilities", "is", "meant", "to", "be", "parsed", "." ]
facebook/watchman
python
https://github.com/facebook/watchman/blob/d416c249dd8f463dc69fc2691d0f890598c045a9/build/fbcode_builder/utils.py#L26-L30
[ "def", "run_command", "(", "*", "cmd", ",", "*", "*", "kwargs", ")", ":", "logging", ".", "debug", "(", "'Running: {0} with {1}'", ".", "format", "(", "cmd", ",", "kwargs", ")", ")", "kwargs", "[", "'stdout'", "]", "=", "sys", ".", "stderr", "subproces...
d416c249dd8f463dc69fc2691d0f890598c045a9
train
_inner_read_config
Helper to read a named config file. The grossness with the global is a workaround for this python bug: https://bugs.python.org/issue21591 The bug prevents us from defining either a local function or a lambda in the scope of read_fbcode_builder_config below.
build/fbcode_builder/utils.py
def _inner_read_config(path): ''' Helper to read a named config file. The grossness with the global is a workaround for this python bug: https://bugs.python.org/issue21591 The bug prevents us from defining either a local function or a lambda in the scope of read_fbcode_builder_config below. ...
def _inner_read_config(path): ''' Helper to read a named config file. The grossness with the global is a workaround for this python bug: https://bugs.python.org/issue21591 The bug prevents us from defining either a local function or a lambda in the scope of read_fbcode_builder_config below. ...
[ "Helper", "to", "read", "a", "named", "config", "file", ".", "The", "grossness", "with", "the", "global", "is", "a", "workaround", "for", "this", "python", "bug", ":", "https", ":", "//", "bugs", ".", "python", ".", "org", "/", "issue21591", "The", "bu...
facebook/watchman
python
https://github.com/facebook/watchman/blob/d416c249dd8f463dc69fc2691d0f890598c045a9/build/fbcode_builder/utils.py#L42-L52
[ "def", "_inner_read_config", "(", "path", ")", ":", "global", "_project_dir", "full_path", "=", "os", ".", "path", ".", "join", "(", "_project_dir", ",", "path", ")", "return", "read_fbcode_builder_config", "(", "full_path", ")" ]
d416c249dd8f463dc69fc2691d0f890598c045a9
train
steps_for_spec
Sets `builder` configuration, and returns all the builder steps necessary to build `spec` and its dependencies. Traverses the dependencies in depth-first order, honoring the sequencing in each 'depends_on' list.
build/fbcode_builder/utils.py
def steps_for_spec(builder, spec, processed_modules=None): ''' Sets `builder` configuration, and returns all the builder steps necessary to build `spec` and its dependencies. Traverses the dependencies in depth-first order, honoring the sequencing in each 'depends_on' list. ''' if processed...
def steps_for_spec(builder, spec, processed_modules=None): ''' Sets `builder` configuration, and returns all the builder steps necessary to build `spec` and its dependencies. Traverses the dependencies in depth-first order, honoring the sequencing in each 'depends_on' list. ''' if processed...
[ "Sets", "builder", "configuration", "and", "returns", "all", "the", "builder", "steps", "necessary", "to", "build", "spec", "and", "its", "dependencies", "." ]
facebook/watchman
python
https://github.com/facebook/watchman/blob/d416c249dd8f463dc69fc2691d0f890598c045a9/build/fbcode_builder/utils.py#L70-L90
[ "def", "steps_for_spec", "(", "builder", ",", "spec", ",", "processed_modules", "=", "None", ")", ":", "if", "processed_modules", "is", "None", ":", "processed_modules", "=", "set", "(", ")", "steps", "=", "[", "]", "for", "module", "in", "spec", ".", "g...
d416c249dd8f463dc69fc2691d0f890598c045a9
train
vcpkg_dir
Figure out where vcpkg is installed. vcpkg-exported is populated in some flavors of FB internal builds. C:/tools/vcpkg is the appveyor location. C:/open/vcpkg is my local location.
getdeps.py
def vcpkg_dir(): """ Figure out where vcpkg is installed. vcpkg-exported is populated in some flavors of FB internal builds. C:/tools/vcpkg is the appveyor location. C:/open/vcpkg is my local location. """ for p in ["vcpkg-exported", "C:/tools/vcpkg", "C:/open/vcpkg"]: if os.path.isdir(p...
def vcpkg_dir(): """ Figure out where vcpkg is installed. vcpkg-exported is populated in some flavors of FB internal builds. C:/tools/vcpkg is the appveyor location. C:/open/vcpkg is my local location. """ for p in ["vcpkg-exported", "C:/tools/vcpkg", "C:/open/vcpkg"]: if os.path.isdir(p...
[ "Figure", "out", "where", "vcpkg", "is", "installed", ".", "vcpkg", "-", "exported", "is", "populated", "in", "some", "flavors", "of", "FB", "internal", "builds", ".", "C", ":", "/", "tools", "/", "vcpkg", "is", "the", "appveyor", "location", ".", "C", ...
facebook/watchman
python
https://github.com/facebook/watchman/blob/d416c249dd8f463dc69fc2691d0f890598c045a9/getdeps.py#L285-L294
[ "def", "vcpkg_dir", "(", ")", ":", "for", "p", "in", "[", "\"vcpkg-exported\"", ",", "\"C:/tools/vcpkg\"", ",", "\"C:/open/vcpkg\"", "]", ":", "if", "os", ".", "path", ".", "isdir", "(", "p", ")", ":", "return", "os", ".", "path", ".", "realpath", "(",...
d416c249dd8f463dc69fc2691d0f890598c045a9
train
synthesize
Synthesize a capability enabled version response This is a very limited emulation for relatively recent feature sets
python/pywatchman/capabilities.py
def synthesize(vers, opts): """ Synthesize a capability enabled version response This is a very limited emulation for relatively recent feature sets """ parsed_version = parse_version(vers["version"]) vers["capabilities"] = {} for name in opts["optional"]: vers["capabilities"][name] ...
def synthesize(vers, opts): """ Synthesize a capability enabled version response This is a very limited emulation for relatively recent feature sets """ parsed_version = parse_version(vers["version"]) vers["capabilities"] = {} for name in opts["optional"]: vers["capabilities"][name] ...
[ "Synthesize", "a", "capability", "enabled", "version", "response", "This", "is", "a", "very", "limited", "emulation", "for", "relatively", "recent", "feature", "sets" ]
facebook/watchman
python
https://github.com/facebook/watchman/blob/d416c249dd8f463dc69fc2691d0f890598c045a9/python/pywatchman/capabilities.py#L59-L77
[ "def", "synthesize", "(", "vers", ",", "opts", ")", ":", "parsed_version", "=", "parse_version", "(", "vers", "[", "\"version\"", "]", ")", "vers", "[", "\"capabilities\"", "]", "=", "{", "}", "for", "name", "in", "opts", "[", "\"optional\"", "]", ":", ...
d416c249dd8f463dc69fc2691d0f890598c045a9
train
shell_quote
Quotes a string if it is not already quoted
build/fbcode_builder/shell_quoting.py
def shell_quote(s): 'Quotes a string if it is not already quoted' return s if isinstance(s, ShellQuoted) \ else ShellQuoted("'" + str(s).replace("'", "'\\''") + "'")
def shell_quote(s): 'Quotes a string if it is not already quoted' return s if isinstance(s, ShellQuoted) \ else ShellQuoted("'" + str(s).replace("'", "'\\''") + "'")
[ "Quotes", "a", "string", "if", "it", "is", "not", "already", "quoted" ]
facebook/watchman
python
https://github.com/facebook/watchman/blob/d416c249dd8f463dc69fc2691d0f890598c045a9/build/fbcode_builder/shell_quoting.py#L69-L72
[ "def", "shell_quote", "(", "s", ")", ":", "return", "s", "if", "isinstance", "(", "s", ",", "ShellQuoted", ")", "else", "ShellQuoted", "(", "\"'\"", "+", "str", "(", "s", ")", ".", "replace", "(", "\"'\"", ",", "\"'\\\\''\"", ")", "+", "\"'\"", ")" ]
d416c249dd8f463dc69fc2691d0f890598c045a9
train
raw_shell
Not a member of ShellQuoted so we get a useful error for raw strings
build/fbcode_builder/shell_quoting.py
def raw_shell(s): 'Not a member of ShellQuoted so we get a useful error for raw strings' if isinstance(s, ShellQuoted): return s.do_not_use_raw_str raise RuntimeError('{0} should have been ShellQuoted'.format(s))
def raw_shell(s): 'Not a member of ShellQuoted so we get a useful error for raw strings' if isinstance(s, ShellQuoted): return s.do_not_use_raw_str raise RuntimeError('{0} should have been ShellQuoted'.format(s))
[ "Not", "a", "member", "of", "ShellQuoted", "so", "we", "get", "a", "useful", "error", "for", "raw", "strings" ]
facebook/watchman
python
https://github.com/facebook/watchman/blob/d416c249dd8f463dc69fc2691d0f890598c045a9/build/fbcode_builder/shell_quoting.py#L75-L79
[ "def", "raw_shell", "(", "s", ")", ":", "if", "isinstance", "(", "s", ",", "ShellQuoted", ")", ":", "return", "s", ".", "do_not_use_raw_str", "raise", "RuntimeError", "(", "'{0} should have been ShellQuoted'", ".", "format", "(", "s", ")", ")" ]
d416c249dd8f463dc69fc2691d0f890598c045a9
train
shell_join
Joins an iterable of ShellQuoted with a delimiter between each two
build/fbcode_builder/shell_quoting.py
def shell_join(delim, it): 'Joins an iterable of ShellQuoted with a delimiter between each two' return ShellQuoted(delim.join(raw_shell(s) for s in it))
def shell_join(delim, it): 'Joins an iterable of ShellQuoted with a delimiter between each two' return ShellQuoted(delim.join(raw_shell(s) for s in it))
[ "Joins", "an", "iterable", "of", "ShellQuoted", "with", "a", "delimiter", "between", "each", "two" ]
facebook/watchman
python
https://github.com/facebook/watchman/blob/d416c249dd8f463dc69fc2691d0f890598c045a9/build/fbcode_builder/shell_quoting.py#L82-L84
[ "def", "shell_join", "(", "delim", ",", "it", ")", ":", "return", "ShellQuoted", "(", "delim", ".", "join", "(", "raw_shell", "(", "s", ")", "for", "s", "in", "it", ")", ")" ]
d416c249dd8f463dc69fc2691d0f890598c045a9
train
path_join
Joins ShellQuoted and raw pieces of paths to make a shell-quoted path
build/fbcode_builder/shell_quoting.py
def path_join(*args): 'Joins ShellQuoted and raw pieces of paths to make a shell-quoted path' return ShellQuoted(os.path.join(*[ raw_shell(shell_quote(s)) for s in args ]))
def path_join(*args): 'Joins ShellQuoted and raw pieces of paths to make a shell-quoted path' return ShellQuoted(os.path.join(*[ raw_shell(shell_quote(s)) for s in args ]))
[ "Joins", "ShellQuoted", "and", "raw", "pieces", "of", "paths", "to", "make", "a", "shell", "-", "quoted", "path" ]
facebook/watchman
python
https://github.com/facebook/watchman/blob/d416c249dd8f463dc69fc2691d0f890598c045a9/build/fbcode_builder/shell_quoting.py#L87-L91
[ "def", "path_join", "(", "*", "args", ")", ":", "return", "ShellQuoted", "(", "os", ".", "path", ".", "join", "(", "*", "[", "raw_shell", "(", "shell_quote", "(", "s", ")", ")", "for", "s", "in", "args", "]", ")", ")" ]
d416c249dd8f463dc69fc2691d0f890598c045a9
train
shell_comment
Do not shell-escape raw strings in comments, but do handle line breaks.
build/fbcode_builder/shell_quoting.py
def shell_comment(c): 'Do not shell-escape raw strings in comments, but do handle line breaks.' return ShellQuoted('# {c}').format(c=ShellQuoted( (raw_shell(c) if isinstance(c, ShellQuoted) else c) .replace('\n', '\n# ') ))
def shell_comment(c): 'Do not shell-escape raw strings in comments, but do handle line breaks.' return ShellQuoted('# {c}').format(c=ShellQuoted( (raw_shell(c) if isinstance(c, ShellQuoted) else c) .replace('\n', '\n# ') ))
[ "Do", "not", "shell", "-", "escape", "raw", "strings", "in", "comments", "but", "do", "handle", "line", "breaks", "." ]
facebook/watchman
python
https://github.com/facebook/watchman/blob/d416c249dd8f463dc69fc2691d0f890598c045a9/build/fbcode_builder/shell_quoting.py#L94-L99
[ "def", "shell_comment", "(", "c", ")", ":", "return", "ShellQuoted", "(", "'# {c}'", ")", ".", "format", "(", "c", "=", "ShellQuoted", "(", "(", "raw_shell", "(", "c", ")", "if", "isinstance", "(", "c", ",", "ShellQuoted", ")", "else", "c", ")", ".",...
d416c249dd8f463dc69fc2691d0f890598c045a9
train
State.resolve_dep
Locate dep in the search path; if found, return its path. If not found in the search path, and the dep is not a system-provided dep, raise an error
winbuild/copy-dyn-deps.py
def resolve_dep(self, depname): """ Locate dep in the search path; if found, return its path. If not found in the search path, and the dep is not a system-provided dep, raise an error """ for d in self._search_path: name = os.path.join(d, depname) if self._mock: ...
def resolve_dep(self, depname): """ Locate dep in the search path; if found, return its path. If not found in the search path, and the dep is not a system-provided dep, raise an error """ for d in self._search_path: name = os.path.join(d, depname) if self._mock: ...
[ "Locate", "dep", "in", "the", "search", "path", ";", "if", "found", "return", "its", "path", ".", "If", "not", "found", "in", "the", "search", "path", "and", "the", "dep", "is", "not", "a", "system", "-", "provided", "dep", "raise", "an", "error" ]
facebook/watchman
python
https://github.com/facebook/watchman/blob/d416c249dd8f463dc69fc2691d0f890598c045a9/winbuild/copy-dyn-deps.py#L147-L166
[ "def", "resolve_dep", "(", "self", ",", "depname", ")", ":", "for", "d", "in", "self", ".", "_search_path", ":", "name", "=", "os", ".", "path", ".", "join", "(", "d", ",", "depname", ")", "if", "self", ".", "_mock", ":", "return", "name", "if", ...
d416c249dd8f463dc69fc2691d0f890598c045a9
train
State.resolve_dep_from_path
If we can find the dep in the PATH, then we consider it to be a system dependency that we should not bundle in the package
winbuild/copy-dyn-deps.py
def resolve_dep_from_path(self, depname): """ If we can find the dep in the PATH, then we consider it to be a system dependency that we should not bundle in the package """ if is_system_dep(depname): return True for d in self._path: name = os.path.join(d, depname...
def resolve_dep_from_path(self, depname): """ If we can find the dep in the PATH, then we consider it to be a system dependency that we should not bundle in the package """ if is_system_dep(depname): return True for d in self._path: name = os.path.join(d, depname...
[ "If", "we", "can", "find", "the", "dep", "in", "the", "PATH", "then", "we", "consider", "it", "to", "be", "a", "system", "dependency", "that", "we", "should", "not", "bundle", "in", "the", "package" ]
facebook/watchman
python
https://github.com/facebook/watchman/blob/d416c249dd8f463dc69fc2691d0f890598c045a9/winbuild/copy-dyn-deps.py#L168-L179
[ "def", "resolve_dep_from_path", "(", "self", ",", "depname", ")", ":", "if", "is_system_dep", "(", "depname", ")", ":", "return", "True", "for", "d", "in", "self", ".", "_path", ":", "name", "=", "os", ".", "path", ".", "join", "(", "d", ",", "depnam...
d416c249dd8f463dc69fc2691d0f890598c045a9