The VFS represents tags as directories; the directories are numbered to
distinguish tags with the same name; numbering also helps to sort tags by their
The VFS represents tags as directories; the directories are numbered to
distinguish tags with the same name; numbering also helps to sort tags by their
-order in XML instead of sorting them by name. Attributes, text nodes and
-comments are represented as text files; attributes are shown in a file named
-"attributes", attributes are listed in the file as name=value lines (I
-deliberately ignore a small chance of newline characters in values); names and
-values are reencoded to the console encoding. Text nodes and comments are
-collected in a file named "text", stripped and reencoded. The filesystem is
+order in XML instead of sorting them by name and prevents name clash when tag
+names coincide with the names of special files used by XML VFS. Attributes,
+text nodes and comments are represented as text files; attributes are shown in
+a file named "attributes", attributes are listed in the file as name=value
+lines (I deliberately ignore a small chance of newline characters in values);
+names and values are reencoded to the console encoding. Text nodes and comments
+are collected in a file named "text", stripped and reencoded. The filesystem is
__author__ = "Oleg Broytman <phd@phdru.name>"
__copyright__ = "Copyright (C) 2013-2015 PhiloSoft Design"
__license__ = "GPL"
__author__ = "Oleg Broytman <phd@phdru.name>"
__copyright__ = "Copyright (C) 2013-2015 PhiloSoft Design"
__license__ = "GPL"
-force_implementation = None # Can be None for default choice,
- # 'lxml', 'elementtree' or 'minidom'
+# Can be None for default choice, 'lxml', 'elementtree' or 'minidom'.
+force_implementation = None
- # Get the default charset.
- try:
- lcAll = locale.getdefaultlocale()
- except locale.Error, err:
- print >>sys.stderr, "WARNING:", err
- lcAll = []
-
- if len(lcAll) == 2:
- default_encoding = lcAll[1]
- else:
- try:
- default_encoding = locale.getpreferredencoding()
- except locale.Error, err:
- print >>sys.stderr, "WARNING:", err
- default_encoding = sys.getdefaultencoding()
+ # Get the default charset.
+ try:
+ lcAll = locale.getdefaultlocale()
+ except locale.Error, err:
+ print >>sys.stderr, "WARNING:", err
+ lcAll = []
+
+ if len(lcAll) == 2:
+ default_encoding = lcAll[1]
+ else:
+ try:
+ default_encoding = locale.getpreferredencoding()
+ except locale.Error, err:
+ print >>sys.stderr, "WARNING:", err
+ default_encoding = sys.getdefaultencoding()
This is not a program. Put the script in $HOME/[.local/share/].mc/extfs.d or
/usr/[local/][lib|share]/mc/extfs. For more information read the source!""",
This is not a program. Put the script in $HOME/[.local/share/].mc/extfs.d or
/usr/[local/][lib|share]/mc/extfs. For more information read the source!""",
+ Y, m, d, H, M = localtime(getmtime(self.xml_file))[0:5]
+ self.xml_file_dt = "%02d-%02d-%d %02d:%02d" % (m, d, Y, H, M)
+
self._list(self.getroot())
def _list(self, node, path=''):
self._list(self.getroot())
def _list(self, node, path=''):
else:
subpath = '%s %s' % (template % n, tag)
subpath_encoded = subpath.encode(default_encoding, "replace")
else:
subpath = '%s %s' % (template % n, tag)
subpath_encoded = subpath.encode(default_encoding, "replace")
- print "-r--r--r-- 1 user group %d Jan 1 00:00 %s/attributes" % (
- len(attr_text), subpath_encoded)
+ print "-r--r--r-- 1 user group %d %s %s/attributes" % (
+ len(attr_text), self.xml_file_dt, subpath_encoded)
- print "-r--r--r-- 1 user group %d Jan 1 00:00 %s/namespaces" % (
- len(ns_text), subpath_encoded)
+ print "-r--r--r-- 1 user group %d %s %s/namespaces" % (
+ len(ns_text), self.xml_file_dt, subpath_encoded)
- print "-r--r--r-- 1 user group %d Jan 1 00:00 %s/text" % (
- len(text), subpath_encoded)
+ print "-r--r--r-- 1 user group %d %s %s/text" % (
+ len(text), self.xml_file_dt, subpath_encoded)
self._list(element, subpath)
def get_tag_node(self, node, i):
self._list(element, subpath)
def get_tag_node(self, node, i):
for element in node:
if not self.istag(element):
text = u"<!--%s-->" % element.text
text_accumulator.append(text)
if node.tail:
text = node.tail.strip()
for element in node:
if not self.istag(element):
text = u"<!--%s-->" % element.text
text_accumulator.append(text)
if node.tail:
text = node.tail.strip()
- if text: text_accumulator.append(text)
- return '\n'.join(text_accumulator).encode(default_encoding, "replace")
+ if text:
+ text_accumulator.append(text)
+ return '\n'.join(text_accumulator).encode(
+ default_encoding, "replace")
if not self.istag(element):
text = u"<!--%s-->" % element.text
text_accumulator.append(text)
if not self.istag(element):
text = u"<!--%s-->" % element.text
text_accumulator.append(text)
def getlocalname(self, name):
return etree.QName(name).localname
def getlocalname(self, name):
return etree.QName(name).localname
- raise ValueError('Unknown implementation "%s", expected "minidom", "elementtree" or "lxml"' % force_implementation)
+ raise ValueError('Unknown implementation "%s", expected "minidom", '
+ '"elementtree" or "lxml"' % force_implementation)