OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 | 6 |
7 import json | 7 import json |
8 from xml.dom import minidom | 8 from xml.dom import minidom |
9 from grit import lazy_re | 9 from grit import lazy_re |
10 from grit.format.policy_templates.writers import xml_formatted_writer | 10 from grit.format.policy_templates.writers import xml_formatted_writer |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 key_name = self.config['win_reg_recommended_key_name'] | 184 key_name = self.config['win_reg_recommended_key_name'] |
185 else: | 185 else: |
186 key_name = self.config['win_reg_mandatory_key_name'] | 186 key_name = self.config['win_reg_mandatory_key_name'] |
187 for item in example_value: | 187 for item in example_value: |
188 win_text.append( | 188 win_text.append( |
189 '%s\\%s\\%d = "%s"' % | 189 '%s\\%s\\%d = "%s"' % |
190 (key_name, policy['name'], cnt, item)) | 190 (key_name, policy['name'], cnt, item)) |
191 cnt = cnt + 1 | 191 cnt = cnt + 1 |
192 self.AddText(win, '\n'.join(win_text)) | 192 self.AddText(win, '\n'.join(win_text)) |
193 | 193 |
194 def _AddListExampleLinux(self, parent, policy): | 194 def _AddListExampleAndroidLinux(self, parent, policy): |
195 '''Adds an example value for Linux of a 'list' policy to a DOM node. | 195 '''Adds an example value for Android/Linux of a 'list' policy to a DOM node. |
196 | 196 |
197 Args: | 197 Args: |
198 parent: The DOM node for which the example will be added. | 198 parent: The DOM node for which the example will be added. |
199 policy: A policy of type 'list', for which the Linux example value | 199 policy: A policy of type 'list', for which the Android/Linux example value |
200 is generated. | 200 is generated. |
201 ''' | 201 ''' |
202 example_value = policy['example_value'] | 202 example_value = policy['example_value'] |
203 self.AddElement(parent, 'dt', {}, 'Linux:') | 203 self.AddElement(parent, 'dt', {}, 'Android/Linux:') |
204 linux = self._AddStyledElement(parent, 'dd', ['.monospace']) | 204 element = self._AddStyledElement(parent, 'dd', ['.monospace']) |
205 linux_text = [] | 205 text = [] |
206 for item in example_value: | 206 for item in example_value: |
207 linux_text.append('"%s"' % item) | 207 text.append('"%s"' % item) |
208 self.AddText(linux, '[%s]' % ', '.join(linux_text)) | 208 self.AddText(element, '[%s]' % ', '.join(text)) |
209 | 209 |
210 def _AddListExample(self, parent, policy): | 210 def _AddListExample(self, parent, policy): |
211 '''Adds the example value of a 'list' policy to a DOM node. Example output: | 211 '''Adds the example value of a 'list' policy to a DOM node. Example output: |
212 <dl> | 212 <dl> |
213 <dt>Windows:</dt> | 213 <dt>Windows:</dt> |
214 <dd> | 214 <dd> |
215 Software\Policies\Chromium\DisabledPlugins\0 = "Java" | 215 Software\Policies\Chromium\DisabledPlugins\0 = "Java" |
216 Software\Policies\Chromium\DisabledPlugins\1 = "Shockwave Flash" | 216 Software\Policies\Chromium\DisabledPlugins\1 = "Shockwave Flash" |
217 </dd> | 217 </dd> |
218 <dt>Linux:</dt> | 218 <dt>Android/Linux:</dt> |
219 <dd>["Java", "Shockwave Flash"]</dd> | 219 <dd>["Java", "Shockwave Flash"]</dd> |
220 <dt>Mac:</dt> | 220 <dt>Mac:</dt> |
221 <dd> | 221 <dd> |
222 <array> | 222 <array> |
223 <string>Java</string> | 223 <string>Java</string> |
224 <string>Shockwave Flash</string> | 224 <string>Shockwave Flash</string> |
225 </array> | 225 </array> |
226 </dd> | 226 </dd> |
227 </dl> | 227 </dl> |
228 | 228 |
229 Args: | 229 Args: |
230 parent: The DOM node for which the example will be added. | 230 parent: The DOM node for which the example will be added. |
231 policy: The data structure of a policy. | 231 policy: The data structure of a policy. |
232 ''' | 232 ''' |
233 examples = self._AddStyledElement(parent, 'dl', ['dd dl']) | 233 examples = self._AddStyledElement(parent, 'dl', ['dd dl']) |
234 if self.IsPolicySupportedOnPlatform(policy, 'win'): | 234 if self.IsPolicySupportedOnPlatform(policy, 'win'): |
235 self._AddListExampleWindows(examples, policy) | 235 self._AddListExampleWindows(examples, policy) |
236 if self.IsPolicySupportedOnPlatform(policy, 'linux'): | 236 if (self.IsPolicySupportedOnPlatform(policy, 'android') or |
237 self._AddListExampleLinux(examples, policy) | 237 self.IsPolicySupportedOnPlatform(policy, 'linux')): |
| 238 self._AddListExampleAndroidLinux(examples, policy) |
238 if self.IsPolicySupportedOnPlatform(policy, 'mac'): | 239 if self.IsPolicySupportedOnPlatform(policy, 'mac'): |
239 self._AddListExampleMac(examples, policy) | 240 self._AddListExampleMac(examples, policy) |
240 | 241 |
241 def _PythonObjectToPlist(self, obj, indent=''): | 242 def _PythonObjectToPlist(self, obj, indent=''): |
242 '''Converts a python object to an equivalent XML plist. | 243 '''Converts a python object to an equivalent XML plist. |
243 | 244 |
244 Returns a list of lines.''' | 245 Returns a list of lines.''' |
245 obj_type = type(obj) | 246 obj_type = type(obj) |
246 if obj_type == bool: | 247 if obj_type == bool: |
247 return [ '%s<%s/>' % (indent, 'true' if obj else 'false') ] | 248 return [ '%s<%s/>' % (indent, 'true' if obj else 'false') ] |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 ''' | 291 ''' |
291 self.AddElement(parent, 'dt', {}, 'Windows:') | 292 self.AddElement(parent, 'dt', {}, 'Windows:') |
292 win = self._AddStyledElement(parent, 'dd', ['.monospace', '.pre']) | 293 win = self._AddStyledElement(parent, 'dd', ['.monospace', '.pre']) |
293 if self.CanBeRecommended(policy) and not self.CanBeMandatory(policy): | 294 if self.CanBeRecommended(policy) and not self.CanBeMandatory(policy): |
294 key_name = self.config['win_reg_recommended_key_name'] | 295 key_name = self.config['win_reg_recommended_key_name'] |
295 else: | 296 else: |
296 key_name = self.config['win_reg_mandatory_key_name'] | 297 key_name = self.config['win_reg_mandatory_key_name'] |
297 example = json.dumps(policy['example_value']) | 298 example = json.dumps(policy['example_value']) |
298 self.AddText(win, '%s\\%s = %s' % (key_name, policy['name'], example)) | 299 self.AddText(win, '%s\\%s = %s' % (key_name, policy['name'], example)) |
299 | 300 |
300 def _AddDictionaryExampleLinux(self, parent, policy): | 301 def _AddDictionaryExampleAndroidLinux(self, parent, policy): |
301 '''Adds an example value for Linux of a 'dict' policy to a DOM node. | 302 '''Adds an example value for Android/Linux of a 'dict' policy to a DOM node. |
302 | 303 |
303 Args: | 304 Args: |
304 parent: The DOM node for which the example will be added. | 305 parent: The DOM node for which the example will be added. |
305 policy: A policy of type 'dict', for which the Linux example value | 306 policy: A policy of type 'dict', for which the Android/Linux example value |
306 is generated. | 307 is generated. |
307 ''' | 308 ''' |
308 self.AddElement(parent, 'dt', {}, 'Linux:') | 309 self.AddElement(parent, 'dt', {}, 'Android/Linux:') |
309 linux = self._AddStyledElement(parent, 'dd', ['.monospace']) | 310 element = self._AddStyledElement(parent, 'dd', ['.monospace']) |
310 example = json.dumps(policy['example_value']) | 311 example = json.dumps(policy['example_value']) |
311 self.AddText(linux, '%s: %s' % (policy['name'], example)) | 312 self.AddText(element, '%s: %s' % (policy['name'], example)) |
312 | 313 |
313 def _AddDictionaryExample(self, parent, policy): | 314 def _AddDictionaryExample(self, parent, policy): |
314 '''Adds the example value of a 'dict' policy to a DOM node. Example output: | 315 '''Adds the example value of a 'dict' policy to a DOM node. Example output: |
315 <dl> | 316 <dl> |
316 <dt>Windows:</dt> | 317 <dt>Windows:</dt> |
317 <dd> | 318 <dd> |
318 Software\Policies\Chromium\ProxySettings = "{ 'ProxyMode': 'direct' }" | 319 Software\Policies\Chromium\ProxySettings = "{ 'ProxyMode': 'direct' }" |
319 </dd> | 320 </dd> |
320 <dt>Linux:</dt> | 321 <dt>Android/Linux:</dt> |
321 <dd>"ProxySettings": { | 322 <dd>"ProxySettings": { |
322 "ProxyMode": "direct" | 323 "ProxyMode": "direct" |
323 } | 324 } |
324 </dd> | 325 </dd> |
325 <dt>Mac:</dt> | 326 <dt>Mac:</dt> |
326 <dd> | 327 <dd> |
327 <key>ProxySettings</key> | 328 <key>ProxySettings</key> |
328 <dict> | 329 <dict> |
329 <key>ProxyMode</key> | 330 <key>ProxyMode</key> |
330 <string>direct</string> | 331 <string>direct</string> |
331 </dict> | 332 </dict> |
332 </dd> | 333 </dd> |
333 </dl> | 334 </dl> |
334 | 335 |
335 Args: | 336 Args: |
336 parent: The DOM node for which the example will be added. | 337 parent: The DOM node for which the example will be added. |
337 policy: The data structure of a policy. | 338 policy: The data structure of a policy. |
338 ''' | 339 ''' |
339 examples = self._AddStyledElement(parent, 'dl', ['dd dl']) | 340 examples = self._AddStyledElement(parent, 'dl', ['dd dl']) |
340 if self.IsPolicySupportedOnPlatform(policy, 'win'): | 341 if self.IsPolicySupportedOnPlatform(policy, 'win'): |
341 self._AddDictionaryExampleWindows(examples, policy) | 342 self._AddDictionaryExampleWindows(examples, policy) |
342 if self.IsPolicySupportedOnPlatform(policy, 'linux'): | 343 if (self.IsPolicySupportedOnPlatform(policy, 'android') or |
343 self._AddDictionaryExampleLinux(examples, policy) | 344 self.IsPolicySupportedOnPlatform(policy, 'linux')): |
| 345 self._AddDictionaryExampleAndroidLinux(examples, policy) |
344 if self.IsPolicySupportedOnPlatform(policy, 'mac'): | 346 if self.IsPolicySupportedOnPlatform(policy, 'mac'): |
345 self._AddDictionaryExampleMac(examples, policy) | 347 self._AddDictionaryExampleMac(examples, policy) |
346 | 348 |
347 def _AddExample(self, parent, policy): | 349 def _AddExample(self, parent, policy): |
348 '''Adds the HTML DOM representation of the example value of a policy to | 350 '''Adds the HTML DOM representation of the example value of a policy to |
349 a DOM node. It is simple text for boolean policies, like | 351 a DOM node. It is simple text for boolean policies, like |
350 '0x00000001 (Windows), true (Linux), <true /> (Mac)' in case of boolean | 352 '0x00000001 (Windows), true (Linux), true (Android), <true /> (Mac)' |
351 policies, but it may also contain other HTML elements. (See method | 353 in case of boolean policies, but it may also contain other HTML elements. |
352 _AddListExample.) | 354 (See method _AddListExample.) |
353 | 355 |
354 Args: | 356 Args: |
355 parent: The DOM node for which the example will be added. | 357 parent: The DOM node for which the example will be added. |
356 policy: The data structure of a policy. | 358 policy: The data structure of a policy. |
357 | 359 |
358 Raises: | 360 Raises: |
359 Exception: If the type of the policy is unknown or the example value | 361 Exception: If the type of the policy is unknown or the example value |
360 of the policy is out of its expected range. | 362 of the policy is out of its expected range. |
361 ''' | 363 ''' |
362 example_value = policy['example_value'] | 364 example_value = policy['example_value'] |
363 policy_type = policy['type'] | 365 policy_type = policy['type'] |
364 if policy_type == 'main': | 366 if policy_type == 'main': |
365 pieces = [] | 367 pieces = [] |
366 if self.IsPolicySupportedOnPlatform(policy, 'win'): | 368 if self.IsPolicySupportedOnPlatform(policy, 'win'): |
367 value = '0x00000001' if example_value else '0x00000000' | 369 value = '0x00000001' if example_value else '0x00000000' |
368 pieces.append(value + ' (Windows)') | 370 pieces.append(value + ' (Windows)') |
369 if self.IsPolicySupportedOnPlatform(policy, 'linux'): | 371 if self.IsPolicySupportedOnPlatform(policy, 'linux'): |
370 value = 'true' if example_value else 'false' | 372 value = 'true' if example_value else 'false' |
371 pieces.append(value + ' (Linux)') | 373 pieces.append(value + ' (Linux)') |
| 374 if self.IsPolicySupportedOnPlatform(policy, 'android'): |
| 375 value = 'true' if example_value else 'false' |
| 376 pieces.append(value + ' (Android)') |
372 if self.IsPolicySupportedOnPlatform(policy, 'mac'): | 377 if self.IsPolicySupportedOnPlatform(policy, 'mac'): |
373 value = '<true />' if example_value else '<false />' | 378 value = '<true />' if example_value else '<false />' |
374 pieces.append(value + ' (Mac)') | 379 pieces.append(value + ' (Mac)') |
375 self.AddText(parent, ', '.join(pieces)) | 380 self.AddText(parent, ', '.join(pieces)) |
376 elif policy_type == 'string': | 381 elif policy_type == 'string': |
377 self.AddText(parent, '"%s"' % example_value) | 382 self.AddText(parent, '"%s"' % example_value) |
378 elif policy_type in ('int', 'int-enum'): | 383 elif policy_type in ('int', 'int-enum'): |
379 pieces = [] | 384 pieces = [] |
380 if self.IsPolicySupportedOnPlatform(policy, 'win'): | 385 if self.IsPolicySupportedOnPlatform(policy, 'win'): |
381 pieces.append('0x%08x (Windows)' % example_value) | 386 pieces.append('0x%08x (Windows)' % example_value) |
382 if self.IsPolicySupportedOnPlatform(policy, 'linux'): | 387 if self.IsPolicySupportedOnPlatform(policy, 'linux'): |
383 pieces.append('%d (Linux)' % example_value) | 388 pieces.append('%d (Linux)' % example_value) |
| 389 if self.IsPolicySupportedOnPlatform(policy, 'android'): |
| 390 pieces.append('%d (Android)' % example_value) |
384 if self.IsPolicySupportedOnPlatform(policy, 'mac'): | 391 if self.IsPolicySupportedOnPlatform(policy, 'mac'): |
385 pieces.append('%d (Mac)' % example_value) | 392 pieces.append('%d (Mac)' % example_value) |
386 self.AddText(parent, ', '.join(pieces)) | 393 self.AddText(parent, ', '.join(pieces)) |
387 elif policy_type == 'string-enum': | 394 elif policy_type == 'string-enum': |
388 self.AddText(parent, '"%s"' % (example_value)) | 395 self.AddText(parent, '"%s"' % (example_value)) |
389 elif policy_type in ('list', 'string-enum-list'): | 396 elif policy_type in ('list', 'string-enum-list'): |
390 self._AddListExample(parent, policy) | 397 self._AddListExample(parent, policy) |
391 elif policy_type == 'dict': | 398 elif policy_type == 'dict': |
392 self._AddDictionaryExample(parent, policy) | 399 self._AddDictionaryExample(parent, policy) |
393 else: | 400 else: |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 <dt>Attribute:</dt><dd>Description</dd> | 457 <dt>Attribute:</dt><dd>Description</dd> |
451 ... | 458 ... |
452 </dl> | 459 </dl> |
453 | 460 |
454 Args: | 461 Args: |
455 parent: A DOM element for which the list will be added. | 462 parent: A DOM element for which the list will be added. |
456 policy: The data structure of the policy. | 463 policy: The data structure of the policy. |
457 ''' | 464 ''' |
458 | 465 |
459 dl = self.AddElement(parent, 'dl') | 466 dl = self.AddElement(parent, 'dl') |
460 data_type = self._TYPE_MAP[policy['type']] | 467 data_type = [self._TYPE_MAP[policy['type']]] |
| 468 qualified_types = [] |
| 469 is_complex_policy = False |
| 470 if (self.IsPolicySupportedOnPlatform(policy, 'android') and |
| 471 self._RESTRICTION_TYPE_MAP.get(policy['type'], None)): |
| 472 qualified_types.append('Android:%s' % |
| 473 self._RESTRICTION_TYPE_MAP[policy['type']]) |
| 474 if policy['type'] in ('dict', 'list'): |
| 475 is_complex_policy = True |
461 if (self.IsPolicySupportedOnPlatform(policy, 'win') and | 476 if (self.IsPolicySupportedOnPlatform(policy, 'win') and |
462 self._REG_TYPE_MAP.get(policy['type'], None)): | 477 self._REG_TYPE_MAP.get(policy['type'], None)): |
463 data_type += ' (%s)' % self._REG_TYPE_MAP[policy['type']] | 478 qualified_types.append('Windows:%s' % self._REG_TYPE_MAP[policy['type']]) |
464 self._AddPolicyAttribute(dl, 'data_type', data_type) | 479 if policy['type'] == 'dict': |
| 480 is_complex_policy = True |
| 481 if qualified_types: |
| 482 data_type.append('[%s]' % ', '.join(qualified_types)) |
| 483 if is_complex_policy: |
| 484 data_type.append('(%s)' % |
| 485 self._GetLocalizedMessage('complex_policies_on_windows')) |
| 486 self._AddPolicyAttribute(dl, 'data_type', ' '.join(data_type)) |
465 if policy['type'] != 'external': | 487 if policy['type'] != 'external': |
466 # All types except 'external' can be set through platform policy. | 488 # All types except 'external' can be set through platform policy. |
467 if self.IsPolicySupportedOnPlatform(policy, 'win'): | 489 if self.IsPolicySupportedOnPlatform(policy, 'win'): |
468 if self.CanBeRecommended(policy) and not self.CanBeMandatory(policy): | 490 if self.CanBeRecommended(policy) and not self.CanBeMandatory(policy): |
469 key_name = self.config['win_reg_recommended_key_name'] | 491 key_name = self.config['win_reg_recommended_key_name'] |
470 else: | 492 else: |
471 key_name = self.config['win_reg_mandatory_key_name'] | 493 key_name = self.config['win_reg_mandatory_key_name'] |
472 self._AddPolicyAttribute( | 494 self._AddPolicyAttribute( |
473 dl, | 495 dl, |
474 'win_reg_loc', | 496 'win_reg_loc', |
475 key_name + '\\' + policy['name'], | 497 key_name + '\\' + policy['name'], |
476 ['.monospace']) | 498 ['.monospace']) |
477 if (self.IsPolicySupportedOnPlatform(policy, 'linux') or | 499 if (self.IsPolicySupportedOnPlatform(policy, 'linux') or |
478 self.IsPolicySupportedOnPlatform(policy, 'mac')): | 500 self.IsPolicySupportedOnPlatform(policy, 'mac')): |
479 self._AddPolicyAttribute( | 501 self._AddPolicyAttribute( |
480 dl, | 502 dl, |
481 'mac_linux_pref_name', | 503 'mac_linux_pref_name', |
482 policy['name'], | 504 policy['name'], |
483 ['.monospace']) | 505 ['.monospace']) |
| 506 if self.IsPolicySupportedOnPlatform(policy, 'android'): |
| 507 self._AddPolicyAttribute( |
| 508 dl, |
| 509 'android_restriction_name', |
| 510 policy['name'], |
| 511 ['.monospace']) |
484 dd = self._AddPolicyAttribute(dl, 'supported_on') | 512 dd = self._AddPolicyAttribute(dl, 'supported_on') |
485 self._AddSupportedOnList(dd, policy['supported_on']) | 513 self._AddSupportedOnList(dd, policy['supported_on']) |
486 dd = self._AddPolicyAttribute(dl, 'supported_features') | 514 dd = self._AddPolicyAttribute(dl, 'supported_features') |
487 self._AddFeatures(dd, policy) | 515 self._AddFeatures(dd, policy) |
488 dd = self._AddPolicyAttribute(dl, 'description') | 516 dd = self._AddPolicyAttribute(dl, 'description') |
489 self._AddDescription(dd, policy) | 517 self._AddDescription(dd, policy) |
490 if (self.IsPolicySupportedOnPlatform(policy, 'win') or | 518 if (self.IsPolicySupportedOnPlatform(policy, 'win') or |
491 self.IsPolicySupportedOnPlatform(policy, 'linux') or | 519 self.IsPolicySupportedOnPlatform(policy, 'linux') or |
| 520 self.IsPolicySupportedOnPlatform(policy, 'android') or |
492 self.IsPolicySupportedOnPlatform(policy, 'mac')): | 521 self.IsPolicySupportedOnPlatform(policy, 'mac')): |
493 # Don't add an example for ChromeOS-only policies. | 522 # Don't add an example for ChromeOS-only policies. |
494 if policy['type'] != 'external': | 523 if policy['type'] != 'external': |
495 # All types except 'external' can be set through platform policy. | 524 # All types except 'external' can be set through platform policy. |
496 dd = self._AddPolicyAttribute(dl, 'example_value') | 525 dd = self._AddPolicyAttribute(dl, 'example_value') |
497 self._AddExample(dd, policy) | 526 self._AddExample(dd, policy) |
498 | 527 |
499 def _AddPolicyNote(self, parent, policy): | 528 def _AddPolicyNote(self, parent, policy): |
500 '''If a policy has an additional web page assigned with it, then add | 529 '''If a policy has an additional web page assigned with it, then add |
501 a link for that page. | 530 a link for that page. |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 'string': 'String', | 681 'string': 'String', |
653 'int': 'Integer', | 682 'int': 'Integer', |
654 'main': 'Boolean', | 683 'main': 'Boolean', |
655 'int-enum': 'Integer', | 684 'int-enum': 'Integer', |
656 'string-enum': 'String', | 685 'string-enum': 'String', |
657 'list': 'List of strings', | 686 'list': 'List of strings', |
658 'string-enum-list': 'List of strings', | 687 'string-enum-list': 'List of strings', |
659 'dict': 'Dictionary', | 688 'dict': 'Dictionary', |
660 'external': 'External data reference', | 689 'external': 'External data reference', |
661 } | 690 } |
662 reg_dict = 'REG_SZ; %s' % self._GetLocalizedMessage( | |
663 'complex_policies_on_windows') | |
664 self._REG_TYPE_MAP = { | 691 self._REG_TYPE_MAP = { |
665 'string': 'REG_SZ', | 692 'string': 'REG_SZ', |
666 'int': 'REG_DWORD', | 693 'int': 'REG_DWORD', |
667 'main': 'REG_DWORD', | 694 'main': 'REG_DWORD', |
668 'int-enum': 'REG_DWORD', | 695 'int-enum': 'REG_DWORD', |
669 'string-enum': 'REG_SZ', | 696 'string-enum': 'REG_SZ', |
670 'dict': reg_dict, | 697 'dict': 'REG_SZ', |
| 698 } |
| 699 self._RESTRICTION_TYPE_MAP = { |
| 700 'int-enum': 'choice', |
| 701 'string-enum': 'choice', |
| 702 'list': 'string', |
| 703 'string-enum-list': 'multi-select', |
| 704 'dict': 'string', |
671 } | 705 } |
672 # The CSS style-sheet used for the document. It will be used in Google | 706 # The CSS style-sheet used for the document. It will be used in Google |
673 # Sites, which strips class attributes from HTML tags. To work around this, | 707 # Sites, which strips class attributes from HTML tags. To work around this, |
674 # the style-sheet is a dictionary and the style attributes will be added | 708 # the style-sheet is a dictionary and the style attributes will be added |
675 # "by hand" for each element. | 709 # "by hand" for each element. |
676 self._STYLE = { | 710 self._STYLE = { |
677 'table': 'border-style: none; border-collapse: collapse;', | 711 'table': 'border-style: none; border-collapse: collapse;', |
678 'tr': 'height: 0px;', | 712 'tr': 'height: 0px;', |
679 'td': 'border: 1px dotted rgb(170, 170, 170); padding: 7px; ' | 713 'td': 'border: 1px dotted rgb(170, 170, 170); padding: 7px; ' |
680 'vertical-align: top; width: 236px; height: 15px;', | 714 'vertical-align: top; width: 236px; height: 15px;', |
(...skipping 10 matching lines...) Expand all Loading... |
691 } | 725 } |
692 | 726 |
693 # A simple regexp to search for URLs. It is enough for now. | 727 # A simple regexp to search for URLs. It is enough for now. |
694 self._url_matcher = lazy_re.compile('(http://[^\\s]*[^\\s\\.])') | 728 self._url_matcher = lazy_re.compile('(http://[^\\s]*[^\\s\\.])') |
695 | 729 |
696 def GetTemplateText(self): | 730 def GetTemplateText(self): |
697 # Return the text representation of the main <div> tag. | 731 # Return the text representation of the main <div> tag. |
698 return self._main_div.toxml() | 732 return self._main_div.toxml() |
699 # To get a complete HTML file, use the following. | 733 # To get a complete HTML file, use the following. |
700 # return self._doc.toxml() | 734 # return self._doc.toxml() |
OLD | NEW |