Merge pull request #2635 from wereii/fix-syntax-warnings
Fix invalid escape syntax warnings
This commit is contained in:
@@ -141,14 +141,14 @@ def update_db():
|
||||
(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
|
||||
|
||||
@@ -14,7 +14,7 @@ with open("version.yml", 'r') as file:
|
||||
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")
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ for modName in iterNamespace(__name__, __path__):
|
||||
# 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<index>\d+)$", modname_tail)
|
||||
m = re.match(r"^upgrade(?P<index>\d+)$", modname_tail)
|
||||
if not m:
|
||||
continue
|
||||
index = int(m.group("index"))
|
||||
|
||||
@@ -273,7 +273,7 @@ class GraphCanvasPanel(wx.Panel):
|
||||
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)
|
||||
|
||||
@@ -22,9 +22,9 @@ class ItemDescription(wx.Panel):
|
||||
|
||||
desc = item.description.replace("\n", "<br>")
|
||||
# Strip font tags
|
||||
desc = re.sub("<( *)font( *)color( *)=(.*?)>(?P<inside>.*?)<( *)/( *)font( *)>", "\g<inside>", desc)
|
||||
desc = re.sub("<( *)font( *)color( *)=(.*?)>(?P<inside>.*?)<( *)/( *)font( *)>", r"\g<inside>", desc)
|
||||
# Strip URLs
|
||||
desc = re.sub("<( *)a(.*?)>(?P<inside>.*?)<( *)/( *)a( *)>", "\g<inside>", desc)
|
||||
desc = re.sub("<( *)a(.*?)>(?P<inside>.*?)<( *)/( *)a( *)>", r"\g<inside>", desc)
|
||||
desc = "<body bgcolor='{}' text='{}'>{}</body>".format(
|
||||
bgcolor.GetAsString(wx.C2S_HTML_SYNTAX),
|
||||
fgcolor.GetAsString(wx.C2S_HTML_SYNTAX),
|
||||
|
||||
@@ -13,8 +13,8 @@ from service.market import Market
|
||||
|
||||
|
||||
def stripHtml(text):
|
||||
text = re.sub('<\s*br\s*/?\s*>', '\n', text)
|
||||
text = re.sub('</?[^/]+?(/\s*)?>', '', text)
|
||||
text = re.sub(r'<\s*br\s*/?\s*>', '\n', text)
|
||||
text = re.sub(r'</?[^/]+?(/\s*)?>', '', text)
|
||||
return text
|
||||
|
||||
|
||||
|
||||
@@ -66,8 +66,8 @@ class UpdateDialog(wx.Dialog):
|
||||
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(
|
||||
|
||||
@@ -96,7 +96,7 @@ class FloatBox(wx.TextCtrl):
|
||||
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 @@ class FloatRangeBox(wx.TextCtrl):
|
||||
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:
|
||||
|
||||
@@ -117,7 +117,7 @@ class PyfaJsonWriter(BaseWriter):
|
||||
# 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
|
||||
|
||||
|
||||
|
||||
@@ -395,7 +395,7 @@ effectids_eos = set()
|
||||
|
||||
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)
|
||||
|
||||
@@ -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<eid>\d+)\(BaseEffect\):', line):
|
||||
for m in re.finditer(r'class Effect(?P<eid>\d+)\(BaseEffect\):', line):
|
||||
effectid = int(m.group('eid'))
|
||||
implemented.add(effectid)
|
||||
|
||||
|
||||
@@ -184,7 +184,7 @@ class SearchWorkerThread(threading.Thread):
|
||||
def _prepareRequestNormal(self, request):
|
||||
# Escape regexp-specific symbols, and un-escape whitespaces
|
||||
request = re.escape(request)
|
||||
request = re.sub(r'\\(?P<ws>\s+)', '\\g<ws>', request)
|
||||
request = re.sub(r'\\(?P<ws>\s+)', r'\g<ws>', request)
|
||||
# Imitate wildcard search
|
||||
request = re.sub(r'\\\*', r'\\w*', request)
|
||||
request = re.sub(r'\\\?', r'\\w?', request)
|
||||
|
||||
@@ -46,7 +46,7 @@ pyfalog = Logger(__name__)
|
||||
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<typeName>{0}+?)(,\s*(?P<chargeName>{0}+?))?(?P<offline>\s*{1})?(\s*\[(?P<mutation>\d+?)\])?$'.format(NAME_CHARS, OFFLINE_SUFFIX)
|
||||
droneCargoPattern = '^(?P<typeName>{}+?) x(?P<amount>\d+?)(\s*\[(?P<mutation>\d+?)\])?$'.format(NAME_CHARS)
|
||||
stubPattern = r'^\[.+?\]$'
|
||||
modulePattern = r'^(?P<typeName>{0}+?)(,\s*(?P<chargeName>{0}+?))?(?P<offline>\s*{1})?(\s*\[(?P<mutation>\d+?)\])?$'.format(NAME_CHARS, OFFLINE_SUFFIX)
|
||||
droneCargoPattern = r'^(?P<typeName>{}+?) x(?P<amount>\d+?)(\s*\[(?P<mutation>\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<ref>\d+)\](?P<tail>.*)')
|
||||
mutantHeaderPattern = re.compile(r'^\[(?P<ref>\d+)\](?P<tail>.*)')
|
||||
|
||||
|
||||
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<shipType>[^,]+),\s*(?P<fitName>.+)\]', header)
|
||||
m = re.match(r'\[(?P<shipType>[^,]+),\s*(?P<fitName>.+)\]', 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<typeName>{}+?)( x(?P<amount>\d+?))?(\s*\[(?P<mutaref>\d+?)\])?$'.format(NAME_CHARS)
|
||||
pattern = r'^(?P<typeName>{}+?)( x(?P<amount>\d+?))?(\s*\[(?P<mutaref>\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, ()
|
||||
|
||||
@@ -231,21 +231,21 @@ class Port:
|
||||
|
||||
# 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 = "<url=fitting:(?P<dna>{})>(?P<fitName>[^<>]+)</url>".format(dnaPattern)
|
||||
dnaChatPattern = r"<url=fitting:(?P<dna>{})>(?P<fitName>[^<>]+)</url>".format(dnaPattern)
|
||||
m = re.search(dnaChatPattern, firstLine)
|
||||
if m:
|
||||
return "DNA", True, (cls.importDna(m.group("dna"), fitName=m.group("fitName")),)
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user