summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorAdam Hupp <adam@hupp.org>2015-02-26 21:46:38 -0800
committerAdam Hupp <adam@hupp.org>2015-02-26 21:46:38 -0800
commit016ab238228a322371b400280fd5818827adcfc9 (patch)
treeea1e7f41cec1dca4926f9f4d3a0a5c1d5f282207 /README.md
parent221a407f5c68d74f8567383b8d000be2147a1eec (diff)
parente9376e2d81883a64067e7471be5bec15946e2fd4 (diff)
downloadpython-magic-016ab238228a322371b400280fd5818827adcfc9.tar.gz
Merge pull request #74 from iiSeymour/patch-1
Updated README.md
Diffstat (limited to 'README.md')
-rw-r--r--README.md34
1 files changed, 20 insertions, 14 deletions
diff --git a/README.md b/README.md
index d9e254a..cdb0460 100644
--- a/README.md
+++ b/README.md
@@ -8,13 +8,15 @@ functionality is exposed to the command line by the Unix command
## Usage
- >>> import magic
- >>> magic.from_file("testdata/test.pdf")
- 'PDF document, version 1.2'
- >>> magic.from_buffer(open("testdata/test.pdf").read(1024))
- 'PDF document, version 1.2'
- >>> magic.from_file("testdata/test.pdf", mime=True)
- 'application/pdf'
+```python
+>>> import magic
+>>> magic.from_file("testdata/test.pdf")
+'PDF document, version 1.2'
+>>> magic.from_buffer(open("testdata/test.pdf").read(1024))
+'PDF document, version 1.2'
+>>> magic.from_file("testdata/test.pdf", mime=True)
+'application/pdf'
+```
There is also a `Magic` class that provides more direct control,
including overriding the magic database file and turning on character
@@ -22,16 +24,20 @@ encoding detection. This is not recommended for general use. In
particular, it's not safe for sharing across multiple threads and
will fail throw if this is attempted.
- >>> f = magic.Magic(uncompress=True)
- >>> f.from_file('testdata/test.gz')
- 'ASCII text (gzip compressed data, was "test", last modified: Sat Jun 28
- 21:32:52 2008, from Unix)'
+```python
+>>> f = magic.Magic(uncompress=True)
+>>> f.from_file('testdata/test.gz')
+'ASCII text (gzip compressed data, was "test", last modified: Sat Jun 28
+21:32:52 2008, from Unix)'
+```
You can also combine the flag options:
- >>> f = magic.Magic(mime=True, uncompress=True)
- >>> f.from_file('testdata/test.gz')
- 'text/plain'
+```python
+>>> f = magic.Magic(mime=True, uncompress=True)
+>>> f.from_file('testdata/test.gz')
+'text/plain'
+```
## Name Conflict