doc/book/mode_plan.py
author Aurelien Campeas <aurelien.campeas@logilab.fr>
Mon, 12 Apr 2010 16:57:11 +0200
branchstable
changeset 5221 b851558456bb
parent 1977 606923dff11b
child 5421 8167de96c523
permissions -rw-r--r--
[doc/book] remove merged chapter
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
127
ae611743f5c6 [doc] divided book in parts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
     1
"""
ae611743f5c6 [doc] divided book in parts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
     2
>>> from mode_plan import *
ae611743f5c6 [doc] divided book in parts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
     3
>>> ls()
ae611743f5c6 [doc] divided book in parts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
     4
<list of directory content>
ae611743f5c6 [doc] divided book in parts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
     5
>>> ren('A01','A03')
ae611743f5c6 [doc] divided book in parts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
     6
rename A010-joe.en.txt to A030-joe.en.txt
ae611743f5c6 [doc] divided book in parts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
     7
accept [y/N]?
1977
606923dff11b big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 127
diff changeset
     8
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
127
ae611743f5c6 [doc] divided book in parts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
     9
"""
ae611743f5c6 [doc] divided book in parts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    10
ae611743f5c6 [doc] divided book in parts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    11
def ren(a,b):
ae611743f5c6 [doc] divided book in parts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    12
    names = glob.glob('%s*'%a)
ae611743f5c6 [doc] divided book in parts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    13
    for name in names :
ae611743f5c6 [doc] divided book in parts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    14
        print 'rename %s to %s' % (name, name.replace(a,b))
ae611743f5c6 [doc] divided book in parts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    15
    if raw_input('accept [y/N]?').lower() =='y':
ae611743f5c6 [doc] divided book in parts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    16
        for name in names:
ae611743f5c6 [doc] divided book in parts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    17
            os.system('hg mv %s %s' % (name, name.replace(a,b)))
ae611743f5c6 [doc] divided book in parts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    18
ae611743f5c6 [doc] divided book in parts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    19
ae611743f5c6 [doc] divided book in parts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    20
def ls(): print '\n'.join(sorted(os.listdir('.')))
ae611743f5c6 [doc] divided book in parts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    21
ae611743f5c6 [doc] divided book in parts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    22
def move():
ae611743f5c6 [doc] divided book in parts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    23
    filenames = []
ae611743f5c6 [doc] divided book in parts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    24
    for name in sorted(os.listdir('.')):
ae611743f5c6 [doc] divided book in parts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    25
        num = name[:2]
ae611743f5c6 [doc] divided book in parts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    26
        if num.isdigit():
ae611743f5c6 [doc] divided book in parts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    27
            filenames.append( (int(num), name) )
ae611743f5c6 [doc] divided book in parts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    28
ae611743f5c6 [doc] divided book in parts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    29
ae611743f5c6 [doc] divided book in parts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    30
    #print filenames
ae611743f5c6 [doc] divided book in parts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    31
ae611743f5c6 [doc] divided book in parts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    32
    for num, name in filenames:
ae611743f5c6 [doc] divided book in parts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    33
        if num >= start:
ae611743f5c6 [doc] divided book in parts
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    34
            print 'hg mv %s %2i%s' %(name,num+1,name[2:])