Projects/laydi
Projects
/
laydi
Archived
7
0
Fork 0

Piping information through dataset -i works. Added names of planned features

to the dataset script.
This commit is contained in:
Einar Ryeng 2007-05-09 21:52:59 +00:00
parent 7272eb63d2
commit 1ab558248c
1 changed files with 67 additions and 6 deletions

View File

@ -3,10 +3,48 @@
import os,sys import os,sys
from fluents import dataset from fluents import dataset
import cfgparse, optparse import cfgparse, optparse
import re
PROGRAM_NAME = 'dataset' PROGRAM_NAME = 'dataset'
VERSION = '0.1.0' VERSION = '0.1.0'
def show_info(input):
name = "N/A"
type = "N/A"
dimensions = []
kv_re = re.compile('^\s*#\s*(\w+)\s*:(.*)$')
lines = []
line = input.readline()
while line.startswith('#'):
lines.append(line)
line = input.readline()
for line in lines:
match = kv_re.match(line)
if not match:
continue
k, v = match.groups()
k = k.strip()
if k == 'name':
name = v
elif k == 'type':
type = v
elif k == 'dimension':
values = v.split()
dimensions.append((values[0], len(values) - 1))
print "Name: %s" % name
print "Type: %s" % type
print "Dimensions:",
for i, dim in enumerate(dimensions):
print "%s(%i)" % dim,
if i < len(dimensions)-1:
print "x",
def parse_options(): def parse_options():
conf_files = ['/etc/fluentsrc', conf_files = ['/etc/fluentsrc',
os.path.join(os.environ['HOME'], '.fluents')] os.path.join(os.environ['HOME'], '.fluents')]
@ -14,12 +52,34 @@ def parse_options():
cp = cfgparse.ConfigParser() cp = cfgparse.ConfigParser()
op = optparse.OptionParser() op = optparse.OptionParser()
op.add_option('-c', '--csv',
action='store_true', default=False,
help='Export as CSV file.')
op.add_option('-d', '--dimension',
action='store_true', default=False,
help='Get all identifiers along a dimension.')
op.add_option('-i', '--info', op.add_option('-i', '--info',
action='store_true', action='store_true', default=False,
default=False,
help='Show dataset information.') help='Show dataset information.')
# op.add_option('- op.add_option('-l', '--longinfo',
action='store_true', default=False,
help='Display more information than -i.')
op.add_option('-o', '--output-file',
action='store_true', default=False,
help='Send output to file instead of stdout.')
op.add_option('-t', '--transpose',
action='store_true', default=False,
help='Transpose dataset.')
op.add_option('-y', '--change-type',
action='store_true', default=False,
help='Set new dataset type.')
for cf in conf_files: for cf in conf_files:
if os.path.isfile(cf): if os.path.isfile(cf):
@ -29,9 +89,10 @@ def parse_options():
if __name__ == '__main__': if __name__ == '__main__':
options, params = parse_options() options, params = parse_options()
input = sys.stdin
output = sys.stdout
if options.help: if options.info:
print_help() show_info(input)
sys.exit(0) sys.exit(0)