Search code examples
pythonpysvn

How do I recurse into list returned by PySVN.Client.list()?


I am using PySVN to get some repository info.

I used Client.list entries_list = client.list("https://myrepourl.com/myproject", ...) which "returns a list with a tuple of information for each file in the given path."

I would like to get only single information from the list/tuple, and that's whether the URL has some properties set (has_props - bool - True if the node has properties).

How do I recurse into entries_list and return a list of remote http paths, but only those paths with has_props set to True?

Edit:

entries_list {list}
  000 {tuple}
    0 {instance}
      data {dict}
        'path' = https://myrepourl.com/myproject/somedirorfile1
        'has_props' = 1
        'kind' = dir
  001 {tuple}
    0 {instance}
      data {dict}
        'path' = https://myrepourl.com/myproject/somedirorfile2
        'has_props' = 1
        'kind' = file
  002 {tuple}
    0 {instance}
      data {dict}
        'path' = https://myrepourl.com/myproject/somedirorfile3
        'has_props' = 0
        'kind' = dir
 .
 .
 .

Solution

  • This is how has_props element could be accessed:

    has_props = entries_list[0][0][‘has_props’]
    

    And this is how to loop and search through the whole list:

    entries_list = client.list("https://example.com/svnrepository/product",...)
    
    for entry in entries_list:
        data_dict = entry[0]
        has_props = data_dict['has_props']
    
        if has_props == 1:
            print "Found props."