shotgun-api3 3.8.4__py2.py3-none-any.whl → 3.9.0__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- shotgun_api3/lib/certifi/__init__.py +1 -1
- shotgun_api3/lib/certifi/cacert.pem +185 -263
- shotgun_api3/lib/certifi/core.py +1 -32
- shotgun_api3/lib/httplib2/__init__.py +1799 -39
- shotgun_api3/lib/httplib2/auth.py +1 -1
- shotgun_api3/lib/mockgun/mockgun.py +0 -1
- shotgun_api3/lib/mockgun/schema.py +1 -1
- shotgun_api3/shotgun.py +98 -275
- {shotgun_api3-3.8.4.dist-info → shotgun_api3-3.9.0.dist-info}/METADATA +6 -47
- shotgun_api3-3.9.0.dist-info/RECORD +26 -0
- shotgun_api3/lib/httplib2/python2/__init__.py +0 -1993
- shotgun_api3/lib/httplib2/python2/auth.py +0 -63
- shotgun_api3/lib/httplib2/python2/cacerts.txt +0 -2225
- shotgun_api3/lib/httplib2/python2/certs.py +0 -42
- shotgun_api3/lib/httplib2/python2/error.py +0 -48
- shotgun_api3/lib/httplib2/python2/iri2uri.py +0 -123
- shotgun_api3/lib/httplib2/python2/socks.py +0 -518
- shotgun_api3/lib/httplib2/python3/__init__.py +0 -1799
- shotgun_api3/lib/httplib2/python3/auth.py +0 -69
- shotgun_api3/lib/httplib2/python3/cacerts.txt +0 -2225
- shotgun_api3/lib/httplib2/python3/certs.py +0 -42
- shotgun_api3/lib/httplib2/python3/error.py +0 -48
- shotgun_api3/lib/httplib2/python3/iri2uri.py +0 -124
- shotgun_api3/lib/httplib2/python3/socks.py +0 -518
- shotgun_api3/lib/mimetypes.py +0 -598
- shotgun_api3/lib/sgsix.py +0 -87
- shotgun_api3/lib/sgutils.py +0 -62
- shotgun_api3/lib/six.py +0 -964
- shotgun_api3-3.8.4.dist-info/RECORD +0 -44
- {shotgun_api3-3.8.4.dist-info → shotgun_api3-3.9.0.dist-info}/WHEEL +0 -0
- {shotgun_api3-3.8.4.dist-info → shotgun_api3-3.9.0.dist-info}/licenses/LICENSE +0 -0
- {shotgun_api3-3.8.4.dist-info → shotgun_api3-3.9.0.dist-info}/top_level.txt +0 -0
shotgun_api3/lib/mimetypes.py
DELETED
|
@@ -1,598 +0,0 @@
|
|
|
1
|
-
"""Guess the MIME type of a file.
|
|
2
|
-
|
|
3
|
-
This module defines two useful functions:
|
|
4
|
-
|
|
5
|
-
guess_type(url, strict=1) -- guess the MIME type and encoding of a URL.
|
|
6
|
-
|
|
7
|
-
guess_extension(type, strict=1) -- guess the extension for a given MIME type.
|
|
8
|
-
|
|
9
|
-
It also contains the following, for tuning the behavior:
|
|
10
|
-
|
|
11
|
-
Data:
|
|
12
|
-
|
|
13
|
-
knownfiles -- list of files to parse
|
|
14
|
-
inited -- flag set when init() has been called
|
|
15
|
-
suffix_map -- dictionary mapping suffixes to suffixes
|
|
16
|
-
encodings_map -- dictionary mapping suffixes to encodings
|
|
17
|
-
types_map -- dictionary mapping suffixes to types
|
|
18
|
-
|
|
19
|
-
Functions:
|
|
20
|
-
|
|
21
|
-
init([files]) -- parse a list of files, default knownfiles (on Windows, the
|
|
22
|
-
default values are taken from the registry)
|
|
23
|
-
read_mime_types(file) -- parse one file, return a dictionary or None
|
|
24
|
-
|
|
25
|
-
Note that this code has not been updated for python 3 compatibility, as it is
|
|
26
|
-
a patched version of the native mimetypes module and is used only in Python
|
|
27
|
-
versions 2.7.0 - 2.7.9, which included a broken version of the mimetypes module.
|
|
28
|
-
"""
|
|
29
|
-
|
|
30
|
-
import os
|
|
31
|
-
import sys
|
|
32
|
-
import posixpath
|
|
33
|
-
import urllib
|
|
34
|
-
try:
|
|
35
|
-
import _winreg
|
|
36
|
-
except ImportError:
|
|
37
|
-
_winreg = None
|
|
38
|
-
|
|
39
|
-
__all__ = [
|
|
40
|
-
"guess_type","guess_extension","guess_all_extensions",
|
|
41
|
-
"add_type","read_mime_types","init"
|
|
42
|
-
]
|
|
43
|
-
|
|
44
|
-
knownfiles = [
|
|
45
|
-
"/etc/mime.types",
|
|
46
|
-
"/etc/httpd/mime.types", # Mac OS X
|
|
47
|
-
"/etc/httpd/conf/mime.types", # Apache
|
|
48
|
-
"/etc/apache/mime.types", # Apache 1
|
|
49
|
-
"/etc/apache2/mime.types", # Apache 2
|
|
50
|
-
"/usr/local/etc/httpd/conf/mime.types",
|
|
51
|
-
"/usr/local/lib/netscape/mime.types",
|
|
52
|
-
"/usr/local/etc/httpd/conf/mime.types", # Apache 1.2
|
|
53
|
-
"/usr/local/etc/mime.types", # Apache 1.3
|
|
54
|
-
]
|
|
55
|
-
|
|
56
|
-
inited = False
|
|
57
|
-
_db = None
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
class MimeTypes:
|
|
61
|
-
"""MIME-types datastore.
|
|
62
|
-
|
|
63
|
-
This datastore can handle information from mime.types-style files
|
|
64
|
-
and supports basic determination of MIME type from a filename or
|
|
65
|
-
URL, and can guess a reasonable extension given a MIME type.
|
|
66
|
-
"""
|
|
67
|
-
|
|
68
|
-
def __init__(self, filenames=(), strict=True):
|
|
69
|
-
if not inited:
|
|
70
|
-
init()
|
|
71
|
-
self.encodings_map = encodings_map.copy()
|
|
72
|
-
self.suffix_map = suffix_map.copy()
|
|
73
|
-
self.types_map = ({}, {}) # dict for (non-strict, strict)
|
|
74
|
-
self.types_map_inv = ({}, {})
|
|
75
|
-
for (ext, type) in types_map.items():
|
|
76
|
-
self.add_type(type, ext, True)
|
|
77
|
-
for (ext, type) in common_types.items():
|
|
78
|
-
self.add_type(type, ext, False)
|
|
79
|
-
for name in filenames:
|
|
80
|
-
self.read(name, strict)
|
|
81
|
-
|
|
82
|
-
def add_type(self, type, ext, strict=True):
|
|
83
|
-
"""Add a mapping between a type and an extension.
|
|
84
|
-
|
|
85
|
-
When the extension is already known, the new
|
|
86
|
-
type will replace the old one. When the type
|
|
87
|
-
is already known the extension will be added
|
|
88
|
-
to the list of known extensions.
|
|
89
|
-
|
|
90
|
-
If strict is true, information will be added to
|
|
91
|
-
list of standard types, else to the list of non-standard
|
|
92
|
-
types.
|
|
93
|
-
"""
|
|
94
|
-
self.types_map[strict][ext] = type
|
|
95
|
-
exts = self.types_map_inv[strict].setdefault(type, [])
|
|
96
|
-
if ext not in exts:
|
|
97
|
-
exts.append(ext)
|
|
98
|
-
|
|
99
|
-
def guess_type(self, url, strict=True):
|
|
100
|
-
"""Guess the type of a file based on its URL.
|
|
101
|
-
|
|
102
|
-
Return value is a tuple (type, encoding) where type is None if
|
|
103
|
-
the type can't be guessed (no or unknown suffix) or a string
|
|
104
|
-
of the form type/subtype, usable for a MIME Content-type
|
|
105
|
-
header; and encoding is None for no encoding or the name of
|
|
106
|
-
the program used to encode (e.g. compress or gzip). The
|
|
107
|
-
mappings are table driven. Encoding suffixes are case
|
|
108
|
-
sensitive; type suffixes are first tried case sensitive, then
|
|
109
|
-
case insensitive.
|
|
110
|
-
|
|
111
|
-
The suffixes .tgz, .taz and .tz (case sensitive!) are all
|
|
112
|
-
mapped to '.tar.gz'. (This is table-driven too, using the
|
|
113
|
-
dictionary suffix_map.)
|
|
114
|
-
|
|
115
|
-
Optional `strict' argument when False adds a bunch of commonly found,
|
|
116
|
-
but non-standard types.
|
|
117
|
-
"""
|
|
118
|
-
scheme, url = urllib.splittype(url)
|
|
119
|
-
if scheme == 'data':
|
|
120
|
-
# syntax of data URLs:
|
|
121
|
-
# dataurl := "data:" [ mediatype ] [ ";base64" ] "," data
|
|
122
|
-
# mediatype := [ type "/" subtype ] *( ";" parameter )
|
|
123
|
-
# data := *urlchar
|
|
124
|
-
# parameter := attribute "=" value
|
|
125
|
-
# type/subtype defaults to "text/plain"
|
|
126
|
-
comma = url.find(',')
|
|
127
|
-
if comma < 0:
|
|
128
|
-
# bad data URL
|
|
129
|
-
return None, None
|
|
130
|
-
semi = url.find(';', 0, comma)
|
|
131
|
-
if semi >= 0:
|
|
132
|
-
type = url[:semi]
|
|
133
|
-
else:
|
|
134
|
-
type = url[:comma]
|
|
135
|
-
if '=' in type or '/' not in type:
|
|
136
|
-
type = 'text/plain'
|
|
137
|
-
return type, None # never compressed, so encoding is None
|
|
138
|
-
base, ext = posixpath.splitext(url)
|
|
139
|
-
while ext in self.suffix_map:
|
|
140
|
-
base, ext = posixpath.splitext(base + self.suffix_map[ext])
|
|
141
|
-
if ext in self.encodings_map:
|
|
142
|
-
encoding = self.encodings_map[ext]
|
|
143
|
-
base, ext = posixpath.splitext(base)
|
|
144
|
-
else:
|
|
145
|
-
encoding = None
|
|
146
|
-
types_map = self.types_map[True]
|
|
147
|
-
if ext in types_map:
|
|
148
|
-
return types_map[ext], encoding
|
|
149
|
-
elif ext.lower() in types_map:
|
|
150
|
-
return types_map[ext.lower()], encoding
|
|
151
|
-
elif strict:
|
|
152
|
-
return None, encoding
|
|
153
|
-
types_map = self.types_map[False]
|
|
154
|
-
if ext in types_map:
|
|
155
|
-
return types_map[ext], encoding
|
|
156
|
-
elif ext.lower() in types_map:
|
|
157
|
-
return types_map[ext.lower()], encoding
|
|
158
|
-
else:
|
|
159
|
-
return None, encoding
|
|
160
|
-
|
|
161
|
-
def guess_all_extensions(self, type, strict=True):
|
|
162
|
-
"""Guess the extensions for a file based on its MIME type.
|
|
163
|
-
|
|
164
|
-
Return value is a list of strings giving the possible filename
|
|
165
|
-
extensions, including the leading dot ('.'). The extension is not
|
|
166
|
-
guaranteed to have been associated with any particular data stream,
|
|
167
|
-
but would be mapped to the MIME type `type' by guess_type().
|
|
168
|
-
|
|
169
|
-
Optional `strict' argument when false adds a bunch of commonly found,
|
|
170
|
-
but non-standard types.
|
|
171
|
-
"""
|
|
172
|
-
type = type.lower()
|
|
173
|
-
extensions = self.types_map_inv[True].get(type, [])
|
|
174
|
-
if not strict:
|
|
175
|
-
for ext in self.types_map_inv[False].get(type, []):
|
|
176
|
-
if ext not in extensions:
|
|
177
|
-
extensions.append(ext)
|
|
178
|
-
return extensions
|
|
179
|
-
|
|
180
|
-
def guess_extension(self, type, strict=True):
|
|
181
|
-
"""Guess the extension for a file based on its MIME type.
|
|
182
|
-
|
|
183
|
-
Return value is a string giving a filename extension,
|
|
184
|
-
including the leading dot ('.'). The extension is not
|
|
185
|
-
guaranteed to have been associated with any particular data
|
|
186
|
-
stream, but would be mapped to the MIME type `type' by
|
|
187
|
-
guess_type(). If no extension can be guessed for `type', None
|
|
188
|
-
is returned.
|
|
189
|
-
|
|
190
|
-
Optional `strict' argument when false adds a bunch of commonly found,
|
|
191
|
-
but non-standard types.
|
|
192
|
-
"""
|
|
193
|
-
extensions = self.guess_all_extensions(type, strict)
|
|
194
|
-
if not extensions:
|
|
195
|
-
return None
|
|
196
|
-
return extensions[0]
|
|
197
|
-
|
|
198
|
-
def read(self, filename, strict=True):
|
|
199
|
-
"""
|
|
200
|
-
Read a single mime.types-format file, specified by pathname.
|
|
201
|
-
|
|
202
|
-
If strict is true, information will be added to
|
|
203
|
-
list of standard types, else to the list of non-standard
|
|
204
|
-
types.
|
|
205
|
-
"""
|
|
206
|
-
with open(filename) as fp:
|
|
207
|
-
self.readfp(fp, strict)
|
|
208
|
-
|
|
209
|
-
def readfp(self, fp, strict=True):
|
|
210
|
-
"""
|
|
211
|
-
Read a single mime.types-format file.
|
|
212
|
-
|
|
213
|
-
If strict is true, information will be added to
|
|
214
|
-
list of standard types, else to the list of non-standard
|
|
215
|
-
types.
|
|
216
|
-
"""
|
|
217
|
-
while 1:
|
|
218
|
-
line = fp.readline()
|
|
219
|
-
if not line:
|
|
220
|
-
break
|
|
221
|
-
words = line.split()
|
|
222
|
-
for i in range(len(words)):
|
|
223
|
-
if words[i][0] == '#':
|
|
224
|
-
del words[i:]
|
|
225
|
-
break
|
|
226
|
-
if not words:
|
|
227
|
-
continue
|
|
228
|
-
type, suffixes = words[0], words[1:]
|
|
229
|
-
for suff in suffixes:
|
|
230
|
-
self.add_type(type, '.' + suff, strict)
|
|
231
|
-
|
|
232
|
-
def read_windows_registry(self, strict=True):
|
|
233
|
-
"""
|
|
234
|
-
Load the MIME types database from Windows registry.
|
|
235
|
-
|
|
236
|
-
If strict is true, information will be added to
|
|
237
|
-
list of standard types, else to the list of non-standard
|
|
238
|
-
types.
|
|
239
|
-
"""
|
|
240
|
-
|
|
241
|
-
# Windows only
|
|
242
|
-
if not _winreg:
|
|
243
|
-
return
|
|
244
|
-
|
|
245
|
-
def enum_types(mimedb):
|
|
246
|
-
i = 0
|
|
247
|
-
while True:
|
|
248
|
-
try:
|
|
249
|
-
ctype = _winreg.EnumKey(mimedb, i)
|
|
250
|
-
except EnvironmentError:
|
|
251
|
-
break
|
|
252
|
-
else:
|
|
253
|
-
if '\0' not in ctype:
|
|
254
|
-
yield ctype
|
|
255
|
-
i += 1
|
|
256
|
-
|
|
257
|
-
default_encoding = sys.getdefaultencoding()
|
|
258
|
-
with _winreg.OpenKey(_winreg.HKEY_CLASSES_ROOT, '') as hkcr:
|
|
259
|
-
for subkeyname in enum_types(hkcr):
|
|
260
|
-
try:
|
|
261
|
-
with _winreg.OpenKey(hkcr, subkeyname) as subkey:
|
|
262
|
-
# Only check file extensions
|
|
263
|
-
if not subkeyname.startswith("."):
|
|
264
|
-
continue
|
|
265
|
-
# raises EnvironmentError if no 'Content Type' value
|
|
266
|
-
mimetype, datatype = _winreg.QueryValueEx(
|
|
267
|
-
subkey, 'Content Type')
|
|
268
|
-
if datatype != _winreg.REG_SZ:
|
|
269
|
-
continue
|
|
270
|
-
try:
|
|
271
|
-
mimetype = mimetype.encode(default_encoding)
|
|
272
|
-
except UnicodeEncodeError:
|
|
273
|
-
continue
|
|
274
|
-
self.add_type(mimetype, subkeyname, strict)
|
|
275
|
-
except EnvironmentError:
|
|
276
|
-
continue
|
|
277
|
-
|
|
278
|
-
def guess_type(url, strict=True):
|
|
279
|
-
"""Guess the type of a file based on its URL.
|
|
280
|
-
|
|
281
|
-
Return value is a tuple (type, encoding) where type is None if the
|
|
282
|
-
type can't be guessed (no or unknown suffix) or a string of the
|
|
283
|
-
form type/subtype, usable for a MIME Content-type header; and
|
|
284
|
-
encoding is None for no encoding or the name of the program used
|
|
285
|
-
to encode (e.g. compress or gzip). The mappings are table
|
|
286
|
-
driven. Encoding suffixes are case sensitive; type suffixes are
|
|
287
|
-
first tried case sensitive, then case insensitive.
|
|
288
|
-
|
|
289
|
-
The suffixes .tgz, .taz and .tz (case sensitive!) are all mapped
|
|
290
|
-
to ".tar.gz". (This is table-driven too, using the dictionary
|
|
291
|
-
suffix_map).
|
|
292
|
-
|
|
293
|
-
Optional `strict' argument when false adds a bunch of commonly found, but
|
|
294
|
-
non-standard types.
|
|
295
|
-
"""
|
|
296
|
-
if _db is None:
|
|
297
|
-
init()
|
|
298
|
-
return _db.guess_type(url, strict)
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
def guess_all_extensions(type, strict=True):
|
|
302
|
-
"""Guess the extensions for a file based on its MIME type.
|
|
303
|
-
|
|
304
|
-
Return value is a list of strings giving the possible filename
|
|
305
|
-
extensions, including the leading dot ('.'). The extension is not
|
|
306
|
-
guaranteed to have been associated with any particular data
|
|
307
|
-
stream, but would be mapped to the MIME type `type' by
|
|
308
|
-
guess_type(). If no extension can be guessed for `type', None
|
|
309
|
-
is returned.
|
|
310
|
-
|
|
311
|
-
Optional `strict' argument when false adds a bunch of commonly found,
|
|
312
|
-
but non-standard types.
|
|
313
|
-
"""
|
|
314
|
-
if _db is None:
|
|
315
|
-
init()
|
|
316
|
-
return _db.guess_all_extensions(type, strict)
|
|
317
|
-
|
|
318
|
-
def guess_extension(type, strict=True):
|
|
319
|
-
"""Guess the extension for a file based on its MIME type.
|
|
320
|
-
|
|
321
|
-
Return value is a string giving a filename extension, including the
|
|
322
|
-
leading dot ('.'). The extension is not guaranteed to have been
|
|
323
|
-
associated with any particular data stream, but would be mapped to the
|
|
324
|
-
MIME type `type' by guess_type(). If no extension can be guessed for
|
|
325
|
-
`type', None is returned.
|
|
326
|
-
|
|
327
|
-
Optional `strict' argument when false adds a bunch of commonly found,
|
|
328
|
-
but non-standard types.
|
|
329
|
-
"""
|
|
330
|
-
if _db is None:
|
|
331
|
-
init()
|
|
332
|
-
return _db.guess_extension(type, strict)
|
|
333
|
-
|
|
334
|
-
def add_type(type, ext, strict=True):
|
|
335
|
-
"""Add a mapping between a type and an extension.
|
|
336
|
-
|
|
337
|
-
When the extension is already known, the new
|
|
338
|
-
type will replace the old one. When the type
|
|
339
|
-
is already known the extension will be added
|
|
340
|
-
to the list of known extensions.
|
|
341
|
-
|
|
342
|
-
If strict is true, information will be added to
|
|
343
|
-
list of standard types, else to the list of non-standard
|
|
344
|
-
types.
|
|
345
|
-
"""
|
|
346
|
-
if _db is None:
|
|
347
|
-
init()
|
|
348
|
-
return _db.add_type(type, ext, strict)
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
def init(files=None):
|
|
352
|
-
global suffix_map, types_map, encodings_map, common_types
|
|
353
|
-
global inited, _db
|
|
354
|
-
inited = True # so that MimeTypes.__init__() doesn't call us again
|
|
355
|
-
db = MimeTypes()
|
|
356
|
-
if files is None:
|
|
357
|
-
if _winreg:
|
|
358
|
-
db.read_windows_registry()
|
|
359
|
-
files = knownfiles
|
|
360
|
-
for file in files:
|
|
361
|
-
if os.path.isfile(file):
|
|
362
|
-
db.read(file)
|
|
363
|
-
encodings_map = db.encodings_map
|
|
364
|
-
suffix_map = db.suffix_map
|
|
365
|
-
types_map = db.types_map[True]
|
|
366
|
-
common_types = db.types_map[False]
|
|
367
|
-
# Make the DB a global variable now that it is fully initialized
|
|
368
|
-
_db = db
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
def read_mime_types(file):
|
|
372
|
-
try:
|
|
373
|
-
f = open(file)
|
|
374
|
-
except IOError:
|
|
375
|
-
return None
|
|
376
|
-
with f:
|
|
377
|
-
db = MimeTypes()
|
|
378
|
-
db.readfp(f, True)
|
|
379
|
-
return db.types_map[True]
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
def _default_mime_types():
|
|
383
|
-
global suffix_map
|
|
384
|
-
global encodings_map
|
|
385
|
-
global types_map
|
|
386
|
-
global common_types
|
|
387
|
-
|
|
388
|
-
suffix_map = {
|
|
389
|
-
'.tgz': '.tar.gz',
|
|
390
|
-
'.taz': '.tar.gz',
|
|
391
|
-
'.tz': '.tar.gz',
|
|
392
|
-
'.tbz2': '.tar.bz2',
|
|
393
|
-
'.txz': '.tar.xz',
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
encodings_map = {
|
|
397
|
-
'.gz': 'gzip',
|
|
398
|
-
'.Z': 'compress',
|
|
399
|
-
'.bz2': 'bzip2',
|
|
400
|
-
'.xz': 'xz',
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
# Before adding new types, make sure they are either registered with IANA,
|
|
404
|
-
# at http://www.isi.edu/in-notes/iana/assignments/media-types
|
|
405
|
-
# or extensions, i.e. using the x- prefix
|
|
406
|
-
|
|
407
|
-
# If you add to these, please keep them sorted!
|
|
408
|
-
types_map = {
|
|
409
|
-
'.a' : 'application/octet-stream',
|
|
410
|
-
'.ai' : 'application/postscript',
|
|
411
|
-
'.aif' : 'audio/x-aiff',
|
|
412
|
-
'.aifc' : 'audio/x-aiff',
|
|
413
|
-
'.aiff' : 'audio/x-aiff',
|
|
414
|
-
'.au' : 'audio/basic',
|
|
415
|
-
'.avi' : 'video/x-msvideo',
|
|
416
|
-
'.bat' : 'text/plain',
|
|
417
|
-
'.bcpio' : 'application/x-bcpio',
|
|
418
|
-
'.bin' : 'application/octet-stream',
|
|
419
|
-
'.bmp' : 'image/x-ms-bmp',
|
|
420
|
-
'.c' : 'text/plain',
|
|
421
|
-
# Duplicates :(
|
|
422
|
-
'.cdf' : 'application/x-cdf',
|
|
423
|
-
'.cdf' : 'application/x-netcdf',
|
|
424
|
-
'.cpio' : 'application/x-cpio',
|
|
425
|
-
'.csh' : 'application/x-csh',
|
|
426
|
-
'.css' : 'text/css',
|
|
427
|
-
'.dll' : 'application/octet-stream',
|
|
428
|
-
'.doc' : 'application/msword',
|
|
429
|
-
'.dot' : 'application/msword',
|
|
430
|
-
'.dvi' : 'application/x-dvi',
|
|
431
|
-
'.eml' : 'message/rfc822',
|
|
432
|
-
'.eps' : 'application/postscript',
|
|
433
|
-
'.etx' : 'text/x-setext',
|
|
434
|
-
'.exe' : 'application/octet-stream',
|
|
435
|
-
'.gif' : 'image/gif',
|
|
436
|
-
'.gtar' : 'application/x-gtar',
|
|
437
|
-
'.h' : 'text/plain',
|
|
438
|
-
'.hdf' : 'application/x-hdf',
|
|
439
|
-
'.htm' : 'text/html',
|
|
440
|
-
'.html' : 'text/html',
|
|
441
|
-
'.ico' : 'image/vnd.microsoft.icon',
|
|
442
|
-
'.ief' : 'image/ief',
|
|
443
|
-
'.jpe' : 'image/jpeg',
|
|
444
|
-
'.jpeg' : 'image/jpeg',
|
|
445
|
-
'.jpg' : 'image/jpeg',
|
|
446
|
-
'.js' : 'application/javascript',
|
|
447
|
-
'.ksh' : 'text/plain',
|
|
448
|
-
'.latex' : 'application/x-latex',
|
|
449
|
-
'.m1v' : 'video/mpeg',
|
|
450
|
-
'.man' : 'application/x-troff-man',
|
|
451
|
-
'.me' : 'application/x-troff-me',
|
|
452
|
-
'.mht' : 'message/rfc822',
|
|
453
|
-
'.mhtml' : 'message/rfc822',
|
|
454
|
-
'.mif' : 'application/x-mif',
|
|
455
|
-
'.mov' : 'video/quicktime',
|
|
456
|
-
'.movie' : 'video/x-sgi-movie',
|
|
457
|
-
'.mp2' : 'audio/mpeg',
|
|
458
|
-
'.mp3' : 'audio/mpeg',
|
|
459
|
-
'.mp4' : 'video/mp4',
|
|
460
|
-
'.mpa' : 'video/mpeg',
|
|
461
|
-
'.mpe' : 'video/mpeg',
|
|
462
|
-
'.mpeg' : 'video/mpeg',
|
|
463
|
-
'.mpg' : 'video/mpeg',
|
|
464
|
-
'.ms' : 'application/x-troff-ms',
|
|
465
|
-
'.nc' : 'application/x-netcdf',
|
|
466
|
-
'.nws' : 'message/rfc822',
|
|
467
|
-
'.o' : 'application/octet-stream',
|
|
468
|
-
'.obj' : 'application/octet-stream',
|
|
469
|
-
'.oda' : 'application/oda',
|
|
470
|
-
'.p12' : 'application/x-pkcs12',
|
|
471
|
-
'.p7c' : 'application/pkcs7-mime',
|
|
472
|
-
'.pbm' : 'image/x-portable-bitmap',
|
|
473
|
-
'.pdf' : 'application/pdf',
|
|
474
|
-
'.pfx' : 'application/x-pkcs12',
|
|
475
|
-
'.pgm' : 'image/x-portable-graymap',
|
|
476
|
-
'.pl' : 'text/plain',
|
|
477
|
-
'.png' : 'image/png',
|
|
478
|
-
'.pnm' : 'image/x-portable-anymap',
|
|
479
|
-
'.pot' : 'application/vnd.ms-powerpoint',
|
|
480
|
-
'.ppa' : 'application/vnd.ms-powerpoint',
|
|
481
|
-
'.ppm' : 'image/x-portable-pixmap',
|
|
482
|
-
'.pps' : 'application/vnd.ms-powerpoint',
|
|
483
|
-
'.ppt' : 'application/vnd.ms-powerpoint',
|
|
484
|
-
'.ps' : 'application/postscript',
|
|
485
|
-
'.pwz' : 'application/vnd.ms-powerpoint',
|
|
486
|
-
'.py' : 'text/x-python',
|
|
487
|
-
'.pyc' : 'application/x-python-code',
|
|
488
|
-
'.pyo' : 'application/x-python-code',
|
|
489
|
-
'.qt' : 'video/quicktime',
|
|
490
|
-
'.ra' : 'audio/x-pn-realaudio',
|
|
491
|
-
'.ram' : 'application/x-pn-realaudio',
|
|
492
|
-
'.ras' : 'image/x-cmu-raster',
|
|
493
|
-
'.rdf' : 'application/xml',
|
|
494
|
-
'.rgb' : 'image/x-rgb',
|
|
495
|
-
'.roff' : 'application/x-troff',
|
|
496
|
-
'.rtx' : 'text/richtext',
|
|
497
|
-
'.sgm' : 'text/x-sgml',
|
|
498
|
-
'.sgml' : 'text/x-sgml',
|
|
499
|
-
'.sh' : 'application/x-sh',
|
|
500
|
-
'.shar' : 'application/x-shar',
|
|
501
|
-
'.snd' : 'audio/basic',
|
|
502
|
-
'.so' : 'application/octet-stream',
|
|
503
|
-
'.src' : 'application/x-wais-source',
|
|
504
|
-
'.sv4cpio': 'application/x-sv4cpio',
|
|
505
|
-
'.sv4crc' : 'application/x-sv4crc',
|
|
506
|
-
'.swf' : 'application/x-shockwave-flash',
|
|
507
|
-
'.t' : 'application/x-troff',
|
|
508
|
-
'.tar' : 'application/x-tar',
|
|
509
|
-
'.tcl' : 'application/x-tcl',
|
|
510
|
-
'.tex' : 'application/x-tex',
|
|
511
|
-
'.texi' : 'application/x-texinfo',
|
|
512
|
-
'.texinfo': 'application/x-texinfo',
|
|
513
|
-
'.tif' : 'image/tiff',
|
|
514
|
-
'.tiff' : 'image/tiff',
|
|
515
|
-
'.tr' : 'application/x-troff',
|
|
516
|
-
'.tsv' : 'text/tab-separated-values',
|
|
517
|
-
'.txt' : 'text/plain',
|
|
518
|
-
'.ustar' : 'application/x-ustar',
|
|
519
|
-
'.vcf' : 'text/x-vcard',
|
|
520
|
-
'.wav' : 'audio/x-wav',
|
|
521
|
-
'.wiz' : 'application/msword',
|
|
522
|
-
'.wsdl' : 'application/xml',
|
|
523
|
-
'.xbm' : 'image/x-xbitmap',
|
|
524
|
-
'.xlb' : 'application/vnd.ms-excel',
|
|
525
|
-
# Duplicates :(
|
|
526
|
-
'.xls' : 'application/excel',
|
|
527
|
-
'.xls' : 'application/vnd.ms-excel',
|
|
528
|
-
'.xml' : 'text/xml',
|
|
529
|
-
'.xpdl' : 'application/xml',
|
|
530
|
-
'.xpm' : 'image/x-xpixmap',
|
|
531
|
-
'.xsl' : 'application/xml',
|
|
532
|
-
'.xwd' : 'image/x-xwindowdump',
|
|
533
|
-
'.zip' : 'application/zip',
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
# These are non-standard types, commonly found in the wild. They will
|
|
537
|
-
# only match if strict=0 flag is given to the API methods.
|
|
538
|
-
|
|
539
|
-
# Please sort these too
|
|
540
|
-
common_types = {
|
|
541
|
-
'.jpg' : 'image/jpg',
|
|
542
|
-
'.mid' : 'audio/midi',
|
|
543
|
-
'.midi': 'audio/midi',
|
|
544
|
-
'.pct' : 'image/pict',
|
|
545
|
-
'.pic' : 'image/pict',
|
|
546
|
-
'.pict': 'image/pict',
|
|
547
|
-
'.rtf' : 'application/rtf',
|
|
548
|
-
'.xul' : 'text/xul'
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
_default_mime_types()
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
if __name__ == '__main__':
|
|
556
|
-
import getopt
|
|
557
|
-
|
|
558
|
-
USAGE = """\
|
|
559
|
-
Usage: mimetypes.py [options] type
|
|
560
|
-
|
|
561
|
-
Options:
|
|
562
|
-
--help / -h -- print this message and exit
|
|
563
|
-
--lenient / -l -- additionally search of some common, but non-standard
|
|
564
|
-
types.
|
|
565
|
-
--extension / -e -- guess extension instead of type
|
|
566
|
-
|
|
567
|
-
More than one type argument may be given.
|
|
568
|
-
"""
|
|
569
|
-
|
|
570
|
-
def usage(code, msg=''):
|
|
571
|
-
print USAGE
|
|
572
|
-
if msg: print msg
|
|
573
|
-
sys.exit(code)
|
|
574
|
-
|
|
575
|
-
try:
|
|
576
|
-
opts, args = getopt.getopt(sys.argv[1:], 'hle',
|
|
577
|
-
['help', 'lenient', 'extension'])
|
|
578
|
-
except getopt.error, msg:
|
|
579
|
-
usage(1, msg)
|
|
580
|
-
|
|
581
|
-
strict = 1
|
|
582
|
-
extension = 0
|
|
583
|
-
for opt, arg in opts:
|
|
584
|
-
if opt in ('-h', '--help'):
|
|
585
|
-
usage(0)
|
|
586
|
-
elif opt in ('-l', '--lenient'):
|
|
587
|
-
strict = 0
|
|
588
|
-
elif opt in ('-e', '--extension'):
|
|
589
|
-
extension = 1
|
|
590
|
-
for gtype in args:
|
|
591
|
-
if extension:
|
|
592
|
-
guess = guess_extension(gtype, strict)
|
|
593
|
-
if not guess: print "I don't know anything about type", gtype
|
|
594
|
-
else: print guess
|
|
595
|
-
else:
|
|
596
|
-
guess, encoding = guess_type(gtype, strict)
|
|
597
|
-
if not guess: print "I don't know anything about type", gtype
|
|
598
|
-
else: print 'type:', guess, 'encoding:', encoding
|
shotgun_api3/lib/sgsix.py
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
-----------------------------------------------------------------------------
|
|
3
|
-
Copyright (c) 2009-2019, Shotgun Software Inc.
|
|
4
|
-
|
|
5
|
-
Redistribution and use in source and binary forms, with or without
|
|
6
|
-
modification, are permitted provided that the following conditions are met:
|
|
7
|
-
|
|
8
|
-
- Redistributions of source code must retain the above copyright notice, this
|
|
9
|
-
list of conditions and the following disclaimer.
|
|
10
|
-
|
|
11
|
-
- Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
-
this list of conditions and the following disclaimer in the documentation
|
|
13
|
-
and/or other materials provided with the distribution.
|
|
14
|
-
|
|
15
|
-
- Neither the name of the Shotgun Software Inc nor the names of its
|
|
16
|
-
contributors may be used to endorse or promote products derived from this
|
|
17
|
-
software without specific prior written permission.
|
|
18
|
-
|
|
19
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20
|
-
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
21
|
-
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
23
|
-
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
24
|
-
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
25
|
-
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
26
|
-
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
27
|
-
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
28
|
-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
29
|
-
"""
|
|
30
|
-
|
|
31
|
-
# This module contains addtional functions and variables to supplement the six
|
|
32
|
-
# module for python 2/3 compatibility.
|
|
33
|
-
|
|
34
|
-
from . import six
|
|
35
|
-
import io
|
|
36
|
-
import sys
|
|
37
|
-
|
|
38
|
-
# For python 3, the `file` type no longer exists, and open() returns an
|
|
39
|
-
# io.IOBase instance. We add file_types to allow comparison across python
|
|
40
|
-
# versions. See https://stackoverflow.com/questions/36321030#36321030
|
|
41
|
-
#
|
|
42
|
-
# This means that to test if a variable contains a file in both Python 2 and 3
|
|
43
|
-
# you can use an isinstance test like:
|
|
44
|
-
# isinstance(value, sgsix.file_types)
|
|
45
|
-
if six.PY3:
|
|
46
|
-
file_types = (io.IOBase, )
|
|
47
|
-
else:
|
|
48
|
-
file_types = (file, io.IOBase) # noqa warning for undefined `file` in python 3
|
|
49
|
-
|
|
50
|
-
# For python-api calls that result in an SSL error, the exception raised is
|
|
51
|
-
# different on Python 2 and 3. Store the approriate exception class in a
|
|
52
|
-
# variable to allow easier exception handling across Python 2/3.
|
|
53
|
-
if six.PY3:
|
|
54
|
-
import ssl
|
|
55
|
-
ShotgunSSLError = ssl.SSLError
|
|
56
|
-
else:
|
|
57
|
-
from .httplib2 import SSLHandshakeError
|
|
58
|
-
ShotgunSSLError = SSLHandshakeError
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
def normalize_platform(platform, python2=True):
|
|
62
|
-
"""
|
|
63
|
-
Normalize the return of sys.platform between Python 2 and 3.
|
|
64
|
-
|
|
65
|
-
On Python 2 on linux hosts, sys.platform was 'linux' appended with the
|
|
66
|
-
current kernel version that Python was built on. In Python3, this was
|
|
67
|
-
changed and sys.platform now returns 'linux' regardless of the kernel version.
|
|
68
|
-
See https://bugs.python.org/issue12326
|
|
69
|
-
This function will normalize platform strings to always conform to Python2 or
|
|
70
|
-
Python3 behavior.
|
|
71
|
-
|
|
72
|
-
:param str platform: The platform string to normalize
|
|
73
|
-
:param bool python2: The python version behavior to target. If True, a
|
|
74
|
-
Python2-style platform string will be returned (i.e. 'linux2'), otherwise
|
|
75
|
-
the modern 'linux' platform string will be returned.
|
|
76
|
-
|
|
77
|
-
:returns: The normalized platform string.
|
|
78
|
-
:rtype: str
|
|
79
|
-
"""
|
|
80
|
-
if python2:
|
|
81
|
-
return "linux2" if platform.startswith("linux") else platform
|
|
82
|
-
return "linux" if platform.startswith("linux") else platform
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
# sgsix.platform will mimick the python2 sys.platform behavior to ensure
|
|
86
|
-
# compatibility with existing comparisons and dict keys.
|
|
87
|
-
platform = normalize_platform(sys.platform)
|