コード例 #1
0
ファイル: manager.py プロジェクト: OmarIthawi/explainshell
    def run(self):
        added = []
        exists = []
        for path in self.paths:
            try:
                m = manpage.manpage(path)
                logger.info('handling manpage %s (from %s)', m.name, path)
                try:
                    name, section = util.namesection(m.shortpath[:-3])
                    mps = self.store.findmanpage(name, section)
                    mps = [mp for mp in mps if m.shortpath == mp.source]
                    if mps:
                        assert len(mps) == 1
                        mp = mps[0]
                        if not self.overwrite or mp.updated:
                            logger.info('manpage %r already in store, not overwriting it', m.name)
                            exists.append(m)
                            continue
                except errors.ProgramDoesNotExist:
                    pass

                ctx = self.ctx(m)
                m = self.process(ctx)
                if m:
                    added.append(m)
            except errors.EmptyManpage, e:
                logger.error('manpage %r is empty!', e.args[0])
            except ValueError:
                logger.fatal('uncaught exception when handling manpage %s', path)
コード例 #2
0
    def run(self):
        added = []
        exists = []
        for path in self.paths:
            try:
                m = manpage.manpage(path)
                logger.info('handling manpage %s (from %s)', m.name, path)
                try:
                    name, section = util.namesection(m.shortpath[:-3])
                    mps = self.store.findmanpage(name, section)
                    mps = [mp for mp in mps if m.shortpath == mp.source]
                    if mps:
                        assert len(mps) == 1
                        mp = mps[0]
                        if not self.overwrite or mp.updated:
                            logger.info(
                                'manpage %r already in store, not overwriting it',
                                m.name)
                            exists.append(m)
                            continue
                except errors.ProgramDoesNotExist:
                    pass

                ctx = self.ctx(m)
                m = self.process(ctx)
                if m:
                    added.append(m)
            except errors.EmptyManpage, e:
                logger.error('manpage %r is empty!', e.args[0])
            except ValueError:
                logger.fatal('uncaught exception when handling manpage %s',
                             path)
コード例 #3
0
ファイル: manager.py プロジェクト: MayankAgarwal/explainshell
    def run(self):
        added = []
        exists = []
        for path in self.paths:
            try:
                m = manpage.manpage(path)
                logger.info('handling manpage %s (from %s)', m.name, path)
                try:
                    mps = self.store.findmanpage(m.shortpath[:-3])
                    mps = [mp for mp in mps if m.shortpath == mp.source]
                    if mps:
                        assert len(mps) == 1
                        mp = mps[0]
                        if not self.overwrite or mp.updated:
                            logger.info('manpage %r already in the data store, not overwriting it', m.name)
                            exists.append(m)
                            continue
                except errors.ProgramDoesNotExist:
                    pass

                # the manpage is not in the data store; process and add it
                ctx = self.ctx(m)
                m = self.process(ctx)
                if m:
                    added.append(m)
            except errors.EmptyManpage as e:
                logger.error('manpage %r is empty!', e.args[0])
            except ValueError as err:
                logger.fatal('uncaught exception when handling manpage %s', path)
                logger.fatal('Exception: %s', str(err))
            except KeyboardInterrupt:
                raise
            except:
                logger.fatal('uncaught exception when handling manpage %s', path)
                raise
        if not added:
            logger.warn('no manpages added')
        else:
            self.findmulticommands()

        return added, exists
コード例 #4
0
 def test_no_synopsis(self):
     m = manpage.manpage('foo')
     m._text = 'a b c d e f g h i j k l'.replace(' ', '\n')
     m.parse()
     self.assertEquals(m.aliases, [('foo', 10)])