Saravanan666/pypi-org huggingface dataset:
Package: petit-interfacer
Prototype transformerIt's a module of thepetite_stackWhats is that for ?You have a framework that executes a particular prototype of function but you don't want to bother yourself or the end developper with using the exact prototype, then this will help.This lib will attempt to automatically build an interface layer, for your functions without using the**kwargsmagic and the dynamic nature of it.Example :frompetit_interfacerimport(BlindBind,Dataclass,RealOptional,interface_binder_for,Dataclass)defproto(worker:RealOptional[Worker],session:RealOptional[Session],body:BlindBind[RealOptional[Body]],d:Dataclass,cookies:RealOptional[Cookies],):->Optional[Any]:...worker:Worker=...session:Session=...body:Body=...cookies:Cookies=...bind_interface=interface_binder_for(proto)@bind_interfacedefexample1(body)->Any:#notice here that, as body# is BlindBind, we are not obligated to set it's type...# then you can do# without worrying about the user having written the exact prototypeexample1(worker=worker,session=session,body=body,cookies=cookies)@bind_interfacedefexample2(w:Worker)->None:...example2(worker=worker,session=session,body=body,cookies=cookies)# here we have the same prototype in the end, and we are not using **kwargs, so everything is static# and any error will raise a warning before your app starts, so no runtime error and less testing required@bind_interfacedefexample3(w:Worker,BoDyButStangelyNamed)->None:...example3(worker=worker,session=session,body=body,cookies=cookies)# This will work@bind_interfacedefexample3(w,BoDyButStangelyNamed)->None:...example3(worker=worker,session=session,body=body,cookies=cookies)# This will raise an Exception as it can't decide how to bind params togetherSo you see that you can make your life easier, by simply defining the prototype, you want to execute and reliying on static checking and binding.DataclassAs you may know dataclasses does not provide a way to check if a class is a dataclass withissubclass, so this libs add theClassProxyTestclass which can be inherited in order to add support for other classes.The petit_interfacer lib provides the support for the dataclasses based on this technique. You can simply importDataclassfrom it.If you need to add another custom class / function, then useClassProxyTest:Example: How dataclasses is handled:frompetit_interfacerimportClassProxyTestclassDataclass(ClassProxyTest):"""As dataclasses does not provide a class to be used with issubclass, we use this proxy to handle it"""defis_correct_type(t:Any)->bool:returnis_dataclass(t)Using it with basic types:Inherit the type you want to use it with, as without it, the app can't make the difference between twointor twostrNext points :Stop using a lambda for the interface and rather completly redefine and evaluate the function with a modified prototype.
Package: petitioners
# Petitioners[![Build Status](https://secure.travis-ci.org/balanced/petitioners.png?branch=master)](http://travis-ci.org/balanced/petitioners) [![Latest Version](https://pypip.in/version/petitioners/badge.svg)](https://pypi.python.org/pypi/petitioners/) [![Downloads](https://pypip.in/download/petitioners/badge.svg)](https://pypi.python.org/pypi/petitioners/) [![Supported Python versions](https://pypip.in/py_versions/petitioners/badge.svg)](https://pypi.python.org/pypi/petitioners/) [![License](https://pypip.in/license/petitioners/badge.svg)](https://pypi.python.org/pypi/petitioners/)Adds tracing to requests generated by Flask apps.```python@petitioners.register_flask_app('X-Request-Trace', 'Trace-')class FlaskApp(flask.Flask):passapp = FlaskApp('name')# or if you prefer not to use a decoratorpetitioners.Petitioner.register(app)```Requests to `app` will now generate response with headers tagged like```X-Request-Trace: Trace-123123```If this header already exists then it will be appended to like```X-Request-Trace: Trace-123123,Trace-123432```The current trace value can be accessed from `app` via the `petitioners` property```python>>> import flask>>> import petitioners>>> app = flask.Flask('name')>>> petitioners.Petitioner.register(app)>>> app.test_request_context().push()>>> print flask.current_app.petitioners<Petitioner (<Flask 'name'>)X-Petitioners=[u'OHM-c92bffaf1b27497aad73a1cb02b22059']>```
Package: petit-mail
Petit MailThis app provides an easy way to send templated mails.It implements and handles classic SMTP handlers and google-oauth2 handlers.Using Jinja2 and premailer it can easily template an email and it's subject.This lib aims to provide a solid base to build more complex service out of it.Themake_serverfunction will return a prepared instance of FastAPI for later user. It is advised to run this app with uvicorn or gunicorn.EndpointsPOST /send_mail/<_type: Literal['plain', 'html']>Cet endpoint permet d'envoyer un mail :{"data"?:{},"template_name"?:"","content"?:"mail content","subject"?:"mail subject","from":"sender adress","addresses":[]}if_type== 'html' then the mail will be templated with the data contained under thedatakey.if_type== 'plain' then the mail won't be templated and the content under thecontentkey will be usedGET /reloadReloads all the template of the server without restarting the server.How to write a templateThis lib uses the Jinja2 template engine, so you can refer to the Jinja2 documentation for the syntax.There is however, one diffence, in an effort to be concise the subject and the body of each template are in the same file.So you have to put thesubjectof the email between this two balises: '' and ''The body of the email should then be between this two balises: '<mail_content>' and '</mail_content>'example :<subject>Docker | Backup Failed</subject><mail_content><body>{%from"common/centered_button.html"importcentered_button%}{%from"common/card.html"importcard%}{%callcard("La sauvegarde a échouée")%}<div style="white-space: pre-wrap">The backup failed at{{data.operation_date}}, if the problem persists, contact an administrator</div><br />{{centered_button("Example Incorporation","https://example.com")}}<br> Sysadmins{%endcall%}</body></mail_content>How to reuse componentsIn order to make a component reusable, you have to place it into the common directory, and you don't have to use the special  and <mail_content> balises.ConfigurationMost of the configuration is held in theconf.yamlfile.There are 2 things to configure, the template_provider and the emails senders:The infos for the template provider are located under thetemplateskey.Two providers are provided with the library, an S3 provider and a local provider.They can be used by using the string values 's3' or 'local'. You can see below an example of settings for both types.exemple :templates:# minio doesn't support the last optionss3:host:documents.staging.example.compass_key:passwordaccess_key:keybucket_name:mail-templateslocal:folder:templatesexemple :creds:example:type:gmailemail:example@example.comrefresh_token:<>client_id:<>client_secret:<>info:type:gmailemail:info@example.comrefresh_token:<>client_id:<>client_secret:<># note that here with smtp support it's not the same keysinfo2:type:smtpemail:info@example.compassword:<>server:<>server_port:<>How to get your tokens ?Activate your Gmail API keys in the Gmail consoleGet thecredentials.jsonfrom the Gmail consoleuse themake_token.pyscript from thegoogle_token_utilsfolder
Package: petit-python-publipost-connector
Python publipost connectorThis connector is meant to get used with thepetit_publipost_gatewayIt's a connector which can used in order to create a new publipost engineAs of now, it works using an HTTP interface, handled by an express server.It implements the required endpoints needed to work with thepetit_publipost_gatewayPOST /publipostPOST /get_placeholdersGET /listDELETE /remove_templatePOST /load_templatesGET /livePOST /configureIt is used by :petit_html_enginepetit_docx_engineIt exposes 2 things:make_connectorTemplateExample:# ...importioimportrefromtypingimportDict,List,Optionalimportpdfkitfromjinja2importTemplateasJinjaTemplatefrompetit_python_publipost_connectorimportTemplateasBaseTemplate,make_connectorlocal_funcs:List[str]=[]defextract_variable(var:str):"""Extracts variable and removes some stuff"""# remove the '(' and ')'# in the case values in {{data + "test"}}# we want to get the 'data' partr=var.split('+')r=[i.replace('(',"").replace(')',"").strip()foriinrif'"'notini]returnrdefget_placeholder(text:str,local_funcs:List[str])->List[str]:fornameinlocal_funcs:text=text.replace(name,'')# finding between {{ }}res:List[str]=re.findall(r"\{{(.*?)\}}",text,re.MULTILINE)# finding between {% %}res2=[]foriinres:res2.extend(extract_variable(i.strip()))returnres2classBytesIO(io.BytesIO):@staticmethoddefof(content:bytes):f=io.BytesIO()f.write(content)returnfclassTemplate(BaseTemplate):def__init__(self,_file:io.BytesIO):self.fields:List[str]=list()self.content=_file.getvalue().decode('utf-8')self.template=JinjaTemplate(self.content)self.__load_fields()def__load_fields(self):self.fields=fields=get_placeholder(self.content,local_funcs)returnfieldsdef__apply_template(self,data:Dict[str,str])->str:"""Applies the data to the template and returns a `Template`"""returnself.template.render(data)defrender(self,data:Dict[str,object],options:Optional[List[str]])->io.BytesIO:rendered=self.__apply_template(data)# if need pdf conversion# if options is not None and 'pdf' in options:ifTrue:# always true for nowrendered=pdfkit.from_string(rendered,output_path=False)returnBytesIO.of(rendered)app=make_connector(Template)
Package: petitRADTRANS
An easy-to-use Python package for calculating exoplanet spectraWelcome to the repository of petitRADTRANS, an easy-to-use code for the calculation of exoplanet spectra.
petitRADTRANS allows the calculation of emission or transmission spectra, at low or high resolution, clear or cloudy,
and includes a retrieval module to fit a petitRADTRANS model to your spectral data.DocumentationThe code documentation, installation guide, and tutorial can be found athttps://petitradtrans.readthedocs.io.AttributionIf you use petitRADTRANS in your work, please cite the petitRADTRANS
paper (Mollière et al. 2019).LicenseCopyright 2019-2023 Paul MollièrepetitRADTRANS is available under the MIT license.
See the LICENSE file for more information.
Package: petl
petlis a general purpose Python package for extracting, transforming and
loading tables of data.ResourcesDocumentation:http://petl.readthedocs.org/Mailing List:http://groups.google.com/group/python-etlSource Code:https://github.com/petl-developers/petlDownload:
- PyPI:http://pypi.python.org/pypi/petl- Conda Forge:https://anaconda.org/conda-forge/petlGetting HelpPlease feel free to ask questions via the mailing list
(python-etl@googlegroups.com).To report installation problems, bugs or any other issues please emailpython-etl@googlegroups.comorraise an issue on GitHub.
Package: petl-fwf
# petl_fwfThis package contains two additional methods which add the ability to read fixed-width files to the fabulous [petl package](https://github.com/petl-developers/petl).## fromfwfThis is the primary method which this package adds. Usage is straightforward, and similar to other methods in the petl library```sh>>> import fromfwf>>> # setup a sample file... text = '  18 5 2\\n2018 5 2\\n20180502'>>> with open('example.txt', 'w') as f:...    f.write(text)...28>>> table1 = etl.fromfwf('example.txt', widths=[4, 2, 2])>>> table1+--------+------+------+| lines  |      |      |+========+======+======+| '  18' | ' 5' | ' 2' |+--------+------+------+| '2018' | ' 5' | ' 2' |+--------+------+------+| '2018' | '05' | '02' |+--------+------+------+>>> # Specify headers for the file... table1 = etl.fromfwf('example.txt', widths=[4, 2, 2], header=['year', 'month', 'day'])>>> table1+--------+-------+------+| year   | month | day  |+========+=======+======+| '  18' | ' 5'  | ' 2' |+--------+-------+------+| '2018' | ' 5'  | ' 2' |+--------+-------+------+| '2018' | '05'  | '02' |+--------+-------+------+```## skiplastThis method will skip the last n rows of a table.```sh>>> import petl as etl>>> table1 = [['foo', 'bar'],...           ['a', 1],...           ['b', 2],...           ['c', 3],...           ['FOOTER ROW']]>>> table2 = etl.skiplast(table1, 1)>>> table2+-----+-----+| foo | bar |+=====+=====+| 'a' |   1 |+-----+-----+| 'b' |   2 |+-----+-----+| 'c' |   3 |+-----+-----+```
Package: petljadoc
PetljaDoc - Petlja's tool for eLearning contentThe tool is based onhttps://github.com/RunestoneInteractive/RunestoneComponentsandhttps://github.com/sphinx-doc/sphinxand includes:additional Sphinx extensionspartial Pygame implementation for Sculpt (https://github.com/Petlja/pygame4skulpt)additional ActiveCode featurescustomized Sphinx themecustomized project templateexteded online course formatpetljadoccommand line interface (CLI)PetljaDoc currently depends on forked RunestoneComonents, but we are gradually closing the gap with the upstream repository through pull requests.InstallationUsepiptoinstallPetljaDoc:pip3 install petljadocIf you use Windows and previous command does not work, try:py -3 -m pip install petljadocCLI usagepetljadoc [OPTIONS] COMMAND [ARGS]...Options:--helpShow help messageCommands:init-courseCreate a new online course project in your current directoryinit-runestoneCreate a new Runestone project in your current directorypreviewBuild the project, open it in a web browser, watch for changes, rebuild changed files and refresh browser after rebuild (usingsphinx-autobuild)publishBuild the project and copy produced content indocssubfolder (ready to be published using GitHub Pages)exportBuilds the project and exports its content as a SCORM package. You can select one of the 3 options with will deliver you diffrent type of packages:single: A single SCO (Shareable Content Object) SCORM package, which contains all course content in a single filemulti: A multi SCO SCORM package, which breaks the course content into multiple modules or unitsproxy: A proxy SCORM package, that can be used with a Learning Management System (LMS) and an additional Moodle backup file. This option requires you to upload your course files to a web server and provide a link to the packager viapackage-conf.json. We recommend to upload your course files to a web server like GitHub Pages, which allows you to host static web content for free. You can create a new repository for your course files and enable GitHub Pages to generate a website URL for your repository. Then, you can updatepackage-conf.jsonto include the GitHub Pages URL as thedata_content_urlproperty.By usingpetljadoc preview, an author may keep opened a browser window for preview. Any saved changes will be updated in browser in about 5-10 seconds.petljadoc publishcommand helps an author to share a public preview of his work via GitHub Pages.
Package: petl-retouched-version
NOTE: THIS IS MODIFIED REPLICA OF THE ORIGINAL PETL LIBRARY
DIFFERENCE: IT INCOPERATES THE USE OF COPY COMMAND FOR DB-API 2.0 CONNECTIONSpetlis a general purpose Python package for extracting, transforming and
loading tables of data.ResourcesDocumentation:http://petl.readthedocs.org/Mailing List:http://groups.google.com/group/python-etlSource Code:https://github.com/petl-developers/petlDownload:
- PyPI:http://pypi.python.org/pypi/petl- Conda Forge:https://anaconda.org/conda-forge/petlGetting HelpPlease feel free to ask questions via the mailing list
(python-etl@googlegroups.com).To report installation problems, bugs or any other issues please emailpython-etl@googlegroups.comorraise an issue on GitHub.
Package: petlx
petlxis a collection of domain-specific and/or experimental extensions topetl, a Python package for extracting,
transforming and loading tables of data.Docs:http://petlx.readthedocs.org/Source:https://github.com/alimanfoo/petlxDownload:http://pypi.python.org/pypi/petlxMailing list:http://groups.google.com/group/python-etl
Package: pet-pet-gif
pet-pet-gifPython adaptation ofhttps://github.com/aDu/pet-pet-gifUsage:frompetpetgifimportpetpetpetpet.make(source,dest)source:  A filename (string), pathlib.Path object or a file object. (This parameter corresponds
and is passed to the PIL.Image.open() method.)dest: A filename (string), pathlib.Path object or a file object. (This parameter corresponds
and is passed to the PIL.Image.save() method.)Basic example:frompetpetgifimportpetpetpetpet.make('test.png','out.gif')Discord.py example:importosimportdiscordfromdiscord.extimportcommandsfromdotenvimportload_dotenvfromioimportBytesIOfromtypingimportUnion,Optionalfrompetpetgifimportpetpetaspetpetgifload_dotenv()token=os.getenv('DISCORD_BOT_TOKEN')client=commands.Bot(command_prefix='!')@client.eventasyncdefon_ready():print('Bot is ready.')@client.command()asyncdefpet(ctx,image:Optional[Union[discord.PartialEmoji,discord.member.Member]]):iftype(image)==discord.PartialEmoji:image=awaitimage.url_as(format='png').read()# retrieve the image byteseliftype(image)==discord.member.Member:image=awaitimage.avatar_url_as(format='png').read()# retrieve the image byteselse:awaitctx.reply('Please use a custom emoji or tag a member to petpet their avatar.')returnsource=BytesIO(image)# file-like container to hold the emoji in memorydest=BytesIO()# container to store the petpet gif in memorypetpetgif.make(source,dest)dest.seek(0)# set the file pointer back to the beginning so it doesn't upload a blank file.awaitctx.send(file=discord.File(dest,filename=f"{image[0]}-petpet.gif"))client.run(token)
Package: petrabytesunitconverter
This python libraries to do all the unit conversion. It usses the Python PINT library and adds additional feature of unit conversion which is useful for OIL & GAS Logs calculation.Change Log0.0.1 (31/08/2021)First Release0.0.2 (31/08/2021)Second ReleaseUsageImporting the library$  import petrabytes-unitsconverterExample:$ petrabytesunitconverter.unit_convert(5,”meter”,”centimeter”,false)
$ 500
Package: petra-camera
General info:This utility allows displaying images from 2d Tango detectors and to do simple analysis.Right now TangoTine (LM screens) and Vimba cameras are supported.Full instruction can be found here:https://confluence.desy.de/display/FSP23/Camera+viewerLogs are stored in the ~/.petra_camera folderIf you wnat logs to be printed in terminal windows add --log optionAdd new camera:The camera configuration is stored in the ~/.petra_camera folderBy default the default.xml is loadingIf you want to force another config add -p or --profile option with file nameThis is example of minimum entry to add camera:<cameraname="LM05"proxy="LMScreen"tango_server="hasep23oh:10000/hasylab/p23_lm5/output"/><cameraname="Microscope"proxy="TangoVimba"tango_server="hasep23oh:10000/p23/tangovimba/micro"/>proxycan be 'VimbaProxy" or "LMScreen", "LambdaProxy"  or "DummyProxy"tango_serveris the image source serverIf you want a 12 bit mode of Vimba camera:high_depth= 'True'If you want a RGB mode of Vimba camera:color= 'True'In case you have an associated LMAnalysis server you can add it by:roi_server="hasep23oh:10000/p23/lmanalysis/lm5"In case there is an motor to insert/remove screen it can be specified by:For FSBT motor (you need to have FSBT valve control server running):motor_type='FSBT'
motor_host='hasep23swt01'
motor_port='12658'
motor_name='LM5'For Acromag:motor_type='Acromag'valve_tango_server="p22/acromagxt1121/ch1.02"valve_channel="2"In case of you need to flip/rotate image (in 90 deg terms):flip_vertical="True"
flip_horizontal="True"
rotate='2'Here is an example of TTGW camera, with associated settings, lmanalysis server, driven by FSBT motor which picture need to be vertically flipped:<cameraname="LM05"proxy="LMScreen"tango_server="hasep23oh:10000/p23/tinecamera/lm5"roi_server ="hasep23oh:10000/p23/lmanalysis/lm5"widget="CameraSettingsWidget"motor_type ='FSBT'motor_host ='hasep23web'motor_port ='12658'motor_name ='LM5'/>Here is an example of TangoVimba camera, running at 12 bit bw mode, with associated Acromag motor, which picture need to be 90 deg rotated:<cameraname="Microscope"proxy="VimbaProxy"tango_server="hasep23oh:10000/p23/tangovimba/micro"high_depth="True"motor_type ='Acromag'valve_tango_server ="p23/acromagxt1121/ch1.01"valve_channel="2"motor_host ='hasep23dev'rotate ='1'/>
Package: petra-grid
petra_gridpetra_gridis a Python library for reading grid data in the.GRDfile
format produced by the Petra™ geological interpretation applicationpetra_gridis implemented as a set of bindings to thecorresponding Rust
crateThis library is based on a lot of time spent in a hex editor looking at
grid files and poring over publicly-available documentation. It is by necessity
incomplete and incorrect, and will remain so until the file format is properly
and publicly specified.However, the library is able to successfully read rectangular and triangulated
grids and a good portion of their metadata. Please open an issue if you have
trouble reading a grid and are able to share the grid (in GRD and exported form)
with the developer.Example usageThis library can be used to read.GRDgrid data from a file or file-like
object.  Here's a short program for dumping "debug" representations of grid
files provided on the command line:importsysimportpetra_griddefmain(argv:list[str])->int:iflen(argv)<=1:print(f'Usage:{argv[0]ifargvelse"read_grid"}<grd-files>',file=sys.stderr)return2forpathinargv[1:]:withopen(path,'rb')asf:grid=petra_grid.read_grid(f)ifgrid.is_rectangular:print(f'{grid.name}:{grid.rows}x{grid.columns}rectangular grid')elifgrid.is_triangular:print(f'{grid.name}:{grid.n_triangles}-triangle triangular grid')print(f'Details:{grid}')return0if__name__=='__main__':sys.exit(main(sys.argv))As another example, we can usematplotlibto render images of rectangular or
triangular grids.importsysimportpetra_gridimportnumpyasnpfrommatplotlib.triimportTriangulation# type: ignoreimportmatplotlib.pyplotasplt# type: ignoredefplot_rectangular(grid:petra_grid.Grid)->None:plt.imshow(grid.data,extent=(grid.xmin,grid.xmax,grid.ymin,grid.ymax),origin='lower')plt.title(f'{grid.name}')plt.colorbar()plt.show()defplot_triangular(grid:petra_grid.Grid)->None:triangles=grid.dataxs=np.ravel(triangles[:,:,0])ys=np.ravel(triangles[:,:,1])ixs=np.reshape(np.indices(xs.shape)[0],(triangles.shape[0],3))triangulation=Triangulation(xs,ys,ixs)zs=np.ravel(triangles[:,:,2])fig,ax=plt.subplots()ax.set_aspect('equal')tc=ax.tripcolor(triangulation,zs)ax.set_title(f'{grid.name}')fig.colorbar(tc)plt.show()defmain(argv:list[str])->int:iflen(argv)<=1:print(f'Usage:{argv[0]ifargvelse"render_grid"}<grd-files>',file=sys.stderr)return2forpathinargv[1:]:withopen(path,'rb')asf:grid=petra_grid.read_grid(f)ifgrid.is_rectangular:plot_rectangular(grid)elifgrid.is_triangular:plot_triangular(grid)print(f'Details:{grid}')return0if__name__=='__main__':sys.exit(main(sys.argv))DocumentationDocumentation strings and type annotations are provided for all public types,
functions, and methods. We recommend viewing "nice" documentation pages usingpdoc; e.g. in the same environment as thepetra_gridpackage is installed, installpdocwithpip install pdoc, then
runpdoc petra_grid.Available under theMIT license(c) 2023dwt|terminus, LLC
Package: petrel
PetrelTools for writing, submitting, debugging, and monitoring Storm topologies in pure Python.OverviewPetrel offers some important improvements over the storm.py module provided with Storm:Topologies are implemented in 100% PythonPetrel’s packaging support automatically sets up a Python virtual environment for your topology and makes it easy to install additional Python packages.“petrel.mock” allows testing of single components or single chains of related components.Petrel automatically sets up logging for every spout or bolt and logs a stack trace on unhandled errors.