Esempio n. 1
0
    def repair(path, ext_storedir=None, revision='latest', **kwargs):
        """Repair a working copy.

        path is the path to the package working copy.

        Keyword arguments:
        project -- name of the project (default: '')
        package -- name of the package (default: '')
        apiurl -- apiurl is the apiurl (default: '')
        revision -- the revision of the package (default: 'latest')
        ext_storedir -- path to the storedir (default: None)

        """
        global _PKG_DATA
        if not os.path.exists(_storedir(path)):
            wc_init(path, ext_storedir=ext_storedir)
        missing, xml_data, pkg_data = Package.wc_check(path)
        for filename in ('_project', '_package', '_apiurl'):
            if filename not in missing:
                continue
            key = filename[1:]
            if key not in kwargs:
                raise ValueError("%s argument required" % key)
            meth_name = 'wc_write_' + key
            globals()[meth_name](path, kwargs[key])
        project = wc_read_project(path)
        package = wc_read_package(path)
        apiurl = wc_read_apiurl(path)
        if '_files' in missing or xml_data:
            spkg = SourcePackage(project, package)
            directory = spkg.list(rev=revision, apiurl=apiurl)
            xml_data = etree.tostring(directory, pretty_print=True)
            wc_write_files(path, xml_data)
        if '_version' in missing:
            wc_write_version(path)
        if _PKG_DATA in missing:
            os.mkdir(wc_pkg_data_filename(path, ''))
        files = wc_read_files(path)
        # check again - only pkg_data left
        missing, xml_data, pkg_data = Package.wc_check(path)
        for filename in pkg_data:
            fname = wc_pkg_data_filename(path, filename)
            f = files.find(filename).file()
            f.write_to(fname)
        # clean unused storefiles
        store = wc_pkg_data_filename(path, '')
        for filename in os.listdir(store):
            if files.find(filename) is None:
                os.unlink(os.path.join(store, filename))
Esempio n. 2
0
    def repair(path, ext_storedir=None, revision='latest', **kwargs):
        """Repair a working copy.

        path is the path to the package working copy.

        Keyword arguments:
        project -- name of the project (default: '')
        package -- name of the package (default: '')
        apiurl -- apiurl is the apiurl (default: '')
        revision -- the revision of the package (default: 'latest')
        ext_storedir -- path to the storedir (default: None)

        """
        global _PKG_DATA
        if not os.path.exists(_storedir(path)):
            wc_init(path, ext_storedir=ext_storedir)
        missing, xml_data, pkg_data = Package.wc_check(path)
        for filename in ('_project', '_package', '_apiurl'):
            if filename not in missing:
                continue
            key = filename[1:]
            if key not in kwargs:
                raise ValueError("%s argument required" % key)
            meth_name = 'wc_write_' + key
            globals()[meth_name](path, kwargs[key])
        project = wc_read_project(path)
        package = wc_read_package(path)
        apiurl = wc_read_apiurl(path)
        if '_files' in missing or xml_data:
            spkg = SourcePackage(project, package)
            directory = spkg.list(rev=revision, apiurl=apiurl)
            xml_data = etree.tostring(directory, pretty_print=True)
            wc_write_files(path, xml_data)
        if '_version' in missing:
            wc_write_version(path)
        if _PKG_DATA in missing:
            os.mkdir(wc_pkg_data_filename(path, ''))
        files = wc_read_files(path)
        # check again - only pkg_data left
        missing, xml_data, pkg_data = Package.wc_check(path)
        for filename in pkg_data:
            fname = wc_pkg_data_filename(path, filename)
            f = files.find(filename).file()
            f.write_to(fname)
        # clean unused storefiles
        store = wc_pkg_data_filename(path, '')
        for filename in os.listdir(store):
            if files.find(filename) is None:
                os.unlink(os.path.join(store, filename))
Esempio n. 3
0
    def init(path, project, package, apiurl, ext_storedir=None, **kwargs):
        """Initializes a directory as a package working copy.

        path is a path to a directory, project is the name
        of the project, package is the name of the package
        and apiurl is the apiurl.

        Keyword arguments:
        ext_storedir -- path to the storedir (default: None).
                        If not specified a "flat" package is created,
                        otherwise path/.osc is a symlink to storedir.
        kwargs -- optional keyword args which are passed to Package's
                  __init__ method

        """
        wc_init(path, ext_storedir=ext_storedir)
        wc_write_project(path, project)
        wc_write_package(path, package)
        wc_write_apiurl(path, apiurl)
        wc_write_files(path, '<directory/>')
        return Package(path, **kwargs)
Esempio n. 4
0
    def init(path, project, package, apiurl, ext_storedir=None, **kwargs):
        """Initializes a directory as a package working copy.

        path is a path to a directory, project is the name
        of the project, package is the name of the package
        and apiurl is the apiurl.

        Keyword arguments:
        ext_storedir -- path to the storedir (default: None).
                        If not specified a "flat" package is created,
                        otherwise path/.osc is a symlink to storedir.
        kwargs -- optional keyword args which are passed to Package's
                  __init__ method

        """
        wc_init(path, ext_storedir=ext_storedir)
        wc_write_project(path, project)
        wc_write_package(path, package)
        wc_write_apiurl(path, apiurl)
        wc_write_files(path, '<directory/>')
        return Package(path, **kwargs)