Saravanan666/pypi-org huggingface dataset:
Package: pyjon.events
What is it ?Pyjon.Events is an easy-to-use event dispatcher metaclass for your objects :
Just add it to any of your class, and you can add event listeners and dispatch events.You can define arguments passed to your listener when you add it.
You can also define argument passed to the listener when emiting an event.ExampleFor our example, we will define a person class.
Just import the module, and add it to your class (Python2 example):from pyjon.events import EventDispatcher

class Person(object):
    __metaclass__ = EventDispatcher

    def __init__(self, name):
        # just a sample initialization, you can do whatever you want, of course.
        self.name = name

    def run(self, meters=1):
        print "I'm running for %d meters !" % meters
        self.emit_event('ran', meters)
        self.emit_event('moved', meters=meters)

    def walk(self, meters=1):
        print "I'm walking for %d meters !" % meters
        self.emit_event('walked', meters)
        self.emit_event('moved', meters=meters)

    def sleep(self):
        print "sleeping..."
        self.emit_event('sleeping')
        time.sleep(5)
        self.emit_event('sleeped')
        print "Wow... had a good night !"For Python3, just replace this:class Person(object):
    __metaclass__ = EventDispatcherwith this:class Person(metaclass = EventDispatcher):Now, let’s instanciate our class and subscribe to events:>>> henry = Person('henry')

>>> def handle_movement(meters=None):
...     print "he moved for %d meters" % meters

>>> def handle_person_movement(who, meters=None):
...     print "%s moved for %d meters" % (who, meters)

>>> henry.add_listener('moved', handle_movement)

>>> henry.add_listener('moved', handle_person_movement, "henry")

>>> henry.walk(5)
I'm walking for 5 meters !
he moved for 5 meters
henry moved for 5 meters

>>> def handle_advanced_movement(meters, who, movement_type):
...     print "%s %s for %d meters" % (who, movement_type, meters)

>>> henry.add_listener('walked', handle_advanced_movement, "henry", "walked")

>>> henry.add_listener('ran', handle_advanced_movement, "henry", "ran")

>>> henry.walk(5)
I'm walking for 5 meters !
henry walked for 5 meters
he moved for 5 meters
henry moved for 5 meters

>>> henry.run(5)
I'm running for 5 meters !
henry ran for 5 meters
he moved for 5 meters
henry moved for 5 metersThat’s simple isn’t it ?Changelog1.0 - UnreleasedInitial release1.1 - First public releaseSupport of events with keyword argumentsAdded documentation1.1.1 - Bugfix releaseMANIFEST.in fixDocs fixes1.2 - Python 3 compatible !Now works with Python 3 !
Package: pyjon.versionning
Pyjon.Versionning is a little helper to use mercurial to version objects in your application.Those objects can be stored in a database for example, allowing changes from the filesystem to be synchronised in the database and the other way around (while maintaining an history).Versionning managers are classes that get a repository folder and initialize it if not existing yet.The base managers available are :pyjon.versionning.Repository: the base repository.pyjon.versionning.SARepository: the base repository to version sqlalchemy objects.Basically, the default classes assume you have a payload or payload_xml field in your objects, and this field will get written to file.If you want to have other field (or version your whole object serializing it as json for example), you have to create your own repository class basen on the base one.Example using a simple json serializerimport simplejson
from myapp import get_vehicles, get_people, get_adresses
from pyjon.versionning import Repository

# for an sqlalchemy repository :
# class MyRepository(SARepository):
# for a normal one (or manual fetching) :
class MyRepository(Repository):
     def get_file_content(self, item):
        # we will assume your objects have an "serializable_fields" attribute
        # this is to support multiple object types (each object type will be stored in a separate folder)

        output_dict = dict()
        for field in item.serializable_fields:
            output_dict[field] = getattr(item, field)

        return simplejson.dumps(output_dict)



    def update_content(self, item, value):

        input_dict = simplejson.loads(value)
        for field in item.serializable_fields:
            setattr(item, field, input_dict[field])

        return simplejson.dumps(my_output_dict)

    # this is used to init the repository with all existing data
    # not necessary with SARepository as it will do it himself with the given classes and dbsession
    def get_all_objects(self):
        for item in get_vehicle():
            yield item

        for item in get_people():
            yield item

        for item in get_adresses():
            yield itemTo call it, here is how# it's thread safe, so you can define it as a global var (imported like "from my_app.versionning import repository")
repository = MyRepository('./repository',
                          default_user="our_great_app <system@ourgreatapp.com>")

# if you have an SARepository, here is how to call it:
from my_app.model import session, vehicles, people, adresses
repository = MyRepository('./repository', session,
                          [vehicles, people, adresses],
                          default_user="our_great_app <system@ourgreatapp.com>")

# now, before using an item in your app (to check changes in the repo), just do that:
repository.check_item(item)

# after saving or creating an item:
repository.store_item(item) # you can define user= to specify the user who did that

# after deleting an item:
repository.delete_item(item) # you can define user= to specify the user who did that
Package: pyjoptional
PyJOptionalA Python module providing thePyOptionalclass/type, a Java-likeOptionalwrapper for Python values.HOWTOuser@machine:~$pipinstallpyjoptionalfrompyoptional.pyoptionalimportPyOptionalp:PyOptional[int]=PyOptional.of(1)p1:PyOptional=PyOptional.of_nullable(None)p2:PyOptional=PyOptional.empty()Comparison with the JavaOptionalPyOptional.of()corresponds toOptional.of().PyOptional.of_nullable()corresponds toOptional.ofNullable().PyOptional.empty()corresponds toOptional.empty().PyOptional.is_empty()corresponds toOptional.isEmpty().PyOptional.is_present()corresponds toOptional.isPresent().PyOptional.filter()corresponds toOptional.filter().PyOptional.get()corresponds toOptional.get().PyOptional.or_else()corresponds toOptional.orElse().PyOptional.or_else_get()corresponds toOptional.orElseGet().PyOptional.or_else_raise()corresponds toOptional.orElseThrow()(both with and without a suppliedException).PyOptional.or_else_throwis an alias ofOptional.or_else_raise.PyOptional.or_new_pyoptional()corresponds toOptional.or()(becauseoris a Python keyword).PyOptional.if_present()corresponds toOptional.ifPresent().PyOptional.if_present_or_else()corresponds toOptional.ifPresentOrElse().PyOptional.map()corresponds toOptional.map().PyOptional.flatMap()corresponds toOptional.flatMap().Additionally,PyOptional.__eq__,PyOptional.__hash__,PyOptional.__str__, andPyOptional.__repr__override the default Python implementation of such methods, much like the JavaOptional.equals(),Optional.hashCode(), andOptional.toString()methods.Finally, there is no correspondent of the JavaOptional.stream()method, as Python has no nativeStreamclass.Comparison with the PythonOptionalThe native PythonOptional[SomeType]type is just syntactic sugar forSomeType | None. Therefore, it does not provide any of the API methods ofPyOptional.
Package: pyjoulescope-driver
Joulescope DriverWelcome to the Joulescope™ Driver project.Joulescopeis an affordable, precision DC energy
analyzer that enables you to build better products.This user-space C library communicates with Joulescope products to configure
operation and receive data.  The first-generation driver introduced in 2019 was
written in Python.  While Python proved to be a very flexible language enabling
many user scripts, it was difficult to support other languages.This second-generation driver launched in 2022 addresses several issues
with the first-generation python driver including:Improved event-driven API based upon PubSub for easier integration with
user interfaces and other complicated software packages.Improved portability for easier language bindings.Improved performance.For more information, see:source codedocumentationpypiJoulescope(Joulescope web store)jls(Joulescope file format)forumPython InstallationThe python bindings work with Python 3.9 and later.
To use the python bindings, ensure that you have a compatible version
of python installed on your host computer.  Then:python -m pip install pyjoulescope_driverFor Ubuntu, you will also need toinstall the udev rules.You can then run the pyjoulescope_driver python entry points:python -m pyjoulescope_driver --help
python -m pyjoulescope_driver scan
python -m pyjoulescope_driver info
python -m pyjoulescope_driver info * --verboseNote that you may need to change "python" to "python3" or the full path.You can also use a pythonvirtual environment.BuildingEnsure that your computer has a development environment including CMake.WindowsInstall cmake and your favorite build toolchain such as
Visual Studio, mingw64, wsl, ninja.macOSFor macOS, install homebrew, then:brew install pkgconfig python3Ubuntu 22.04 LTSFor Ubuntu:sudo apt install cmake build-essential ninja-build libudev-devYou will also need to install the udev rules:$ wget https://raw.githubusercontent.com/jetperch/joulescope_driver/main/99-joulescope.rules
$ sudo cp 99-joulescope.rules /etc/udev/rules.d/
$ sudo udevadm control --reload-rulesCommoncd {your/repos/joulescope_driver}
mkdir build && cd build
cmake ..
cmake --build . && ctest .This package includes a command-line tool, jsdrv:jsdrv --help
jsdrv scanBuild python bindingsInstall a compatible version of Python 3.9 or later.  To install
the pyjoulescope_driver dependencies:cd {your/repos/joulescope_driver}
python -m pip install -U requirements.txtYou should then be able to build the native bindings:python setup.py build_ext --inplaceYou can build the package using isolation:python -m buildDepending upon your system configuration, you may need to replace
"python" with "python3" or the full path to your desired python installation.On Windows, you may be prompted to install theMicrosoft C++ Build Tools.
Package: pyjournalctl
A python module that reads systemd journal similar to journalctlRequirementspython2 >= 2.7 or python3systemd >= 187Installationpython setup.py installLicenseGNU Lesser General Public License v2.1Usage Examples>>> import pyjournalctl
>>> journal = pyjournalctl.Journalctl()
>>> journal.add_matches({"PRIORITY": "5", "_PID": "1"})
>>> entry = journal.get_next()
>>> print("PRIORITY: %(PRIORITY)i" % entry)
PRIORITY: 5
>>> print("_PID: %(_PID)i" % entry)
_PID: 1
>>> print("MESSAGE: %(MESSAGE)s" % entry) # doctest: +ELLIPSIS
MESSAGE: ...
>>>
>>> journal.flush_matches()
>>> journal.seek(100) # 100 entries from start
>>> journal.add_match("_TRANSPORT", "kernel")
>>> journal.add_disjunction() # OR next matches
>>> journal.add_match("PRIORITY", "5")
>>> journal.add_match("_UID", "0")
>>> entry = journal.get_next(2) # Get second match
>>> entry.get("_TRANSPORT") == "kernel" or (
...     entry.get('PRIORITY') == 5 and entry.get("_UID") == 0)
True
>>>
>>> cursor = entry['__CURSOR'] # Cursor is unique reference
>>> journal.flush_matches()
>>> journal.seek(0,2) # End of journal
>>> entry2 = journal.get_previous()
>>> entry2['__CURSOR'] == cursor
False
>>> entry2 == entry
False
>>> journal.seek_cursor(cursor) # Seek to unique reference
>>> journal.get_next() == entry
True
>>> realtime = entry['__REALTIME_TIMESTAMP']
>>> journal.get_next(10) == entry
False
>>> journal.seek_realtime(realtime)
>>> journal.get_next() == entry
True
>>> monotonic = entry['__MONOTONIC_TIMESTAMP']
>>> bootid = entry['_BOOT_ID']
>>> journal.get_next(5) == entry
False
>>> journal.seek_monotonic(int(monotonic.total_seconds()*1E6), bootid)
>>> journal.get_next() == entry
True
>>> journal.flush_matches()
>>> journal.seek(-1000,2) # Last 1000 entries
>>> priorities = set(range(0,5))
>>> journal.log_level(4) # Log level from 0 - 4
>>> priorities >= set(entry['PRIORITY'] for entry in journal)
True
>>> systemd_units = journal.query_unique("_SYSTEMD_UNIT")
>>> print("Unique systemd units in journal: %s" % ', '.join(systemd_units)) # doctest: +ELLIPSIS
Unique systemd units in journal: ...
>>> len(systemd_units) == len(set(systemd_units))
True
>>> journal.flush_matches()
>>> journal.this_boot() # Only log entries from this boot
>>> journal.seek(0) # First entry
>>> entry = journal.get_next()
>>> journal.seek(0,2) # Last entry
>>> journal.get_previous()['_BOOT_ID'] == entry['_BOOT_ID']
True
>>> journal.flush_matches()
>>> journal.seek(-1000,2) # Last 1000 entries
>>> journal.this_machine() # Only log entries for this machine
>>> len(set(entry['_MACHINE_ID'] for entry in journal))
1Known Issuesseek_monotonicseems to ignorebootidparameter. Can use seek monotonic by setting “_BOOT_ID” filter. Currently suspect this is issue with systemd c APIsd_journal_seek_monotonic_usec…TODO
Package: pyjourney
PyJourneyA python module for calling the Midjourney API to get job details and for creating jobs.Currently just trying to fixmidjourney-graphand figured i'd break out the api calls into a module.pypiTODOmore than 35 jobs at a time.jobs by date range, type, and for other usersget sepcific job details for a job and a list of jobsget the list of community jobs by hot, new, trending, etc.Searching for jobs by title, description, and tagsInstallationpipinstallpyjourneySetupCreate a .env file in the root of your project and add the following:MIDJOURNEY_COOKIE=your_cookieMIDJOURNEY_USERID=your_userIdThe userID should be the newer GUID version of the userid, not the old integer version.
The cookie can be taken from the cookie header in your browser when you're logged in to Midjourney for any request against the API.UsagefrompyjourneyimportMidjourneyAPIapi=MidjourneyAPI()#Loads your cookie and userId from the .env file  (required for now.)request=api.recent_jobs()# Defaults to fetching the most recent 35 jobs you've done.print(request.status_code)# request.json() should work if this is 200 :)
Package: pyjoystick
Python joystick event handler.Simple Examplefrompyjoystick.sdl2importKey,Joystick,run_event_loopdefprint_add(joy):print('Added',joy)defprint_remove(joy):print('Removed',joy)defkey_received(key):print('Key:',key)run_event_loop(print_add,print_remove,key_received)Qt IntegrationThe code below displays a label with the most recent key’s value.
A green ball will move around as you press the HAT button on the controller.# App with a green ball in the center that moves when you press the HAT buttonsimportpyjoystickfrompyjoystick.sdl2importKey,Joystick,run_event_loop# from pyjoystick.pygame import Key, Joystick, run_event_loopfromqt_thread_updaterimportThreadUpdaterfromqtpyimportQtWidgets,QtGui,QtCoreapp=QtWidgets.QApplication()updater=ThreadUpdater()main=QtWidgets.QWidget()main.setLayout(QtWidgets.QHBoxLayout())main.resize(800,600)main.show()lbl=QtWidgets.QLabel()# Absolute positioningmain.layout().addWidget(lbl,alignment=QtCore.Qt.AlignTop)mover=QtWidgets.QLabel(parent=main)# Absolute positioningmover.resize(50,50)mover.point=main.rect().center()mover.move(mover.point)mover.show()defsvg_paint_event(self,event):painter=QtGui.QPainter(self)painter.setRenderHint(painter.Antialiasing,True)# Get Black Backgroundrect=self.rect()center=rect.center()radius=20# Colorspainter.setBrush(QtGui.QColor('green'))# Fill colorpainter.setPen(QtGui.QColor('black'))# Line Color# Drawpainter.drawEllipse(center,radius,radius)painter.end()mover.paintEvent=svg_paint_event.__get__(mover,mover.__class__)defhandle_key_event(key):updater.now_call_latest(lbl.setText,'{}:{}={}'.format(key.joystick,key,key.value))# print(key, '-', key.keytype, '-', key.number, '-', key.value)ifkey.keytype!=Key.HAT:returnifkey.value==Key.HAT_UP:mover.point.setY(mover.point.y()-10)elifkey.value==Key.HAT_DOWN:mover.point.setY(mover.point.y()+10)ifkey.value==Key.HAT_LEFT:mover.point.setX(mover.point.x()-10)elifkey.value==Key.HAT_UPLEFT:mover.point.setX(mover.point.x()-5)mover.point.setY(mover.point.y()-5)elifkey.value==Key.HAT_DOWNLEFT:mover.point.setX(mover.point.x()-5)mover.point.setY(mover.point.y()+5)elifkey.value==Key.HAT_RIGHT:mover.point.setX(mover.point.x()+10)elifkey.value==Key.HAT_UPRIGHT:mover.point.setX(mover.point.x()+5)mover.point.setY(mover.point.y()-5)elifkey.value==Key.HAT_DOWNRIGHT:mover.point.setX(mover.point.x()+5)mover.point.setY(mover.point.y()+5)updater.now_call_latest(mover.move,mover.point)# If it button is held down it should be repeatedrepeater=pyjoystick.HatRepeater(first_repeat_timeout=0.5,repeat_timeout=0.03,check_timeout=0.01)mngr=pyjoystick.ThreadEventManager(event_loop=run_event_loop,handle_key_event=handle_key_event,button_repeater=repeater)mngr.start()# Find key functionalitybtn=QtWidgets.QPushButton('Find Key:')deffind_key():key=mngr.find_key(timeout=float('inf'))ifkeyisNone:btn.setText('Find Key:')else:btn.setText('Find Key:{}={}'.format(key,key.value))btn.clicked.connect(find_key)main.layout().addWidget(btn,alignment=QtCore.Qt.AlignTop)app.exec_()
Package: pyjpegls
pyjpeglsNoteThis is a fork of theoriginal CharPyLS repositorycreated
to be able to add fixes and adaptions, as that repo is not maintained anymore. The rest
of this file is unchanged from the original readme.JPEG-LS for Python via CharLS C++ LibraryI wrote this interface to enable easy access to the awesomeJPEG-LSlossless image compression algorithm from within my Python application.  I had no need to read/write anyone else's JPEG-LS image files, but rather I needed to compress some data structures internal to my application.  This data was similar in nature to greyscale imagery such that it was an easy choice to leverage the existing CharLS C++ library I found oncodeplex.com.  I did eventually incorporate some basic file I/O functionality for my unit tests, and that's why I list Pillow below as a dependency.I have tested this code on Windows 7 x64, Windows 8 x64, and Ubuntu x64.  Note, even though this package has the odd name "CharPyLS", you will import it into your module as "jpeg_ls".  Here is a quick example of using this tool to compress an image to a buffer in memory.  For more details, check out the examples included within the source code.# Read in an image from an existing PNG file.fname_img='test/image.png'data_image=data_io.read_PIL(fname_img)# Compress image data to a sequence of bytes.data_buffer=jpeg_ls.encode(data_image)# Sizes.size_png=os.path.getsize(fname_img)print('Size of RGB 8-bit image data:{:n}'.format(len(data_image.tostring())))print('Size of PNG encoded data file:{:n}'.format(size_png))print('Size of JPEG-LS encoded data:{:n}'.format(len(data_buffer)))# Decompress.data_image_b=jpeg_ls.decode(data_buffer)# Compare.is_same=(data_image==data_image_b).all()print('Restored data is identical to original:{:s}'.format(str(is_same)))The output generated by the above example should look like the following:Size of RGB 8-bit image data:  5038848
Size of PNG encoded data file: 2409950
Size of JPEG-LS encoded data:  2088357
Restored data is identical to original: TrueAbout JPEG-LSFromWikipedia article: JPEG-LS (ISO-14495-1/ITU-T.87) is an accepted lossless image compression standard derived from theHewlett Packard LOCO algorithm.FromCharLS codeplex site: CharLS is an optimized implementation of the JPEG-LS standard for lossless and near-lossless image compression. JPEG-LS is a low-complexity standard that matches JPEG 2000 compression ratios. In terms of speed, CharLS outperforms open source and commercial JPEG LS implementations.DependenciesNumpyCython (only for building and installing, not for everyday use)Pillow (friendly fork of PIL, used here for file I/O with the example and during unit tests)CharLS (source included as subfolder)
Package: pyjpegoptim
What is PyJpegOptim?PyJpegOptim is a utility for optimizing JPEG files.
It provides lossless optimization (based on optimizing the Huffman tables) and “lossy” optimization based on setting a maximum quality factor.InstallationYou need to install libjpeg first, To install JpegOptim:Debian:apt-get install libjpeg-dev -yFreeBSD:cd /usr/ports/graphics/jpeg
make install cleanTo install PyJpegOptim:pip install pyjpegoptimHow to use it?Following is a simple example:# -*- coding: utf8 -*-
from pyjpegoptim import JpegOptim
t = JpegOptim('/tmp/test.jpg', quality=80)
t.save('/tmp/test_optim.jpg')
t.close()
Package: pyjpgclipboard
pyjpgclipboardPlatform Unit TestsBriefCross platform clipboard for handling copy/paste jpg in pythonThis libray is meant to do only one thing and one thing well: copy jpg's to and from the
system clipboard.Installpython -m pip install pyjpgclipboardUbuntu/LinuxThe ubuntu lib usesxclipsudo apt-get install xclipIf you are running in a headless display you'll need a dummy x-server running to use xclip. Please install it using this:export DISPLAY=:0
sudo Xvfb -ac :0 -screen 0 1280x1024x24 > /dev/null 2>&1 &Apifrom pyjpgclipboard import clipboard_dump_jpg, clipboard_load_jpg

clipboard_load_jpg("myfile.jpg") # Clipboard now has jpg image
clipboard_dump_jpg("myfile2.jpg) # Clipboard image contents dumped to disk.TestingMake sure thattoxis installed on your system and run it at the root directory of this project.Will pyjpgclipboard support more features?Probably not. Unless it'sreallyimportant.We only support jpg images (and not any other formats or text) because manipulating the system
clipboard across different platforms ishard. As of the creation of this repo there really
isn't any library that allows users to copy / paste jpegs. There are a lot of libraries that
allow cross platform posting of text and binary data. So this library is intended to fill in that
gap. Libraries likepyclipshould, in the future, usepyjpgclipboardto handle the missing jpg
clipboard manipulation.What motivatated this library?Selenium webdriver tests has a missing feature of taking an image and pasting it through it's
api.This is a problem if you are running a selenium test and you need to be able to test pasting
an image as part of your test suite (hence the motivation to create this library).FootgunsThere is only one system clipboard. So running this library in different threads/processes will
result in collisions. It's up to the application running this library to provide any necessary
locking mechanism.Versions1.0.3: Ubuntu implemented and tested to work on headless display1.0.2: Now installs on linux. Before it would error. But not all codepaths that include this library will actually use it.1.0.1: Bug fix1.0.0: Release.
Package: pyjpmesh
Japan grid square code (JIS X 0410) utility for Python.FeaturesSupports the meshes below.1st mesh (jpmesh.FirstMeshclass, about 80 km square).2nd mesh (jpmesh.SecondMeshclass, about 10 km square).3rd mesh (jpmesh.ThirdMeshclass, about 1 km square).1/2 mesh (jpmesh.HalfMeshclass, about 500 m square).1/4 mesh (jpmesh.QuarterMeshclass, about 250 m square).1/8 mesh (jpmesh.OneEighthMeshclass, about 125 m square).Supports the calculations below.Mesh border coordinates from mesh codes.Mesh codes from coordinates.Consisted of only one file and depends on no other libraries,
which enable you to use it portably.InstallationChoose one from the following.Runpip install pyjpmesh.Putjpmesh.pyon your project.TutorialHere is an example to get the 1st mesh (about 8 km square) code
that a given point belongs to.fromjpmeshimportAngle,Coordinate,FirstMeshcoordinate=Coordinate(lon=Angle.from_degree(140.0),lat=Angle.from_degree(35.0))mesh=FirstMesh.from_coordinate(coordinate)printmesh.code# '5240'Here is another example to get the center point of the given mesh.fromjpmeshimportparse_mesh_codemesh=parse_mesh_code('5339')mesh_center=mesh.south_west+(mesh.size/2.0)printmesh_center.lon.degree,mesh_center.lat.degree# 139.5 35.667To use other mesh classes (SecondMesh, ThirdMesh, etc.),
use those classes instead of FirstMesh.