socialfeeder/utilities/configuration.py
def parse(path:str, save:bool=False):
    '''
    Parse xml document to dict object
    '''
    # Load xml
    print(f'INFO: XML file at: {path}')
    lxml_content = open(file=path,mode="r",encoding="utf8").read()
    soup = bs4.BeautifulSoup(lxml_content, "lxml")
    
    # Load xml schema - xsd to validate
    xsd_path = f'{os.path.dirname(os.path.realpath(__file__))}/configuration.xsd'
    # valid, message = _validate(xml_path=path, xsd_path=xsd_path)
    # if not valid:
    #     print(f'ERROR: Failed at validation with message: {message}')
    #     return None
    
    results = []
    pages = soup.findAll("page")
    for page in pages:
        # result - base
        result = {
            "config_at": os.path.abspath(path),
            "actions": _parse_actions(page.find("actions"))
        }

        results.append(ObjectView(result))
        
    if save:
        save_to_json_file(results[0].origin, path.replace('.xml', '.json'))
    return results

    Parse xml document to dict object
    
Parse xml document to dict object
Parse xml document to dict object
def parse(path:str, save:bool=False):
    print(f'INFO: XML file at: {path}')
    lxml_content = open(file=path,mode="r",encoding="utf8").read()
    soup = bs4.BeautifulSoup(lxml_content, "lxml")
     schema - xsd to validate
    xsd_path = f'{os.path.dirname(os.path.realpath(__file__))}/configuration.xsd'
    results = []
    pages = soup.findAll("page")
    for page in pages:
        result = {
            "config_at": os.path.abspath(path),
            "actions": _parse_actions(page.find("actions"))
        }
        results.append(ObjectView(result))
    if save:
        save_to_json_file(results[0].origin, path.replace('.xml', '.json'))
    return results
def parse ( path : str , save : bool = False ) : print ( f'INFO: XML file at: {path}' ) lxml_content = open ( file = path , mode = "r" , encoding = "utf8" ) . read ( ) soup = bs4 . BeautifulSoup ( lxml_content , "lxml" ) xsd_path = f'{os.path.dirname(os.path.realpath(__file__))}/configuration.xsd' results = [ ] pages = soup . findAll ( "page" ) for page in pages : result = { "config_at" : os . path . abspath ( path ) , "actions" : _parse_actions ( page . find ( "actions" ) ) } results . append ( ObjectView ( result ) ) if save : save_to_json_file ( results [ 0 ] . origin , path . replace ( '.xml' , '.json' ) ) return results
Parse xml document to dict object
Parse xml document to dict object
'''
    Parse xml document to dict object
    ''' # Load xml # Load xml schema - xsd to validate # valid, message = _validate(xml_path=path, xsd_path=xsd_path) # if not valid: #     print(f'ERROR: Failed at validation with message: {message}') #     return None # result - base
path
str
save
bool