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

--query will not detect previous file if query has non-alpha characters #40

Closed
skilfullycurled opened this issue Dec 26, 2014 · 2 comments

Comments

@skilfullycurled
Copy link

--query has the ability to stop where it left off. However, it was not working for me. In testing, this was not a problem when the filename only had alphanumeric characters, but when I used a query that included punctuation, in this case a hash, the functionality would not work.

This is because the name of the files are based on the string that is sent to twitter and the string that is sent to twitter has the quote() function performed on it first. So if query q = "#somekeyword", then the query that is sent to twitter is "%23somekeyword".

However, in the last_archive function, when --query looks up previous filenames for a stop ID, it is matching the filename with q prior to having the quote() function performed on it. It's matching q which is "#somekeyword" with a file that begins with "%23somekeyword".

I'm not sure this is either the best solution, or if it is, the best way to implement this solution, but in the last_archive function, matching quote(q, safe='') with the filename instead of just q on 218 fixed the problem.

see below:

def last_archive(q):
     other_archive_files = []
     for filename in os.listdir("."):
          if re.match("^%s-\d+\.json$" % quote(q, safe=''), filename):
               other_archive_files.append(filename)
     other_archive_files.sort()
     while len(other_archive_files) != 0:
          f = other_archive_files.pop()
          if os.path.getsize(f) > 0:
               return f
     return None
@edsu
Copy link
Member

edsu commented Dec 29, 2014

Thanks for noticing this! I think your solution should work well. I'll push an update shortly.

@edsu edsu closed this as completed in cc28f58 Dec 29, 2014
@edsu
Copy link
Member

edsu commented Dec 29, 2014

just released to PyPI as v0.1.1 - thanks again!

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

No branches or pull requests

2 participants