Python string.rjust() Examples

The following are 7 code examples for showing how to use string.rjust(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

You may check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module string , or try the search function .

Example 1
Project: Penetration-Testing-Study-Notes   Author: AnasAboureada   File: scythe.py    License: MIT License 6 votes vote down vote up
def logo():
    # because ASCII-art is the future!

    logo = '''
                                                            ,,
                                                     mm   `7MM
                                                     MM     MM
                        ,pP"Ybd  ,p6"bo `7M'   `MF'mmMMmm   MMpMMMb.  .gP"Ya
                        8I   `" 6M'  OO   VA   ,V    MM     MM    MM ,M'   Yb
                        `YMMMa. 8M         VA ,V     MM     MM    MM 8M""""""
                        L.   I8 YM.    ,    VVV      MM     MM    MM YM.    ,
                        M9mmmP'  YMbmd'     ,V       `Mbmo.JMML  JMML.`Mbmmd'
                                           ,V
                                        OOb"      ::: account harvester :::'''

    # add version, codename and maintainer to logo
    print logo
    print string.rjust('ver ' + __version__ + ' (' + __codename__ + ')', 74)
    print string.rjust(__maintainer__, 73) 
Example 2
Project: Offensive-Security-Certified-Professional   Author: StevenDias33   File: scythe.py    License: MIT License 6 votes vote down vote up
def logo():
    # because ASCII-art is the future!

    logo = '''
                                                            ,,
                                                     mm   `7MM
                                                     MM     MM
                        ,pP"Ybd  ,p6"bo `7M'   `MF'mmMMmm   MMpMMMb.  .gP"Ya
                        8I   `" 6M'  OO   VA   ,V    MM     MM    MM ,M'   Yb
                        `YMMMa. 8M         VA ,V     MM     MM    MM 8M""""""
                        L.   I8 YM.    ,    VVV      MM     MM    MM YM.    ,
                        M9mmmP'  YMbmd'     ,V       `Mbmo.JMML  JMML.`Mbmmd'
                                           ,V
                                        OOb"      ::: account harvester :::'''

    # add version, codename and maintainer to logo
    print logo
    print string.rjust('ver ' + __version__ + ' (' + __codename__ + ')', 74)
    print string.rjust(__maintainer__, 73) 
Example 3
Project: pentest-notes   Author: wwong99   File: scythe.py    License: MIT License 6 votes vote down vote up
def logo():
    # because ASCII-art is the future!

    logo = '''
                                                            ,,
                                                     mm   `7MM
                                                     MM     MM
                        ,pP"Ybd  ,p6"bo `7M'   `MF'mmMMmm   MMpMMMb.  .gP"Ya
                        8I   `" 6M'  OO   VA   ,V    MM     MM    MM ,M'   Yb
                        `YMMMa. 8M         VA ,V     MM     MM    MM 8M""""""
                        L.   I8 YM.    ,    VVV      MM     MM    MM YM.    ,
                        M9mmmP'  YMbmd'     ,V       `Mbmo.JMML  JMML.`Mbmmd'
                                           ,V
                                        OOb"      ::: account harvester :::'''

    # add version, codename and maintainer to logo
    print logo
    print string.rjust('ver ' + __version__ + ' (' + __codename__ + ')', 74)
    print string.rjust(__maintainer__, 73) 
Example 4
Project: lic   Author: remig   File: LicAssistantWidget.py    License: GNU General Public License v3.0 5 votes vote down vote up
def job_1S(self):
        if self.destItem:
            self._warning.setText( string.rjust(self._processingText, self._thumbSize) )
            self.window().setCursor(Qt.WaitCursor)
                            
            self.scene.setFocus(Qt.MouseFocusReason)
            self.scene.setFocusItem(self.destItem , Qt.MouseFocusReason)
            self.destItem.setSelected(True) 
Example 5
Project: lic   Author: remig   File: LicAssistantWidget.py    License: GNU General Public License v3.0 4 votes vote down vote up
def moveItemToStep(self):
        self._warning.clear()
        if self._item is not None:
            self.scene = self._item.scene()
            srcPage = self._item.getStep().parentItem()      
            try:
                self.destItem = self.scene.selectedItems()[0]
            except IndexError:
                self.destItem = None
            
            # Find Step assigned to currently selected item
            if self.destItem and self.destItem.__class__.__name__ != "Page":
                while self.destItem and not isinstance(self.destItem, Step):
                    try:
                        self.destItem = self.destItem.parent()
                    except:
                        break
            
            # Convert Page to first step on the list
            if self.destItem and self.destItem.__class__.__name__ == "Page":
                if srcPage.number == self.destItem.number:
                    self._warning.setText(self._noMoveText)
                else:
                    if self.destItem.steps:
                        self.destItem = self.destItem.steps[0]
                    else:
                        self._warning.setText(self._noEmptyText)
                    
            # Find the selected item's parent page, then flip to that page
            # Move Part into Step
            canMove = True
            message = ""
            if isinstance(self.destItem, Step):
                destPage = self.destItem.parentItem()
                
                if srcPage.number == destPage.number:
                    canMove = False
                    message = self._noMoveText
                     
                if destPage.isLocked():
                    canMove = False
                    message = self._lockedPageText
                    
                if destPage.isEmpty():
                    canMove = False
                    message = self._noEmptyText
                
                if destPage.__class__.__name__.lower() in ['titlepage' , 'templatepage' ,'partlistpage']:
                    canMove = False
                    message = self._noSpecialPage
                 
                if canMove:        
                    self._worker.start([self.job_1S , self.job_2 , self.job_3])
                
            if message:
                self._warning.setText(string.rjust(message, self._thumbSize)) 
Example 6
Project: BioBlender   Author: MonZop   File: structures.py    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
def __str__(self):
        """
            Returns a string of the new atom type.  Uses the ATOM string
            output but changes the first field to either by ATOM or
            HETATM as necessary.

            Returns
                str: String with ATOM/HETATM field set appropriately
        """
        str = ""
        tstr = self.type
        str = str + string.ljust(tstr, 6)[:6]
        tstr = "%d" % self.serial
        str = str + string.rjust(tstr, 5)[:5]
        str = str + " "
        tstr = self.name
        if len(tstr) == 4 or len(tstr.strip("FLIP")) == 4:
            str = str + string.ljust(tstr, 4)[:4]
        else:
            str = str + " " + string.ljust(tstr, 3)[:3]

        tstr = self.resName
        if len(tstr) == 4:
            str = str + string.ljust(tstr, 4)[:4]
        else:
            str = str + " " + string.ljust(tstr, 3)[:3]
            
        str = str + " "
        tstr = self.chainID
        str = str + string.ljust(tstr, 1)[:1]
        tstr = "%d" % self.resSeq
        str = str + string.rjust(tstr, 4)[:4]
        if self.iCode != "":
            str = str + "%s   " % self.iCode
        else:
            str = str + "    "
        tstr = "%8.3f" % self.x
        str = str + string.ljust(tstr, 8)[:8]
        tstr = "%8.3f" % self.y
        str = str + string.ljust(tstr, 8)[:8]
        tstr = "%8.3f" % self.z
        str = str + string.ljust(tstr, 8)[:8]
        if self.ffcharge != None: ffcharge = "%.4f" % self.ffcharge
        else: ffcharge = "0.0000"
        str = str + string.rjust(ffcharge, 8)[:8]
        if self.radius != None: ffradius = "%.4f" % self.radius
        else: ffradius = "0.0000"
        str = str + string.rjust(ffradius, 7)[:7]
        return str 
Example 7
Project: BioBlender   Author: MonZop   File: pdb.py    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
def readAtom(line):
    """
        If the ATOM/HETATM is not column-formatted, try to get some
        information by parsing whitespace from the right.  Look for
        five floating point numbers followed by the residue number.

        Parameters
            line:  The line to parse(string)
       if record == ATOM:
            self.serial = int(string.strip(line[6:11]))
            self.name = string.strip(line[12:16])
            self.altLoc = string.strip(line[16])
            self.resName = string.strip(line[17:20])
            self.chainID = string.strip(line[21])
            self.resSeq = int(string.strip(line[22:26]))
            self.iCode = string.strip(line[26])
            self.x = float(string.strip(line[30:38]))
            self.y = float(string.strip(line[38:46]))
            self.z = float(string.strip(line[46:54]))
            try:
                self.occupancy = float(string.strip(line[54:60]))
                self.tempFactor = float(string.strip(line[60:66]))
                self.segID = string.strip(line[72:76])
                self.element = string.strip(line[76:78])
                self.charge = string.strip(line[78:80])
            except ValueError, IndexError:
                self.occupancy = 0.00
                self.tempFactor = 0.00
                self.segID = 0
                self.element = 0
                self.charge = 0
        else: raise ValueError, record
    """

    # Try to find 5 consecutive floats
    words = string.split(line)
    size = len(words) - 1
    consec = 0
    for i in range(size):
        entry = words[size - i]
        try:
            val = float(entry)
            consec = consec + 1
            if consec == 5:      
                break                
        except ValueError:
            consec = 0

    record = string.strip(line[0:6])
    newline = line[0:22]
    newline = newline + string.rjust(words[size-i-1],4)
    newline = newline + string.rjust("",3)
    newline = newline + string.rjust(words[size-i],8)
    newline = newline + string.rjust(words[size-i+1],8)
    newline = newline + string.rjust(words[size-i+2],8)
    newline = newline + string.rjust(words[size-i+3],6)
    newline = newline + string.rjust(words[size-i+4],6)
    cmdstr = "%s(newline)" % record
    obj = eval(cmdstr)
    return obj