{ "info": { "author": "David McEwan", "author_email": "dmcewa15@caledonian.ac.uk", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "Intended Audience :: Science/Research", "License :: OSI Approved :: GNU General Public License (GPL)", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Topic :: Software Development :: Code Generators", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "Binstr - A collection of utility functions for creating and operating on\n strings of binary digits. It is compatible with Python versions >2.6\n including 3.x.\n It is useful to use these functions to make small bugs in your code\n easier to find since all inputs are checked thoroughly for errors\n using assertions.\n\nPyPI may not always have the latest version.\nThe latest version can always be found on the GitHub page (https://github.com/DavidMcEwan/binstr).\n\nIncludes:\n b_and() - Perform a bitwise AND\n b_or() - Perform a bitwise OR\n b_xor() - Perform a bitwise XOR\n b_nand() - Perform a bitwise NAND\n b_nor() - Perform a bitwise NOR\n b_nxor() - Perform a bitwise NXOR\n b_not() - Perform a bitwise NOT (inversion)\n \n b_land() - Perform a logical AND\n b_lor() - Perform a logical OR\n b_lxor() - Perform a logical XOR\n b_lnand() - Perform a logical NAND\n b_lnor() - Perform a logical NOR\n b_lnxor() - Perform a logical NXOR\n \n int_to_b() - Convert a positive integer to a sting of binary.\n e.g. int_to_b(5) -> '00000101'\n frac_to_b() - Convert a positive fraction to a string of binary.\n e.g. frac_to_b(0.5) -> '10000000'\n str_to_b() - Convert an ASCII string of characters to a string of binary.\n e.g. str_to_b('abc') -> '011000010110001001100011' \n bytes_to_b() - Convert an byte sequence to a string of binary.\n In Python 2.x this is the same as str_to_b().\n baseX_to_b() - Convert from another base (4, 8, 16, 32 or 64) to binary coding.\n \n b_to_int() - Convert from base2 binary coding to an integer.\n b_to_frac() - Convert from base2 binary coding to an float less than 1.0.\n b_to_str() - Convert from binary coding to a string of ASCII characters.\n b_to_bytes() - Convert from binary coding to a byte sequence.\n In Python 2.x this is the same as b_to_str().\n b_to_baseX() - Convert from binary coding to another base (4, 8, 16, 32 or 64).\n \n b_bin_to_gray() - Convert binary code into gray code\n b_gray_to_bin() - Convert gray code into binary code\n \n b_add() - Perform an ADD operation\n b_mul() - Perform a MUL operation (multiply)\n \n b_blockify() - Separate a string of binary into blocks\n b_validate() - Validate that a given string contains only 0s and 1s\n\nint_to_b() is a lot more flexible than the built in bin() function although\nbin() is used internally. It allows you to force a width, change what bits are\nchopped off, change the alignment and change the bit endianness.\n\nThe bit endianness is particularly useful for creating binary shuffles.\nE.g. For creating the binary shuffle for a 256 sample FFT this can be done in a few lines.\n\nfrom math import log\nlength = 256\nshuffle = [int( int_to_b(i, width=int(log(length, 2)), endian='little') , 2)\n for i in range(length)]\n\n\nstr_to_b() is also very flexible and can be used to simulate the voltage levels\nin serial communication.\nE.g. To simulate a standard RS232 port with a \"8E1\" configuration sending the\ndata \"Hello World!\" this can be done simply.\n\ndata = str_to_b('Hello World!', endian='little', char_width=8, parity='sE', suffix='1')\n\nNote that data is usually sent out LSB first. The char_width argument is shown\nfor clarity but is 8 by default. The suffix argument is used to add one stop bit.\n\n\n-------------------------------------------------------------------------------\nInstallation\n-------------------------------------------------------------------------------\nextract the contents of the tarball:\ncd to this directory (where README.txt and setup.py are) then run:\n\npython setup.py install\n\nNote: This may need to be run with root (admin) priviliges.\n\n\n-------------------------------------------------------------------------------\nDev Notes\n-------------------------------------------------------------------------------\nThis is just a list of things which have been considered while developing binstr,\njust in case anybody is interested.\n\nBinstr may work on versions of Python before 2.6 with some slight and fairly obvious\nmodifications (obvious when you run it) it. This is not really a big priority\nof mine but I'll try not to break backward compatiblity when possible. No promises.\n\nRejected funtions include:\n deblockify - Use str().replace()\n b_to_file - Use file().write(b_to_bytes(), 'wb')\n file_to_b - Use bytes_to_b(open(, 'rb').read())\n b_log, b_exp, etc... - Use the proper math functions\n b_sub - Use b_add() with b_not for Two's compliment representaion.\n b_div - Use b_mul with inverse\n b_rotl, b_rotr - Use Python slices\n b_reverse - Use [::-1] E.g. '0101'[::-1] returns '1010'\n\nStuff on my TODO list for next version include:\n 1. Make some of the functions a bit more efficient by using map(), reduce() and filter().\n None of the functions have been written with speed as a top priority so some are pretty\n poor in terms of efficiency.\n \n 2. Add functions for other binary encodings apart from standard base2 and Gray.\n These would (maybe) include signed/unsigned exponential, signed/unsigned interleaved\n exponential, Fibonacci, Rice, Golomb, Levenshtein, and Huffman coding.\n I'm not quite sure what else should be added like that just now.\n \n 3. Add Two's Compliment function and One's(?).\n I know it's so trivial I could just put it in now but\n it seems nicer to leave it till version 1.4.\n\nIf anybody has any tips, advice or general abuse concerning Binstr then please feel\nfree to send me an email or even get on GitHub and contribute.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/DavidMcEwan/binstr", "keywords": null, "license": "GLPv3", "maintainer": null, "maintainer_email": null, "name": "binstr", "package_url": "https://pypi.org/project/binstr/", "platform": "Python >2.6 including 3.x (OS Independent)", "project_url": "https://pypi.org/project/binstr/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/DavidMcEwan/binstr" }, "release_url": "https://pypi.org/project/binstr/1.3/", "requires_dist": null, "requires_python": null, "summary": "Utility functions for strings of binary digits", "version": "1.3" }, "last_serial": 786864, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "92bcee89b57edf0c5b28fe51836a9874", "sha256": "024c32494747685bd20faef3488f90bb42dc83b50f531f9b87dfab2ecd34b086" }, "downloads": -1, "filename": "binstr-1.0.tar.gz", "has_sig": false, "md5_digest": "92bcee89b57edf0c5b28fe51836a9874", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4900, "upload_time": "2011-02-09T23:48:22", "url": "https://files.pythonhosted.org/packages/8a/f1/920598b82860b3bbf09ea216b25487abc7b304d871afb668226e6884f742/binstr-1.0.tar.gz" } ], "1.1": [ { "comment_text": "", "digests": { "md5": "99ce87dedb77e832bf9a47a71d313c64", "sha256": "40fc3ead795b14491045264e0363c2654026969c919400c83cdda702f4fc40a7" }, "downloads": -1, "filename": "binstr-1.1.tar.gz", "has_sig": false, "md5_digest": "99ce87dedb77e832bf9a47a71d313c64", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7089, "upload_time": "2011-02-26T18:27:31", "url": "https://files.pythonhosted.org/packages/58/89/786eb25cb45fd1b4954d90789d0b971fe895920f97d2856ada94549205d2/binstr-1.1.tar.gz" } ], "1.2": [ { "comment_text": "", "digests": { "md5": "e7efd56820cc1c332576ec41278aa446", "sha256": "58121fb9622c8a614ec83b51f9727e0c59b61b244df931bd84e3c40d373a3307" }, "downloads": -1, "filename": "binstr-1.2.tar.gz", "has_sig": false, "md5_digest": "e7efd56820cc1c332576ec41278aa446", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11781, "upload_time": "2011-05-29T22:32:52", "url": "https://files.pythonhosted.org/packages/09/ae/aeec9889a2e02cea1299b55e5d7e6cff3669dcee169ff223f30949df5bc7/binstr-1.2.tar.gz" } ], "1.3": [ { "comment_text": "", "digests": { "md5": "95738dec8b0b568be5ce2d3239860bbf", "sha256": "cbb26503762552ec264d40aacac50b035bca2dba0cb881292bdf290975014a13" }, "downloads": -1, "filename": "binstr-1.3.tar.gz", "has_sig": false, "md5_digest": "95738dec8b0b568be5ce2d3239860bbf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12659, "upload_time": "2011-08-08T00:58:08", "url": "https://files.pythonhosted.org/packages/8e/f7/72d6ce42c07c04ded2229ddfa3a028989619c4a18fa52e08edd5d3242f54/binstr-1.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "95738dec8b0b568be5ce2d3239860bbf", "sha256": "cbb26503762552ec264d40aacac50b035bca2dba0cb881292bdf290975014a13" }, "downloads": -1, "filename": "binstr-1.3.tar.gz", "has_sig": false, "md5_digest": "95738dec8b0b568be5ce2d3239860bbf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12659, "upload_time": "2011-08-08T00:58:08", "url": "https://files.pythonhosted.org/packages/8e/f7/72d6ce42c07c04ded2229ddfa3a028989619c4a18fa52e08edd5d3242f54/binstr-1.3.tar.gz" } ] }