Skip to content

Commit

Permalink
Merge pull request #2635 from wereii/fix-syntax-warnings
Browse files Browse the repository at this point in the history
Fix invalid escape syntax warnings
  • Loading branch information
DarkFenX authored Nov 27, 2024
2 parents 08d4e85 + 45f0743 commit ea26d57
Show file tree
Hide file tree
Showing 15 changed files with 40 additions and 40 deletions.
4 changes: 2 additions & 2 deletions db_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion dist_assets/win/dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
2 changes: 1 addition & 1 deletion eos/db/migrations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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<index>\d+)$", modname_tail)
m = re.match(r"^upgrade(?P<index>\d+)$", modname_tail)
if not m:
continue
index = int(m.group("index"))
Expand Down
2 changes: 1 addition & 1 deletion graphs/gui/canvasPanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions gui/builtinItemStatsViews/itemDescription.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ def __init__(self, parent, stuff, item):

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),
Expand Down
4 changes: 2 additions & 2 deletions gui/builtinViews/implantEditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@


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


Expand Down
4 changes: 2 additions & 2 deletions gui/updateDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions gui/utils/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion scripts/dump_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
2 changes: 1 addition & 1 deletion scripts/effectUsedBy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion scripts/itemDiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion service/market.py
Original file line number Diff line number Diff line change
Expand Up @@ -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<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)
Expand Down
36 changes: 18 additions & 18 deletions service/port/eft.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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, ()
Expand All @@ -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, ()
Expand All @@ -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, ()
Expand All @@ -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, ()
Expand All @@ -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, ()
Expand Down
8 changes: 4 additions & 4 deletions service/port/port.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<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")),)
Expand Down
2 changes: 1 addition & 1 deletion service/prereqsCheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit ea26d57

Please sign in to comment.