Menu

[3b00ec]: / scripts / modeline.py  Maximize  Restore  History

Download this file

17 lines (12 with data), 389 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
import sys
modline = "// -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*-\n\n"
for path in sys.argv[1:]:
lines = [modline]
with file(path) as f:
lines += f.readlines()
has_modeline = any([l for l in lines[1:] if l.find('Mode: c++') != -1])
if has_modeline:
continue
with file(path, 'w') as f:
for line in lines:
f.write(line)
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.