|
@@ -3,7 +3,6 @@
|
|
import platform
|
|
import platform
|
|
import unittest
|
|
import unittest
|
|
import os
|
|
import os
|
|
-from typing import Union
|
|
|
|
from datetime import datetime
|
|
from datetime import datetime
|
|
|
|
|
|
import ujson
|
|
import ujson
|
|
@@ -156,7 +155,7 @@ class efactTest(unittest.TestCase):
|
|
print(latest)
|
|
print(latest)
|
|
# os.replace(latest, latest.replace('.xml'.lower(), '_booked.xml'))
|
|
# os.replace(latest, latest.replace('.xml'.lower(), '_booked.xml'))
|
|
|
|
|
|
- def test_rename_all(self, dir_path, kind: Union[str, 'seller', 'buyer']): # @UndefinedVariable
|
|
|
|
|
|
+ def test_rename_all(self, dir_path, kind: str): # @UndefinedVariable
|
|
if kind == 'seller':
|
|
if kind == 'seller':
|
|
account = 'AccountingCustomerParty'
|
|
account = 'AccountingCustomerParty'
|
|
# print(os.path.basename(dir_path))
|
|
# print(os.path.basename(dir_path))
|
|
@@ -175,25 +174,25 @@ class efactTest(unittest.TestCase):
|
|
tree = etree.parse(os.path.join(root_f, file))
|
|
tree = etree.parse(os.path.join(root_f, file))
|
|
root = tree.getroot()
|
|
root = tree.getroot()
|
|
inv_id = root.xpath('//cbc:ID', namespaces={'cbc': 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2'})
|
|
inv_id = root.xpath('//cbc:ID', namespaces={'cbc': 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2'})
|
|
- inv_id = inv_id[0].text
|
|
|
|
|
|
+ inv_id = inv_id[0].text # noqa
|
|
parties = root.xpath('//cbc:RegistrationName', namespaces={'cbc': 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2'})
|
|
parties = root.xpath('//cbc:RegistrationName', namespaces={'cbc': 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2'})
|
|
- for partie in parties:
|
|
|
|
- parent_p_type = partie.getparent().getparent().getparent()
|
|
|
|
|
|
+ for partie in parties: # noqa
|
|
|
|
+ parent_p_type = partie.getparent().getparent().getparent() # noqa
|
|
if etree.QName(parent_p_type).localname == account: # @UndefinedVariable
|
|
if etree.QName(parent_p_type).localname == account: # @UndefinedVariable
|
|
# print(partie.text)
|
|
# print(partie.text)
|
|
- file_partie = partie.text
|
|
|
|
|
|
+ file_partie = partie.text # noqa
|
|
|
|
|
|
is_date = root.xpath('//cbc:IssueDate', namespaces={'cbc': 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2'})
|
|
is_date = root.xpath('//cbc:IssueDate', namespaces={'cbc': 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2'})
|
|
- is_date = is_date[0].text
|
|
|
|
|
|
+ is_date = is_date[0].text # noqa
|
|
|
|
|
|
partie_ids = root.xpath('//cbc:CompanyID', namespaces={'cbc': 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2'})
|
|
partie_ids = root.xpath('//cbc:CompanyID', namespaces={'cbc': 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2'})
|
|
- for partie_id in partie_ids:
|
|
|
|
- parent_p_type = partie_id.getparent().getparent().getparent()
|
|
|
|
- parent_t_type = partie_id.getparent()
|
|
|
|
|
|
+ for partie_id in partie_ids: # noqa
|
|
|
|
+ parent_p_type = partie_id.getparent().getparent().getparent() # noqa
|
|
|
|
+ parent_t_type = partie_id.getparent() # noqa
|
|
# print(parent_t_type)
|
|
# print(parent_t_type)
|
|
if etree.QName(parent_t_type).localname == 'PartyTaxScheme' and etree.QName(parent_p_type).localname == account: # @UndefinedVariable
|
|
if etree.QName(parent_t_type).localname == 'PartyTaxScheme' and etree.QName(parent_p_type).localname == account: # @UndefinedVariable
|
|
# print(partie_id.text)
|
|
# print(partie_id.text)
|
|
- file_partn_id = partie_id.text
|
|
|
|
|
|
+ file_partn_id = partie_id.text # noqa
|
|
new_name = '{}_{}_{}_{}.xml'.format(file.replace('.xml', ''), inv_id, file_partie, is_date)
|
|
new_name = '{}_{}_{}_{}.xml'.format(file.replace('.xml', ''), inv_id, file_partie, is_date)
|
|
current_path = os.path.join(root_f, file)
|
|
current_path = os.path.join(root_f, file)
|
|
new_path = os.path.join(root_f, new_name)
|
|
new_path = os.path.join(root_f, new_name)
|