Skip to content

Commit

Permalink
Adiciona o parâmetro pretty_print em finger_print e get_zip_content (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
robertatakenaka authored Jan 25, 2024
1 parent 14a18eb commit c01bbc0
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packtools/sps/pid_provider/xml_sps_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,11 @@ class XMLWithPre:
Preserva o texto anterior ao elemento `root`
"""

def __init__(self, xmlpre, xmltree):
def __init__(self, xmlpre, xmltree, pretty_print=True):
self.xmlpre = xmlpre or ""
self.xmltree = xmltree
self.filename = None
self.pretty_print = pretty_print

@classmethod
def create(cls, path=None, uri=None):
Expand All @@ -266,12 +267,12 @@ def create(cls, path=None, uri=None):
if uri:
yield get_xml_with_pre_from_uri(uri, timeout=30)

def get_zip_content(self, xml_filename):
def get_zip_content(self, xml_filename, pretty_print=False):
zip_content = None
with TemporaryDirectory() as tmpdirname:
temp_zip_file_path = os.path.join(tmpdirname, f"{xml_filename}.zip")
with ZipFile(temp_zip_file_path, "w") as zf:
zf.writestr(xml_filename, self.tostring())
zf.writestr(xml_filename, self.tostring(pretty_print=pretty_print))

with open(temp_zip_file_path, "rb") as fp:
zip_content = fp.read()
Expand Down Expand Up @@ -736,7 +737,7 @@ def article_titles_texts(self):

@property
def finger_print(self):
return generate_finger_print(self.tostring())
return generate_finger_print(self.tostring(pretty_print=self.pretty_print))


def generate_finger_print(content):
Expand Down

0 comments on commit c01bbc0

Please sign in to comment.