IssueID #1835: fixed use of tempfile
This commit is contained in:
parent
cb6960f58a
commit
59dd78f9b2
|
@ -1,24 +1,26 @@
|
||||||
import argparse
|
import argparse
|
||||||
import tempfile
|
import tempfile
|
||||||
import os
|
import shutil
|
||||||
|
|
||||||
from structure_assignment.pipeline import Pipeline, create_nlp
|
from structure_assignment.pipeline import Pipeline, create_nlp
|
||||||
|
|
||||||
resource_directory = '../resources'
|
resource_directory = '../resources'
|
||||||
|
|
||||||
def run_all(input_file_name, output_file_name, nlp, structure_file_name):
|
def run_all(input_file_name, output_file_name, nlp, structure_file_name):
|
||||||
tmp_file_name = tempfile.mksfile()
|
tmp_directory = tempfile.mkdtemp()
|
||||||
string_to_parse(input_file_name, tmp_file_name, nlp)
|
tmp_file_name = tmp_directory + '/parsed.xml'
|
||||||
|
strings_to_parse(input_file_name, tmp_file_name, nlp)
|
||||||
parse_to_dictionary(tmp_file_name, output_file_name, structure_file_name)
|
parse_to_dictionary(tmp_file_name, output_file_name, structure_file_name)
|
||||||
os.remove(tmp_file_name)
|
shutil.rmtree(tmp_directory)
|
||||||
validate_structures(structure_file_name)
|
validate_structures(structure_file_name)
|
||||||
validate_dictionary(output_file_name)
|
validate_dictionary(output_file_name)
|
||||||
|
|
||||||
def strings_to_dictionary(input_file_name, output_file_name, nlp, structure_file_name):
|
def strings_to_dictionary(input_file_name, output_file_name, nlp, structure_file_name):
|
||||||
tmp_file_name = tempfile.mksfile()
|
tmp_directory = tempfile.mkdtemp()
|
||||||
string_to_parse(input_file_name, tmp_file_name, nlp)
|
tmp_file_name = tmp_directory + '/parsed.xml'
|
||||||
|
strings_to_parse(input_file_name, tmp_file_name, nlp)
|
||||||
parse_to_dictionary(tmp_file_name, output_file_name, structure_file_name)
|
parse_to_dictionary(tmp_file_name, output_file_name, structure_file_name)
|
||||||
os.remove(tmp_file_name)
|
shutil.rmtree(tmp_directory)
|
||||||
|
|
||||||
def strings_to_parse(input_file_name, output_file_name, nlp):
|
def strings_to_parse(input_file_name, output_file_name, nlp):
|
||||||
pipeline = Pipeline(resource_directory, nlp)
|
pipeline = Pipeline(resource_directory, nlp)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user