13
13
DEFAULT_TAG = "python_sample_basic"
14
14
15
15
def dump_response (response ):
16
- print "Upload response:"
16
+ print ( "Upload response:" )
17
17
for key in sorted (response .keys ()):
18
- print " %s: %s" % (key , response [key ])
18
+ print ( " %s: %s" % (key , response [key ]) )
19
19
20
20
def upload_files ():
21
- print "--- Upload a local file"
21
+ print ( "--- Upload a local file" )
22
22
response = upload ("pizza.jpg" , tags = DEFAULT_TAG )
23
23
dump_response (response )
24
24
url , options = cloudinary_url (response ['public_id' ],
@@ -27,10 +27,10 @@ def upload_files():
27
27
height = 150 ,
28
28
crop = "fill"
29
29
)
30
- print "Fill 200x150 url: " + url
31
- print
30
+ print ( "Fill 200x150 url: " + url )
31
+ print ( "" )
32
32
33
- print "--- Upload a local file with custom public ID"
33
+ print ( "--- Upload a local file with custom public ID" )
34
34
response = upload ("pizza.jpg" ,
35
35
tags = DEFAULT_TAG ,
36
36
public_id = "custom_name" ,
@@ -42,10 +42,10 @@ def upload_files():
42
42
height = 150 ,
43
43
crop = "fit"
44
44
)
45
- print "Fit into 200x150 url: " + url
46
- print
45
+ print ( "Fit into 200x150 url: " + url )
46
+ print ( "" )
47
47
48
- print "--- Upload a local file with eager transformation of scaling to 200x150"
48
+ print ( "--- Upload a local file with eager transformation of scaling to 200x150" )
49
49
response = upload ("lake.jpg" ,
50
50
tags = DEFAULT_TAG ,
51
51
public_id = "eager_custom_name" ,
@@ -62,10 +62,10 @@ def upload_files():
62
62
height = 150 ,
63
63
crop = "scale" ,
64
64
)
65
- print "scaling to 200x150 url: " + url
66
- print
65
+ print ( "scaling to 200x150 url: " + url )
66
+ print ( "" )
67
67
68
- print "--- Upload by fetching a remote image"
68
+ print ( "--- Upload by fetching a remote image" )
69
69
response = upload ("http://res.cloudinary.com/demo/image/upload/couple.jpg" ,
70
70
tags = DEFAULT_TAG ,
71
71
)
@@ -77,10 +77,10 @@ def upload_files():
77
77
crop = "thumb" ,
78
78
gravity = "faces" ,
79
79
)
80
- print "Face detection based 200x150 thumbnail url: " + url
81
- print
80
+ print ( "Face detection based 200x150 thumbnail url: " + url )
81
+ print ( "" )
82
82
83
- print "--- Fetch an uploaded remote image, fitting it into 500x500 and reducing saturation"
83
+ print ( "--- Fetch an uploaded remote image, fitting it into 500x500 and reducing saturation" )
84
84
response = upload ("http://res.cloudinary.com/demo/image/upload/couple.jpg" ,
85
85
tags = DEFAULT_TAG ,
86
86
width = 500 ,
@@ -98,25 +98,25 @@ def upload_files():
98
98
radius = 10 ,
99
99
effect = "sepia" ,
100
100
)
101
- print "Fill 200x150, round corners, apply the sepia effect, url: " + url
102
- print
101
+ print ( "Fill 200x150, round corners, apply the sepia effect, url: " + url )
102
+ print ( "" )
103
103
104
104
def cleanup ():
105
105
response = resources_by_tag (DEFAULT_TAG )
106
106
count = len (response .get ('resources' , []))
107
107
if (count == 0 ):
108
- print "No images found"
108
+ print ( "No images found" )
109
109
return
110
- print "Deleting %d images..." % (count ,)
110
+ print ( "Deleting %d images..." % (count ,) )
111
111
delete_resources_by_tag (DEFAULT_TAG )
112
- print "Done!"
112
+ print ( "Done!" )
113
113
pass
114
114
115
115
if len (sys .argv ) > 1 :
116
116
if sys .argv [1 ] == 'upload' : upload_files ()
117
117
if sys .argv [1 ] == 'cleanup' : cleanup ()
118
118
else :
119
- print "--- Uploading files and then cleaning up"
120
- print " you can only one instead by passing 'upload' or 'cleanup' as an argument"
121
- print
119
+ print ( "--- Uploading files and then cleaning up" )
120
+ print ( " you can only one instead by passing 'upload' or 'cleanup' as an argument" )
121
+ print ( "" )
122
122
upload_files ()
0 commit comments