예제 #1
0
    def short_list(self, width=0):
        '''
        Return a shortened list of overlay information.

        @params width: int specifying terminal width.
        @rtype str: string of overlay information.
        '''
        if len(self.name) > 25:
            name = self.name + "   ###\n"
            name += pad(" ", 25)
        else:
            name = pad(self.name, 25)

        if len(set(e.type for e in self.sources)) == 1:
            _type = self.sources[0].type
        else:
            _type = '%s/..' % self.sources[0].type

        mtype = ' [' + pad(_type, 10) + ']'
        if not width:
            width = terminal_width() - 1
        srclen = width - 43
        source = ', '.join(self.source_uris())
        if len(source) > srclen:
            source = source.replace("overlays.gentoo.org", "o.g.o")
        source = ' (' + pad(source, srclen) + ')'

        return encoder(name + mtype + source, self._encoding_)
예제 #2
0
파일: overlay.py 프로젝트: dewey/layman
    def short_list(self, width = 0):
        '''
        Return a shortened list of overlay information.

        @params width: int specifying terminal width.
        @rtype str: string of overlay information.
        '''
        if len(self.name) > 25:
            name = self.name + "   ###\n"
            name += pad(" ", 25)
        else:
            name   = pad(self.name, 25)

        if len(set(e.type for e in self.sources)) == 1:
            _type = self.sources[0].type
        else:
            _type = '%s/..' % self.sources[0].type

        mtype  = ' [' + pad(_type, 10) + ']'
        if not width:
            width = terminal_width()-1
        srclen = width - 43
        source = ', '.join(self.source_uris())
        if len(source) > srclen:
            source = source.replace("overlays.gentoo.org", "o.g.o")
        source = ' (' + pad(source, srclen) + ')'

        return encoder(name + mtype + source, self._encoding_)
예제 #3
0
파일: overlay.py 프로젝트: dwfreed/layman
    def short_list(self, width = 0):
        '''
        >>> here = os.path.dirname(os.path.realpath(__file__))
        >>> import xml.etree.ElementTree as ET # Python 2.5
        >>> document =ET.parse(here + '/../tests/testfiles/global-overlays.xml')
        >>> overlays = document.findall('repo') + document.findall('overlay')
        >>> from layman.output import Message
        >>> output = Message()
        >>> a = Overlay({'output': output}, overlays[0])
        >>> print a.short_list(80)
        wrobel                    [Subversion] (https://o.g.o/svn/dev/wrobel         )
        '''
        if len(self.name) > 25:
            name = self.name + "   ###\n"
            name += pad(" ", 25)
        else:
            name   = pad(self.name, 25)

        if len(set(e.type for e in self.sources)) == 1:
            _type = self.sources[0].type
        else:
            _type = '%s/..' % self.sources[0].type

        mtype  = ' [' + pad(_type, 10) + ']'
        if not width:
            width = terminal_width()-1
        srclen = width - 43
        source = ', '.join(self.source_uris())
        if len(source) > srclen:
            source = source.replace("overlays.gentoo.org", "o.g.o")
        source = ' (' + pad(source, srclen) + ')'

        return encoder(name + mtype + source, self._encoding_)
예제 #4
0
파일: cli.py 프로젝트: vaeth/layman
 def __init__(self, config):
     self.config = config
     self.output = self.config['output']
     if not self.config['width']:
         self.width = terminal_width() - 1
     else:
         self.width = self.config['width']
     self.srclen = self.width - 43
     self._encoding_ = get_encoding(self.output)
     if config['verbose']:
         self.my_lister = self.short_list  # self.long_list
     else:
         self.my_lister = self.short_list
예제 #5
0
파일: cli.py 프로젝트: gentoo/layman
 def __init__(self, config):
     self.config = config
     self.output = self.config['output']
     if not self.config['width']:
         self.width = terminal_width()-1
     else:
         self.width = self.config['width']
     self.srclen = self.width - 43
     self._encoding_ = get_encoding(self.output)
     if config['verbose']:
         self.my_lister = self.short_list # self.long_list
     else:
         self.my_lister = self.short_list