Dunder v0.1.1

Dunder is a small module which extracts dunder variables from Python source files.

Example

The following example demonstrates the functionality available in the module.

Using the following Python source file test.py

# -*- coding: utf-8 -*-

# Copyright 2014 Joe Bloggs Inc.

"""Module docstring"""

import datetime

__all__ = ['a']

__version__ = "0.1"
__author__ = "Joe Bloggs <joe.bloggs@example.com>"
__wally__ = 1
__dave__ = 1.1
__brian__ = (1, 2, 3)

def a():
    __walter__ = 'dave'

Running the following code will extract the ‘dunder’ variables and present them as a dictionary

>>> import dunder
>>> d = dunder.parse('test.py')
>>> print(d['__version__'])
0.1
>>> print(d['__walter__'])
dave

Note

For lists and tuples only values of a single level are parsed correctly i.e. (1, 2) and [2, ‘s’] work but [1, [3, 5], 6] doesn’t

License

This module is licensed under the terms of the Apache V2.0 license.

Dependencies

Dunder has no external dependencies.

Installation

Installation can be performed by using the pip command.

pip install dunder

Version History

Version Description
0.1.1 Use some selfdogfooding in setup.py
0.1 First release