Saravanan666/pypi-org huggingface dataset:
Package: python-leetcode-runner
python_leetcode_runnerTest your leetcode Python solutions locally.Installationpip install python-leetcode-runnerUsageI have a beginner's guideover hereSay your solution fileadd_numbers.pylooks like this:classSolution:defaddNumbers(self,x:int,y:int)->int:returnx+yAll you need to add to the file is a few test cases, usually provided to you in the leetcode question description:classSolution:defaddNumbers(self,x:int,y:int)->int:returnx+ytests=[((2,4,),# input tuple6,# output),((45,67,),# input tuple112,# output),]Now, run the code locally by doing:> pyleet add_numbers.pyTest 1 - ([1, 2, 3])......................................................PASSEDTest 2 - ([4, 5, 6, 7])...................................................PASSEDCustom ValidatorsIn some questions, you don't just have to match expected output with function output. For eg, in some questions it might ask you to modify a list in-place, or some questions might have many acceptable answers.For that case, you can provide your own customvalidatorfunction.A validator is a function that receives 3 arguments:method: your leetcode solution functioninputs: your test inputs tupleexpected: your expected test output valueTo make assertions, you have to useassertstatements in the following way:assertoutput==expected,(output,expected)# this tuple is important!For example, let's add custom validation to theaddNumbersmethod:classSolution:defaddNumbers(self,nums:list[int])->int:returnsum(nums)tests=[(([1,2,3],),# input tuple6,# output),(([4,5,6,7],),# input tuple22,# output),]defvalidator(addNumbers,inputs,expected):nums=inputs[0]output=addNumbers(nums)assertoutput==expected,(output,expected)Here's a more elaborate example,remove_duplicates:classSolution:defremoveDuplicates(self,nums:list[int])->int:offset=0values:set[int]=set()forindex,numinenumerate(nums):nums[index-offset]=numifnuminvalues:offset+=1else:values.add(num)new_length=len(nums)-offsetreturnnew_lengthtests=[(([1,1,2],),(2,[1,2]),),(([0,0,1,1,1,2,2,3,3,4],),(5,[0,1,2,3,4]),),]defvalidator(removeDuplicates,inputs,outputs):nums,=inputslength,expected=outputsnew_length=removeDuplicates(nums)assertlength==new_length,(length,new_length)assertnums[:new_length]==expected,(nums[:new_length],expected)Run the file against sample inputs by doing:> pyleet remove_duplicates.pyTest 1 - ([1, 2, 2])......................................................PASSEDTest 2 - ([0, 1, 2, 3, 4, 2, 2, 3, 3, 4]).................................PASSEDCode SnippetsIf you're using VSCode, you can use the providedcode snippetsto help write the test cases faster.
Package: python-lefthandclient
HPE LeftHand/StoreVirtual REST ClientThis is a Client library that can talk to the HPE LeftHand/StoreVirtual Storage array.
The HPE LeftHand storage array has a REST web service interface as well as runs SSH.
This client library implements a simple interface to talk with that REST
interface using the python Requests http library and communicates via SSH using
Pytohn’s paramiko library.This is the new location for the rebranded HP LeftHand/StoreVirtual REST Client and
will be where all future releases are made. It was previously located on PyPi at:https://pypi.python.org/pypi/hplefthandclientThe GitHub repository for the old HP LeftHand/StoreVirtual REST Client is located at:https://github.com/hpe-storage/python-lefthandclient/tree/1.xThe HP LeftHand/StoreVirtual REST Client (hplefthandclient) is now considered deprecated.RequirementsThis branch requires 11.5 version or later of the LeftHand OS firmware.CapabilitiesGet Volume(s)Get Volume by NameCreate VolumeDelete VolumeModify VolumeClone VolumeGet Snapshot(s)Delete ShapshotGet Shapshot by NameCreate SnapshotDelete SnapshotClone SnapshotModify SnapshotGet Cluster(s)Get Cluster by NameGet Server(s)Get Server by NameCreate ServerDelete ServerAdd Server AccessRemove Server AccessMake Volume RemoteMake Volume PrimaryCreate Remote Snapshot ScheduleDelete Remote Snapshot ScheduleQuery Remote Snapshot ScheduleStop Remote Snapshot ScheduleStart Remote Snapshot ScheduleInstallationTo install:$ sudo pip install .Unit TestsTo run all unit tests:$ tox -e py27To run a specific test:$ tox -e py27 -- test/file.py:class_name.test_method_nameTo run all unit tests with Python 3.4:$ tox -e py34To run a specific test with Python 3.4:$ tox -e py34 -- test/file.py:class_name.test_method_nameTo run all unit tests with code coverage:$ tox -e coverThe output of the coverage tests will be placed into thecoveragedir.Foldersdocs – contains the documentation.hpelefthandlient – the actual client.py librarytest – unit testssamples – some sample usesDocumentationTo build the documentation:$ tox -e docsTo view the built documentation point your browser to:docs/html/index.htmlRunning SimulatorsManually run flask server (when config.ini unit=true):* WSAPI::$ python test/HPELeftHandMockServer_flask.py -port 5001 -user <USERNAME> -password <PASSWORD> -debugSSH:$ python test/HPELeftHandMockServer_ssh.py [port]
Package: python-Levenshtein
LevenshteinIntroductionThe Levenshtein Python C extension module contains functions for fast
computation of:Levenshtein (edit) distance, and edit operationsstring similarityapproximate median strings, and generally string averagingstring sequence and set similarity:warning: The package was renamed toLevenshteinand can be foundhere.
Thepython-Levenshteinpackage will continue to be updated alongside the new packageRequirementsPython 3.8 or laterInstallationpipinstalllevenshteinDocumentationThe documentation for the current version can be found athttps://rapidfuzz.github.io/Levenshtein/Support the projectIf you are using Levenshtein for your work and feel like giving a bit of your own benefit back to support the project, consider sending us money through GitHub Sponsors or PayPal that we can use to buy us free time for the maintenance of this great library, to fix bugs in the software, review and integrate code contributions, to improve its features and documentation, or to just take a deep breath and have a cup of tea every once in a while. Thank you for your support.Support the project throughGitHub Sponsorsor viaPayPal:.LicenseLevenshtein is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option)
any later version.See the fileCOPYINGfor the full text of GNU General Public License version 2.
Package: python-libdiscid
libdiscid Python bindingspython-libdiscid implements Python >= 3.6 bindings for libdiscid using Cython.DependencieslibdiscidCython (>= 0.15, optional)pkgconfig (optional)Note that the tarballs come with pre-built C source for the Cython module. So
Cython is only required if one builds python-libdiscid from the git repository
or if one wants to change anything in the Cython module.If pkgconfig is installed, setup.py uses libdiscid's pkg-config information to
set include directories, libraries to link, etc.Quick installation guidepython-libdiscid is available in some distributions:Debian/Ubuntu:apt-get install python3-libdiscid(Python 3)Fedora:dnf install python3-libdiscid(Python 3)python-libdiscid can be installed viapip:$ pip install python-libdiscidor by running:$ python3 setup.py installIf you just want to try it locally, run:$ python3 setup.py build_ext -iand hack right away. You can also run:$ python3 setup.py buildbut please make sure thatbuild/lib.*is insys.pathbefore the source
folder.A note for Windows usersThere are eggs available from PyPI that don't require the extension module to be
built. If these are used, it is still required to drop a working discid.dll inC:\WINDOWS\system32(or wherever it can be found).Usagefromlibdiscidimportreaddisc=read("/dev/cdrom")print("id:{}".format(disc.id))Licensepython-libdiscid is released under the MIT license. Check LICENSE for details.
Package: python-libfprint
RequirementsCython >= 0.27libfprint == 0.99.0Installpip install git+git://github.com/jdiego/python-libfprint.gitUsageimportfprintfprint.init()devices=fprint.DiscoveredDevices()iflen(devices)>0:dev=devices[0].open_device()print_data=dev.enroll_finger_loop()print_data=fprint.PrintData.from_data(print_data.data)result=dev.verify_finger_loop(print_data)assertresultisTruedev.close()
Package: python-libguess
libguessenables finding out in what encoding some text is for
given language. This library is especially useful for short text strings
that themselves don’t carry reliable encoding information, like ID3 tags
in MP3 files. For example we can encode the same Japanese string in 3
different encodings (UTF-8, SHIFT-JIS, EUC-JP) andlibguesswill
hopefully guess the encoding correctly just by looking at the first
few bytes of the given string.You can also use this as a regular command line program by giving
region as the first parameter and possible target files after that:Usage: python -m guess REGION [INPUT_FILE]

If input file name is not given, this program reads from the standard input.Functionsdetermine_encoding(in_string, region)Determines encoding of a string for the given language region.Arguments:in_string– a raw byte string for which encoding needs to be guessed.region– one of theREGION_*constants for which encoding is guessed.Returns:String value indicating the guessed encoding of in_string argument for given region orNoneif error happened.As an usage example we might see what happens when given Japanese
text in 2 different encodings:>>> import guess
>>> guess.determine_encoding(u'\u3042'.encode('euc-jp'), guess.REGION_JP)
'EUC-JP'
>>> guess.determine_encoding(u'\u3042'.encode('utf-8'), guess.REGION_JP)
'UTF-8'The output string of this function can be given directly
toiconv_open()C function and the resulting names should be
compatible with the encoding string ofstr.decode()function:>>> encoded_value = u'\u3042'.encode('shift-jis')
>>> encoding = guess.determine_encoding(encoded_value, guess.REGION_JP)
>>> encoding
'SJIS'
>>> encoded_value.decode(encoding)
u'\u3042'In case the given region name is invalid or the underlyinglibguess_determine_encoding()call fails for any other reason,
None value is returned:>>> encoding = guess.determine_encoding("asdf", "UNKNOWN")
>>> encoding is None
TrueUseREGION_*constants for region names.validate_utf8(in_string)Checks if the given string is a valid UTF-8 byte sequence.Arguments:in_string– a raw byte string to be inspected for UTF-8 validity.Return value:Trueif given string is a valid UTF-8 byte sequence,Falseotherwise.This function is included here for the completeness with libguess
interface. It gives more precise results for UTF-8 validity than
for example functions in glib.>>> import guess
>>> guess.validate_utf8(u'\u3042'.encode('EUC-JP'))
False
>>> guess.validate_utf8(u'\u3042'.encode('UTF-8'))
TrueRegion namesREGION_AR= ‘arabic’REGION_BL= ‘baltic’REGION_CN= ‘chinese’REGION_GR= ‘greek’REGION_HW= ‘hebrew’REGION_JP= ‘japanese’REGION_KR= ‘korean’REGION_PL= ‘polish’REGION_RU= ‘russian’REGION_TR= ‘turkish’REGION_TW= ‘taiwanese’
Package: python-libinput
This package provides a pure python wrapper forlibinput, a library that
handles input devices for display servers and other applications that need to
directly deal with input devices.It provides device detection, device handling,
input device event processing and abstraction.libinputdoes this by reading character files in/dev/input/, so to use
this package you need to run your code as root or to belong toinputgroup.Documentationhttps://python-libinput.readthedocs.io/Developmenthttps://github.com/OzymandiasTheGreat/python-libinputPackagehttps://pypi.org/project/python-libinput/
Package: python-liblockfile
A Python wrapper aroundliblockfile, usingctypes. You must have
theliblockfileshared library installed on your system. On Ubuntu,
this can be done with:sudo apt-get install liblockfile1For more information see theLaunchpad project page.Getting startedlockfile = os.path.join(args.output, ".lock")
with Lock.WithPID(lockfile) as lock, LockHolder(lock):
    ...
Package: python-libmaas
python-libmaasPython client API library made especially forMAAS.InstallationAll the dependencies are declared insetup.pyso this can be installed
withpip. Python 3.5+ is required.When working from master it can be helpful to use a virtualenv:$ python3 -m venv ve && source ve/bin/activate
$ pip install git+https://github.com/maas/python-libmaas.git
$ maas --helpReleases are periodically made toPyPIbut,
at least for now, it makes more sense to work directly from trunk.DocumentationDocumentation can be generated withmake docswhich publishes into thesitedirectory. Recent documentation is also published to theMAAS Client Library & CLI documentationsite.DevelopmentIt's pretty easy to start hacking onpython-libmaas:$ git clone git@github.com:maas/python-libmaas.git
$ cd python-libmaas
$ make develop
$ make testInstallingIPythonis generally a good idea too:$ bin/pip install -UI IPythonPull requests are welcome but authors need to sign theCanonical
contributor license agreementbefore those PRs can be merged.History & licenceIn short:AGPLv3.python-libmaaswas begun by a core MAAS developer, Gavin Panella, on
his own time, but is now maintained by the core MAAS team at Canonical.
It is licensed under the GNU Affero GPLv3, the same as MAAS itself.Some of the code in here has come from MAAS, upon which Canonical Ltd
has the copyright. Gavin Panella licenses his parts under the AGPLv3,
and MAAS is also under the AGPLv3, so everything should be good.
Package: python-libmagic
# python-libmagic![magic.h](http://i.imgur.com/GbN8szC.jpg)# Usage```pythonimport magicwith magic.Magic() as m:print m.from_buffer("hello") # => "text/plain"``````pythonimport magicimport magic.flagsmagic = magic.Magic()mimetype = magic.from_buffer("\x89\x50\x4E\x47\x0D\x0A\x1A\x0A")print mimetype # => "image/png"mimetype = magic.from_file("/etc/passwd")print mimetype # => "text/plain"updated = magic.set_flags(magic.flags.MAGIC_NONE)print updated # => Truemimetype = magic.from_file("demo.docx")print mimetype # => "Microsoft Word 2007+"magic.close() # don't forget about this```# Installation`python-libmagic` works on CPython 2.7/3.3+ and PyPy.```bash$ apt-get install libmagic-dev$ pip install python-libmagic```# LicenseLicensed under MIT license.
Package: python-libmed
python-libmed is a package that provides a wrapper to the libmed C library to
manipulate MED files; the wrapping is done using Cython. MED files are used to
store and exchange meshed data or computation results. The underlying file
format is HDF5.python-libmed’s user interface (API) consists of pure Python modules that
allow manipulation of fundamental components of a MED file (the file itself,
meshes, fields, numerical parameters, etc.). The main entry point is the
MEDFile class which provides an interface to a MED file and to its components.
Package: python-libmt94x
MT940/MT942 is a text based data file format used in bank account statements
(commonly used by banks in the Netherlands). A bank account statement contains
your account balance as well as a listing of all the transactions between a
given start date and end date.This library provides an API to define and serialize MT940/MT942 documents in
Python. It does not provide a parser.InstallationInstall using pip:$ pip install python-libmt94xUsageCreating MT940 documentslibmt94ximplements two ING-defined dialects of MT940:Mijn ING Zakelijk (dubbedming),Inside Business Payments (dubbedibp).No matter which dialect your are using you first need to construct anMT940Documentand then use the appropriate method to write it out
to the target dialect:fromlibmt94x.documentimportMt940Documentfromlibmt94x.fieldsimportAccountIdentification# ...snip...fromlibmt94x.fieldsimportTransactionReferenceNumberfromlibmt94x.serializerimportMt94xSerializerfromlibmt94x.writerimportMt94xWriterserializer=Mt94xSerializer()writer=Mt94xWriter(serializer)doc=Mt940Document(transaction_reference_number=TransactionReferenceNumber('P140220000000001'),account_identification=AccountIdentification('NL69INGB0123456789','EUR'),# ...snip...)# to write using the ``ming`` dialectbytestring=writer.write_document_ming(doc)# to write using the ``ibp`` dialectbytestring=writer.write_document_ibp(doc)How to find more infoFor more details on the API and compatibility issues see docs/design.rst.For example MT940 documents see tests/examples/.For fully fledged code examples see the tests in
tests/test_writer_doc_XXX.py.Developing on libmt94xRunning testsIt is recommended that you use a virtualenv when working on libmt94x. To run
tests you will first need to install the development dependencies, which
includetox:$ pip install -r dev-requirements.txtNow run the tests using tox (this will invoke py.test inside the tox-managed
virtual test environment):$ toxThis will run tests, collect test coverage and run the style checkerflake8. For a more lightweight test run you can run pytest directly:$ py.testContributingPlease see CONTRIBUTING.rst for guidelines on how to contribute to libmt94x.Changelog0.3.4 (2016-07-11)Updating package metadata (no code changes).
[numerodix]0.3.3 (2016-07-11)First release to PyPI.
[numerodix]0.3.2 (2016-06-27)Add README.txt and HISTORY.rst to setup.py long_description for display on
ginger devpi.
[numerodix]0.3.1 (2016-05-13)Use standard packaging and testing conventions in this package.
[numerodix]
Package: python-libpcap
Cython libpcap, read/write/merge/captureGIthub repo:https://github.com/caizhengxin/python-libpcapDocumentation:https://python-libpcap.readthedocs.ioFree software: BSD lincenseFeaturesRead pcap fileWrite pcap fileMerge pcap fileMulti-file quick mergeGet first ifaceGet iface listSend raw packetCapture dataInstallationTo install python-libpcap, run this command in your terminal:$sudoapt-getinstalllibpcap-dev$pip3installpython-libpcapUsageCommand:#Multi-filequickmerge$libpcap-merge-itest.pcap-opcap.pcapport502$libpcap-merge-ipcap/-opcap.pcapport502#Capturedatapacket$sudolibpcap-capture-ienp0s3-v-pport22$sudolibpcap-capture-ienp0s3-opcap.pcapport22#Writepacket$libpcap-write--outputpcap.pcapac64175ffa41000ec6c9157e08004500004b8a1e400080060000c0a80002c0a80001c794006618e119b56ef0831d5018faf081910000030000231ee00000001d00c1020600c20f53494d415449432d524f4f542d4553c0010a#Readpacket$libpcap-read-itest.pcap-v-pport502Read pcap:frompylibpcap.pcapimportrpcapforlen,t,pktinrpcap("tests/dns.pcap"):print("Buf length:",len)print("Time:",t)print("Buf:",pkt)Write pcap:frompylibpcapimportwpcapbuf=b'\x00\xc0\x9f2A\x8c\x00\xe0\x18\xb1\x0c\xad\x08\x00E\x00\x008'\b'\x00\x00@\x00@\x11eG\xc0\xa8\xaa\x08\xc0\xa8\xaa\x14\x80\x1b'\b'\x005\x00$\x85\xed\x102\x01\x00\x00\x01\x00\x00\x00\x00\x00'\b'\x00\x06google\x03com\x00\x00\x10\x00\x01'wpcap(buf,"pcap.pcap")wpcap([buf,buf],"pcap.pcap)frompylibpcapimportOpenPcapwithOpenPcap("pcap.pcap","a")asf:f.write(buf)Merge pcap:frompylibpcap.pcapimportmpcapmpcap("demo.pcap","demo2.pcap")mpcap("pcap/","output.pcap","port 502")Get first iface:frompylibpcapimportget_first_ifaceprint(get_first_iface())Get iface list:frompylibpcapimportget_iface_listprint(get_iface_list())Send raw packet:frompylibpcapimportsend_packetsend_packet("enp2s0",b"")Capture data:frompylibpcap.pcapimportsniffforplen,t,bufinsniff("enp2s0",filters="port 53",count=-1,promisc=1,out_file="pcap.pcap"):print("[+]: Payload len=",plen)print("[+]: Time",t)print("[+]: Payload",buf)frompylibpcap.baseimportSniffsniffobj=Sniff("enp2s0",filters="port 53",count=-1,promisc=1,out_file="pcap.pcap")forplen,t,bufinsniffobj.capture():print("[+]: Payload len=",plen)print("[+]: Time",t)print("[+]: Payload",buf)stats=sniffobj.stats()print(stats.capture_cnt," packets captured")print(stats.ps_recv," packets received by filter")print(stats.ps_drop,"  packets dropped by kernel")print(stats.ps_ifdrop,"  packets dropped by iface")CreditsThis package was created withCookiecutterand thecaizhengxin/cookiecutter-packageproject template.
Package: python-librsync
ASmartFileOpen Source project.Read moreabout how SmartFile
uses and contributes to Open Source software.IntroductionA ctypes wrapper for librsync. Providessignature(),delta(), andpatch()functions.There are three steps necessary to synchronize a file. Two steps are performed
on the source file and one on the destination.Generate a signature for the destination file.Generate a delta for the source file (using the signature).Patch the destination file using the generated delta.Usually, these steps involve remote systems. Here is an example of synchronizing
two local files.importlibrsync# The destination file.dst=file('Resume-v1.0.pdf','rb')# The source file.src=file('Resume-v1.2.pdf','rb')# Where we will write the synchronized copy.synced=file('Resume-latest.pdf','wb')# Step 1: prepare signature of the destination filesignature=librsync.signature(dst)# Step 2: prepare a delta of the source filedelta=librsync.delta(src,signature)# Step 3: synchronize the files.# In many cases, you would overwrite the destination with the result of# synchronization. However, by default a new file is created.librsync.patch(dst,delta,synced)ExtendingThis wrapper only exposes the most common operations that librsync provides. It
is not meant to be a full wrapper, but should cover most use-cases. You can
easily extend this wrapper. Information about librsync is available in it’s
manual which is linked below (I wish I had found this BEFORE writing this
wrapper!)http://rproxy.samba.org/doxygen/librsync/refman.pdf
Package: python-librtmp
python-librtmppython-librtmp is aRTMPclient library. It uses the implementation
provided bylibrtmpviacffi.Free software:BSD licenseDocumentation:http://pythonhosted.org/python-librtmpInstallationThe latest stable version is available to install usingpipsudo pip install python-librtmpBut you can also get the development version usingGit:git clone git://github.com/chrippa/python-librtmp.git
cd python-librtmp
sudo python setup.py installDependenciesPython, at least version 2.6 or 3.3.a C compiler capapable of buildingPythonextensions, e.g.gcclibrtmp: The library including its headers (librtmp-devor equivalent)cffi: cffi depends on libffi and its headers (libffi-devor equivalent)On Python <3.4 the backport ofsingledispatchis also required.Windowspython-librtmp (andcffi) has wheel packages (binaries) available on PyPi and can
therefore be easily installed withpip 1.4+without the need to compile anything:> pip install python-librtmp(on older pip versions you need to use --use-wheel)> pip install --use-wheel python-librtmpFeaturesStreamingThe most common use case of RTMP is to read a video stream from
a server.importlibrtmp# Create a connectionconn=librtmp.RTMP("rtmp://your.server.net/app/playpath",live=True)# Attempt to connectconn.connect()# Get a file-like object to access to the streamstream=conn.create_stream()# Read 1024 bytes of datadata=stream.read(1024)Remote function callsHere is a example of creating a Python function that can be used to call
remote functions:my_remote_method=conn.remote_method("MyRemoteMethod",block=True)result=my_remote_method("some argument")Waiting for the server to call our function:# This will automatically name the function after it's Python name@conn.invoke_handlerdefmy_add(a,b):returna+b# Start waiting for callsconn.process_packets()You can also use custom function name instead:@conn.invoke_handler("MyMath.MyAdd")Instead of blocking forever when waiting for a call you can specify to wait
only for a specific invoke and then stop blocking:conn.process_packets(invoked_method="MyMath.MyAdd",timeout=30)History0.3.0 (2015-05-25)Added update_buffer option (enabled by default) to RTMP.create_stream,
which enables a hack to increase throughput.Added a update_buffer method to RTMPStream.We now require at least version 1.0.1 of cffi.0.2.2 (2015-04-15)Fixed proxy not being used by librtmp.Added support for Cygwin, patch by @schrobby. (#17)0.2.1 (2014-09-01)Fixed expected bytes type on Python 2.Fixed singledispatch dependency condition.0.2.0 (2014-04-07)RTMPError now inherits from IOError.Fixed MSVC build.Added librtmp.so.1 to library paths, patch by Athanasios Oikonomou. (#4)Added librtmp.dylib to library paths, patch by Will Donohoe. (#6)0.1.2 (2013-10-08)Fixed compilation issue on some platforms.Fixed AMF issue on older librtmp versions. (#1)0.1.1 (2013-09-25)Fixed packaging issues.0.1.0 (2013-09-23)First release on PyPI.