You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "danepitkin (via GitHub)" <gi...@apache.org> on 2023/09/11 22:21:35 UTC

[GitHub] [arrow] danepitkin commented on a diff in pull request #37558: GH-37555: [Python] Update test_get_file_info_with_selector

danepitkin commented on code in PR #37558:
URL: https://github.com/apache/arrow/pull/37558#discussion_r1322126974


##########
python/pyarrow/fs.py:
##########
@@ -356,7 +356,12 @@ def get_file_info_selector(self, selector):
             selector.base_dir, maxdepth=maxdepth, withdirs=True, detail=True
         )
         for path, info in selected_files.items():
-            infos.append(self._create_file_info(path, info))
+            # Need to exclude base directory from selected files if present
+            # (fsspec filesystems, see GH-37555)
+            if (path != selector.base_dir and
+                path != "/" + selector.base_dir[:len(selector.base_dir)-1] and
+                    path != selector.base_dir[:len(selector.base_dir)-1]):

Review Comment:
   Is this logic to handle starting/ending slashes `/`? If so, it might be easier to read with start/end vars e.g.
   ```
   start = 0
   end = len(selector.base_dir)
   if selector.base_dir.startswith("/"):
       start += 1
   if selector.base_dir.endswith("/"):
       end -= 1
   if path != selector.base_dir[start:end]:
       ...
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org