# -*- coding: utf-8 -*-
"""
Created on Thu Aug 28 11:35:25 2014

@author: markgot
"""
import time
import sys
import os.path
import os

__version__ = "1.0"

class var():
    """
Variable object.
holds the changes done to the variable with time

Parameters
--------
name : name of the variable
bits : number of bits in the variable
wire : not implemented

Examples
-------
A sweeping clock

>>> from vcd import var
>>> v = var('clk')
>>> v.append('0', 0)
>>> v.append(1, 1)
>>> v.append([0,1], [2,3])
>>> v.append(['0', '1'], [4, 5])
>>> v.append([0, 1]*50, range(6, 106))
"""

    def __init__(self, name, bits=1, wire=True):
        self._name = name
        self._bits = bits
        self._wire = wire
        self._data = []
        self._char = ''

    def append(self, data, time, timeFromLast=True):
        """
Appends changes to variable state over time.
The 'time' variable is how long since the last change.
If arrays of values are appended both arrays MUST be of the same length. \n
Parameters:
--------
data : array or single input
    single point - 0,1,'0','1','x','z'\n
    set of points - [0,1,0] ,['0','x','z','0']\n
time : array or single input
    single point - number of # from last\n
    set of points - set of times when data is also a list\n
Examples:
--------
>>> from vcd import var
>>> v = var('clk')
>>> v.append('0', 0)
>>> v.append(1, 1)
>>> v.append([0,1], [2,3])
>>> v.append(['0', '1'], [4, 5])
>>> v.append([0, 1]*50, range(6, 106))
        """
        if (type(data) is int or type(data) is str) and type(time) is int:
            if type(data) is int:
                data = str(data)
            self._data.append((data, time))
            return 'succses'

        elif type(data) is list and type(time) is list:
            if len(data) != len(time):
                return 'list lengths do not equal'
            for i in xrange(len(data)):