added options for separator (csv,tsv) and projectName (all)
This commit is contained in:
parent
74ec004c8b
commit
6f8badae6a
21
refine.py
21
refine.py
|
@ -94,6 +94,8 @@ group5.add_option('--sheets', dest='sheets',
|
||||||
PARSER.add_option_group(group5)
|
PARSER.add_option_group(group5)
|
||||||
|
|
||||||
group6 = optparse.OptionGroup(PARSER, 'More create options (optional, only together with --format)')
|
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',
|
group6.add_option('--limit', dest='limit',
|
||||||
help='(all formats), default: -1')
|
help='(all formats), default: -1')
|
||||||
group6.add_option('--includeFileSources', dest='includeFileSources',
|
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')
|
help='(csv, tsv, line-based, fixed-width, xlsx, ods), default: 0')
|
||||||
group6.add_option('--storeBlankRows', dest='storeBlankRows',
|
group6.add_option('--storeBlankRows', dest='storeBlankRows',
|
||||||
help='(csv, tsv, line-based, fixed-width, xlsx, ods), default: true')
|
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',
|
group6.add_option('--processQuotes', dest='processQuotes',
|
||||||
help='(csv, tsv), default: true')
|
help='(csv, tsv), default: true')
|
||||||
group6.add_option('--storeBlankCellsAsNulls',
|
group6.add_option('--storeBlankCellsAsNulls',
|
||||||
|
@ -166,6 +170,9 @@ def create_project(options, file_fullpath):
|
||||||
encoding = ''
|
encoding = ''
|
||||||
if options.encoding:
|
if options.encoding:
|
||||||
encoding = options.encoding
|
encoding = options.encoding
|
||||||
|
separator = ','
|
||||||
|
if options.separator:
|
||||||
|
separator = options.separator
|
||||||
ignoreLines = '-1'
|
ignoreLines = '-1'
|
||||||
if options.ignoreLines:
|
if options.ignoreLines:
|
||||||
ignoreLines = options.ignoreLines
|
ignoreLines = options.ignoreLines
|
||||||
|
@ -194,7 +201,7 @@ def create_project(options, file_fullpath):
|
||||||
if options.includeFileSources:
|
if options.includeFileSources:
|
||||||
includeFileSources = options.includeFileSources
|
includeFileSources = options.includeFileSources
|
||||||
input_options = '{"encoding":"' + encoding + '"' \
|
input_options = '{"encoding":"' + encoding + '"' \
|
||||||
+ ',"separator":","' \
|
+ ',"separator":"' + separator + '"' \
|
||||||
+ ',"ignoreLines":' + ignoreLines \
|
+ ',"ignoreLines":' + ignoreLines \
|
||||||
+ ',"headerLines":' + headerLines \
|
+ ',"headerLines":' + headerLines \
|
||||||
+ ',"skipDataLines":' + skipDataLines \
|
+ ',"skipDataLines":' + skipDataLines \
|
||||||
|
@ -212,6 +219,9 @@ def create_project(options, file_fullpath):
|
||||||
encoding = ''
|
encoding = ''
|
||||||
if options.encoding:
|
if options.encoding:
|
||||||
encoding = options.encoding
|
encoding = options.encoding
|
||||||
|
separator = '\\t'
|
||||||
|
if options.separator:
|
||||||
|
separator = options.separator
|
||||||
ignoreLines = '-1'
|
ignoreLines = '-1'
|
||||||
if options.ignoreLines:
|
if options.ignoreLines:
|
||||||
ignoreLines = options.ignoreLines
|
ignoreLines = options.ignoreLines
|
||||||
|
@ -240,7 +250,7 @@ def create_project(options, file_fullpath):
|
||||||
if options.includeFileSources:
|
if options.includeFileSources:
|
||||||
includeFileSources = options.includeFileSources
|
includeFileSources = options.includeFileSources
|
||||||
input_options = '{"encoding":"' + encoding + '"' \
|
input_options = '{"encoding":"' + encoding + '"' \
|
||||||
+ ',"separator":"\\t"' \
|
+ ',"separator":"' + separator + '"' \
|
||||||
+ ',"ignoreLines":' + ignoreLines \
|
+ ',"ignoreLines":' + ignoreLines \
|
||||||
+ ',"headerLines":' + headerLines \
|
+ ',"headerLines":' + headerLines \
|
||||||
+ ',"skipDataLines":' + skipDataLines \
|
+ ',"skipDataLines":' + skipDataLines \
|
||||||
|
@ -437,11 +447,14 @@ def create_project(options, file_fullpath):
|
||||||
+ ',"includeFileSources":' + includeFileSources \
|
+ ',"includeFileSources":' + includeFileSources \
|
||||||
+ '}'
|
+ '}'
|
||||||
|
|
||||||
data = {}
|
|
||||||
file_name = os.path.split(file_fullpath)[-1]
|
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),
|
data['project-file'] = {'fd': open(file_fullpath),
|
||||||
'filename': file_name}
|
'filename': file_name}
|
||||||
data['project-name'] = file_name
|
data['project-name'] = projectName
|
||||||
|
|
||||||
response = urllib2.urlopen(servernewproject
|
response = urllib2.urlopen(servernewproject
|
||||||
+ '/command/core/create-project-from-upload?format='
|
+ '/command/core/create-project-from-upload?format='
|
||||||
|
|
Loading…
Reference in New Issue