tominsam/dropbox-tools — pull request #2 by darth-cheney (2013-11-12 04:05:22+00:00)
Title: Added Settings and other Configuration Options

I came across your program today when I had to help someone in real estate recover over 5k files that had been mysteriously deleted from Dropbox. In our case, all the files were deleted on a specific date, so at the time I changed one line in your program, ran it, and everything worked A-Ok. That said, I decided I should add that capability, which then turned into a bunch of other things.

Here's the basic idea: I've added a `settings.py` file and I have the `undelete.py` import it. Basically, it takes the system arguments and parses them based on a `dict` of possible settings (which anyone can customize) and returns a different `dict` with all of the configured settings. You'll see in the `undelete` file that this ends up being something called `config`.

The `all_settings' dictionary in `settings.py` might look a little confusing, but it really isn't. Every new "feature" added here will have to have a `func` key that points to a function to be executed if the user provides the given flag (so when adding a new feature, be sure to write the function too). The `arguments` key is needed because some settings might take multiple arguments and others might take none at all. for example:

```shell$: python undelete.py -R ./ /```

This simply switches `use_recovery` (formerly a constant called `USE_RECOVERY`) to `False` because the default value is always `True`. As such, it takes no arguments.

On the other hand:

```shell$: python undelete.py -D 10/27/2013 11/1/2013 ./ /```

The `-D` flag takes two arguments, a beginning date and end date in `MM/DD/YY` or `MM/DD/YYYY' format. When you look in the `undelete` file you'll see that if this is enabled, the program will only look for files deleted within that range. On a related note, the `-d` flag only looks for files deleted on a given date, which it what I used to get out my the mess that brought me here in the first place.

That about covers what I've done so far. The only problems I see are that the `settings.py` processing doesn't error-check to see whether the correct number of arguments follow a given flag. That's definitely an issue.

Here is an example with multiple flags:

```shell$: python undelete.py -D 5/23/2013 6/4/2013 -d 7/23/2013 -R ./ /```