Permalink
Browse files

Search up the directory tree for default.txt files

  • Loading branch information...
1 parent 9e1a69e commit e2b5cccb29d965e37bd19926a16d1f1eb58d061a @jpenney jpenney committed Mar 1, 2012
Showing with 18 additions and 4 deletions.
  1. +18 −4 metadata.py
View
@@ -263,10 +263,24 @@ def from_text(full_path):
path, name = os.path.split(full_path)
title, ext = os.path.splitext(name)
- for metafile in [os.path.join(path, title) + '.properties',
- os.path.join(path, 'default.txt'), full_path + '.txt',
- os.path.join(path, '.meta', 'default.txt'),
- os.path.join(path, '.meta', name) + '.txt']:
+ search_paths = []
+ ptmp = full_path
+ while ptmp:
+ parent = os.path.dirname(ptmp)
+ if ptmp != parent:
+ ptmp = parent
+ else:
+ break
+ search_paths.append(os.path.join(ptmp, 'default.txt'))
+
+ search_paths.append(os.path.join(path, title) + '.properties')
+ search_paths.reverse()
+
+ search_paths += [ full_path + '.txt',
+ os.path.join(path, '.meta', 'default.txt'),
+ os.path.join(path, '.meta', name) + '.txt']
+
+ for metafile in search_paths:
if os.path.exists(metafile):
sep = ':='[metafile.endswith('.properties')]
for line in file(metafile, 'U'):

0 comments on commit e2b5ccc

Please sign in to comment.