-
Notifications
You must be signed in to change notification settings - Fork 115
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
Code reorganization - mainly management of file moving/copying/renaming #70
base: master
Are you sure you want to change the base?
Conversation
Oh sorry, I lost track of this pull request! Generally this looks great. I want to make a few more dramatic changes for tvnamer3, but this is a good first step A few things:
|
@@ -360,55 +297,67 @@ def main(): | |||
p("Loading config: %s" % (configToLoad)) | |||
try: | |||
loadedConfig = json.load(open(os.path.expanduser(configToLoad))) | |||
config_version = loadedConfig.get("__version__") or "0" | |||
if cmp(__version__, config_version): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this will really work.. Version number comparison is hard, and cmp
just does simple string comparions, e.g:
>>> cmp('3.0.10', "30.0.2")
-1
>>> cmp('3.0.10', "30.0.11")
-1
What about just having a separate file like tvnamer3.json
? Easier for migrating, and don't have to worry about backwards compatibility
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about transforming the version string into tuple (something like this should do it)? It's pretty simple to compare tuples...
I don't like the idea of creating new config file, it doesn't solve similar issues in future versions. If we add version string into the config file, when there's backwards incompatible change in the future, it's enough to increase (minor) version number and users would be notified.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True.. but there's no real link between minor-version bumps and config compatibility
So, instead, what about a simple config_version
integer? That way it can be incremented only when there's a backwards-incompatible change
I've done the rebase, had to solve only three conflicts... I've slightly changed my previous code, see line 350 in utils.py. I also added |
Removed the "I doubt anyone will ever fix this test" commit. |
I've fixed the two failing tests in master, was just an episode title changed in thetvdb data. BTW, did you do anything specific to make that unicode test stop failing in Python 2.5/2.6? |
Yes, I used Btw, I split some tests into separate files, I think more tests from large files should be split into separate files based on which feature they test, it should be more transparent. |
…ully_moving_disabled' and 'test_forcefully_moving_default', sometimes they pass and sometimes they don't. I think the order of processing input files is not always the same, maybe some change to test helpers required?
…test_with_invalid_seriesname_test2
…e_files_destination
…led (had to change move destination to original directory, but that should not matter).
… test is aborted)
Just wanted to ask - is it necessary to support python 2.5? It's pretty obsolete IMO, preferably I'd like to see more transition to python 3.x. |
…arser.parse() split into multiple parts, other minor tweaks
I've got an idea to improve |
Oh, I think this is a bad idea. It's likely to hide legitimate unicode problems... I'm pretty sure the tests were only failing because of a Unicode bug in nosetests, which was only happened with Python 2.5 and 2.6 (e.g see the traceback here), it should have been fixed in nose in this pull request
If it starts causing problems, I'm fine with dropping 2.5 support. |
Oh, I've been using tvnamer with your changes for a while, and it's working nicely for the most part. Thanks hugely for all your effort! I've pulled your current work into a A few things I noticed:
Currently it's run on chunks of the data, like I just realised that the test is only valid on Darwin (and Windows, both of which have Adding
Also the new path should be run through
Note the "New path: ." which implies the file will be moved into the current working directory, which is incorrect. The code functions correctly, just the UI is wrong
Something like this:
I think it's better to show the filename separate from the path, so if the file is only being renamed then "old/new directory" is hidden (otherwise it implies maybe the file may be moved)
|
The API returns the series in what it thinks is the best order, so I'm not convinced tvnamer should try and re-sort these again Also, there may be some subtitles that might be difficult to handle, like sorting the multiple language versions of the same show (where the similarity on all would be 100%) |
|
I've created new branch devel-argparse in my repo. I've changed the argument list parsing code to use argparse instead of optparse. Hopefully the code is cleaner and config loading simpler (see last commits), the problem is that argparse is in standard library only since python 2.7 (though it can be installed as separate package for older versions). I'd appreciate any feedback, testing and so on, it surely is in it's early stages. |
Regardless I'm not sure sure this is the right thing to do, pretty sure the tests were failing on Travis because of a nosetest bug
I began to work on the clean-up, so far I managed to maintain (more or less) the same functionality, almost all tests pass - except for test_forcefully_moving_default and test_forcefully_moving_disabled, which sometimes pass and sometimes fail, I think the order of input files isn't preserved - maybe some change to test helpers required?
(Oh, the tests fail because now first the filename is constructed and then moved, originally the file was first renamed and then moved.)
One other test that always fails on my platform is test_unicode_in_inputname - tvnamer generates filename as 'The Big Bang Theory - [02x07] - The Panty Pi\xf1ata Polarization.avi'.
There's still a lot of work to be done, merge when ready... Until then, any comments appreciated.