Created
September 22, 2017 06:23
-
-
Save david0/f43011b91354a641aacca16d8e1b45b3 to your computer and use it in GitHub Desktop.
LdifFilteringParser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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