Commit 4774cfab authored by Jérome Perrin's avatar Jérome Perrin

syncml: pylint for py3

parent ef6e7cd9
...@@ -541,7 +541,7 @@ class SyncMLSubscription(XMLObject): ...@@ -541,7 +541,7 @@ class SyncMLSubscription(XMLObject):
xml_document = etree.tostring(xml_document, encoding='utf-8', xml_document = etree.tostring(xml_document, encoding='utf-8',
pretty_print=True) pretty_print=True)
if six.PY2 and isinstance(xml_document, unicode): if six.PY2 and isinstance(xml_document, six.text_type):
xml_document = xml_document.encode('utf-8') xml_document = xml_document.encode('utf-8')
# Link the signature to the document # Link the signature to the document
if signature: if signature:
......
...@@ -76,11 +76,10 @@ class SyncMLEngineMixin(object): ...@@ -76,11 +76,10 @@ class SyncMLEngineMixin(object):
status['authentication_type'])) status['authentication_type']))
# XXX Not working To Review ! # XXX Not working To Review !
raise NotImplementedError("Adding credentials") raise NotImplementedError("Adding credentials")
""" # syncml_response = domain.generateBaseResponse()
syncml_response = domain.generateBaseResponse() # syncml_response.addCredentialMessage(domain)
syncml_response.addCredentialMessage(domain) # return syncml_response
return syncml_response
"""
elif status['status_code'] == \ elif status['status_code'] == \
resolveSyncmlStatusCode('invalid_credentials'): resolveSyncmlStatusCode('invalid_credentials'):
syncml_logger.error("\tClient authentication refused") syncml_logger.error("\tClient authentication refused")
......
...@@ -92,5 +92,4 @@ class BaseConduit(object): ...@@ -92,5 +92,4 @@ class BaseConduit(object):
Method called when update command is received Method called when update command is received
XXX It should returns the list of conflicts ? XXX It should returns the list of conflicts ?
""" """
pass
...@@ -489,9 +489,8 @@ class ERP5Conduit(XMLSyncUtilsMixin): ...@@ -489,9 +489,8 @@ class ERP5Conduit(XMLSyncUtilsMixin):
first_object = False first_object = False
elif sub_context is not None: elif sub_context is not None:
context = sub_context context = sub_context
else: # else:
# Ignore non existing objects # Ignore non existing objects
pass
#LOG('ERP5Conduit', INFO, 'sub document of %s not found with id:%r'%\ #LOG('ERP5Conduit', INFO, 'sub document of %s not found with id:%r'%\
#(context.getPath(), sub_context_id)) #(context.getPath(), sub_context_id))
xpath = xpath.replace(object_block, '', 1) xpath = xpath.replace(object_block, '', 1)
...@@ -694,7 +693,6 @@ class ERP5Conduit(XMLSyncUtilsMixin): ...@@ -694,7 +693,6 @@ class ERP5Conduit(XMLSyncUtilsMixin):
def afterNewObject(self, object): # pylint: disable=redefined-builtin def afterNewObject(self, object): # pylint: disable=redefined-builtin
"""Overloadable method """Overloadable method
""" """
pass
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getStatusFromXml') 'getStatusFromXml')
...@@ -855,7 +853,7 @@ class ERP5Conduit(XMLSyncUtilsMixin): ...@@ -855,7 +853,7 @@ class ERP5Conduit(XMLSyncUtilsMixin):
if xupdated_node_list: if xupdated_node_list:
xupdated_node = xupdated_node_list[0] xupdated_node = xupdated_node_list[0]
else: else:
ValueError('Wrong xpath expression:%r' % base_xpath_expression) raise ValueError('Wrong xpath expression:%r' % base_xpath_expression)
if base_xpath_expression not in xpath_expression_update_dict: if base_xpath_expression not in xpath_expression_update_dict:
xpath_expression_update_dict[base_xpath_expression] = \ xpath_expression_update_dict[base_xpath_expression] = \
dict(xml=xupdated_node, dict(xml=xupdated_node,
...@@ -875,7 +873,7 @@ class ERP5Conduit(XMLSyncUtilsMixin): ...@@ -875,7 +873,7 @@ class ERP5Conduit(XMLSyncUtilsMixin):
if xupdated_node_list: if xupdated_node_list:
xupdated_node = xupdated_node_list[0] xupdated_node = xupdated_node_list[0]
else: else:
ValueError('Wrong xpath expression:%r' % base_xpath_expression) raise ValueError('Wrong xpath expression:%r' % base_xpath_expression)
if base_xpath_expression not in xpath_expression_update_dict: if base_xpath_expression not in xpath_expression_update_dict:
xpath_expression_update_dict[base_xpath_expression] = \ xpath_expression_update_dict[base_xpath_expression] = \
dict(xml=xupdated_node, dict(xml=xupdated_node,
......
...@@ -145,7 +145,7 @@ class SyncMLAsynchronousEngine(SyncMLEngineMixin): ...@@ -145,7 +145,7 @@ class SyncMLAsynchronousEngine(SyncMLEngineMixin):
""" """
Process the package 4 of the SyncML DS exchange Process the package 4 of the SyncML DS exchange
""" """
if False: if False: # pylint:disable=using-constant-test
pass pass
# not subscriber.checkCorrectRemoteMessageId( # not subscriber.checkCorrectRemoteMessageId(
# syncml_request.header['message_id']): # syncml_request.header['message_id']):
......
...@@ -225,41 +225,41 @@ class SyncMLResponse(object): ...@@ -225,41 +225,41 @@ class SyncMLResponse(object):
receiving a challenge message receiving a challenge message
""" """
raise NotImplementedError("To review") raise NotImplementedError("To review")
"""
# create element 'SyncML' with a default namespace # # create element 'SyncML' with a default namespace
xml = E.SyncML() # xml = E.SyncML()
# syncml header # # syncml header
xml.append(self.buildHeader( # xml.append(self.buildHeader(
session_id=subscription.incrementSessionId(), # session_id=subscription.incrementSessionId(),
msg_id=subscription.incrementMessageId(), # msg_id=subscription.incrementMessageId(),
target=subscription.getUrlString(), # target=subscription.getUrlString(),
source=subscription.getSubscriptionUrlString(), # source=subscription.getSubscriptionUrlString(),
user_id=subscription.getUserId(), # user_id=subscription.getUserId(),
password=subscription.getPassword(), # password=subscription.getPassword(),
authentication_format=subscription.getAuthenticationFormat(), # authentication_format=subscription.getAuthenticationFormat(),
authentication_type=subscription.getAuthenticationType())) # authentication_type=subscription.getAuthenticationType()))
#
# Build the message body # # Build the message body
sync_body = E.SyncBody() # sync_body = E.SyncBody()
#
# alert message # # alert message
sync_body.append(self.buildAlertMessage( # sync_body.append(self.buildAlertMessage(
command_id=self._getNextCommandId(), # command_id=self._getNextCommandId(),
alert_code=subscription.getSyncmlAlertCode(), # alert_code=subscription.getSyncmlAlertCode(),
target=subscription.getDestinationReference(), # target=subscription.getDestinationReference(),
source=subscription.getSourceReference(), # source=subscription.getSourceReference(),
last_anchor=subscription.getLastAnchor(), # last_anchor=subscription.getLastAnchor(),
next_anchor=subscription.getNextAnchor())) # next_anchor=subscription.getNextAnchor()))
syncml_put = self.buildPutMessage(subscription) # syncml_put = self.buildPutMessage(subscription)
if syncml_put is not None: # if syncml_put is not None:
sync_body.append(syncml_put) # sync_body.append(syncml_put)
sync_body.append(E.Final()) # sync_body.append(E.Final())
#
xml.append(sync_body) # xml.append(sync_body)
xml_string = etree.tostring(xml, encoding='utf-8', xml_declaration=True, # xml_string = etree.tostring(xml, encoding='utf-8', xml_declaration=True,
pretty_print=True) # pretty_print=True)
self.data_append(xml_string) # self.data_append(xml_string)
"""
def addPutMessage(self,subscription, markup='Put', def addPutMessage(self,subscription, markup='Put',
cmd_ref=None, message_id=None): cmd_ref=None, message_id=None):
...@@ -280,61 +280,59 @@ class SyncMLResponse(object): ...@@ -280,61 +280,59 @@ class SyncMLResponse(object):
Both must be able to handle and process these informations Both must be able to handle and process these informations
""" """
return return
""" # # XXX-Aurel : must be reviewed according to specification
# XXX-Aurel : must be reviewed according to specification # # This part can be skipped for now
# This part can be skipped for now # conduit = subscription.getConduit()
conduit = subscription.getConduit() # xml = None
xml = None # # The conduit defined what capabilities the service offers
# The conduit defined what capabilities the service offers # if getattr(conduit, 'getCapabilitiesCTTypeList', None) and \
if getattr(conduit, 'getCapabilitiesCTTypeList', None) and \ # getattr(conduit, 'getCapabilitiesVerCTList', None) and \
getattr(conduit, 'getCapabilitiesVerCTList', None) and \ # getattr(conduit, 'getPreferedCapabilitieVerCT', None):
getattr(conduit, 'getPreferedCapabilitieVerCT', None): # xml = Element('{%s}%s' % (SYNCML_NAMESPACE, markup))
xml = Element('{%s}%s' % (SYNCML_NAMESPACE, markup)) # xml.append(E.CmdID(self._getNextCommandId()))
xml.append(E.CmdID(self._getNextCommandId())) # if message_id:
if message_id: # xml.append(E.MsgRef('%s' % message_id))
xml.append(E.MsgRef('%s' % message_id)) # if cmd_ref:
if cmd_ref: # xml.append(E.CmdRef('%s' % cmd_ref))
xml.append(E.CmdRef('%s' % cmd_ref)) # xml.extend((E.Meta(E.Type('application/vnd.syncml-devinf+xml')),
xml.extend((E.Meta(E.Type('application/vnd.syncml-devinf+xml')), # E.Item(E.Source(E.LocURI('./devinf12')),
E.Item(E.Source(E.LocURI('./devinf12')), # E.Data(E.DevInf(E.VerDTD('1.2'),
E.Data(E.DevInf(E.VerDTD('1.2'), # E.Man('Nexedi'),
E.Man('Nexedi'), # E.Mod('ERP5SyncML'),
E.Mod('ERP5SyncML'), # E.OEM('Open Source'),
E.OEM('Open Source'), # E.SwV('0.1'),
E.SwV('0.1'), # E.DevID(subscription.getSubscriptionUrlString()),
E.DevID(subscription.getSubscriptionUrlString()), # E.DevTyp('workstation'),
E.DevTyp('workstation'), # E.UTC(),
E.UTC(), # E.DataStore(E.SourceRef(subscription.getSourceReference()))
E.DataStore(E.SourceRef(subscription.getSourceReference())) # )
) # )
) # )))
))) # data_store = xml.find('{%(ns)s}Item/{%(ns)s}Data/{%(ns)s}DevInf/{%(ns)s}DataStore' % {'ns': SYNCML_NAMESPACE})
data_store = xml.find('{%(ns)s}Item/{%(ns)s}Data/{%(ns)s}DevInf/{%(ns)s}DataStore' % {'ns': SYNCML_NAMESPACE}) # tx_element_list = []
tx_element_list = [] # rx_element_list = []
rx_element_list = [] # for cttype in conduit.getCapabilitiesCTTypeList():
for cttype in conduit.getCapabilitiesCTTypeList(): # if cttype != 'text/xml':
if cttype != 'text/xml': # for x_version in conduit.getCapabilitiesVerCTList(cttype):
for x_version in conduit.getCapabilitiesVerCTList(cttype): # rx_element_list.append(E.Rx(E.CTType(cttype), E.VerCT(x_version)))
rx_element_list.append(E.Rx(E.CTType(cttype), E.VerCT(x_version))) # tx_element_list.append(E.Tx(E.CTType(cttype), E.VerCT(x_version)))
tx_element_list.append(E.Tx(E.CTType(cttype), E.VerCT(x_version))) # rx_pref = Element('{%s}Rx-Pref' % SYNCML_NAMESPACE)
rx_pref = Element('{%s}Rx-Pref' % SYNCML_NAMESPACE) # rx_pref.extend((E.CTType(conduit.getPreferedCapabilitieCTType()),
rx_pref.extend((E.CTType(conduit.getPreferedCapabilitieCTType()), # E.VerCT(conduit.getPreferedCapabilitieVerCT())))
E.VerCT(conduit.getPreferedCapabilitieVerCT()))) # data_store.append(rx_pref)
data_store.append(rx_pref) # data_store.extend(rx_element_list)
data_store.extend(rx_element_list) # tx_pref = Element('{%s}Tx-Pref' % SYNCML_NAMESPACE)
tx_pref = Element('{%s}Tx-Pref' % SYNCML_NAMESPACE) # tx_pref.extend((E.CTType(conduit.getPreferedCapabilitieCTType()),
tx_pref.extend((E.CTType(conduit.getPreferedCapabilitieCTType()), # E.VerCT(conduit.getPreferedCapabilitieVerCT())))
E.VerCT(conduit.getPreferedCapabilitieVerCT()))) # data_store.append(tx_pref)
data_store.append(tx_pref) # data_store.extend(tx_element_list)
data_store.extend(tx_element_list) # data_store.append(E.SyncCap(
data_store.append(E.SyncCap( # E.SyncType('2'),
E.SyncType('2'), # E.SyncType('1'),
E.SyncType('1'), # E.SyncType('4'),
E.SyncType('4'), # E.SyncType('6')
E.SyncType('6') # ))
)) # self.data_append(xml)
self.data_append(xml)
"""
def addSyncCommand(self, sync_command, gid, data, media_type, more_data): def addSyncCommand(self, sync_command, gid, data, media_type, more_data):
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
# #
############################################################################## ##############################################################################
from erp5.component.module.SyncMLTransportHTTP import ConnectionError from erp5.component.module.SyncMLTransportHTTP import ConnectionError as _ConnectionError
class FileTransport: class FileTransport:
...@@ -35,4 +35,4 @@ class FileTransport: ...@@ -35,4 +35,4 @@ class FileTransport:
with open(filename, 'wb') as stream: with open(filename, 'wb') as stream:
stream.write(data) stream.write(data)
except IOError: except IOError:
raise ConnectionError raise _ConnectionError
...@@ -31,7 +31,7 @@ from requests import post ...@@ -31,7 +31,7 @@ from requests import post
syncml_logger = getLogger('ERP5SyncML') syncml_logger = getLogger('ERP5SyncML')
class ConnectionError(Exception): class ConnectionError(Exception): # pylint:disable=redefined-builtin
pass pass
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
# #
############################################################################## ##############################################################################
from erp5.component.module.SyncMLTransportHTTP import ConnectionError from erp5.component.module.SyncMLTransportHTTP import ConnectionError as _ConnectionError
from Products.ERP5.ERP5Site import getSite from Products.ERP5.ERP5Site import getSite
class MailTransport: class MailTransport:
...@@ -36,4 +36,4 @@ class MailTransport: ...@@ -36,4 +36,4 @@ class MailTransport:
try: try:
getSite().sendMail(from_address, to_address, sync_id, xml) getSite().sendMail(from_address, to_address, sync_id, xml)
except: except:
raise ConnectionError raise _ConnectionError
...@@ -141,7 +141,7 @@ class VCardConduit(ERP5Conduit): ...@@ -141,7 +141,7 @@ class VCardConduit(ERP5Conduit):
property_value_list_well_incoded=[] property_value_list_well_incoded=[]
if encoding == 'QUOTED-PRINTABLE': if encoding == 'QUOTED-PRINTABLE':
import mimify import mimify # pylint:disable=import-error
for property_value in property_value_list: for property_value in property_value_list:
property_value = mimify.mime_decode(property_value) property_value = mimify.mime_decode(property_value)
property_value_list_well_incoded.append(property_value) property_value_list_well_incoded.append(property_value)
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
# #
############################################################################## ##############################################################################
import six
from erp5.component.module.XMLSyncUtils import XMLSyncUtilsMixin from erp5.component.module.XMLSyncUtils import XMLSyncUtilsMixin
from xml.dom.ext.reader.Sax2 import FromXml # pylint:disable=no-name-in-module,import-error from xml.dom.ext.reader.Sax2 import FromXml # pylint:disable=no-name-in-module,import-error
...@@ -40,7 +41,7 @@ class XupdateUtils(XMLSyncUtilsMixin): ...@@ -40,7 +41,7 @@ class XupdateUtils(XMLSyncUtilsMixin):
Parse the xupdate and then it will call the conduit Parse the xupdate and then it will call the conduit
""" """
conflict_list = [] conflict_list = []
if isinstance(xupdate, (str, unicode)): if isinstance(xupdate, six.string_types):
xupdate = FromXml(xupdate) xupdate = FromXml(xupdate)
for subnode in xupdate: for subnode in xupdate:
......
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