summaryrefslogtreecommitdiffstats
path: root/classes/servercontact.py
diff options
context:
space:
mode:
Diffstat (limited to 'classes/servercontact.py')
-rw-r--r--classes/servercontact.py26
1 files changed, 5 insertions, 21 deletions
diff --git a/classes/servercontact.py b/classes/servercontact.py
index c2f4ad5..e0e871e 100644
--- a/classes/servercontact.py
+++ b/classes/servercontact.py
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
+from common.misc import arg_abbr
import defusedxml.ElementTree as Et
@@ -19,23 +20,6 @@ class ServerContact:
self.contact = None
self.target, self.opt_arg = None, None
- def opt_arg_abbreviation(self):
- """
- optional argument abbreviation function
- if the provided string > 2 characters the most likely key will be chosen
- :return: completes the opt_arg to the most likely one
- """
- # if opt_argument is smaller then 2 pass to prohibit multiple answers
- if len(self.opt_arg) < 2:
- pass
-
- abbr = str(self.opt_arg)
- possible_abbr = ["abuse-addresses", "admin-addresses", "feedback-addresses", "sales-addresses",
- "security-addresses", "support-addresses"]
-
- # searches the best match in the list of possible_abbr and completes the opt_arg to that
- self.opt_arg = [s for s in possible_abbr if s.startswith(abbr)][0]
-
def process(self):
# get etree from base xml
iq = Et.fromstring(str(self.contact))
@@ -57,11 +41,11 @@ class ServerContact:
# iterate over all child elements in node
for child in node:
- # if one opt_arg is defined return just that one
- if self.opt_arg in self.possible_vars:
- # check for possible abbreviations to the optional argument
- self.opt_arg_abbreviation()
+ # check for possible abbreviations to the optional argument
+ self.opt_arg = arg_abbr(self.opt_arg, self.possible_vars)
+ # if opt_arg is defined and valid return just that one
+ if self.opt_arg in self.possible_vars:
if child.attrib['var'] == self.opt_arg:
# add section to result dict and append info
result[child.attrib['var']] = list()