Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7664743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:22:55+00:00 2026-05-31T14:22:55+00:00

I need to read a filesystem directory structure from an ftp site, so that

  • 0

I need to read a filesystem directory structure from an ftp site, so that later I can seek out specific files for downloading (at different times or not at all).

when downloading the directory structure I am using the following

class remoteFileSystem:
    directory_structure = ?
    def parse_directory_listing(self,listing_str):
            print listing_str

    def readFileListingFTP(self,target):
            ftpaddress = target.ip_address
            ftp_serv = ftplib.FTP(ftpaddress)
            ftp_serv.login('root', 'pass')
            response = ftpserv.retrlines('LIST',parse_directory_listing)

Where the callback doesn’t do anything yet, and the class has no particular members yet for storing the directory structure.

Is there a nice pythonic way of sticking the directory listings into a xml or native directory structure type object? ie does something exist that I am not aware of that will save me from rolling my own stuff (not much coding I admit, but I am always looking for more pythonic ways of doing stuff).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T14:22:56+00:00Added an answer on May 31, 2026 at 2:22 pm

    No native datatype that I’m aware of. Note that a directory structure is a pretty simple tree structure though. If you need more than just a simple tree listing, I’d recommend rolling your own Directory and File objects. Allow your Directory object to act like a dict and you’ll be able to do things like root['etc']['ssh']['config'].

    If you just need a simple tree structure, have you considered just using nested dicts?

    root = {
        'etc': {
            'passwd': None, 
            'shadow': None, 
            'ssh': {
                'config': None}
        }, 
        'lib': {
        }
    }
    

    I’m using None as the data value for a leaf node, but you could certainly store file metadata there instead if you like. Navigating the tree structure is very simple. A listing of /etc is just root['etc'].keys().

    Finally, pet peeve time. “I am always looking for more pythonic ways of doing stuff” What does that mean? It’s perfectly reasonable to look for ideas/advice/guidance, but at the end of the day, the guy with the working code wins. In this case, the “pythonic way of doing stuff” is to just do it. In Python, of course 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to read a properties files that's buried in my package structure in
I need to read from a variety of different text files (I've some delimited
I need to read selected files, matching on the file name, from a remote
I know that you can use java.util.Properties to read Java properties files. See: Java
I need raw read data from and write data into drive..not via existed filesystem
is there a location on the Android filesystem that any program can read and
Within a VB.NET program, I want to read files from a filesystem, then write
I need to read and write xml files to disk from a stateless session
I need to read a file from the local file system using JSP, save
i need to read the values from a file(.csv) ,which contains both positive and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.