From 9fc99fb71e505c91ba8bfa5f0cc1175d01c33d05 Mon Sep 17 00:00:00 2001 From: hut Date: Sat, 17 Jan 2015 02:52:03 +0100 Subject: core.metadata: use DefaultOpenStruct instead of OpenStruct --- ranger/core/metadata.py | 8 ++++---- ranger/gui/widgets/browsercolumn.py | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ranger/core/metadata.py b/ranger/core/metadata.py index 5b73e9dc..2454ee15 100644 --- a/ranger/core/metadata.py +++ b/ranger/core/metadata.py @@ -12,7 +12,7 @@ DEEP_SEARCH_DEFAULT = False import copy from os.path import join, dirname, exists, basename -from ranger.ext.openstruct import OpenStruct +from ranger.ext.openstruct import DefaultOpenStruct as ostruct class MetadataManager(object): def __init__(self): @@ -28,12 +28,12 @@ class MetadataManager(object): def get_metadata(self, filename): try: - return OpenStruct(copy.deepcopy(self.metadata_cache[filename])) + return ostruct(copy.deepcopy(self.metadata_cache[filename])) except KeyError: try: - return OpenStruct(copy.deepcopy(self._get_entry(filename))) + return ostruct(copy.deepcopy(self._get_entry(filename))) except KeyError: - return OpenStruct() + return ostruct() def set_metadata(self, filename, update_dict): import json diff --git a/ranger/gui/widgets/browsercolumn.py b/ranger/gui/widgets/browsercolumn.py index c8d1023c..00cac553 100644 --- a/ranger/gui/widgets/browsercolumn.py +++ b/ranger/gui/widgets/browsercolumn.py @@ -253,7 +253,7 @@ class BrowserColumn(Pager): use_linemode = drawn._linemode if use_linemode == "metatitle": metadata = self.fm.metadata.get_metadata(drawn.path) - if 'title' not in metadata: + if not metadata.title: use_linemode = "filename" metakey = hash(repr(sorted(metadata.items()))) if metadata else 0 @@ -270,8 +270,8 @@ class BrowserColumn(Pager): # Deal with the line mode if use_linemode == "metatitle": - assert 'title' in metadata, "Ensure that metadata.title is set!" - if 'year' in metadata: + assert metadata.title, "Ensure that metadata.title is set!" + if metadata.year: text = "%s - %s" % (metadata.year, metadata.title) else: text = metadata.title @@ -314,7 +314,7 @@ class BrowserColumn(Pager): if use_linemode == "filename": infostring = self._draw_infostring_display(drawn, space) elif use_linemode == "metatitle": - if metadata and 'authors' in metadata: + if metadata.authors: authorstring = metadata.authors if ',' in authorstring: authorstring = authorstring[0:authorstring.find(",")] -- cgit 1.4.1-2-gfad0