There are two options for getting files from a shelved changelist; one is easy but requires managing more persistent state on the server, and the other is more stateless but requires more logic on the client side.
The standard workflow (i.e. what most human Perforce users would do) is to unshelve the files into your client workspace:
p4 unshelve -s CHANGE
The files in the shelved changelist will be automatically synced to your workspace (according to your client view) and opened in your default changelist. This is the easy option because you just have to run that one command to have all the files in a predefined local location. From there you can modify them freely, and either submit them or reshelve them to a different changelist (or the same changelist if you modify it to make yourself the owner).
This requires that you have a workspace already set up, and that the files are not already open there, so if you're doing this in a script, the script will need to be configured ahead of time with a suitable workspace and it will need to make sure that at some point it either submits or reverts the changes, or it will need to know how to create its own workspace by running p4 client
, picking a unique client root, etc.
The stateless option is to use p4 print
to get the contents of the shelved changelist:
p4 print @=CHANGE
This will stream the files to stdout, with headers in between giving the depot path. If your linter can handle streaming data, this may be the easy option; if it needs to read files from disk, you'll have to implement the logic required to put the files in a suitable location, and clean them up when you're done.
Translating either of the above to p4python is pretty straightforward (I'd try to whip up a code sample but the p4python installer is currently broken on Windows so I haven't been able to use p4python in a while), but my recommendation is to familiarize yourself with the above commands at the terminal in a test environment first so you can better understand the interface and the requirements around workspace setup, authentication, etc. before you implement that logic in a script.