Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/jay0lee/GAM
Browse files Browse the repository at this point in the history
  • Loading branch information
jay0lee committed Nov 9, 2019
2 parents 0f39b99 + 6e9068c commit ae6ac85
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/gam.py
Original file line number Diff line number Diff line change
Expand Up @@ -1348,11 +1348,6 @@ def getValidOauth2TxtCredentials(force_refresh=False):
elif credentials is None or not credentials.valid:
doRequestOAuth()
credentials = getOauth2TxtStorageCredentials()
if not GM_Globals[GM_WINDOWS]:
try:
os.remove(lock_file)
except IOError:
pass
return credentials

def getService(api, http):
Expand Down Expand Up @@ -6465,6 +6460,11 @@ def updateLabels(users):
else:
print('Error: user does not have a label named %s' % label_name)

def cleanLabelQuery(labelQuery):
for ch in '/ (){}':
labelQuery = labelQuery.replace(ch, '-')
return labelQuery.lower()

def renameLabels(users):
search = '^Inbox/(.*)$'
replace = '%s'
Expand Down Expand Up @@ -6505,7 +6505,7 @@ def renameLabels(users):
if merge:
print(' Merging %s label to existing %s label' % (label['name'], new_label_name))
messages_to_relabel = callGAPIpages(gmail.users().messages(), 'list', 'messages',
userId=user, q='label:%s' % label['name'].lower().replace('/', '-').replace(' ', '-'))
userId=user, q='label:%s' % cleanLabelQuery(label['name']))
if messages_to_relabel:
for new_label in labels['labels']:
if new_label['name'].lower() == new_label_name.lower():
Expand Down

0 comments on commit ae6ac85

Please sign in to comment.