/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/generate_ids.py

  • Committer: Martin
  • Date: 2017-06-10 01:57:00 UTC
  • mto: This revision was merged to the branch mainline in revision 6679.
  • Revision ID: gzlist@googlemail.com-20170610015700-o3xeuyaqry2obiay
Go back to native str for urls and many other py3 changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
59
59
    #           suffix forever.
60
60
    global _gen_file_id_suffix, _gen_file_id_serial
61
61
    if _gen_file_id_suffix is None:
62
 
        _gen_file_id_suffix = "-%s-%s-" % (osutils.compact_date(time.time()),
63
 
                                           osutils.rand_chars(16))
 
62
        _gen_file_id_suffix =  ("-%s-%s-" % (
 
63
                osutils.compact_date(time.time()), osutils.rand_chars(16))
 
64
            ).encode("ascii")
64
65
    _gen_file_id_serial += 1
65
 
    return _gen_file_id_suffix + str(_gen_file_id_serial)
 
66
    return b"%s%d" % (_gen_file_id_suffix, _gen_file_id_serial)
66
67
 
67
68
 
68
69
def gen_file_id(name):
81
82
    #    filesystems
82
83
    # 4) Removing starting '.' characters to prevent the file ids from
83
84
    #    being considered hidden.
84
 
    ascii_word_only = str(_file_id_chars_re.sub('', name.lower()))
85
 
    short_no_dots = ascii_word_only.lstrip('.')[:20]
 
85
    ascii_word_only = _file_id_chars_re.sub('', name.lower()).encode('ascii')
 
86
    short_no_dots = ascii_word_only.lstrip(b'.')[:20]
86
87
    return short_no_dots + _next_id_suffix()
87
88
 
88
89