Unverified Commit 9de04d22 authored by Jintao Lin's avatar Jintao Lin Committed by GitHub
Browse files

Replace `re` with `regex` (#457)

* replace `re` with `regex`

* add regex in requirements

* use regex on windows and re on linux

* update requirements.txt
parent 66864d4a
import inspect import inspect
import re import platform
from .registry import PLUGIN_LAYERS from .registry import PLUGIN_LAYERS
if platform.system() == 'Windows':
import regex as re
else:
import re
def infer_abbr(class_type): def infer_abbr(class_type):
"""Infer abbreviation from the class name. """Infer abbreviation from the class name.
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
import ast import ast
import os.path as osp import os.path as osp
import platform import platform
import re
import shutil import shutil
import sys import sys
import tempfile import tempfile
...@@ -15,6 +14,11 @@ from yapf.yapflib.yapf_api import FormatCode ...@@ -15,6 +14,11 @@ from yapf.yapflib.yapf_api import FormatCode
from .path import check_file_exist from .path import check_file_exist
if platform.system() == 'Windows':
import regex as re
else:
import re
BASE_KEY = '_base_' BASE_KEY = '_base_'
DELETE_KEY = '_delete_' DELETE_KEY = '_delete_'
RESERVED_KEYS = ['filename', 'text', 'pretty_text'] RESERVED_KEYS = ['filename', 'text', 'pretty_text']
......
import logging import logging
import re import platform
import tempfile import tempfile
from unittest.mock import patch from unittest.mock import patch
...@@ -7,6 +7,11 @@ import pytest ...@@ -7,6 +7,11 @@ import pytest
from mmcv import get_logger, print_log from mmcv import get_logger, print_log
if platform.system() == 'Windows':
import regex as re
else:
import re
@patch('torch.distributed.get_rank', lambda: 0) @patch('torch.distributed.get_rank', lambda: 0)
@patch('torch.distributed.is_initialized', lambda: True) @patch('torch.distributed.is_initialized', lambda: True)
......
import os import os
import re import platform
import numpy as np import numpy as np
import torch import torch
import torch.distributed as dist import torch.distributed as dist
import torch.nn as nn import torch.nn as nn
if platform.system() == 'Windows':
import regex as re
else:
import re
class TestSyncBN(object): class TestSyncBN(object):
......
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