New file(1) port
This commit is contained in:
committed by
Thomas Veerman
parent
991c41db8f
commit
835f680238
17
external/bsd/file/dist/python/example.py
vendored
17
external/bsd/file/dist/python/example.py
vendored
@@ -1,16 +1,17 @@
|
||||
#! /usr/bin/python
|
||||
|
||||
import magic
|
||||
|
||||
ms = magic.open(magic.MAGIC_NONE)
|
||||
ms = magic.open(magic.NONE)
|
||||
ms.load()
|
||||
type = ms.file("/path/to/some/file")
|
||||
print type
|
||||
tp = ms.file("/bin/ls")
|
||||
print (tp)
|
||||
|
||||
f = file("/path/to/some/file", "r")
|
||||
buffer = f.read(4096)
|
||||
f = open("/bin/ls", "rb")
|
||||
buf = f.read(4096)
|
||||
f.close()
|
||||
|
||||
type = ms.buffer(buffer)
|
||||
print type
|
||||
tp = ms.buffer(buf)
|
||||
print (tp)
|
||||
|
||||
ms.close()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user