def import_json(file, path=''): with open(get_file(file, path=path), 'r') as f: try: return json.load(f) except: return {}
def export_json(data, file, path='', indent=2): with open(get_file(file, path=path), 'w') as f: json.dump(data, f, indent=indent)
def get_file_string(file, path='', encoding='utf-8'): with open(get_file(file, path=path), 'r', encoding=encoding) as f: return f.read()
def append_file_lines(file, path='', lines=[], newline='\n', encoding='utf-8'): with open(get_file(file, path=path), 'a', encoding=encoding) as f: f.writelines(lines_gen(lines=lines, newline=newline)) return True
def append_file_string(file, path='', text='', encoding='utf-8'): with open(get_file(file, path=path), 'a', encoding=encoding) as f: f.write(text) return True
def get_file_lines(file, path='', newline='\n', encoding='utf-8'): with open(get_file(file, path=path), 'r', encoding=encoding) as f: return [l.rstrip(newline) for l in f]