示例#1
0
    def test_token(self):
        a = sh.Token('a')
        self.assertNotEqual(a, 'a')
        self.assertEqual(str(a), 'a')
        self.assertTrue(a >= 'a')
        self.assertNotEqual(a, sh.Token('a'))
        self.assertEqual(a, copy(a))
        self.assertEqual(a, deepcopy(a))
        self.assertEqual(sorted(['c', a, 'b'], key=str), [a, 'b', 'c'])

        a = sh.Token(1)
        self.assertNotEqual(a, '1')
        self.assertEqual(str(a), '1')

        b = a
        self.assertEqual({a: 1, 1: 3}, {b: 1, 1: 3})
示例#2
0
# Licensed under the EUPL (the 'Licence');
# You may not use this work except in compliance with the Licence.
# You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl
"""
It provides Cell class.
"""
import copy
import collections
import functools
import numpy as np
import schedula as sh
from .parser import Parser
from .ranges import Ranges, _assemble_values
from .tokens.operand import Error, XlError

CELL = sh.Token('Cell')


class CellWrapper:
    def __init__(self, func, parse_args, parse_kwargs):
        self.func = func
        self.parse_args = parse_args
        self.parse_kwargs = parse_kwargs

    def __call__(self, *args, **kwargs):
        return self.func(*self.parse_args(*args),
                         **self.parse_kwargs(**kwargs))

    def check_cycles(self, cycle):
        import networkx as nx
        func = self.func
示例#3
0
    ~operators
    ~stat
    ~text
"""
import re
import copy
import importlib
import functools
import collections
import numpy as np
import schedula as sh
from formulas.errors import (RangeValueError, FoundError, BaseError,
                             BroadcastError, InvalidRangeError)
from formulas.tokens.operand import Error, XlError

COMPILING = sh.Token('Run')


def _init_reshape(base_shape, value):
    res, (r, c) = np.empty(base_shape, object), value.shape
    res[:, :] = getattr(value, '_default', Error.errors['#N/A'])
    r = None if r == 1 else r
    c = None if c == 1 else c
    return res, r, c


class Array(np.ndarray):
    _default = Error.errors['#N/A']

    _collapse_value = None
示例#4
0
# Copyright 2016-2018 European Commission (JRC);
# Licensed under the EUPL (the 'Licence');
# You may not use this work except in compliance with the Licence.
# You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl
"""
It provides Excel model class.
"""

import os.path as osp
import schedula as sh
from .ranges import Ranges
from .cell import Cell, RangesAssembler
from .tokens.operand import range2parts, XlError
from .functions import flatten

BOOK = sh.Token('Book')
SHEETS = sh.Token('Sheets')
CIRCULAR = sh.Token('CIRCULAR')
ERR_CIRCULAR = XlError('0')


def _get_name(name, names):
    if name not in names:
        name = name.upper()
        for n in names:
            if n.upper() == name:
                return n
    return name


class ExcelModel:
示例#5
0
# Licensed under the EUPL (the 'Licence');
# You may not use this work except in compliance with the Licence.
# You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl
"""
It provides excel model class.
"""

import openpyxl
import os.path as osp
import schedula as sh
from .ranges import Ranges
from .cell import Cell, RangesAssembler
from .tokens.operand import range2parts
from .functions import flatten

BOOK = sh.Token('Book')
SHEETS = sh.Token('Sheets')


def _get_name(name, names):
    if name not in names:
        name = name.upper()
        for n in names:
            if n.upper() == name:
                return n
    return name


class ExcelModel(object):
    def __init__(self):
        self.dsp = sh.Dispatcher()