1111from ted_sws .resources import XSLT_FILES_PATH
1212
1313UNIQUE_XPATHS_XSLT_FILE_PATH = "get_unique_xpaths.xsl"
14- XPATHS_XSLT_FILE_PATH = "get_xpaths.xsl"
1514XSLT_PREFIX_RESULT = "<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>"
1615
1716
@@ -29,7 +28,7 @@ def index_notice_by_id(notice_id: str, mongodb_client: MongoClient):
2928 notice_repository .update (notice = notice )
3029
3130
32- def index_notice (notice : Notice , xslt_transformer = None , unique = True ) -> Notice :
31+ def index_notice (notice : Notice , xslt_transformer = None ) -> Notice :
3332 """
3433 This function selects unique XPath from XMlManifestation from a notice and indexes notices with these unique XPath.
3534 :param notice:
@@ -42,20 +41,16 @@ def index_notice(notice: Notice, xslt_transformer=None, unique=True) -> Notice:
4241 fp .write (notice .xml_manifestation .object_data .encode ("utf-8" ))
4342 xml_path = pathlib .Path (fp .name )
4443 xslt_path = XSLT_FILES_PATH
45- if unique :
46- xslt_path /= UNIQUE_XPATHS_XSLT_FILE_PATH
47- else :
48- xslt_path /= XPATHS_XSLT_FILE_PATH
44+ xslt_path /= UNIQUE_XPATHS_XSLT_FILE_PATH
45+
4946 if xslt_transformer is None :
5047 xslt_transformer = XMLPreprocessor ()
5148 result = xslt_transformer .transform_with_xslt_to_string (xml_path = xml_path ,
5249 xslt_path = xslt_path )
5350 xpaths = result [len (XSLT_PREFIX_RESULT ):].split ("," )
5451 xml_metadata = XMLMetadata ()
55- if unique :
56- xml_metadata .unique_xpaths = xpaths
57- else :
58- xml_metadata .xpaths = xpaths
52+ xml_metadata .unique_xpaths = xpaths
53+
5954 notice .set_xml_metadata (xml_metadata = xml_metadata )
6055
6156 return notice
0 commit comments