diff options
Diffstat (limited to 'lib/srtgui/templatetags/projecttags.py')
-rw-r--r-- | lib/srtgui/templatetags/projecttags.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/srtgui/templatetags/projecttags.py b/lib/srtgui/templatetags/projecttags.py index d7bc5319..0c5efc29 100644 --- a/lib/srtgui/templatetags/projecttags.py +++ b/lib/srtgui/templatetags/projecttags.py @@ -275,6 +275,24 @@ def get_dict_value(dictionary, key): return '' @register.filter +def get_strdict_value(dictionary_str, key): + """ return the value of a dictionary key + where the dictionary is in string form + """ + try: + dictionary = JsonLib.loads(dictionary_str) + return dictionary[key] + except (KeyError, IndexError): + return '' + +def get_tag_key(tag,key,default=None): + d = json.loads(tag) + if key in d: + return d[key] + return default + + +@register.filter def is_shaid(text): """ return True if text length is 40 characters and all hex-digits """ |