labordata / lm20

labor relations consultants
MIT License
2 stars 1 forks source link

Fix attribute errors and filing csvs #13

Closed xmedr closed 4 months ago

xmedr commented 4 months ago

Overview

All of the content-dispositions when looking for filenames as of late have been either of type str or None. So the decode() method that has been in use has been raising AttributeErrors. This branch accounts for the content-disposition being a string, and passes the filename found within.

After resolving that error, jq had issues parsing out the files attributes of objects in filing.json to a csv since they were nested objects. This branch also flattens out that object with a make command to get the csv working.

Testing Instructions

xmedr commented 4 months ago

This still errors out when the content-disposition is None, but the command would still continue to run. I imagine this can return something more useful in that case, but was unsure what that would be since no content would mean no file. What do you think @fgregg?

fgregg commented 4 months ago

@xmedr let's do something like


       content_disposition = headers.get("Content-Disposition")
       if content_disposition:
           _, params = cgi.parse_header(content_disposition)
            filename = params["filename"]

            media_ext = os.path.splitext(filename)[1]
        else:
            media_ext = ""
xmedr commented 4 months ago

awesome, ty for those suggestions i've got them in!