Fix pycodestyle W605 warnings

W605 invalid escape sequence, which was recently added in pycodestyle,
would be a syntax error in future python3 versions.

Signed-off-by: IWAMOTO Toshihiro <iwamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
IWAMOTO Toshihiro 2018-06-13 12:02:15 +09:00 committed by FUJITA Tomonori
parent b1ec9ed457
commit 4bc29b2c5f
13 changed files with 58 additions and 58 deletions

View File

@ -1147,13 +1147,13 @@ class Action(object):
if REST_ACTION in flow: if REST_ACTION in flow:
actions = [] actions = []
for act in flow[REST_ACTION]: for act in flow[REST_ACTION]:
field_value = re.search('SET_FIELD: \{ip_dscp:(\d+)', act) field_value = re.search(r'SET_FIELD: \{ip_dscp:(\d+)', act)
if field_value: if field_value:
actions.append({REST_ACTION_MARK: field_value.group(1)}) actions.append({REST_ACTION_MARK: field_value.group(1)})
meter_value = re.search('METER:(\d+)', act) meter_value = re.search(r'METER:(\d+)', act)
if meter_value: if meter_value:
actions.append({REST_ACTION_METER: meter_value.group(1)}) actions.append({REST_ACTION_METER: meter_value.group(1)})
queue_value = re.search('SET_QUEUE:(\d+)', act) queue_value = re.search(r'SET_QUEUE:(\d+)', act)
if queue_value: if queue_value:
actions.append({REST_ACTION_QUEUE: queue_value.group(1)}) actions.append({REST_ACTION_QUEUE: queue_value.group(1)})
action = {REST_ACTION: actions} action = {REST_ACTION: actions}

View File

@ -39,7 +39,7 @@ def ofp_instruction_from_str(ofproto, action_str):
action_str An action string. action_str An action string.
=========== ================================================= =========== =================================================
""" """
action_re = re.compile("([a-z_]+)(\([^)]*\)|[^a-z_,()][^,()]*)*") action_re = re.compile(r"([a-z_]+)(\([^)]*\)|[^a-z_,()][^,()]*)*")
result = [] result = []
while len(action_str): while len(action_str):
m = action_re.match(action_str) m = action_re.match(action_str)
@ -303,7 +303,7 @@ class OfctlActionConverter(object):
if k == 'table': if k == 'table':
recirc_table = str_to_int(v) recirc_table = str_to_int(v)
elif k == 'zone': elif k == 'zone':
m = re.search('\[(\d*)\.\.(\d*)\]', v) m = re.search(r'\[(\d*)\.\.(\d*)\]', v)
if m: if m:
zone_ofs_nbits = nicira_ext.ofs_nbits( zone_ofs_nbits = nicira_ext.ofs_nbits(
int(m.group(1)), int(m.group(2))) int(m.group(1)), int(m.group(2)))

View File

@ -66,12 +66,12 @@ def valid_ovsdb_addr(addr):
:return: True if valid, otherwise False. :return: True if valid, otherwise False.
""" """
# Assumes Unix socket format: "unix:file" # Assumes Unix socket format: "unix:file"
m = re.match('unix:(\S+)', addr) m = re.match(r'unix:(\S+)', addr)
if m: if m:
file = m.group(1) file = m.group(1)
return os.path.isfile(file) return os.path.isfile(file)
# Assumes TCP/SSL socket format: "tcp:ip:port" or "ssl:ip:port" # Assumes TCP/SSL socket format: "tcp:ip:port" or "ssl:ip:port"
m = re.match('(tcp|ssl):(\S+):(\d+)', addr) m = re.match(r'(tcp|ssl):(\S+):(\d+)', addr)
if m: if m:
address = m.group(2) address = m.group(2)
port = m.group(3) port = m.group(3)

View File

@ -69,7 +69,7 @@ BMP_PEER_DOWN_REASON_REMOTE_NO_NOTIFICATION = 4
class BMPMessage(packet_base.PacketBase, TypeDisp): class BMPMessage(packet_base.PacketBase, TypeDisp):
"""Base class for BGP Monitoring Protocol messages. r"""Base class for BGP Monitoring Protocol messages.
An instance has the following attributes at least. An instance has the following attributes at least.
Most of them are same to the on-wire counterparts but in host byte Most of them are same to the on-wire counterparts but in host byte
@ -141,7 +141,7 @@ class BMPMessage(packet_base.PacketBase, TypeDisp):
class BMPPeerMessage(BMPMessage): class BMPPeerMessage(BMPMessage):
"""BMP Message with Per Peer Header r"""BMP Message with Per Peer Header
Following BMP Messages contain Per Peer Header after Common BMP Header. Following BMP Messages contain Per Peer Header after Common BMP Header.
@ -250,7 +250,7 @@ class BMPPeerMessage(BMPMessage):
@BMPMessage.register_type(BMP_MSG_ROUTE_MONITORING) @BMPMessage.register_type(BMP_MSG_ROUTE_MONITORING)
class BMPRouteMonitoring(BMPPeerMessage): class BMPRouteMonitoring(BMPPeerMessage):
"""BMP Route Monitoring Message r"""BMP Route Monitoring Message
========================== =============================================== ========================== ===============================================
Attribute Description Attribute Description
@ -308,7 +308,7 @@ class BMPRouteMonitoring(BMPPeerMessage):
@BMPMessage.register_type(BMP_MSG_STATISTICS_REPORT) @BMPMessage.register_type(BMP_MSG_STATISTICS_REPORT)
class BMPStatisticsReport(BMPPeerMessage): class BMPStatisticsReport(BMPPeerMessage):
"""BMP Statistics Report Message r"""BMP Statistics Report Message
========================== =============================================== ========================== ===============================================
Attribute Description Attribute Description
@ -424,7 +424,7 @@ class BMPStatisticsReport(BMPPeerMessage):
@BMPMessage.register_type(BMP_MSG_PEER_DOWN_NOTIFICATION) @BMPMessage.register_type(BMP_MSG_PEER_DOWN_NOTIFICATION)
class BMPPeerDownNotification(BMPPeerMessage): class BMPPeerDownNotification(BMPPeerMessage):
"""BMP Peer Down Notification Message r"""BMP Peer Down Notification Message
========================== =============================================== ========================== ===============================================
Attribute Description Attribute Description
@ -498,7 +498,7 @@ class BMPPeerDownNotification(BMPPeerMessage):
@BMPMessage.register_type(BMP_MSG_PEER_UP_NOTIFICATION) @BMPMessage.register_type(BMP_MSG_PEER_UP_NOTIFICATION)
class BMPPeerUpNotification(BMPPeerMessage): class BMPPeerUpNotification(BMPPeerMessage):
"""BMP Peer Up Notification Message r"""BMP Peer Up Notification Message
========================== =============================================== ========================== ===============================================
Attribute Description Attribute Description
@ -605,7 +605,7 @@ class BMPPeerUpNotification(BMPPeerMessage):
@BMPMessage.register_type(BMP_MSG_INITIATION) @BMPMessage.register_type(BMP_MSG_INITIATION)
class BMPInitiation(BMPMessage): class BMPInitiation(BMPMessage):
"""BMP Initiation Message r"""BMP Initiation Message
========================== =============================================== ========================== ===============================================
Attribute Description Attribute Description
@ -669,7 +669,7 @@ class BMPInitiation(BMPMessage):
@BMPMessage.register_type(BMP_MSG_TERMINATION) @BMPMessage.register_type(BMP_MSG_TERMINATION)
class BMPTermination(BMPMessage): class BMPTermination(BMPMessage):
"""BMP Termination Message r"""BMP Termination Message
========================== =============================================== ========================== ===============================================
Attribute Description Attribute Description

View File

@ -75,7 +75,7 @@ BLOCK_OLD_SOURCES = 6
class icmpv6(packet_base.PacketBase): class icmpv6(packet_base.PacketBase):
"""ICMPv6 (RFC 2463) header encoder/decoder class. r"""ICMPv6 (RFC 2463) header encoder/decoder class.
An instance has the following attributes at least. An instance has the following attributes at least.
Most of them are same to the on-wire counterparts but in host byte order. Most of them are same to the on-wire counterparts but in host byte order.
@ -553,7 +553,7 @@ class nd_option_tla(nd_option_la):
@nd_router_advert.register_nd_option_type @nd_router_advert.register_nd_option_type
class nd_option_pi(nd_option): class nd_option_pi(nd_option):
"""ICMPv6 sub encoder/decoder class for Neighbor discovery r"""ICMPv6 sub encoder/decoder class for Neighbor discovery
Prefix Information Option. (RFC 4861) Prefix Information Option. (RFC 4861)
This is used with ryu.lib.packet.icmpv6.nd_router_advert. This is used with ryu.lib.packet.icmpv6.nd_router_advert.
@ -884,7 +884,7 @@ class mldv2_report(mld):
class mldv2_report_group(stringify.StringifyMixin): class mldv2_report_group(stringify.StringifyMixin):
""" r"""
ICMPv6 sub encoder/decoder class for MLD v2 Lister Report Group ICMPv6 sub encoder/decoder class for MLD v2 Lister Report Group
Record messages. (RFC 3810) Record messages. (RFC 3810)

View File

@ -391,7 +391,7 @@ class igmpv3_report(igmp):
class igmpv3_report_group(stringify.StringifyMixin): class igmpv3_report_group(stringify.StringifyMixin):
""" r"""
Internet Group Management Protocol(IGMP, RFC 3376) Internet Group Management Protocol(IGMP, RFC 3376)
Membership Report Group Record message encoder/decoder class. Membership Report Group Record message encoder/decoder class.

View File

@ -274,7 +274,7 @@ class dst_opts(opt_header):
class option(stringify.StringifyMixin): class option(stringify.StringifyMixin):
"""IPv6 (RFC 2460) Options header encoder/decoder class. r"""IPv6 (RFC 2460) Options header encoder/decoder class.
This is used with ryu.lib.packet.ipv6.hop_opts or This is used with ryu.lib.packet.ipv6.hop_opts or
ryu.lib.packet.ipv6.dst_opts. ryu.lib.packet.ipv6.dst_opts.
@ -496,7 +496,7 @@ class routing_type3(header):
@ipv6.register_header_type(inet.IPPROTO_FRAGMENT) @ipv6.register_header_type(inet.IPPROTO_FRAGMENT)
class fragment(header): class fragment(header):
"""IPv6 (RFC 2460) fragment header encoder/decoder class. r"""IPv6 (RFC 2460) fragment header encoder/decoder class.
This is used with ryu.lib.packet.ipv6.ipv6. This is used with ryu.lib.packet.ipv6.ipv6.

View File

@ -327,7 +327,7 @@ class StringifyMixin(object):
@classmethod @classmethod
def from_jsondict(cls, dict_, decode_string=base64.b64decode, def from_jsondict(cls, dict_, decode_string=base64.b64decode,
**additional_args): **additional_args):
"""Create an instance from a JSON style dict. r"""Create an instance from a JSON style dict.
Instantiate this class with parameters specified by the dict. Instantiate this class with parameters specified by the dict.

View File

@ -298,7 +298,7 @@ NXM_IP_FRAG_NOT_LATER = (0, FLOW_NW_FRAG_LATER)
def ofs_nbits(start, end): def ofs_nbits(start, end):
""" r"""
The utility method for ofs_nbits The utility method for ofs_nbits
This method is used in the class to set the ofs_nbits. This method is used in the class to set the ofs_nbits.

View File

@ -248,7 +248,7 @@ def generate(ofp_name, ofpp_name):
# For OpenFlow1.0 only # For OpenFlow1.0 only
class NXActionSetQueue(NXAction): class NXActionSetQueue(NXAction):
""" r"""
Set queue action Set queue action
This action sets the queue that should be used to queue This action sets the queue that should be used to queue
@ -338,7 +338,7 @@ def generate(ofp_name, ofpp_name):
return data return data
class NXActionRegLoad(NXAction): class NXActionRegLoad(NXAction):
""" r"""
Load literal value action Load literal value action
This action loads a literal value into a field or part of a field. This action loads a literal value into a field or part of a field.
@ -405,7 +405,7 @@ def generate(ofp_name, ofpp_name):
return data return data
class NXActionRegLoad2(NXAction): class NXActionRegLoad2(NXAction):
""" r"""
Load literal value action Load literal value action
This action loads a literal value into a field or part of a field. This action loads a literal value into a field or part of a field.
@ -474,7 +474,7 @@ def generate(ofp_name, ofpp_name):
return data return data
class NXActionNote(NXAction): class NXActionNote(NXAction):
""" r"""
Note action Note action
This action does nothing at all. This action does nothing at all.
@ -553,7 +553,7 @@ def generate(ofp_name, ofpp_name):
return data return data
class NXActionSetTunnel(_NXActionSetTunnelBase): class NXActionSetTunnel(_NXActionSetTunnelBase):
""" r"""
Set Tunnel action Set Tunnel action
This action sets the identifier (such as GRE) to the specified id. This action sets the identifier (such as GRE) to the specified id.
@ -600,7 +600,7 @@ def generate(ofp_name, ofpp_name):
_fmt_str = '!2xI' _fmt_str = '!2xI'
class NXActionSetTunnel64(_NXActionSetTunnelBase): class NXActionSetTunnel64(_NXActionSetTunnelBase):
""" r"""
Set Tunnel action Set Tunnel action
This action outputs to a port that encapsulates This action outputs to a port that encapsulates
@ -648,7 +648,7 @@ def generate(ofp_name, ofpp_name):
_fmt_str = '!6xQ' _fmt_str = '!6xQ'
class NXActionRegMove(NXAction): class NXActionRegMove(NXAction):
""" r"""
Move register action Move register action
This action copies the src to dst. This action copies the src to dst.
@ -737,7 +737,7 @@ def generate(ofp_name, ofpp_name):
return data return data
class NXActionResubmit(NXAction): class NXActionResubmit(NXAction):
""" r"""
Resubmit action Resubmit action
This action searches one of the switch's flow tables. This action searches one of the switch's flow tables.
@ -786,7 +786,7 @@ def generate(ofp_name, ofpp_name):
return data return data
class NXActionResubmitTable(NXAction): class NXActionResubmitTable(NXAction):
""" r"""
Resubmit action Resubmit action
This action searches one of the switch's flow tables. This action searches one of the switch's flow tables.
@ -840,7 +840,7 @@ def generate(ofp_name, ofpp_name):
return data return data
class NXActionOutputReg(NXAction): class NXActionOutputReg(NXAction):
""" r"""
Add output action Add output action
This action outputs the packet to the OpenFlow port number read from This action outputs the packet to the OpenFlow port number read from
@ -914,7 +914,7 @@ def generate(ofp_name, ofpp_name):
return data return data
class NXActionOutputReg2(NXAction): class NXActionOutputReg2(NXAction):
""" r"""
Add output action Add output action
This action outputs the packet to the OpenFlow port number read from This action outputs the packet to the OpenFlow port number read from
@ -996,7 +996,7 @@ def generate(ofp_name, ofpp_name):
return data return data
class NXActionLearn(NXAction): class NXActionLearn(NXAction):
""" r"""
Adds or modifies flow action Adds or modifies flow action
This action adds or modifies a flow in OpenFlow table. This action adds or modifies a flow in OpenFlow table.
@ -1260,7 +1260,7 @@ def generate(ofp_name, ofpp_name):
return data return data
class NXActionController(NXAction): class NXActionController(NXAction):
""" r"""
Send packet in message action Send packet in message action
This action sends the packet to the OpenFlow controller as This action sends the packet to the OpenFlow controller as
@ -1325,7 +1325,7 @@ def generate(ofp_name, ofpp_name):
return data return data
class NXActionController2(NXAction): class NXActionController2(NXAction):
""" r"""
Send packet in message action Send packet in message action
This action sends the packet to the OpenFlow controller as This action sends the packet to the OpenFlow controller as
@ -1571,7 +1571,7 @@ def generate(ofp_name, ofpp_name):
return data return data
class NXActionDecTtlCntIds(NXAction): class NXActionDecTtlCntIds(NXAction):
""" r"""
Decrement TTL action Decrement TTL action
This action decrements TTL of IPv4 packet or This action decrements TTL of IPv4 packet or
@ -1682,7 +1682,7 @@ def generate(ofp_name, ofpp_name):
# For OpenFlow1.0 only # For OpenFlow1.0 only
class NXActionPushMpls(NXActionMplsBase): class NXActionPushMpls(NXActionMplsBase):
""" r"""
Push MPLS action Push MPLS action
This action pushes a new MPLS header to the packet. This action pushes a new MPLS header to the packet.
@ -1717,7 +1717,7 @@ def generate(ofp_name, ofpp_name):
# For OpenFlow1.0 only # For OpenFlow1.0 only
class NXActionPopMpls(NXActionMplsBase): class NXActionPopMpls(NXActionMplsBase):
""" r"""
Pop MPLS action Pop MPLS action
This action pops the MPLS header from the packet. This action pops the MPLS header from the packet.
@ -1752,7 +1752,7 @@ def generate(ofp_name, ofpp_name):
# For OpenFlow1.0 only # For OpenFlow1.0 only
class NXActionSetMplsTtl(NXAction): class NXActionSetMplsTtl(NXAction):
""" r"""
Set MPLS TTL action Set MPLS TTL action
This action sets the MPLS TTL. This action sets the MPLS TTL.
@ -1851,7 +1851,7 @@ def generate(ofp_name, ofpp_name):
# For OpenFlow1.0 only # For OpenFlow1.0 only
class NXActionSetMplsLabel(NXAction): class NXActionSetMplsLabel(NXAction):
""" r"""
Set MPLS Lavel action Set MPLS Lavel action
This action sets the MPLS Label. This action sets the MPLS Label.
@ -1906,7 +1906,7 @@ def generate(ofp_name, ofpp_name):
# For OpenFlow1.0 only # For OpenFlow1.0 only
class NXActionSetMplsTc(NXAction): class NXActionSetMplsTc(NXAction):
""" r"""
Set MPLS Tc action Set MPLS Tc action
This action sets the MPLS Tc. This action sets the MPLS Tc.
@ -2000,7 +2000,7 @@ def generate(ofp_name, ofpp_name):
return data return data
class NXActionStackPush(NXActionStackBase): class NXActionStackPush(NXActionStackBase):
""" r"""
Push field action Push field action
This action pushes field to top of the stack. This action pushes field to top of the stack.
@ -2032,7 +2032,7 @@ def generate(ofp_name, ofpp_name):
_subtype = nicira_ext.NXAST_STACK_PUSH _subtype = nicira_ext.NXAST_STACK_PUSH
class NXActionStackPop(NXActionStackBase): class NXActionStackPop(NXActionStackBase):
""" r"""
Pop field action Pop field action
This action pops field from top of the stack. This action pops field from top of the stack.
@ -2064,7 +2064,7 @@ def generate(ofp_name, ofpp_name):
_subtype = nicira_ext.NXAST_STACK_POP _subtype = nicira_ext.NXAST_STACK_POP
class NXActionSample(NXAction): class NXActionSample(NXAction):
""" r"""
Sample packets action Sample packets action
This action samples packets and sends one sample for This action samples packets and sends one sample for
@ -2137,7 +2137,7 @@ def generate(ofp_name, ofpp_name):
return data return data
class NXActionSample2(NXAction): class NXActionSample2(NXAction):
""" r"""
Sample packets action Sample packets action
This action samples packets and sends one sample for This action samples packets and sends one sample for
@ -2218,7 +2218,7 @@ def generate(ofp_name, ofpp_name):
return data return data
class NXActionFinTimeout(NXAction): class NXActionFinTimeout(NXAction):
""" r"""
Change TCP timeout action Change TCP timeout action
This action changes the idle timeout or hard timeout or This action changes the idle timeout or hard timeout or
@ -2279,7 +2279,7 @@ def generate(ofp_name, ofpp_name):
return data return data
class NXActionConjunction(NXAction): class NXActionConjunction(NXAction):
""" r"""
Conjunctive matches action Conjunctive matches action
This action ties groups of individual OpenFlow flows into This action ties groups of individual OpenFlow flows into
@ -2342,7 +2342,7 @@ def generate(ofp_name, ofpp_name):
return data return data
class NXActionMultipath(NXAction): class NXActionMultipath(NXAction):
""" r"""
Select multipath link action Select multipath link action
This action selects multipath link based on the specified parameters. This action selects multipath link based on the specified parameters.
@ -2528,7 +2528,7 @@ def generate(ofp_name, ofpp_name):
return data return data
class NXActionBundle(_NXActionBundleBase): class NXActionBundle(_NXActionBundleBase):
""" r"""
Select bundle link action Select bundle link action
This action selects bundle link based on the specified parameters. This action selects bundle link based on the specified parameters.
@ -2581,7 +2581,7 @@ def generate(ofp_name, ofpp_name):
ofs_nbits=0, dst=0, slaves=slaves) ofs_nbits=0, dst=0, slaves=slaves)
class NXActionBundleLoad(_NXActionBundleBase): class NXActionBundleLoad(_NXActionBundleBase):
""" r"""
Select bundle link action Select bundle link action
This action has the same behavior as the bundle action, This action has the same behavior as the bundle action,
@ -2642,7 +2642,7 @@ def generate(ofp_name, ofpp_name):
ofs_nbits, dst, slaves) ofs_nbits, dst, slaves)
class NXActionCT(NXAction): class NXActionCT(NXAction):
""" r"""
Pass traffic to the connection tracker action Pass traffic to the connection tracker action
This action sends the packet through the connection tracker. This action sends the packet through the connection tracker.
@ -2804,7 +2804,7 @@ def generate(ofp_name, ofpp_name):
return data return data
class NXActionNAT(NXAction): class NXActionNAT(NXAction):
""" r"""
Network address translation action Network address translation action
This action sends the packet through the connection tracker. This action sends the packet through the connection tracker.
@ -2967,7 +2967,7 @@ def generate(ofp_name, ofpp_name):
return data return data
class NXActionOutputTrunc(NXAction): class NXActionOutputTrunc(NXAction):
""" r"""
Truncate output action Truncate output action
This action truncate a packet into the specified size and outputs it. This action truncate a packet into the specified size and outputs it.

View File

@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
""" r"""
Usage: Usage:
PYTHONPATH=. ./bin/ryu-manager --verbose \ PYTHONPATH=. ./bin/ryu-manager --verbose \
ryu.services.protocols.vrrp.dumper \ ryu.services.protocols.vrrp.dumper \

View File

@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
""" r"""
Usage: Usage:
PYTHONPATH=. ./bin/ryu-manager --verbose \ PYTHONPATH=. ./bin/ryu-manager --verbose \
ryu.topology.switches \ ryu.topology.switches \

View File

@ -319,7 +319,7 @@ if __name__ == '__main__':
stdout=subprocess.PIPE) stdout=subprocess.PIPE)
has_names = False has_names = False
try: try:
ver_tuple = re.search('\s(\d+)\.(\d+)(\.\d*|\s*$)', ver_tuple = re.search(r'\s(\d+)\.(\d+)(\.\d*|\s*$)',
ovs_version.stdout.readline().decode()).groups() ovs_version.stdout.readline().decode()).groups()
if int(ver_tuple[0]) > 2 or \ if int(ver_tuple[0]) > 2 or \
int(ver_tuple[0]) == 2 and int(ver_tuple[1]) >= 8: int(ver_tuple[0]) == 2 and int(ver_tuple[1]) >= 8: