예제 #1
0
파일: package.py 프로젝트: dagss/Bento
def raw_to_pkg_kw(raw_dict, user_flags, filename):
    d = build_ast_from_raw_dict(raw_dict, user_flags)

    meta_d, libraries_d, options_d, misc_d = extract_top_dicts(deepcopy(d))
    libraries = build_libs_from_dict(libraries_d)
    executables = build_executables_from_dict(misc_d.pop("executables"))
    data_files = build_data_files_from_dict(misc_d.pop("data_files"))

    kw = {}
    kw.update(meta_d)
    for k in libraries:
        kw[k] = libraries[k]
    kw["executables"] = executables
    kw["data_files"] = data_files

    path_options = misc_d.pop("path_options")
    flag_options = misc_d.pop("flag_options")

    if misc_d.has_key("subento"):
        subentos = misc_d.pop("subento")
        subpackages, files = recurse_subentos(subentos)
        kw["subpackages"] = subpackages
    else:
        files = []

    kw.update(misc_d)
    if filename is not None:
        files.append(filename)
    files.extend(misc_d["hook_files"])
    # XXX: Do we want to automatically add the hook and bento files in extra
    # source files at the PackageDescription level ?
    kw["extra_source_files"].extend(files)

    return kw, files
예제 #2
0
파일: package.py 프로젝트: abadger/Bento
def raw_to_pkg_kw(raw_dict, user_flags, filename):
    d = build_ast_from_raw_dict(raw_dict, user_flags)

    meta_d, libraries_d, options_d, misc_d = extract_top_dicts(deepcopy(d))
    libraries = build_libs_from_dict(libraries_d)
    executables = build_executables_from_dict(misc_d.pop("executables"))
    data_files = build_data_files_from_dict(misc_d.pop("data_files"))

    kw = {}
    kw.update(meta_d)
    for k in libraries:
        kw[k] = libraries[k]
    kw["executables"] = executables
    kw["data_files"] = data_files

    misc_d.pop("path_options")
    misc_d.pop("flag_options")

    if misc_d.has_key("subento"):
        subentos = misc_d.pop("subento")
        if filename is None:
            source_dir = os.getcwd()
        else:
            source_dir = os.path.dirname(filename)
        subpackages, files = recurse_subentos(subentos, source_dir=source_dir)
        kw["subpackages"] = subpackages
    else:
        files = []

    kw.update(misc_d)
    if filename is not None:
        files.append(filename)
    files.extend(misc_d["hook_files"])
    # XXX: Do we want to automatically add the hook and bento files in extra
    # source files at the PackageDescription level ?
    kw["extra_source_files"].extend(files)

    if "description_from_file" in kw:
        if filename:
            description_file = os.path.join(os.path.dirname(filename), kw["description_from_file"])
        else:
            description_file = kw["description_from_file"]
        if not os.path.exists(description_file):
            raise IOError("Description file %r not found" % (description_file,))
        else:
            f = open(description_file)
            try:
                kw["description"] = f.read()
            finally:
                f.close()
    return kw, files
예제 #3
0
파일: package.py 프로젝트: pfmoore/Bento
def raw_to_pkg_kw(raw_dict, user_flags, bento_info=None):
    if bento_info is None:
        source_dir = os.getcwd()
    else:
        # bento_info may be a string or a node
        try:
            source_dir = bento_info.parent.abspath()
            bento_info_path = bento_info.srcpath()
        except AttributeError:
            if os.path.isabs(bento_info):
                source_dir = os.path.dirname(bento_info)
                bento_info_path = os.path.basename(bento_info)
            else:
                source_dir = os.getcwd()
                bento_info_path = os.path.basename(bento_info)
                assert bento_info_path == bento_info

    d = build_ast_from_raw_dict(raw_dict, user_flags)

    meta_d, libraries_d, options_d, misc_d = extract_top_dicts(deepcopy(d))
    libraries = build_libs_from_dict(libraries_d)
    executables = build_executables_from_dict(misc_d.pop("executables"))
    data_files = build_data_files_from_dict(misc_d.pop("data_files"))

    kw = {}
    kw.update(meta_d)
    for k in libraries:
        kw[k] = libraries[k]
    kw["executables"] = executables
    kw["data_files"] = data_files

    misc_d.pop("path_options")
    misc_d.pop("flag_options")

    if "subento" in misc_d:
        subentos = misc_d.pop("subento")
        if len(subentos
               ) > 0 and libraries and libraries["sub_directory"] is not None:
            raise InvalidPackage(
                "You cannot use both Recurse and Library:SubDirectory features !"
            )
        else:
            subpackages, files = recurse_subentos(subentos,
                                                  source_dir=source_dir)
            kw["subpackages"] = subpackages
    else:
        files = []

    kw.update(misc_d)
    if bento_info is not None:
        files.append(bento_info_path)
    files.extend(misc_d["hook_files"])
    # XXX: Do we want to automatically add the hook and bento files in extra
    # source files at the PackageDescription level ?
    kw["extra_source_files"].extend(files)

    if "description_from_file" in kw:
        if bento_info:
            description_file = os.path.join(source_dir,
                                            kw["description_from_file"])
        else:
            description_file = kw["description_from_file"]
        if not os.path.exists(description_file):
            raise IOError("Description file %r not found" %
                          (description_file, ))
        else:
            f = open(description_file)
            try:
                kw["description"] = f.read()
            finally:
                f.close()
    return kw, files
예제 #4
0
파일: package.py 프로젝트: pberkes/Bento
def raw_to_pkg_kw(raw_dict, user_flags, bento_info=None):
    if bento_info is None:
        source_dir = os.getcwd()
    else:
        # bento_info may be a string or a node
        try:
            source_dir = bento_info.parent.abspath()
            bento_info_path = bento_info.srcpath()
        except AttributeError:
            if os.path.isabs(bento_info):
                source_dir = os.path.dirname(bento_info)
                bento_info_path = os.path.basename(bento_info)
            else:
                source_dir = os.getcwd()
                bento_info_path = os.path.basename(bento_info)
                assert bento_info_path == bento_info

    d = build_ast_from_raw_dict(raw_dict, user_flags)

    meta_d, libraries_d, options_d, misc_d = extract_top_dicts(deepcopy(d))
    libraries = build_libs_from_dict(libraries_d)
    executables = build_executables_from_dict(misc_d.pop("executables"))
    data_files = build_data_files_from_dict(misc_d.pop("data_files"))

    kw = {}
    kw.update(meta_d)
    for k in libraries:
        kw[k] = libraries[k]
    kw["executables"] = executables
    kw["data_files"] = data_files

    misc_d.pop("path_options")
    misc_d.pop("flag_options")

    if "subento" in misc_d:
        subentos = misc_d.pop("subento")
        subpackages, files = recurse_subentos(subentos, source_dir=source_dir)
        kw["subpackages"] = subpackages
    else:
        files = []

    kw.update(misc_d)
    if bento_info is not None:
        files.append(bento_info_path)
    files.extend(misc_d["hook_files"])
    # XXX: Do we want to automatically add the hook and bento files in extra
    # source files at the PackageDescription level ?
    kw["extra_source_files"].extend(files)

    if "description_from_file" in kw:
        if bento_info:
            description_file = os.path.join(source_dir, kw["description_from_file"])
        else:
            description_file = kw["description_from_file"]
        if not os.path.exists(description_file):
            raise IOError("Description file %r not found" % (description_file,))
        else:
            f = open(description_file)
            try:
                kw["description"] = f.read()
            finally:
                f.close()
    return kw, files