Saravanan666/pypi-org huggingface dataset:
Package: binaryreader
binaryreaderbinaryreader is a faster and more elegant alternative tostructfor parsing binary data in Python.ExamplefrombinaryreaderimportBinaryReaderdata:bytes|bytearrayread_little_endian:bool=Truereader=BinaryReader(data,read_little_endian)text=reader.readStringC()BenchmarkTODODocumentationNotes:kwargs won't be accepted, only args are useableall readArray functions accept a langth as optional argumentbytes can be read by using readUInt8ArrayInitBinaryReader(data: bytes|bytearray, is_little_endian: bool)Properties.endian: bool[get,set] - endianness of the reader (True - little, False - big).position: int[get,set] - position of the cursor within the data.size: int[get] - size of underlying/passed object.obj: bytes|bytearray[get] - underlying/passed objectFunctions.readBool(): bool- reads a bool.readInt8(): int- reads an int8.readUInt8(): int- reads an uint8.readInt16(): int- reads an int16.readUInt16(): int- reads an uint16.readInt32(): int- reads an int32.readUInt32(): int- reads an uint32.readInt64(): int- reads an int64.readUInt64(): int- reads an uint64.readHalf(): float- reads a half.readFloat(): float- reads a float.readDouble(): float- reads a double.readBoolArray(): [bool]- reads a bool array.readInt8Array(): [int]- reads a array of int8.readUInt8Array(): bytearray- reads a array of uint8.readInt16Array(): [int]- reads a array of int16.readUInt16Array(): [int]- reads a array of uint16.readInt32Array(): [int]- reads a array of int32.readUInt32Array(): [int]- reads a array of uint32.readInt64Array(): [int]- reads a array of int64.readUInt64Array(): [int]- reads a array of uint64.readHalfArray(): [float]- reads a array of half.readFloatArray(): [float]- reads a array of float.readDoubleArray(): [float]- reads a array of double.readStringC(): str- reads a null terminated string.readStringCArray(): [str]- reads an array of null terminated strings.readString(): str- reads a string (if length is not passed as arg, read an int as length).readStringArray(): [str]- reads an array of strings.readStringAligned(): str- same as readString but aligned to 4 bytes after reading the string.readStringAlignedArray(): [str]- reads an array of aligned strings.align(align_by: int): int- aligns the cursor to the given input and returns the position after the alignment.readVarInt(): int- reads a varint.readLSB(): bytearray- reads the lsb data of the given size (in bytes to read -> output length is 1/8 of that)
Package: binary-reader
PyBinaryReaderA python module for basic binary file IO.This is something I wrote to use in my personal projects, but feel free to use it if you like!Installationpip install binary-readerUsagefrombinary_readerimportBinaryReaderHere is some example usage on creating and using a BinaryReader to read a small part of the DDS header:f=open("example.dds","rb")# Open a file in binary modereader=BinaryReader(f.read())# Create a new BinaryReader from the file buffer (we can close the file afterwards)# Read the magic as a UTF-8 encoded string and compare it to the correct magicifreader.read_str(4)!='DDS ':raiseException('Incorrect magic.')size=reader.read_uint32()# Read the next 4 bytes as an unsigned 32-bit integerAnother example on using BinaryReader features to navigate through a buffer:some_offset=reader.read_uint32()# Read an offset that we want to move toprev_pos=reader.pos()# Store the current position so we can return back laterreader.seek(some_offset)# Set the current position in the file to that offsetvector=reader.read_float(3)# Read 3 consecutive 32-bit floats, return them as a tuplereader.seek(prev_pos)# Go back to the previous positionreader.seek(4,whence=1)# In addition to absolute seeking, we can also seek relative to the current position...reader.seek(0,whence=2)# And relative to the end of the buffer. This will set the position to be the last index in the bufferIn addition to reading, you can also write to a new buffer:writer=BinaryReader()# Create a new BinaryReader (bytearray buffer is initialized automatically)writer.set_endian(is_big_endian=True)# Set the endianness to big endianwriter.write_str('MGIC')writer.write_uint32(20)writer.align(0x10)# Align the buffer to 0x10 (in this case, will append 8 bytes to the buffer)writer.pad(0xF0)# Add 0xF0 bytes of paddingprint(writer.size())# This should print 256 (0x100)# Write the buffer to a new filewithopen('examplefile','wb')asf:f.write(writer.buffer())These are the types that can be used with BinaryReader. Just addread_orwrite_before the type to get the method name:uint8, int8,
uint16, int16, half_float
uint32, int32, float
uint64, int64,
bytes, strLicenseThis project uses the MIT License, so feel free to include it in whatever you want.
Package: binary-repr
Binary RepresentationConverts integers to binary representation.Yes, a Cython spinoff ofnumpy.binary_reprfunction.Free software: MIT licenseDocumentation:https://binary-repr.readthedocs.org.FeaturesTODOCreditsThis package was created withCookiecutterand theaudreyr/cookiecutter-pypackageproject template.History0.1.0 (2016-06-17)First release on PyPI.
Package: binary-rw
binary-rwSimple library for reading binary files.
I wrote this library to help myself with working with binary files written with c#.ExamplesWrite text to file.>>>importbinary_rw>>>file=binary_rw.BinaryWriter("test")>>>file.write_string("Example text")>>>file.close()Read byte from file.>>>importbinary_rw>>>file=binary_rw.BinaryReader("test")>>>file.read_byte()>>>file.close()Use BinaryReader with withimportbinary_rwwithBinaryReader("test")asfile:#codeInstallationpip install binary-rwLicenseMIT© Filip K.
Package: binary-search
Binary Search in PythonBinary search on already sorted sequences (list, tuple) to get the first element>=or>a value (similar to C++'sstd::lower_boundandstd::upper_bound).Requires python >=3.5 for thetypingmodule and >= 3.4 for theenummodule, but you can easily
extract thesearchfunction frombinary_search/__init__.pyif you need it for a lower version.Installpip install binary-searchUsageSeetests.pyfor more sample usage.importbinary_searchasbssorted_sequence=(2,5,7,9)a=bs.search(sorted_sequence,5)print(a)# 1 - the index of the first element >= 5b=bs.search(sorted_sequence,6)print(b)# 2 - the index of the first element >= 6 (element 2 with value 7)You can also use a custom key in the same way assortedimportbinary_searchasbsimportrandom# sequence of 10 random pairs of integerssequence=[(random.randint(),random.randint())for_inrange(10)]# sort and search just using the first integerkey=lambdapair:pair[0]sorted_sequence=sorted(sequence,key=key)bs.search(sorted_sequence,[5,None],key=key)Development and testingFork the repositoryClone your forkInstall it in editable modepip install -e .Make any changes and add new tests totests.pyRun pytestpython -m pytestCommit and push to your forkMake pull request (merge your fork back to main repo)
Package: binarysearchsimulation
Binary Search SimulationPython program to visualize the behavior of upper_bound and lower_bound binary searches.Upper BoundLower BoundIntuitive Binary SearchUpper BoundLower BoundintupperBound(vector<int>&array,inttarget){// array should be sorted in non-decreasing// order from left to rightintl=0,r=array.size()-1;while(l<=r){intmid=l+(r-l)/2;if(target<array[mid]){r=m-1;}else{l=m+1;}}returnl;}intlowerBound(vector<int>&array,inttarget){// array should be sorted in non-decreasing// order from left to rightintl=0,r=array.size()-1;while(l<=r){intmid=l+(r-l)/2;if(target<=array[mid]){r=m-1;}else{l=m+1;}}returnl;}Binary Search Variation (works optimally for non-integer spaces)Upper BoundLower BoundintupperBound(vector<int>&array,inttarget){// array should be sorted in non-decreasing// order from left to rightintl=-1,r=array.size();while(l+1<r){intmid=l+(r-l)/2;if(target<array[mid]){r=m;}else{l=m;}}returnr;}intlowerBound(vector<int>&array,inttarget){// array should be sorted in non-decreasing// order from left to rightintl=-1,r=array.size();while(l+1<r){intmid=l+(r-l)/2;if(target<=array[mid]){r=m;}else{l=m;}}returnr;}
Package: binarySerialReceiver
Simple module for receiving binary data from a serial port in an asynchronous form. Useful for receiving data from an Arduino or a microcontroller without the need to use strings.DescriptionThis modules lets you specify the format of the binary data and the header to be received from a serial port. The module creates a dedicated thread to read de serial port and feed the numpy arrays passed as buffers in a circular forma, always keeping the same length.ExampleIn the example folder there is a script that creates a virtual serial port (works only on linux) allowing you to run test-receiver.py which will print the received data buffer.An exemple code for an arduino to send data to be read using this module would be the fallowing:voidloop(){uint16_tadc_signal=analogRead(sensorPin);longunsignedt_now=micros();uint16_tbuffer_size=sizeof(uint16_t)+sizeof(longunsigned)+2;bytebuf[buffer_size];buf[0]=0xFD;memcpy(buf+1,(byte*)&t_now,sizeof(unsignedlong));memcpy(buf+1+sizeof(unsignedlong),(byte*)&adc_vdd,sizeof(uint16_t));buf[buffer_size-1]='\n';Serial.write(buf,buffer_size);}In this case the format for receiving would be ‘Lh’. All the possible formats are defined in thestruct package page.
Package: binary-stream
BinaryStreamBinaryStream library for pythonWhat is it?This is a library for convenient serialization of standard C/C++ types similar to that used for example in RakNet
protocol.InstallationFor Linux/Macpip3 install binary-streamFor Windowspip install binary-streamUsageExamplefrombinary_streamimportBinaryStreamwrite_stream=BinaryStream()write_stream.write_int8(42)write_stream.write_bool(True)write_stream.write_bool(True)data=write_stream.get_buffer()print(data.hex())read_stream=BinaryStream(data)print(read_stream.read_int8())print(read_stream.read_bool())print(read_stream.read_bool())CreditsThis project is inspired bybinary_utilsLicenseThis project is open sourced under MIT license, see theLICENSEfile for more details.
Package: binary-system
code-binary-systemEsto lo he hecho con fines educativo cuando estaba en clases de Arquitectura del Computador y quise realizar mi propio algoritmo.Te permite convertir números decimales a binarios y viceversa.Instalaciónpip install binary_systemUsoPara convertir un número decimal a binario, se puede llamar a la funciónnumber_to_binary()y proporcionar el número como argumento. La función devolverá una cadena de texto que representa el número en su forma binaria.frombinary_systemimportBinarybinary=Binary()result=binary.number_to_binary(10)# Convierte el número 10 a binarioprint(result)# Imprime "1010"Para convertir un número binario a decimal, se puede llamar a la funciónbinary_to_number()y proporcionar la cadena de texto binaria como argumento. La función devolverá el número decimal correspondiente.frombinary_systemimportBinarybinary=Binary()result=binary.binary_to_number('1010')# Convierte la cadena de texto "1010" a decimalprint(result)# Imprime "10"
Package: binary-tree
Binary_treeBinary_tree is a simple package to create sort and search data with binary trees.##installpip install --upgrade binary_treeusageTo create a tree use the tree objectGet a sorted array using the tree traverse functionSearch an item (True/False) via the tree search function####exampleimportbinary_treeasbttree1=bt.tree([1,6,3,9])print(tree1.traverse())# returns [1, 3, 6, 9]print(tree1.search(6))#returns True#####creditsCreator: Ofri Kirshen
Package: binary_tree_dict_mod
A pure python binary tree class is provided.  It is
thoroughly unit tested, passes pylint, and is known
to run on CPython 2.x, CPython 3.x, Pypy 2.4.0, Pypy3 2.4.0 and
Jython 2.7b3.This binary tree looks like a dictionary that’s always
sorted by key.  It does not reorganize itself.Although definitely a poor choice for pre-sorted keys, it’s quite
good for pre-randomized keys.
Package: binary-waterfall
Binary WaterfallA Raw Data Media PlayerInspired by this video.Command Line UsageAfter installing the module, runbinary-waterfall.AttributionIf you use this program to make a video or other project, you must provide attribution. Attribution is required regardless of whether your project is for-profit or not. Please reproduce the following attribution statement in full in your video description or otherwise include it in the references for your project:Made with the help of Binary Waterfall:
https://github.com/nimaid/binary-waterfallKeyboard ShortcutsPlay / Pause:SpacebarBack:Left ArrowForward:Right ArrowFrame Back:<(,)Frame Forward:>(.)Restart:RVolume Up:Up ArrowVolume Down:Down ArrowMute / Unmute:MShowcase Video
Package: binboy
Bin BoyPrint binary numbers in a hacking style.Built by Aitzaz ImtiazInstructionsgit clone <repository link>
cd Bin-Boy
make install
aitbinThat's it!Or as anternative, you can use pip on any prompt and run:pip install binboy
python -m binboyTo exit click Ctrl+C, must generate a File Break or error message.
Package: bincalc
Binary prefix calculatorCLI calculator for IEEE 1541-2002 / ISO/IEC 80000-13:2008 Prefixes for Binary MultiplesFree software: GNU General Public License v3Documentation:https://bincalc.readthedocs.io.FeaturesTODOCreditsThis package was created withCookiecutterand theaudreyr/cookiecutter-pypackageproject template.History1.0.0 (2022-10-21)First release on PyPI.
Package: binconvert
binconvertA CLI utility for converting byte orders in binary files from one
platform to another.Introduction and Motivationbinconvertis a program that was born out of the author’s need to
read old files that were written in abinaryformat on a SPARC system.
Because SPARC’s native byte-ordering isbig endian(ie, most
significant byte first), this caused comptatability issues when porting
these files over to an x86 Linux machine (which haslittle endian, or
least significant byte first native byte-ordering). In an ideal world
where the binary files areunstructuredand every data value stored in
the file has the same type, one could easily get around this problem by
either recompiling their program with special compiler flags or using
some existing CLI solutions likedd conv=swab.Unfortunately there are many binary files which arestructured, ie the
variables stored in the file are of different lengths and types, and so
it becomes necessary to know the internal structure of the file
beforehand. Thankfully, python provides an easy to usestructmodule
which allows for users to express the structure and byte-ordering of the
data as a format string. For example, “f6s” would imply that the first 4
bytes in the file represent a floating point number, while the remaining
6 bytes designate a 6 character string.Although this is a much nicer alternative than forcing the user to
manually perform the byte-swapping by hand, it can still break down when
needing to process larger binary files with more complex structures. As
an example, consider a binary file nameda.binwhich represents the
following table:NameAge(yr)Weight(lb)Height(ft)Alex26170.56.0Now imagine if this table had hundreds of additional entries. The format
string required bystructcan easily become very long. However, we
know that it can be generalized as aheaderwhich labels each column
in the table (“4s7s10s10s”) followed by the actual entries of the table
(“4si2f”), so it should be possible to generate the format string for an
arbitrary number of entries. Usingbinconvert, without even knowing
the total size of the file beforehand, we can easily convert its
byte-ordering from big to little-endian on an x86 machine using:bconva.bin-f4s7s10s10s4si2f:#In summary,binconvert’s main purpose is to extend the functionality
of the pythonstructmodule for these use cases by doing the following:Make it easier to generate format strings for larger files.Provide a simple CLI interface for performing the endianness
conversion.Installation and UsageTo installbinconvertfrom the current codebase, you may usegitclonehttps://github.com/agoodm/binconvert.gitcdbinconvertpythonsetup.pyinstallIf all goes well, you should be able to execute the program with:bconv-hIn the near future, installation methods usingcondawill be provided.
Package: bincount
No-copy parallelized bincount returning dict.MotivationAs of Nov 2018,np.bincountis unusable with large memmaps:>>> import numpy as np
>>> np.bincount(np.memmap('some-5gb-file.txt', mode='r'))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
MemoryErrorThe most effective pure-python solution forwc-lis a bit slow:In [6]: %%time
   ...: sum(1 for i in open('some-5gb-file.txt', mode='rb'))
   ...:
CPU times: user 3.5 s, sys: 878 ms, total: 4.38 s
Wall time: 4.38 s
Out[6]: 58941384It is 3x times slower thanwc-l:In [1]: %%time
   ...: !wc -l some-5gb-file.txt
   ...:
58941384 some-5gb-file.txt
CPU times: user 1.48 ms, sys: 3.48 ms, total: 4.96 ms
Wall time: 1.24 sWhile it should be faster on modern multicore SMP systems:In [1]: import numpy as np

In [2]: from bincount import bincount

In [3]: %%time
   ...: bincount(np.memmap('some-5gb-file.txt', mode='r'))[10]
   ...:
CPU times: user 6.83 s, sys: 354 ms, total: 7.19 s
Wall time: 705 ms
Out[4]: 58941384InstallPrequirements: C-compiler with OpenMP support.Install with pip:pip install bincountUsageThere is abincount(a parallel version) and abincount_single(which don’t
parallelize the calculation) functions, both returning the dict containing the
number of occurrences of each byte value in the passed bytes-like object:>>> from bincount import bincount
>>> bincount(open('a-tiny-file.txt', 'rb').read())
{59: 2, 65: 5, 66: 1, 67: 3, 68: 2, 69: 3, 73: 4, 76: 7, 84: 3, 86: 1, 95: 4}
Package: bincrafters-conventions
Bincrafters ConventionsA Script to update Conan projects following Conan conventionsThis project contains scripts to update CI files, to
update Conan conventions in general and to perform some linting.INSTALLYou can installbincrafters-conventionsviapiplike this:$ pip install bincrafters_conventionsRUN💡 Bincrafters Conventions is a command line tool.Executebincrafters-conventions --helpto see all options.bincrafters-conventionshas also the aliasbconfor convince.EXAMPLESTo updateALLConan projects on GitHub forhttps://github.com/bincrafters$ bcon --remote=bincraftersTo updateONLYone project on GitHubhttps://github.com/bincrafters/conan-conversion$ bcon --remote=bincrafters/conan-double-conversionToAVOIDto execute push command after to update$ bcon --remote=bincrafters/conan-libusb --dry-runTo filterPROJECTSby pattern$ bcon --remote=bincrafters --project-pattern bincrafters/conan-*To filterBRANCHESby pattern$ bcon --remote=bincrafters --branch-pattern stable/*or$ bcon --remote=bincrafters/conan-libzip --branch-pattern stable/*To update and checkLOCALeverything$ bconTo checkLOCALeverything$ bcon --checkTo apply Conan conventions in a local file:$ bcon --conanfile=conanfile.pyTo update AppVeyor file:$ bcon --appveryorfile=appveyor.ymlTesting and DevelopmentIf you want to installbincrafters-conventionsvia a local git clonepip install --user -U .To install extra packages required to testpip install .[test]To run all unit test + code coverage, execute:cd tests
pytest -v --cov=bincrafters_conventionsLICENSEMIT
Package: bincrafters-envy
[![Build Status](https://travis-ci.org/bincrafters/bincrafters-envy.svg?branch=master)](https://travis-ci.org/bincrafters/bincrafters-envy)[![Build status](https://ci.appveyor.com/api/projects/status/bb3844r6mnu7gy1g?svg=true)](https://ci.appveyor.com/project/BinCrafters/bincrafters-envy)[![codecov](https://codecov.io/gh/bincrafters/bincrafters-envy/branch/master/graph/badge.svg)](https://codecov.io/gh/bincrafters/bincrafters-envy)[![download](https://img.shields.io/badge/download-pypi-blue.svg)](https://pypi.org/project/bincrafters-envy)# Bincrafters EnvyUpdate environment variables for travis and appveyor#### InstallTo install using pypi.org:pip install bincrafters-envy#### Usagefirst, you'll need to obtains travis and appveyor tokensto obtain appveyor token, visit this [page](https://ci.appveyor.com/api-keys)to obtain travis token (for travis-ci.com), visit this [page](https://travis-ci.com/account/preferences)to obtain travis token (for travis-ci.org), visit this [page](https://travis-ci.org/account/preferences)create **env.ini** file with your environment variables (take a look at the **env.ini.example**):```[account]appveyor = <your account name on appveyor>travis = <your account name on travis>github = <your account name on GitHub>[env]CONAN_LOGIN_USERNAME = <your username>CONAN_PASSWORD = <your password>[encrypted]CONAN_PASSWORD[token]appveyor = <your appveyor token>travis = <your travis token>```then run `python envy.py -p <project>` (e.g. `python envy.py -p conan-libastral`)#### TestingTo run all unit tests:cd testspytest -v -s --cov=bincrafters_envy#### LICENSE[MIT](LICENSE)
Package: bincrafters-package-tools
Bincrafters Package ToolsA modular toolset forConan Package ToolsThis project contains files used by Conan Package Tools for all kinds of bincrafters builds.These scripts are used during build process to allow for rapid testing and prototyping at this time.INSTALLTo install by pip is just one stepLocalIf you want to install by local copypip install .RemoteOr if you want to download our pip packagepip install bincrafters_package_toolsENVIRONMENT VARIABLESAll variables supported by Conan package tools, are treated by Bincrafters package tools as well.
To solve the upload, some variables are customized by default:CONAN_UPLOAD:https://bincrafters.jfrog.io/artifactory/api/conan/public-conanCONAN_REFERENCE: Fieldsnameandversionfrom conanfile.pyCONAN_USERNAME: Get from CI env vars. Otherwise, usebincraftersCONAN_VERSION: Get from CI env vars.CONAN_VERSION: Fieldversionfrom conanfile.pyCONAN_UPLOAD_ONLY_WHEN_STABLE: True for default template. False for Boost builds.CONAN_STABLE_BRANCH_PATTERN: stable/*CONAN_ARCHS: Only x86_64 per default. To build 32-bit and 64-bit use e.g. [x86_64, x86]BPT SPECIFIC ENVIRONMENT VARIBLES:BPT_MATRIX_SPLIT_BY_BUILD_TYPES: Splits build jobs intoReleaseandDebugbuild jobs.BPT_MATRIX_DISCARD_DUPLICATE_BUILD_IDS:true/false, default:true. This does NOT YET what it says. Right now, this only has an effect for installer_only and header_only recipes when set tofalse. In those cases, you get the full build matrix, instead of a shortened build matrix. In the future, the matrix generation actually compares build IDs and discards jobs based on the IDs.Testing and DevelopmentTo install extra packages required to testpip install .[test]TESTINGTo run all unit test + code coverage, just execute:pip install -r bincrafters/requirements_test.txt
cd tests
pytest -v --cov=bincraftersLICENSEMIT