MCPcopy Create free account
hub / github.com/PyQt5/PyQtClient / renderReadme

Method renderReadme

Widgets/MainWindow.py:96–122  ·  view source on GitHub ↗

加载README.md并显示

(self, path='')

Source from the content-addressed store, hash-verified

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暴露调用本地方法接口

Callers 3

on_buttonHead_clickedMethod · 0.80
on_buttonHome_clickedMethod · 0.80
renderReadmeFunction · 0.80

Calls 2

_runJsMethod · 0.95
countMethod · 0.45

Tested by

no test coverage detected