• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript coreutils.PathExt类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中@jupyterlab/coreutils.PathExt的典型用法代码示例。如果您正苦于以下问题:TypeScript PathExt类的具体用法?TypeScript PathExt怎么用?TypeScript PathExt使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了PathExt类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: constructor

 /**
  * Construct a new "rename" dialog.
  */
 constructor(oldPath: string) {
   super({ node: Private.createRenameNode(oldPath) });
   this.addClass(FILE_DIALOG_CLASS);
   let ext = PathExt.extname(oldPath);
   let value = (this.inputNode.value = PathExt.basename(oldPath));
   this.inputNode.setSelectionRange(0, value.length - ext.length);
 }
开发者ID:afshin,项目名称:jupyterlab,代码行数:10,代码来源:dialogs.ts


示例2: renameFile

 }).then(result => {
   if (!result.value) {
     return null;
   }
   let basePath = PathExt.dirname(oldPath);
   let newPath = PathExt.join(basePath, result.value);
   return renameFile(manager, oldPath, newPath);
 });
开发者ID:cameronoelsen,项目名称:jupyterlab,代码行数:8,代码来源:dialogs.ts


示例3: diffNotebookCheckpoint

function diffNotebookCheckpoint(args: {readonly path: string, readonly rendermime: IRenderMimeRegistry}): Widget {
  const {path, rendermime} = args;
  let nb_dir = PathExt.dirname(path);
  let name = PathExt.basename(path, '.ipynb');
  let base = PathExt.join(nb_dir, name + '.ipynb');
  let widget = new NbdimeWidget({base, rendermime, baseLabel: 'Checkpoint'});
  widget.title.label = `Diff checkpoint: ${name}`;
  widget.title.caption = `Local: latest checkpoint\nRemote: '${path}'`;
  widget.title.iconClass = 'fa fa-clock-o jp-fa-tabIcon';
  return widget;
}
开发者ID:vidartf,项目名称:nbdime,代码行数:11,代码来源:actions.ts


示例4: showErrorMessage

 }).then(result => {
   if (!isValidFileName(result.value)) {
     showErrorMessage('Rename Error', Error(
         `"${result.value}" is not a valid name for a file. ` +
         `Names must have nonzero length, ` +
         `and cannot include "/", "\\", or ":"`
     ));
     return null;
   }
   let basePath = PathExt.dirname(oldPath);
   let newPath = PathExt.join(basePath, result.value);
   return renameFile(manager, oldPath, newPath);
 });
开发者ID:SimonBiggs,项目名称:jupyterlab,代码行数:13,代码来源:dialogs.ts


示例5:

    execute: () => {
      let widget = tracker.currentWidget.content;

      if (!widget) {
        return;
      }

      let code = '';
      let editor = widget.editor;
      let text = editor.model.value.text;
      let path = widget.context.path;
      let extension = PathExt.extname(path);

      if (MarkdownCodeBlocks.isMarkdown(extension)) {
        // For Markdown files, run only code blocks.
        const blocks = MarkdownCodeBlocks.findMarkdownCodeBlocks(text);
        for (let block of blocks) {
          code += block.code;
        }
      } else {
        code = text;
      }

      const activate = false;
      if (code) {
        return commands.execute('console:inject', { activate, code, path });
      } else {
        return Promise.resolve(void 0);
      }
    },
开发者ID:AlbertHilb,项目名称:jupyterlab,代码行数:30,代码来源:index.ts


示例6: hasGitNotebook

  /**
   * Whether the notebook is in a git repository.
   */
  function hasGitNotebook(): boolean {
    if (!baseEnabled()) {
      return false;
    }

    let path = tracker.currentWidget!.context.path;
    let dir = PathExt.dirname(path);
    let known_git = lut_known_git[dir];
    if (known_git === undefined) {
      const inGitPromise = isNbInGit({path: dir});
      inGitPromise.then(inGit => {
        networkRetry = INITIAL_NETWORK_RETRY;
        lut_known_git[dir] = inGit;
        // Only update if false, since it is left enabled while waiting
        if (!inGit) {
          commands.notifyCommandChanged(CommandIDs.diffNotebookGit);
        }
      });
      inGitPromise.catch((reason) => {
        hasAPI = reason.status !== undefined && reason.status !== 404;
        setTimeout(() => {
          networkRetry *= 2;
          commands.notifyCommandChanged(CommandIDs.diffNotebook);
          commands.notifyCommandChanged(CommandIDs.diffNotebookCheckpoint);
          commands.notifyCommandChanged(CommandIDs.diffNotebookGit);
        }, networkRetry);
      });
      // Leave button enabled while unsure
      return true;
    }

    return known_git;
  }
开发者ID:vidartf,项目名称:nbdime,代码行数:36,代码来源:plugin.ts


示例7: getMimeTypeByFilePath

 /**
  * Returns a mime type for the given file path.
  *
  * #### Notes
  * If a mime type cannot be found returns the default mime type `text/plain`, never `null`.
  */
 getMimeTypeByFilePath(path: string): string {
   if (PathExt.extname(path) === '.ipy') {
     return 'text/x-python';
   }
   let mode = Mode.findByFileName(path) || Mode.findBest('');
   return mode.mime;
 }
开发者ID:cameronoelsen,项目名称:jupyterlab,代码行数:13,代码来源:mimetype.ts


示例8: getMimeTypeByFilePath

 /**
  * Returns a mime type for the given file path.
  *
  * #### Notes
  * If a mime type cannot be found returns the defaul mime type `text/plain`, never `null`.
  */
 getMimeTypeByFilePath(path: string): string {
   if (PathExt.extname(path) === '.ipy') {
     return 'text/x-python';
   }
   const mode = CodeMirror.findModeByFileName(path);
   return mode ? mode.mime : IEditorMimeTypeService.defaultMimeType;
 }
开发者ID:charnpreetsingh185,项目名称:jupyterlab,代码行数:13,代码来源:mimetype.ts


示例9: diffNotebookGit

function diffNotebookGit(args: {readonly path: string, readonly rendermime: IRenderMimeRegistry}): Widget {
  const {path, rendermime} = args;
  let name = PathExt.basename(path, '.ipynb');
  let widget = new NbdimeWidget({base: path, rendermime});
  widget.title.label = `Diff git: ${name}`;
  widget.title.caption = `Local: git HEAD\nRemote: '${path}'`;
  widget.title.iconClass = 'fa fa-git jp-fa-tabIcon';
  return widget;
}
开发者ID:vidartf,项目名称:nbdime,代码行数:9,代码来源:actions.ts


示例10: _evtDrop

  /**
   * Handle the `'p-drop'` event for the widget.
   */
  private _evtDrop(event: IDragEvent): void {
    event.preventDefault();
    event.stopPropagation();
    if (event.proposedAction === 'none') {
      event.dropAction = 'none';
      return;
    }
    if (!event.mimeData.hasData(CONTENTS_MIME)) {
      return;
    }
    event.dropAction = event.proposedAction;

    let target = event.target as HTMLElement;
    while (target && target.parentElement) {
      if (target.classList.contains(DROP_TARGET_CLASS)) {
        target.classList.remove(DROP_TARGET_CLASS);
        break;
      }
      target = target.parentElement;
    }

    // Get the path based on the target node.
    let index = ArrayExt.findFirstIndex(this._crumbs, node => node === target);
    if (index === -1) {
      return;
    }

    const model = this._model;
    const path = PathExt.resolve(model.path, BREAD_CRUMB_PATHS[index]);
    const manager = model.manager;

    // Move all of the items.
    let promises: Promise<any>[] = [];
    let oldPaths = event.mimeData.getData(CONTENTS_MIME) as string[];
    for (let oldPath of oldPaths) {
      let localOldPath = manager.services.contents.localPath(oldPath);
      let name = PathExt.basename(localOldPath);
      let newPath = PathExt.join(path, name);
      promises.push(renameFile(manager, oldPath, newPath));
    }
    Promise.all(promises).catch(err => {
      showErrorMessage('Move Error', err);
    });
  }
开发者ID:7125messi,项目名称:jupyterlab,代码行数:47,代码来源:crumbs.ts



注:本文中的@jupyterlab/coreutils.PathExt类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript coreutils.Poll类代码示例发布时间:2022-05-28
下一篇:
TypeScript coreutils.PageConfig类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap