Did I find the right examples for you? yes no

All Samples(13)  |  Call(10)  |  Derive(0)  |  Import(3)
Pretty-print an item from list of sections, item name, and value
E.g.: ([sec1, sec2], item, value) to '[sec1][sec2]item = value'.

        def itemstr( parents=[], item=None, value=None ):
    """
    Pretty-print an item from list of sections, item name, and value
    E.g.: ([sec1, sec2], item, value) to '[sec1][sec2]item = value'.
    """
    keys = copy(parents)
    if keys and value and not item:
        # last parent is the item
        item = keys[-1]
        keys.remove(item)
    if parents:
        s = '[' + ']['.join(parents) + ']'
    else:
        s = ''
    if item:
        s += str(item)
        if value:
            s += " = " + str(value)
    if not s:
        s = str(value)

    return s
        


src/c/y/cylc-HEAD/lib/parsec/validate.py   cylc(Download)
import sys, re
from OrderedDict import OrderedDict
from util import m_override, un_many, itemstr
from copy import copy
 
    def __init__( self, vtype, keys, value ):
        msg = 'Illegal ' + vtype + ' value: ' + itemstr( keys, value=value )
        ValidationError.__init__( self, msg )
 
class IllegalItemError( ValidationError ):
    def __init__( self, keys, key ):
        msg = 'Illegal item: ' + itemstr( keys, key )

src/c/y/cylc-HEAD/lib/parsec/fileparse.py   cylc(Download)
from OrderedDict import OrderedDict
from include import inline, IncludeFileNotFoundError
from util import itemstr
import cylc.flags
 
        # this doesn't warrant a warning unless contained items are repeated
        if cylc.flags.verbose:
            print 'Section already encountered: ' + itemstr( parents + [sname] )
    else:
        cfig[sname] = OrderedDict()
    if not isinstance( cfig, dict ):
        # an item of this name has already been encountered at this level
        print >> sys.stderr, itemstr( parents, key, val )
        raise ParseError( 'ERROR line ' + str(index) + ': already encountered ' + itemstr( parents ))
 
            # append the new graph string to the existing one
           if cylc.flags.verbose:
               print 'Merging graph strings under ' + itemstr( parents )
           if not isinstance( cfig[key], list ):
               cfig[key] = [cfig[key]]

src/c/y/cylc-HEAD/lib/parsec/config.py   cylc(Download)
from validate import validate, check_compulsory, expand
from OrderedDict import OrderedDict
from util import replicate, itemstr
from upgrade import UpgradeError
from validate import validator
            else:
                if not isinstance( value, validator ):
                    raise ParsecError( "Illegal file spec item: " + itemstr( pars, repr(value)) )
 
 
                cfg = cfg[key]
            except KeyError, x:
                raise ItemNotFoundError( itemstr(parents,key) )
            else:
                parents.append(key)
                item = self.get( keys, sparse )
                if isinstance( item, list ) or isinstance( item, dict ):
                    raise NotSingleItemError( itemstr(keys) )
                if not item:
                    item = none_str or "None"