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

Side by Side Diff: grit/node/misc.py

Issue 10800072: When looking up a file in the first IDs list, and the file is outside of the tree starting at SRCDI… (Closed) Base URL: http://grit-i18n.googlecode.com/svn/trunk/
Patch Set: Created 8 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 """Miscellaneous node types. 6 """Miscellaneous node types.
7 """ 7 """
8 8
9 import os.path 9 import os.path
10 import re 10 import re
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 # Nothing to do if the first_ids_filename attribute isn't set. 451 # Nothing to do if the first_ids_filename attribute isn't set.
452 first_ids_filename = self.GetFirstIdsFile() 452 first_ids_filename = self.GetFirstIdsFile()
453 if not first_ids_filename: 453 if not first_ids_filename:
454 return 454 return
455 455
456 src_root_dir, first_ids = _ReadFirstIdsFromFile(first_ids_filename, 456 src_root_dir, first_ids = _ReadFirstIdsFromFile(first_ids_filename,
457 defines) 457 defines)
458 from grit.node import empty 458 from grit.node import empty
459 for node in self.inorder(): 459 for node in self.inorder():
460 if isinstance(node, empty.GroupingNode): 460 if isinstance(node, empty.GroupingNode):
461 filename = os.path.abspath(filename_or_stream)[ 461 abs_filename = os.path.abspath(filename_or_stream)
462 len(src_root_dir) + 1:] 462 if abs_filename[:len(src_root_dir)] != src_root_dir:
463 filename = filename.replace('\\', '/') 463 filename = os.path.basename(filename_or_stream)
464 else:
465 filename = abs_filename[len(src_root_dir) + 1:]
466 filename = filename.replace('\\', '/')
464 467
465 if node.attrs['first_id'] != '': 468 if node.attrs['first_id'] != '':
466 raise Exception( 469 raise Exception(
467 "Don't set the first_id attribute when using the first_ids_file " 470 "Don't set the first_id attribute when using the first_ids_file "
468 "attribute on the <grit> node, update %s instead." % 471 "attribute on the <grit> node, update %s instead." %
469 first_ids_filename) 472 first_ids_filename)
470 473
471 try: 474 try:
472 id_list = first_ids[filename][node.name] 475 id_list = first_ids[filename][node.name]
473 except KeyError, e: 476 except KeyError, e:
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 by parameters of the same name. 555 by parameters of the same name.
553 """ 556 """
554 node = IdentifierNode() 557 node = IdentifierNode()
555 node.StartParsing('identifier', parent) 558 node.StartParsing('identifier', parent)
556 node.HandleAttribute('name', name) 559 node.HandleAttribute('name', name)
557 node.HandleAttribute('id', id) 560 node.HandleAttribute('id', id)
558 node.HandleAttribute('comment', comment) 561 node.HandleAttribute('comment', comment)
559 node.HandleAttribute('systemid', systemid) 562 node.HandleAttribute('systemid', systemid)
560 node.EndParsing() 563 node.EndParsing()
561 return node 564 return node
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698