def post(self): base_nb = self.get_notebook_argument('base') local_nb = self.get_notebook_argument('local') remote_nb = self.get_notebook_argument('remote') merge_args = self.settings.get('merge_args') if merge_args is None: merge_args = build_merge_parser().parse_args(['', '', '']) merge_args.merge_strategy = 'mergetool' self.settings['merge_args'] = merge_args try: decisions = decide_notebook_merge(base_nb, local_nb, remote_nb, args=merge_args) except Exception: nbdime.log.exception('Error merging documents:') raise web.HTTPError(500, 'Error while attempting to merge documents') data = {'base': base_nb, 'merge_decisions': decisions} self.finish(data)
def post(self): base_nb = self.get_notebook_argument("base") local_nb = self.get_notebook_argument("local") remote_nb = self.get_notebook_argument("remote") merge_args = self.settings.get('merge_args') if merge_args is None: merge_args = build_merge_parser().parse_args(["", "", ""]) merge_args.merge_strategy = 'mergetool' self.settings['merge_args'] = merge_args try: decisions = decide_notebook_merge(base_nb, local_nb, remote_nb, args=merge_args) except Exception: nbdime.log.exception("Error merging documents:") raise web.HTTPError(500, "Error while attempting to merge documents") data = { "base": base_nb, "merge_decisions": decisions } self.finish(data)
def post(self): base_nb = self.get_notebook_argument("base") local_nb = self.get_notebook_argument("local") remote_nb = self.get_notebook_argument("remote") merge_args = self.settings.get('merge_args') if merge_args is None: merge_args = build_merge_parser().parse_args(["", "", ""]) merge_args.merge_strategy = 'mergetool' self.settings['merge_args'] = merge_args try: decisions = decide_notebook_merge(base_nb, local_nb, remote_nb, args=merge_args) except Exception: nbdime.log.exception("Error merging documents:") raise web.HTTPError(500, "Error while attempting to merge documents") data = {"base": base_nb, "merge_decisions": decisions} self.finish(data)
def post(self): base_nb = self.get_notebook_argument('base') local_nb = self.get_notebook_argument('local') remote_nb = self.get_notebook_argument('remote') merge_args = self.settings.get('merge_args') if merge_args is None: merge_args = build_merge_parser().parse_args(['', '', '']) merge_args.merge_strategy = 'mergetool' self.settings['merge_args'] = merge_args try: decisions = decide_notebook_merge(base_nb, local_nb, remote_nb, args=merge_args) except Exception: nbdime.log.exception('Error merging documents:') raise web.HTTPError(500, 'Error while attempting to merge documents') data = { 'base': base_nb, 'merge_decisions': decisions } self.finish(data)
from nbdime.merging.notebooks import decide_notebook_merge from nbdime.nbmergeapp import _build_arg_parser as build_merge_parser from nbdime.args import add_generic_args, add_web_args # TODO: See <notebook>/notebook/services/contents/handlers.py for possibly useful utilities: #@json_errors #contents_manager #ContentsHandler #APIHandler here = os.path.abspath(os.path.dirname(__file__)) static_path = os.path.join(here, "static") template_path = os.path.join(here, "templates") merge_args = build_merge_parser().parse_args( ["--merge-strategy", "mergetool", "", "", ""]) exit_code = 0 def truncate_filename(name): limit = 20 if len(name) < limit: return name else: return name[:limit - 3] + "..." class NbdimeApiHandler(web.RequestHandler): def initialize(self, **params): self.params = params