Пример #1
0
def dump_path(path, prefix="", tab="    ", file=None):
    if file is None:
        file = sys.stdout
    p = Path(path)
    if   p.islink():
        print >>file, "%s%s -> %s" % (prefix, p.name, p.read_link())
    elif p.isdir():
        print >>file, "%s%s:" % (prefix, p.name)
        for p2 in p.listdir():
            dump_path(p2, prefix+tab, tab, file)
    else:
        print >>file, "%s%s  (%d)" % (prefix, p.name, p.size())
Пример #2
0

# Expands system variable and ~. Will also normalise the path ( remove redundant
# .. . incorrect slashes and correct capitalisation on case sensitive file systems. Calls os.path.normpath

# File Attributes and permissions
print("\n*** File Attributes and permissions")
# noinspection PyArgumentList
print(here.atime())  # Last access time; seconds past epcoh
# noinspection PyArgumentList
print(here.ctime())  # Last permission or ownership modification; windows is creation time;
# noinspection PyArgumentList
print(here.isfile())  # Is a file; symbolic links are followed.
print(here.isdir())  # Is a directory; symbolic links are followed.
# noinspection PyArgumentList
print(here.islink())  # Is a symbolic link
# noinspection PyArgumentList
print(here.ismount())  # Is a mount point; ie the parent is on a different device.
# noinspection PyArgumentList
print(here.exists())  # File exists; symbolic links are followed.
# noinspection PyArgumentList
print(here.lexists())  # Same as exists but symbolic links are not followed.
# noinspection PyArgumentList
print(here.size())  # File size in bytes.
print(Path("/foo").isabsolute())  # Is absolute and not relative path

# Epoch?
print("\n*** gmtime")
print(gmtime(0))

Пример #3
0
# Expands system variable and ~. Will also normalise the path ( remove redundant
# .. . incorrect slashes and correct capitalisation on case sensitive file systems. Calls os.path.normpath

# File Attributes and permissions
print("\n*** File Attributes and permissions")
# noinspection PyArgumentList
print(here.atime())  # Last access time; seconds past epcoh
# noinspection PyArgumentList
print(here.ctime()
      )  # Last permission or ownership modification; windows is creation time;
# noinspection PyArgumentList
print(here.isfile())  # Is a file; symbolic links are followed.
print(here.isdir())  # Is a directory; symbolic links are followed.
# noinspection PyArgumentList
print(here.islink())  # Is a symbolic link
# noinspection PyArgumentList
print(here.ismount()
      )  # Is a mount point; ie the parent is on a different device.
# noinspection PyArgumentList
print(here.exists())  # File exists; symbolic links are followed.
# noinspection PyArgumentList
print(here.lexists())  # Same as exists but symbolic links are not followed.
# noinspection PyArgumentList
print(here.size())  # File size in bytes.
print(Path("/foo").isabsolute())  # Is absolute and not relative path

# Epoch?
print("\n*** gmtime")
print(gmtime(0))