Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: sitescripts/management/bin/generateHgAuth.py

Issue 29756646: Noissue - Adapt best practices for trailing commas (abpssembly) (Closed)
Patch Set: Re-run script on Python 2, added flake8-commas extension Created April 19, 2018, 2:41 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 # This file is part of the Adblock Plus web scripts, 1 # This file is part of the Adblock Plus web scripts,
2 # Copyright (C) 2006-present eyeo GmbH 2 # Copyright (C) 2006-present eyeo GmbH
3 # 3 #
4 # Adblock Plus is free software: you can redistribute it and/or modify 4 # Adblock Plus is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License version 3 as 5 # it under the terms of the GNU General Public License version 3 as
6 # published by the Free Software Foundation. 6 # published by the Free Software Foundation.
7 # 7 #
8 # Adblock Plus is distributed in the hope that it will be useful, 8 # Adblock Plus is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
(...skipping 29 matching lines...) Expand all
40 match = re.search(r'^(.*)\[(.*)\]$', name) 40 match = re.search(r'^(.*)\[(.*)\]$', name)
41 if match: 41 if match:
42 name = match.group(1) 42 name = match.group(1)
43 options = match.group(2).split(',') 43 options = match.group(2).split(',')
44 44
45 user = { 45 user = {
46 'name': name, 46 'name': name,
47 'keytype': 'rsa', 47 'keytype': 'rsa',
48 'disabled': False, 48 'disabled': False,
49 'trusted': False, 49 'trusted': False,
50 'repos': [] 50 'repos': [],
51 } 51 }
52 for option in options: 52 for option in options:
53 if option == 'dsa': 53 if option == 'dsa':
54 user['keytype'] = 'dsa' 54 user['keytype'] = 'dsa'
55 elif option == 'disabled': 55 elif option == 'disabled':
56 user['disabled'] = True 56 user['disabled'] = True
57 elif option == 'trusted': 57 elif option == 'trusted':
58 user['trusted'] = True 58 user['trusted'] = True
59 else: 59 else:
60 print >>sys.stderr, 'Unknown user option: %s' % option 60 print >>sys.stderr, 'Unknown user option: %s' % option
(...skipping 16 matching lines...) Expand all
77 else: 77 else:
78 print >>sys.stderr, 'Unknown user listed for repository %s: %s' % (name, user) 78 print >>sys.stderr, 'Unknown user listed for repository %s: %s' % (name, user)
79 79
80 for user in users.itervalues(): 80 for user in users.itervalues():
81 if user['disabled']: 81 if user['disabled']:
82 continue 82 continue
83 yield 'no-pty,environment="HGUSER=%s",environment="HGREPOS=%s" %s %s\n' % ( 83 yield 'no-pty,environment="HGUSER=%s",environment="HGREPOS=%s" %s %s\n' % (
84 user['name'] if not user['trusted'] else '', 84 user['name'] if not user['trusted'] else '',
85 ' '.join(user['repos']), 85 ' '.join(user['repos']),
86 'ssh-rsa' if user['keytype'] == 'rsa' else 'ssh-dss', 86 'ssh-rsa' if user['keytype'] == 'rsa' else 'ssh-dss',
87 user['key'] 87 user['key'],
88 ) 88 )
89 89
90 90
91 def hook(ui=None, repo=None, **kwargs): 91 def hook(ui=None, repo=None, **kwargs):
92 setupStderr() 92 setupStderr()
93 93
94 root = repo.root if repo != None else get_config().get('hg', 'auth_repositor y') 94 root = repo.root if repo != None else get_config().get('hg', 'auth_repositor y')
95 result = generate_data(root) 95 result = generate_data(root)
96 96
97 with open(get_config().get('hg', 'auth_file'), 'wb') as file: 97 with open(get_config().get('hg', 'auth_file'), 'wb') as file:
98 for s in result: 98 for s in result:
99 file.write(s) 99 file.write(s)
100 100
101 101
102 if __name__ == '__main__': 102 if __name__ == '__main__':
103 hook() 103 hook()
OLDNEW
« no previous file with comments | « sitescripts/hg/test/update_issues.py ('k') | sitescripts/management/bin/generateNotifications.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld