Ejemplo n.º 1
0
def smart_save(data, dpath='', fname='', uid='', ext='', verbose=VERBOSE_IO):
    ''' Saves data to the direcotry speficied '''
    helpers.ensuredir(dpath)
    fpath = __args2_fpath(dpath, fname, uid, ext)
    if verbose:
        if verbose > 1:
            print('[io]')
        print(smart_fname_info('smart_save', dpath, fname, uid, ext))
    ret = __smart_save(data, fpath, verbose)
    if verbose > 1:
        print('[io]')
    return ret
Ejemplo n.º 2
0
def smart_save(data, dpath='', fname='', uid='', ext='', verbose=VERBOSE_IO):
    ''' Saves data to the direcotry speficied '''
    helpers.ensuredir(dpath)
    fpath = __args2_fpath(dpath, fname, uid, ext)
    if verbose:
        if verbose > 1:
            print('[io]')
        print(('[io] smart_save(dpath=%r,\n' + (' ' * 11) + 'fname=%r, uid=%r, ext=%r)')
              % (dpath, fname, uid, ext))
    ret = __smart_save(data, fpath, verbose)
    if verbose > 1:
        print('[io]')
    return ret
Ejemplo n.º 3
0
def smart_save(data, dpath='', fname='', uid='', ext='', verbose=VERBOSE_IO):
    ''' Saves data to the direcotry speficied '''
    helpers.ensuredir(dpath)
    fpath = __args2_fpath(dpath, fname, uid, ext)
    if verbose:
        if verbose > 1:
            print('[io]')
        print(('[io] smart_save(dpath=%r,\n' +
               (' ' * 11) + 'fname=%r, uid=%r, ext=%r)') %
              (dpath, fname, uid, ext))
    ret = __smart_save(data, fpath, verbose)
    if verbose > 1:
        print('[io]')
    return ret
Ejemplo n.º 4
0
        hsdir = dirname((dirname(__file__)))
    return hsdir


def splash_img_fpath():
    hsdir = dirname(__file__)
    splash_fpath = realpath(join(hsdir, '../hsgui/_frontend/splash.png'))
    return splash_fpath


# --- Global Cache ---
# TODO: This doesnt belong here
HOME = expanduser('~')
#GLOBAL_CACHE_DIR = realpath('.hotspotter/global_cache')
GLOBAL_CACHE_DIR = join(HOME, '.hotspotter/global_cache')
helpers.ensuredir(GLOBAL_CACHE_DIR)


def global_cache_read(cache_id, default='.'):
    cache_fname = join(GLOBAL_CACHE_DIR, 'cached_dir_%s.txt' % cache_id)
    return helpers.read_from(cache_fname) if exists(cache_fname) else default


def global_cache_write(cache_id, newdir):
    cache_fname = join(GLOBAL_CACHE_DIR, 'cached_dir_%s.txt' % cache_id)
    helpers.write_to(cache_fname, newdir)


def delete_global_cache():
    global_cache_dir = GLOBAL_CACHE_DIR
    helpers.remove_files_in_dir(global_cache_dir, recursive=True, verbose=True,
Ejemplo n.º 5
0
# --- Standard Images ---


def splash_img_fpath():
    hsdir = dirname(__file__)
    splash_fpath = realpath(join(hsdir, '../hsgui/_frontend/splash.png'))
    return splash_fpath


# --- Global Cache ---
# TODO: This doesnt belong here
HOME = expanduser('~')
#GLOBAL_CACHE_DIR = realpath('.hotspotter/global_cache')
GLOBAL_CACHE_DIR = join(HOME, '.hotspotter/global_cache')
helpers.ensuredir(GLOBAL_CACHE_DIR)


def global_cache_read(cache_id, default='.'):
    cache_fname = join(GLOBAL_CACHE_DIR, 'cached_dir_%s.txt' % cache_id)
    return helpers.read_from(cache_fname) if exists(cache_fname) else default


def global_cache_write(cache_id, newdir):
    cache_fname = join(GLOBAL_CACHE_DIR, 'cached_dir_%s.txt' % cache_id)
    helpers.write_to(cache_fname, newdir)


def delete_global_cache():
    global_cache_dir = GLOBAL_CACHE_DIR
    helpers.remove_files_in_dir(global_cache_dir,