alexlib


Namealexlib JSON
Version 0.1.6 PyPI version JSON
download
home_pagehttps://github.com/thisismygitrepo/alexlib
SummaryMaking Python even more convenient by extending list and dict and pathlib and more.
upload_time2020-12-02 00:05:00
maintainer
docs_urlNone
authorAlex Al-Saffar
requires_python
licenseApache 2.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# Welcome to alexlib

Fill your life with one-liners, take your code to artistic level of brevity and readability while simultaneously being more productive by typing less boilerplate lines of code that are needless to say.

This package extends many native Python classes to equip you with an uneasy-to-tame power. The major classes extended are:

 * `list` is  extended to `List`
    * Forget that `for` loops exist in your life, because with this class, `for` loops are implicitly applied to all items.
      Inevitably while programming, one will encounter objects of the same type and you will be struggling to get a tough grab on them.  `List` is a powerful structure that put at your disposal a grip, so tough, that the objects you have at hand start behaving like one object. This is the power of implicit `for` loops.

  * `dict` is  extended to `Struct`.
    * Combines the power of dot notation like classes and key access like dictionaries.

   * `pathlib.Path` is  extended to `P`
        * `P` objects are incredibly powerful for parsing paths, *no* more than one line of code is required to do **any** operation. Take a shufti at this:
        ```
     path = tb.P("dataset/type1/meta/images/file3.ext")
     >> path[0]  # ALLOWS INDEXING !
        P("dataset")
     >> path[-1]  # NIFTY
        P("file3.ext")
     >> path[2:-1]  # Even slicing!
        P("meta/images/file3.ext")
     ```
     This and much much more, is only on top of the indesipensible `pathlib.Path` functionalities.

   * Some other classes that make honorable mention here are `Read` and `Save` classes. Together with `P`, they provide comprehensible support for file management. Life cannot get easier with those. Every class inherits attributes that allow saving and reloading in one line.


Furthermore, those classes are inextricably connected. Example, globbing a path `P` object returns a `List` object. You can move back and forth between `List` and `Struct` with one method, and so on.


# Install
In the commandline:
`pip install alexlib`.

Being a thin extension on top of almost pure Python, you need to worry **not** about your venv, the package is not aggressive in requirements, it installs itself peacefully, never interfere with your other packages. If you do not have `numpy`, `matplotlib` and `pandas`, it simply throws `ImportError` at runtime, that's it. The package is not fussy about versions either. It can though at runtime, install packages on the fly, e.g. `dill` and `tqdm` which are very lightweight libraries.

# Getting Started
That's as easy as taking candy from a baby; whenever you start a Python file, preface it with following in order to unleash the library:

```
import alexlib.toolbox as tb
```


# A Taste of Power
Suppose you want to know how many lines of code in your repository. The procedure is to glob all `.py` files recursively, read string code, split each one of them by lines, count the lines, add up everything from all strings of code.


To achieve this, all you need is an eminently readable one-liner.
```
tb.P.cwd().myglob("*.py", r=True).read_text().split('\n').apply(len).to_numpy().sum()
```

How does this make perfect sense?
* `myglob` returns `List` of `P` path objects
* `read_text` is a `P` method, but it is being run against `List` object. Behind the scenes, **responsible black magic** fails to find such a method in `List` and realizes it is a method of items inside the list, so it runs it against them and thus read all files and containerize them in another `List` object and returns it.
* Similar story applies to `split` which is a method of strings in Python.
* Next, `apply` is a method of `List`. Sure enough, it lives up to its apt name and applies the passed function `len` to all items in the list and returns another `List` object that contains the results.
* `.to_numpy()` converts `List` to `numpy` array, then `.sum` is a method of `numpy`, which gives the final result.


# Full docs:
Click [Here](<https://alexlib.readthedocs.io/en/latest/>)



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/thisismygitrepo/alexlib",
    "name": "alexlib",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Alex Al-Saffar",
    "author_email": "programmer@usa.com",
    "download_url": "https://files.pythonhosted.org/packages/64/93/e4c1ac03b25a356263410632e421d97814cdc2894dc384ce95fb4e51541a/alexlib-0.1.6.tar.gz",
    "platform": "",
    "description": "\n# Welcome to alexlib\n\nFill your life with one-liners, take your code to artistic level of brevity and readability while simultaneously being more productive by typing less boilerplate lines of code that are needless to say.\n\nThis package extends many native Python classes to equip you with an uneasy-to-tame power. The major classes extended are:\n\n * `list` is  extended to `List`\n    * Forget that `for` loops exist in your life, because with this class, `for` loops are implicitly applied to all items.\n      Inevitably while programming, one will encounter objects of the same type and you will be struggling to get a tough grab on them.  `List` is a powerful structure that put at your disposal a grip, so tough, that the objects you have at hand start behaving like one object. This is the power of implicit `for` loops.\n\n  * `dict` is  extended to `Struct`.\n    * Combines the power of dot notation like classes and key access like dictionaries.\n\n   * `pathlib.Path` is  extended to `P`\n        * `P` objects are incredibly powerful for parsing paths, *no* more than one line of code is required to do **any** operation. Take a shufti at this:\n        ```\n     path = tb.P(\"dataset/type1/meta/images/file3.ext\")\n     >> path[0]  # ALLOWS INDEXING !\n        P(\"dataset\")\n     >> path[-1]  # NIFTY\n        P(\"file3.ext\")\n     >> path[2:-1]  # Even slicing!\n        P(\"meta/images/file3.ext\")\n     ```\n     This and much much more, is only on top of the indesipensible `pathlib.Path` functionalities.\n\n   * Some other classes that make honorable mention here are `Read` and `Save` classes. Together with `P`, they provide comprehensible support for file management. Life cannot get easier with those. Every class inherits attributes that allow saving and reloading in one line.\n\n\nFurthermore, those classes are inextricably connected. Example, globbing a path `P` object returns a `List` object. You can move back and forth between `List` and `Struct` with one method, and so on.\n\n\n# Install\nIn the commandline:\n`pip install alexlib`.\n\nBeing a thin extension on top of almost pure Python, you need to worry **not** about your venv, the package is not aggressive in requirements, it installs itself peacefully, never interfere with your other packages. If you do not have `numpy`, `matplotlib` and `pandas`, it simply throws `ImportError` at runtime, that's it. The package is not fussy about versions either. It can though at runtime, install packages on the fly, e.g. `dill` and `tqdm` which are very lightweight libraries.\n\n# Getting Started\nThat's as easy as taking candy from a baby; whenever you start a Python file, preface it with following in order to unleash the library:\n\n```\nimport alexlib.toolbox as tb\n```\n\n\n# A Taste of Power\nSuppose you want to know how many lines of code in your repository. The procedure is to glob all `.py` files recursively, read string code, split each one of them by lines, count the lines, add up everything from all strings of code.\n\n\nTo achieve this, all you need is an eminently readable one-liner.\n```\ntb.P.cwd().myglob(\"*.py\", r=True).read_text().split('\\n').apply(len).to_numpy().sum()\n```\n\nHow does this make perfect sense?\n* `myglob` returns `List` of `P` path objects\n* `read_text` is a `P` method, but it is being run against `List` object. Behind the scenes, **responsible black magic** fails to find such a method in `List` and realizes it is a method of items inside the list, so it runs it against them and thus read all files and containerize them in another `List` object and returns it.\n* Similar story applies to `split` which is a method of strings in Python.\n* Next, `apply` is a method of `List`. Sure enough, it lives up to its apt name and applies the passed function `len` to all items in the list and returns another `List` object that contains the results.\n* `.to_numpy()` converts `List` to `numpy` array, then `.sum` is a method of `numpy`, which gives the final result.\n\n\n# Full docs:\nClick [Here](<https://alexlib.readthedocs.io/en/latest/>)\n\n\n",
    "bugtrack_url": null,
    "license": "Apache 2.0",
    "summary": "Making Python even more convenient by extending list and dict and pathlib and more.",
    "version": "0.1.6",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "85f68399a1d23025cb62943957bbfcd5",
                "sha256": "f5517c65b80853ba37dd49b2e323d25bff3d1a656c1f9664514b1b9b76713612"
            },
            "downloads": -1,
            "filename": "alexlib-0.1.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "85f68399a1d23025cb62943957bbfcd5",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 49535,
            "upload_time": "2020-12-02T00:04:53",
            "upload_time_iso_8601": "2020-12-02T00:04:53.897612Z",
            "url": "https://files.pythonhosted.org/packages/88/46/e9487442d0451e0eadc54878c9d430d63754794c03a2ef275129d04171c5/alexlib-0.1.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "685bbcf56e54d4434415407b041fd6a2",
                "sha256": "1dc34c2ef54585331c019b6849e73249e4d0915d23bfd6acd7231ad17a6f0faf"
            },
            "downloads": -1,
            "filename": "alexlib-0.1.6.tar.gz",
            "has_sig": false,
            "md5_digest": "685bbcf56e54d4434415407b041fd6a2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 46107,
            "upload_time": "2020-12-02T00:05:00",
            "upload_time_iso_8601": "2020-12-02T00:05:00.723425Z",
            "url": "https://files.pythonhosted.org/packages/64/93/e4c1ac03b25a356263410632e421d97814cdc2894dc384ce95fb4e51541a/alexlib-0.1.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2020-12-02 00:05:00",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": null,
    "github_project": "thisismygitrepo",
    "error": "Could not fetch GitHub repository",
    "lcname": "alexlib"
}
        
Elapsed time: 0.18937s