pyyc package

Documentation for package pyyc.

pyyc.mod module

Documentation for module mod.

pyyc.mod.addition(*args)[source]

Addition function (undefined type).

Arguments should support mutual addition:

\[\mathrm{out} = \sum_i \mathrm{arg}_i\]
Parameters:

args – parameters

Returns:

python addition of args

Raises:

TypeError – arguments cannot be summed together

>>> addition(1, 2, 3)
6
>>> addition("abc", "def")
'abcdef'
>>> addition([1], [2, 3], [4, 5, 6])
[1, 2, 3, 4, 5, 6]
>>> addition(1, "abc")
Traceback (most recent call last):
    ...
TypeError: unsupported operand type(s) for +=: 'int' and 'str'
pyyc.mod.addition_int(*args)[source]

Addition function for integers (includes cast to integer).

Parameters:

args (int) – arguments to be casted to integer

Returns:

integer addition of args

Return type:

int

Raises:

ValueError – if arguments cannot be casted to integer.

>>> addition_int(1, 2, 3)
6
>>> addition_int('1', 2)
3
>>> addition_int("abc", "def")
Traceback (most recent call last):
    ...
ValueError: Arguments must cast to integer.
pyyc.mod.PYYC_PATH = MultiplexedPath('/builds/ycopin/pyyc/pyyc/config')

Path to pyyc configuration file.

pyyc.mod.read_config(cfgname='default.cfg')[source]

Get config from configuration file.

If the input filename does not specifically include a path, it will be looked for in the default PYYC_PATH directory.

Parameters:

cfgname (str) – configuration file name

Returns:

configuration object

Return type:

configparser.ConfigParser

>>> cfg = read_config()  
Reading configuration from ...
>>> cfg['DEFAULT']['version']
'cfg-1.0'
pyyc.mod.format_pkg_tree(node, max_depth=2, printout=False, depth=0)[source]

Format the package architecture.

Parameters:
  • node (module) – name of the top-level module

  • max_depth (int) – maximum depth of recursion

  • printout (bool) – print out the resulting string

  • depth (int) – depth level (used for recursion)

Returns:

structure as a list of strings (without newlines)

Return type:

list

>>> import pyyc
>>> format_pkg_tree(pyyc, max_depth=1)  
['pyyc',
 '  pyyc.config',
 '  pyyc.mod',
 '  pyyc.subpkgA',
 '  pyyc.subpkgB']
pyyc.mod.greetings()[source]

Stupid function, to illustrate tests on stdin/stdout.

Subpackages