From 6ff2eb61097ded9e33d78bbfad6031e8dc64a47f Mon Sep 17 00:00:00 2001 From: MrD Date: Thu, 30 May 2019 17:59:40 +0300 Subject: [PATCH] Typo fix, some cruft and renames: bash/game/__init__.py: typo (914dba4eda506ccdd5fc05f89f61179929afca9c) Took the opportunity to throw in some local `flag` variable renames, untested but should be fine - under #312. Track using \bflags\b(?!=) and \bflags\s*=\s*(?!re) regexes. Mopy/bash/windows.py: Delete unused GetStockIcon GetStockIconLocation They were unused since dacfb390bb804d0f589c9b0bd52b5210e7e93899 - under #173. --- Mopy/bash/balt.py | 5 +- Mopy/bash/bolt.py | 6 +- Mopy/bash/bosh/_saves.py | 12 ++-- Mopy/bash/env.py | 16 ++--- Mopy/bash/game/__init__.py | 2 +- Mopy/bash/patcher/patchers/importers.py | 16 ++--- .../bash/patcher/patchers/multitweak_names.py | 22 +++--- Mopy/bash/windows.py | 67 +++++-------------- 8 files changed, 57 insertions(+), 89 deletions(-) diff --git a/Mopy/bash/balt.py b/Mopy/bash/balt.py index 181f7adb44..e92248fde3 100644 --- a/Mopy/bash/balt.py +++ b/Mopy/bash/balt.py @@ -1441,7 +1441,7 @@ def __init__(self, parent, fnDndAllow, pos=defPos, size=defSize, style=0, def OnDragging(self,x,y,dragResult): # We're dragging, see if we need to scroll the list - index, flags = self.HitTest((x, y)) + index, _hit_flags = self.HitTest((x, y)) if index == wx.NOT_FOUND: # Didn't drop it on an item if self.GetItemCount() > 0: if y <= self.GetItemRect(0).y: @@ -1503,8 +1503,7 @@ def OnDropFiles(self, x, y, filenames): def _OnDropList(self, x, y, indexes): start = indexes[0] stop = indexes[-1] - - index, flags = self.HitTest((x, y)) + index, _hit_flags = self.HitTest((x, y)) if index == wx.NOT_FOUND: # Didn't drop it on an item if self.GetItemCount() > 0: if y <= self.GetItemRect(0).y: diff --git a/Mopy/bash/bolt.py b/Mopy/bash/bolt.py index 2a7eea70ac..ee16a9702e 100644 --- a/Mopy/bash/bolt.py +++ b/Mopy/bash/bolt.py @@ -891,15 +891,15 @@ def clearRO(self): try: clearReadOnly(self) except UnicodeError: - flags = stat.S_IWUSR|stat.S_IWOTH + stat_flags = stat.S_IWUSR|stat.S_IWOTH chmod = os.chmod for root_dir,dirs,files in _walk(self._s): rootJoin = root_dir.join for directory in dirs: - try: chmod(rootJoin(directory),flags) + try: chmod(rootJoin(directory),stat_flags) except: pass for filename in files: - try: chmod(rootJoin(filename),flags) + try: chmod(rootJoin(filename),stat_flags) except: pass def open(self,*args,**kwdargs): diff --git a/Mopy/bash/bosh/_saves.py b/Mopy/bash/bosh/_saves.py index afe9b9fa37..d159cd9580 100644 --- a/Mopy/bash/bosh/_saves.py +++ b/Mopy/bash/bosh/_saves.py @@ -642,7 +642,7 @@ def getMaster(modIndex): objRefNullBases = 0 fids = self.fids for record in self.records: - fid,type,flags,version,data = record + fid,type,rec_flgs,version,data = record if fid ==0xFEFFFFFF: continue #--Ignore intentional(?) extra fid added by patch. mod = fid >> 24 if type not in typeModHisto: @@ -661,7 +661,7 @@ def getMaster(modIndex): print type,hex(fid),id_created[fid].recType knownTypes.add(type) #--Obj ref parents - if type == 49 and mod == 255 and (flags & 2): + if type == 49 and mod == 255 and (rec_flgs & 2): iref, = struct_unpack('I', data[4:8]) count,cumSize = objRefBases.get(iref,(0,0)) count += 1 @@ -730,8 +730,8 @@ def findBloating(self,progress=None): progress(len(self.created),_(u'Scanning change records.')) fids = self.fids for record in self.records: - fid,recType,flags,version,data = record - if recType == 49 and fid >> 24 == 0xFF and (flags & 2): + fid,recType,rec_flgs,version,data = record + if recType == 49 and fid >> 24 == 0xFF and (rec_flgs & 2): iref, = struct_unpack('I', data[4:8]) if iref >> 24 != 0xFF and fids[iref] == 0: nullRefCount += 1 @@ -765,10 +765,10 @@ def removeBloating(self,uncreateKeys,removeNullRefs=True,progress=None): fids = self.fids kept = [] for record in self.records: - fid,recType,flags,version,data = record + fid,recType,rec_flgs,version,data = record if fid in uncreated: numUnCreChanged += 1 - elif removeNullRefs and recType == 49 and fid >> 24 == 0xFF and (flags & 2): + elif removeNullRefs and recType == 49 and fid >> 24 == 0xFF and (rec_flgs & 2): iref, = struct_unpack('I', data[4:8]) if iref >> 24 != 0xFF and fids[iref] == 0: numUnNulled += 1 diff --git a/Mopy/bash/env.py b/Mopy/bash/env.py index d6288c3f44..e444c5424e 100644 --- a/Mopy/bash/env.py +++ b/Mopy/bash/env.py @@ -571,13 +571,13 @@ def _fileOperation(operation, source, target=None, allowUndo=True, _source = source; _target = target if __shell and shell is not None: # flags - flags = shellcon.FOF_WANTMAPPINGHANDLE # enables mapping return value ! - flags |= FOF_NOCONFIRMMKDIR # never ask user for creating dirs - flags |= (len(target) > 1) * shellcon.FOF_MULTIDESTFILES - if allowUndo: flags |= shellcon.FOF_ALLOWUNDO - if not confirm: flags |= shellcon.FOF_NOCONFIRMATION - if renameOnCollision: flags |= shellcon.FOF_RENAMEONCOLLISION - if silent: flags |= shellcon.FOF_SILENT + flgs = shellcon.FOF_WANTMAPPINGHANDLE # enables mapping return value ! + flgs |= FOF_NOCONFIRMMKDIR # never ask user for creating dirs + flgs |= (len(target) > 1) * shellcon.FOF_MULTIDESTFILES + if allowUndo: flgs |= shellcon.FOF_ALLOWUNDO + if not confirm: flgs |= shellcon.FOF_NOCONFIRMATION + if renameOnCollision: flgs |= shellcon.FOF_RENAMEONCOLLISION + if silent: flgs |= shellcon.FOF_SILENT # null terminated strings source = u'\x00'.join(source) # nope: + u'\x00' target = u'\x00'.join(target) @@ -588,7 +588,7 @@ def _fileOperation(operation, source, target=None, allowUndo=True, # aborted: True if any operations aborted, False otherwise # mapping: maps the old and new names of the renamed files result, aborted, mapping = shell.SHFileOperation( - (parent, operation, source, target, flags, None, None)) + (parent, operation, source, target, flgs, None, None)) if result == 0: if aborted: raise SkipError() return dict(mapping) diff --git a/Mopy/bash/game/__init__.py b/Mopy/bash/game/__init__.py index f3e9a7b9e5..2e99b825d8 100644 --- a/Mopy/bash/game/__init__.py +++ b/Mopy/bash/game/__init__.py @@ -136,7 +136,7 @@ class sd(object): class sp(object): sp_abbrev = u'' # Abbreviated name. If this is empty, it signals that # this game does not support SkyProc patchers. - long_ame = u'' # Full name + long_name = u'' # Full name install_dir = u'' # The directory, relative to the Data folder, into # which SkyProc patchers will be installed. diff --git a/Mopy/bash/patcher/patchers/importers.py b/Mopy/bash/patcher/patchers/importers.py index d131dec3fe..f9ec05db40 100644 --- a/Mopy/bash/patcher/patchers/importers.py +++ b/Mopy/bash/patcher/patchers/importers.py @@ -294,9 +294,9 @@ def importCellBlockData(cellBlock): for attr in attrs: tempCellData[fid][attr] = cellBlock.cell.__getattribute__( attr) - for flag in flags: + for flg_ in flgs_: tempCellData[fid + ('flags',)][ - flag] = cellBlock.cell.flags.__getattr__(flag) + flg_] = cellBlock.cell.flags.__getattr__(flg_) def checkMasterCellBlockData(cellBlock): """ Add attribute values from record(s) in master file(s). @@ -312,11 +312,11 @@ def checkMasterCellBlockData(cellBlock): master_attr = cellBlock.cell.__getattribute__(attr) if tempCellData[fid][attr] != master_attr: cellData[fid][attr] = tempCellData[fid][attr] - for flag in flags: - master_flag = cellBlock.cell.flags.__getattr__(flag) - if tempCellData[fid + ('flags',)][flag] != master_flag: - cellData[fid + ('flags',)][flag] = \ - tempCellData[fid + ('flags',)][flag] + for flg_ in flgs_: + master_flag = cellBlock.cell.flags.__getattr__(flg_) + if tempCellData[fid + ('flags',)][flg_] != master_flag: + cellData[fid + ('flags',)][flg_] = \ + tempCellData[fid + ('flags',)][flg_] loadFactory = LoadFactory(False,MreRecord.type_class['CELL'], MreRecord.type_class['WRLD']) progress.setFull(len(self.srcs)) @@ -341,7 +341,7 @@ def checkMasterCellBlockData(cellBlock): if not tags: continue attrs = set(reduce(# adds tuples together, then takes the set operator.concat, (self.recAttrs[bashKey] for bashKey in tags))) - flags = tuple(self.recFlags[bashKey] for bashKey in tags if + flgs_ = tuple(self.recFlags[bashKey] for bashKey in tags if self.recFlags[bashKey] != u'') if 'CELL' in srcFile.tops: for cellBlock in srcFile.CELL.cellBlocks: diff --git a/Mopy/bash/patcher/patchers/multitweak_names.py b/Mopy/bash/patcher/patchers/multitweak_names.py index 58495ea2ce..1474e89d7c 100644 --- a/Mopy/bash/patcher/patchers/multitweak_names.py +++ b/Mopy/bash/patcher/patchers/multitweak_names.py @@ -101,17 +101,17 @@ def buildPatch(self,log,progress,patchFile): for record in getattr(patchFile,self.key).records: if not record.full: continue if record.full[0] in u'+-=.()[]': continue - flags = record.flags - if flags.head or flags.hair: type_ = head - elif flags.rightRing or flags.leftRing: type_ = ring - elif flags.amulet: type_ = amulet - elif flags.upperBody and flags.lowerBody: type_ = robe - elif flags.upperBody: type_ = chest - elif flags.lowerBody: type_ = pants - elif flags.hand: type_ = gloves - elif flags.foot: type_ = shoes - elif flags.tail: type_ = tail - elif flags.shield: type_ = shield + rec_flgs = record.flags + if rec_flgs.head or rec_flgs.hair: type_ = head + elif rec_flgs.rightRing or rec_flgs.leftRing: type_ = ring + elif rec_flgs.amulet: type_ = amulet + elif rec_flgs.upperBody and rec_flgs.lowerBody: type_ = robe + elif rec_flgs.upperBody: type_ = chest + elif rec_flgs.lowerBody: type_ = pants + elif rec_flgs.hand: type_ = gloves + elif rec_flgs.foot: type_ = shoes + elif rec_flgs.tail: type_ = tail + elif rec_flgs.shield: type_ = shield else: continue if record.recType == 'ARMO': type_ += 'LH'[record.flags.heavyArmor] diff --git a/Mopy/bash/windows.py b/Mopy/bash/windows.py index a09480c107..b6d5be20e1 100644 --- a/Mopy/bash/windows.py +++ b/Mopy/bash/windows.py @@ -248,38 +248,6 @@ class SHSTOCKICONINFO(Structure): ('szPath',c_wchar*MAX_PATH)] -try: - stockiconinfo = windll.shell32.SHGetStockIconInfo - stockiconinfo.argtypes = [c_uint,c_uint,POINTER(SHSTOCKICONINFO)] - stockiconinfo.restype = c_uint32 - STOCK_ICON_AVAILABLE = True - - def GetStockIcon(id_,flags=0): - flags = ~(~flags|SHGSI_ICONLOCATION)|SHGSI_ICON - info = SHSTOCKICONINFO() - info.cbSize = sizeof(info) - result = stockiconinfo(id_,flags,byref(info)) - if result != 0: - raise Exception(result) - return info.hIcon - - def GetStockIconLocation(id_,flags=0): - flags = ~(~flags|SHGSI_ICON)|SHGSI_ICONLOCATION - info = SHSTOCKICONINFO() - info.cbSize = sizeof(info) - result = stockiconinfo(id_,flags,byref(info)) - if result != 0: - raise Exception(result) - return info.szPath,info.iIcon -except AttributeError: - STOCK_ICON_AVAILABLE = False - - def GetStockIcon(id_,flags=0): - return None - - def GetStockIconLocation(id_,flags=0): - return u'',0 - #--Start a webpage with an anchor --------------------------------------------- # Need to do this specially, because doing it via os.startfile, ShellExecute, # etc drops off the anchor part of the url @@ -498,19 +466,20 @@ def show(self, command_links=False, centered=True, can_cancel=False, ############################### # Windows windll.user32 calls # ############################### - def __configure(self, c_links, centered, close, minimize, h_links, flags): + def __configure(self, c_links, centered, close, minimize, h_links, + additional_flags): conf = TASKDIALOGCONFIG() if c_links and len(getattr(self, '_buttons', [])) > 0: - flags |= USE_COMMAND_LINKS + additional_flags |= USE_COMMAND_LINKS if centered: - flags |= POSITION_RELATIVE_TO_WINDOW + additional_flags |= POSITION_RELATIVE_TO_WINDOW if close: - flags |= ALLOW_DIALOG_CANCELLATION + additional_flags |= ALLOW_DIALOG_CANCELLATION if minimize: - flags |= CAN_BE_MINIMIZED + additional_flags |= CAN_BE_MINIMIZED if h_links: - flags |= ENABLE_HYPERLINKS + additional_flags |= ENABLE_HYPERLINKS conf.cbSize = sizeof(TASKDIALOGCONFIG) conf.hwndParent = self._parent @@ -530,13 +499,13 @@ def __configure(self, c_links, centered, close, minimize, h_links, flags): conf.uFooterIcon.pszFooterIcon = self._footer_icon else: conf.uFooterIcon.hFooterIcon = self._footer_icon - flags |= USE_HICON_FOOTER + additional_flags |= USE_HICON_FOOTER if self._main_icon is not None: if self._main_is_stock: conf.uMainIcon.pszMainIcon = self._main_icon else: conf.uMainIcon.hMainIcon = self._main_icon - flags |= USE_HICON_MAIN + additional_flags |= USE_HICON_MAIN if '_buttons' in attributes: custom_buttons = [] @@ -579,7 +548,7 @@ def __configure(self, c_links, centered, close, minimize, h_links, flags): conf.pRadioButtons = c_array if self._default_radio is None: - flags |= NO_DEFAULT_RADIO_BUTTON + additional_flags |= NO_DEFAULT_RADIO_BUTTON else: conf.nDefaultRadioButton = self._default_radio @@ -589,24 +558,24 @@ def __configure(self, c_links, centered, close, minimize, h_links, flags): conf.pszExpandedInformation = self._expander_data[2] if self._expander_expanded: - flags |= EXPANDED_BY_DEFAULT + additional_flags |= EXPANDED_BY_DEFAULT if self._expands_at_footer: - flags |= EXPAND_FOOTER_AREA + additional_flags |= EXPAND_FOOTER_AREA if '_cbox_label' in attributes: conf.pszVerificationText = self._cbox_label if self._cbox_checked: - flags |= VERIFICATION_FLAG_CHECKED + additional_flags |= VERIFICATION_FLAG_CHECKED if '_marquee_progress_bar' in attributes: - flags |= SHOW_MARQUEE_PROGRESS_BAR - flags |= CALLBACK_TIMER + additional_flags |= SHOW_MARQUEE_PROGRESS_BAR + additional_flags |= CALLBACK_TIMER if '_progress_bar' in attributes: - flags |= SHOW_PROGRESS_BAR - flags |= CALLBACK_TIMER + additional_flags |= SHOW_PROGRESS_BAR + additional_flags |= CALLBACK_TIMER - conf.dwFlags = flags + conf.dwFlags = additional_flags conf.pfCallback = PFTASKDIALOGCALLBACK(self.__callback) return conf