Exemplo n.º 1
0
    def __init__(self, path, *args, **kwargs):
        super(PerforcePath, self).__init__(path)
        self._p4 = kwargs.pop('p4', None)
        self._clientData = kwargs.pop('clientData', None)
        self._where = kwargs.pop('where', None)
        self._client = None
        self._perforce_root = None

        self._data = {}
        self._loaded_cmds = set()

        self._input_path = path

        if path == '/':
            raise Exception(
                "Can't create a Perforce instance from your system root path: {0}"
                .format(path))

        if path[0:2] == "//":
            self._data['depotFile'] = general.path_normalize(path)
        else:
            self._data['path'] = general.path_normalize(path)

        if kwargs.get('validate', True):
            self.validate()
Exemplo n.º 2
0
def get_client_from_path(p4, path, clients=None, includeData=False):
    if clients is None:
        clients = p4.run_clients('-u', p4.user)
        clients.sort(key=lambda c: c['Access'], reverse=True)

    if not clients:
        return

    path = general.path_normalize(path).lower()

    # First check for matching clients with matching host
    _clients = filter(lambda c: c['Host'] == p4.host, clients)
    for _client in _clients:
        if check_path_in_client(p4, _client, path):
            if includeData:
                return _client
            return _client['client']

    # Search the rest of the clients that don't have a host set
    _clients = filter(lambda c: c['Host'] == "", clients)
    for _client in _clients:
        if check_path_in_client(p4, _client, path):
            if includeData:
                return _client
            return _client['client']

    # No Matches
    return
Exemplo n.º 3
0
def get_child_dirs(p4, path, **kwargs):
    """
    Return all child directories of the given path as strings
    Kwargs are passed to filter_item
    """
    searchPath = "{0}/*".format(path)
    result = []
    try:
        dirsResult = p4.run_dirs(searchPath)
    except P4.P4Exception:
        dirsResult = []
    for r in dirsResult:
        path = general.path_normalize(r['dir'])
        basename = os.path.basename(path)
        if general.filter_item(basename, **kwargs):
            result.append(path)
    return result
Exemplo n.º 4
0
def get_child_files(p4, path, includeDeleted=False, **kwargs):
    """
    Return all perforce files inside the given directory as strings
    """
    searchPath = "{0}/*".format(path)
    result = []
    try:
        filesResult = p4.run_files(searchPath)
    except P4.P4Exception:
        filesResult = []
    for f in filesResult:
        deleted = f.get('action', '').endswith('delete')
        if not deleted or includeDeleted:
            path = general.path_normalize(f['depotFile'])
            basename = os.path.basename(path)
            if general.filter_item(basename, **kwargs):
                result.append(path)
    return result
Exemplo n.º 5
0
 def __init__(self, path):
     self._path = general.path_normalize(path)
     self._type = None