A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-checkins/2002-October/030340.html below:

[Python-checkins] python/dist/src/Lib calendar.py,1.29,1.30

[Python-checkins] python/dist/src/Lib calendar.py,1.29,1.30rhettinger@users.sourceforge.net rhettinger@users.sourceforge.net
Mon, 21 Oct 2002 22:15:20 -0700
Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv21185

Modified Files:
	calendar.py 
Log Message:
Patches #626105:

Replaces the _center function in the calendar
module with the center method for strings.

For situations with uneven padding, the behavior is 
slightly different in that the center method puts the 
extra space on the right instead of the left.



Index: calendar.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/calendar.py,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -d -r1.29 -r1.30
*** calendar.py	21 Oct 2002 03:08:20 -0000	1.29
--- calendar.py	22 Oct 2002 05:15:17 -0000	1.30
***************
*** 123,133 ****
      return rows
  
- def _center(str, width):
-     """Center a string in a field."""
-     n = width - len(str)
-     if n <= 0:
-         return str
-     return ' '*((n+1)/2) + str + ' '*((n)/2)
- 
  def prweek(theweek, width):
      """Print a single week (no newline)."""
--- 123,126 ----
***************
*** 142,146 ****
          else:
              s = '%2i' % day             # right-align single-digit days
!         days.append(_center(s, width))
      return ' '.join(days)
  
--- 135,139 ----
          else:
              s = '%2i' % day             # right-align single-digit days
!         days.append(s.center(width))
      return ' '.join(days)
  
***************
*** 153,157 ****
      days = []
      for i in range(_firstweekday, _firstweekday + 7):
!         days.append(_center(names[i%7][:width], width))
      return ' '.join(days)
  
--- 146,150 ----
      days = []
      for i in range(_firstweekday, _firstweekday + 7):
!         days.append(names[i%7][:width].center(width))
      return ' '.join(days)
  
***************
*** 164,168 ****
      w = max(2, w)
      l = max(1, l)
!     s = (_center(month_name[themonth] + ' ' + `theyear`,
                   7 * (w + 1) - 1).rstrip() +
           '\n' * l + weekheader(w).rstrip() + '\n' * l)
--- 157,161 ----
      w = max(2, w)
      l = max(1, l)
!     s = ((month_name[themonth] + ' ' + `theyear`).center(
                   7 * (w + 1) - 1).rstrip() +
           '\n' * l + weekheader(w).rstrip() + '\n' * l)
***************
*** 181,186 ****
  def format3cstring(a, b, c, colwidth=_colwidth, spacing=_spacing):
      """Returns a string formatted from 3 strings, centered within 3 columns."""
!     return (_center(a, colwidth) + ' ' * spacing + _center(b, colwidth) +
!             ' ' * spacing + _center(c, colwidth))
  
  def prcal(year, w=0, l=0, c=_spacing):
--- 174,179 ----
  def format3cstring(a, b, c, colwidth=_colwidth, spacing=_spacing):
      """Returns a string formatted from 3 strings, centered within 3 columns."""
!     return (a.center(colwidth) + ' ' * spacing + b.center(colwidth) +
!             ' ' * spacing + c.center(colwidth))
  
  def prcal(year, w=0, l=0, c=_spacing):
***************
*** 194,198 ****
      c = max(2, c)
      colwidth = (w + 1) * 7 - 1
!     s = _center(`year`, colwidth * 3 + c * 2).rstrip() + '\n' * l
      header = weekheader(w)
      header = format3cstring(header, header, header, colwidth, c).rstrip()
--- 187,191 ----
      c = max(2, c)
      colwidth = (w + 1) * 7 - 1
!     s = `year`.center(colwidth * 3 + c * 2).rstrip() + '\n' * l
      header = weekheader(w)
      header = format3cstring(header, header, header, colwidth, c).rstrip()





RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4