From 622a096a5a402672b903ebacaf0e3caaaa118aa9 Mon Sep 17 00:00:00 2001 From: Ssuching Yu Date: Tue, 14 May 2019 21:52:54 +0800 Subject: [PATCH 1/2] Remove ALIDNS_LINE_MAP. --- black_dnsync/dns_client.py | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/black_dnsync/dns_client.py b/black_dnsync/dns_client.py index bdd3c04..d6f007f 100644 --- a/black_dnsync/dns_client.py +++ b/black_dnsync/dns_client.py @@ -272,19 +272,6 @@ def update_record(self, domain, record_id, record): data['mx'] = record.priority return self.__request('PUT', uri, data) - -ALIDNS_LINE_MAP = { - 'default': 'default', - 'ct': 'telecom', - 'cu': 'unicom', - 'cm': 'mobile', - 'edu': 'edu', - 'oversea': 'oversea', -} - -ALIDNS_LINE_MAP_REV = {v: k for k, v in ALIDNS_LINE_MAP.items()} - - class AliyunClient(BaseClient): def __init__(self, api_key, api_secret): super(AliyunClient, self).__init__(api_key, api_secret) @@ -342,7 +329,7 @@ def __to_record(self, record): raise ValueError('Do not support Aliyun DNS record disabled status!') try: - line = ALIDNS_LINE_MAP_REV[record['Line']] + line = record['Line'] except KeyError: raise UnsupportedLineError(record) @@ -381,7 +368,7 @@ def add_record(self, domain, record): 'Value': record.value, 'TTL': record.ttl, } - data['Line'] = ALIDNS_LINE_MAP[record.line] + data['Line'] = record.line if record.type == 'MX': data['Priority'] = record.priority return self.__request(data) @@ -402,7 +389,7 @@ def update_record(self, domain, record_id, record): 'Value': record.value, 'TTL': record.ttl, } - data['Line'] = ALIDNS_LINE_MAP[record.line] + data['Line'] = record.line if record.type == 'MX': data['Priority'] = record.priority return self.__request(data) From ce2198e76d4b7025efa920501fb304cf71a597a5 Mon Sep 17 00:00:00 2001 From: Ssuching Yu Date: Wed, 15 May 2019 14:41:37 +0800 Subject: [PATCH 2/2] Remove UnsupportedLineError --- black_dnsync/dns_client.py | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/black_dnsync/dns_client.py b/black_dnsync/dns_client.py index d6f007f..fdfa136 100644 --- a/black_dnsync/dns_client.py +++ b/black_dnsync/dns_client.py @@ -32,13 +32,6 @@ def __str__(self): return repr(self.msg) -class UnsupportedLineError(Exception): - def __init__(self, msg): - self.msg = msg - def __str__(self): - return repr(self.msg) - - class BaseClient(object): def __init__(self, api_key, api_secret): @@ -328,10 +321,8 @@ def __to_record(self, record): if record['Status'] == 'Disable': raise ValueError('Do not support Aliyun DNS record disabled status!') - try: - line = record['Line'] - except KeyError: - raise UnsupportedLineError(record) + + line = record['Line'] priority = None if record['Type'] == 'MX':