Package: replbox
replboxA synchronous Python client package for loading, reading, and dumping REPL projects from repl.itThere currently isn't any functionality for writing to REPLs, nor running REPLs in this version, those features will come at a later date. This library is still in alpha and much more is still to come. Version 0.1.0 won't hit until the ability to run a REPL is added. Currently working on learning crosis first lolUsageYou first have to instantiate aClientclass fromreplbox. Like so:importreplboxclient=replbox.Client()Load/Create a REPL:Then you can either load a REPL from a user/team path, or create an anonymous REPL with the client.repl=client.create(language="python3",title="New Repl")otherRepl=client.load_from_path("@replbox/dummy-repl")client.create()can take a number of keyword arguments but only requires thelanguagekwarg, which defaults topython3. You get a list of valid languages by runningprint(replbox.fetch_langs())client.load_from_path()takes a single argument: a user/team REPL path. This path is usually follow the format@<username>/<replname>.The username is case-insensitive, but the REPL name has to be a compatible slug, so for example, "This is a New Repl" becomesThis-is-a-New-Repl.Once you've done that, you now have a REPL!Get REPL Info:You can ouput the REPL object in a pretty way like this:print(json.dumps(repl.json,indent=2))which will get you a similar output to this:{"id":"dd6f9fcd-c515-4d7f-ae93-0e3b317c85d8","user_id":4532700,"title":"dummy-repl","description":"","is_project":false,"is_private":false,"time_created":"2020-10-26T20:59:41.312Z","time_updated":"2020-10-26T21:59:42.407Z",...}NOTE:All attributes inrepl.jsoncan be accessed individually, likerepl.idorrepl.time_createdRead a REPL file:You can read the contents of a file within a REPL with:file=repl.read('mock/__init__.py')print(file)ORmainFile=repl.read_main()print(mainFile)The main file of a REPL is usually namedmain.<language-extension>. If a main file can't be found then it will default to the first file in the listrepl.fileNames.Download the REPL:Using a bit ofosmagic, you can download all the contents of a repl to a folder of your choosing, take a look at this code:path=os.getcwd()+"/"+repl.slug+"/"forfileinrepl.fileNames:repl.ensure_path(path+file)print(f"Created directory:{path+file}")withopen(path+file,'w+')asfp:repl.dump(file,fp)print(f"Contents successfully dumped.")print()This code does a few things:Creates a folder with the REPL name in the same directory as your code.repl.ensure_path()Splices the file path and file name, then creates the directory if it doesn't exist already.repl.dump()Writes the contents of the REPL file to the local copy.LoginYou can login with your repl.it SID. Find this value in your cookies after logging into repl.it underconnect.sidandkeep this supder-duper ultrasecret! It'll look a little something like this:Then login like so:importosimportreplboxSID=os.getenv("SID")client=replbox.Client()user=client.login(SID)client.login()will return aUserClient()which is essentially the same as a base client but will make requests to the API on your behalf. So loading a REPL from a path under your username should makerepl.is_ownerequal toTrue.