У меня есть файл схемы LDAP (текстовый файл, записанный в BASH), прочитанный в список в Python. Мой код:
LDAP_SCHEMA_LIST = []
LDAP_CORE_LIST = []
LDAP_CORE_DICT = {}
LDAP_CORE_FILE = '/../../../schema-core'
with open (LDAP_CORE_FILE) as LDAP_FILE_OBJECT:
LDAP_SCHEMA_LIST = LDAP_FILE_OBJECT.readlines()
for line in LDAP_SCHEMA_LIST:
if re.match("[A-Za-z0-9]+:", line)
print(line.strip())
Вывод:
dn: cn=<OU>, cn=schema, cn=config
objectClass: schemaConfig
cn: <OU>
objectAttribute: {n} ( 1.2.3.4.5.6 Name Address Us
er Just making up some more data to fill 1.1..1.1
.111.131.111 SINGLE-VALUE )
objectAttribute: More Plaintext Data
This would be the string above continued on this line
1212 this is another continued line from the string
objectAttribute: etc...
Я хотел бы иметь возможность создать шаблон поиска регулярного выражения или оператор sed / awk для соответствует двум строкам продолжения строки и соединяет их в одну строку . Например:
dn: cn=<OU>, cn=schema, cn=config
objectClass: schemaConfig
cn: <OU>
objectAttribute: {n} ( 1.2.3.4.5.6 Name Address User Just making up some more data to fill...
objectAttribute: More Plaintext Data This would be the string above continued on this line 1212 this...