• 1 Post
  • 992 Comments
Joined 2 years ago
cake
Cake day: August 6th, 2023

help-circle















  • Make a script. I’d use xonsh or python with sh.py.

    • create a dict for remote to local filename map
    • walk your local collection
      • for each file, determine what the correct remote name (including a valid extension) would be, and add the pair to the dict, with remote filenames as keys, local filenames as values
    • make a set like local_munged_names from that dict’s keys
    • walk your remote tree, and store the filenames in a set like remote_names
    • names_to_upload = local_munged_names - remote_names
    • for each name in names to upload, look up the local filename from the remote to local filename map. Then, encode it if it needs encoding, and upload.

  • Yes, because

    In the first kind of language, the thought process is basically: I have the flow of execution, starting at the top of the file. If I want to make a library, I should build the things I want to build, then get out of the way.

    Note the “I have the flow of execution”, and the “if I want to build a library”.

    If you just want to build an executable, do as you wish, you already have the flow of execution.

    If you want to build a library, make the relevant classes and functions and get out of the way (i.e., no IO, no long-running tasks).

    If you want to combine them, use the main name check - or, make a package and do entry points that way. Either way works, because both can fulfill the goal of staying out of the way of those importing this as a library.