Skip to content

Instantly share code, notes, and snippets.

@david0
Created September 22, 2017 06:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save david0/f43011b91354a641aacca16d8e1b45b3 to your computer and use it in GitHub Desktop.
Save david0/f43011b91354a641aacca16d8e1b45b3 to your computer and use it in GitHub Desktop.
LdifFilteringParser
#!/usr/bin/python3
from sys import argv, stdout
class LdifFilteringParser(object):
def __init__(self, input, output):
self.output = output
self.input = input
def parse(self):
changeset = ""
firstline = True
for line in self.input.readlines():
if firstline and "version:" in line:
self.output.write(line)
firstline = False
continue
firstline = False
if line.startswith("#"):
continue
if line.strip() == "":
self.handle(changeset)
changeset = ""
if line.startswith(" "):
changeset += line[1:]
else:
changeset += line
self.handle(changeset)
def handle(changeset):
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment