Commit bfd80953 authored by Lorenz Steinert's avatar Lorenz Steinert

removed clean_string function as it isn't needed anymore

parent 9d9f783d
......@@ -18,26 +18,8 @@ class fetch():
def __init__(self):
self.server = ldap.Server("rincewind.fs.physik.uni-kl.de")
self.reg_a = re.compile('\"a')
self.reg_o = re.compile('\"o')
self.reg_u = re.compile('\"u')
self.reg_A = re.compile('\"A')
self.reg_O = re.compile('\"O')
self.reg_U = re.compile('\"U')
self.reg_Kovac = re.compile('Kovac')
self.base = "dc=fs,dc=physik,dc=uni-kl,dc=de"
def clean_string(self, data):
"""remove "A, "O, "U, "a, "o, "u from input"""
data = self.reg_Kovac.sub("Kova"+r"\v"+"{c}", data)
data = self.reg_A.sub('Ä', data)
data = self.reg_O.sub('Ö', data)
data = self.reg_U.sub('Ü', data)
data = self.reg_a.sub('ä', data)
data = self.reg_o.sub('ö', data)
data = self.reg_u.sub('ü', data)
return data
def get_fsr_ldap(self, fsr):
"""get fsr from LDAP"""
print("Fetching FSR from LDAP ...")
......@@ -51,7 +33,7 @@ class fetch():
for i in conn.entries[0]['memberUid']:
if conn.search('ou=people,' + self.base,
'(uid='+i+')', attributes=['displayName']):
fsr_ += [self.clean_string(str(conn.entries[0]['displayName']))]
fsr_ += [str(conn.entries[0]['displayName'])]
fsr_.sort()
fsr_ = [" ".join(i.split(', ')[::-1]) for i in fsr_]
return fsr_
......@@ -73,7 +55,7 @@ class fetch():
for i in conn.entries[0]['memberUid']:
if conn.search('ou=people,' + self.base,
'(uid='+i+')', attributes=['displayName']):
fsr_extern_ += [self.clean_string(str(conn.entries[0]['displayName']))]
fsr_extern_ += [str(conn.entries[0]['displayName'])]
fsr_extern_.sort()
fsr_extern_ = [" ".join(i.split(', ')[::-1]) for i in fsr_extern_]
return fsr_extern_
......@@ -89,17 +71,9 @@ class fetch():
fsr_out = ""
fsr_extern_out = ""
for i in fsr:
if "Sarah" in i:
fsr_out += r"Sarah Anna Kova\\\\v{c}"+"\n"
else:
fsr_out += i + "\n"
fsr_out = [i+"\n" for i in fsr]
for i in fsr_extern:
if "Sarah" in i:
fsr_extern_out += r"Sarah Anna Kova\\\\v{c}"+"\n"
else:
fsr_extern_out += i + "\n"
fsr_extern_out = [i+"\n" for i in fsr_extern]
with codecs.open('fsr', 'w', 'utf-8') as fobj_fsr_out:
fobj_fsr_out.write(fsr_out)
......
......@@ -48,21 +48,14 @@ class Protokollskript:
self.date = (day+"."+mon+"."+year, year, mon, day)
self.reg = {'"a': re.compile('\"a'),
'"o': re.compile('\"o'),
'"u': re.compile('\"u'),
'"A': re.compile('\"A'),
'"O': re.compile('\"O'),
'"U': re.compile('\"U'),
'Kovac': re.compile('Kovac'),
'SPR': re.compile('%%SPRECHER'),
self.reg = {'SPR': re.compile('%%SPRECHER'),
'PRO': re.compile('%%PROTOKOLLANT'),
'DATE': re.compile('%%DATE'),
'ACRO': re.compile('%%ACRO'),
'ACRON': re.compile('%%ACRONAME'),
'FSRN': re.compile('%%FSRNAME')}
self.fsr = ['','']
self.fsr = ['', '']
self.fsr[0] = sorted([re.sub(re.escape('\t'),
' ',
......@@ -90,17 +83,6 @@ class Protokollskript:
str(list(self.opt.keys())))
raise SystemExit(0)
def clean_string(self, data):
"""remove "A, "O, "U, "a, "o, "u from input"""
data = self.reg['Kovac'].sub("Kova"+r"\v"+"{c}", data)
data = self.reg['"A'].sub('Ä', data)
data = self.reg['"O'].sub('Ö', data)
data = self.reg['"U'].sub('Ü', data)
data = self.reg['"a'].sub('ä', data)
data = self.reg['"o'].sub('ö', data)
data = self.reg['"u'].sub('ü', data)
return data
def get_protokollant_ldap(self, protokollant):
"""search the LDAP for the current user"""
print("Fetching Protokollant from LDAP ...")
......@@ -109,7 +91,7 @@ class Protokollskript:
conn.bind()
fil = "(uid="+current_user()+")"
if conn.search('ou=people,'+self.base, fil, attributes=['displayName']):
return self.clean_string(" ".join(str(conn.entries[0]['displayName']).split(", ")[::-1]))
return " ".join(str(conn.entries[0]['displayName']).split(", ")[::-1])
return protokollant
except ldap.core.exceptions.LDAPException as error_message:
if self.opt['-d']:
......@@ -132,7 +114,7 @@ class Protokollskript:
for i in conn.entries[0]['memberUid']:
if conn.search('ou=people,' + self.base,
'(uid='+i+')', attributes=['displayName']):
fsr_ += [self.clean_string(str(conn.entries[0]['displayName']))]
fsr_ += [str(conn.entries[0]['displayName'])]
fsr_.sort()
fsr_ = [" ".join(i.split(', ')[::-1]) for i in fsr_]
return fsr_
......@@ -157,7 +139,7 @@ class Protokollskript:
for i in conn.entries[0]['memberUid']:
if conn.search('ou=people,' + self.base,
'(uid='+i+')', attributes=['displayName']):
fsr_extern_ += [self.clean_string(str(conn.entries[0]['displayName']))]
fsr_extern_ += [str(conn.entries[0]['displayName'])]
fsr_extern_.sort()
fsr_extern_ = [" ".join(i.split(', ')[::-1]) for i in fsr_extern_]
return fsr_extern_
......@@ -294,10 +276,7 @@ class Protokollskript:
else:
msg += "&"
if "Sarah" in i[0]:
msg += r" &Sarah Anna Kova\v{c}"
else:
msg += " &" + i[0]
msg += " &" + i[0]
if i[1] % num_cols == num_cols - 1:
msg += "\\\\\\hline\n"
......@@ -325,10 +304,7 @@ class Protokollskript:
else:
msg += "&"
if "Sarah" in i[0]:
msg += r" &Sarah Anna Kova\v{c}"
else:
msg += " &" +i[0]
msg += " &" +i[0]
if i[1] % num_cols_ext == num_cols_ext - 1:
msg += "\\\\\\hline\n"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment