Saravanan666/pypi-org huggingface dataset:
Package: safedexml
dexml:  a dead-simple Object-XML mapper for Python==================================================Let's face it: xml is a fact of modern life.  I'd even go so far as to saythat it's *good* at what is does.  But that doesn't mean it's easy to workwith and it doesn't mean that we have to like it.  Most of the time, XMLjust needs to get out of the way and let you do some actual work insteadof writing code to traverse and manipulate yet another DOM.The dexml module takes the obvious mapping between XML tags and Python objectsand lets you capture that as cleanly as possible.  Loosely inspired by Django'sORM, you write simple class definitions to define the expected structure ofyour XML document.  Like so::>>> import dexml>>> from dexml import fields>>> class Person(dexml.Model):...   name = fields.String()...   age = fields.Integer(tagname='age')Then you can parse an XML document into an object like this::>>> p = Person.parse("<Person name='Foo McBar'><age>42</age></Person>")>>> p.nameu'Foo McBar'>>> p.age42And you can render an object into an XML document like this::>>> p = Person(name="Handsome B. Wonderful",age=36)>>> p.render()'<?xml version="1.0" ?><Person name="Handsome B. Wonderful"><age>36</age></Person>'Malformed documents will raise a ParseError::>>> p = Person.parse("<Person><age>92</age></Person>")Traceback (most recent call last):...ParseError: required field not found: 'name'Of course, it gets more interesting when you nest Model definitions, like this::>>> class Group(dexml.Model):...   name = fields.String(attrname="name")...   members = fields.List(Person)...>>> g = Group(name="Monty Python")>>> g.members.append(Person(name="John Cleese",age=69))>>> g.members.append(Person(name="Terry Jones",age=67))>>> g.render(fragment=True)'<Group name="Monty Python"><Person name="John Cleese"><age>69</age></Person><Person name="Terry Jones"><age>67</age></Person></Group>'There's support for XML namespaces, default field values, case-insensitiveparsing, and more fun stuff.  Check out the documentation on the followingclasses for more details::Model:  the base class for objects that map into XML:Field:  the base class for individual model fields:Meta:   meta-information about how to parse/render a model
Package: safe-ds
Safe-DS Python LibraryA user-friendly library for Data Science (DS) in Python.Our goal is to make DS more accessible to a wider audience by providing a simple, intuitive, and consistent API to solve common tasks on small to moderately sized datasets. As such, a major focus is to provide a learning tool for DS novices.Instead of implementing DS methods from scratch, we use established DS libraries under the hood such as:pandasfor manipulation of tabular data,scikit-learnfor machine learning, andseabornfor visualization.For more specialized tasks, we recommend using these or other DS libraries directly.Note that this library is still in development and not yet ready for production. Expect breaking changes in the future without a major version bump (while in the0.y.zversion range). Feedback is very welcome, however! If you have a suggestion or find a bug, pleaseopen an issue. If you have a question, pleaseuse our discussion forum.InstallationGet the latest version fromPyPI:pipinstallsafe-dsDocumentationYou can find the full documentationhere.ContributingWe welcome contributions from everyone. As a starting point, check the following resources:Setting up a development environmentProject guidelinesContributing pageIf you need further help, pleaseuse our discussion forum.
Package: safe-ds-examples
Safe-DS Python Library - ExamplesReady-to-use examples for theSafe-DS Python Library.InstallationGet the latest version fromPyPI:pipinstallsafe-ds-examplesDocumentationYou can find the full documentationhere.ContributingWe welcome contributions from everyone. As a starting point, check the following resources:Setting up a development environmentProject guidelinesContributing pageIf you need further help, pleaseuse our discussion forum.
Package: safe-ds-runner
Safe-DS RunnerExecute Safe-DS programs that were compiled to Python.InstallationGet the latest version fromPyPI:pipinstallsafe-ds-runnerUsageStart the runner server:safe-ds-runnerstartDocumentationYou can find the full documentationhere.ContributingWe welcome contributions from everyone. As a starting point, check the following resources:Setting up a development environmentProject guidelinesContributing pageIf you need further help, pleaseuse our discussion forum.
Package: safe-environ
Safe EnvironSafely integrate environment variablesStatusSourceShieldsProjectPublishersDownloadsRaisedInstallingTo install the package from pypi:pipinstallsafe_environAlternatively, you can clone the repo and build the package locally.DocsAdditional details are available in thefull documentation.To generate the documentation locally:multi-jobdocsTestsUnit tests and behaviour tests are written with the pytest framework.To run tests:multi-jobtestsAdditionally, an html report will be saved to the local directory.ContributingPlease readCONTRIBUTING.mdfor details on our code of conduct, and the process for submitting pull requests.VersioningSemVeris used for versioning. For a list of versions available, see the tags on this repository.Bump2version is used to version and tag changes.
For example:bump2versionpatchReleases are made on every major change.AuthorJoel Lefkowitz-Initial work-Joel LefkowitzSee also the list of contributors who participated in this project.LicenseThis project is licensed under the MIT License - see theLICENSE.mdfile for detailsAcknowledgmentsNone yet!
Package: safeeval
safeevalSafely evaluate an expression from an untrusted partyGetting StartedSimply install via pip:pip install safeevalPrerequisitesNo dependencies are required.ExampleSimple Comparision:import safeeval
ast = safeeval.SafeEval.parse("x == y")
res = safeeval.SafeEval.evalAst(ast, {"x": 4, "y": 3)
print("res", res)More examples can be found in tests directory.ContributingWrite issues and provide patches via PRs on github.AuthorsTobias Steinrücken-Initial work-Mausbrand Informationsysteme GmbHStefan Kögl-Packaging, callable support, docstrings-Mausbrand Informationsysteme GmbHSee also the list ofcontributorswho participated in this project.LicenseThis project is licensed under the MIT License - see theLICENSEfile for details
Package: safeexecute
SafeExecuteThis module provides a safe way to execute Python code in a container. It is intended to be used with language models to enable them to execute code in a safe environment separate from the host machine (your computer or server).The container comes preloaded with the following packages:numpymatplotlibseabornscikit-learnyfinancescipystatsmodelssympybokehplotlydashnetworkxpyvispandasInstallationpipinstallsafeexecuteUsageYou can pass an entire message from a langauge model into thecodefield and it will parse out any Python code blocks and execute them.  If anywhere in thecodesayspip install <package>, it will install the package in the container before executing the code.fromsafeexecuteimportexecute_python_codecode="print('Hello, World!')"result=execute_python_code(code=code)print(result)
Package: safe-exit
Safe Exit is a Python package that provides functionality to handle graceful process termination.
The package allows users to register functions that will be called when the program exits.Difference from atexitPython has a standard module calledatexitthat does something similar,
butatexitcannot handle cases where a program is killed by a signal not handled by Python.Python only handles the SIGINT signal and does not handle SIGTERM, SIGQUIT, and SIGHUP signals.
On Windows, programs can also be killed by SIGBREAK and CTRL_CLOSE_EVENT.Safe Exit can handle all these signals:On POSIX systems:SIGINT,SIGTERM,SIGQUIT, andSIGHUPOn Windows:SIGINT,SIGTERM,SIGBREAKCTRL_CLOSE_EVENT,CTRL_LOGOFF_EVENT,CTRL_SHUTDOWN_EVENTWindows also hasCTRL_C_EVENTandCTRL_BREAK_EVENTwhich Python translate toSIGINTandSIGBREAKsignals, respectively.
On windows,SIGTERMis implemented only  for the current process,
there is no way to sendSIGTERMto other processes.InstallationTo install Safe Exit, simply run:pipinstallsafe-exitUsageJust register a cleanup function like you would withatexit:importsafe_exitdefcleanup_function():# Perform cleanup taskssafe_exit.register(cleanup_function)Theregisterfunction can also be used as a decorator:@safe_exit.registerdefcleanup_function():# Perform cleanup tasksSignal handling is configurable.
Call theconfigfunction before registering functions.
The following code configuressafe_exitto handle SIGQUIT and SIGHUP signals:fromsafe_exitimportConfigFlag,config,registerconfig(ConfigFlag.SIGQUIT|ConfigFlag.SIGHUP)@registerdefcleanup()print("clean up")To nicely kill a process, giving it a chance to clean up:process_id=...safe_exit.safe_kill(process_pid)ContributingContributions to Safe Exit are welcome!
If you would like to contribute or have any ideas for improvements,
please feel free to open an issue on the project’s issue tracker
or get in touch with the maintainer directly.LicenseSafe Exit is released under the MIT License. See the LICENSE.txt file for more details.
Package: safefilesystem
SafeFSA Python module for safely working with the file system in a safe, auditable way.(2021/08/05) CURRENTLY UNDER DEVELOPMENT. THIS VERSION IS HOLDING THE NAME ON PYPI.InstallationTo install with pip, run:pip install safefsQuickstart GuideTODO - fill this in laterContributeIf you'd like to contribute to SafeFS, check outhttps://github.com/asweigart/safefs
Package: safefunc
safefuncImportantYou may want to use the newer libraryfnsafe.Make sudden erros not stop your programInstallationpip install safefuncfromsafefuncimportmakesafeBasic Example@makesafe()defdivide(a,b):returna/bprint("Let's calculate!")result=divide(1,0)print(f"{result= }")Output:Let's calculate!
Ignoring exception in divide
Traceback (most recent call last):
  File "<string>", line 40, in safe
  File "<string>", line 75, in divide
ZeroDivisionError: division by zero
result = NoneAs you can see, the exception gets printed but
the program continues.More ExamplesLet's try the same thing withdivide(1, 1):Output:Let's calculate!
result = 1Now everything worked fine.Some functions may returnNone. If an error
happens, it would also returnNone. Luckily
we can differate between success and failure
with thereturn_entire_resultparamter:@makesafe(return_entire_result=True)defdivide(a,b):returna/bprint("Let's calculate!")result=divide(1,0)ifresult:# or result.successprint(result())# or result.resultIn this case our function returns aResultobject which allows us to check wether the
function succeeded or not. Theresultattribute (which also can be accessed by
calling the object) returns depending on the
success, the function return value or the
exception.Let's expect, we calldivide("1", 1). Because
the first argument is not supported for
division, it would raise an error. If we only want
to ignoreZeroDivisionErrors, we can make use of
theignoreparameter. You can interpret this as
a whitelist:@makesafe(return_entire_result=True,ignore=[ZeroDivisionError])defdivide(a,b):returna/bprint("Let's calculate!")result=divide("1",1)ifresult:print(result())This will raise any error that occures exceptZeroDivisionError.We can also reverse the situation and ignore
any exception exceptZeroDivisionErrorby
setting theraise_whenparameter. You can
understand this as a blacklist:@makesafe(return_entire_result=True,raise_when=[ZeroDivisionError])defdivide(a,b):returna/bprint("Let's calculate!")result=divide("1",1)ifresult:print(result())Keep in mind that you can not set bothignoreandraise_when. If you do
so, a TypeError gets raised.Other Parametersquietrefrains displaying the exceptiontype: booldefault: Falsetitletext that gets displayed above the exceptiontype: strdefault: "Ignoring exception in {function.__name__}"coloreddisplays the exception in a darker color;
may not work on every device / console;
should not be used when using a file for the outputtype: booldefault: Falsefilea file or file-like object where the ouput gets written totype: typing.TextIOdefault: sys.stderrinspired by discord.pyTipsIn case you want to justruna function safely
instead of directlymakingit safe, you can
include this function:fromsafefuncimportmakesafedefrunsafe(function,*args,**kwargs):returnmakesafe(*args,**kwargs)(function)
Package: safegate-pro
Open source Safegate Pro automation that puts local control and privacy first. Powered by a worldwide community of tinkerers and DIY enthusiasts. Perfect to run on a Raspberry Pi or a local server.Check outhome-assistant.iofora
demo,installation instructions,tutorialsanddocumentation.Featured integrationsThe system is built using a modular approach so support for other devices or actions can be implemented easily. See also thesection on architectureand thesection on creating your own
components.If you run into issues while using Safegate Pro or during development
of a component, check theSafegate Pro help sectionof our website for further help and information.
Package: safe-geonode
safe-geonodeSAFE - GeoNode plugin.http://inasafe.org/http://geonode.org/INSTALLATIONThese are the instructions for installation of Risiko in development mode (for changing the software) and production mode (for deploying on a server).Install safe-geonode:sudo add-apt-repository ppa:geonode/unstable
sudo apt-get update
sudo apt-get install geonode
source /var/lib/geonode/bin/activate
pip install safe-geonodeModify your INSTALLED_APPS to include safe_geonode:INSTALLED_APPS += ('safe_geonode', 'leaflet',)Add an entry for geonode_safe in your urls.py:urlpatters += ((r'^safe/', include('safe_geonode.urls'),)Copy the missing static files, create the new tables in the database and reload the apache web server:sudo geonode collectstatic
sudo geonode syncdb
sudo service apache2 reloadIf you need sample data, get it from the inasafe_data repository:git clone https://github.com/AIFDR/inasafe_data.gitAnd load it usingsafeimportlayers:geonode safeimportlayers inasafe_data/hazard
geonode safeimportlayers inasafe_data/exposureFinally, navigate to the safe interface to try it out:http://localhost/safeLIMITATIONSsafe-geonode is a very new project.
However, we work on the philosophy that stakeholders should have access to the development and source code from the very beginning and invite comments, suggestions and contributions.As such, safe-geonode currently has some major limitations, includingAll data must be provided in WGS84 geographic coordinatesNeither AIFDR nor GFDRR take any responsibility for the correctness of outputs from safe-geonode or decisions derived as a consequence
Package: safeguardcredentialtype
Safeguard Credential Type plugin for AnsibleWhat is the Safeguard Credential Type plugin?The Safeguard Credential Type plugin is a plugin that is installed and used by the AWX web interface to fetch credentials from Safeguard for Privileged Passwords (SPP). Once installed, a new credential type plugin will appear in the drop-own listResources>Credentials>Create New Credentialpage. A Safeguard Credential type can be used to fetch a credential from SPP by configuring the following values:Safeguard Credential API key- The API key is generated by SPP when an A2A registration is created. The API key identifies a specific credential which can be fetched by a third-party application from SPP through the A2A interface.Safeguard Appliance IP or Host name- The IP address or host name of the SPP appliance.Safeguard client certificate file path- The full path to the user authentication certificate (PEM format).Safeguard client key file path- The full path to the user authentication private key (PEM format). NOTE: It is the responsibility of the Ansible administrator to make sure that the private key is stored in a safe location and can only be read by Ansible.Safeguard TLS certificate file path(optional) - The full path to the TLS public certificate that is associated with the SPP appliance. If this certificate path is not provided, the lookup plugin will disable TLS validation which may produce a warning.Safeguard credential type to retrieve(optional) - Specify the credential type to retrieve from SPP. The options arepassword(default) orprivatekey.To fetch a credential from SPP, an A2A registration must have been created in SPP. For more information about how to create an A2A registration, please see the Safeguard for Privileged Passwords Administration Guide for your version of SPP (https://support.oneidentity.com/technical-documents).InstallationThe installation of the Safeguard Credential Type plugin must be done on the server that is running the Ansible Automation Platform web interface. The plugin is available from the PyPI repository athttps://pypi.org/project/safeguardcredentialtype/and can be install by running the following commands:> sudo awx-python -m pip install safeguardcredentialtype
> sudo awx-manage setup_managed_credential_types
> sudo automation-controller-service restart
Package: safegym
SafeGymImplementation of satellite environments and other environments to explore SafeRLSafeGymSafeGym is a Gymnasium environment coupled with tools aimed at facilitating Safe Reinforcement Learning (SafeRL) research and development.FeaturesCustomizable Environment: Create a variety of satellite chasing scenarios with customizable starting states and noise.Underactuated and Fully Actuated Dynamics: Simulate real-world control dynamics with options for both underactuated and fully actuated control systems.Reward Shaping: Built-in reward shaping functionality to guide the learning process towards safe and effective solutions.Truncation and Termination: Control the episode flow with truncation and termination conditions to manage the agent's learning experience.Visualization Tools: Render the environment and visualize the agent's interactions and performance over time.Testing Utilities: Validate the environment and control algorithms with a set of provided testing functions.Getting StartedClone the repository to your local machine:gitclonehttps://github.com/spbisc97/SafeGym.gitcdSafeGymEnsure you have the necessary dependencies installed. The primary dependencies include:gymnasiumnumpymatplotlibUsageInstallpipinstall-e.Run a simple experimentimportsafegymimportgymnasiumasgymenv=gym.make('Satellite-SE',render_mode="human")observation,info=env.reset()DONE=FalsewhilenotDONEaction=env.action_space.sample()observation,reward,term,trunc,info=env.step(action)DONE=termortruncenv.close()
Package: safehaven
![https://www.gnu.org/licenses/gpl-3.0](https://img.shields.io/badge/License-GPL%20v3-blue.svg“GPL-3.0”)
# safehaven## Description
This library allows users to list, upload and download objects to and from the following cloud providers:Amazon Web Services (AWS S3)Microsoft Azure (Blob Store)Google Cloud Platform (GCP Storage)## Usage
### Installation` pip install safehaven `### AWS` from safehaven import Aws s3 = Aws()s3.create_client('s3-shared-object-store-test','file_names', 'region', 'aws_access_key_id', 'aws_secret_access_key') s3.list_objects() s3.upload_objects() s3.download_objects() `### Azure` from safehaven import Azure blob = Azure()blob.create_client('container_name','file_names', 'connection_string') blob.list_objects() blob.upload_objects() blob.download_objects() `### GCP` from safehaven import Gcp gcp = Gcp()gcp.create_client('project_name''storage_bucket_name', 'location_and_name_of_files', 'key_file') gcp.list_objects() gcp.upload_objects() gcp.download_objects() `### Testing this library` pip install moto python3 ~/safehaven/tests/test_safehaven.py `## Links
* Code:https://github.com/tzankov/safehaven* Releases on Pypi:https://pypi.org/project/safehaven
Package: safeint
Construct integer within a given range to prevent DoS attacks.Pulling data from the Internet and feeding it to Python’s builtin int function exposes you to a potential DoS attack. Python supports arbitrary precision integers. Unlike other languages like C++, Java or even Javascript which will eventually overflow, Python can represent any number you have the memory to store. For instance, in the following code:s = '9' * 1000000  # Generate a string with one million 9s
i = int(s)Python keeps on going and will stuff 10^1000000 - 1 into i after 7 seconds of CPU work and 400kb of RAM. 7 seconds during which your gevent based web server cannot perform a context switch and service other requests. A single machine running a few hundred greenlets on a cable modem would be enough to cripple a web server with APIs that accepts integers.safeint.int is a drop-in replacement for int to help parse untrusted data coming from the Internet. You use it like this:import safeint


def my_controller():
    foo = safeint.int(bottle.request.query.foo)By default safeint.int will raise a ValueError if your input string is too long.  The default is 10 digits, but you can raise or lower that as your application requires with the keyword parameter digits. So for example, safeint.int(foo, digits=2) limits you to numbers in the range -9 to 99 inclusive.safeint.int also supports a few extra parameters and features beyond what int normally supports. If you pass it None or an empty string it returns None, saving you from the hassle of writing code that looks like this:if bottle.request.query.foo is None:
    foo = None
else:
    foo = int(bottle.request.query.foo)Instead you can write this:import safeint


foo = safe.int(bottle.request.query.foo)safe.int also has some syntactic sugar to save time when enforcing bounds.   Instead of writing this:import safeint


foo = safeint.int(bottle.request.query.foo)
if foo > high:
    raise ValueError(...)
elif foo < low:
    raise ValueError(...)you can just write this:import safeint


foo = safeint.int(bottle.request.query.foo, low=low, high=high)DevelopmentBug reports and pull requests welcome!AcknowledgmentsPelotonfor supporting open source!Dan Sokolsky and Adam DePrince for implementing this solution!
Package: safelogging
A simple python library that adds some additional logging functionality on top
of the standard python logging library that could be useful for python
applications running as background services in a UNIX system.One of the main functionalities it provides is aResilientSysLogHandlerclass that is a drop-in replacement oflogging.handlers.SysLogHandlerand
is able to gracefully handle any connection issues to the syslog server while
falling back to file stream logging to avoid any loss of messages.
Package: safely
SafelyCapture side effects, safely ⚔️InstallationpipinstallsafelyUsageAs a function (without second-order arguments):deff(...):...result=safely(f)(...)As a function (with second-order arguments):deff(...):...result=safely(f,logger=logger.error,message="{exc_type}:{exc_value}")(...)As a decorator (without second-order arguments):@safelydeff(...):...result=f(...)As a decorator (with second-order arguments):@safely(logger=logger.error,message="{exc_type}:{exc_value}")deff(...):...result=f(...)