Package: pysubtypes
PLEASE NOTE:This library is currently still under development. The API will likely undergo significant changes that may break any code you write with it.
The documentation will fall out of sync with the updates regularly until development slows down. Use it at your own risk.OverviewProvides subclasses for certain python builtins (str, list, dict) and common complex types (datetime, Enum, DataFrame, BeautifulSoup) which add functionality and
convenience methods/properties. Most of these have better__repr__()implementations than their superclass.TheStrclass (subclassesstr)Can be slicedComplex slicing methodsRegular expression operationsFuzzy matchingClipboard functionalityCasingStrippingTheListclass (subclasseslist)Method chaining on in-place mutation methods (list.append(),list.clear()etc.)Complex slicing methodsFuzzy matchingTheDictclass (subclassesdict)Method chaining on in-place mutation methods (dict.update(),dict.clear()etc.)filtering and getting values based on regular expressions, for keys that are strings.Allows its attributes to be accessed and modified using item accessRecursively replaces dicts withDictinstances when constructed and when settings an attribute or itemTheDateTimeclass (subclassesdatetime.datetime)DateTime.delta()method (timedelta addition and subtraction using keyword arguments)Methods representing the DateTime in various useful formatsFormatCode Enum, that can be used withDateTime.strftime()andDateTime.strptime().Accessor objects that shadow the object's basic attributes as PascalCase (DateTime.YearforDateTime.year,DateTime.MicroSecondforDateTime.microsecondetc.) which
return that attribute as a string in various formats, based on the available format codes of the datetime class.TheEnumclass (subclassesaenum.Enum)Incorporates the aenum library'sextend_enumfunction directly asEnum.extend_enum()ProvidesEnum.namesandEnum.valuesattributes that return listsAValueEnumsubclass which returns the value of its members on attribute access, rather than the members themselves.AnAutoEnumclass which does not require values to be explicitly set, and sets the values to be lowercased versions of the nameTheMarkupclass (subclassesbs4.BeautifulSoup)Ensures the 'html.parser' is selected , rather than the system's best available parserTheFrameclass (subclassespandas.DataFrame)Ensures the use of the new Int64Seriesdtype when constructed with an iterable that only containsintandNone(rather than using the default float64)High-level methods for pivoting and unpivotingChange the casing of the column namesRepresent theFrameas asciiModifiedFrame.to_excel()formats the output file to an excel table, returns a path objectModifiedFrame.to_sql(), with better SQL type selection, allows one of the columns (or the index) to be used as a primary key for the resulting SQL table.ModifiedFrame.from_excel(), capable of inferring table boundaries from messy spreadsheets using several rulesets, recasing the column names, and removing password protectionCreate aFramefrom an iterable of homogenous objectsWrite out an iterable of Frames as a single excel document with multiple sheets.Other misc utility functions (eg. replacing all NaN values with None, etc.)TheProcessclass (subclasses subprocess.Popen)Can print out the actual command-line call when instanciated.ModifiedProcess.wait()method which prints any stdout to the console and returns aCompletedProcessrather than just a return code.TheColorclass (subclasses colour.Color)Has aColor.NameEnumwhich contains all the possible color names that can be passed to theColor()constructor.TheHttpclass (subclasses requests.Session)Constructor takes aHttp(base_url=)argument which allows subsequent request to use shortened urls.TheNameSpaceclassAllows its attributes to be accessed and modified using item access/setting as well as attribute access/setting.Implements iteration and membership test magic methods for public members (not starting with_).TheSingletonclassInherit from it to implement singletons (subclasses ofSingletonwill return the same instance whenever constucted).InstallationTo install use pip:$ pip install pysubtypesOr clone the repo:$ git clone https://github.com/matthewgdv/subtypes.git
$ python setup.py installUsageDetailed usage examples coming soon.ContributingContributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.You can contribute in many ways:Report BugsReport bugs athttps://github.com/matthewgdv/subtypes/issuesIf you are reporting a bug, please include:Your operating system name and version.Any details about your local setup that might be helpful in troubleshooting.Detailed steps to reproduce the bug.Fix BugsLook through the GitHub issues for bugs. Anything tagged with "bug" and "help wanted" is open to whoever wants to implement a fix for it.Implement FeaturesLook through the GitHub issues for features. Anything tagged with "enhancement" and "help wanted" is open to whoever wants to implement it.Write DocumentationThe repository could always use more documentation, whether as part of the official docs, in docstrings, or even on the web in blog posts, articles, and such.Submit FeedbackThe best way to send feedback is to file an issue athttps://github.com/matthewgdv/subtypes/issues.If you are proposing a new feature:Explain in detail how it would work.Keep the scope as narrow as possible, to make it easier to implement.Remember that this is a volunteer-driven project, and that contributions are welcome :)Get Started!Before you submit a pull request, check that it meets these guidelines:If the pull request adds functionality, it should include tests and the docs should be updated. Write docstrings for any functions that are part of the external API, and add
the feature to the README.md.If the pull request fixes a bug, tests should be added proving that the bug has been fixed. However, no update to the docs is necessary for bugfixes.The pull request should work for the newest version of Python (currently 3.7). Older versions may incidentally work, but are not officially supported.Inline type hints should be used, with an emphasis on ensuring that introspection and autocompletion tools such as Jedi are able to understand the code wherever possible.PEP8 guidelines should be followed where possible, but deviations from it where it makes sense and improves legibility are encouraged. The following PEP8 error codes can be
safely ignored: E121, E123, E126, E226, E24, E704, W503This repository intentionally disallows the PEP8 79-character limit. Therefore, any contributions adhering to this convention will be rejected. As a rule of thumb you should
endeavor to stay under 200 characters except where going over preserves alignment, or where the line is mostly non-algorythmic code, such as extremely long strings or function
calls.