<commit_before>import xml
from xml.dom.minidom import Document
from collections import namedtuple
from xml.etree.ElementTree import Element, SubElement, Comment, tostring
from xml.etree import ElementTree
from xml.dom import minidom
import time
import calendar
import re
import os
import operator
from git import *
from generatePoaXml import *
from xml_generation import *
from parsePoaXml import *
import settings

"""

"""

class crossrefXML(object):

    def __init__(self, poa_articles, pub_date = None):
        """
        set the root node
        get the article type from the object passed in to the class
        set default values for items that are boilder plate for this XML 
        """
        self.root = Element('doi_batch')

        # set the boiler plate values
        self.contrib_types = ["author"]
        self.elife_journal_id = "eLife"
        self.elife_journal_title = "eLife"
        self.elife_journal_volume = "3"
        self.elife_email_address = '<EMAIL>'
        self.elife_epub_issn = "2050-084X"
        self.elife_publisher_name = "eLife Sciences Publications, Ltd"
        self.elife_crossmark_policy = "10.7554/eLife/crossmark_policy"
        self.elife_crossmark_domain = "www.elifesciences.org"

        self.root.set('version', "4.3.2")
        self.root.set('xmlns', 'http://www.crossref.org/schema/4.3.2')
        self.root.set('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance')
        self.root.set('xmlns:fr', 'http://www.crossref.org/fundref.xsd')
        self.root.set('xmlns:ai', 'http://www.crossref.org/AccessIndicators.xsd')
        self.root.set('xmlns:schemaLocation', 'http://www.crossref.org/schema/4.3.2 http://www.crossref.org/schemas/crossref4.3.2.xsd')
        self.root.set('xmlns:mml', 'http://www.w3.org/1998/Math/MathML')

        # Publication date
        if pub_date is None:
            self.pub_date = time.gmtime()
            
        # Generate batch id
        self.elife_doi_batch_id = "elife-" + time.strftime("%Y-%m-%d-%H%M%S", self.pub_date) + "-PoA"

        # set comment
        generated = time.strftime("%Y-%m-%d %H:%M:%S")
        last_commit = get_last_commit_to_master()
        comment = Comment('generated by eLife at ' + generated + ' from version ' + last_commit)
        self.root.append(comment)

        self.build(self.root, poa_articles)

    def build(self, root, poa_articles):
        self.set_head(self.root)
        self.set_body(self.root, poa_articles)

    def set_head(self, parent):
        self.head = SubElement(parent, 'head')
        self.doi_batch_id = SubElement(self.head, 'doi_batch_id')
        self.doi_batch_id.text = self.elife_doi_batch_id
        self.timestamp = SubElement(self.head, 'timestamp')
        self.timestamp.text = str(calendar.timegm(self.pub_date))
        self.set_depositor(self.head)
        self.registrant = SubElement(self.head, 'registrant')
        self.registrant.text = self.elife_journal_title

    def set_depositor(self, parent):<commit_msg>Change to 14 digit timestamp value in crossref XML.<commit_after>import xml
from xml.dom.minidom import Document
from collections import namedtuple
from xml.etree.ElementTree import Element, SubElement, Comment, tostring
from xml.etree import ElementTree
from xml.dom import minidom
import time
import calendar
import re
import os
import operator
from git import *
from generatePoaXml import *
from xml_generation import *
from parsePoaXml import *
import settings

"""

"""

class crossrefXML(object):

    def __init__(self, poa_articles, pub_date = None):
        """
        set the root node
        get the article type from the object passed in to the class
        set default values for items that are boilder plate for this XML 
        """
        self.root = Element('doi_batch')

        # set the boiler plate values
        self.contrib_types = ["author"]
        self.elife_journal_id = "eLife"
        self.elife_journal_title = "eLife"
        self.elife_journal_volume = "3"
        self.elife_email_address = '<EMAIL>'
        self.elife_epub_issn = "2050-084X"
        self.elife_publisher_name = "eLife Sciences Publications, Ltd"
        self.elife_crossmark_policy = "10.7554/eLife/crossmark_policy"
        self.elife_crossmark_domain = "www.elifesciences.org"

        self.root.set('version', "4.3.2")
        self.root.set('xmlns', 'http://www.crossref.org/schema/4.3.2')
        self.root.set('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance')
        self.root.set('xmlns:fr', 'http://www.crossref.org/fundref.xsd')
        self.root.set('xmlns:ai', 'http://www.crossref.org/AccessIndicators.xsd')
        self.root.set('xmlns:schemaLocation', 'http://www.crossref.org/schema/4.3.2 http://www.crossref.org/schemas/crossref4.3.2.xsd')
        self.root.set('xmlns:mml', 'http://www.w3.org/1998/Math/MathML')

        # Publication date
        if pub_date is None:
            self.pub_date = time.gmtime()
            
        # Generate batch id
        self.elife_doi_batch_id = "elife-" + time.strftime("%Y-%m-%d-%H%M%S", self.pub_date) + "-PoA"

        # set comment
        generated = time.strftime("%Y-%m-%d %H:%M:%S")
        last_commit = get_last_commit_to_master()
        comment = Comment('generated by eLife at ' + generated + ' from version ' + last_commit)
        self.root.append(comment)

        self.build(self.root, poa_articles)

    def build(self, root, poa_articles):
        self.set_head(self.root)
        self.set_body(self.root, poa_articles)

    def set_head(self, parent):
        self.head = SubElement(parent, 'head')
        self.doi_batch_id = SubElement(self.head, 'doi_batch_id')
        self.doi_batch_id.text = self.elife_doi_batch_id
        self.timestamp = SubElement(self.head, 'timestamp')
        self.timestamp.text = time.strftime("%Y%m%d%H%M%S", self.pub_date)
        self.set_depositor(self.head)
        self.registrant = SubElement(self.head, 'registrant')
        self.registrant.text = self.elife_journal_title

    def set_depositor(self, parent):
{'fraction_non_alphanumeric': 0.12253684384831925, 'fraction_numerical': 0.012253684384831926, 'mean_word_length': 2.929733246584255, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 16, 'xml': 24}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1741522', 'n_tokens_mistral': 2054, 'n_tokens_neox': 1945, 'n_words': 396}