MCPcopy Index your code
hub / github.com/danfengcao/binlog2sql / create_unique_file

Function create_unique_file

binlog2sql/binlog2sql_util.py:32–41  ·  view source on GitHub ↗
(filename)

Source from the content-addressed store, hash-verified

30
31
32def create_unique_file(filename):
33 version = 0
34 result_file = filename
35 # if we have to try more than 1000 times, something is seriously wrong
36 while os.path.exists(result_file) and version < 1000:
37 result_file = filename + '.' + str(version)
38 version += 1
39 if version >= 1000:
40 raise OSError('cannot create unique file %s.[0-1000]' % filename)
41 return result_file
42
43
44@contextmanager

Callers 2

process_binlogMethod · 0.90

Calls

no outgoing calls

Tested by 1