Example #1
0
File: lxml.py Project: whigg/pyrads
def fromstring(text: _ParserInputType, parser: Optional[XMLParser] = None) \
        -> etree._Element:
    """Parse XML document from string constant.

    This function can be used to embed 'XML Literals' in Python code.

    This is wrapper around :func:`lxml.etree.fromstring` to make it behave like
    :func:`xml.etree.ElementTree.fromtstring`.

    Parameters
    ----------
    text
        A string containing XML data.
    parser
        Optional parser instance, defaulting to
        :class:`lxml.etree.ETCompatXMLParser`.

    Returns
    -------
    _Element
        An Element instance.

    """
    if parser is None:
        parser = ETCompatXMLParser()
    return etree.fromstring(text, parser)
Example #2
0
def fromstringlist(sequence: Sequence[_ParserInputType],
                   parser: Optional[XMLParser] = None) -> etree._Element:
    """Parse XML document from sequence of string fragments.

    :param sequence:
        A list or other sequence of strings containing XML data.
    :param parser:
        Optional parser instance, defaulting to
        :class:`lxml.etree.ETCompatXMLParser`.

    :return:
        An Element instance.
    """
    if parser is None:
        parser = ETCompatXMLParser()
    return etree.fromstringlist(sequence, parser)
Example #3
0
def parse(source: _FileOrFilename,
          parser: Optional[XMLParser] = None) -> etree._ElementTree:
    """Parse XML document into element tree.

    This is wrapper around :func:`lxml.etree.parse` to make it behave like
    :func:`xml.etree.ElementTree.parse`.

    :param source:
        Filename or file object containing XML data.
    :param parser:
        Optional parser instance, defaulting to
        :class:`lxml.etree.ETCompatXMLParser`.

    :return:
        An ElementTree instance.
    """
    if parser is None:
        parser = ETCompatXMLParser()
    return etree.parse(source, parser)
Example #4
0
import sqlite3
try:
    from lxml.etree import ETCompatXMLParser
    custom_parser = ETCompatXMLParser(huge_tree=True, recover=True)
except ImportError:
    custom_parser = None

try:
    import xml.etree.cElementTree as XML
except ImportError:
    import xml.etree.ElementTree as XML
import logging as log
from datetime import datetime
import argparse
import glob, fnmatch, os, re

#    TODO SMSCOUNT backup_set backup_date
#

GLOB_ID_MMS = 0


def main(input_paths, output_path):
    try:
        time_start = datetime.now()
        log.basicConfig(level=log.DEBUG, format='%(asctime)s %(message)s')
        log.debug('Starting Operation...')
        conn = sqlite3.connect('sms.db')
        conn.execute('DELETE FROM smss')
        conn.execute("DELETE FROM mmss")
        conn.execute("DELETE FROM parts")