Files
pseudo-channel/both-dir/src/Helpers.py
mutto233 ea70ed38ce Directory Revamp
Before making changes to the update-channels-from-git.sh file, I wanted to have everything stored in such a way that it made logical sense where it went.

Anything that goes to the root folder is in "main-dir", channel specific files are in "channel-dir", and the files for both sections are in "both-dir".  These directories will eventually be referenced in the new version of "update-channels-from-git.sh".
2018-06-29 16:27:29 -04:00

44 lines
854 B
Python

import os
import logging
class Helpers():
"""Class for consolidating helper methods"""
def __init__(self):
pass
def save_file(self, data, filename, path, overwrite=True):
fileName = filename
writepath = path
if not os.path.exists(writepath):
os.makedirs(writepath)
if os.path.exists(writepath+fileName) and overwrite:
os.remove(writepath+fileName)
mode = 'a' if os.path.exists(writepath) else 'w'
with open(writepath+fileName, mode) as f:
f.write(data)
def get_file(self, filename, path):
if not os.path.exists(writepath):
raise IOError("{}, doesn't exist").format(writepath)
if not os.path.exists(writepath+fileName):
raise IOError("{}, doesn't exist").format(fileName)
return None