~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: Martin Pool
  • Date: 2005-05-02 04:37:13 UTC
  • Revision ID: mbp@sourcefrog.net-20050502043713-23c8c2663d774e34
- remove trivial chomp() function

Show diffs side-by-side

added added

removed removed

Lines of Context:
84
84
 
85
85
def uuid():
86
86
    """Return a new UUID"""
87
 
    
88
 
    ## XXX: Could alternatively read /proc/sys/kernel/random/uuid on
89
 
    ## Linux, but we need something portable for other systems;
90
 
    ## preferably an implementation in Python.
91
87
    try:
92
 
        return chomp(file('/proc/sys/kernel/random/uuid').readline())
 
88
        return file('/proc/sys/kernel/random/uuid').readline().rstrip('\n')
93
89
    except IOError:
94
90
        return chomp(os.popen('uuidgen').readline())
95
91
 
96
92
 
97
 
def chomp(s):
98
 
    if s and (s[-1] == '\n'):
99
 
        return s[:-1]
100
 
    else:
101
 
        return s
102
 
 
103
 
 
104
93
def sha_file(f):
105
94
    import sha
106
95
    ## TODO: Maybe read in chunks to handle big files