Esempio n. 1
0
def process_file(verbose, ignore_fault, rm_ext, _file):
    
    result, contents=file_contents(_file)
    if not result.startswith("ok"):
        if not ignore_fault:
            raise Exception("Can't read file: %s" % _file)
    
    try:    
        maybe_log(verbose, "Formatting file contents")
        contents=contents.replace('\t', ' ')
        lines=contents.split("\n")
        big_line='\t'.join(lines)
        
        name=os.path.basename(_file)
        if rm_ext:
            name, _=os.path.splitext(name)
        whole_line="%s\t%s" % (name, big_line)
    except:
        raise Exception("Can't format text file")
    
    maybe_log(verbose, "Outputting file")
    print whole_line
    
        
        
    
    
Esempio n. 2
0
def run(
    path_config=None
    # ,args=[]
    ,
    **_kw
):

    code, maybe_cpath = resolve_path(path_config)
    raise_if_not_ok(code, "Can't resolve configuration file path")

    code, maybe_contents = file_contents(maybe_cpath)
    raise_if_not_ok(code, "Can't resolve load configuration file")

    logging.info("Loading configuration file...")
    try:
        cdata = yaml.load(maybe_contents)
    except Exception, e:
        raise Exception("Problem with YAML config file: %s" % e)