Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(545)

Side by Side Diff: appengine/machine_provider/utils.py

Issue 2013943002: Changing license header, again! (Closed) Base URL: git@github.com:luci/luci-py.git@master
Patch Set: Fixed third parties Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « appengine/machine_provider/test_env.py ('k') | appengine/swarming/PRESUBMIT.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2015 The LUCI Authors. All rights reserved. 1 # Copyright 2015 The LUCI Authors. All rights reserved.
2 # Use of this source code is governed by the Apache v2.0 license that can be 2 # Use of this source code is governed under the Apache License, Version 2.0
3 # found in the LICENSE file. 3 # that can be found in the LICENSE file.
4 4
5 """Miscellaneous helper functions.""" 5 """Miscellaneous helper functions."""
6 6
7 import collections 7 import collections
8 8
9 9
10 def fingerprint(proto): 10 def fingerprint(proto):
11 """Returns a fingerprint of a simple messages.Message instance. 11 """Returns a fingerprint of a simple messages.Message instance.
12 12
13 Args: 13 Args:
14 proto: A messages.Message instance. 14 proto: A messages.Message instance.
15 15
16 Returns: 16 Returns:
17 A string which uniquely identifies proto. 17 A string which uniquely identifies proto.
18 """ 18 """
19 components = collections.OrderedDict() 19 components = collections.OrderedDict()
20 20
21 for field in sorted(proto.all_fields(), key=lambda field: field.number): 21 for field in sorted(proto.all_fields(), key=lambda field: field.number):
22 if proto.get_assigned_value(field.name) is not None: 22 if proto.get_assigned_value(field.name) is not None:
23 components[field.number] = proto.get_assigned_value(field.name) 23 components[field.number] = proto.get_assigned_value(field.name)
24 24
25 return '\0'.join( 25 return '\0'.join(
26 '%s\0%s' % (key, value) for key, value in components.iteritems() 26 '%s\0%s' % (key, value) for key, value in components.iteritems()
27 ) 27 )
OLDNEW
« no previous file with comments | « appengine/machine_provider/test_env.py ('k') | appengine/swarming/PRESUBMIT.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698