加载README.md并显示
(self, path='')
| 94 | |
| 95 | @pyqtSlot(str) |
| 96 | def renderReadme(self, path=''): |
| 97 | """加载README.md并显示 |
| 98 | """ |
| 99 | path = path.replace('\\', '/') |
| 100 | if not path: |
| 101 | path = os.path.join(Constants.DirProjects, 'README.md') |
| 102 | Constants.CurrentReadme = '' |
| 103 | elif path.count('/') == 0: |
| 104 | path = os.path.join(Constants.DirCurrent, path, 'README.md') |
| 105 | Constants.CurrentReadme = path |
| 106 | elif not path.endswith('README.md'): |
| 107 | path = path + '/README.md' |
| 108 | Constants.CurrentReadme = path |
| 109 | if not os.path.exists(path): |
| 110 | AppLog.debug('{} not exists'.format(path)) |
| 111 | self._runJs('updateText("");') |
| 112 | return |
| 113 | if not os.path.isfile(path): |
| 114 | AppLog.warn('file {} not exists'.format(path)) |
| 115 | return |
| 116 | Constants.DirCurrent = os.path.dirname(path).replace('\\', '/') |
| 117 | AppLog.debug('DirCurrent change to: {}'.format(Constants.DirCurrent)) |
| 118 | AppLog.debug('render: {}'.format(path)) |
| 119 | Constants.CurrentReadme = path # 记录打开的路径防止重复加载 |
| 120 | AppLog.debug('readme dir: {}'.format(Constants.DirCurrent)) |
| 121 | content = repr(open(path, 'rb').read().decode()) |
| 122 | self._runJs("updateText({});".format(content)) |
| 123 | |
| 124 | def _exposeInterface(self): |
| 125 | """向Js暴露调用本地方法接口 |
no test coverage detected