Reputation: 2471
I have a python script using Pyinotify that does some stuff on IN_MOVED_TO
. What's the easiest way to trigger the script on specific files, using another python script, without actually moving the files out and back in?
Upvotes: 0
Views: 916
Reputation: 328800
Create a "glue function". Say the original code is:
def some_inane_os_api(with, lots, of, arguments):
... your code ...
Replace this with:
def some_inane_os_api(with, lots, of, arguments):
your_code(just, the, arguments, you need)
def your_code(...)
... your code ...
Now you can call your_code()
(which has a much more simple API) from your tests.
Say the original API has some complex structures. All you need to do is copy the relevant data from that structure into parameters or a couple of simple helper objects.
That isolates your code from the complex API and makes it much more simple to test and/or reuse.
Upvotes: 1
Reputation: 80851
you can avoid moving file by simply renaming the file (which is very similar on linux), for example a mv file file.sav && mv file.sav file
Upvotes: 0