#!/usr/bin/env python import os, sys fpath = os.path.dirname(os.path.abspath(__file__)) # parsec sys.path.append( fpath + '/../../..' ) """ Check that single-line config print works """ from config import config from validate import validator as vdr from OrderedDict import OrderedDict SPEC = { 'foo' : { 'bar' : { '__MANY__' : vdr( vtype="string" ) } } } cfg = config( SPEC ) cfg.loadcfg( "test.rc" ) cfg.mdump ( [['foo','bar','baz'],['foo','bar','qux']], oneline=True, sparse=True)
#!/usr/bin/env python import os, sys fpath = os.path.dirname(os.path.abspath(__file__)) # parsec sys.path.append( fpath + '/../../..' ) """ An empty config file should successfully yield an empty sparse config dict. """ from config import config from validate import validator as vdr from OrderedDict import OrderedDict SPEC = { 'title' : vdr( vtype="string" ) } cfg = config( SPEC ) cfg.loadcfg( "empty.rc" ) if cfg.get(sparse=True) != OrderedDict(): sys.exit(1)
os.path.join(os.path.dirname(os.path.abspath(__file__)), '..')) from fileparse import parse from util import printcfg from validate import validator as vdr from validate import validate, expand """ Legal items and validators for the parsec test config file. """ TEST_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'test.rc') cfg = None SPEC = { 'unquoted': vdr(vtype="string"), 'continuation': vdr(vtype="string"), 'level 1': { 'single-quoted': vdr(vtype="string"), 'level 2': { 'double-quoted': vdr(vtype="string"), 'level 3': { 'single-line triple-single-quoted': vdr(vtype="string"), 'single-line triple-double-quoted': vdr(vtype="string"), 'empty value': vdr(vtype="string"), }, }, 'level 2_2': { 'multiline value': vdr(vtype="string"), '__MANY__': vdr(vtype="string"), },
#C: This program is distributed in the hope that it will be useful, #C: but WITHOUT ANY WARRANTY; without even the implied warranty of #C: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #C: GNU General Public License for more details. #C: #C: You should have received a copy of the GNU General Public License #C: along with this program. If not, see <http://www.gnu.org/licenses/>. from validate import validator as vdr """ Legal items and validators for the parsec test config file. """ SPEC = { 'title' : vdr( vtype="string" ), 'single values' : { 'integers' : { '__MANY__' : vdr( vtype="integer" ) }, 'booleans' : { '__MANY__' : vdr( vtype="boolean" ) }, 'floats' : { '__MANY__' : vdr( vtype="float" ) }, 'strings' : { '__MANY__' : vdr( vtype="string" ) }, 'strings with internal comments' : { '__MANY__' : vdr( vtype="string" ) }, 'multiline strings' : { '__MANY__' : vdr( vtype="string" ) }, 'multiline strings with internal comments' : { '__MANY__' : vdr( vtype="string" ) }, }, 'list values' : { 'string lists' : { '__MANY__' : vdr( vtype="string_list" ),
from fileparse import parse from util import printcfg from validate import validator as vdr from validate import validate, expand """ Legal items and validators for the parsec test config file. """ TEST_FILE = os.path.join( os.path.dirname( os.path.abspath( __file__ )), 'test.rc' ) cfg = None SPEC = { 'unquoted' : vdr( vtype="string" ), 'continuation' : vdr( vtype="string" ), 'level 1' : { 'single-quoted' : vdr( vtype="string" ), 'level 2' : { 'double-quoted' : vdr( vtype="string" ), 'level 3' : { 'single-line triple-single-quoted' : vdr( vtype="string" ), 'single-line triple-double-quoted' : vdr( vtype="string" ), 'empty value' : vdr( vtype="string" ), }, }, 'level 2_2' :
#C: (at your option) any later version. #C: #C: This program is distributed in the hope that it will be useful, #C: but WITHOUT ANY WARRANTY; without even the implied warranty of #C: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #C: GNU General Public License for more details. #C: #C: You should have received a copy of the GNU General Public License #C: along with this program. If not, see <http://www.gnu.org/licenses/>. from validate import validator as vdr SPEC = { 'boolean': { '__MANY__': { '__MANY__': vdr(vtype="boolean") }, }, 'integer': { '__MANY__': { '__MANY__': vdr(vtype="integer") }, }, 'float': { '__MANY__': { '__MANY__': vdr(vtype="float") }, }, 'string': { '__MANY__': { '__MANY__': vdr(vtype="string")
#!/usr/bin/env python import os, sys fpath = os.path.dirname(os.path.abspath(__file__)) # parsec sys.path.append(fpath + '/../../..') """ An empty config file should successfully yield an empty sparse config dict. """ from config import config from validate import validator as vdr from OrderedDict import OrderedDict SPEC = {'title': vdr(vtype="string")} cfg = config(SPEC) cfg.loadcfg("empty.rc") if cfg.get(sparse=True) != OrderedDict(): sys.exit(1)
#C: #C: This program is distributed in the hope that it will be useful, #C: but WITHOUT ANY WARRANTY; without even the implied warranty of #C: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #C: GNU General Public License for more details. #C: #C: You should have received a copy of the GNU General Public License #C: along with this program. If not, see <http://www.gnu.org/licenses/>. from validate import validator as vdr """ Legal items and validators for the parsec test config file. """ SPEC = { 'title': vdr(vtype="string"), 'single values': { 'integers': { '__MANY__': vdr(vtype="integer") }, 'booleans': { '__MANY__': vdr(vtype="boolean") }, 'floats': { '__MANY__': vdr(vtype="float") }, 'strings': { '__MANY__': vdr(vtype="string") }, 'strings with internal comments': { '__MANY__': vdr(vtype="string")
#C: the Free Software Foundation, either version 3 of the License, or #C: (at your option) any later version. #C: #C: This program is distributed in the hope that it will be useful, #C: but WITHOUT ANY WARRANTY; without even the implied warranty of #C: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #C: GNU General Public License for more details. #C: #C: You should have received a copy of the GNU General Public License #C: along with this program. If not, see <http://www.gnu.org/licenses/>. from validate import validator as vdr SPEC = { 'boolean' : { '__MANY__' : { '__MANY__' : vdr( vtype="boolean" ) }, }, 'integer' : { '__MANY__' : { '__MANY__' : vdr( vtype="integer" ) }, }, 'float' : { '__MANY__' : { '__MANY__' : vdr( vtype="float" ) }, }, 'string' : { '__MANY__' : { '__MANY__' : vdr( vtype="string" ) }, }, 'string_list' : { '__MANY__' : { '__MANY__' : vdr( vtype="string_list" ) }, }, 'float_list' : { '__MANY__' : { '__MANY__' : vdr( vtype="float_list", allow_zeroes=False ) },