Beautify / pretty print XML in `path`.

    Parameters
    ----------
    path : str

    Returns
    -------
    str
512973
def beautify_xml(path):
    
    with open(path) as f:
        content = f.read()

    pretty_print = lambda data: '\n'.join([line for line in
                                           parseString(data)
                                           .toprettyxml(indent=' ' * 2)
                                           .split('\n')
                                           if line.strip()])
    return pretty_print(content)
938112
def path_serialize(cls, path):
        
        # make it into a netstring
        path_parts = ['{}-{}'.format(p['order'], p['hash']) for p in path]
        path_ns_parts = ['{}:{},'.format(len(pp), pp) for pp in path_parts]
        path_str = ''.join(path_ns_parts)
        return '{}:{},'.format(len(path_str), path_str)
1229455
def fixPath(path):
  
  path = os.path.abspath(os.path.expanduser(path))
  if path.startswith("\\"):
    return "C:" + path

  return path
1158741
def render_relative_path(export_path, path)
      export_path = Pathname.new(export_path)
      path = Pathname.new(path).relative_path_from(export_path)
      return path.to_path
    end
1333465
def render_path(self, template_path, *context, **kwargs):
        
        loader = self._make_loader()
        template = loader.read(template_path)

        return self._render_string(template, *context, **kwargs)
981205
def relpath(self, path):
        
        return os.path.relpath(path, start=self.path)
236682
def translate_path(self, path):
        
        # abandon query parameters
        path = path.split('?',1)[0]
        path = path.split('#',1)[0]
        path = posixpath.normpath(urllib_parse.unquote(path))
        words = path.split('/')
        words = filter(None, words)
        path = os.getcwd()
        for word in words:
            drive, word = os.path.splitdrive(word)
            head, word = os.path.split(word)
            if word in (os.curdir, os.pardir): continue
            path = os.path.join(path, word)
        return path
485440
def _rel(self, path):
        
        return os.path.relpath(
            str(path), self._parent).replace(os.path.sep, '/')
281686
def _path_to_str(self, path):
        
        inp = ''
        for arc in path:
            i = self.isyms.find(arc.ilabel)
            # Ignore \epsilon transitions both on input
            if i != fst.EPSILON:
                inp += i
        return inp
96929
def make_path_relative(path: str) -> str:
    
    if "../" in path:
        raise ManifestBuildingError(
            f"Path: {path} appears to be outside of the virtual source tree. "
            "Please make sure all sources are within the virtual source tree root directory."
        )

    if path[:2] != "./":
        return f"./{path}"
    return path
458540
def itemByPath( self, path, includeRoot = False ):
        
        sep     = self.separator()
        path    = nativestring(path).strip(sep)
        if ( not path ):
            if ( includeRoot ):
                return self.invisibleRootItem()
            else:
                return None
            
        splt    = path.split(sep)
        item    = self.invisibleRootItem()
        for part in splt:
            next_item = None
            for row in range(item.rowCount()):
                child = item.child(row)
                if ( child.text() == part ):
                    next_item = child
                    break
            
            if ( not next_item ):
                item = None
                break
                
            item = next_item
            item.initialize()
        
        return item
1202244
def pretty_print(source, dest):
    
    parser = etree.XMLParser(remove_blank_text=True)
    if not isinstance(source, str):
        source = str(source)
    tree = etree.parse(source, parser)
    docinfo = tree.docinfo
    with open(dest, 'wb') as fp:
        fp.write(etree.tostring(tree, pretty_print=True,
                                encoding=docinfo.encoding, standalone=docinfo.standalone))
52699
def render_string(self, path: str, **kwargs: Any) -> bytes:
        """"""
        return self.handler.render_string(path, **kwargs)
1226382
def fromfile(cls, path):
        
        parser = etree.XMLParser(remove_blank_text=True)

        return cls.fromtree(etree.parse(path, parser=parser))
882781
def import_attribute(path):
    
    module_name, attribute_name = path.rsplit('.', 1)
    module = import_module(module_name)
    attribute = getattr(module, attribute_name)
    return attribute
349778
def simplify_path(path: str, path_prefixes: list = None) -> str:
    

    test_path = '{}'.format(path if path else '')
    replacements = (path_prefixes if path_prefixes else []).copy()
    replacements.append(('~', os.path.expanduser('~')))

    for key, value in replacements:
        if test_path.startswith(value):
            return '{}{}'.format(key, test_path[len(value):])

    return test_path
394793
def serialize(self, path):
        
        pickle.dump([self.x, self.y_raw], file(path, 'w'))