Projects/laydi
Projects
/
laydi
Archived
7
0
Fork 0

Added -d option to get all identifiers along a single dimension.

This commit is contained in:
Einar Ryeng 2007-05-16 10:30:54 +00:00
parent c7bfefe358
commit 7bdfdea23b
1 changed files with 25 additions and 7 deletions

View File

@ -8,9 +8,9 @@ import re
PROGRAM_NAME = 'dataset'
VERSION = '0.1.0'
def show_info(input):
name = "N/A"
type = "N/A"
def read_dataset_header(input):
name = ""
type = ""
dimensions = []
kv_re = re.compile('^\s*#\s*(\w+)\s*:(.*)$')
@ -34,16 +34,31 @@ def show_info(input):
type = v
elif k == 'dimension':
values = v.split()
dimensions.append((values[0], len(values) - 1))
dimensions.append((values[0], values[1:]))
return (name, type, dimensions)
def show_info(input):
name, type, dimensions = read_dataset_header(input)
print "Name: %s" % name
print "Type: %s" % type
print "Dimensions:",
for i, dim in enumerate(dimensions):
print "%s(%i)" % dim,
dimname = dim[0]
length = len(dim[1])
print "%s(%i)" % (dimname, length),
if i < len(dimensions)-1:
print "x",
print
def list_dimension_ids(input, dimname):
name, type, dimensions = read_dataset_header(input)
for i, dim in enumerate(dimensions):
name, ids = dim
if name == dimname:
for id in ids:
print id
def parse_options():
conf_files = ['/etc/fluentsrc',
@ -57,7 +72,7 @@ def parse_options():
help='Export as CSV file.')
op.add_option('-d', '--dimension',
action='store_true', default=False,
action='store', default=None,
help='Get all identifiers along a dimension.')
op.add_option('-i', '--info',
@ -96,3 +111,6 @@ if __name__ == '__main__':
show_info(input)
sys.exit(0)
elif options.dimension != None:
list_dimension_ids(input, options.dimension)