Projet

Général

Profil

Demande #4566 » remove_owners_and_editors.py

François Poulain, 17/08/2020 19:30

 
#!/usr/bin/env python3
import glob, re

section = re.compile(r'\s*\n+\s*\n+')
owner_editor_section = re.compile(r'^(owner|editor)(\n(visibility|reception|gecos|profile|email) [^\n]+)+$')

def clean_config(config):
sections = section.split(config)
cleaned_sections = [s for s in sections if not owner_editor_section.match(s)]
return '\n\n'.join(cleaned_sections)


for config_filename in glob.glob('expl/*/*/config'):
print(config_filename)
with open(config_filename, 'r') as f:
config = f.read()

with open(config_filename, 'w') as f:
f.write(clean_config(config))
(1-1/2)