Home | Trees | Indices | Help |
|
---|
|
1 # This file is part of pybliographer 2 # 3 # Copyright (C) 1998-2006 Frederic GOBRY 4 # Email : gobry@pybliographer.org 5 # 6 # This program is free software; you can redistribute it and/or 7 # modify it under the terms of the GNU General Public License 8 # as published by the Free Software Foundation; either version 2 9 # of the License, or (at your option) any later version. 10 # 11 # This program is distributed in the hope that it will be useful, 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 # GNU General Public License for more details. 15 # 16 # You should have received a copy of the GNU General Public License 17 # along with this program; if not, write to the Free Software 18 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 # 2022 23 """ Return an identifier, possibly taking into account a proposed 24 id. """ 25 26 if proposed: 27 if proposed >= last: last = proposed + 1 28 29 else: 30 proposed = last 31 last = last + 1 32 33 return last, proposed34 3537 38 ''' Format a string on a given width ''' 39 40 out = [] 41 current = first 42 43 # if the entry does not fit the current width 44 while len (string) > width - current: 45 46 pos = width - next - 1 47 48 # search a previous space 49 while pos > 0 and string [pos] <> ' ': 50 pos = pos - 1 51 52 # if there is no space before... 53 if pos == 0: 54 pos = width - current 55 taille = len (string) 56 while pos < taille and string [pos] <> ' ': 57 pos = pos + 1 58 59 out.append (' ' * current + string [0:pos]) 60 string = string [pos+1:] 61 current = next 62 63 out.append (' ' * current + string) 64 65 return '\n'.join (out).rstrip ()66
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0beta1 on Thu Sep 13 21:54:25 2007 | http://epydoc.sourceforge.net |