Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Split function to extract filename for .yml use is not reliable #62
I found this problem playing with routes.py yesterday:
What's happening here is that the path to the file includes "python2.7", and the split('.') function is therefore splitting on the '.' in the middle of "2.7" rather than the dot before the "py" suffix.
Oddly, it didn't seem to affect ethport.py when I tested, which is coded identically as far as I could see, but I'm not arguing. The solution is to match on the last occurrence of the '.', OR to import the os module and use os.path to extract the filename without extension.
Here is the line causing the issue, in op/routes.py:
I propose two solutions to this issue for your consideration. The first is a text solution using rsplit:
The second is to use the os.path.splitext function to extract the path (which may be safer across multiple platforms) instead:
I welcome your thoughts; I can implement either "fix" for you and issue pull request if you'd like one done.