diff --git a/pysnooper/__main__.py b/pysnooper/__main__.py new file mode 100644 index 0000000..72a41bb --- /dev/null +++ b/pysnooper/__main__.py @@ -0,0 +1,19 @@ +# Copyright 2019 Ram Rachum and collaborators. +# This program is distributed under the MIT license. + +from wrapper import snoop_wrapper +import sys + +def main(): + #TODO: Add flags for different options + if sys.argv[1] == "-m": #python3 -m pysnooper + snoop_wrapper() + if sys.argv[1] =='h': + print("Usage: python3 -m pysnooper ") + sys.exit(1) + +if __name__ == '__main__': + #TODO: Add flags for different options + #TODO: Assertions + + main() diff --git a/pysnooper/wrapper.py b/pysnooper/wrapper.py new file mode 100644 index 0000000..e09b64c --- /dev/null +++ b/pysnooper/wrapper.py @@ -0,0 +1,62 @@ +# Copyright 2019 Ram Rachum and collaborators. +# This program is distributed under the MIT license. + +import sys +import os +import subprocess + +#TODO: Pass the arguments to the file_snoop + +# Define the snoop code to be prepended to the original code +snoop_code = """import pysnooper +pysnooper.snoop().__enter__() +""" + +def assertions(): + assert len(sys.argv) >1, "Usage: python