Saravanan666/pypi-org huggingface dataset:
Package: base64file
Base64FileAn IO wrapper that but reads/writes binary data as base64 text, supporting concurrent reading and writing. Similar
toGzipFile, it simulates most of the methods of a
standard file object (with the exception ofreadline).Usagebase64file.open()Similar togzip.open()orio.open()importbase64file# to write textwithbase64file.open('some-file.txt','rt',encoding='utf8')asf:f.write('1234567890')# to write binarywithbase64file.open('some-file.txt','rb')asf:f.write(b'\1\2\3\4\5')base64file.Base64FileWhen opening a Base64File without specifying an underlying file, a filename must be provided, and the usual binary
modes are supported:r,rb,w,wb,a,ab,x, andxb(optional+to enable concurrent
reading/writing, e.g.wb+).When opening a Base64File with a specified underlying file, the mode is inherited from the specified file (replacing
text-mode with binary-mode). If a binary-mode file is provided, it is automatically wrapped with
aTextIOWrapper.frombase64fileimportBase64File# open a new/existing file for concurrent reading and writingwithBase64File('some-file.txt','w+')asb:b.write(b'\0\1\2\3\4')b.seek(0)b.write(b'\n')print(b.read(2))# prints b'\1\2'# wrap an existing file (in this example, open for reading)withopen('some-file.txt','r')asf:withBase64File(file_obj=f)asb:print(b.read(2))# prints b'\n\1'print(b.read())# prints b'\2\3\4'# if you need to keep the file open, remember to close itf=open('some-file.txt','w+')b=Base64File(file_obj=f)b.write(b'\0\1\2\3\4')b.seek(0)b.write(b'\n')print(b.read(2))# prints b'\1\2'b.close()# this is necessary, otherwise the final 1-2 bytes may not be writtenf.close()base64file.Base85File and base64file.Ascii85FileThe same as base64file.Base64File, but instead
usesb85encode()ora85encode()Note that many implementations of base85 are actually Ascii85 (for example, CyberChef.io)frombase64fileimportAscii85Filefrombase64fileimportBase85File
Package: base64io
This project is designed to develop a class,base64io.Base64IO, that implements
a streaming interface for Base64 encoding.Python has supported native Base64 encoding since version 2.4. However, there is no
streaming interface for Base64 encoding, and none is available from the community.The legacybase64.encodeandbase64.decodeinterface lets you shuffle data between
two streams, but it assumes that you have two complete streams. We wanted a
standard stream that applies Base64 encoding and decoding.base64io.Base64IOprovides aniostreaming interface with context manager
support that transparently Base64-encodes data read from it. You can use it to transform
large files without caching the entire context in memory, or to transform an existing
stream.For the latest full documentation, seeRead the Docs.Find us onGitHub.Getting Startedbase64io.Base64IOhas no dependencies other than the standard library and should
work with any version of Python greater than 2.6. We test it on CPython 2.6, 2.7, 3.3,
3.4, 3.5, 3.6, and 3.7.Installation$ pip install base64ioUsebase64io.Base64IOwraps the input stream and transparently encodes or decodes
data written to or read from the input stream.write()encodes data before writing it to the wrapped streamread()decodes data after reading it from the wrapped streamBecause the position of thebase64io.Base64IOstream and the wrapped stream will
almost always be different,base64io.Base64IOdoes not support:seek()tell()Also,base64io.Base64IOdoes not support:fileno()truncate()Encode dataWarningIf you are not usingbase64io.Base64IOas a context manager, when you write to
abase64io.Base64IOstream, youmustclose the stream after your final
write. The Base64 transformation might hold up to two bytes of unencoded data in an
internal buffer before writing it to the wrapped stream. Callingclose()flushes
this buffer and writes the padded result to the wrapped stream. Thebase64io.Base64IOcontext manager does this for you.frombase64ioimportBase64IOwithopen("source_file","rb")assource,open("encoded_file","wb")astarget:withBase64IO(target)asencoded_target:forlineinsource:encoded_target.write(line)Decode dataNoteWhen it reads data from the wrapping stream, it might read up to three additional bytes
from the underlying stream.frombase64ioimportBase64IOwithopen("encoded_file","rb")asencoded_source,open("target_file","wb")astarget:withBase64IO(encoded_source)assource:forlineinsource:target.write(line)LicenseThis library is licensed under the Apache 2.0 License.
Package: base64-random
base64_randomGenerates a base 64 random number of an arbitrary length.base64_random uses Python'ssecretsmodule to generate the random numbers, so you should be able to generate high
quality random numbers when using this library. That said, I cannot recommend that this library be used in contexts
where high-quality random numbers are used to secure sensitive information. Please use a suitable cryptography library
for contexts where you need to protect information.Please also note, that as of the time of writing, this library providesNO SUPPORTfor Base64 encoding or decoding.
Additionally, this library generates numbers in base 64, it has no relation to theBase64encoding format.UsageThere are two main ways to use this package, command line invocation and importing the module.Command Line InvocationCommand line usage is quite easy, simply pass the module the length of number you wish to generate:python-mbase64_random10Or, by invoking the shell script:b64r10Python module usageYou can also import this module in your code to use it:frombase64_randomimportgen_random_base64base64_number=gen_random_base64(10)print(base64_number)Installationbase64_randomis available on pip!pipinstallbase64_randomYou can also installbase64_randomdirectly from git, but please refer to theofficial documentationfor the details
of how to do that.
Package: base64-to-hex-converter
Base64 to Hexadecimal ConverterConverts strings in Base64 to Hexadecimal inside JSON files.ExampleConsider the following JSON file calleddata.json.{"mostRecentMachineHash":{"data":"BAAAhWHqhD6t35WDLbQjCNThk04glwBqEGfmh27rkoA="},"mostRecentVouchersEpochRootHash":{"data":"XhaRbdkr3XQD9FDIl/N8MDNG7z9LrT8YmigcNvqWnMY="},"mostRecentNoticesEpochRootHash":{"data":"WJfJG6VyF4ndZkW5Z8/UGfd8ALPov88EcFpOyu1wZ9Q="},"processedInputs":[{"mostRecentMachineHash":{"data":"VT/WlH6kqOvLt7/e3gOrAQriU7Lgq8QtZD0yh4jeAjc="},"voucherHashesInEpoch":{"targetHash":{"data":"S0oviQGm0hoFsu01ead/1odUJQO8b09Q5ZGBa6E0wEM="},"rootHash":{"data":"XhaRbdkr3XQD9FDIl/N8MDNG7z9LrT8YmigcNvqWnMY="}},"reports":[{"payload":"jcIadw=="}]}]}If we runpython -m b64to16 data.json, we get the following output.{"mostRecentMachineHash":{"data":"0x0400008561ea843eaddf95832db42308d4e1934e2097006a1067e6876eeb9280"},"mostRecentVouchersEpochRootHash":{"data":"0x5e16916dd92bdd7403f450c897f37c303346ef3f4bad3f189a281c36fa969cc6"},"mostRecentNoticesEpochRootHash":{"data":"0x5897c91ba5721789dd6645b967cfd419f77c00b3e8bfcf04705a4ecaed7067d4"},"processedInputs":[{"mostRecentMachineHash":{"data":"0x553fd6947ea4a8ebcbb7bfdede03ab010ae253b2e0abc42d643d328788de0237"},"voucherHashesInEpoch":{"targetHash":{"data":"0x4b4a2f8901a6d21a05b2ed3579a77fd687542503bc6f4f50e591816ba134c043"},"rootHash":{"data":"0x5e16916dd92bdd7403f450c897f37c303346ef3f4bad3f189a281c36fa969cc6"}},"reports":[{"payload":"0x8dc21a77"}]}]}We can also stream the JSON input through standard input, likecat data.json | python -m b64to16.HelpRunpython -m b64to16 -h
Package: base64-to-image
Library for converting RGB / Grayscale numpy images from to base64 and back.Installationpip install -U image_to_base_64ConversionRGB to base 64base64 = rgb2base64(rgb_image, image_format)where image format isJPEG,PNGGrayscale to base 64base64 = grayscale2base64(grayscale_image)Base64 to RGB imagergb_image = base64_to_rgb(base64)Base64 to Grayscale imagegrayscale_image = base64_to_grayscale(base64)IssuesFor some reason I cannot convertRGBimage toJPEGrepresentation in base 64 and back without losses.
=> test only forPNGand notJPEG
Package: base64u
base64uBase64u - URL-Safe Base64 variant no padding.
Based onhttps://gist.github.com/jonleighton/958841Also main part code was fromhttps://github.com/greymass/eosio-signing-request/blob/ffe7458abb48c4fcd998d7c6b142cdd4c7d46cda/src/base64u.tsInstallationpipinstallbase64uUsageimportbase64udata=base64u.Uint8Array(10)# like bytearrayencoded=base64u.encode(data)decoded=base64u.decode(encoded)print(encoded)print(decoded)# data is Uint8Array for assert equality bytearray and List[int]assertdata==[0]*10assertencoded=="AAAAAAAAAAAAAA"assertdecoded==data
Package: base91x
base91xThis base91x method provides data encoding and decoding
using numeric system of base 91 with specific alphabet that does not require
escaping any symbols in C, C++ (and many other languages?) string.
'x' - means the alphabet was obtained with XOR function.The alphabet contains visible printable characters of ASCII except:"Quotation mark'Apostrophe\BackslashAn encoded string might be used for JSON string if JSON does not require to escape / Slash.Encoded string size ~ 16 * original size / 13.There is possibility to extend the algorithm to use 89 codes during decode.The alphabet transforms from base91 value with operation XOR(0x7F) with the tree exceptions.The alphabet in the order:!~}|{zyxwvutsrqponmlkjihgfedcba`_^]#[ZYXWVUTSRQPONMLKJIHGFEDCBA@?>=<;:9876543210/.-,+*)($&%PAY ATTENTION:Encoded string may have awkwardly sequence/*or*/It may hurt C or C++ code when the string is placed into code.
But sequence %%% should not appear. So, encoded string might be placed with raw string literal:char string[]=R"%%%( a string )%%%";Workaround: use space | line feed | tab in encoded text to break wrong sequence due the algorithm skips non alphabet symbols.
e.g.Ma^7*/0629->Ma^7* /0629The algorithm is not compatible withhttps://base91.sourceforge.net/
Package: base92
A little library for encoding byte-strings into strings easily
typeable on a standard US 101-key keyboard, with strictly better
information density than base64 or base85 encodings.USAGEFire up your favorite python:>>> import base92
>>> base92.decode(base92.encode('hello world'))
'hello world'
>>> base92.encode('\x61\xf2\x05\x99\x42')
'DJ8gER!'We use doctests, so running the tests is as easy as executing the
base92.py library file with your python.MISCThis library is pure python: there may be a cbase92 forthcoming,
backed by a C library.This library has not been tested with python3.There is more information available at
<https://github.com/thenoviceoof/base92>
Package: base-api
BaseAPIEasily create maintainable API clients.RationaleBuilding other Python based API clients I found that there was a
tendency to end up with a "mega-class", containing most of the
definitions of my API. BaseAPI tries to keep unrelated API concepts
separate, hopefully making for an easier maintenance experience.InstallationPyPi is the easiest way to install:pipinstallbase-apiUsageCreating a clientNormally theClientclass is inherited to create your own client
class:frombaseapiimportClientclassMyClient(Client):DEFAULT_URL='https://my-api.com'Here we've set our default API URL. This can also be set during the
creation of the client:client=MyClient(url='https://localhost')Creating APIsTo populate your client with functions to access your API use
individual API classes. These reflect an isolated part of your overall
API.As an example, you may have an authorization component to your API. To
add authorization to your client library, you may create a file calledauth.py:frombaseapi.apisimportGraphqlApiclassAuthApi(GraphqlApi):deflogin(self,username,password):login_query='...'data={'username':username,'password':password}returnself.perform_query(login_query,data)deflogout(self):logout_query='...'returnself.perform_query(logout_query)Once you have this slice of your API ready, you can add it to your
client by specifying it during the client class definition:frombaseapiimportClientclassMyClient(Client):DEFAULT_URL='https://my-api.com'DEFAULT_APIS=('auth',)In this case,auth.pymust be placed in yourPYTHONPATH, most
likely alongside your client class file. Now, you may access the APIs
methods on your client as such:client=MyClient()client.login('username','password')There are currently two API types supported, GraphQL and Rest. The
sameauthAPI as above, but using Rest instead:frombaseapi.apisimportRestApiclassAuthApi(RestApi):deflogin(self,username,password):data={'username':username,'password':password}returnself.post('/login',data)deflogout(self):returnself.post('/logout')Exposing methods to the clientThe methods in an API that get exposed to a client are chosen based on
a leading underscore. Those without an underscore are automatically
added to the client class, while those with an underscore are treated
as private.So, as an example, a local validation method could be added to an API
as such:frombaseapi.apisimportRestApiclassMyApi(RestApi):defget_something(self,type):self._validate_type(type)returnself.get('/api/something, data={'type': type})def_validate_type(self,type):# Do validation.pass
Package: base-api-connector
Base API ConnectorHelps create a simple API Connector where all you have to do is define the resources and possible commands.InstructionsUsing the ModuleFirst import the GenericAPIConnector class:from base_api_connector import GenericAPIConnectorThen, define a base_api_url and resource fields like this:class ImplementedAPIConnector(GenericAPIConnector):
    base_api_url = 'http://127.0.0.1:8000/notes-backend/'
    reports = APIResource(('create', 'retrieve', 'update'))
    users = APIResource('all')That will generate the following attributes when you use the class:conn = ImplementedAPIConnector()

conn.reports.create(data)
conn.reports.retrieve(pk)
conn.reports update(pk, data)

conn.users.list()
conn.users.create(data)
conn.users.retrieve(pk)
conn.users.update(pk, data)
conn.users.delete(pk)AsyncioYou can tell tell your resource fields that they should be accessed with asyncio per default:class ImplementedAPIConnector(GenericAPIConnector):
    # ...
    users = APIResource('all', is_async=True)and then use it in an async metho as follows:async def create_user(user):
    r = await conn.user.create(user)
    data = await r.json()
    # ...Alternatively, you can change switch to async in-line as well:# ...
    r = await conn.reports(is_async=True).list()
    # ...or the other way around:r = conn.user(is_async=False).list()Using The Returned ObjectThe methods of GenericAPIConnector return a regular Response object from the requests module. See requestsDocumentation for Responsefor more details.Using AsDictObject (WIP)If you want to define how a resource looks only once, import AsDictObject:import datetime
from base_api_connecotr import AsDictObject

class CreateUsersResourceObject(AsDictObject):
    name = None  # None will not pass the field in the request
    created = datetime.datetime.now  # use methods to set defaults like this
    created_for_app = 'readme_example'And then use it like this:user = CreateUsersResourceObject():
user.name = 'readme user'
conn.users.create(user)
Package: baseapp-auth
BaseApp AuthUsageThis project includes:API endpoints for authentication and account managementdefault User modelAbstract user modelAbstractUseris an abstract Django user model implementation. It provides a default implementation ofUsermodel and can be extended in the target Django app. The attachedtest projectcontains a concrete implementation of User class for demo purposes.Authentication endpointsIn therest_framework/directory you can find a implementation of account-related endpoints: login, signup, forgot-passowrd, change-email. Authentication (login) is implemented in a few different modes that can be picked depending on project preference/requirements. Intestproject/urls.pyyou'll find DRF routing set up for each of supported modes with unit tests for each mode:Authentication with Simple AuthTokenAuthentication with JWTAuthentication with MFA and Simple AuthTokenAuthentication with MFA and JWTGraphQLPermissionsInterfaceWhen yourDjangoObjectTypeimplementsPermissionsInterfaceyou are able to query for object-level permissions:query{page(id:1){canDelete:hasPerm(perm:"delete")canChange:hasPerm(perm:"change")}}### Utilities

## Demo

There is a [test project](testproject/) with a complete demo set up.

## Installation

Add to requirements of yor project (replacing everything inside brackets):

```bash
baseapp-auth @ git+https://github.com/silverlogic/baseapp-backend.git@v0.1#subdirectory=baseapp-authSettingsAdd the app to your project INSTALLED_APPS:INSTALLED_APPS=[..."baseapp_auth",]Set the Django auth user model to the concrete model of your app:AUTH_USER_MODEL="testapp.User"If you want to use JWT authentication, add the corresponding authentication backend:REST_FRAMEWORK={"DEFAULT_AUTHENTICATION_CLASSES":("rest_framework_simplejwt.authentication.JWTAuthentication",# ...)}I you want to use JWT authentication, set the related JWT settings (e.g. the claims serializer):SIMPLE_JWT={# It will work instead of the default serializer(TokenObtainPairSerializer)."TOKEN_OBTAIN_SERIALIZER":"testproject.testapp.rest_framework.jwt.serializers.MyTokenObtainPairSerializer",# ...}JWT_CLAIM_SERIALIZER_CLASS="baseapp_auth.rest_framework.users.serializers.UserBaseSerializer"There is a constance config for password expiration interval:CONSTANCE_CONFIG=OrderedDict([("USER_PASSWORD_EXPIRATION_INTERVAL",(365*2,"The time interval (in days) after which a user will need to reset their password.",),),])There is an optional scheduled task that can be configured for notifying that the user's password has expired:CELERY_BEAT_SCHEDULE={"notify_is_password_expired":{"task":"baseapp_auth.tasks.notify_users_is_password_expired","schedule":"...","options":"...",},}How to delevopGeneral development instructions can be found inmain READMEOther SettingsBA_AUTH_PRE_AUTH_TOKEN_EXPIRATION_TIME_DELTA:datetime.timedelta
Package: baseapp-django-trench
This is a fork fromhttps://github.com/merixstudio/django-trenchmeant to be used with baseapp packagesdjango-trenchprovides a set of REST API endpoints to supplementdjango-rest-frameworkwith multi-factor authentication (MFA, 2FA). It supports both standard built-in authentication methods, as well as JWT (JSON Web Token).We deliver a couple of sample secondary authentication methods including sending OTP based code by:E-mailSMS / text3rd party mobile appsYubiKeyDevelopers can easily add their own authentication backends supporting any communication channel.FeaturesEasily pluggable and compatible withdjango-rest-frameworkAllows user to pick an additional authentication method from range of backends defined by a developer. Read more:backendsComes out of a box with email, SMS, mobile apps and YubiKey supportSupported versionsPython 3.7, 3.8, 3.9, 3.10, 3.11Django 2.0, 2.1, 2.2, 3.0, 3.1, 3.2, 4.0, 4.1Django REST Framework 3.10, 3.11, 3.12, 3.13, 3.14If you are going to use JWT authentication:djangorestframework-simplejwt>= 4.3.0Quick StartInstall the package using pip:pipinstalldjango-trenchor add it to your requirements file.Addtrenchlibrary to INSTALLED_APPS in your app settings file:INSTALLED_APPS=(...,'rest_framework','rest_framework.authtoken',# In case of implementing Token Based Authentication...,'trench',)Run migrationsRead further in:installation.TranslationTrench uses Transifex service to translate our package into other languages.We will appreciate your help with translation.https://www.transifex.com/merixstudio/django-trench/dashboard/Local developmentClone the repo.Crete virtual environment named e.g..venv:virtualenv.venvActivate the virtual environment:source.venv/bin/activateInstall dependencies:pipinstallblackmypypipinstall-rtestproject/requirements.txtSet environment variables:exportPYTHONPATH=./testprojectexportDJANGO_SETTINGS_MODULE=settingsexportSECRET_KEY=YOURsecretGOEShereCreate a symbolic link to thetrench/module inside thetestproject/directory to emulate thetrenchpackage being installed.# make sure you run this command from the root directory of this projectln-s$(pwd)/trench/$(pwd)/testproject/trenchCheck whether the tests are passing:pytest--cov=testproject/trenchtestproject/tests/Remember - anytime you change something in thedjango-trenchsource code you need to re-build and re-install
the package (steps 6-7) for the changes to be present during e.g. running the tests.[OPTIONAL] To make the tests run faster you can try to execute them in parallel.To do so you need to install thepytest-xdistpackage and run the tests
with additional parameter of-n 8where8stands for the number
of threads that will be spawned for executing the tests. Depending on the machine
you’re using using this tool can speed up the test execution process up to 5 times.pytest-n8--cov=testproject/trenchtestproject/tests/
Package: baseapp-e2e
BaseApp E2EUsageThis project includes utilities for database initialization and seeding when performing End-To-End tests.E2E EndpointsE2EViewSethas a set of endpoints for managing the test data from the frontend E2E test client (usually from Cypress):POST/load-data- load data usingDjango's default serizlization format. Example payload:{"objects":[{"model":"users.user","fields":{"email":"abc@tsl.io",// ...}},{"model":"users.user","fields":{"email":"def@tsl.io",// ...}}]}POST/load-script- load data through a script module that exists in the backend project repository. Example:Set theSCRIPTS_PACKAGEsetting to a module path where the scripts are located:E2E={"ENABLED":True,"SCRIPTS_PACKAGE":"e2e.scripts",}Then add a python script on the defined module path, e.g.:<project-root>/e2e/scripts/users.py. The script is expected to have adef load()function that will be executed by the endpoint.importtests.factoriesasfdefload():f.UserFactory()To request the script to be run use request format as:{"scripts":["users"]}POST/flush-data- remove the data from database usingDjango flush commandPOST/set-password- set a password for an existing user. Example payload:{"user":<userid>,"password":"1234"}DemoThere is atest projectwith a complete demo set up.InstallationAdd to requirements of yor project (replacing everything inside brackets):baseapp-e2e@git+https://github.com/silverlogic/baseapp-backend.git@v0.1#subdirectory=baseapp-e2eSettingsAdd the app to your project INSTALLED_APPS:INSTALLED_APPS=[..."baseapp_e2e",]Add E2E settings to Django settings file of your application:E2E={"ENABLED":True,"SCRIPTS_PACKAGE":"e2e.scripts",}How to delevopGeneral development instructions can be found inmain README
Package: baseapp-follows
BaseApp FollowsReusable app to enable any model follow/unfollow any model.Requirements:- **baseapp-core** >= 0.2.3Runpip install baseapp-followsAnd make sure to add the frozen version to yourrequirements/base.txtfileIf you want to develop,install using this other guide.How to useAddbaseapp_followsto your project'sINSTALLED_APPSNow make sure all models you'd like to get follows also inheritsFollowableModel, like:frombaseapp_follows.modelsimportFollowableModelclassUser(models.Model,FollowableModel):Also make sure your GraphQL object types extendsFollowsInterfaceinterface:frombaseapp_follows.graphql.object_typesimportFollowsInterfaceclassUserNode(DjangoObjectType):classMeta:interfaces=(relay.Node,FollowsInterface)ExposeFollowsMutationsin your GraphQL/graphene endpoint, like:frombaseapp_follows.graphql.mutationsimportFollowsMutationsclassMutation(graphene.ObjectType,FollowsMutations):passschema=graphene.Schema(query=Query,mutation=Mutation)This will exposefollowTogglemutation and add fields and connections to all your GraphqlQL Object Types using interfaceFollowsInterface.Example:mutationFollowButtonMutation($input:FollowToggleInput!){followToggle(input:$input){follow{node{id}}target{idfollowersCountisFollowedByMe}actor{idfollowingCount}}}How to developClone the project inside your project's backend dir:git clone git@github.com:silverlogic/baseapp-backend.gitAnd manually install the package:pip install -e baseapp-backend/baseapp-followsThe-eflag will make it like any change you make in the cloned repo files will effect into the project.