Debian Codegraph @

test cases/common/227 very long command line/name_gen.py

raw
1 #!/usr/bin/env python3
2 """
3 generate sequence of filename that does not exceed MAX_LEN=260
4 for Python < 3.6 and Windows without modified registry
5 """
6
7 import sys
8 import string
9
10 name_len = 260 - len(sys.argv[2]) - 4 - 39 - 4 - 2
11 if name_len < 1:
12 raise ValueError('The meson build directory pathname is so long '
13 'that we cannot generate filenames within 260 characters.')
14 # leave room for suffix and file separators, and meson generated text
15 # e.g. ".c.obj.d" and other decorators added by Meson at configuration
16 # for intermediate files
17
18 base = string.ascii_letters * 5 # 260 characters
19 max_num_len = len(str(sys.argv[1]))
20 base = base[: name_len - max_num_len]
21
22 for i in range(int(sys.argv[1])):
23 print("{base}{i:0{max_num_len}d}".format(base=base, max_num_len=max_num_len, i=i))