added options for separator (csv,tsv) and projectName (all)

This commit is contained in:
Felix Lohmeier 2017-03-01 04:25:20 +01:00
parent 74ec004c8b
commit 6f8badae6a
1 changed files with 17 additions and 4 deletions

View File

@ -94,6 +94,8 @@ group5.add_option('--sheets', dest='sheets',
PARSER.add_option_group(group5)
group6 = optparse.OptionGroup(PARSER, 'More create options (optional, only together with --format)')
group6.add_option('--projectName', dest='projectName',
help='(all formats), default: (filename)')
group6.add_option('--limit', dest='limit',
help='(all formats), default: -1')
group6.add_option('--includeFileSources', dest='includeFileSources',
@ -114,6 +116,8 @@ group6.add_option('--skipDataLines', dest='skipDataLines',
help='(csv, tsv, line-based, fixed-width, xlsx, ods), default: 0')
group6.add_option('--storeBlankRows', dest='storeBlankRows',
help='(csv, tsv, line-based, fixed-width, xlsx, ods), default: true')
group6.add_option('--separator', dest='separator',
help='(csv, tsv), default: csv: , tsv: \\t')
group6.add_option('--processQuotes', dest='processQuotes',
help='(csv, tsv), default: true')
group6.add_option('--storeBlankCellsAsNulls',
@ -166,6 +170,9 @@ def create_project(options, file_fullpath):
encoding = ''
if options.encoding:
encoding = options.encoding
separator = ','
if options.separator:
separator = options.separator
ignoreLines = '-1'
if options.ignoreLines:
ignoreLines = options.ignoreLines
@ -194,7 +201,7 @@ def create_project(options, file_fullpath):
if options.includeFileSources:
includeFileSources = options.includeFileSources
input_options = '{"encoding":"' + encoding + '"' \
+ ',"separator":","' \
+ ',"separator":"' + separator + '"' \
+ ',"ignoreLines":' + ignoreLines \
+ ',"headerLines":' + headerLines \
+ ',"skipDataLines":' + skipDataLines \
@ -212,6 +219,9 @@ def create_project(options, file_fullpath):
encoding = ''
if options.encoding:
encoding = options.encoding
separator = '\\t'
if options.separator:
separator = options.separator
ignoreLines = '-1'
if options.ignoreLines:
ignoreLines = options.ignoreLines
@ -240,7 +250,7 @@ def create_project(options, file_fullpath):
if options.includeFileSources:
includeFileSources = options.includeFileSources
input_options = '{"encoding":"' + encoding + '"' \
+ ',"separator":"\\t"' \
+ ',"separator":"' + separator + '"' \
+ ',"ignoreLines":' + ignoreLines \
+ ',"headerLines":' + headerLines \
+ ',"skipDataLines":' + skipDataLines \
@ -437,11 +447,14 @@ def create_project(options, file_fullpath):
+ ',"includeFileSources":' + includeFileSources \
+ '}'
data = {}
file_name = os.path.split(file_fullpath)[-1]
projectName = file_name
if options.projectName:
projectName = options.projectName
data = {}
data['project-file'] = {'fd': open(file_fullpath),
'filename': file_name}
data['project-name'] = file_name
data['project-name'] = projectName
response = urllib2.urlopen(servernewproject
+ '/command/core/create-project-from-upload?format='