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

All Matching Regex #15

Merged
merged 6 commits into from
Jun 24, 2017
Merged

All Matching Regex #15

merged 6 commits into from
Jun 24, 2017

Conversation

JohnMoutafis
Copy link
Contributor

Added a utility method, able to read a multitude of user input from tracks txt.

Other changes (minor):

  • Updated the dev branch to be in sync with the master branch.
  • Made code of the parsing part of split.py DRY.
  • Erased tracks.txt from the repository and added a tracks.txt.example in it's place, because it is a configuration file, thus it is better to be environment specific.

@crisbal
Copy link
Owner

crisbal commented Jun 23, 2017

I will review this in the afternoon, thanks a lot!

@JohnMoutafis
Copy link
Contributor Author

Note also that this refs: #5 because it provides an easier way to edit tracks.txt, by accepting more types of text input format.

@crisbal
Copy link
Owner

crisbal commented Jun 23, 2017

Yes, that input parsing function is very very beautiful, amazing job there!

There are a few edge cases I found

>> all_matching_regex("1 - 1:12:00 - hello 32") # dash instead of a dot for the track number
('1:12:00', '- hello 32')
# There is a dash inside the title
>>> all_matching_regex("1:12:00 - hello 12:13") # time inside the title of the song
('1:12:00', 'hello')
# The `12:13` in the title is ignored

Not sure if these are easy fix, let me know.

Also we should update the README, I could do this if you don't want to.

@JohnMoutafis
Copy link
Contributor Author

JohnMoutafis commented Jun 23, 2017

  • Added the update for the edge cases mentioned
  • Updated README.

Thanks for your comment :)

@crisbal crisbal merged commit 39151c3 into crisbal:master Jun 24, 2017
@crisbal
Copy link
Owner

crisbal commented Jun 24, 2017

Thanks again! Great job!

@crisbal
Copy link
Owner

crisbal commented Jun 24, 2017

Hey, I removed a regex in commit #4d84353

It was causing a problem for songs that started with a number (for example "21 Guns" from Green Day was getting recognized as "Guns").

If you see any potential problem in this, let me know.

I also updated my code a little bit, I wrote this a few years back so it needed some cleaning.

@crisbal
Copy link
Owner

crisbal commented Jun 28, 2017

Hey,

I am writing tests for track_parser, right now I expect this:

self.assertEqual(track_parser("12:32"), ("", ""))

but I get ('12:32', '')

Do you think it should return ('', '') or ('12:32', '')?

EDIT: let's also consider that right now track_parser("testing breaking") = ("", "")

@JohnMoutafis
Copy link
Contributor Author

I haven't considered what happens on fail.
If we are to follow the zen of python, nothing should fail silently. In that case, we should define what a bad input is and what we should respond to it.

  • I believe that just a timestamp should result on an empty title but work
  • Empty time and title should fail
  • Only title should fail

What is your take on the matter?

@crisbal
Copy link
Owner

crisbal commented Jun 28, 2017

First of all I think we should throw an exception instead of returning an empty tuple.

Now that I think more on this, I also agree that just timestamp should work, but we have to handle the empty title somehow, for example naming the tracks with their position.

@JohnMoutafis
Copy link
Contributor Author

JohnMoutafis commented Jun 28, 2017

  • It can just fail, notify the user and he can fix it and restart.

OR

  • A bit more complicated but interesting, if a title is empty, prompt for user input!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants