Esempio n. 1
0
def savecache(apicache, json_file):
    """
    Saves apicache dictionary as json_file, returns dictionary as indented str
    """
    apicachestr = json.dumps(apicache, indent=2)
    with open(json_file, 'w') as cache_file:
        cache_file.write(apicachestr)
    return apicachestr
Esempio n. 2
0
def savecache(apicache, json_file):
    """
    Saves apicache dictionary as json_file, returns dictionary as indented str
    """
    if isinstance(type(apicache), types.NoneType) or apicache is None or apicache is {}:
      return ""
    apicachestr = json.dumps(apicache, indent=2)
    with open(json_file, 'w') as cache_file:
        cache_file.write(apicachestr)
    return apicachestr
def savecache(apicache, json_file):
    """
    Saves apicache dictionary as json_file, returns dictionary as indented str
    """
    if apicache is None or apicache is {}:
        return ""
    apicachestr = json.dumps(apicache, indent=2)
    with open(json_file, 'w') as cache_file:
        cache_file.write(apicachestr)
    return apicachestr