Created
July 9, 2012 03:54
-
-
Save jmahmood/3074148 to your computer and use it in GitHub Desktop.
3 years of python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A few years ago: | |
def parseBugzillaCookies(self,s): | |
if s is None: return {self.SESSION_ID_STRING:None} | |
ret = {} | |
tmp = s.split(';') | |
for t in tmp: | |
t = t.replace('HttpOnly, ','') | |
coppia = t.split('=') | |
if coppia[0].strip() in ['Bugzilla_logincookie','Bugzilla_login']: | |
k = coppia[0].strip() | |
v = coppia[1].strip() | |
ret[k]=v | |
return ret | |
Now: | |
(Probably less efficient, but much easier to read) | |
def parseBugzillaCookies(self,s): | |
if s is None: | |
return {self.SESSION_ID_STRING:None} | |
BugzillaCookieKeys = ['Bugzilla_logincookie','Bugzilla_login'] | |
headers = [t.replace('HttpOnly, ','').split("=") for t in s.split(';')] | |
return dict((k.strip(),v.strip()) for (k,v) in headers if k in BugzillaCookieKeys) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for the bugfix - I applied it in py-bugziller :D
I was concerned that I was running through the same array twice when I could do everything in a single loop previously. However, in retrospect, that wasn't really such a big deal.