hackytools


Namehackytools JSON
Version 0.1.1 PyPI version JSON
download
home_page
SummaryTools that are hacky. Obviously.
upload_time2020-11-22 04:00:31
maintainer
docs_urlNone
authorHackysack
requires_python>=3.6
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # hackytools
Hacky Tools, by Hackysack (I'll never get tired of that joke.)

# Installation
You can install this package via the command:

`pip install hackytools`

To get the development version instead (where there may be unstable features) use one of the following:

`pip install https://github.com/H4CKY54CK/hackytools/archive/main.zip`  
`pip install https://github.com/H4CKY54CK/hackytools/archive/main.tar.gz`

# What do I get?
So far, not much. But I promise that I'm working hard at gathering a bunch of my homemade tools.

For right now, you get a couple of different hacky decorators, a spritesheet/stylesheet generator (mainly for subreddit CSS), and a command line tool (currently, only a single command).

# Decorators

## `@timeit`

A decorator to time how long a function takes, illustrated below.

    from hackytools import timeit
    import time

    # We need the `time` module to delay our test functions just a little bit.

    # Time how long a function takes.
    @timeit
    def main1():
        time.sleep(2)

    # Same thing, but in case you're used to using parentheses
    @timeit()
    def main2():
        time.sleep(.5)

    # Get an average elapsed time by running your function 5 times.
    @timeit(repeat=5)
    def main3():
        pass

    if __name__ == '__main__':
        main1()
        main2()
        main3()


    # main1 elapsed: 2.00 s
    # main2 elapsed: 500.38 ms
    # main3 average elapsed: 616.67 ns | best (of 5): 300.00 ns | worst (of 5): 1.90 µs

The timing decorator also automatically converts the time returned into a sensible unit, for optimal viewing pleasure.

Just be careful that you don't repeat 50 times, and your code takes 50 seconds each run. That would take forever. Be smart.

## `@timeable`

This does *nearly* the same thing as `@timeit`. However, `@timeable` by default, does **not** time your function. In fact, it doesn't interfere with it at all, unless explicitly told to do so. What do I mean? I'll explain.

    from hackytools import timeable

    @timeable
    def some_function():
        # do some stuff
        return # or whatever

    some_function()

    # Even though it is decorated, this function will act normally. However...
    # If we were to pass in a specific (unlikely to already be in use) kwargs
    # dict such as the following (and unpack it with **):

    some_function(**{'_frequency': 1})

    # some_function elapsed: 1.20 µs

    # This WILL time the function, with a frequency of 1 time(s).

    # "But that function doesn't take any arguments!", I hear you say.

    # And you'd be right. Through the magic of decorators (and some pretty basic python)
    # we can actually reach into the kwargs, get the value for this specific kwarg,
    # and then remove the kwargs from the kwargs dict. ezpz

## `@logme`

This is just a regular logging decorator. You decorate your function with `@logme`, and it logs some basic information about what just happened, to the file `{your_filename}.log`. So, if your filename was `myproject.py`, the logfile would literally be `myproject.py.log`. This is for several reasons, the most important being to not overwrite existing files. I should probably just add a file check.

    # myproject.py

    from hackytools import logme

    @logme
    def add(x, y):
        return x + y

    add(5, 6)

    # What was logged and where:
    # (DEBUG) 10/09/20 01:54:33 PM: func: add | args: (5, 6) | kwargs: {} | returned: 11
    # to file `myproject.py.log`

## `whatsmyip`

Use this at the command line to get your **public** IP address. This is just a convenience command due to me getting tired of having to specifically search "whats my ip ipv4" on Google. If I'm going to do *some* of the legwork, I may as well make it easy on myself.

# More

I have more planned. I have a changelog planned, so I don't clutter the README. I have docs planned, to also avoid cluttering the README. Some of these may already be in effect. I don't know, I'm not God. Jeez. (The changelog is in effect, though.)


            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "hackytools",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "",
    "author": "Hackysack",
    "author_email": "tk13xr37@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/b6/06/3a9e5837c6f6f5f867812098f7f9137c413edde083356e187b8c23a6eec6/hackytools-0.1.1.tar.gz",
    "platform": "",
    "description": "# hackytools\nHacky Tools, by Hackysack (I'll never get tired of that joke.)\n\n# Installation\nYou can install this package via the command:\n\n`pip install hackytools`\n\nTo get the development version instead (where there may be unstable features) use one of the following:\n\n`pip install https://github.com/H4CKY54CK/hackytools/archive/main.zip`  \n`pip install https://github.com/H4CKY54CK/hackytools/archive/main.tar.gz`\n\n# What do I get?\nSo far, not much. But I promise that I'm working hard at gathering a bunch of my homemade tools.\n\nFor right now, you get a couple of different hacky decorators, a spritesheet/stylesheet generator (mainly for subreddit CSS), and a command line tool (currently, only a single command).\n\n# Decorators\n\n## `@timeit`\n\nA decorator to time how long a function takes, illustrated below.\n\n    from hackytools import timeit\n    import time\n\n    # We need the `time` module to delay our test functions just a little bit.\n\n    # Time how long a function takes.\n    @timeit\n    def main1():\n        time.sleep(2)\n\n    # Same thing, but in case you're used to using parentheses\n    @timeit()\n    def main2():\n        time.sleep(.5)\n\n    # Get an average elapsed time by running your function 5 times.\n    @timeit(repeat=5)\n    def main3():\n        pass\n\n    if __name__ == '__main__':\n        main1()\n        main2()\n        main3()\n\n\n    # main1 elapsed: 2.00 s\n    # main2 elapsed: 500.38 ms\n    # main3 average elapsed: 616.67 ns | best (of 5): 300.00 ns | worst (of 5): 1.90 \u00c2\u00b5s\n\nThe timing decorator also automatically converts the time returned into a sensible unit, for optimal viewing pleasure.\n\nJust be careful that you don't repeat 50 times, and your code takes 50 seconds each run. That would take forever. Be smart.\n\n## `@timeable`\n\nThis does *nearly* the same thing as `@timeit`. However, `@timeable` by default, does **not** time your function. In fact, it doesn't interfere with it at all, unless explicitly told to do so. What do I mean? I'll explain.\n\n    from hackytools import timeable\n\n    @timeable\n    def some_function():\n        # do some stuff\n        return # or whatever\n\n    some_function()\n\n    # Even though it is decorated, this function will act normally. However...\n    # If we were to pass in a specific (unlikely to already be in use) kwargs\n    # dict such as the following (and unpack it with **):\n\n    some_function(**{'_frequency': 1})\n\n    # some_function elapsed: 1.20 \u00c2\u00b5s\n\n    # This WILL time the function, with a frequency of 1 time(s).\n\n    # \"But that function doesn't take any arguments!\", I hear you say.\n\n    # And you'd be right. Through the magic of decorators (and some pretty basic python)\n    # we can actually reach into the kwargs, get the value for this specific kwarg,\n    # and then remove the kwargs from the kwargs dict. ezpz\n\n## `@logme`\n\nThis is just a regular logging decorator. You decorate your function with `@logme`, and it logs some basic information about what just happened, to the file `{your_filename}.log`. So, if your filename was `myproject.py`, the logfile would literally be `myproject.py.log`. This is for several reasons, the most important being to not overwrite existing files. I should probably just add a file check.\n\n    # myproject.py\n\n    from hackytools import logme\n\n    @logme\n    def add(x, y):\n        return x + y\n\n    add(5, 6)\n\n    # What was logged and where:\n    # (DEBUG) 10/09/20 01:54:33 PM: func: add | args: (5, 6) | kwargs: {} | returned: 11\n    # to file `myproject.py.log`\n\n## `whatsmyip`\n\nUse this at the command line to get your **public** IP address. This is just a convenience command due to me getting tired of having to specifically search \"whats my ip ipv4\" on Google. If I'm going to do *some* of the legwork, I may as well make it easy on myself.\n\n# More\n\nI have more planned. I have a changelog planned, so I don't clutter the README. I have docs planned, to also avoid cluttering the README. Some of these may already be in effect. I don't know, I'm not God. Jeez. (The changelog is in effect, though.)\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Tools that are hacky. Obviously.",
    "version": "0.1.1",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "ebf56d53aa0fea555d36f12c49b5097d",
                "sha256": "f847a1ab4364ab5773c6b89f4427f78a3699cf0f5a767dd7d347e6fef95ebe4f"
            },
            "downloads": -1,
            "filename": "hackytools-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ebf56d53aa0fea555d36f12c49b5097d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 7353,
            "upload_time": "2020-11-22T04:00:30",
            "upload_time_iso_8601": "2020-11-22T04:00:30.448551Z",
            "url": "https://files.pythonhosted.org/packages/2b/17/af7c0f3041e60f2e428942f86481daa44e18a5f3f1c716526cbdafcf2c03/hackytools-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "b91f84b06d622cc2bf57a59e24d38d3c",
                "sha256": "87663de6fe2ebe6dad8989614b0440fa68d0e67aac8afba95d282e2e06ee7130"
            },
            "downloads": -1,
            "filename": "hackytools-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "b91f84b06d622cc2bf57a59e24d38d3c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 6166,
            "upload_time": "2020-11-22T04:00:31",
            "upload_time_iso_8601": "2020-11-22T04:00:31.345839Z",
            "url": "https://files.pythonhosted.org/packages/b6/06/3a9e5837c6f6f5f867812098f7f9137c413edde083356e187b8c23a6eec6/hackytools-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2020-11-22 04:00:31",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "hackytools"
}
        
Elapsed time: 0.17906s