Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List files in Clean Data & Sync From Data #273

Closed
Utumno opened this issue Feb 22, 2016 · 22 comments
Closed

List files in Clean Data & Sync From Data #273

Utumno opened this issue Feb 22, 2016 · 22 comments
Assignees
Labels
A-bain Area: BAIN (BAsh INstallers, in bosh/bain.py) A-links Area: Links (Options shown in right-click menus, in basher/*_links.py and basher/links_init.py) C-enhancement Category: Enhancement, a request to add or enhance a feature M-relnotes Misc: Issue should be listed in the version history for its milestone M-svn Misc: Issue was carried over from the old SVN repo
Milestone

Comments

@Utumno
Copy link
Member

Utumno commented Feb 22, 2016

See: https://sourceforge.net/p/oblivionworks/enhancements/162/, https://sourceforge.net/p/oblivionworks/enhancements/113/, https://sourceforge.net/p/oblivionworks/enhancements/220/

Do see those for ideas etc

At least prompt before sync from data - quoting @saebel:

Data sync suggestion: don't just list the number of files that are going to be updated/deleted, show the file names. I accidentally agreed to a data sync that deleted files that it shouldn't have and would have caught had I seen the file names. Thank goodness I had made a backup.

From 162:

basically the "Clean data" command, but just gathering the file names and listing them instead of moving them.

From 220:

It would be nice to have a preview of the files that will be removed from the data folder when 'Clean Data' is executed from the Installers tab.
Possibly with an option to either once or permanently exclude some files from cleaning.

@Utumno Utumno added C-enhancement Category: Enhancement, a request to add or enhance a feature M-svn Misc: Issue was carried over from the old SVN repo A-bain Area: BAIN (BAsh INstallers, in bosh/bain.py) labels Feb 22, 2016
@Utumno Utumno added this to the 308 milestone Feb 22, 2016
@saebel saebel mentioned this issue Feb 22, 2016
25 tasks
@Utumno
Copy link
Member Author

Utumno commented Mar 30, 2016

This was referenced Feb 16, 2018
@Utumno Utumno added the M-good-first-issue Misc: A good issue for newcomers to start with label Jan 5, 2019
@Infernio Infernio added the A-links Area: Links (Options shown in right-click menus, in basher/*_links.py and basher/links_init.py) label Mar 1, 2020
@warmfrost85
Copy link
Member

@Infernio & @Utumno : This commit on today's nightly branch handles this need. It displays a sorted list of untracked files using checkboxes.
warmfrost85@6729695
It's based off nightly rather than dev because I'm using python 64 bit and haven't setup a virtual environment.

@Infernio
Copy link
Member

Thanks! Left a preliminary review (code style only) on your commit.

@Infernio Infernio modified the milestones: 308, 307 Apr 15, 2020
@warmfrost85
Copy link
Member

Pushed an update with requested changes. Probably should be squished later but preserving history now.
warmfrost85@3ad90a5

@Infernio
Copy link
Member

Left a few more nits, mostly line wrapping. Do you have your editor configured to show a 79-chars boundary? Very useful when writing WB code.

@warmfrost85
Copy link
Member

I'm using PyCharm but was set to show a 120-char boundary so didn't see that when I scrolled. I've set it to 79 and now see all the offenders. I also see a lot of existing code exceeding that boundary. Those must be legacy and slowly be reworked.

I personally think sometimes going a little beyond a 79 char boundary leads to more readable code or might incentivize using less descriptive names. For example, in bain.py (nightly branch) line's 2647 & 2648 exceed 79 chars and is more readable as-is IMO than wrapping.

        showInactive = conflicts_mode and bass.settings['bash.installers.conflictsReport.showInactive']
        showLower = conflicts_mode and bass.settings['bash.installers.conflictsReport.showLower']

However that's not the consensus in the python community and having said that I'll fix it to standards and not mention it again. :)

I see I didn't study the code enough to notice I could use self._askOK or better self._showOK and the other things you mentioned. Thanks for the insight and feedback @Infernio .

@Infernio
Copy link
Member

Yup, code that goes beyond 79 is generally old. New code should always stick to PEP8.
And yeah, sometimes the 79 thing gets a bit unwieldy. I do find it to be worth it though - makes git diffs much easier to read :)

The bain example looks OK, but I think this alternative which fits into 79 chars isn't that much worse (the symmetry of having the string line up is actually pretty nice):

        showInactive = conflicts_mode and bass.settings[
            'bash.installers.conflictsReport.showInactive']
        showLower = conflicts_mode and bass.settings[
            'bash.installers.conflictsReport.showLower']
        showBSA = bass.settings[
            'bash.installers.conflictsReport.showBSAConflicts']

Anyway, yes this is off-topic chatter :)

@warmfrost85
Copy link
Member

This commit should met your request. It needs to be squashed later.
warmfrost85@2c2c66b
I did not translate the new strings in the ListBox. When I ran Settings/Dump Translator I got:

Traceback (most recent call last):
  File "bash\balt.py", line 1793, in __Execute
    self.Execute()
  File "bash\basher\settings_links.py", line 498, in Execute
    outFile = dump_translator(outPath.s, bass.active_locale)
  File "bash\localize.py", line 177, in dump_translator
    args.extend(_find_all_bash_modules())
  File "bash\localize.py", line 161, in _find_all_bash_modules
    os.path.join(cur_dir, p[1]))
  File "bash\localize.py", line 151, in _find_all_bash_modules
    _files.extend([bash_path.join(m).s for m in os.listdir(cur_dir)
AttributeError: 'unicode' object has no attribute 'extend'

I assume there is something wrong with my local setup but stopped going down that rabbit hole after investigating a while. Does Dump Translator work off nightly for you?
I'm using: chardet in c:\python27\lib\site-packages (3.0.4)

@Infernio
Copy link
Member

No need to actually translate the strings, just surround them with an _() call. Dump Translator might well be broken, I'll check it out.

@Infernio Infernio mentioned this issue Apr 16, 2020
17 tasks
warmfrost85 added a commit to warmfrost85/wrye-bash that referenced this issue Apr 17, 2020
Let the user edit the list and keep any file in the Data folder.

@Infernio handles wrye-bash#273.
@Infernio
Copy link
Member

Style looks fine now :)
When I run this on my Oblivion install, I get this result:

CleanData

The two Docs results are in there because of a bug I fixed in c657540 (rebase on latest nightly to get it), but the remainder aren't actually valid results. They get skipped inside clean_data_dir:

skipPrefixes = [skipDir.lower() + os.sep for skipDir in
bush.game.wryeBashDataDirs | bush.game.ignoreDataDirs]
skipPrefixes.extend([skipPrefix.lower() for skipPrefix in bush.game.ignoreDataFilePrefixes])
skipPrefixes = tuple(skipPrefixes)

# don't remove files in Wrye Bash-related directories
if filename.lower().startswith(skipPrefixes): continue

So moving that part up into get_clean_data_dir_list would be a good idea, to not show the user any bogus results.

@Infernio Infernio mentioned this issue Apr 17, 2020
@warmfrost85
Copy link
Member

warmfrost85 commented Apr 18, 2020

Rebased on latest nightly, updated and ready for review.
warmfrost85@a30ab8b

@Infernio
Copy link
Member

We keep Bashed Patch docs for all BPs that are in the Data folder. So if you have a Bashed Patch, 0.esp and a Bashed Patch, Tweaks only.esp, only those docs will be kept.
Probably fine behavior, since you can't actually predict what the BP name is going to be (matching a regex like Bashed Patch.+\.esp is not going to do - the only thing identifying a BP is the Author field in the header, so you could name your BP something like My Cool BP.esp).

@warmfrost85
Copy link
Member

I noticed my error after I posted that comment so I edited and removed. Bad practice to remove part of a comment once published since your comment now refers to "nothing". My bad. :( Next time I'll show EDIT: instead.

@Infernio
Copy link
Member

Was just wondering why it was trying to remove ArchiveInvalidationInvalidated!.bsa in FO3, a file that comes with WB - turns out it was a typo:

diff --git a/Mopy/bash/game/fallout3/__init__.py b/Mopy/bash/game/fallout3/__init__.py
index c94abc3f1..f9a0d9396 100644
--- a/Mopy/bash/game/fallout3/__init__.py
+++ b/Mopy/bash/game/fallout3/__init__.py
@@ -106,7 +106,7 @@ class Xe(GameInfo.Xe):
     }
     SkipBAINRefresh = {u'fo3edit backups', u'fo3edit cache'}
     wryeBashDataFiles = GameInfo.wryeBashDataFiles | {
-        u'ArchiveInvalidationInvalidated!.bsa'
+        u'ArchiveInvalidationInvalidated!.bsa',
         u'Fallout - AI!.bsa'
     }
     ignoreDataFiles = {

You could include that in your commit as a quick fixup :)

@warmfrost85
Copy link
Member

Nice catch. Technically that change is not directly related to the Clean Data code. It's a result of Clean Data now displaying files to the user. However I can make that change and include it in the commit if you want.

@Infernio
Copy link
Member

Infernio commented Apr 18, 2020

You can include it and add a small note like this in the commit msg:

Mopy/bash/game/fallout3/__init__.py:
Tiny fixup, was cleaning out ArchiveInvalidationInvalidated!.bsa

That's generally what we do if we have a tiny commit that doesn't have much value on its own.

Edit: you can see an example here: 5c7772a

@warmfrost85
Copy link
Member

Done. warmfrost85@387fe05

@Infernio
Copy link
Member

Infernio commented Apr 18, 2020

Did you see my comments I left on warmfrost85@a30ab8b? Once those are addressed, then I think this is ready for testing - I'll pull it over and stick it on nightly/307-beta6 here :)

@Infernio Infernio changed the title List files in clean data/ sync from data List files in Clean Data & Sync From Data Apr 18, 2020
@Utumno
Copy link
Member Author

Utumno commented Apr 18, 2020

Let me do that - although turns out the difficult part is this: https://bugs.python.org/issue7195

@warmfrost85
Copy link
Member

Sorry, I missed your comments. Now updated. Is there such a thing as Done. Done. ? :)
warmfrost85@4abca0a

@Infernio
Copy link
Member

@Utumno Do you have your BP docs on a different drive? If so, checking if the Data folder is part of the BP doc path should be enough, right? If something isn't in the data folder, then BAIN has no business trying to clean it.

@Utumno
Copy link
Member Author

Utumno commented Apr 18, 2020

Yes - good one :)

@@ -2590,2 +2590,3 @@ def get_clean_data_dir_list(self):
             if bp_doc: # path is absolute, convert to relative to the Data/ dir
+                print(u'%s %s' % (bp_doc,bass.dirs['mods'].s))
                 bp_doc = bp_doc.relpath(bass.dirs['mods'].s)


D:\GAMES\TESIV\Oblivion\Data\Docs\PBASH_refactor_307 on 312-patchers.html D:\GAMES\TESIV\Oblivion\Data
C:\GAMES\TESIV\Oblivion\Data\Docs\Bashed Patch, 2.txt D:\GAMES\TESIV\Oblivion\Data

What's even stranger though is that when I run pycharm debugger it will silently fail - won't even show the dialog. A heisenbug ? :D

@Infernio Infernio removed the M-good-first-issue Misc: A good issue for newcomers to start with label Apr 18, 2020
@Infernio Infernio added the M-relnotes Misc: Issue should be listed in the version history for its milestone label Nov 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-bain Area: BAIN (BAsh INstallers, in bosh/bain.py) A-links Area: Links (Options shown in right-click menus, in basher/*_links.py and basher/links_init.py) C-enhancement Category: Enhancement, a request to add or enhance a feature M-relnotes Misc: Issue should be listed in the version history for its milestone M-svn Misc: Issue was carried over from the old SVN repo
Projects
None yet
Development

No branches or pull requests

3 participants