Saravanan666/pypi-org huggingface dataset:
Package: generic-events-manager
GenericEventsManagerOverviewIt is a generic class for managing events generated by an application.Installing GenericEventsManager and Supported VersionsGenericEventsManager is available on PyPI:$ python -m pip install generic-events-managerGenericEventsManager officially supports Python 3.8+.Cloning the repository$ git clone https://github.com/tatianno/generic-events-manager.gitExamplefrom events_manager import GenericEventsManager
from events_manager.entities import GenericObserver


class CustomObserver(GenericObserver):

    def _exec_routine_update_obj(self, obj_new: GenericEventsManager.EventObject, obj_old: GenericEventsManager.EventObject) -> None:
        '''
        Method called each time the observed object changes state
        '''
        print(f'The object {obj_new.key} has been updated with the state {obj_new.state}')
        print(f'The previous state was {obj_old.state}')

    def _exec_routine_delete_obj(self, obj: GenericEventsManager.EventObject) -> None:
        '''
        Method called when observed object is deleted
        '''
        print(f'The object {obj.key} has been deleted')


class CustomEventsManager(GenericEventsManager):

    class EventObject(GenericEventsManager.EventObject):
        observer_class = CustomObserver

    def create(self, entity: EventObject) -> None:
        self.perfom_create(entity)

    def update(self, entity: EventObject) -> None:
        old_entity = self.get(entity.get_key())
        self.perfom_update(entity, old_entity)

    def delete(self, entity: EventObject) -> None:
        self.perfom_destroy(entity)


# Instantiating the Event Handler and Observer
events_manager = CustomEventsManager()
observer = CustomObserver()

# Dictionary containing event data
data = {
    'state' : 'ON',
    'key' : 'k1'
}

# Updating the object with the received event data
response = events_manager.event_update(data)

# Subscribing observer
obj = events_manager.get('k1')
obj.subscribe(observer)

# Dictionary containing event data
data = {
    'state' : 'OFF',
    'key' : 'k1'
}

# Updating the object with the received event data
response = events_manager.event_update(data)

# Deleting object
obj = events_manager.get('k1')
events_manager.delete(obj)
Package: genericf2py
Genericf2Py Demostrates How To Handle Fortran Binaries In Python Modules.See the Code at:https://github.com/sonofeft/GenericF2PYSee the Docs at:http://genericf2py.readthedocs.org/en/latest/See PyPI page at:https://pypi.python.org/pypi/genericf2pyOverviewGenericF2PY focuses on the use off2pyfor integrating FORTRAN modules into pythonPyPIprojects.GenericF2PY has the following goals:Support a variety of platforms Windows/Linux/MacOS/etc.Support a variety of python distributions (2 & 3).Support both 32 & 64 bit installations.Based on my experience developing GenericF2PY, I believe the best way to achieve the above goals is:Distribute onlysource code(Python & FORTRAN).Provide guidance for setting upf2pyon the user’s platform.Recommend users install with“pip install <packagename>”.Provide guidance for correcting any error messages.Binary DistributionsWhen binary distributions install properly, they are the most convenient approach for users…HOWEVER…When binary distributions fail, they can be confounding for many users and greatly impede
or even preclude the use of your project for those users.The sheer difficulty of maintaining binaries for all possible systems can become overwhelming.Binary distributions can fail for a variety of reasons:Compiled against wrong version ofnumpyMissing or wrong version of system librariesEnvironment variable problems (PATH, LIBRARY_PATH, CC, GCC, etc.)Security RestrictionsUnknown UnknownsIt is for these reasons, that I recommend distributingsource code only.I’m weighing the user’s difficulty of installingf2pyagainst the user’s difficulty of debugging your potentially failed binary distribution and deciding that
installingf2pyis the smaller burden.
Also, the user can Googlef2pyand find answers.
You will be the user’s only source of information on your binaries for all possible systems.If you want to make binary distributions available, it might be best to either:create binary wheels in a Githubpip-wheelsdirectoryprovide an option to install from source code.Users can be directed to that Githubpip-wheelsdirectory or given
source-install instructions as required.Keywords: genericf2py setuptools development
Platform: any
Classifier: Development Status :: 4 - Beta
Classifier: Operating System :: OS Independent
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: End Users/Desktop
Classifier: Topic :: Software Development :: Build Tools
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Description-Content-Type: text/x-rst
Provides-Extra: dev
Provides-Extra: test
Package: generic-fk
Description‘django-generic-fk’ is essentially just a collection of widgets and mixin for easy use GenericForeignKey in Django admin.Install::pip install generic-fkUsageMixinIn fileadmin.py:from django.contrib import admin

from apps.models import SomeModel
from generic_fk.mixins import ModelAdminMixin


class SomeModelAdmin(ModelAdminMixin, admin.ModelAdmin):
    pass

admin.site.register(SomeModel, SomeModelAdmin)WidgetIn fileadmin.py:from django.contrib import admin
from django.contrib.admin.widgets import ForeignKeyRawIdWidget
from django.core.exceptions import ObjectDoesNotExist
from django.db.models import ManyToOneRel
from django import forms

from apps.models import SomeModel
from generic_fk.widgets import ContentTypeSelect


class SomeModelForm(forms.ModelForm):
    def __init__(self, *args, **kwargs):
        super(SomeModelForm, self).__init__(*args, **kwargs)
        try:
            model = self.instance.content_type.model_class()
            model_key = model._meta.pk.name
        except (AttributeError, ObjectDoesNotExist):
            model = self.fields['content_type'].queryset[0].model_class()
            model_key = 'id'
        self.fields['object_id'].widget = ForeignKeyRawIdWidget(
            rel=ManyToOneRel(model, model_key),
            admin_site=admin.site
        )

    class Meta:
        model = SomeModel
        widgets = {
            'content_type': ContentTypeSelect
        }

class SomeModelAdmin(admin.ModelAdmin):
    form = SomeModelForm

admin.site.register(SomeModel, SomeModelAdmin)
Package: genericfuncs
genericfuncs============:code:`genericfuncs` allows you to create functions which execute differentimplementations depending on the arguments.This module can be seen as a powerful improvement over Python 3's :code:`singledispatch`:* Allows dispatch over any boolean callable, not just type checks.* Allows dispatch over any number of arguments, not just the first argument.Basic usage***********from genericfuncs import generic@genericdef func(a):# default implementationraise ValueError()@func.when(lambda a: a.startswith('foo')):def _impl_1(a):return a.upper()@func.when(lambda a: a.startswith('bar')):def _impl_2(a):return a.lower()The first predicate that returns True has its mapped implementation invoked.Predicates are checked in order of definition.Installation************:code:`pip install genericfuncs`Advanced********Arguments are injected into predicates and implementations by their name.This means a predicate or implementation is able to specify only the arguments it needs. For example::@genericdef multiple_params_func(a, b, c):return a + b + c  # default implementation@multiple_params_func.when(lambda b: b > 10)  # only inject argument `b` to the predicatedef _when_b_greater_than_10(a):  # only inject `a` to the implementationreturn a * 10@multiple_params_func.when(lambda a, b: a % b == 0)  # only inject `a` and `b`def _when_a_divisible_by_c(a, b, c):  # use all argumentsreturn a / b * cHowever the call site must list all mandatory arguments, as usual in Python::multiple_params_func(10, 20, 30) --> 100  # _when_b_great_than_10() invokedmultiple_params_func(4, 2, 'bla') --> 'blabla'  # _when_a_divisible_by_c() invokedmultiple_params_func(0, 0, 0) --> 0  # default implementation invokedWhen defining a predicate, one can list exception types that should notpropagate if raised inside the predicate. For example::@my_generic_func.when(lambda a: a > 10, ignored_errors=[TypeError])def _implementation(a):...When invoking :code:`my_generic_func(MyThing())`, a :code:`TypeError` will be raised inside the predicatebecause :code:`MyThing` doesn't support :code:`>` operator.Normally, the error would propagate and crash the program.Specifying :code:`ignored_errors=[TypeError]` makes the error be silently ignored,moving on to the next predicate.
Package: generic-grader
Generic GraderA collection of generic tests for grading programming assignments.UsageDon't use this yet. It's not ready.ContributingClone the repo onto your machine.HTTPSgitclonehttps://github.com/Purdue-EBEC/generic-grader.gitSSHgitclonegit@github.com:Purdue-EBEC/generic-grader.gitSet up a new virtual environment in the cloned repo.cdgeneric-grader
python3.11-mvenv.env3.11Activate the virtual environment.  If you are using VS Code, there may be a pop-up to do this automatically when working from this directory.Linux/macOSsource.env3.11/bin/activateWindows.env3.11\Scripts\activateInstall tesseract-ocron Linuxsudoaptinstalltesseract-ocron macOSbrewinstalltesseracton Windows, download the latest installers fromhttps://github.com/UB-Mannheim/tesseract/wikiInstall other dependencies.pipinstall-rcommon/requirements.txtInstall the pre-commit hooks.pre-commitinstallInstall the package.  Note that this installs the package as editable, so
edits will be automatically reflected in the installed package.pipinstall-e.[dev]Run the tests.pytestMake changes ...Deactivate the virtual environment.deactivate
Package: generic-heap
ï»¿
HeapHeap data structure,Gives a feel like using priority queue in Java and C++.
crete instance Heap(List,Key) Key can be any lambda or other functionEg:-do not mix datatypes other wise error may happen
other wise customize the func to handle multipel datatypesdef func(x):customize the function as you wish and returnl =[el1,el2,…….,eln]Initialization
heap = Heap(l,key = lambda x: func(x)) <- user negative return value to implement max_hap , by default min_heapEg:-heap = Heap(l,key = lambda x: func(x)) <- min heap
heap = Heap(l,key = lambda x: -func(x)) <- max heapheap.show() <- it shows the entire heapheap.size() <- returns the size of the heap(no of element it contains)heap.push(x) <- enter an elementheap.pop() <- removes and returns the top most elementheap.peek() <- returns the top element without removing itheap.empty() <- returns whether heap is empty or notInstallationcopy from PyPi and paste to cmd and enterHow to use it?Import it in python script and use by creating Heap class Instance
from generic_heap import HeapLicenseCopyright 2021 Pritam SarkarThis repository is licensed under the MIT license. See LICENSE for details.Change Log0.0.1 (18/07/2021)First Release1.0.1 (09/08/2021)First Release
Package: generic-iterative-stemmer
Word embedding: generic iterative stemmerA generic helper for traininggensimandfasttextword embedding models.Specifically, this repository was created in order to
implementstemmingon a Wikipedia-based corpus in Hebrew, but it will probably also work for other
corpus sources and languages as well.Importantto note that while there are sophisticated and efficient
approaches to the stemming task, this repository implements a naive approach
with no strict time or memory considerations (more about that in
theexplanation section).Based onhttps://github.com/liorshk/wordembedding-hebrew.SetupCreate apython3virtual environment.Install dependencies usingmake install(this will run tests too).UsageThe general flow is as follows:Get a text corpus (for example, from Wikipedia).Create a training program.Run aStemmingTrainer.The output of the training process is ageneric_iterative_stemmer.models.StemmedKeyedVectorsobject
(in the form of a.kvfile). It has the same interface as the standardgensim.models.KeyedVectors,
so the 2 can be used interchangeably.0. (Optional) Set up a language data cachegeneric_iterative_stemmeruses a language data cache to store its output and intermediate results.The language data directory is useful if you want to train multiple models on the same corpus, or if you want to
train a model on a corpus that you've already trained on in the past, with different parameters.To set up the language data cache, runmkdir -p ~/.cache/language_data.Tip: soft-link the language data cache to your project's root directory,
e.g.ln -s ~/.cache/language_data language_data.1. Get a text corpusIf you don't a specific corpus in mind, you can use Wikipedia. Here's how:Under~/.cache/language_datafolder, create a directory for your corpus (for example,wiki-he).Download Hebrew (or any other language) dataset from Wikipedia:Go towikimedia dumps(in the URL, replacehewith
yourlanguage code).Download the matchingwiki-latest-pages-articles.xml.bz2file, and place it in your corpus directory.Create initial text corpus: run the script insidenotebooks/create_corpus.py(change parameters as needed).This will create acorpus.txtfile in your corpus directory. It takes roughly 15 minutes to run (depending on the
corpus size and your computer).2. Create a training programTODO3. Run aStemmingTrainerTODO4. Play with your trained modelPlay with your trained model usingplayground.ipynb.Generic iterative stemmingTODO: Explain the algorithm.
Package: generic-lexer
Generic LexerA generic pattern-based Lexer/tokenizer tool.The minimum python version is 3.6Original AuthorEli Benderskywiththis gistlast modified on 2010/08MaintainerLeandro Benedet Garcialast modified on 2020/11Version1.1.0LicenseThe UnlicenseDocumentationThe documentation can befound hereExampleIf we try to execute the following code:fromgeneric_lexerimportLexerrules={"VARIABLE":r"(?P<var_name>[a-z_]+): (?P<var_type>[A-Z]\w+)","EQUALS":r"=","SPACE":r" ","STRING":r"\".*\"",}data="first_word: String =\"Hello\""data=data.strip()forcurr_tokeninLexer(rules,False,data):print(curr_token)Will give us the following output:VARIABLE({'var_name':'first_word','var_type':'String'})at0SPACE()at18EQUALS(=)at19SPACE()at20STRING("Hello")at21As you can see differently from the original gist, we are capable of specifying multiple groups per token.
You cannot use the same group twice,
either per token or not because all the regex patterns are merged together to generate the tokens later on.You may get the values of the tokens this way:>>>fromgeneric_lexerimportLexer>>>rules={..."VARIABLE":r"(?P<var_name>[a-z_]+): (?P<var_type>[A-Z]\w+)",..."EQUALS":r"=",..."STRING":r"\".*\"",...}>>>data="first_word: String =\"Hello\"">>>variable,equals,string=tuple(Lexer(rules,True,data))>>>variableVARIABLE({'var_name':'first_word','var_type':'String'})at0>>>variable.val{'var_name':'first_word','var_type':'String'}>>>variable["var_name"]'first_word'>>>variable["var_type"]'String'>>>equalsEQUALS(=)at19>>>equals.val'='>>>stringSTRING("Hello")at21>>>string.val'"Hello"'
Package: generic_oauth
# Generic Oauth## Description`generic_oauth` makes it extremely simple to use any OAuth v2 API purely from the command line. With any of the provided implementations you can get an access token in just 2 lines of code.Typically browsers are a required component of the Oauth flow—APIs use html pages to allow users to grant permisson to third party apps to make requests on their behalf. This makes it easy for web-apps to use oauth apis, but difficult and clunkly for command-line apps to use these services.With `generic_oauth` you can synchronosly generate access_tokens for any oauth api with just a few lines of code.Implementations included:- Google- Github- Facebook- Spotify## Sample Usage```import secretsimport requestsfrom generic_oauth import SpotifyOAuth# Get a spotify access_token in just 2 lines.o = SpotifyOAuth(secrets.client_id, secrets.client_secret, secrets.redirect_uri, secrets.scope_string)access_data = o.get_access_code()headers = {'Authorization': 'Bearer ' + access_data['access_token']}r = requests.get('https://api.spotify.com/v1/me', headers=headers)print r.json()```## Documentation`OAuthWebFlowController` is an abstract class responsible for handling the bulk of the oauth 2.0 web flow. To implement a handler for an OAuth api not already included, you will need to make a subclass of this class and override the `authorization_url()` and `parse_temp_code()` methods.`OAuthWebFlowController` creates a temporarly local HTTP server to accept data sent to the `redirect_uri`. The default `redirect_uri` supported is http://localhost:5555. If you would like to use a different url, you will need to change the `port` param in the `__init__` method. For example if you use http://localhost:4321, you would set port=4321.## How to include in projectTODO
Package: generic-parser
Generic ParserThe package provides an all-around parser for arguments and config-files.
The creation of the arguments is similar to the ones from argparse, but the input can then be either from command line, a config file or directly from python.See theAPI documentationfor details.InstallingInstallation is easily done viapip. The package is then used asgeneric_parser.python-mpipinstallgeneric-parserOne can also install in acondaenvironment via theconda-forgechannel with:condainstall-cconda-forgegeneric_parserExample Usage:Content ofmyscript.pyfromgeneric_parserimportentrypoint,EntryPointParametersdefget_arguments():args=EntryPointParameters()args.add_parameter(name="first",flags=["-f","--first"],help="First Parameter, an int",choices=[1,2,3],type=int,required=True,)args.add_parameter(name="second",flags=["-s","--second"],help="Second Parameter, a string",type=str,default="default",required=False,)returnargs@entrypoint(get_arguments())defmain(opt,unknown):print(opt.first==1)print(opt.second=="default")if__name__=='__main__':main()CommandlineCalling that script withpython myscript.py -f 1 -s "test"will result in:True
FalseIt is assumed, that this is the standard mode of operation for your functions.Config FileFurther, one can also use a config fileconfig.inicontaining:[Section]
first = 2
second = "Hello"and run the script withpython myscript.py --entry_cfg config.inileading toFalse
FalseConfig files are very useful if you want to rerun your code with the same or similar parameters.
Especially the declaration of a[DEFAULT]section can be helpful.
For further information about config files, check the pythonConfig Parser.PythonOr call the function directly from python code:if__name__=='__main__':main(first=1,second="World")True
FalseThis is incredibly helpful if one wants to write python-wrappers around entrypoint-functions,
and does not want to resort to commandline calls from python.Note that also in this case all variables are validated, courtesy of thedict_parser.dict_parserprovides even multi-level dictionary checking functionality,
which is not used in theEntrypoint, but can be handy in other use-cases.LicenseThis project is licensed under the MIT License - see theLICENSE.mdfile for details
Package: generic-pool
generic-poolgeneric-pool is a generic object pool for python inspired by the node.js library.You can use it to build your own resource pools, e.g. to manage file handles, connections or similar.InstallInstallgeneric-poolfrom pypi using your favourite package manager.# If you use poetrypoetryaddgeneric-pool# If you use pippipinstallgeneric-poolUsagefromrandomfromgeneric_poolimportFactoryfromgeneric_poolimportPoolclassIntValue:def__init__(self):self.value=random.randpassclassFortyTwoFactory(Factory):defcreate(self)->IntValue:returnIntValue()defvalidate(self,item:IntValue)->bool:returnitem.value==42defdestroy(self):# free resources, not applicable herepassfactory=FortyTwoFactory()pool=Pool(factory)item=pool.acquire()try:assertitem.value==42finally:pool.release(item)withpool.acquire(item):assertitem.value==42LicenseMIT
Package: generic-request-signer
I simple utility to sign http requests given some private keyTo run the python testspip install -r requirements/test.txtnosetestsTo run the example using flaskpip install -r requirements/example.txtpython app.pyopen a browser and point tohttp://localhost:5000/After you invoke the GET request above you should see a request in the terminalGET /verify?__client_id=example&username=foo&password=bar&__signature=somestrangestuffhereThis shows the client in action but at this time our example does not truly verify the signed request
Package: generics
GenericsA classy toolkit designed with OOP in mind.Documentation|Source Code|Task TrackerIn our opinion, main benefits of having objects implemented in the language are
encapsulation and polymorphous. Classes that could be easily used in a
composition are tricky to write. Thegenericslibrary aims to help you in
writing code with high quality.ProsReal private attributes without loosing the readabilityLeads to a better design forcing you to use encapsulation properlyMakes writing quality code with high cohesion and low coupling easierGuides you to follow SOLID principlesExampleThegenericslibrary gives you an easy way to define private attributes on
objects without loosing little nice things like readability.>>>fromgenericsimportprivate>>>@private...classUser:...def__init__(self,name):...self.name=name......defgreet(self):...returnf"Hello,{self.name}">>>user=User("Jeff")>>>user.greet()'Hello, Jeff'>>>hasattr(user,"name")FalseQuestionsIf you have any questions, feel free to create an issue in ourTask Tracker. We have thequestion labelexactly for this purpose.Enterprise supportIf you have an issue with any version of the library, you can apply for a paid
enterprise support contract. This will guarantee you that no breaking changes
will happen to you. No matter how old version you're using at the moment. All
necessary features and bug fixes will be backported in a way that serves your
needs.Please contactproofit404@gmail.comif you're
interested in it.Licensegenericslibrary is offered under the two clause BSD license.— ⭐ —
Package: generic-server
Generic-ServerPython generic TCP/UDP server implementation, with configurable request-response modules (e.g, 'ok', 'reflect', 'json').Status:BetaAuthors:Carsten KönigPurposeSometimes you need a TCP or UDP server that answers with a specific strings to a given request.  For testing different network components in a lab environment, some components in the network might not be available. In order to simulate their presence, Generic-Server answers TCP or UDP string requests using modules either with pre-defined responses or simulated behaviour.Installationpipinstallgeneric-serverHow to useIn order to start a Generic-Server, start the server with the desired config:genericserver<protocol><port><responder>protocol: either TCP or UDPport: port to listen onresponder: one out of 'ok', 'reflect', 'manual' or 'json'ok:         Always sends 'ok' as an answer.reflect:    Reflects the request string back to the sender.manual:     Prompts the user to manually enter an answer.json:       Get answers from a json document. For nested json, a delimiter
can be chosen (default ':').Example:{"test":{"a":"1","b":2}}Request:test:aResponse:1LicenseGNU GPLv3 LicenseAuthorCarsten KönigGitLabGitHubLinkedInWebsite
Package: genericsetup.quickinstaller
OverviewGeneric setup import step that installs products inportal_quickinstaller.
This is useful if you depend on a product that does not have a generic setup
profile.In that case, you can create a fileproducts.xml<?xml version="1.0"?>
<products>
  <installs>
    <product name="FCKeditor" />
  </installs>
</products>This will installFCKeditorproduct.Changelog0.2 (2011-05-02)Added svn ignore settings [spereverde]Removed deprecation warning [spereverde]0.1 (2009-03-12)Added import step
[gotcha]Created recipe with ZopeSkel
[gotcha]ContributorsGodefroid Chapelle for K.U.Leuven ICTSWMS team - K.U.Leuven ICTSDownload