diff --git a/db_update.py b/db_update.py index 1be20f2702..c0361679b3 100644 --- a/db_update.py +++ b/db_update.py @@ -141,14 +141,14 @@ def processEveTypes(): (row['typeName_en-us'].startswith('Civilian') and "Shuttle" not in row['typeName_en-us']) or row['typeName_en-us'] == 'Capsule' or row['groupID'] == 4033 # destructible effect beacons - or re.match('AIR .+Booster.*', row['typeName_en-us']) + or re.match(r'AIR .+Booster.*', row['typeName_en-us']) ): row['published'] = True # Nearly useless and clutter search results too much elif ( row['typeName_en-us'].startswith('Limited Synth ') or row['typeName_en-us'].startswith('Expired ') - or re.match('Mining Blitz .+ Booster Dose .+', row['typeName_en-us']) + or re.match(r'Mining Blitz .+ Booster Dose .+', row['typeName_en-us']) or row['typeName_en-us'].endswith(' Filament') and ( "'Needlejack'" not in row['typeName_en-us'] and "'Devana'" not in row['typeName_en-us'] and diff --git a/dist_assets/win/dist.py b/dist_assets/win/dist.py index be543ee201..c4663bc1d0 100644 --- a/dist_assets/win/dist.py +++ b/dist_assets/win/dist.py @@ -14,7 +14,7 @@ os.environ["PYFA_DIST_DIR"] = os.path.join(os.getcwd(), 'dist') os.environ["PYFA_VERSION"] = version -iscc = "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" +iscc = r"C:\Program Files (x86)\Inno Setup 6\ISCC.exe" source = os.path.join(os.environ["PYFA_DIST_DIR"], "pyfa") diff --git a/eos/db/migrations/__init__.py b/eos/db/migrations/__init__.py index b5034ac036..a9546b086f 100644 --- a/eos/db/migrations/__init__.py +++ b/eos/db/migrations/__init__.py @@ -21,7 +21,7 @@ # loop through python files, extracting update number and function, and # adding it to a list modname_tail = modName.rsplit('.', 1)[-1] - m = re.match("^upgrade(?P\d+)$", modname_tail) + m = re.match(r"^upgrade(?P\d+)$", modname_tail) if not m: continue index = int(m.group("index")) diff --git a/graphs/gui/canvasPanel.py b/graphs/gui/canvasPanel.py index 83b8a2ced3..4c862f6001 100644 --- a/graphs/gui/canvasPanel.py +++ b/graphs/gui/canvasPanel.py @@ -273,7 +273,7 @@ def addYMark(val): legendLines = [] for i, iData in enumerate(legendData): color, lineStyle, label = iData - legendLines.append(Line2D([0], [0], color=color, linestyle=lineStyle, label=label.replace('$', '\$'))) + legendLines.append(Line2D([0], [0], color=color, linestyle=lineStyle, label=label.replace('$', r'\$'))) if len(legendLines) > 0 and self.graphFrame.ctrlPanel.showLegend: legend = self.subplot.legend(handles=legendLines) diff --git a/gui/builtinItemStatsViews/itemDescription.py b/gui/builtinItemStatsViews/itemDescription.py index 2929303810..50292e361a 100644 --- a/gui/builtinItemStatsViews/itemDescription.py +++ b/gui/builtinItemStatsViews/itemDescription.py @@ -22,9 +22,9 @@ def __init__(self, parent, stuff, item): desc = item.description.replace("\n", "
") # Strip font tags - desc = re.sub("<( *)font( *)color( *)=(.*?)>(?P.*?)<( *)/( *)font( *)>", "\g", desc) + desc = re.sub("<( *)font( *)color( *)=(.*?)>(?P.*?)<( *)/( *)font( *)>", r"\g", desc) # Strip URLs - desc = re.sub("<( *)a(.*?)>(?P.*?)<( *)/( *)a( *)>", "\g", desc) + desc = re.sub("<( *)a(.*?)>(?P.*?)<( *)/( *)a( *)>", r"\g", desc) desc = "{}".format( bgcolor.GetAsString(wx.C2S_HTML_SYNTAX), fgcolor.GetAsString(wx.C2S_HTML_SYNTAX), diff --git a/gui/builtinViews/implantEditor.py b/gui/builtinViews/implantEditor.py index 5cc1c1d72a..cf735fe8f6 100644 --- a/gui/builtinViews/implantEditor.py +++ b/gui/builtinViews/implantEditor.py @@ -13,8 +13,8 @@ def stripHtml(text): - text = re.sub('<\s*br\s*/?\s*>', '\n', text) - text = re.sub('', '', text) + text = re.sub(r'<\s*br\s*/?\s*>', '\n', text) + text = re.sub(r'', '', text) return text diff --git a/gui/updateDialog.py b/gui/updateDialog.py index 0565f7962a..fc465c4632 100644 --- a/gui/updateDialog.py +++ b/gui/updateDialog.py @@ -66,8 +66,8 @@ def __init__(self, parent, release, version): self.browser.Bind(wx.html2.EVT_WEBVIEW_NEWWINDOW, self.OnNewWindow) link_patterns = [ - (re.compile("#(\d+)", re.I), r"https://github.com/pyfa-org/Pyfa/issues/\1"), - (re.compile("@(\w+)", re.I), r"https://github.com/\1") + (re.compile(r"#(\d+)", re.I), r"https://github.com/pyfa-org/Pyfa/issues/\1"), + (re.compile(r"@(\w+)", re.I), r"https://github.com/\1") ] markdowner = markdown2.Markdown( diff --git a/gui/utils/inputs.py b/gui/utils/inputs.py index 35a150fe70..c2beab89da 100644 --- a/gui/utils/inputs.py +++ b/gui/utils/inputs.py @@ -96,7 +96,7 @@ def OnText(self, event): if currentValue == self._storedValue: event.Skip() return - if currentValue == '' or re.match('^\d*\.?\d*$', currentValue): + if currentValue == '' or re.match(r'^\d*\.?\d*$', currentValue): self._storedValue = currentValue self.updateColor() event.Skip() @@ -131,7 +131,7 @@ def OnText(self, event): if currentValue == self._storedValue: event.Skip() return - if currentValue == '' or re.match('^\d*\.?\d*-?\d*\.?\d*$', currentValue): + if currentValue == '' or re.match(r'^\d*\.?\d*-?\d*\.?\d*$', currentValue): self._storedValue = currentValue event.Skip() else: diff --git a/scripts/dump_data.py b/scripts/dump_data.py index a85ed26c46..561c1c23d0 100644 --- a/scripts/dump_data.py +++ b/scripts/dump_data.py @@ -117,7 +117,7 @@ def __secure_name(self, name): # Prefer safe way - replace any characters besides # alphanumeric and few special characters with # underscore - writer_safe_name = re.sub('[^\w\-.,() ]', '_', name, flags=re.UNICODE) + writer_safe_name = re.sub(r'[^\w\-.,() ]', '_', name, flags=re.UNICODE) return writer_safe_name diff --git a/scripts/effectUsedBy.py b/scripts/effectUsedBy.py index 3ff2a7f611..f2883aaf74 100755 --- a/scripts/effectUsedBy.py +++ b/scripts/effectUsedBy.py @@ -395,7 +395,7 @@ def validate_string(s): with open(effects_path) as f: for line in f: - m = re.match("class Effect(\d+)\(", line) + m = re.match(r"class Effect(\d+)\(", line) if m: effectid = int(m.group(1)) effectids_eos.add(effectid) diff --git a/scripts/itemDiff.py b/scripts/itemDiff.py index 5ac263caf8..09dca6e399 100755 --- a/scripts/itemDiff.py +++ b/scripts/itemDiff.py @@ -57,7 +57,7 @@ def main(old, new, groups=True, effects=True, attributes=True, renames=True): with open(effectspath) as f: for line in f: - for m in re.finditer('class Effect(?P\d+)\(BaseEffect\):', line): + for m in re.finditer(r'class Effect(?P\d+)\(BaseEffect\):', line): effectid = int(m.group('eid')) implemented.add(effectid) diff --git a/service/market.py b/service/market.py index f240ab157f..9db615e2fb 100644 --- a/service/market.py +++ b/service/market.py @@ -184,7 +184,7 @@ def stop(self): def _prepareRequestNormal(self, request): # Escape regexp-specific symbols, and un-escape whitespaces request = re.escape(request) - request = re.sub(r'\\(?P\s+)', '\\g', request) + request = re.sub(r'\\(?P\s+)', r'\g', request) # Imitate wildcard search request = re.sub(r'\\\*', r'\\w*', request) request = re.sub(r'\\\?', r'\\w?', request) diff --git a/service/port/eft.py b/service/port/eft.py index dd05d9d26c..31007f2642 100644 --- a/service/port/eft.py +++ b/service/port/eft.py @@ -46,7 +46,7 @@ MODULE_CATS = ('Module', 'Subsystem', 'Structure Module') SLOT_ORDER = (FittingSlot.LOW, FittingSlot.MED, FittingSlot.HIGH, FittingSlot.RIG, FittingSlot.SUBSYSTEM, FittingSlot.SERVICE) OFFLINE_SUFFIX = '/OFFLINE' -NAME_CHARS = '[^,/\[\]]' # Characters which are allowed to be used in name +NAME_CHARS = r'[^,/\[\]]' # Characters which are allowed to be used in name class MutationExportData: @@ -247,9 +247,9 @@ def importEft(lines): aFit = AbstractFit() aFit.mutations = importGetMutationData(lines) - stubPattern = '^\[.+?\]$' - modulePattern = '^(?P{0}+?)(,\s*(?P{0}+?))?(?P\s*{1})?(\s*\[(?P\d+?)\])?$'.format(NAME_CHARS, OFFLINE_SUFFIX) - droneCargoPattern = '^(?P{}+?) x(?P\d+?)(\s*\[(?P\d+?)\])?$'.format(NAME_CHARS) + stubPattern = r'^\[.+?\]$' + modulePattern = r'^(?P{0}+?)(,\s*(?P{0}+?))?(?P\s*{1})?(\s*\[(?P\d+?)\])?$'.format(NAME_CHARS, OFFLINE_SUFFIX) + droneCargoPattern = r'^(?P{}+?) x(?P\d+?)(\s*\[(?P\d+?)\])?$'.format(NAME_CHARS) sections = [] for section in _importSectionIter(lines): @@ -419,17 +419,17 @@ def importEftCfg(shipname, lines, progress): continue # Parse line into some data we will need - misc = re.match("(Drones|Implant|Booster)_(Active|Inactive)=(.+)", line) - cargo = re.match("Cargohold=(.+)", line) + misc = re.match(r"(Drones|Implant|Booster)_(Active|Inactive)=(.+)", line) + cargo = re.match(r"Cargohold=(.+)", line) # 2017/03/27 NOTE: store description from EFT - description = re.match("Description=(.+)", line) + description = re.match(r"Description=(.+)", line) if misc: entityType = misc.group(1) entityState = misc.group(2) entityData = misc.group(3) if entityType == "Drones": - droneData = re.match("(.+),([0-9]+)", entityData) + droneData = re.match(r"(.+),([0-9]+)", entityData) # Get drone name and attempt to detect drone number droneName = droneData.group(1) if droneData else entityData droneAmount = int(droneData.group(2)) if droneData else 1 @@ -495,7 +495,7 @@ def importEftCfg(shipname, lines, progress): fitobj.boosters.append(b) # If we don't have any prefixes, then it's a module elif cargo: - cargoData = re.match("(.+),([0-9]+)", cargo.group(1)) + cargoData = re.match(r"(.+),([0-9]+)", cargo.group(1)) cargoName = cargoData.group(1) if cargoData else cargo.group(1) cargoAmount = int(cargoData.group(2)) if cargoData else 1 # Bail if we can't get item @@ -514,7 +514,7 @@ def importEftCfg(shipname, lines, progress): elif description: fitobj.notes = description.group(1).replace("|", "\n") else: - withCharge = re.match("(.+),(.+)", line) + withCharge = re.match(r"(.+),(.+)", line) modName = withCharge.group(1) if withCharge else line chargeName = withCharge.group(2) if withCharge else None # If we can't get module item, skip it @@ -588,7 +588,7 @@ def _importPrepare(lines): return lines -mutantHeaderPattern = re.compile('^\[(?P\d+)\](?P.*)') +mutantHeaderPattern = re.compile(r'^\[(?P\d+)\](?P.*)') def importGetMutationData(lines): @@ -649,7 +649,7 @@ def _importCreateFit(lines): """Create fit and set top-level entity (ship or citadel).""" fit = Fit() header = lines.pop(0) - m = re.match('\[(?P[^,]+),\s*(?P.+)\]', header) + m = re.match(r'\[(?P[^,]+),\s*(?P.+)\]', header) if not m: pyfalog.warning('service.port.eft.importEft: corrupted fit header') raise EftImportError @@ -972,7 +972,7 @@ def lineIter(text): def parseAdditions(text, mutaData=None): items = [] sMkt = Market.getInstance() - pattern = '^(?P{}+?)( x(?P\d+?))?(\s*\[(?P\d+?)\])?$'.format(NAME_CHARS) + pattern = r'^(?P{}+?)( x(?P\d+?))?(\s*\[(?P\d+?)\])?$'.format(NAME_CHARS) for line in lineIter(text): m = re.match(pattern, line) if not m: @@ -995,7 +995,7 @@ def isValidDroneImport(text): lines = list(lineIter(text)) mutaData = importGetMutationData(lines) text = '\n'.join(lines) - pattern = 'x\d+(\s*\[\d+\])?$' + pattern = r'x\d+(\s*\[\d+\])?$' for line in lineIter(text): if not re.search(pattern, line): return False, () @@ -1009,7 +1009,7 @@ def isValidDroneImport(text): def isValidFighterImport(text): - pattern = 'x\d+$' + pattern = r'x\d+$' for line in lineIter(text): if not re.search(pattern, line): return False, () @@ -1023,7 +1023,7 @@ def isValidFighterImport(text): def isValidCargoImport(text): - pattern = 'x\d+$' + pattern = r'x\d+$' for line in lineIter(text): if not re.search(pattern, line): return False, () @@ -1037,7 +1037,7 @@ def isValidCargoImport(text): def isValidImplantImport(text): - pattern = 'x\d+$' + pattern = r'x\d+$' for line in lineIter(text): if re.search(pattern, line): return False, () @@ -1051,7 +1051,7 @@ def isValidImplantImport(text): def isValidBoosterImport(text): - pattern = 'x\d+$' + pattern = r'x\d+$' for line in lineIter(text): if re.search(pattern, line): return False, () diff --git a/service/port/port.py b/service/port/port.py index 6c175e2ab2..cb10994715 100644 --- a/service/port/port.py +++ b/service/port/port.py @@ -231,21 +231,21 @@ def importAuto(cls, string, path=None, activeFit=None, progress=None): # If we've got source file name which is used to describe ship name # and first line contains something like [setup name], detect as eft config file - if re.match("^\s*\[.*\]", firstLine) and path is not None: + if re.match(r"^\s*\[.*\]", firstLine) and path is not None: filename = os.path.split(path)[1] shipName = filename.rsplit('.')[0] return "EFT Config", True, cls.importEftCfg(shipName, lines, progress) # If no file is specified and there's comma between brackets, # consider that we have [ship, setup name] and detect like eft export format - if re.match("^\s*\[.*,.*\]", firstLine): + if re.match(r"^\s*\[.*,.*\]", firstLine): return "EFT", True, (cls.importEft(lines),) # Check if string is in DNA format - dnaPattern = "\d+(:\d+(;\d+))*::" + dnaPattern = r"\d+(:\d+(;\d+))*::" if re.match(dnaPattern, firstLine): return "DNA", True, (cls.importDna(string),) - dnaChatPattern = "{})>(?P[^<>]+)".format(dnaPattern) + dnaChatPattern = r"{})>(?P[^<>]+)".format(dnaPattern) m = re.search(dnaChatPattern, firstLine) if m: return "DNA", True, (cls.importDna(m.group("dna"), fitName=m.group("fitName")),) diff --git a/service/prereqsCheck.py b/service/prereqsCheck.py index 3bbb1b81e6..f2a1b37eb9 100644 --- a/service/prereqsCheck.py +++ b/service/prereqsCheck.py @@ -55,7 +55,7 @@ def version_precheck(): try: import sqlalchemy - saMatch = re.match("([0-9]+).([0-9]+).([0-9]+)(([b\.])([0-9]+))?", sqlalchemy.__version__) + saMatch = re.match(r"([0-9]+).([0-9]+).([0-9]+)(([b\.])([0-9]+))?", sqlalchemy.__version__) version_block += "\nSQLAlchemy version: {}".format(sqlalchemy.__version__) if (int(saMatch.group(1)), int(saMatch.group(2)), int(saMatch.group(3))) < (1, 0, 5):