Kouhei Sutou
null+****@clear*****
Mon Mar 10 15:12:58 JST 2014
Kouhei Sutou 2014-03-10 15:12:58 +0900 (Mon, 10 Mar 2014) New Revision: 0f30c480866853c95673d9963242e1b9ada2ebe3 https://github.com/groonga/groonga/commit/0f30c480866853c95673d9963242e1b9ada2ebe3 Message: doc execution example: support continuous line Modified files: doc/source/example/reference/columns/vector/usage_adjuster_weight.log doc/update_execution_example.py Modified: doc/source/example/reference/columns/vector/usage_adjuster_weight.log (+52 -0) =================================================================== --- doc/source/example/reference/columns/vector/usage_adjuster_weight.log 2014-03-10 14:49:35 +0900 (e8cb584) +++ doc/source/example/reference/columns/vector/usage_adjuster_weight.log 2014-03-10 15:12:58 +0900 (413b75a) @@ -4,3 +4,55 @@ Execution example:: --filter true \ --adjuster 'tags @ "mysql" * 10 + tags @ "groonga" * 5' \ --output_columns _key,tags,_score + # [ + # [ + # 0, + # 1337566253.89858, + # 0.000355720520019531 + # ], + # [ + # [ + # [ + # 3 + # ], + # [ + # [ + # "_key", + # "ShortText" + # ], + # [ + # "tags", + # "ShortText" + # ], + # [ + # "_score", + # "Int32" + # ] + # ], + # [ + # "http://groonga.org/", + # { + # "groonga": 100 + # }, + # 506 + # ], + # [ + # "http://mroonga.org/", + # { + # "mroonga": 100, + # "groonga": 10, + # "mysql": 50 + # }, + # 566 + # ], + # [ + # "http://ranguba.org/", + # { + # "ruby": 100, + # "groonga": 50 + # }, + # 256 + # ] + # ] + # ] + # ] Modified: doc/update_execution_example.py (+11 -2) =================================================================== --- doc/update_execution_example.py 2014-03-10 14:49:35 +0900 (1464ed5) +++ doc/update_execution_example.py 2014-03-10 15:12:58 +0900 (71d812a) @@ -46,10 +46,17 @@ def normalize_output(output): status[2] = normalized_elapsed_time return output +def remove_continuous_marks(command): + return re.sub('\\\\\n', '', command) + +def prepend_prefix(prefix, command): + beginning_of_line = re.compile('^', re.M) + return beginning_of_line.sub(prefix, command) + def execmd(command, fout): stdout.write(command + "\n") stdout.flush() - groonga_process.stdin.write(command + "\n") + groonga_process.stdin.write(remove_continuous_marks(command) + "\n") groonga_process.stdin.flush() is_command = re.match("[a-z/]", command) is_load_command = re.match("load ", command) @@ -59,7 +66,7 @@ def execmd(command, fout): prefix = " " else: prefix = " % curl http://localhost:10041" - formatted_command_line = prefix + command + "\n" + formatted_command_line = prepend_prefix(prefix, command) + "\n" fout.write(formatted_command_line) is_load_data_end = re.match("^\]", command) if is_load_command: @@ -166,6 +173,8 @@ def readfile(fname, outflag): execmd(dat.pop(0), fout) else: cmd = cmd[3:] + while cmd.endswith('\\'): + cmd += '\n' + re.sub('^\.\. ', '', dat.pop(0)) execmd(cmd, fout) else: print '### command end' -------------- next part -------------- HTML����������������������������...Download