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

Side by Side Diff: build/android/pylib/content_settings.py

Issue 194843003: [Android] Lint the rest of pylib. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: no more linting *.py.svn-base files. Created 6 years, 9 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 | « build/android/pylib/constants.py ('k') | build/android/pylib/device/adb_wrapper.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 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 5
6 class ContentSettings(dict): 6 class ContentSettings(dict):
7 7
8 """A dict interface to interact with device content settings. 8 """A dict interface to interact with device content settings.
9 9
10 System properties are key/value pairs as exposed by adb shell content. 10 System properties are key/value pairs as exposed by adb shell content.
11 """ 11 """
12 12
13 def __init__(self, table, adb): 13 def __init__(self, table, adb):
14 super(ContentSettings, self).__init__() 14 super(ContentSettings, self).__init__()
15 try: 15 try:
16 sdk_version = int(adb.system_properties['ro.build.version.sdk']) 16 sdk_version = int(adb.system_properties['ro.build.version.sdk'])
17 assert sdk_version >= 16, ( 17 assert sdk_version >= 16, (
18 'ContentSettings supported only on SDK 16 and later') 18 'ContentSettings supported only on SDK 16 and later')
19 except ValueError: 19 except ValueError:
20 assert False, ('Unknown SDK version %s' % 20 assert False, ('Unknown SDK version %s' %
21 adb.system_properties['ro.build.version.sdk']) 21 adb.system_properties['ro.build.version.sdk'])
22 self._table = table 22 self._table = table
23 self._adb = adb 23 self._adb = adb
24 24
25 def _GetTypeBinding(self, value): 25 @staticmethod
26 def _GetTypeBinding(value):
26 if isinstance(value, bool): 27 if isinstance(value, bool):
27 return 'b' 28 return 'b'
28 if isinstance(value, float): 29 if isinstance(value, float):
29 return 'f' 30 return 'f'
30 if isinstance(value, int): 31 if isinstance(value, int):
31 return 'i' 32 return 'i'
32 if isinstance(value, long): 33 if isinstance(value, long):
33 return 'l' 34 return 'l'
34 if isinstance(value, str): 35 if isinstance(value, str):
35 return 's' 36 return 's'
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 self._table, 72 self._table,
72 self._GetTypeBinding(key), key, 73 self._GetTypeBinding(key), key,
73 self._GetTypeBinding(value), value)) 74 self._GetTypeBinding(value), value))
74 75
75 def __delitem__(self, key): 76 def __delitem__(self, key):
76 self._adb.RunShellCommandWithSU( 77 self._adb.RunShellCommandWithSU(
77 'content delete --uri content://%s ' 78 'content delete --uri content://%s '
78 '--bind name:%s:%s' % ( 79 '--bind name:%s:%s' % (
79 self._table, 80 self._table,
80 self._GetTypeBinding(key), key)) 81 self._GetTypeBinding(key), key))
OLDNEW
« no previous file with comments | « build/android/pylib/constants.py ('k') | build/android/pylib/device/adb_wrapper.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698