Saravanan666/pypi-org huggingface dataset:
Package: safemodels
safemodelsCryptographically-secure proof-of-concept for verifying the provenance of ML models.This library is a thought experiment into what securing the supply chain of ML models could look like. It's built on top ofsafetensors. You should probably readthe blog postfor more context!Installation$pipinstallsafemodelsUsageHashingfromsafemodelsimportsafe_hashfromhuggingface_hubimporthf_hub_downloadasdlst=dl("gpt2",filename="model.safetensors")pt=dl("gpt2",filename="pytorch_model.bin")assertsafe_hash(st)==safe_hash(pt)=='d6c60a3126ef088e5f8fdaa332da56d552da966a'SigningfromsafemodelsimportSafeModelfromhuggingface_hubimporthf_hub_downloadasdlst=dl("gpt2",filename="model.safetensors")sm=SafeModel.from_safetensor(st)# orst,sm=SafeModel.from_hf("gpt2",version="main")sm.sign_safetensor(st)# backwards-compatible rewrite of fileVerification>>>fromsafemodelsimportinit,Issuer>>>fromhuggingface_hubimporthf_hub_download>>>>>>init(Issuer(identity="EleutherAI",issuer="https://auth.huggingface.com")>>>>>>hf_hub_download("EleuterAI/gpt-j-6B",filename="model.safetensors")Downloading model.safetensors: 100%|███| 548M/548M [00:14<00:00, 39.2MB/s]211it [00:00, 4785.46it/s]Error: none of the expected identities matched what was in the certificate, got subjects [EleuterAI] with issuer https://auth.huggingface.comTraceback (most recent call last):...safemodels.InvalidSignature:Loaded a safetensor with an invalid signature!safetensorMetadatafromsafemodels.utils.safetensorsimportextract_metadata,update_metafromhuggingface_hubimporthf_hub_downloadasdlst=dl("gpt2",filename="model.safetensors")print(extract_metadata(st))# {'format': 'pt'}update_meta(st,{"hello":"world"})print(extract_metadata(st))# {'format': 'pt', 'hello': 'world'}
Package: safemount
# safemountWe have to jump through multiple hoops in shell scripts to ensure that our
scripts handle special characters such as space, hyphen etc. properly. A number
of security vulnerabilities exist because of mishandling of these characters.However, these special characters, while important for GUI are not a necessity
for command line. The idea of this library is to provide a FUSE filesystem that
mounts a given directory under a mount point such that all the special
characters are URL encoded. We include-in the list of characters that are
encoded. Further, we also remove.and..from the directory listing.With this, the shell scripts can assume that none of the directory
or file names contain special characters.The usage is as follows:` python3-mpip install fusepy python3-msafemount ./mydir ./mntpoint `See also:
1.https://dwheeler.com/essays/filenames-in-shell.html2.https://dwheeler.com/essays/fixing-unix-linux-filenames.html3.https://lwn.net/Articles/325304/4.https://lwn.net/Articles/686789/
Package: safenet
safenet----Build Status master:|Linux/OS X|Windows|Docs||:--------:|:-----:|:----:||[![Build Status](https://travis-ci.org/rid-dim/pySafe.svg?branch=master)](https://travis-ci.org/rid-dim/pySafe?branch=master)|[![Build status](https://ci.appveyor.com/api/projects/status/qyx4b75u9mxrla1g/branch/master?svg=true)](https://ci.appveyor.com/project/rid-dim/pysafe/branch/master)|[![docs](https://readthedocs.org/projects/pysafe/badge/?version=master)](http://pysafe.readthedocs.io/en/master)|Build Status dev:|Linux/OS X|Windows|Docs||:--------:|:-----:|:----:||[![Build Status](https://travis-ci.org/rid-dim/pySafe.svg?branch=dev)](https://travis-ci.org/rid-dim/pySafe?branch=dev)|[![Build status](https://ci.appveyor.com/api/projects/status/qyx4b75u9mxrla1g/branch/dev?svg=true)](https://ci.appveyor.com/project/rid-dim/pysafe/branch/dev)|[![docs](https://readthedocs.org/projects/pysafe/badge/?version=dev)](http://pysafe.readthedocs.io/en/dev)|A Python interface for the C FFI API of the SAFE Network (www.maidsafe.net)---contributors: rid-dim, duncankushnirThe design goal of pySafe is to provide a full python interface to SAFE network, via the SAFE binaries.The package (will) include an importable and installable module, as well as utilities to generate the bindings and hopefully eventually some example applications beyond 'hello world'.Designed to be minimally dependent, however the following modules are not included in the base python install:-cffi, py-cid, multihashWe use features that currently require python 3.6+ . With enough interest, we could probably back port it, but this will depend on our chosen asynchronous implementation.Under heavy development - so please don't criticize but just open a pull request ;)Installing into an environment---First, clone the repo.  We are currently working to find an acceptable PyPi name to enable pip/easy install- On linux, running upg_local.sh will pip update your local environment to the current pySafe state (any python prog can import pySafe, sym-linked to the development directory):- sh ./upg_local.sh- On Windows: upg_local.bat (we now feature Windows compatibility)- On Mac: well, the way localization is coded should work, but we need someone to compile the binaries on mac and test!Contributing----If you want to help us and work together with us on this project you can just join [our telegram channel](https://t.me/pySafe) or [get in touch with us in the dev forum](https://forum.safedev.org/) or you just open a pull request / contact us on github :)The more people get involved, the easier it is to utilize safe and the more powerful this library gets the better for freedom of humanity =) Together we work on creating a peoples internet where everybody wins and access to knowledge and freedom of speech are no privileges but universal rights of every human.
Package: safe-netrc
Safe NetrcThis package provides a subclass of the Python standard librarynetrc.netrcclassto add some
custom behaviors.If theNETRCenvironment variable is defined, then use it as
the default netrc file path.Backport permissions checks that were added in Python 3.1
(seehttps://bugs.python.org/issue14984).Apply permissions checks whether or or not we are reading from the
default netrc file, and whether or not the file contains passwords.Installationpip install safe-netrcUsage>>> from safe_netrc import netrcNotes for software packagingSoftware packaging files exist for the following systems:RPM:https://git.ligo.org/packaging/rhel/python-safe-netrcDebian:https://git.ligo.org/packaging/debian/safe-netrcConda:https://github.com/conda-forge/safe-netrc-feedstock
Package: safe-open
IntroductionResolved Issue: When reading a file, the inadvertent use of "w" mode will erase the original file's contents.Installpipinstallsafe_openHow to usefromsafe_openimportsafe_openwithsafe_open("test.txt","w")asf:f.write("Hello, World!")# 正常写入withsafe_open("test.txt","r")asf:content=f.read()# 正常读取withsafe_open("test.txt","w")asf:# OSError: file mode error: cannot read in write modecontent=f.read()# 异常读取withsafe_open("test.txt","r")asf:# OSError: file mode error: cannot write in read modecontent=f.write()# 异常写入
Package: safeopt
This code implements an adapted version of the safe, Bayesian optimization algorithm, SafeOpt[1],[2]. It also provides a more scalable implementation based on[3]as well as an implementation for the original algorithm in[4].
The code can be used to automatically optimize a performance measures subject to a safety constraint by adapting parameters.
The prefered way of citing this code is by referring to [1] or [2].[1]F. Berkenkamp, A. P. Schoellig, A. Krause,Safe Controller Optimization for Quadrotors with Gaussian Processesin Proc. of the IEEE International Conference on Robotics and Automation (ICRA), 2016, pp. 491-496.[2]F. Berkenkamp, A. Krause, A. P. Schoellig,Bayesian Optimization with Safety Constraints: Safe and Automatic Parameter Tuning in Robotics,
ArXiv, 2016, arXiv:1602.04450 [cs.RO].[3]Rikky R.P.R. Duivenvoorden, Felix Berkenkamp, Nicolas Carion, Andreas Krause, Angela P. Schoellig,Constrained Bayesian optimization with Particle Swarms for Safe Adaptive Controller Tuning,
in Proc. of the IFAC (International Federation of Automatic Control) World Congress, 2017.[4]Y. Sui, A. Gotovos, J. W. Burdick, and A. Krause,Safe exploration for optimization with Gaussian processesin Proc. of the International Conference on Machine Learning (ICML), 2015, pp. 997–1005.InstallationThe easiest way to install the necessary python libraries is by installing pip (e.g.apt-getinstallpython-pipon Ubuntu) and runningpip install safeoptAlternatively you can clone the repository and install it usingpython setup.py installUsageThe easiest way to get familiar with the library is to run the interactive example ipython notebooks!Make sure that theipywidgetsmodule is installed. All functions and classes are documented onRead The Docs.LicenseThe code is licenced under the MIT license and free to use by anyone without any restrictions.
Package: safeoutput
Tool to facilitate console script output redirection. When scripts run, often they have an output file option. If no output option is specified, its common to write to stdout. Its common to use tempfiles as output, and then rename the tempfile to the output name as the last step of the program so that the flip of output is atomic and partial/truncated/corrupt output is not confused as successful output. This is especially true when dealing with make, as exiting with error will stop make, but subsequent runs will assume that partial output files left in the workspace are complete. Writing to stdout gives no guarantees about partial results due to truncation.
Package: safepass
safepassCheck passwords againsthttps://haveibeenpwned.com/API/v2#PwnedPasswordsUsageFor humans$safepass
Password:<enterpwnedpassword(masked)>
NOTSAFE!
$echo$?1$safepass
Password:<enternot-pwnedpassword(masked)>
SAFE!
$echo$?0For scriptingNote: scripting mode intended for situations where command history is not saved. Please use above interactive mode if checking directly in command line.$ safepass $PASSWORDAPI>>>fromsafepassimportsafepass
>>>result=safepass(PWNED_PASSWORD)NOTSAFE!
>>>result
False
>>>result=safepass(NOT_PWNED_PASSWORD)SAFE!
>>>result
True
Package: safe-password
safe_passwordThis is a simple library, i do in free time, when trying to understand, how websites store passwords, and how to do this as much secure, as possible. This is learning project, so you can use it for free in any software, you make.ExamplesThis module have only two functions -generate(password), andverify(salt, user_input). You can found more examples insrc/example_safe_password/, but here is a short explanation:generate(password)takes raw user password, and generate random hash and salt, that always unique.verify(salt, user_input, password), where salt and password is given bygenerate()function, and user_input is rawuser input. This function returnTrue, if it's correct input.
Package: safepay-python
Safepay Python SDKOfficial python library forSafepay API.InstallationWith Pippip install safepay-pythonUsageImport and create a Safepay client by passing your config;fromsafepay_python.safepayimport*env=Safepay({"environment":"sandbox","apiKey":"sec_asd12-2342s-1231s","v1Secret":"bar","webhookSecret":"foo",})You can now create payments and checkout links.PaymentsCreate paymentParameterTypeRequiredamountnumberYescurrencyPKR,USDYespayment_response=env.set_payment_details({"amount":10000,"currency":"PKR"})token=(payment_response['data'])['token']# Pass `token` to create checkout linkCheckoutCreate checkout linkParameterTypeDescriptionRequiredtokenstringToken fromenv.set_payment_detailsYesorderIdstringYour internal invoice / order idNocancelUrlstringUrl to redirect to if user cancels the flowYesredirectUrlstringUrl to redirect to if user completes the flowYessourcestringOptional, defaults tocustomNowebhooksbooleanOptional, defaults tofalseNocheckout_url=env.get_checkout_url({"beacon":token,"cancelUrl":"http://example.com/cancel","orderId":"T800","redirectUrl":"http://example.com/success","source":"custom","webhooks":True,})# set webhooks = True if want to subscribe to webhooks# redirect user to `url`VerificationSignatureParameterTypeDescriptionRequiredsigstringThesignaturestring from your serverYestrackerstringThetrackerstring from your serverYessignature_verification=env.is_signature_valid({"sig":"abcd","tracker":token})# mark the invoice as paid if valid# show an error if invalidWebhookParameterTypeDescriptionRequiredx-sfpy-signaturestringThesignaturestring from your serverYesdataobjectThedataobject from your serverYeswebhook_verification=env.is_webhook_valid({"x-sfpy-signature":"abcd"},{"data":data})# mark the invoice as paid if valid# show an error if invalid
Package: safepickling
SafePicklingSafePickling is a python library that allows you to sign and verify python pickles.graph LR
    subgraph Server
        A[Object]:::object -->B{Pickle and sign}:::cryptography
        C[Key]:::storage --> B
        B --> pik2[signature] --> D(Server):::network
        B --> pik1[pickle] --> D
    end
    subgraph Client
        D ==> E(Client):::network
        E -->unpik2[signature]
        E -->unpik1[pickle] --> F{Sign}:::cryptography
        known[(Known keys)]:::storage --> F --> F
        F --> eq{Is equal?}
        unpik2 --> eq:::cryptography
        eq -->|Yes|unpik{{Unpickle}}:::cryptography --> Z[Object]:::object
        eq -->|No|Invalid(Invalid):::error
    end

    classDef network fill:#FFD666;
    classDef cryptography fill:#82FF66;
    classDef error fill:#FF6B66;
    classDef storage fill:#DE66FF;
    classDef object fill:#666EFF;InstallationpipinstallsafepicklingUsage Exampleobject=ExampleObject()server=SafePickling()# Create a server instanceserver.generate_key()# Generate a random key for the serverpickled_object=server.pickle(object)# Pickle the object and sign itclient=SafePickling()# Create a client instanceclient.add_trusted_keys([server.key])# Add the server's key to the client's trusted keysunpickled_object=client.unpickle(pickled_object)# Unpickle the data while verifying it's signature with the server's keyCryptographyRandom provided bysecrets.token_bytesHash comparison withhmac.compare_digestHashing done usinghashlib.blake2b
Package: safe-pip-upgrade
Pip-safe-upgradePip-safe-upgrade automatically updates your pip requirements to the highest versions the tests pass.OverviewThis package can works only with docker-compose projects for now.Installationpipinstallsafe-pip-upgradeWork algorithmPip-safe-upgrade try to upgrade the packages versions in requirements file one by one, run your tests after every
step and if the tests fail it returns version back. The whole workflow goes without rebuilding the docker image
and hence is very fast.Additionally pip-safe-upgrade add sensible comments to requirements file.Here is a detailed algorithm of what safe-pip will do after launch:starts the container in daemon mode (runsdocker-compose run project sleep 3590).read the next package in requirements.check comment. if the comment is'# the latest working version'go to p. 2.check comment. if the comment is'# error on the version x.x.x':check if the is version between current and x.x.xif there is update requirements file to version in the middle between the current and x.x.x and go to p. 3if there is not, add comment'# the latest working version'and go to p. 2check if there is newer versionif there is not go to p. 2if there is, update requirements file to the newest versionstarts the testsif tests fail set version back, add comment'# error on the version x.x.x'and go to p. 4.otherwise, go to p. 2UsageUsing safe-pip-upgrade is basically a two-step process.Define your app's parameters with apip_upgrade.iniRunpip-upgrade.py UPGRADEto start the upgrade of your requirementsApip_upgrade.inilooks like this:[MAIN]working_directory=./# change it if you want to start upgrade from other directory.local_requirements_file=requirements.txt# path and name of the requirements file relative to the working directoryignore_line_starts=['#', '-r', 'https://', 'http://', 'git+'] # list of the line beginnings you want to ignore[COMPOSE RUNNER]compose_project_folder=.# path to your docker-compose filecompose_requirements_file=requirements.txt# path and name of the requirements file in docker container relative to CWD in your Dockerfilecompose_service_name=django# name of the docker-compose servicecompose_work_dir=# set it if you want to change working directory in containerYou can runpip_upgrade.py CREATE-INIso that pip-upgrade automatically creates an ini-file for youAll ini-files option can also be defined with command keys. Typepip_upgrade.pyto see a detailed description.
Package: safe-print-utils
Safe Print Logging UtilitiesTable of ContentsOverviewInstallationRequirementsInstallation StepsInstalling with pipUsagesafe_printDescriptionParametersExampleerror_infoDescriptionParametersExamplereplace_invalid_utf8_charactersDescriptionParametersExampleAdditional Usage NotesContributorsOverviewThe Safe Print Logging Utilities is a Python script providing enhanced printing functionality with colorful formatting, logging capability, and handling of UTF-8 encoding issues across various data types.The Utilities define three main functions:safe_print: Augments print functionality.error_info: Logs detailed error information.replace_invalid_utf8_characters: Mitigates issues with invalid UTF-8 characters.InstallationRequirementsPython 3.xcoloramapackageInstallation StepsEnsure Python is installed on your machine.Install thecoloramapackage using pip:pipinstallcoloramaIntegrate the script into your project.Installing with pipSince the package is available on PyPI, you can install it using pip with the following command:pipinstallsafe_print_utilsUsage1.safe_printDescriptionPrints data with colorful formatting and logging options.Parametersdata: Data to print, formatted/indented for dicts and lists.child_process_label: (Optional) Label identifying a child process.label_color: Color forchild_process_label(Default: "RED").prefix: (Optional) Custom output prefix.prefix_color: Prefix color (Default: "GREEN").text_color: (Optional) Main text color.highlight: Flag to highlight text with yellow background and black text (Default: False).secondary_highlight: Flag to highlight text with black background and yellow text (Default: False).file_path: (Optional) File path for logging (Default: "").file_lines_limit: Max lines in log file, older lines are removed (Default: 10000).show_time: Flag to prefix output with the time (Default: True).error: Flag to make text color red (Default: False).Examplesafe_print("Hello, World!",prefix="Info",prefix_color="GREEN")2.error_infoDescriptionPrints and optionally logs detailed error information, including line number and traceback.Parameterserror: Caught exception object.file_path: (Optional) Log file path (Default: "").file_lines_limit: Max lines in log file, older lines are removed (Default: 10000).Exampletry:1/0exceptExceptionase:error_info(e)3.replace_invalid_utf8_charactersDescriptionReplaces invalid UTF-8 characters within various data types.Parametersinput_data: Data containing potential non-UTF-8 encoded characters.replacement_character: Character replacing invalid UTF-8 characters (Default: ' ').Examplecleaned_data=replace_invalid_utf8_characters("some_data_with_invalid_utf8")Additional Usage NotesEnsure text/log file encoding compatibility with UTF-8.Ensure correct and writable file path/directory when logging withsafe_print.ContributorsSyntaxSurge (https://syntaxsurge.com)
Package: safepy
Safepy (rhymes with safety) is a latency and fault tolerance library for Python 3.5 (or greater) inspired byHystrix,Cloud Design Patterns,AWS Architecture Blogand many others.How to use the libraryYou can either use the mechanisms as decorators:fromsafetyimportretryclassProfileService(object):@retry(attempts=3,base_delay=1)asyncdefget_profile(self,username):...Or to dynamically recreate protected methods:fromsafetyimportretryclassProfileService(object):def__init__(self):self.get_profile=retry(attempts=3,base_delay=1)(self.get_profile)asyncdefget_profile(self,username):...RetryfromsafepyimportretryclassServiceA(object):@retry(attempts=3,base_delay=1)asyncdefcall():...NotesThe defaultretryis an alias forretry_with_jitter_backoff, a retry mechanism which usesjitter backoff. For exponential backoff useretry_with_exponential_backoff.
Package: safe-radix32
safe_radix32A simple Python package that encodes any 64bit integer (long) into to
a string that is free from accidentally intelligible words.What?The primary use-case for this library is to encode (and decode) 64bit database IDs
into compact strings. This functionality was defined by a few goals:translated IDs must be string-type to be compatible with JavaScript where 64bit integers are not (well) supportedIDs must be usable in URLs (path, query-value and fragment) without escapingIDs must avoid translating into intelligible wordsthe translated form has to be as compact as feasibleWhy?There are numerous well supported and established encodings to represent an integer as string, but
hardly any (here I mean I could not find one suitable) where the translated value is guaranteed
to... look and feel professional.Examples:A system generates a database ID randomly for an account:6733255313934373709.
It seems perfectly innocuous, but if you base64 encode it the result is highly undesirable:XXFUCKER000.
Normal base32 has similar issues, but without both letter cases.Encoding into hexadecimal representation is mostly acceptable. Some undesired values:B00B5,DEAD,FACE, etc.
One could argue that these are not very bad... maybe childish, but certainly not "professional".I'll leave even worse randomly translated words up to imagination. The point is that immutable database IDs for a
business accountmustn'thave such handles.How?I could not find many detailed sources/references on how to construct a suitable alphabet. After
gathering some information from the internet, some good ideas were presented and those were combined:Avoid vowels. This greatly limits random word creation. There are less vowels than consonants so excluding the
smaller group leaves us more to work with.Avoid visually similar characters:5Ss,i1Il,o0O, etc. (depends on font, but generally true)Trim further letters in order of their frequency in the language (english).I've started out with the base64 alphabet and reduced it. To make processing easy I wished to use a base that is a
power of 2. Thankfully trimming half of the base64 alphabet seemed to be just about optimal. A base16 alphabet would
not yield meaningful benefits.The safe_radix32 alphabet is2346789BCFGJKLMPQVWZbcfgjkmpqvwzwhich was generated by the script attools/alphabet.py.ImplementationThere is a Cython extension implementation withgoodperformance and a pure python fallback module for compatibility.InstallA source distribution is available on PyPI:$python-mpipinstallsafe_radix32Python 3.6+ and PyPy3 are supported.Usage>>>importsafe_radix32>>>safe_radix32.encode(12345678987654321)'GwqGVVF6v8V'>>>safe_radix32.decode(_)12345678987654321# or fixed width encoding (13 chars)>>>safe_radix32.encode_fw(12345678987654321)'22GwqGVVF6v8V'>>>safe_radix32.decode(_)12345678987654321SecurityEncoding and decoding will raiseOverflowExceptionif the value cannot be faithfully represented in a C long.Decoding a string will also raiseOverflowExceptionif an invalid character is found. If the input is badly
formatted or invalidUnicodeErrorwill be raised.
Package: safe-reboot
safe-rebootWrapper around reboot. Checks if other users are logged in or have active screen or tmux sessions.Free software: Apache Software License 2.0Documentation:https://safe-reboot.readthedocs.io.FeaturesTODOCreditsThis package was created withCookiecutterand theaudreyr/cookiecutter-pypackageproject template.History0.1.0 (2020-03-03)First release on PyPI.